YAML treatment of '#' character in middle of a string

Hi –

I’m wondering whether the “#” and everything after it are
really supposed to be taken out of the string in this
example:

irb(main):015:0> YAML.load("—\nstring: one # two")
=> {“string”=>“one”}

I guess I can wrap it all in quotation marks, but I didn’t
think I had to.

david

···


David A. Black
dblack@wobblini.net

In article Pine.LNX.4.44.0312111608390.6969-100000@wobblini.net,

···

David A. Black dblack@wobblini.net wrote:

Hi –

I’m wondering whether the “#” and everything after it are
really supposed to be taken out of the string in this
example:

irb(main):015:0> YAML.load(“—\nstring: one # two”)
=> {“string”=>“one”}

I guess I can wrap it all in quotation marks, but I didn’t
think I had to.

http://www.yaml.org/spec/#.-syntax-throw-Throwaway-comments-

suggests this is the right behaviour; so the quites are necessary.

Hope this helps,

Mike

mike@stok.co.uk | The “`Stok’ disclaimers” apply.
http://www.stok.co.uk/~mike/ | GPG PGP Key 1024D/059913DA
mike@exegenix.com | Fingerprint 0570 71CD 6790 7C28 3D60
http://www.exegenix.com/ | 75D2 9EC4 C1C0 0599 13DA

Treatment of the comment character has long been discussed on the yaml-core
list and has changed a bit in the spec over this year. Currently, any pound
character which is preceded by space trims to the next newline as a comment.
Yes, quotes can overcome this weakness.

···

plain: one #this is a comment
quoted: ‘one # this is not a comment’
also plain: one#this is not a comment
and also: one# this is also not a comment

I do agree with the rule. I can see compelling reasons to follow plain
scalars with descriptive comments. I don’t see the compelling reason for the
space-pound in plain scalars. But if you have a good use case, hop on
yaml-core ML and lay it out for us, Brother Black.

_why

On Thursday 11 December 2003 05:11 pm, David A. Black wrote:

Hi –

I’m wondering whether the “#” and everything after it are
really supposed to be taken out of the string in this
example:

irb(main):015:0> YAML.load(“—\nstring: one # two”)
=> {“string”=>“one”}

I guess I can wrap it all in quotation marks, but I didn’t
think I had to.

david

Hi –

In article Pine.LNX.4.44.0312111608390.6969-100000@wobblini.net,

Hi –

I’m wondering whether the “#” and everything after it are
really supposed to be taken out of the string in this
example:

irb(main):015:0> YAML.load(“—\nstring: one # two”)
=> {“string”=>“one”}

I guess I can wrap it all in quotation marks, but I didn’t
think I had to.

YAML™ Specification Index

suggests this is the right behaviour; so the quites are necessary.

I’d read that part of the spec yesterday and come away uncertain
(hence my question :slight_smile: mainly because I thought that the last
line of the example:

this: | # Comments may trail block indicators.
contains three lines of text.
The third one starts with a
# character. This isn’t a comment.

should be a comment if my line contained a comment. But now I think
I’m grasping the idea that indentation on the left isn’t counted as
whitespace for purposes of defining a comment as whitespace followed
optionally by ‘#’ and so on.

David

···

On Sat, 13 Dec 2003, Mike Stok wrote:

David A. Black dblack@wobblini.net wrote:


David A. Black
dblack@wobblini.net

As it stands right now, though, yaml can’t read it’s own output, which
strikes me as a fairly major issue;

require ‘yaml’
fred = “Call the method #dave
str = YAML.dump(fred)
fred1 = YAML.load(str)
puts fred1 # => 'Call the method ’

For me, this, combined with the stuct bug I mentioned over on -core,
makes YAML unusable for my RI work. At the very least, shouldn’t ::dump
escape the output?

Cheers

Dave

···

On Dec 12, 2003, at 12:33, why the lucky stiff wrote:

Treatment of the comment character has long been discussed on the
yaml-core
list and has changed a bit in the spec over this year. Currently, any
pound
character which is preceded by space trims to the next newline as a
comment.
Yes, quotes can overcome this weakness.

I do agree with the rule. I can see compelling reasons to follow plain
scalars with descriptive comments. I don’t see the compelling reason
for the
space-pound in plain scalars. But if you have a good use case, hop on
yaml-core ML and lay it out for us, Brother Black.

Yeah, that bug was fixed a few hours after you reported it. Checked into Ruby
CVS. I could have sworn I responded, but I must have … got distracted.

Got a fix for this bug, too. Testing it out just now.

_why

···

On Saturday 13 December 2003 01:32 pm, Dave Thomas wrote:

As it stands right now, though, yaml can’t read it’s own output, which
strikes me as a fairly major issue;

require ‘yaml’
fred = “Call the method #dave
str = YAML.dump(fred)
fred1 = YAML.load(str)
puts fred1 # => 'Call the method ’

For me, this, combined with the stuct bug I mentioned over on -core,
makes YAML unusable for my RI work. At the very least, shouldn’t ::dump
escape the output?

Cheers

Dave

I know that feeling :slight_smile:

Thanks for the fixes: both work great.

Dave

···

On Dec 15, 2003, at 12:05, why the lucky stiff wrote:

Yeah, that bug was fixed a few hours after you reported it. Checked
into Ruby
CVS. I could have sworn I responded, but I must have … got
distracted.