rburns / ansi-to-html

Convert ansi escaped text streams to html.
MIT License
357 stars 48 forks source link

Incorrect parsing for square brackets in string ? #38

Closed Dzenly closed 7 years ago

Dzenly commented 7 years ago

Hi, thank you for your work!

0.6.3 version:

2017-11-13 17:20:00: .[33mwarn.[39m: [IM.server] MAIL is not configured

Dot's before square brackets are ESC symbols (\x1b).

Converts to:

2017-11-13 17:20:00:
<span style="color:#A50">warn<span style="color:#FFF">: [IM.server] MAIL is not configured</span></span>

So on my white background, the second part of string just disappeared. I really wandered why there are two spans, actually I expected:

2017-11-13 17:20:00:
<span style="color:#A50">warn</span>
[IM.server] MAIL is not configured

Some greedy problems in regexp ?

Dzenly commented 7 years ago

Oh, my fault.

https://en.wikipedia.org/wiki/ANSI_escape_code

39 is default foreground color.

new Convert({
  fg: '#000',
  bg: '#FFF',
});

is solved the problem.