Reputation: 261
I'm using google-diff-match-patch with my Java app to create a diff. I use the method diff_prettyHtml for generating HTML output of the diff.
However, I would like to have two different outputs, so I can put them side-by-side to make it a bit more easy for the user to see the differences. (For example, like Eclipse does.)
Is there anything in that library I can use to achieve this? How would you do that? (I would not use a different library, if possible.)
Upvotes: 6
Views: 5756
Reputation: 2220
I have tried to implement a different approach in Python:
http://code.activestate.com/recipes/577784-line-based-side-by-side-diff/
Failing test cases are welcome.
Upvotes: 1
Reputation: 9971
Assuming you're not attempting to diff HTML, in which case I'd suggest using DaisyDiff, what you probably want to do with diff-match-patch is line differencing, which is described on a project wiki page. Basically it involves generating an array of hash codes, one for each line of the left and right, and keeping track of those hash codes relative to the lines in a map, and then running those arrays through the diffing algorithm. Then you use the diff output in conjunction with the map to rehydrate left and right highlighting as appropriate.
Upvotes: 2