nikolaydubina/treemap

Can't use slash or comma in names

mlange-42 opened this issue · 4 comments

Slashes and commas are reserved as path and column delimiters, respectively. This prevents their use in names (path parts). Or rather, it leads to unexpected results.

My particular use case is in dirstat again, where I would like to use a trailing slash to denote directories.

I see two options to solve this:

  • Configurable column and path delimiters
  • Using HTLM entities, like / for these characters
    • Comes with some problems:
      • Would not work well with string length calculations for box titles
        • Could use regex or a dedicated XML/HTML encoding/decoding library to fix this
      • & is currently replaced by & to form valid XML/SVG
        • Would require to take care of HTML entities in & replacement

Actually, adding the delimiters to the API (esp. for the path) would be sufficient for my use case.

Regarding column separator, I am currently passing a CSV string internally. Would also construct the tree in my code without CSV parsing, but I did not understand the To field of nodes in a first attempt.

Will try some examples and post the results here. Actually, I am not really sure what is gonna happen with the double slashes my example would produce. I guess additional path elements with name "".

Using the HTML entity produces this:

grafik

(it should be ./)

EDIT: BTW, I realize that commas can probably be used by double-quoting the entire field.

As only slashes seem to be left, a third option would be to be able to specify a character (or sequence) that is replaced by a slash in the rendering code.

If there is no intent to treat HTML entities (2nd suggestion), it could just be / that is replaced by / before the other replacements.

Implementation of solution 3 in #26.