ansicolor icon indicating copy to clipboard operation
ansicolor copied to clipboard

color hierarchy issue

Open dwelle opened this issue 6 years ago • 4 comments

It seems that a nested color affects a sibling color when a color is applied to both strings up a level.

('aaa' + 'bbb'.magenta).red

leads to aaa in red and bbb in magenta, but when doing:

('aaa'.white + 'bbb'.magenta).red

the white bleeds into bbb (making it pink) for no apparent reason:

image

repro:

$ node
> console.log(('aaa'.white + 'aaa'.magenta).red)
> console.log(('aaa'.white + 'aaa'.magenta))
> console.log(('aaa' + 'aaa'.magenta).red)

version: 1.1.92

dwelle avatar Aug 09 '19 14:08 dwelle

@dwelle How do the String.prototype colors work?

ChocolateLoverRaj avatar Sep 22 '20 21:09 ChocolateLoverRaj

https://github.com/xpl/ansicolor#nice-mode-not-recommended

dwelle avatar Sep 23 '20 08:09 dwelle

@dwelle I saw how to use the nice mode, but how does it actually work internally? Does the actual text change as soon as you call the white method? Then when you call the method again with the red is it supposed to only change the colors of non colored characters?

ChocolateLoverRaj avatar Sep 23 '20 11:09 ChocolateLoverRaj

Does the actual text change as soon as you call the white method

it must

Then when you call the method again with the red is it supposed to only change the colors of non colored characters?

I'd say so, yes.

Note, I'm not the author.

dwelle avatar Sep 23 '20 11:09 dwelle