style(yaml): preserve newlines in folded block scalars#58
Open
eric-thelin wants to merge 1 commit into
Open
Conversation
From the official documentation of yamlfmt: > Option that will preserve newlines in folded block scalars (blocks > that start with >). Without this option newlines in folded block scalars are always replaced with spaces. This defeats the purpose of using a folded block scalar. Consider this YAML: example_of_folded_block_scalar: > Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. The above is an example of a folded block scalar (as denoted by the `>` syntax). It is a way to break a long string into multiple lines for better readability. The newlines are interpreted as spaces. However, without `scan_folded_as_literal: true` the linter would replace the newlines with spaces and place the whole text on a single line: example_of_folded_block_scalar: > Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. This is counterproductive. If I wanted to put the whole thing on a single line, I would use a regular string and not a folded block scalar. See: https://yaml.cc/tutorial/yaml-multiline-string.html See: https://github.com/google/yamlfmt/blob/main/docs/config-file.md Signed-off-by: Eric Thelin <extern.eric.thelin@digg.se>
1dadc7c to
7767ebf
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
From the official documentation of yamlfmt:
Without this option newlines in folded block scalars are always replaced with spaces. This defeats the purpose of using a folded block scalar.
Consider this YAML:
The above is an example of a folded block scalar (as denoted by the
>syntax). It is a way to break a long string into multiple lines for better readability. The newlines are interpreted as spaces.However, without
scan_folded_as_literal: truethe linter would replace the newlines with spaces and place the whole text on a single line:This is counterproductive. If I wanted to put the whole thing on a single line, I would use a regular string and not a folded block scalar.
See: https://yaml.cc/tutorial/yaml-multiline-string.html
See: https://github.com/google/yamlfmt/blob/main/docs/config-file.md
Checklist