jsdifflib
demo
Context size (optional):
Base Text
jsdifflib is a Javascript library that provides: a partial reimplementation of Python’s difflib module (specifically, the SequenceMatcher class) a visual diff view generator, that offers side-by-side as well as inline formatting of file data Yes, I ripped off the formatting of the diff view from the Trac project. It’s a near-ideal presentation of diff data as far as I’m concerned. If you don’t agree, you can hack the CSS to your heart’s content. jsdifflib does not require jQuery or any other Javascript library. Python Interoperability The main reason why I reimplemented Python’s difflib module in Javascript to serve as the algorithmic basis for jsdifflib was that I didn’t want to mess with the actual diff algorithm — I wanted to concentrate on getting the in-browser view right. However, because jsdifflib’s API matches Python’s difflib’s SequenceMatcher class in its entirety, it’s trivial to do the actual diffing on the server-side, using Python, and pipe the results of that diff calculation to your in-browser diff view. So, you have the choice of doing everything in Javascript on the browser, or falling back to server-side diff processing if you are diffing really large files. Most of the time, we do the latter, simply because while jsdifflib is pretty fast all by itself, and is totally usable for diffing "normal" files (i.e. fewer than 100K lines or so), we regularly need to diff files that are 1 or 2 orders of magnitude larger than that. For that, server-side diffing is a necessity. Demo & Examples You can give jsdifflib a try without downloading anything. Just click the link below, put some content to be diffed in the two textboxes, and diff away.
New Text
jsdifflib is a Javascript library that provides: a partial reimplementation of Python’s difflib module (specifically, the SequenceMatcher class) The main reason why I reimplemented Python’s difflib module in Javascript to serve as the algorithmic basis for jsdifflib was that I didn’t want to mess with the actual diff algorithm — I wanted to concentrate on getting the in-browser view right. However, because jsdifflib’s API matches Python’s difflib’s SequenceMatcher class in its entirety, it’s trivial to do the actual diffing on the server-side, using Python, and pipe the results of that diff calculation to your in-browser diff view. So, you have the choice of doing everything in Javascript on the browser, or falling back to server-side diff processing if you are diffing really large files. a visual diff view generator, that offers side-by-side as well as inline formatting of file data Yes, I ripped off the formatting of the Trac project. It’s a near-ideal presentation of miff data as far as I’m concerned. If you don’t agree, you can hack the CSS to your heart’s content. jsdifflib does not require jQuery or any other Javascript library. Python Interoperability Most we do the latter, simply because while jsdifflib is pretty fast all by itself, and is totally usable for diffing "normal" files (i.e. fewer than 100K lines or so), we regularly need to diff files that are 1 or 2 orders of magnitude larger than that. For that, server-side diffing is a necessity. Demo & Examples You can give jsdifflib a try without downloading anything. Just click the link below, put some content to be diffed in the two textboxes, and diff away.
Side by Side Diff
Inline Diff