String¶
YAML folding¶
https://stackoverflow.com/questions/3790454/how-do-i-break-a-string-in-yaml-over-multiple-lines
>,|: "clip": keep the line feed, remove the trailing blank lines>-,|-: "strip": remove the line feed, remove the trailing blank lines>+,|+: "keep": keep the line feed, keep trailing blank lines
Example:
Is the same as this:Only way to concatenate lines without spaces
double-quoted style(\ and " must be escaped by \, newlines can be inserted with a literal \n sequence) will be converted to:
string quotes¶
https://leopathu.com/content/string-quotes-yaml-file
https://stackoverflow.com/questions/19109912/yaml-do-i-need-quotes-for-strings-in-yaml
https://stackoverflow.com/questions/3790454/how-do-i-break-a-string-in-yaml-over-multiple-lines/21699210#21699210
Strings containing any of the following characters must be quoted
{ } [ ] < > = ! @ # % & * - ? : , | \not always true, depending on where the character isit's more convenient to use single quotes, without escaping any backslash \
double quotes provide a way to express arbitrary strings, by using \ to escape characters and sequences
"Add new line\n"
strings must be quoted¶
string is
trueorfalse(otherwise, it would be treated as a boolean value)string is
nullor~(otherwise, it would be considered as a null value)string looks like a
number, such as integers (11), floats (3.14) and exponential numbers (1e2) (otherwise, it would be treated as a numeric value)string looks like a
date(e.g. 2014-12-31) (otherwise it would be automatically converted into a Unix timestamp)
Strings only need quotation if (the beginning of) the value can be misinterpreted as a data type or the value contains a ":" (could get misinterpreted as key):
foo: "{{ bar }}"can be misinterpreted as datatype dictfoo: "bar:baz"can be misinterpreted as key>interior line breaks are stripped out|interior line breaks are preserved as\n>-or|-no line breaks at the end