f0d82666514cbc9bf85506d1aa9a3507043a8f9a
[yaffs-website] / vendor / caxy / php-htmldiff / doc / differences.rst
1 Differences from rashid2538/php-htmldiff
2 ========================================
3
4 .. contents:: Table of Contents
5
6 Code Styling and Clean-up
7 -------------------------
8
9 * Added namespaces, split up classes to their own files, some code styling changes
10
11 Enhancements
12 ------------
13
14 * Allow the specialCaseOpeningTags and specialCaseClosingTags properties to be modified by passing an array into the constructor or using set/add/remove functions
15 * Updated the demo to accept input and diff via AJAX
16 * Added static properties for the default config variables
17
18 Bug Fixes
19 ---------
20
21 * Fixed an index out of range bug (may have been fixed on the original repo since): c9ba1fa_
22 * Check for empty oldText or newText before processing del or ins in processReplaceOperation function
23
24 New Features
25 ------------
26
27 Isolated Diffing of certain HTML elements
28 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
29
30 This is the one of the largest changes from the original repository.
31
32 For more information, see the release notes for tag `0.0.6`_
33
34 List Diffing
35 ^^^^^^^^^^^^
36
37 Similar to the Isolated Diffing feature, but specifically for HTML lists.
38
39 More information is to come on this, and there will definitely be some tweaks and configuration options added for this
40 feature. Currently there is no easy way to enable/disable the feature, so if you're having issues with it I suggest
41 using the `0.0.6`_ or earlier release.
42
43 Table Diffing
44 ^^^^^^^^^^^^^
45
46 Similar to the Isolated Diffing and List Diffing features, but specifically for HTML tables.
47
48 More information to come on this soon.
49
50 New option to group together diffed words by not matching on whitespace-only. Option is enabled by default.
51 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
52
53 This was a specific requirement for an application we use this library for. The original library would replace
54 single words at a time, but enabling this feature will group replacements instead. See example below.
55
56 Old Text::
57
58     testing some text here and there
59
60 New Text::
61
62     testing other words here and there
63
64 With $groupDiffs = false (original functionality)::
65
66     testing <del>some</del><ins>other</ins> <del>text</del><ins>words</ins> here and there
67
68 With $groupDiffs = true (new feature)::
69
70     testing <del>some text</del><ins>other words</ins> here and there
71
72 Change diffing to strike through entire words/numbers if they contain periods or commas within the word
73 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
74
75 This change introduced a new property ``$specialCaseChars``, which defaults to the following characters: ``.`` ``,`` ``(`` ``)`` ``'``
76
77 This feature can be "disabled" by simply setting the $specialCaseChars to an empty array i.e. ``$diff->setSpecialCaseChars(array())``
78
79 In the original library, special characters are treated as their own "words" even if they are in the middle of a word.
80 This causes weird things to happen when diffing numbers that have a comma or a period in the middle of the number.
81
82 For example, diffing ``10,000.50`` against ``11,100.75`` gives you:
83
84 Original Functionality::
85
86     <del class="diffmod">10</del><ins class="diffmod">11</ins>,<del class="diffmod">000</del><ins class="diffmod">100</ins>.<del class="diffmod">50</del><ins class="diffmod">75</ins>
87
88 This is very difficult to read, so the new feature allows you to add ``.`` and ``,`` to the ``$specialCaseChars`` array in order
89 to get output that looks like::
90
91     <del class="diffmod">10,000.50</del><ins class="diffmod">11,100.75</ins>
92
93 Note: It will *not* treat the specialCaseChars as part of the word if it is at the beginning or end of the word,
94 so normal periods or commas at the end of words will still be diffed like the original.
95
96 Added option to insert a space between ``<del>`` and ``<ins>`` tags. Disabled by default.
97 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
98
99 This was a requirement for one our applications that uses this library.
100
101 New property ``$insertSpaceInReplace`` was added, and setting it to true will simply add a space between
102 the ``<del>`` and ``<ins>`` tags in replace operations, which was requested for easier reading.
103
104 Enable it by calling ``$diff->setInsertSpaceInReplace(true);``
105
106 Original Functionality::
107
108     <del>Old</del><ins>New</ins>
109
110 New Functionality::
111
112     <del>Old</del> <ins>New</ins>
113
114 .. _c9ba1fa: https://github.com/caxy/php-htmldiff/commit/c9ba1fab6777cd47427477f8d747293bb01ef1e8
115 .. _0.0.6: https://github.com/caxy/php-htmldiff/releases/tag/0.0.6
116