Parse YAML-style Options from Shinylive Code Blocks
Source:R/quarto-cell-parser.R
parse_yaml_options.Rd
Parses YAML-style configuration options from Shinylive code block headers.
These options appear as lines prefixed with '#|'
and follow a simplified
YAML-like syntax for key-value pairs.
Value
A named list of parsed options where:
Array values (e.g.,
'[1, 2, 3]'
) are converted to character vectorsBoolean values ('true'/'false') are converted to logical values
Numeric values are converted to numeric type
Other values remain as character strings
Details
The function handles several value types:
Arrays: Values in the format
'[item1, item2, ...]'
Booleans: Values 'true' or 'false'
Numbers: Integer values
Strings: All other values
Lines that don't contain a colon (':'
) are ignored.
Examples
if (FALSE) { # \dontrun{
# Parse various types of options
yaml_lines <- c(
"#| viewerHeight: 500",
"#| components: [slider,button]",
"#| fullWidth: true",
"#| title: My App"
)
options <- parse_yaml_options(yaml_lines)
# Results in:
# list(
# viewerHeight = 500,
# components = c("slider", "button"),
# fullWidth = TRUE,
# title = "My App"
# )
} # }