These function extracts all YAML fragments from a file, returning a list of character vectors containing the extracted fragments.
extract_yaml_fragments( text, file, delimiterRegEx = "^---$", ignoreOddDelimiters = FALSE, encoding = "UTF-8", silent = TRUE )
text, file | As |
---|---|
delimiterRegEx | The regular expression used to locate YAML fragments. |
ignoreOddDelimiters | Whether to throw an error (FALSE) or delete the last delimiter (TRUE) if an odd number of delimiters is encountered. |
encoding | The encoding to use when calling |
silent | Whether to be silent ( |
A list of character vectors, where each vector corresponds to one YAML fragment in the source file or text.
extract_yaml_fragments(text=" --- First: YAML fragment id: firstFragment --- Outside of YAML --- Second: YAML fragment id: secondFragment parentId: firstFragment --- Also outside of YAML ");#> [[1]] #> [1] "---" "First: YAML fragment" " id: firstFragment" #> [4] "---" #> attr(,"class") #> [1] "yamlFragment" #> #> [[2]] #> [1] "---" "Second: YAML fragment" #> [3] " id: secondFragment" " parentId: firstFragment" #> [5] "---" #> attr(,"class") #> [1] "yamlFragment" #> #> attr(,"class") #> [1] "yamlFragments" "list"