Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

YAML 1.2 spec: Example 8.2. Block Indentation Indicator #253

Closed
asomov opened this issue Feb 17, 2016 · 3 comments
Closed

YAML 1.2 spec: Example 8.2. Block Indentation Indicator #253

asomov opened this issue Feb 17, 2016 · 3 comments

Comments

@asomov
Copy link

asomov commented Feb 17, 2016

When I try to parse example 8.2 at http://www.yaml.org/spec/1.2/spec.html#Block
I got:

[ 'detected\n',
  '\n\n# detected\n',
  '\n explicit\n',
  '\n\t\ndetected\n' ]

But according to the canonical form last two lines must not get a leading '\n':

%YAML 1.2

---
!!seq [
  !!str "detected\n",
  !!str "\n\n# detected\n",
  !!str "·explicit\n",
  !!str "\t·detected\n",
]
@dervus dervus added the bug label Feb 17, 2016
@dervus
Copy link
Collaborator

dervus commented Feb 17, 2016

For fix squad reference:

  1. Seems like explicit indent identifier adds a linefeed to begin of result. (fixed by Fix block scalar leading/trailing newlines #278)
  2. Folding works wrong when concatenating line "\t" with "foo". Expected: "\t foo"; actual: "\t\nfoo".

aepsilon added a commit to aepsilon/js-yaml that referenced this issue Apr 5, 2016
Fixes nodeca#253: loader should not add an extra newline at the beginning
of block scalars that have an explicit indentation indicator.

Cause: "Detected indent" was assumed logically equivalent to
"did read non-empty line". This no longer holds with an
indentation indicator: indent is detected before any content is read.

Fixes nodeca#276: loader should not remove a trailing newline
for block scalars with "+" chomping.

Cause: "+" chomping didn't account for the last content newline
before the trailing empty lines.
aepsilon added a commit to aepsilon/js-yaml that referenced this issue Apr 15, 2016
Fixes nodeca#253: loader should not add an extra newline at the beginning
of block scalars that have an explicit indentation indicator.

Cause: "Detected indent" was assumed logically equivalent to
"did read non-empty line". This no longer holds with an
indentation indicator: indent is detected before any content is read.

Fixes nodeca#276: loader should not remove a trailing newline
for block scalars with "+" chomping.

Cause: "+" chomping didn't account for the last content newline
before the trailing empty lines.
@dervus
Copy link
Collaborator

dervus commented Apr 15, 2016

Second part is still not clear. @aepsilon pointed that it's possible spec bug in #278

For part 2 of #253, it appears the spec has an error.

' \t' is a more-indented line according to the grammar, since \t is s-white.

[177] s-nb-spaced-text(n) ::= s-indent(n) s-white nb-char*

(Rule [175] for folded lines doesn't match)
Therefore join with a newline.

LibYAML 0.1.5 agrees.
It throws an error on the example, but if you specify indent with>1, it also produces '\t\ndetected\n'.

I think this needs further investigation. I'll need to review that part of the spec by myself as well.

@dervus dervus reopened this Apr 15, 2016
@puzrin puzrin mentioned this issue Feb 28, 2017
9 tasks
@asomov
Copy link
Author

asomov commented Jan 1, 2022

too old

@asomov asomov closed this as completed Jan 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants