当我执行message.to_yaml时,我得到以下输出
mainText: "<h3 class=\"right_column\">Mark</h3> ... "
但我想要以下列格式输出
mainText: |
<h3 class="right_column">Mark</h3>
...
如何强制ruby使用管道折叠多行字符串。
我试过
message.to_yaml(:UseFold => true, :UseBlock => true)
但它不起作用
由于
答案 0 :(得分:1)
irb(main):011:0> puts "Hi!\nIf your string has newlines...\nfolding is by default".to_yaml
--- |-
Hi!
If your string has newlines...
folding is by default