Location: Homepage / Inline-diff
Update: the inline renderer is now a native part of the Text_Diff PEAR package. You don't need to use the hack presented here anymore. This page is kept for reference only.
If you have two strings: "my blue pen" and "my red pen", this is the diff my hack will produce: "my <del>blue</del><ins>red</ins> pen".
I created this in order to be used in a wiki (Wikki Tikki Tavi) but I suppose you can find other applications for it.
It is a rather simple hack. It does the following:
The package has these files:
inline_example.php = shows how to use the diff maker
inline_function.php = the function which does everything
inline_renderer.php = my hacked diff renderer
You either need to install Text_Diff from PEAR on your machine's PEAR repository (do a 'pear help' on the command line if you don't know how), or you can include that package in your source. It's not big, it only has a few files.
Read the code for any additional details you may need. There are a few tips about optimizing it for PHP5 in there.
This package is distributed under the terms of the GNU General Public License. You are encouraged to use and distribute it at will, as long as you act according to the GPL.
Version 0.1. This one breaks the text down to character level. It's nice for small amounts of changes, but becomes unreadable for completely different versions. You can see what I mean in these screenshots (ordered from nice to bad).
Version 0.2. This one breaks the text down to word level. It is quite usable according to my preliminary testing. I've found out it produces the exact same output as wdiff and htmldiff. You can see a sample output.