jml/tree-format

Values that contain newlines are not handled well

jonathanj opened this issue · 0 comments

Modifying the README example, this is what happens if the "baz" leaf is changed to "baz\nfoo":

foo
├── bar
│   ├── a
│   └── b
├── baz
foo
└── qux
    └── c

In eliot-tree I convert control characters into their Unicode equivalent human-display versions, so as not to interfere with the terminal but I leave \n alone because I don't think having a really long line delimited with Unicode is a great way to read long values.

Since the user cannot exert control on the tree rendering, I would expect tree-format to handle this case. Perhaps one way of handling this is to turn \n into ⏎, add a branch bar and indent the next line to the depth of the leaf. Artist's impression follows:

foo
├── bar
│   ├── a
│   └── b
├── baz⏎
│   foo
└── qux
    └── c