views:

1017

answers:

3
+1  A: 

Don't know any tool to do exactly what you want. But here's a piece of code I often use to output html formatted colored diff: simplediff

It's available in PHP and Python. The output tags the differences using <del> and <ins> tags so you can easily color them using CSS.

slebetman
+2  A: 

download diff2html, extract it and convert diff to html with this command:

$ diff2html file1.txt file2.txt > diff-demo1.htm

There is more ... take a look at this question.

[EDIT] ... FINALLY ... I find the way :D

after gitting:

git diff --color-words --no-index orig.txt /tmp/edited.txt > myfile

download both ansifilter from this location. and use this command to convert myfile to html format

ansifilter -i myfile -H -o myfile2.html

so ... this is exactly what you want ;)

Michel Kogan
http://www.flickr.com/photos/hendry/4250699527/I am not accepting `diff2html` because it looks AWFUL.
hendry
what about this --> http://kafka.fr.free.fr/diff2html/diff-demo2.html
Michel Kogan
That looks awful too. I want it to look like my terminal screenshot above.
hendry
check my answer again.
Michel Kogan
I still don't like it. I am convince I need to write some sort of ANSI escape to HTML convertor.
hendry
Thanks very much for trying to help Michel. You were pipped to the post. :)
hendry
+4  A: 
wget http://www.pixelbeat.org/scripts/ansi2html.sh -O /tmp/ansi2html.sh
chmod +x /tmp/ansi2html.sh
git diff --color-words --no-index orig.txt edited.txt | /tmp/ansi2html.sh > 2beshared.html

What I really needed what a ANSI to HTML convertor. And I found a very decent one on http://www.pixelbeat.org/.

hendry
Glad you like it :) You can see some example usage here: http://www.pixelbeat.org/docs/terminal_colours/
pixelbeat
Two other duplicate questions, answered by "use the HTML::FromANSI Perl module on CPAN": http://stackoverflow.com/questions/1425738/how-can-i-convert-the-output-of-git-diff-color-words-to-html , http://stackoverflow.com/questions/245121/a-library-to-convert-ansi-escapes-terminal-formatting-color-codes-to-html
Adam Monsen