YAML: long property names/keys get prefixed with question mark `?`, and colon `:` gets wrapped onto the next line
See original GitHub issuePrettier 1.15.3 Playground link
--parser yaml
Input:
very_long_name_in_fact_it_is_longer_than_80_characters_123123123123123123123123123:
foo: "bar"
Output:
? very_long_name_in_fact_it_is_longer_than_80_characters_123123123123123123123123123
: foo: "bar"
Expected behavior:
Doesn’t wrap the :
to the second line, i.e. leaves the whole thing intact.
very_long_name_in_fact_it_is_longer_than_80_characters_123123123123123123123123123:
foo: "bar"
This issue looks simple to fix, where would I look for the related code if I wanted to make a PR?
Issue Analytics
- State:
- Created 5 years ago
- Reactions:15
- Comments:17 (7 by maintainers)
Top Results From Across the Web
How to escape indicator characters (colon and hyphen) in YAML
A pipe preserves newlines, a gt-sign turns all the following lines into one long string. Share.
Read more >YAML Ain't Markup Language (YAML™) revision 1.2.2
Mappings use a colon and space (“ : ”) to mark each key/value pair. Comments begin with an octothorpe (also called a “hash”,...
Read more >ETSI TS 129 501 V17.5.0 (2022-05)
found in ETSI SR 000 314: "Intellectual Property Rights (IPRs); Essential, ... The question mark character is a delimiter, which terminates ...
Read more >Expert Python Programming Third Edition
Anyway, this book takes into account the fact that not everyone needs to be fully aware of the latest Python features or officially...
Read more >Cobbler Documentation - Read the Docs
Before getting started with Cobbler, you should have a good working ... no errors were reported, you are ready to move on to...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I hit this bug and have fixed it - see PR just above. For anyone interested, there’s some real black magic going on which made this pretty hard to figure out, but which feels commensurate to the wolf in sheep’s clothing that is the YAML grammar.
The intention of the code was to:
This is all pretty edge case stuff - many people will never know that yaml mapping keys can be multiline entities like arrays or multiline strings!
The extra dose of confusion comes from the pointless-looking call to conditionalGroup. It turns out that conditionalGroup has the undocumented behaviour of forcing the printer into MODE_FLAT, which the yaml formatter extensively relies on to prevent various breaks from occurring. Sensible-looking attempts to rewrite the code can very easily result in tons of line breaks appearing out of nowhere!
@nasht00 One lazy workaround that I’ve used for this is setting max line length to 999 for Yaml files. Fixes the issue immediately but doesn’t look great if you have long lists with commas - they might get inlined.