possible parsing issue #1

Closed
jamescharlesworth opened this Issue Jan 4, 2013 · 6 comments

Projects

None yet

2 participants

@jamescharlesworth

Any idea whats going on with this conversion. I'm seeing issues when a word is replaced. For example, the ansi is
months remaining �[1;31mtimes�[m�[1;32mmultiplied by�[m $10 with

and the result html is
months remaining times2mmultiplied by $10

Here is a screenshot from terminal
Screen Shot 2013-01-03 at 8 48 57 PM

You can see that the html not getting generated properly for the new text in green from terminal.

@rburns
Owner
rburns commented Jan 4, 2013

It seems to be the '[m' sequences which confuse it. If I remove those something approaching correct comes out. From what I can find on the web the correct sequences involving 'm' look like this: ESC[#(;#)m. ie there should be at least a number preceeding the 'm' , and possibly a ';#' in addition. as in the other sequences in the string. (eg [1;31m) http://bluesock.org/~willg/dev/ansi.html

@jamescharlesworth

interesting. so this would be considered a bug in git then? This is being generated from git diff --color-words.

@rburns
Owner
rburns commented Jan 5, 2013

the [m appears to be a color reset, which should be possible to handle. I'll have a look.

https://github.com/git/git/blob/018bc80d140aff02f61e3a5100dd1367311d38ff/color.h

@jamescharlesworth

nice. no rush on my end. I have managed to solve my issues by just parsing the ansi with regex. I appreciate the quick responses though.

@rburns
Owner
rburns commented Jan 5, 2013

It turns out '[m' was being handled correctly, what was causing the error were two sequences together eg [m[1;32m. The parser was mangling the second sequence. I've committed a fix for that. can you test it out?

From looking around, my best guess is that [0m is actually the reset code. Though if git produces [m it's at least common.

@jamescharlesworth

Does not seem to fix it. The ansi from git is:

months remainingESC�[1;31mtimesESC�[mESC�[1;32mmultiplied byESC�[m $10

and that turns into

months remaining <b><span style="color:#A00">times</span></b>2mmultiplied by $10

Again, I'm probably not going to be using it though since i solved my issues with regex since its only a few common ansi characters im looking for.

@rburns rburns closed this Jan 6, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment