I want gitweb to output the same diff format as git diff --color-words
. Does anybody know how I can do this? I looked at HTML::FromANSI but couldn't get it working with git diff --color-words
from the command line.
views:
314answers:
1How did you use HTML::FromANSI? Because it works for me, using the following command worked as intended
git diff --color-words HEAD^ HEAD |
perl -wle '
use HTML::FromANSI;
my @lines = <STDIN>;
foreach my $line (@lines) {
chomp $line;
print ansi2html($line);
}' > tmp.html
Although if you want usable output, and not barely visible white text on black background, you would probably need to configure HTML::FromANSI. The above scriptlet is just proof of concept code (ans not in best style).
BTW I am not sure about quality of HTML::FromANSI module; it didn't install (using cpan
) for me without force (but it might be problem with Term::VT102::Boundless this module requires).
ansi2html
subroutine have problems with some lines (I think lines with embedded / trailing end-of-line character, and empty line / string), producing Use of uninitialized value in concatenation (.) or string at .../HTML/FromANSI.pm line 353, <STDIN> line NN.
warning. That's why I had to chomp
lines (and that might be the problem you had with making HTML::FromANSI work).
Also the HTML produced by this module is quite horrid, using outdated and deprecated <font face='...' style ='...'>
tag together with modern <span style='...'>
tag; also I don't see an option to use CSS instead of inline style.