0.0
No commit activity in last 3 years
No release in over 3 years
HTML diffs of text (borrowed from a wiki software I no longer remember)
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

>= 1.6.5
 Project Readme

HTMLdiff

This gem generates nice diff outputs (in HTML) from two supplied bits of HTML which are (presumably) partially different. It is aimed at the limited HTML that one would expect to be outputted from a WYSIWYG editor.

It is not foolproof and only gives good results with a limited (and not fully documented) range of HTML tags. See the specs for stuff that is known to work. Beyond that you're on your own!

Usage

doc_a = 'a word is here'
doc_b = 'a nother word is there'

HTMLDiff.diff(doc_a, doc_b)

# => 'a<ins class=\"diffins\"> nother</ins> word is <del class=\"diffmod\">here</del><ins class=\"diffmod\">there</ins>'

Block tags

If you have some things which need to be treated as one unified lump of HTML that has been added or taken away e.g. an embedded document composed of a div with some images in it, then add class="block_tag" to the opening div tag. The diff will then surround the whole thing with an <ins> or <del> tag, as well as showing the whole thing as replaced with a new version if any of the content changes.

Credits

This is a fork of the htmldiff gem here https://github.com/myobie/htmldiff/ which appears to no longer be maintained. It has been refactored internally and made to be more useful when comparing the diff generated by HTML editors.