Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JavaScript based diff utility [closed]

I'm looking for a diff equivalent written in JavaScript that only returns/prints relevant lines. I don't want both full text displayed next to each other with the differences highlighted, but just want the actual differences (plus some buffer lines to know where the difference is), similar to the output from the linux diff utility.

Does anybody know a javascript function that does this? All differences should be recognized (even changed whitespace). Thanks.

like image 841
poke Avatar asked Jun 16 '10 13:06

poke


2 Answers

I completely rebuilt the jsdifflib utility for speed. Since my version does not require DOM access it at least 4.5 times faster, and it is also extended to highlight character differences in each line.

http://prettydiff.com/diffview.js

You can test this out with the online tool directly at http://prettydiff.com/

like image 64
austincheney Avatar answered Sep 22 '22 07:09

austincheney


jsdifflib inline mode comparison, try tweaking the context size to display just the desired window of change you want. There's a demo here

like image 33
Scott Bale Avatar answered Sep 24 '22 07:09

Scott Bale