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

Ending comments got lost after stringify #576

Closed
longkai opened this issue Sep 22, 2024 · 2 comments
Closed

Ending comments got lost after stringify #576

longkai opened this issue Sep 22, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@longkai
Copy link

longkai commented Sep 22, 2024

Describe the bug

Do parsing the text then format it.

  let doc = YAML.parseDocument(text);
  console.log(YAML.stringify(doc));

To Reproduce

input text:

a:   1
#a: 1
# b: 2

got result:

a: 1

Expected behaviour

a: 1
#a: 1
# b: 2

Versions (please complete the following information):

  • Environment: Node.js v22.6.0
  • yaml: 2.5.1

Additional context

None

@longkai longkai added the bug Something isn't working label Sep 22, 2024
@eemeli eemeli closed this as completed in 438688f Oct 13, 2024
@eemeli
Copy link
Owner

eemeli commented Oct 13, 2024

Technically, the right way to serialize a document would be via String(doc) or doc.toString(), but adding an affordance for stringify() to also do the right thing seemed like the right choice.

@longkai
Copy link
Author

longkai commented Oct 22, 2024

Thanks a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants