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

comments are not preserved for the right key #79

Open
lerminou opened this issue Dec 15, 2021 · 1 comment
Open

comments are not preserved for the right key #79

lerminou opened this issue Dec 15, 2021 · 1 comment

Comments

@lerminou
Copy link

lerminou commented Dec 15, 2021

The library make a wrong association betwen the element and the comment

it took comment AFTER the line and not the comment BEFORE the element

#import ruamel.yaml
from ruyaml import YAML

yaml_str = """

#comment1
key: value 

#comment2
key1: value 1

"""

yaml = YAML()
data = yaml.load(yaml_str)
print(data.ca)

Comment(comment=[None, [CommentToken('#comment1\n', line: 1, col: 0)]],
  items={'key': [None, None, CommentToken('\n\n#comment2\n', line: 4, col: 0), None], 'key1': [None, None, CommentToken('\n\n', line: 5, col: 6), None]})

@lerminou lerminou changed the title comments are not presreved for the right key comments are not preserved for the right key Dec 15, 2021
@pelson
Copy link

pelson commented Aug 30, 2022

FWIW I think there is a TODO in the code for this at

# ToDo, look at indentation of the comment to determine attachment
.

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

No branches or pull requests

2 participants