yaml中“ | > |+ |-”的作用【转】

多行字符串可以使用|保留换行符,也可以使用>折叠换行。


this: |
  Foo
  Bar
that: >
  Foo
  Bar

转为 JavaScript 代码如下。


{ this: 'Foo
Bar
', that: 'Foo Bar
' }

+表示保留文字块末尾的换行,-表示删除字符串末尾的换行。


s1: |
  Foo

s2: |+
  Foo


s3: |-
  Foo

转为 JavaScript 代码如下。


{ s1: 'Foo
', s2: 'Foo


', s3: 'Foo' }

 转自

YAML 语言教程 - 阮一峰的网络日志
https://www.ruanyifeng.com/blog/2016/07/yaml.html

原文地址:https://www.cnblogs.com/paul8339/p/15424623.html