Yaml多行文本格式
Yaml支持多行的字符串格式,可以通过下面两种格式指定:
- Block Scalars
- Flow Scalars
Block Scalars
Block Scalars格式的字符串由两部分组成:Scalar header 和 字符串
下面就是一个Block scalar字符串的例子:
example: >
Several lines of text,
with some "quotes" of various 'types',
and also a blank line:
plus another line at the end.
Scalars Header包含三种类型的Header:
-
Block Style Indicator
> 表示将字符串中的换行符替换为空格
| 表示将字符串中的换行符保留 -
Block Chomping Indicator
- 删除字符串后面所有的空行
**+**保留字符串后面所有的空行
默认是留空,意思是仅保留一行空行 -
Indentation Indicator
y