Open AlchemicRaker opened 10 years ago
What's happening here is that ANSI escape sequences are mostly made out of printable characters, and this can cause a simple regex - such as [a-z]+
in your example - to modify and break pre-existing escape codes by putting escape codes within them.
In order to make this work, synesthesia would need to remove all existing escape sequences while remembering where they were relative to the plain text, color it, perform the same extraction on the new coloration, and then reconcile any overlaps.
I think the least surprising way to perform sequential colorations is to keep all characters the same color they were before unless a new match changes the color of that character. This includes when a new match winds up in the middle of an old match, meaning that the old color codes must appear after the clear color escape sequence for the new match.
I'm not sure to what extent this is synesthesia's fault necessarily, but when synesthesia pipes into a second synesthesia, the final output is full of broken ANSI escape sequences.
In this example, the coloring from the first synesthesia process is garbled and lost, and the coloring from the second synesthesia process renders properly.