Split a document into the YAML metadata (which starts with ---
in the
beginning of the document) and the body.
yaml_body(x, ..., parse = TRUE)
A character vector of the document content.
Arguments to be passed to yaml_load()
.
Whether to parse the YAML data.
A list of components yaml
(the YAML data), lines
(starting and
ending line numbers of YAML), and body
(a character vector of the body
text). If YAML metadata does not exist in the document, the components
yaml
and lines
will be missing.
xfun::yaml_body(c("---", "title: Hello", "output: litedown::html_format", "---",
"", "Content."))
#> $yaml
#> $yaml$title
#> [1] "Hello"
#>
#> $yaml$output
#> [1] "litedown::html_format"
#>
#>
#> $body
#> [1] "" "" "" "" "" "Content."
#>
#> $lines
#> [1] 1 4
#>