diffy icon indicating copy to clipboard operation
diffy copied to clipboard

How to display as a side-by-side comparison split view?

Open andrewhavens opened this issue 10 years ago • 1 comments

I would like to display the diff as a side-by-side comparison split view. Similar to the GitHub split view:

screen shot 2014-09-30 at 1 26 44 pm

I'm using the following code:

left = 'left document'
right = 'right document'
html = Diffy::Diff.new(left, right).to_s(:html)

Diffy generates the HTML as a list, so I'm not sure how to split it apart in order to display left and right.

andrewhavens avatar Sep 30 '14 20:09 andrewhavens

Diffy doesn't currently have this feature, but I think it'd be relatively easy to add.

You could use Diffy::Diff's enumerable interface to filter out additions or deletions (https://github.com/samg/diffy#custom-formats) and then feed the resulting array back through something like the HTML formatter logic.

I won't have time to tackle this for quite some time, but if you're able to get it to work feel free to send a PR.

Thanks!

samg avatar Oct 05 '14 16:10 samg