as_yaml_auto {teal.reporter} | R Documentation |
Parse a named list to yaml
header for an Rmd
file
Description
Converts a named list into a yaml
header for Rmd
, handling output types and arguments
as defined in the rmarkdown
package. This function simplifies the process of generating yaml
headers.
Usage
as_yaml_auto(
input_list,
as_header = TRUE,
convert_logi = TRUE,
multi_output = FALSE,
silent = FALSE
)
Arguments
input_list |
( |
as_header |
( |
convert_logi |
( |
multi_output |
( |
silent |
( |
Details
This function processes a non-nested (flat) named list into a yaml
header for an Rmd
document.
It supports all standard Rmd
yaml
header fields, including author
, date
, title
, subtitle
,
abstract
, keywords
, subject
, description
, category
, and lang
.
Additionally, it handles output
field types and arguments as defined in the rmarkdown
package.
Value
character
with rmd_yaml_header
class,
result of yaml::as.yaml
, optionally wrapped with internal md_header()
.
Note
Only non-nested lists are automatically parsed.
Nested lists require direct processing with yaml::as.yaml
.
Examples
# nested so using yaml::as.yaml directly
as_yaml_auto(
list(author = "", output = list(pdf_document = list(toc = TRUE)))
)
# auto parsing for a flat list, like shiny input
input <- list(author = "", output = "pdf_document", toc = TRUE, keep_tex = TRUE)
as_yaml_auto(input)
as_yaml_auto(list(author = "", output = "pdf_document", toc = TRUE, keep_tex = "TRUE"))
as_yaml_auto(list(
author = "", output = "pdf_document", toc = TRUE, keep_tex = TRUE,
wrong = 2
))
as_yaml_auto(list(author = "", output = "pdf_document", toc = TRUE, keep_tex = 2),
silent = TRUE
)
input <- list(author = "", output = "pdf_document", toc = TRUE, keep_tex = "True")
as_yaml_auto(input)
as_yaml_auto(input, convert_logi = TRUE, silent = TRUE)
as_yaml_auto(input, silent = TRUE)
as_yaml_auto(input, convert_logi = FALSE, silent = TRUE)
as_yaml_auto(
list(
author = "", output = "pdf_document",
output = "html_document", toc = TRUE, keep_tex = TRUE
),
multi_output = TRUE
)
as_yaml_auto(
list(
author = "", output = "pdf_document",
output = "html_document", toc = "True", keep_tex = TRUE
),
multi_output = TRUE
)