Fix instances where a carriage return is replaced with another
- It was causing two <br> elements to be inserted - Now the delete and insert paragraph marks are located next to each other
This commit is contained in:
@@ -20,6 +20,14 @@ class DiffBuilder
|
|||||||
output.each { |q| q.replace(escape_html[q]) }
|
output.each { |q| q.replace(escape_html[q]) }
|
||||||
|
|
||||||
diffs.reverse_each do |hunk|
|
diffs.reverse_each do |hunk|
|
||||||
|
old_cr = hunk[0].try(:old_element)
|
||||||
|
new_cr = hunk[1].try(:new_element)
|
||||||
|
if old_cr && new_cr && old_cr.match?(/^\r?\n$/) && new_cr.match?(/^\r?\n$/)
|
||||||
|
hunk_position = hunk[0].old_position
|
||||||
|
output[hunk_position] = '<del><span class="paragraph-mark">¶</span></del><ins><span class="paragraph-mark">¶</span></ins><br>'
|
||||||
|
next
|
||||||
|
end
|
||||||
|
|
||||||
newchange = hunk.max {|a, b| a.old_position <=> b.old_position}
|
newchange = hunk.max {|a, b| a.old_position <=> b.old_position}
|
||||||
newstart = newchange.old_position
|
newstart = newchange.old_position
|
||||||
oldstart = hunk.min {|a, b| a.old_position <=> b.old_position}.old_position
|
oldstart = hunk.min {|a, b| a.old_position <=> b.old_position}.old_position
|
||||||
|
|||||||
Reference in New Issue
Block a user