【问题标题】:YAML Folding without spacesYAML 无空格折叠
【发布时间】:2025-11-29 19:30:01
【问题描述】:

如何打破 YAML 中的长字符串(如长 url,或文件名/路径),而换行符不变成空格?

示例输入:

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"
}

【问题讨论】:

    标签: yaml line-breaks readability


    【解决方案1】:

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

    【讨论】: