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

Blank Line Comments skipped #498

Open
DeltaOrion opened this issue Apr 12, 2022 · 8 comments
Open

Blank Line Comments skipped #498

DeltaOrion opened this issue Apr 12, 2022 · 8 comments
Labels

Comments

@DeltaOrion
Copy link

Version: 6.0.1
Issue: If a key has a comment with no content inside of the comment then that line and any above lines will not be counted as apart of comments for that node

When reading the following yaml file

#comment line 1
#comment line 2
#
#comment line 4
key: value

When reading the comments from the node key using YamlNode#comment()#value() It only returns [comment line 4]. I believe it should return all 4 comment lines that being, [comment line 1, comment line 2, , comment line 4]

However, when reading this yaml file

#comment line 1
#comment line 2
#abc
#comment line 4
key: value

Reading the comments from the node key using YamlNode#comment#value() returns all 4 comment lines correctly that being [comment line 1, comment line 2, abc, comment line 4]

@zoeself
Copy link
Collaborator

zoeself commented Apr 12, 2022

@DeltaOrion thank you for reporting this. I'll assign someone to take care of it soon.

@zoeself
Copy link
Collaborator

zoeself commented Apr 12, 2022

@amihaiemil I couldn't find any assignee for this task. This is either because there are no contributors with role DEV available or because the project does not have enough funds.

Please, make sure there is at least one available contributor with the required role and the project can afford to pay them.

@amihaiemil
Copy link
Member

@DeltaOrion I'm no sure this is a bug. If I remember well, this was intended behaviour: blank lines and blank comment lines are ignored. Let's leave it open for a while and see if someone else has this issue or other opinion :D

@DeltaOrion
Copy link
Author

https://yaml.org/spec/1.2.2/#comments

According to the YAML spec comments aren't associated to a particular node. But for having any kind of comment support it is only natural that it is attached to a node because comments are almost always there to describe the purpose of the node. Thus, As to whether this is intended behavior would really depend on your requirements. It seems more natural to me that all of the consecutive comment lines above the node are counted as comments whether or not the comment line has content or not but at the end of the day it is up to your teams requirements.

But blank lines aren't really ignored because

When reading

#comment line 1
#comment line 2
#comment line 3

key: value

It produces the output [comment line 1, comment line 2, comment line 3] despite the blank line gap

But when reading

#comment line 1
#comment line 2
#comment line 3
#
key: value

It produces the output ``

@zoeself
Copy link
Collaborator

zoeself commented Aug 19, 2022

@amihaiemil I couldn't find any assignee for this task. This is either because there are no contributors with role DEV available or because the project does not have enough funds.

Please, make sure there is at least one available contributor with the required role and the project can afford to pay them.

1 similar comment
@zoeself
Copy link
Collaborator

zoeself commented Feb 18, 2023

@amihaiemil I couldn't find any assignee for this task. This is either because there are no contributors with role DEV available or because the project does not have enough funds.

Please, make sure there is at least one available contributor with the required role and the project can afford to pay them.

@robross0606
Copy link

robross0606 commented Jul 21, 2023

I hit this as well. If the comments are like this:

# Comment line 1
# Comment line 2
#
# Comment line 3
field: value

And you do a simple "round-trip" where you ingest this YAML and then print it, what you get back is:

# Comment line 3
field: value

It doesn't just "ignore blank lines". It loses entire chunks of the comment.

@zoeself
Copy link
Collaborator

zoeself commented Apr 5, 2024

@amihaiemil I couldn't find any assignee for this task. This is either because there are no contributors with role DEV available or because the project does not have enough funds.

Please, make sure there is at least one available contributor with the required role and the project can afford to pay them.

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

No branches or pull requests

4 participants