Provide either file or test. This input will be interpreted as yaml code, barring the exceptions given by the other options.

read.yaml(
  file = NULL,
  text = NULL,
  verbose = FALSE,
  keep.quotes = TRUE,
  quote.char = "__QUOTE__",
  colon.char = NULL,
  check.by.row = FALSE,
  utf8 = TRUE
)

Arguments

file

A character vector specifying a file to read from.

text

A character vector to directly interpret with yaml syntax. Takes precedent over file if both are provided.

verbose

Shall the input vector after modifications be shown? This vector is given to load_yaml()

keep.quotes

Normally quotes are interpreted by yaml. This allows to write quotes as normal and they are handled seperately.

quote.char

For internal handling quotes are replaced by quote.char and retransformed afterwards. The usage of quote.char within text or file is therefore forbidden if keep.quotes is TRUE.

colon.char

For internal handling colons are replaced by colon.char and retransformed afterwards. The usage of colon.char for verbatim usage within text or file is therefore forbidden if colon.handling is anything other than none.

check.by.row

Allows better error handling by singling through the lines.

utf8

If TRUE (Default) the provided character vector is forced to UTF-8 Encoding which is necessary for yaml.

colon.handling

There exists the following ways to deal with colons, with replace.colon.char being the default:

  • replace.colon.char: If one wants a colon within the generated text without it being interpreted by yaml, just use this option and write colon.char everywhere where a colon should be.

  • replace.all: This allows to use colons within the yaml text as normal, e.g. for quizzes. The first colon in each line is interpreted by yaml and all others are taken verbatim. When the line starts with - all colons are replaced. This implies that this option breaks multi-level yaml structure, so use with care! To keep specified multi-level yaml structures, one may provide allowed code words to colon.replace.exceptions. Providing for example "question" here allows using several quizzes with only one check button.

  • none: No replacement takes place. All colons are interpreted as yaml-colons.

colon.replace.exceptions

A vector with exceptions to allow for specified multi-level-yaml structures

space.after.colon

Should a space after a colon be forced? Caution: This only applies to actually written ":" within the text and not those provided by replace.colon.char.

Value

A list according to the provided yaml-structure

Examples

text.char = "question: What is 20*20? sc: - 100 - 200 - 400* - 500 success: Great, your answer is correct__COLON__ Super! failure: Try again." read.yaml(text=text.char)
#> $question #> [1] "What is 20*20?" #> #> $sc #> $sc[[1]] #> [1] 100 #> #> $sc[[2]] #> [1] 200 #> #> $sc[[3]] #> [1] "400*" #> #> $sc[[4]] #> [1] 500 #> #> #> $success #> [1] "Great, your answer is correct__COLON__ Super!" #> #> $failure #> [1] "Try again." #>