nikolaydubina / treemap

🍬 Pretty Treemaps
153 stars 2 forks source link

Can't use slash or comma in names #25

Closed mlange-42 closed 1 year ago

mlange-42 commented 1 year ago

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:

nikolaydubina commented 1 year ago

Interesting! Could you provide examples that break and what is your ideal expected result? We can start from there.

I am open to add CLI parameter to customise behaviour. Just need to find best solution. (probably your option 1).

On Mon, 19 Dec 2022 at 20:41, Martin Lange @.***> wrote:

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 https://github.com/mlange-42/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

— Reply to this email directly, view it on GitHub https://github.com/nikolaydubina/treemap/issues/25, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAWMCRIPPA5MZRRY7LEHIJTWOBJYRANCNFSM6AAAAAATDKC2TE . You are receiving this because you are subscribed to this thread.Message ID: @.***>

mlange-42 commented 1 year ago

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.

mlange-42 commented 1 year ago

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.

mlange-42 commented 1 year ago

Implementation of solution 3 in #26.