timoxley / columnify

Create text-based columns suitable for console output. Supports cell wrapping.
MIT License
429 stars 30 forks source link

Preserve All Whitespace #45

Open shellscape opened 7 years ago

shellscape commented 7 years ago

Since the module doesn't have configuration (ala text-table) for leading whitespace or space between columns, collapsing all whitespace is problematic. We're left to hack around it by splitting lines for leading whitespace, and we're hosed if we want to configure the whitespace between columns. We can't always know what the minimum width of a column should be, after all.

An option to either preserve (eg. not collapse) whitespace or options for leading and between-column whitespace is sorely needed.

bradennapier commented 7 years ago

Personally I would simply like a padding on the entire column. AKA: add \t\t at the start of every line so that the columns can appear indented on the screen when needed.

vsinha commented 6 years ago

Found a hack which works!

dataTransform: (s: string) => s.replace(" ", "\u2063")

\u2063 is an 'invisible separator' (ie an invisible comma) and is not matched by the \s regex here