AllMightySauron/ascii-table3

Bug: adding colors to cells breaks cell width sync between header & body

Closed this issue · 1 comments

I wanted to have colored text in cells using chalk, which adds this type of unicode chars: \x1B[32m<text>\x1B[39m. The coloring works alright, but it breaks the column width sync between headers & body:
Sample output when all the words in the first column are colored green with chalk.green('text'):

+----------------------+--------+---------+
|       Package        | Compat | Version |
+----------------------+--------+---------+
| coveralls  | >=6    | 3.1.1   |
| mocha      | N/A    | N/A     |
| nyc        | >=8.9  | 15.1.0  |
| release-it | >=10   | 14.11.8 |
+----------------------+--------+---------+

Should be fixed in 0.7.0. Had to replace standard string handling functions... :)

I still need to add more unit tests to make sure it doesn't break anything when word wrapping or truncating for colouring cases.