J
Jamis Buck
I've run into the following odd behavior using YAML:
# a = "something: >\r\n Some text with a\r\n newline in it.\r\n"
# b = "something: >\n Some text with a\n newline in it.\n"
# p YAML.load(a)
{"something"=>"Some text with a\nnewline in it.\n"}
# p YAML.load(b)
{"something"=>"Some text with a newline in it.\n"}
Should this be reported as a bug, or are there still known issues with
how Ruby's yaml processor handles these situations? This kind of threw
us for a loop in some code generation routines I'm writing at work,
since we expected the resulting text to all exist on one line. For now,
the work-around is simple -- just strip out all newlines from the
string. Just wanted to raise a little warning flag to the list, though,
and ask if anyone else had run into this.
Oh, and:
# ruby -v
ruby 1.8.1 (2004-04-24) [i686-linux-gnu]
--
Jamis Buck
(e-mail address removed)
http://www.jamisbuck.org/jamis
ruby -h | ruby -e
'a=[];readlines.join.scan(/-(.)\[e|Kk(\S*)|le.l(..)e|#!(\S*)/) {|r| a <<
r.compact.first };puts "\n>#{a.join(%q/ /)}<\n\n"'
# a = "something: >\r\n Some text with a\r\n newline in it.\r\n"
# b = "something: >\n Some text with a\n newline in it.\n"
# p YAML.load(a)
{"something"=>"Some text with a\nnewline in it.\n"}
# p YAML.load(b)
{"something"=>"Some text with a newline in it.\n"}
Should this be reported as a bug, or are there still known issues with
how Ruby's yaml processor handles these situations? This kind of threw
us for a loop in some code generation routines I'm writing at work,
since we expected the resulting text to all exist on one line. For now,
the work-around is simple -- just strip out all newlines from the
string. Just wanted to raise a little warning flag to the list, though,
and ask if anyone else had run into this.
Oh, and:
# ruby -v
ruby 1.8.1 (2004-04-24) [i686-linux-gnu]
--
Jamis Buck
(e-mail address removed)
http://www.jamisbuck.org/jamis
ruby -h | ruby -e
'a=[];readlines.join.scan(/-(.)\[e|Kk(\S*)|le.l(..)e|#!(\S*)/) {|r| a <<
r.compact.first };puts "\n>#{a.join(%q/ /)}<\n\n"'