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

Literal scalars with no non-empty lines produce wrong value sometimes #313

Closed
ingydotnet opened this issue Sep 19, 2021 · 2 comments
Closed
Labels
bug Something isn't working

Comments

@ingydotnet
Copy link

Describe the bug
Literal scalars with no non-empty lines produce wrong value sometimes

To Reproduce

- |+
___

_____

Where _ is a space.

Expected behaviour
Should be ["\n\n\n"]

Versions (please complete the following information):
1.10.2 and master as seen here: https://spec.yaml.io/main/playground/parser

@ingydotnet ingydotnet added the bug Something isn't working label Sep 19, 2021
@eemeli
Copy link
Owner

eemeli commented Sep 19, 2021

Are you sure? In a |+, the "keep" chomping means that:

In this case, the final line break and any trailing empty lines are considered to be part of the scalar’s content. These additional lines are not subject to folding.

Then, because the value only contains white space:

If a block scalar consists only of empty lines, then these lines are considered as trailing lines and hence are affected by chomping.

And finally, as it's using literal style:

Inside literal scalars, all (indented) characters are considered to be content, including white space characters.

Or is there a definition I've missed or misunderstood that defines the number of spaces that should be considered to be a part of the indentation for an empty block scalar?

@eemeli eemeli closed this as completed in 6cd70f4 Nov 7, 2021
@eemeli
Copy link
Owner

eemeli commented Nov 7, 2021

Verified in communication elsewhere that @ingydotnet was right; the indent level is determined by this:

8.1.1.1. Block Indentation Indicator
[...] If there is no non-empty line then the content indentation level is equal to the number of spaces on the longest line.

Nathan-Fenner pushed a commit to Nathan-Fenner/yaml that referenced this issue Nov 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants