gpt4 book ai didi

yaml - 有没有办法从 YAML 多行键渲染新段落?

转载 作者:行者123 更新时间:2023-12-02 15:15:47 25 4
gpt4 key购买 nike

我有一个 YAML key 设置如下:

en:
info: |
Hello!

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.

Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

预期的渲染是:

Hello!

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.

Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

然而,实际上,它是这样渲染的:

Hello! Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

所以,我的问题是:YAML 是否可以按照我想要的方式呈现?或者,我是否需要为每个段落创建一个单独的键?

最佳答案

根据documentation of YAML ruby implementation ,你可以像这样使用它:

clipped: |
This has one newline.



same as "clipped" above: "This has one newline.\n"

stripped: |-
This has no newline.



same as "stripped" above: "This has no newline."

kept: |+
This has four newlines.



same as "kept" above: "This has four newlines.\n\n\n\n"

它将生成:

{  
'clipped' => "This has one newline.\n",
'same as "clipped" above' => "This has one newline.\n",
'stripped' => 'This has no newline.',
'same as "stripped" above' => 'This has no newline.',
'kept' => "This has four newlines.\n\n\n\n",
'same as "kept" above' => "This has four newlines.\n\n\n\n"
}

示例from here .

关于yaml - 有没有办法从 YAML 多行键渲染新段落?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34314924/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com