These function deletes all YAML fragments from a file, returning a character vector without the lines that specified the YAML fragments.
delete_yaml_fragments(
file,
text,
delimiterRegEx = "^---$",
ignoreOddDelimiters = FALSE,
silent = TRUE
)
The path to a file to scan; if provided, takes precedence
over text
.
A character vector to scan, where every element should
represent one line in the file; can be specified instead of file
.
The regular expression used to locate YAML fragments.
Whether to throw an error (FALSE) or delete the last delimiter (TRUE) if an odd number of delimiters is encountered.
Whether to be silent (TRUE) or informative (FALSE).
A list of character vectors.
yum::delete_yaml_fragments(text=c("---", "First YAML fragment", "---",
"Outside of YAML",
"---", "Second fragment", "---",
"Also outside of YAML"));
#> [1] "Outside of YAML" "Also outside of YAML"