gpt4 book ai didi

ruby - 为什么 psych yaml 解释器在 80 个字符左右添加换行符?

转载 作者:数据小太阳 更新时间:2023-10-29 06:41:08 25 4
gpt4 key购买 nike

Psych 是自 ruby​​ 1.9.3 以来的默认 yaml 引擎

为什么,为什么 psych 在其输出中添加换行符?检查下面的示例。

ruby -v # => ruby 1.9.3p374 (2013-01-15 revision 38858) [x86_64-linux]
require 'yaml'

"this absolutely normal sentence is more than eighty characters long because it IS".to_yaml
# => "--- this absolutely normal sentence is more than eighty characters long because it\n IS\n...\n"

YAML::ENGINE.yamler = 'syck'

"this absolutely normal sentence is more than eighty characters long because it IS".to_yaml
# => "--- this absolutely normal sentence is more than eighty characters long because it IS\n"

最佳答案

您必须配置 psych 的 #to_yaml 选项。您很可能会在这里找到它:

ruby-1.9.3-p125/ext/psych/emitter.c

然后你可以这样做:

yaml.to_yaml(options = {:line_width => -1})

关于ruby - 为什么 psych yaml 解释器在 80 个字符左右添加换行符?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17859864/

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