Display a Diff as a Webpage using diff2html

This entry was posted by on Wednesday, 26 September, 2012 at

Sometimes, especially for documentation purposes, it might be necessary to show a unified diff as a HTML page.

As we will ditch Basic theme in OXID eShop version 4.7/5.0, we had to document how to convert a customized theme based on Basic if you want to update. Included, we wanted to deliver a visual diff of the categorylist.tpl file to show how the category tree was loaded before and how it will be loaded from the new version on.

I found out that neither my IDE nor any other diff tools I knew could export directly to HTML. After a while of searching I found this great bash script: diff2html

Unpack it and you will find just one single file. On Linux, it is pretty easy to use:

~$ ./diff2html file1.txt file2.txt > differences.html

There are several options as well as an own style sheet that can be used (open this file and have a look at it). But even the default results are looking absolutely suitable.

2 Comments to Display a Diff as a Webpage using diff2html

  1. oehly says:

    October 6th, 2012 at 2:33 pm

    Habe mal ein PHP Script geschrieben was alle tpl Dateien “diffed” und dann html Files generiert. Ich überlege ob das als Modul Sinn macht ?

    Guss Frank

  2. Marco Steinhäuser says:

    October 7th, 2012 at 11:12 am

    Depends what shall be diff’ed. Actually tpl diffs are already provided as HTML in cumulative update packages, generated by deployer during the release process. Unfortunately, it cannot be used as a stand alone tool for other purposes.

Leave a comment