Try out ghdiff
, GitHub style HTML for unified diffs. It's on PyPI, but there are better docs on GitHub currently. You'll need to pip install ghdiff
.
Simple usage, assuming the markdown is in markdown1
and markdown2
.
import ghdiff
diff_as_html = ghdiff.diff(markdown1,markdown2)
Here's a more explicit demonstration though. Let's say you have these two markdown strings:
md1 = '''
# Hello world
I am text
* No really
'''
md2 = '''
# Hi world
I am text
* No really
'''
We can perform a diff on these
import ghdiff
diff_as_html = ghdiff.diff(md1,md2)
When rendered, it looks like this:
Here's the raw and the rendered in an IPython Notebook: