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

Unexpected reformatting of block scalar? #136

Closed
andoks opened this issue Sep 8, 2023 · 2 comments
Closed

Unexpected reformatting of block scalar? #136

andoks opened this issue Sep 8, 2023 · 2 comments

Comments

@andoks
Copy link

andoks commented Sep 8, 2023

With the following example, yamlfmt rewrites the value of "something" to not use the block scalar syntax when specifying scan_folded_as_literal=true ( yamlfmt -formatter scan_folded_as_literal=true test.yml), if there is a space character after any of the lines in the scalar. I am not an expert in YAML though, so this might be intentional, but it took me by surprise.

something: >
  {
   "foo": "bar", 
  }
@braydonk
Copy link
Collaborator

braydonk commented Sep 8, 2023

Thanks for opening an issue!

This is not intentional, it's just something weird with the yaml library that I haven't been able to solve. If there is a space at the end of a block scalar string, the yaml library decides it's not printable for some reason. It's either a bug with their raw parser or something to do with the hack we have to retain newlines in formatted output.

I've got #86 open for this already. Sorry I don't have a better answer at the moment for how to resolve this; these kinds of issues in the yaml library are always the hardest to fix.

@braydonk
Copy link
Collaborator

braydonk commented Sep 8, 2023

Going to close this issue since I'll continue tracking work in #86; if you can +1 that bug as well it helps me keep track. Thanks!

@braydonk braydonk closed this as completed Sep 8, 2023
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

2 participants