Class | HTMLDiff::DiffBuilder |
In: |
lib/htmldiff.rb
|
Parent: | Object |
VALID_METHODS | = | [:replace, :insert, :delete, :equal] |
This method encloses words within a specified tag (ins or del), and adds this into @content, with a twist: if there are words contain tags, it actually creates multiple ins or del, so that they don‘t include any ins or del. This handles cases like old: ’<p>a</p>’ new: ’<p>ab</p><p>c</b>’ diff result: ’<p>a<ins>b</ins></p><p><ins>c</ins></p>’ this still doesn‘t guarantee valid HTML (hint: think about diffing a text containing ins or del tags), but handles correctly more cases than the earlier version.
P.S.: Spare a thought for people who write HTML browsers. They live in this … every day.