views:

62

answers:

3

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.

edit

I have seen jsdifflib but in the example it always shows the full source, so unless there is a way to change the output somehow, it doesn't fully meet my requirements. Nevermind, I am stupid. I should learn to read better.

+1  A: 

I dont know much about the diff utility in linux or linux in general, but this might be what you are looking for jsdifflib. You can find a live example there and see if it works for you.

realshadow
+1  A: 

jsdifflib looks promising - try the demo on their site.

Justin Ethier
+2  A: 

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

Scott Bale
The context size was the important thing I didn't see, thanks :)
poke
Glad to have helped
Scott Bale