Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Markdown within yaml / yaml multi-line escape sequence?

Is it possible to store unescaped markdown documents in yaml? I've tested

key:|+ 
    markdown text block that could have any combination of line breaks, >, -, :, ', " etc etc. 

This does not work. I need something like CDATA or python style triple-quotes for yamal. Any ideas?

like image 349
user331782 Avatar asked Aug 19 '10 01:08

user331782


People also ask

How do you write a multiline in YAML?

Multi-line blocks and long strings. YAML also supports writing strings on multiple lines in your YAML, with two different styles: literal and folded. Those are represented by a | (for literal style) or > (for folded style) header line (see examples below), and we will go into their differences soon.

How do you escape special characters in YAML file?

How do you escape quotes in YAML? In single quoted strings the single quote character can be escaped by prefixing it with another single quote, basically doubling it. Backslashes in single quoted strings do not need to be escaped.

How do you insert a line break in YAML?

Use >- or |- instead if you don't want a linebreak appended at the end. Use "..." if you need to split lines in the middle of words or want to literally type linebreaks as \n : key: "Antidisestab\ lishmentarianism. \n\nGet on it."


1 Answers

In literal style of scalar type (what you used in example) line brakes needs still to be "escaped" (in this case intended correctly).

And you can only have printable characters.

I am not fammiliar with markdown, but in case you would need to save unprintable characters, you would definitelly to escape them.

From Yaml specification:

To ensure readability, YAML streams use only the printable subset of the Unicode character set. The allowed character range explicitly excludes the C0 control block #x0-#x1F (except for TAB #x9, LF #xA, and CR #xD which are allowed), DEL #x7F, the C1 control block #x80-#x9F (except for NEL #x85 which is allowed), the surrogate block #xD800-#xDFFF, #xFFFE, and #xFFFF.

On input, a YAML processor must accept all Unicode characters except those explicitly excluded above.

On output, a YAML processor must only produce acceptable characters. Any excluded characters must be presented using escape sequences.

like image 61
user482745 Avatar answered Sep 24 '22 19:09

user482745