def insert_tag(tagname, cssclass, words)
      loop do
        break if words.empty?
        non_tags = extract_consecutive_words(words) { |word| not tag?(word) }
        @content << wrap_text(non_tags.join, tagname, cssclass) unless non_tags.empty?

        break if words.empty?
        @content += extract_consecutive_words(words) { |word| tag?(word) }
      end
    end
def insert_tag(tagname, cssclass, words)
      loop do
        break if words.empty?
        non_tags = extract_consecutive_words(words) { |word| not tag?(word) }
        @content << wrap_text(non_tags.join, tagname, cssclass) unless non_tags.empty?

        break if words.empty?
        @content += extract_consecutive_words(words) { |word| tag?(word) }
      end
    end
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.