medikoo / cli-color

Colors and formatting for the console
ISC License
676 stars 34 forks source link

trim function flaw #8

Closed StreetStrider closed 11 years ago

StreetStrider commented 11 years ago

Good day! It seemes that additional trim function does not handles fine xterm-sequences:

clc = require('cli-color');
trim = require('cli-color/lib/trim');
A = clc.red('AAA');
> '\u001b[31mAAA\u001b[39m'
trim(A)
> 'AAA'
B = clc.xterm(218)('BBB');
> '\u001b[38;5;218mBBB\u001b[39m'
trim(B)
> '\u001b[38;5;218mBBB'

Maybe trim regexp is not enough powerful for this. BTW, thanks for that lib, it's really easy-to-use and awesome!

medikoo commented 11 years ago

@StreetStrider indeed, I wrote it for one of the first versions and then took only basic color sequences into account. I've just fixed it and published as v0.2.2, it should trim all types of control sequences now.

Thanks!