Menu

#10 roundtrip does not preserve escape newlines in double-quoted flow scalars

wont-fix
nobody
None
minor
bug
2021-10-23
2021-10-21
Robin
No

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

Discussion

  • Anthon van der Neut

    Ticket moved from /p/ruamel-yaml/tickets/401/

     
  • Anthon van der Neut

    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:

    foo: >-
      bar,
      baz,
      qux
    

    The - after > is necessary to strip the trailing newline, as that is not in your double-quoted flow scalar.

     
  • Anthon van der Neut

    • status: open --> wont-fix
     

Log in to post a comment.