rburns/ansi-to-html

[Bug] \x1b[0K is not removed in some situations due to token matching logic

Closed this issue · 0 comments

Given the following input:

'HELLO\n\x1b[0K\u001b[33;1mWORLD\u001b[0m\n'

I would expect the output to be the following:

'HELLO\n<span style="color:#A50"><b>WORLD</b></span>\n'

Instead, it is the following:

'HELLO\nK<span style="color:#A50"><b>WORLD</b></span>\n'

After debugging the code I found that the problem was that even after a token is found and removed from the text it doesn't restart matching all tokens.

I have a fix ready and will be submitting a PR.