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
Describe the bug
Wrapping of long strings does not work correctly. After a newline is encountered in the value it will no longer wrap any more content.
Further more, if the line length becomes small enough it inserts a leading newline and doesn't even wrap at the correct line length.
To Reproduce
importyamlfrom"yaml";constdata={foo: "bar",longlines:
"first line which is long enough to be wrapped to a another line\nsecond line which is long enough to be wrapped to a another line\nthird line which is long enough to be wrapped to a another line",};console.log(yaml.stringify(data,{lineWidth: 40,}),);// Inserts a leading newlineconsole.log(yaml.stringify(data,{lineWidth: 20,}),);
This will print
foo: bar
longlines: >-
first line which is long enough to be
wrapped to a another line
second line which is long enough to be wrapped to a another line
third line which is long enough to be wrapped to a another line
foo: bar
longlines: >-
first line which
is long enough to be
wrapped to a another
line
second line which is long enough to be wrapped to a another line
third line which is long enough to be wrapped to a another line
Expected behaviour
foo: bar
longlines: >-
first line which is long enough to be
wrapped to a another line
second line which is long enough to
be wrapped to a another line
third line which is long enough to be
wrapped to a another line
foo: bar
longlines: >-
first line which
is long enough
to be wrapped to
a another line
second line which
is long enough to
be wrapped to a
another line
third line which
is long enough to
be wrapped to a
another line
Versions (please complete the following information):
Environment: Node.js v18.17.0
yaml: 2.4.0
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered:
This was due to mismatching expectations in when indentation is applied to indented scalar values. For > block scalars, lines within the value that are more indented that the others are not folded, so lines starting with whitespace need to be skipped. However, by the time we're doing this, a scalar value inside a block collection will already have been indented, so after the first line we were mistakenly detecting every line as more-indented from the PoV of folding, leading to the observed results.
This also revealed a slight offset in the cutoff for the first soft wrap after a block scalar newline that's also fixed here.
Describe the bug
Wrapping of long strings does not work correctly. After a newline is encountered in the value it will no longer wrap any more content.
Further more, if the line length becomes small enough it inserts a leading newline and doesn't even wrap at the correct line length.
To Reproduce
This will print
Expected behaviour
Versions (please complete the following information):
yaml
: 2.4.0Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: