Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Highlight text diff on client?

I want to compare 2 text values on a web page and highlight the differences. Can I do this client-side, preferably with jQuery or Prototype?

like image 382
Mike Sickler Avatar asked Oct 08 '10 16:10

Mike Sickler


2 Answers

This diff-patch-match library appears to do a really good job:

http://code.google.com/p/google-diff-match-patch/

The project has JavaScript, C#, C++, Python, and Java implementations that all do the same thing.

like image 158
Mike Sickler Avatar answered Sep 19 '22 14:09

Mike Sickler


Check out the the wikEd diff library and the online tool and demo.

The library creates inline text comparisons with block move highlighting and is character/word-based. It has been optimized for Wikipedia, but works equally well for other text types and program code. The library code is customizable, has Unicode support, is extensively commented, and is free (PD).

like image 43
Cacycle Avatar answered Sep 18 '22 14:09

Cacycle