caxy / php-htmldiff

A library for comparing two HTML files/snippets and highlighting the differences using simple HTML. Includes support for comparing complex lists and tables
http://php-htmldiff.caxy.com
GNU General Public License v2.0
202 stars 51 forks source link

the difference between rashid2538/php-htmldiff #21

Closed gondo closed 8 years ago

gondo commented 8 years ago

hi what exactly is the difference between the original repo? a lot of the code was rewritten and it is not clear what changed. can you clarify this in readme file?

also there seems to be missing bug fixe merged into the original repo: https://github.com/rashid2538/php-htmldiff/pull/21

and some code clean up not merged (dont know why) into original repo: https://github.com/rashid2538/php-htmldiff/pull/14

jschroed91 commented 8 years ago

@gondo Good questions - we've been meaning to document this for quite some time but haven't gotten around to doing so. I should have time to do that in the near future.

I also want to check in with the original owner to see if they would be interested in some of the larger changes we have made.

Feel free to put up a pull request for the missing bug fix in the original repo, otherwise I will find some time to include it sometime next week.

I don't have time to compile a full list or details on the changes we have made, but here are some of the bigger things:

Code Styling and Clean-up

Enhancements

Bug Fixes

New Features

Isolated Diffing of certain HTML elements

This is the one of the largest changes from the original repository.

See the release notes for tag 0.0.6 for more information: https://github.com/caxy/php-htmldiff/releases/tag/0.0.6

List Diffing

This is the latest new feature (as of last week-ish), and may need some tweaks still. It is similar to the Isolated Diffing feature, but specifically for HTML lists.

More information is to come on this, and there will definitely be some tweaks and configuration options added for this feature. Currently there is no easy way to enable/disable the feature, so if you're having issues with it I suggest using the 0.0.6 or earlier release.

New option to group together diffed words by not matching on whitespace-only. Option is enabled by default.

This was a specific requirement for an application we use this library for. The original library would replace single words at a time, but enabling this feature will group replacements instead. See example below.

Old Text

testing some text here and there

New Text

testing other words here and there

With $groupDiffs = false (original functionality)

testing someother textwords here and there

With $groupDiffs = true (new feature)

testing some textother words here and there

Change diffing to strike through entire words/numbers if they contain periods or commas within the word

This change introduced a new property $specialCaseChars, which defaults to the following characters: . , ( ) '

This feature can be "disabled" by simply setting the $specialCaseChars to an empty array i.e. $diff->setSpecialCaseChars(array())

In the original library, special characters are treated as their own "words" even if they are in the middle of a word. This causes weird things to happen when diffing numbers that have a comma or a period in the middle of the number.

For example, diffing 10,000.50 against 11,100.75 gives you:

Original Functionality:

1011,000100.5075

This is very difficult to read, so the new feature allows you to add . and , to the $specialCaseChars array in order to get output that looks like:

10,000.5011,100.75

Note: It will not treat the specialCaseChars as part of the word if it is at the beginning or end of the word, so normal periods or commas at the end of words will still be diffed like the original.

Added option to insert a space between <del> and <ins> tags. Disabled by default.

This was a requirement for one our applications that uses this library.

New property $insertSpaceInReplace was added, and setting it to true will simply add a space between the <del> and <ins> tags in replace operations, which was requested for easier reading.

Enable it by calling $diff->setInsertSpaceInReplace(true);

Original Functionality

OldNew

New Functionality

Old New

Upcoming Features (someday)