Difference between revisions of "LRM yaml Support"
(→Lists) |
(→Yaml Parser) |
||
Line 1: | Line 1: | ||
== Yaml Parser == |
== Yaml Parser == |
||
− | LRM supports YAML 1.2 and uses the snakeyaml1.2 engine to parse files. Information on snakeyaml can be found [https://bitbucket.org/asomov/snakeyaml-engine at |
+ | LRM supports YAML 1.2 and uses the snakeyaml1.2 engine to parse files. Information on snakeyaml can be found at [https://bitbucket.org/asomov/snakeyaml-engine snakeyaml]. Information about learning YAML can be found at [https://learnxinyminutes.com/docs/yaml/ Learn YAML] |
== Supported YAML syntax == |
== Supported YAML syntax == |
Revision as of 16:45, 26 November 2018
Contents
Yaml Parser
LRM supports YAML 1.2 and uses the snakeyaml1.2 engine to parse files. Information on snakeyaml can be found at snakeyaml. Information about learning YAML can be found at Learn YAML
Supported YAML syntax
The following syntax is supported by LRM.
Ordered Map
# Explicitly typed ordered map (dictionary). Bestiary: !!omap - aardvark: African pig-like ant eater. Ugly. - anteater: South-American ant eater. Two species. - anaconda: South-American constrictor snake. Scaly. # Flow style Numbers: !!omap [ 1: one, 2: two, 3: three ] #Implicit ordered map Numbers: - {1: one} - {2: two} - {3: three}
Lists
twobytwotable: - - 'a1' - "a2" - - b1 - b2 twobytwotable2: - [a1, a2] - ['b1', "b2"] list: - - 'a1' - - "b1" - - c1
Literal Blocks
# Multiple-line strings can be written either as a 'literal block' (using |), literal_block: | This entire block of text will be the value of the 'literal_block' key, with line breaks being preserved. The literal continues until de-dented, and the leading indentation is stripped. Any lines that are 'more-indented' keep the rest of their indentation - these lines will be indented by 4 spaces.
Unsupported YAML syntax
The following syntax is not supported by LRM. If a file contains unsupported syntax then an error will occur when reading the file.
Set format
A set is an unordered collection of nodes such that no two nodes are equal.
baseball players: !!set ? Mark McGwire ? Sammy Sosa ? Ken Griffey # Flow style baseball teams: !!set { Boston Red Sox, Detroit Tigers, New York Yankees }
Sequence format
A sequence is a collection indexed by sequential integers starting with zero.
Block style: !!seq :- Mercury :- Pluto Flow style: !!seq [ Mercury, Pluto ]
Multiple Documents
A file that contains multiple documents, indicated by '---' and '...' is not supported.
--- doc1: value1 ... --- doc2: value2 ...
Blank Values
An empty string, such as is allowed but a blank value is not.
this_is_valid: "" this_is_invalid: this_is_valid2:
Multi-lines that are not literal strings
key1: 'this\n' is \n a test'
Folded Style (>)
folded_style: > This entire block of text will be the value of 'folded_style', but this time, all newlines will be replaced with a single space. Blank lines, like above, are converted to a newline character. 'More-indented' lines keep their newlines, too - this text will appear over two lines.
Mixing sequence with simple key/values
Sequence and simple key/values cannot be in the same file
- key: alpha_server_is_not_valid translation: "" msg: "The server does not exist" - key: alpha_distributable_is_not_valid translation: "" msg: "The distributable does not exist" simplekey: Simple value