UseFold in YAML

Hi,

while we’re at it …

I try to make YAML fold newlines. Sometimes it does, sometimes it
doesn’t. Does anyone has an idea of what’s happening here? Or is
this just the way YAML works? Thanks.

require ‘yaml’

text =
"Just got my (dead-tree, printed-on-paper, " +
"I don’t know if there’s a web " +
“version) copy of Linux Magazine for September, 2002.” +
"There’s an article by " +
“Dave Thomas about building networked applications in Ruby.” +
“Props to Dave!” # i.e., no newlines

hash = { ‘key’ => text }

puts text.to_yaml( :UseFold => true,
:BestWidth => 15 )

produces:
— >-
Just got my
(dead-tree,
printed-on-pap
r, I don’t know
if there’s a
web version)
copy of Linux
Magazine for
September,
2002. There’s
an article by
Dave Thomas
about building
networked
applications in
Ruby. Props to
Dave!

puts hash.to_yaml( :UseFold => true,
:BestWidth => 15 )

produces:

···

key: “Just got my (dead-tree, printed-on-paper, I don’t know if
there’s a web version) copy of Linux Magazine for September, 2002.
There’s an article by Dave Thomas about building networked
applications in Ruby. Props to Dave!”

Gerard A.W. Vreeswijk wrote:

I try to make YAML fold newlines. Sometimes it does, sometimes it
doesn’t. Does anyone has an idea of what’s happening here? Or is
this just the way YAML works? Thanks.

i hate the way folding works right now. it’s quite nonsensical. i’d
like to improve it so it could be customized at each node.

where str', str2’, `str3’ contains long text

str.to_yaml = {:fold => true, :width => 80}
str2.to_yaml = {:fold => false}
str3.to_yaml = {:fold => true, :keep => false}

root settings will be overriden by individual singleton’s settings

[str, str2, str3].to_yaml( :fold => true }

the keep' setting refers to keeping end newlines (the '+' and '-' options in YAML). with keep’ set to false, no effort would be made to
keep newlines.

how does this sound?

_why

Great, as long as YAML4r’s (or should I say YAML’s) folding behaviour on long strings is consistent,
and persists deeper down the datastructures.

···

On Mon, 15 Mar 2004 05:30:44 +0900, why the lucky stiff ruby-talk@whytheluckystiff.net wrote:

how does this sound?