find_yaml_fragment_indices {yum} | R Documentation |
These function finds all YAML fragments from a file, returning their start and end indices or all indices of all lines in the (non-)YAML fragments.
find_yaml_fragment_indices( file, text, invert = FALSE, returnFragmentIndices = TRUE, returnPairedIndices = TRUE, delimiterRegEx = "^---$", ignoreOddDelimiters = FALSE, silent = TRUE )
file |
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 |
invert |
Set to |
returnFragmentIndices |
Set to |
returnPairedIndices |
Whether to return two vectors with the start and end indices, or pair them up in vectors of 2. |
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. |
silent |
Whether to be silent (TRUE) or informative (FALSE). |
A list of numeric vectors with start and end indices
### Create simple text vector with the right delimiters simpleExampleText <- c( "---", "First YAML fragment", "---", "Outside of YAML", "This, too.", "---", "Second fragment", "---", "Also outside of YAML", "Another one outside", "Last one" ); yum::find_yaml_fragment_indices( text=simpleExampleText ); yum::find_yaml_fragment_indices( text=simpleExampleText, returnFragmentIndices = FALSE ); yum::find_yaml_fragment_indices( text=simpleExampleText, invert = TRUE );