On % being a valid first character in a content line
Joshua Choi <[email protected]>
| Newsgroups | gmane.text.yaml.general |
|---|---|
| Message-ID | <[email protected]> |
To the YAML spec writers, According to the document markers section in the current spec, 'It is valid to have a “%” character at the start of a line (e.g. as the first character of a top-level mapping key).' This does not seem to be true under either the current spec or PyYAML. Implicit block mapping keys, in the case of plain scalars, are governed by ns-plain-one-line. This rule starts with ns-plain-first, which excludes c-indicator, which includes "%". In other words, the node cannot start with a "%". In fact, this is true for any plain scalar that begins with "%": it's not allowed. The spec seems to give the following example as valid YAML containing a node starting with "%": %YAML 1.2 --- %PS-Adobe-2.0: 777 According to InstantYAML (http://instantyaml.appspot.com/, uses PyYAML 3.08), this is an invalid YAML 1.1 stream—it tries to parse "%PS- Adobe-2.0: 777" as a directive. So: - In YAML 1.1, were "%" characters allowed to start plain scalar nodes at the beginning of a line? (I cannot find a section that talks about this feature in the old YAML 1.1 spec.) - Is InstantYAML's behavior correct? Is it correct for YAML 1.2 too? - The spec's rules seem to contradict this feature. Is this actually so? - Would it be possible to *change* this, so that non-directive lines cannot begin with "%"? Disallowing characters that are well known to be indicators, such as "%", "!", "?", etc. is reasonable and sane behavior—not just for the person writing the YAML parser, but also the person using the YAML documents. Making a strange exception just for the sake of letting a scalar beginning with "%" be a plain scalar places a burden on both people. This is, in my opinion, a higher cost than just requiring the scalars to be quoted, just like a scalar beginning with any other indicator. I ask this pleadingly, because the parser library I'm writing currently depends on this—allowing "%" to start a non- directive line would make parsing much more complicated. Sincerely, Joshua Choi ------------------------------------------------------------------------------ Crystal Reports - New Free Runtime and 30 Day Trial Check out the new simplified licensing option that enables unlimited royalty-free distribution of the report engine for externally facing server and web deployment. http://p.sf.net/sfu/businessobjects