diffy
diffy copied to clipboard
How to display as a side-by-side comparison split view?
I would like to display the diff as a side-by-side comparison split view. Similar to the GitHub split view:
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.
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!