Compare Revisions Add-On
This add-on compares the renderd HTML output of two revisions and shows the differences broken down to the word-by-word level if necessary. The output can be formatted by templates and skins.
The CompareRevisionsAddOn compares two revisions of a document, like rdiff
does. But in contrast to normal rdiff
, the comparison is done with the rendered HTML output of the revisions instead of the Foswiki source text files. (This feature was proposed by many of our users, who found the normal rdiff
output too technical - even with the sidebyside
option - and wanted to see
differences in the content of the page).
Furthermore, the differences between the revisions are shown as close as possible. If necessary, this means that different words are marked instead of whole lines or even paragraphs.
The differences may be shown in two formats, either side-by-side or as an interwoven output of the old and new revision (like it is done in Word or StarOffice/!OpenOffice):
- Screenshot of interwoven output:
- Screenshot of side-by-side output:
These screenshots have been taken from CompareRevisionsAddOnDemoTopic
The appearance can be affected by templates and skins.
from your browser
Revision numbers of the two revisions which should be compared.
Defaults to the last two revisions. (More exact:
defaults to the latest edition, rev1
defaults to rev2
Chooses the output format. May also be given in the preference variable COMPARERENDERSTYLE
The number n
of unchanged sections which should be shown around changed sections.
A section means a top-level section like a paragraph, table, etc.
(the default), all unchanged sections are shown.
May also be given in the preference variable COMPARECONTEXT
for the output. See section Templates
The output of the script is rendered by templates. Two templates are needed,
) for the side-by-side format,
) for the interwoven
The templates itself are broken into 7 parts
template for start of page
template for unchanged section
which is not printed according to context
template for unchanged section
which is printed
template for changed section
template for added section
template for deleted section
template for end of page
All empty templates for a section default to their predecessor. (E.g. if you
do not specify a template for a deleted section, it defaults to the template
for an added section, which in turn may default to the template for a changed section).
In the templates for a section,
is replaced by the text of the old revision
is replaced by the text of the new revision.
In interwoven output, only
Examples for templates can be found in the default template files from
the distribution (
The differences in the two revisions are marked with the help of
CSS style classes, whose appearance should be defined in the templates.
The following classes are used:
Class for added items (i.e. items which are in the newer revision,
but not yet in the older one)
Class for deleted items (i.e. items which are in the older revision,
but no more in the newer one)
Class for the items from the older revision which have been changed.
Class for the items from the newer revision which have been changed.
In the default templates files from the distribution, the classes
are defined with
a light red background and stroken out text, and
are defined with a light green background.
Add-On Installation Instructions
You do not need to install anything on the browser to use this add-on. The following instructions are for the administrator who installs the add-on on the server where Foswiki is running.
- This script needs some additional Perl modules. If necessary, download and install the required perl modules from CPAN. If you do not want to install these modules in your standard perl location, install them in /your/twiki/lib. (See e.g. perldoc perlmodinstall on how to install perl modules).
These modules are required:
- HTML::Tree (with HTML::TreeBuilder and HTML::Element). These modules in turn need
- Algorithm::Diff (which is included in the standard Foswiki installation
- Download the ZIP file from the Add-on Home (see below)
CompareRevisionsAddOn.zip in your twiki installation directory. Content:
| File: || Description: |
| Add-on topic |
| Add-on script |
| Perl package used by the script |
| Template for side-by-side output |
| Same for pattern skin |
| Template for interwoven output |
| Same for pattern skin |
| Helper plugin |
| Plugin topic |
| Interwoven screenshot |
| Side-by-side screenshot |
| Demonstration topic |
| Demonstration topic history |
- Test if the installation was successful:
%SCRIPTURL%/compare/Web/Topic with some existing topic. (Try for instance CompareRevisionsAddOnDemoTopic and compare your output with above screenshots).
- Enable the helper plugin CompareRevisionsAddonPlugin with the configure script
- This plugin will support the HistoryPlugin, if it is enabled
- If you disable this plugin, the skin will behave like standard PatternSkin again
Related Topic: ContributedAddOns
| Plugin Author:
| Copyright ©:
|| 2006, JChristophFuchs; 2008 Kenneth Lavrsen and Foswiki Contributors
|| GPL (GNU General Public License)
| Plugin Version:
|| 09 Jan 2009
| Change History:
| 09 Jan 2009
|| Gilmar Santos Jr: fixed ambigous print (Foswiki:Tasks.Item716)
| 08 Dec 2008
|| Kenneth Lavrsen: Changed the author to myself. JChristophFuchs is the original author but announced in 2006 that he no longer maintains this plugin. So now I officially take the task as maintainer. Plugin is changed to Foswiki namespace and tested and works under Foswiki 1.0.0. Policy is now feel free to modify but please do not break compatibility.
| 07 Nov 2007
|| Arthur Clemens: Updated for TWiki 4.2
| 09 Apr 2006
|| Updated for new PatternSkin in TWikiRelease04x00x02
| 26 Feb 2006
|| Updated for TWiki 4
| 02 Mar 2005
|| Corrected bug concerning uninitialized elements
| 03 Feb 2005
|| Removed blank paragraphs before comparing
| 20 Jan 2005
|| Initial version
| CPAN Dependencies:
|| HTML::Parser, HTML::Tagset, HTML::Tree
| Other Dependencies:
| Perl Version:
| Add-on Home: