Generate pretty diff html in Python

The Unknown picture The Unknown · Oct 16, 2009 · Viewed 33.3k times · Source

I have two chunks of text that I would like to compare and see which words/lines have been added/removed/modified in Python (similar to a Wiki's Diff Output).

I have tried difflib.HtmlDiff but it's output is less than pretty.

Is there a way in Python (or external library) that would generate clean looking HTML of the diff of two sets of text chunks? (not just line level, but also word/character modifications within a line)

Answer

tonfa picture tonfa · Oct 16, 2009

There's diff_prettyHtml() in the diff-match-patch library from Google.