Version 7 (modified by py4fun@…, 7 years ago) (diff)

space after : is required

: in the flow context

It's not clear what is the best solution:

  1. Forbid ':' for plain scalars in the flow context and use it to separate keys from values. his syntax is more Python-compatible. For instance, it allows
        {1:2,2:3,3:5,4:7,5:11,6:13,7:17,8:23}    # prime numbers
  2. Allow ':' for plain scalars in the flow context provided it's not followed by a whitespace. Require ': ' to separate keys from values. This will allow unquoted time values and URLs in the flow context. For instance,
        [12:45,]    # Time and URL

What do you think? Please leave an excerpt of your document which produced an error here, in the wiki page.

presentation: {type: textarea_tag, params: rich=true tinymce_options=width:500 }

this is a problem for me, please observe:

found unexpected ':'
 in "<string>", line 3, column 14:
 url: http://localhost/

Here's another real-world example:

      dhcp: [
          group: linux_i386X,
          mac: 99:19:b9:fa:37:99,

I would definitely agree for the colon-space solution (it fixes these examples, but not, I suppose, every issue.)

Yet another example:

found unexpected ':'
  in "<string>", line 1, column 11:
    urls: []

It would make sense to require ': ' when parsing a value - if you see a:b when parsing a value, you should treat that as the string "a:b". When parsing a key-value in a mapping, it should be possible to allow either url: (no space) or url: as you know from context that you're expecting a : to terminate a key. Of course, colons in keys are pathological and should not be tolerated ;-)

Solution #1 does not conform with  YAML 1.1 and  YAML 1.2. YAML 1.2 does not enforce space after ':' only if the value is in quotes.