YAML无空间折叠

时间:2014-08-08 17:17:43

标签: yaml line-breaks readability

如何在YAML(如长网址或文件名/路径)中断掉长字符串,而不换行成为空格?

示例输入:

url: >
  https://example.com/?what=Lorem
  %20ipsum%20dolor
  %20sit%20amet

输出:

{
  "url": "https://example.com/?what=Lorem %20ipsum%20dolor %20sit%20amet"
}

期望的输出:

{
  "url": "https://example.com/?what=Lorem%20ipsum%20dolor%20sit%20amet"
}

1 个答案:

答案 0 :(得分:2)

原来谷歌在我身上失败了,这个问题已经在这个网站上被询问和回答:Is there a way to represent a long string that doesnt have any whitespace on multiple lines in a YAML document?