Pretty diffs of markdown documents
Switch branches/tags
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

Pretty Word Diffs

GitHub has a nice way of showing word-based diffs on Markdown files. I needed a way to be able to create similar pretty diffs as standalone documents. This is what I came up with.


  • git
  • pandoc
git clone
cd pwdiff 
./pwdiff examples/ examples/ > out.html

Then have a look at out.html and you should see something like:

Pretty diffs


  • We're using git diff's -U option to show so-many lines of context. I've set this very large for now. It should probably just be the larger of the total number lines of the two files input.
  • This is fragile to the tagging syntax used by git diff [- -], {+ +} as we're using sed to replace those. If your workflow or text contains those strings, ymmv.