Sunday 3 June 2012, by
All the versions of this article: [English] [français]
The diff2html utility generates an HTML page to display the output of the diff(1) well-known utility. Using Cascading Style Sheets, the user can fully personnalize the appearance of the web page (you might find the default styles are too much colorfull). diff2html is written using the Python language and is licensed under the GNU GPL.
Download and installation
First, make sure you have Python installed. It should be provided with all popular Linux distributions. If you don’t have it, you can get it from http://www.python.org.
Then, get the script from this link.
To install it, just unpack it somewhere in your default path! For example,
/usr/local/bin might be good locations.
Issue a simple
diff2html --help to get the inline help. Basically,
diff2html takes two files on its command-line, and send the HTML page on its default output. So a typical use is:
diff2html file1 file2 > diff.html
diff2html file1.txt file2.txt > diff-demo1.html
and look at the default result.
Now, using the same files, you also have your own style sheet, for example this one. You can ask
diff2html to use it using the
--style-sheet command-line option:
diff2html --style-sheet diff_style.css file1.txt file2.txt > diff_demo2.html
The result] is quite different now.
Have fun with this tool!