clj-yaml
clj-yaml copied to clipboard
Support for reading comments
SnakeYaml has an option to process comments. It would be good to be able to have access to that option from clj, ideally from bb as well.
See https://github.com/snakeyaml/snakeyaml/blob/master/src/main/java/org/yaml/snakeyaml/LoaderOptions.java
private boolean processComments = false;
My use case is to parse yaml documents that are very heavily commented as they main audience is human.
I am raising the issue first and could explore having a go at adding it, but following instructions from the Developer docs, it suggests raising issue first.
OK, PR welcome to see what can be done about it. Please also add a test :)
I have played around with the options - something is happening - for example when parsing the list-yaml in the tests I get a exception as there is an open issue in Snake yaml for a comment in that position. What I found is that setting the option does not change the output at all. There is a line in one of the snakeyaml files that says:
while (scanner.checkToken(Token.ID.Comment)) { // TODO: till we figure out what todo with the comments scanner.getToken(); }
Which does not give me any confidence that the comments will end up somewhere. There is also an old issue where the devs just say that the comment is over-ridden by the node that comes next.
Shame. Would appreciate someone else confirming this.
@mmeroberts thank you very much for the contribution. The mentioned TODO was removed as non applicable any longer. For your information. The parsing/dumping comments in SnakeYAML is fully functional.