Google diff match patch tools

May 18, 2010

This google code library can be used to produce rich diffs of text, complete with strikeout and colour highlighting. It has language support for c++, csharp, javascript, python, lua and java.

Diff

To produce a nice HTML diff, use this code:

from diff_match_patch import diff_match_patch

lDiffClass = diff_match_patch()
lDiffs = lDiffClass.diff_main(lFromText, lToText)
lDiffClass.cleanupSemantic(lDiffs)
lDiffHtml = lDiffClass.diff_prettyHtml(lDiffs)

There a demo page you can play with at http://neil.fraser.name/software/diff_match_patch/svn/trunk/demos/demo_diff.html

References

http://code.google.com/p/google-diff-match-patch/