2017 © Pedro Peláez
 

library htmldiff

Compare two HTML strings

image

gathercontent/htmldiff

Compare two HTML strings

  • Wednesday, April 15, 2015
  • by acairns
  • Repository
  • 8 Watchers
  • 11 Stars
  • 21,044 Installations
  • PHP
  • 2 Dependents
  • 0 Suggesters
  • 2 Forks
  • 3 Open issues
  • 4 Versions
  • 22 % Grown

The README.md

Htmldiff

Build Status, (*1)

Compare two HTML strings. This library converts HTML into a form that can be diffed using the algorithm found in Git or Linux (comparing entire lines of code) to achieve greater accuracy, then decodes it back into a valid HTML., (*2)

Requirements

  • PHP 5.3.0 or later
  • Tidy extension for PHP

Installation

Add Htmldiff to your composer.json file:, (*3)

"require": {
    "gathercontent/htmldiff": "0.2.*"
}

Get composer to install the package:, (*4)

$ composer update gathercontent/htmldiff

Usage

The input is going to be parsed by Tidy before diffing. Here's a few examples:, (*5)

$old = '<span>This is a string</span>';
$new = '<span>This is a text</span>';

$htmldiff = new Htmldiff;
$result = $htmldiff->diff($old, $new);

// result: <span>This is a <del>string</del><ins>text</ins></span>
$old = '

Hello world, how do you do, (*6)

'; $new = '

Hello world, how do you do, (*7)

'; $htmldiff = new Htmldiff; $result = $htmldiff->diff($old, $new); // result:

Hello world, how do youyou do, (*8)

$old = '

Hello world, (*9)

How do you do, (*10)

'; $new = '

Hello world, (*11)

  • first point
  • second point

How do you do, (*12)

'; $htmldiff = new Htmldiff; $result = $htmldiff->diff($old, $new); // result:

Hello world, (*13)

  • first point
  • second point

How do you do, (*14)

Testing

Run unit tests:, (*15)

``` bash $ ./vendor/bin/phpunit, (*16)


Test compliance with [PSR2 coding style guide](http://www.php-fig.org/psr/psr-2/): ``` bash $ ./vendor/bin/phpcs --standard=PSR2 ./src

Licence

The MIT License (MIT) - see README.md, (*17)

The Versions

15/04 2015

dev-master

9999999-dev

Compare two HTML strings

  Sources   Download

MIT

The Requires

 

The Development Requires

by Mathew Chapman

15/04 2015

0.2.1

0.2.1.0

Compare two HTML strings

  Sources   Download

MIT

The Requires

 

The Development Requires

by Mathew Chapman

31/07 2014

0.2.0

0.2.0.0

Compare two HTML strings

  Sources   Download

MIT

The Requires

 

The Development Requires

by Mathew Chapman

25/04 2014

0.1.0

0.1.0.0

Compare two HTML strings

  Sources   Download

MIT

The Requires

 

The Development Requires

by Mathew Chapman