Yaml多行字符串作为序列的一部分

Nep*_*oxx 16 syntax yaml

我无法弄清楚如何使用多行字符串作为yaml序列的一部分:

foo:
  - bar
  - bar2
  - > super duper long
 string that I would like
 to have on multiple lines
  - Another item
Run Code Online (Sandbox Code Playgroud)

可能吗?

fly*_*lyx 26

如果你想使用折叠标量:

foo:
  - bar
  - bar2
  - >
     super duper long
     string that I would like
     to have on multiple lines
  - Another item
Run Code Online (Sandbox Code Playgroud)

请注意,折叠标量的标题(与该行的行>)可能没有内容.

或者,您可以使用普通标量:

foo:
  - bar
  - bar2
  - super duper long
    string that I would like
    to have on multiple lines
  - Another item
Run Code Online (Sandbox Code Playgroud)

  • 我想指出,在这种情况下,缩进真的很挑剔(有充分的理由)。 (3认同)
  • 是.如果你想要折叠的标量不包括尾部换行符,请使用`> -`而不是`>`. (2认同)