Releases: caxy/php-htmldiff
0.0.12
Merge pull request #20 from caxy/feature-list_diffing-new feature-list_diffing-new
Additional fixes for List Diffing
Merge pull request #19 from caxy/feature-list_diffing-new Feature list diffing new
Fix for List Diffing and setting a minimum match threshold percentage for list items
Merge pull request #17 from caxy/feature-list_diffing-new Fix: Updated code so that null is not given in list formatting.
Fix issue in PHP versions < 5.5 (again)
Merge pull request #16 from caxy/feature-list_diffing-new Missed an array_column in ListDiff. Updated to use ArrayColumn function.
Fix issue in PHP versions < 5.5
Merge pull request #15 from caxy/feature-list_diffing-new Added update for php versions that do not have array_column as a function.
Add custom diffing logic for HTML Lists
Merge pull request #14 from caxy/feature-list_diffing-new Created ListDiff class to handle diffing of lists.
Isolated Diffing of Special HTML Tags
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.
Isolated Diffing of Special HTML Tags
Purpose
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.
The Problem
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.
Solution
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.
Variable and function visibility updates
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
Check for empty oldText or newText before processing del or ins in processReplaceOperation
Add option to insert a space between del and ins tags
Add option to insert a space between del and ins tags - this is only done in replacements, and will insert a space between the <del>
and <ins>
tags in the replace operation.