cdauth/htmldiff


Calculate the difference between two HTML snippets

Language: PHP


htmldiff is a PHP library that displays the difference between two HTML snippets. It is taken from the MediaWiki Visual Diff module and has been modified to be usable outside of MediaWiki.

Usage

require("htmldiff/html_diff.php");

$html1 = "<p>This is an example text with a <strong>bold part</strong>.</p>";
$html2 = "<p>This is a changed example text without a bold part.</p>";

echo html_diff($html1, $html2);

Output:

<p>This is <span class="diff-html-removed" id="removed-htmldiff-0">an </span><span class="diff-html-added" id="added-htmldiff-0">a changed </span>example text <span class="diff-html-removed" id="removed-htmldiff-1">with </span><span class="diff-html-added" id="added-htmldiff-1">without </span>a bold part.</p>

License

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. or see http://www.gnu.org/

Sources

These are the original MediaWiki source files that this library is based on: HTMLDiff.php, Diff.php, Nodes.php, Sanitizer.php, Xml.php

Project Statistics

Sourcerank 4
Repository Size 39.1 KB
Stars 21
Forks 6
Watchers 5
Open issues 2
Dependencies 0
Contributors 4
Tags 0
Created
Last updated
Last pushed

Top Contributors See all

Candid Dauth Christiaan Baartse Chris Lewis jabouillei

Interesting Forks See all

original-brownbear/htmldiff
Calculate the difference between two HTML snippets
PHP - Last pushed - 2 stars

Something wrong with this page? Make a suggestion

Last synced: 2017-07-24 22:36:38 UTC

Login to resync this repository