Class HTMLDiff::DiffBuilder
In: lib/htmldiff.rb
Parent: Object

Methods

Constants

VALID_METHODS = [:replace, :insert, :delete, :equal]

Public Class methods

Public Instance methods

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.

[Validate]