YAML
How do I break a string in YAML over multiple lines?
- Use > most of the time: interior line breaks are stripped out, although you get one at the end:
key: >This is my very very verylong string.
Become → This is my very very very long string.\n
- Use | if you want those line breaks to be preserved as \n (for instance, embedded markdown with paragraphs).
key: |This is my very very verylong string.
Become → This is my very very very\n
long string.\n
- Other options with summary table
> | " ' >- >+ |- |+-------------------------|------|-----|-----|-----|------|------|------|------Trailing spaces | Kept | Kept | | | | Kept | Kept | Kept | KeptSingle newline => | _ | \n | _ | _ | _ | _ | _ | \n | \nDouble newline => | \n | \n\n | \n | \n | \n | \n | \n | \n\n | \n\nFinal newline => | \n | \n | | | | | \n | | \nFinal dbl nl's => | | | | | | | Kept | | KeptIn-line newlines | No | No | No | \n | No | No | No | No | NoSpaceless newlines| No | No | No | \ | No | No | No | No | NoSingle quote | ' | ' | ' | ' | '' | ' | ' | ' | 'Double quote | " | " | " | \" | " | " | " | " | "Backslash | \ | \ | \ | \\ | \ | \ | \ | \ | \" #", ": " | Ok | Ok | No | Ok | Ok | Ok | Ok | Ok | OkCan start on same | No | No | Yes | Yes | Yes | No | No | No | Noline as key
- More details & Credit https://stackoverflow.com/a/21699210/1872200
Loading comments...