问题
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?
回答1:
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.
来源:https://stackoverflow.com/questions/3517968/markdown-within-yaml-yaml-multi-line-escape-sequence