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

Support for emitting and parsing comments #42

Open
Tricertops opened this issue Dec 17, 2016 · 3 comments
Open

Support for emitting and parsing comments #42

Tricertops opened this issue Dec 17, 2016 · 3 comments

Comments

@Tricertops
Copy link

Currently, there is no way to write or read comments using this library.

I understand that comments are intended only for humans, so parsing them into runtime model makes little sense. However, there might be a valid case when some runtime model is written to a file that will be read by humans. Imagine an auto-generated configuration file annotated with comments for further human editing.

This would also allow editing files using this lib without losing human-created coments (even if the exact formatting would be lost).

Supporting comments would probably require these new public APIs:

  • value YAML_COMMENT_TOKEN in enum yaml_token_type_t
  • value YAML_COMMENT_EVENT in enum yaml_event_type_t
  • function yaml_comment_event_initialize(yaml_event_t *event, yaml_char_t *content)
@ingydotnet
Copy link
Member

Hi @Tricertops. I agree with you in principal. libyaml should also have a mode
where it parses and emits whitespace, for use in things like editors that can't
throw away any characters.

With comments the devil is in the details. Full line comments might be easier
to start with.

I think to move this idea forward, you should add a number of tests to the test
suite. That will allow us to think through the details.

The test suite is: [email protected]:yaml/yaml-test-suite
Send us a PR or two.

@tobozo
Copy link

tobozo commented Nov 28, 2022

bump

Is that topic still worth researching or is it a WONTFIX?

Would it make sense to establish a more exhaustive list of what's needed to get full line comments support?

@raweden
Copy link

raweden commented Aug 13, 2024

I leave my upvote for this feature.

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

4 participants