yaml / libyaml

Canonical source repository for LibYAML
http://pyyaml.org/wiki/LibYAML
MIT License
938 stars 314 forks source link

Support for emitting and parsing comments #42

Open Tricertops opened 7 years ago

Tricertops commented 7 years ago

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:

ingydotnet commented 7 years ago

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: git@github.com:yaml/yaml-test-suite Send us a PR or two.

tobozo commented 1 year ago

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 commented 3 weeks ago

I leave my upvote for this feature.