You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Depending on the context, one might be easier to read than the other.
Assuming the following two cases (white space represented by • for clarity):
a)
/tmp/a.txt
TEST
1234
00000000: 5445 5354 0a31 3233 340a TEST.1234.
b)
/tmp/b.txt
TEST•
1234
00000000: 5445 5354 200a 3132 3334 0a TEST .1234.
This is the output of the following command:
yq -n '.content = load_str("/tmp/{a,b}.txt")'
a)
content: | TEST 1234
b)
content: "TEST \n1234\n"
Version of yq: 4.34.1
Operating system: MacOS
Installed via: Homebrew
Expected behavior
For clarity, it would be best if the result of encoding a multi-line string ending with •\n (0x20, 0x0a) would not mess up the whole representation - depending on the use.
It would be interesting to allow the user to define this behaviour - some times you really want to make clear that there is a space before a new line - whereas some times you don't really care (e.g: XML).
Additional context
This might be nit-picking, but the output really looks ugly when you have a multi-line document that out of nowhere becomes encoded in a single-line string just because one of the N lines contains a (0x20, 0x0a).
The text was updated successfully, but these errors were encountered:
denysvitali
changed the title
Multiline strings with a line ending with a white space are represented as single line
Multiline strings with a line ending with a white space are represented inline
May 30, 2023
Describe the bug
Using the "literal style" YAML spec page as an example and the following string:
there are two ways of representing it:
Depending on the context, one might be easier to read than the other.
Assuming the following two cases (white space represented by
•
for clarity):a)
/tmp/a.txt
b)
/tmp/b.txt
This is the output of the following command:
a)
b)
Version of yq: 4.34.1
Operating system: MacOS
Installed via: Homebrew
Expected behavior
For clarity, it would be best if the result of encoding a multi-line string ending with
•\n
(0x20, 0x0a) would not mess up the whole representation - depending on the use.It would be interesting to allow the user to define this behaviour - some times you really want to make clear that there is a space before a new line - whereas some times you don't really care (e.g: XML).
Additional context
This might be nit-picking, but the output really looks ugly when you have a multi-line document that out of nowhere becomes encoded in a single-line string just because one of the N lines contains a (0x20, 0x0a).
The text was updated successfully, but these errors were encountered: