You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Sorry if this isn't the appropriate place to ask, feel free to close and direct me elsewhere.
I have a nicely formatted yaml file with comments and newlines separating sections, that I want to parse, edit with js (via a UI) and save back out. The problem is that the package strips all that stuff (rightly so).
I was wondering if you could provide any suggestions for handling this problem. I'm happy to take a stab at a PR to add an extra option if anyone else would find it useful.
For now I'm playing around with adding another key to the object to store line numbers of blank lines and comments, then adding them back into the string post-dump, but this is far from ideal (and will break with arrays etc)
The text was updated successfully, but these errors were encountered:
It's impossible with JS-YAML, sorry. To do something like this you need a parser that can provide full AST of input document, apply patch to it, and save it back. JS-YAML 1.x.x was able to produce AST, but had no patch nor dump functionality. If you have much desire, you can try to fork 1.x.x branch and implement what you need.
Thanks for the quick reply and reasoning. For now I'll stick to the current js-yaml as I'm sure all the extra gains from v1-3 outweigh the inconveniences. I'll certainly have a poke around libyaml later on though.
Sorry if this isn't the appropriate place to ask, feel free to close and direct me elsewhere.
I have a nicely formatted yaml file with comments and newlines separating sections, that I want to parse, edit with js (via a UI) and save back out. The problem is that the package strips all that stuff (rightly so).
I was wondering if you could provide any suggestions for handling this problem. I'm happy to take a stab at a PR to add an extra option if anyone else would find it useful.
For now I'm playing around with adding another key to the object to store line numbers of blank lines and comments, then adding them back into the string post-dump, but this is far from ideal (and will break with arrays etc)
The text was updated successfully, but these errors were encountered: