roundtrip does not preserve escape newlines in double-quoted flow scalars
commandline utility to manipulate YAML files
Brought to you by:
anthon
I have a file where I have a long-ish CSV list: I'd like to keep it ordered and easy to scan visually by splitting it across lines and escaping the newlines in a double-quoted flow scalar. I propose that double-quoted flow scalars with escaped newlines should be preserved.
For context: this CSV list gets passed to another command line tool through a Github Action and I don't have scope to restructure the YAML instead.
Using ruamel.yaml.cmd
...
yaml rt input.yaml
input
foo: "\ bar,\ baz,\ qux"
output
foo: bar,baz,qux
Ticket moved from /p/ruamel-yaml/tickets/401/
This is unlikely going to be added. You should look into using folded scalars if you want newlines in your documents that are preserved on roundtrip but not in the loaded data:
The
-
after>
is necessary to strip the trailing newline, as that is not in your double-quoted flow scalar.