A side-by-side diff view.

Just a short post about a side-by-side diff algorithm I implemented on top of Google’s diff-match-patch library. It is modelled after the Wikipedia one

The snippet is posted under http://code.activestate.com/recipes/577784-line-based-side-by-side-diff/

A screenshot that was generated by this algorithm can be seen on http://jsfiddle.net/hRS9N/1/

Python has a side-by-side diff view implementation in difflib, but it sure isn’t up to current web standards ( everywhere …) and not adaptable at all. After all why would you limit the whole implementation to only return a set of html if the user knows best how to render the diff’s outcome anyway. Also, diff-match-patch is probably way better performance wise. As described under http://code.google.com/p/google-diff-match-patch/wiki/LineOrWordDiffs there is a quicker solution to solve this problem for a similar outcome. However changes are calculated and shown in a pretty coarse way. I’ll post about an application of this diff later on.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s