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

Fix Emitter to handle comments between a mapping key and a mapping/sequence value #814

Merged
merged 1 commit into from Jun 17, 2023
Merged

Conversation

ghost
Copy link

@ghost ghost commented Jun 3, 2023

This PR fixes #812

TL;DR the Emitter doesn't handle comment events that are emitted between a mapping key and a mapping value of the mapping or sequence type. So parsing and regenerate the following yaml will fail for example:

hello:
  # comment
  - world

becomes

hello
# this is a comment
:
- world

This PR moves the writing of the : symbol to be inside the block mapping key emission. Previously it was at the beginning of the block mapping value emission. If the mapping key is prefixed with a ? (explicit form), however, the : is still kept at the mapping value to preserve the existing behaviour, since in the explicit form, the comment does not break YAML syntax. That is,

? hello
# this is a comment
:
- world

is valid.

@EdwardCooke EdwardCooke merged commit 6f1e8dc into aaubry:master Jun 17, 2023
1 check passed
@aaubry
Copy link
Owner

aaubry commented Jun 17, 2023

This feature has been released in version 13.1.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Emitter doesn't handle comments between the mapping value and key
2 participants