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

  • Follow


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


0
Reply dblack6674 (3021) 12/12/2003 12:11:18 AM

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
0
Reply mike103 (43) 12/12/2003 4:27:25 PM


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




0
Reply ruby-talk (359) 12/12/2003 6:33:11 PM

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.
>

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


0
Reply dave3622 (639) 12/13/2003 8:32:44 PM

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




0
Reply ruby-talk (359) 12/15/2003 6:05:51 PM

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.
>
I know that feeling :)

Thanks for the fixes: both work great.

Dave



0
Reply dave3622 (639) 12/15/2003 7:03:34 PM

5 Replies
33 Views

(page loaded in 0.712 seconds)


Reply: