2017 © Pedro Peláez
 

library html-diff

A PHP5 library that diffs (compares) HTML files.

image

icap/html-diff

A PHP5 library that diffs (compares) HTML files.

  • Friday, November 25, 2016
  • by eddymarques
  • Repository
  • 5 Watchers
  • 30 Stars
  • 43,100 Installations
  • PHP
  • 4 Dependents
  • 0 Suggesters
  • 3 Forks
  • 2 Open issues
  • 5 Versions
  • 6 % Grown

The README.md

HtmlDiff

A PHP5 library that diffs (compares) HTML files., (*1)

This library is actually a transfer of the daisy-diff library for PHP, found here for gitgub, meeting the PSR-4 standards. The library was developped in 2008 and is used today by many wiki platforms (wikipedia, wikihub, gamepedia, etc). It is part of code of the MediaWiki package., (*2)

Setup

Requirements

  • PHP >=5.3.0
  • Pimple 1.0.*
  • Silex 1.0.*

Installation

The easiest way to install HtmlDiff is using Composer with the following requirement:, (*3)

    {
        "require": {
            ...
            "icap/html-diff": ">=1.0.1"
        }
    }

Alternatively, you can download the archive and add the src/ folder to PHP's include path:, (*4)

    set_include_path('/path/to/src' . PATH_SEPARATOR . get_include_path());

Usage

To find and render the differences between two html blocks html you need include the HtmlDiff class, (*5)

    use Icap\HtmlDiff\HtmlDiff;

and then initialize a new HtmlDiff class object with the following attributes: - the old html text/block (String) - the new html text/block (String) - the option to enable or not formatting changes (Boolean) (set this to true if beside the adds and removes you also want to display the different style modifications of the nodes/elements), (*6)

Then call the outputDiff function of the class to retrieve the result with the compared version and the modifications., (*7)

    $htmlDiff = new HtmlDiff($oldText, $newText, true);
    $out = $htmlDiff->outputDiff();
    //Then
    $out->toString();//to get the compared version
    //And
    $out->getModifications();//to retrieve the number of differences/modifications between the two blocks.

The output is a ChangeText, (*8)

You can always refer to the demo/examples for further help. In the given examples we use two different styles to render the compared html result. Feel free to copy and use these styles in your application., (*9)

Modifications compared to the original library

  • In the ChangeText object a new attribute was added (modifications) to count the differences found between the two texts. These differences are given in a form of an array ('added' => #, 'changed' => #, 'removed' => #)
  • The details tooltip was removed
  • All the MediaWiki general functions (which are defined here) used by the HtmlDiff module, were replaced with some simple/dummy ones so as the module runs without them.
  • In the converted html output all the 'added' and 'deleted' span tags were replaced by 'ins' and 'del' tags respectively for WAI compliance reasons.

Tests

Since the library is a tranfer of an already tested (hopefully) library, no tests were created or executed., (*10)

Known issues

There is a known issue with table comparison reported here Thow it is referring to the java version of the library, the same issue exists in the PHP version., (*11)

The Versions

25/11 2016

dev-master

9999999-dev

A PHP5 library that diffs (compares) HTML files.

  Sources   Download

The Requires

  • php >=5.3.0

 

The Development Requires

  • php >=5.3.0

by Panagiotis Tsavdaris

html diff daisy diff

17/02 2016

v1.1.0

1.1.0.0

A PHP5 library that diffs (compares) HTML files.

  Sources   Download

The Requires

  • php >=5.3.0

 

The Development Requires

  • php >=5.3.0

by Panagiotis Tsavdaris

html diff daisy diff

16/01 2014

v1.0.2

1.0.2.0

A PHP5 library that diffs (compares) HTML files.

  Sources   Download

The Requires

  • php >=5.3.0

 

The Development Requires

  • php >=5.3.0

by Panagiotis Tsavdaris

html diff daisy diff

24/10 2013

v1.0.1

1.0.1.0

A PHP5 library that diffs (compares) HTML files.

  Sources   Download

The Requires

  • php >=5.3.0

 

The Development Requires

by Panagiotis Tsavdaris

html diff daisy diff

14/10 2013

v1.0.0

1.0.0.0

A PHP5 library that diffs (compares) HTML files.

  Sources   Download

The Requires

  • php >=5.3.0

 

The Development Requires

by Panagiotis Tsavdaris

html diff daisy diff