Comments (2)
You are indeed correct! With scan_folded_as_literal: true
in my real example seems to give the correct output. Thanks a lot for the quick help!
from yamlfmt.
Thanks for making an issue and the kind words!
This appears to be a strange edge case of scanning folded block scalars, something that's been a hassle. There's two bits of weirdness, one of which yamlfmt
has a workaround for, and one that probably needs investigation in the library.
The one with a workaround is that the underlying yaml library cuts out lines for folded block scalars. This actually kind of makes sense, since that's a correct interpretation of folded block scalars from the spec, however it's really uncool for a tool like this where we want to maintain that form. For that, I've implemented a feature in the yaml library that forces re-encoding folded block scalars to retain the line breaks. I added a boolean option in the formatter config called scan_folded_as_literal
to enable this. See the config docs for a bit more info there. With scan_folded_as_literal
enabled, the first example in the issue remains the same after format.
The second weirdness is something I actually discovered just now while reproducing the issue. If a line in a folded block scalar ends with space characters, the encoder throws a fit and dumps the raw string value instead of producing a folded block scalar as intended. If whitespace is left at the end of a folded block scalar, you get output like this:
Foobar:
baz: "Lorem Ipsum is simply dummy text of the printing_and_typesetting industry.
\n#magic___^_^___line\n"
Foobaz:
baz: "foobar"
This is a really annoying consequence, and I'll start tackling it soon.
That being said, hopefully scan_folded_as_literal
will work for your issue! If it does, I will close this issue; I'll be starting the new investigation for folded block scalar lines ending with whitespace in a new issue dedicated to it.
from yamlfmt.
Related Issues (20)
- Exclude patterns not working as expected HOT 3
- Consider reading configuration from .yamlfmt.yml and .yamlfmt.yaml files HOT 1
- Consider to change/improve configfile discovery HOT 7
- W3C YAML-LD HOT 7
- feature request: ignore specific lines instead of entire file HOT 3
- VS Code extension HOT 4
- Support reviewdog HOT 1
- don't remove newline from end of file HOT 1
- Ordered keys HOT 1
- 0.10.0 release? HOT 2
- Add option to remove trailing spaces HOT 2
- Unexpected reformatting of block scalar? HOT 2
- Preserve multiline for line ending with \ HOT 4
- Exclude is still a little bit wonky HOT 8
- Feature Request: Optional exclude content from .gitignore HOT 1
- Docs request: `best_width`, YAML library HOT 2
- Request: `indent` being respected beyond top level HOT 1
- Support system-installed yamlfmt HOT 15
- Wrong front matter interpretation HOT 1
- Feature request: allow to retain some empty lines HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from yamlfmt.