caxy/php-htmldiff
Compare two HTML snippets/files and generate a marked-up diff highlighting insertions, deletions, and changes. Easy Composer install, simple API (HtmlDiff->build()), configurable behavior and CSS-friendly output; includes a live demo and Symfony bundle option.
Full Changelog: https://github.com/caxy/php-htmldiff/compare/v0.1.16...v0.1.17
Full Changelog: https://github.com/caxy/php-htmldiff/compare/v0.1.15...v0.1.16
Full Changelog: https://github.com/caxy/php-htmldiff/compare/v0.1.14...v0.1.15
This release mainly removed everything that is related to the concept of special-case-tags. This was adopted from the original library by rashid2538 that this fork is based on.
The feature tried to wrap the special tags in an extra <ins / del class='mod'> tag.
However, this never really worked properly (the closing tag was not always added to the diff output) and usually ended up crippling the HTML.
Given the feature never really worked, and there is no clear use-case for it, I decided to remove it and fix issue 106 and issue 69 in the process where it was sometimes impossible to diff html that contained these special tags or unexpected extra tags got added to the output.
In case you really needed this feature, please open an issue explaining your use-case, in that case this decision can be revisited.
.gitattributes file to exclude demo and tests from the exported zip package to reduce package size when installed via composer (#86 - @danepowell )The changes to the list diffing are substantial, and we have tested as much as possible, to make sure the output stays the same between this version and the previous version.
If there are issues cropping up with list diffing after updating to this version feel free to open an issue
In order to be compatible with PHP8 we had to upgrade some vendor packages.
Since these vendor packages have dropped support for older versions of PHP we had todo the same, therefore this version is not compatible anymore with PHP versions prior to 7.3.
In case you are not able to upgrade your PHP version, please pin version v0.1.9 of php-htmldiff in your composer config.
Bugfixes:
[Bug] HTMLPurifier Permission Fix (#63) (@snebes)
[BUG] changes the [] arrays to array() as it does not work in php 5.3 (@myfriend12)
Bug fixes
Features and Enhancements:
Thank you @SavageTiger again for the drastic performance improvements and the Release Notes!
Bug fixes
Features and Enhancements:
Thank you @SavageTiger for your bugfix contribution, and for the Release Notes!
Features and Enhancements:
Miscellaneous:
Features and Enhancements:
New Feature: Table Diffing Enhancement: Detecting link changes
Note: There are many changes to the HtmlDiff class in this release. A new AbstractDiff class was created and HtmlDiff extends this new class, and many of the common functions have been moved into the AbstractClass in preparation for some upcoming features and enhancements for the diffing of lists and tables.
The purpose of these changes is to isolate certain HTML elements in the old and new texts and diff them against the matching element (if one exists), in order to prevent issues with matches in old and new text overlapping certain HTML elements.
As an example, let's say you have the following inputs:
Old Text
Testing text with <sup>superscript</sup>
New Text
Testing text with superscript
Output Before These Changes
Testing some text with <ins class="mod">superscript</ins>
Output After These Changes
Testing some text with <sup class="diffmod"><del class="diffmod">superscript</del></sup><ins class="diffmod">superscript</ins>
As you can see in this example, before these changes were made it was seeing the match on the word superscript in both, but was not accounting for the fact that the word was in superscript in the old text and is no longer in superscript in the new text.
The solution that was implemented in this release was to encapsulate certain HTML elements and diff them separately from the rest of the text, in order to prevent issues with matches overlapping HTML elements.
Currently, the elements to isolate and diff are: ol, ul, dl, sup, sub, and table.
These are set on a protected property on the HtmlDiff class: $isolatedDiffTags. In this release, this property is not exposed to be configured, but there are additional updates coming soon that will allow configuration of the elements to be handled in this manner.
Properties and functions in HtmlDiff.php have been updated to protected visibility instead of private to allow for extending the class.
Check for empty oldText or newText before processing del or ins in processReplaceOperation
How can I help you explore Laravel packages today?