-
-
Notifications
You must be signed in to change notification settings - Fork 60
Open
Labels
Description
I'm liking the output of sdiff but each "segment" is a separate object. Would it be possible to merge adjacent objects with similar actions into 1 object?
In my case I'm feeding in arrays of sentences. If someone adds a paragraph, the difference is shown as a collection of new sentences. Instead, I would like one <ins> tag around the whole new paragraph.
Update: This is what I've done to accommodate for now
def consolidateDiff(sdiff)
lastAction = ''
sdiff.each_with_index do |diff, index|
if diff.action == lastAction
sdiff[index-1].old_element << diff.old_element unless sdiff[index-1].old_element.nil?
sdiff[index-1].new_element << diff.new_element unless sdiff[index-1].new_element.nil?
sdiff.delete_at(index)
consolidateDiff(sdiff)
end
lastAction = diff.action
end
end