@@ -11,7 +11,7 @@ class HtmlDiff extends AbstractDiff
11
11
protected $ isolatedDiffTags = array ('ol ' => '[[REPLACE_ORDERED_LIST]] ' , 'ul ' => '[[REPLACE_UNORDERED_LIST]] ' , 'sub ' => '[[REPLACE_SUB_SCRIPT]] ' , 'sup ' => '[[REPLACE_SUPER_SCRIPT]] ' , 'dl ' => '[[REPLACE_DEFINITION_LIST]] ' , 'table ' => '[[REPLACE_TABLE]] ' );
12
12
13
13
/**
14
- * @param boolean $boolean
14
+ * @param boolean $boolean
15
15
* @return HtmlDiff
16
16
*/
17
17
public function setInsertSpaceInReplace ($ boolean )
@@ -34,7 +34,7 @@ public function build()
34
34
$ this ->splitInputsToWords ();
35
35
$ this ->replaceIsolatedDiffTags ();
36
36
$ this ->indexNewWords ();
37
-
37
+
38
38
$ operations = $ this ->operations ();
39
39
foreach ($ operations as $ item ) {
40
40
$ this ->performOperation ( $ item );
@@ -78,9 +78,9 @@ protected function createIsolatedDiffTagPlaceholders(&$words)
78
78
}
79
79
$ openIsolatedDiffTags ++;
80
80
$ currentIsolatedDiffTag = $ openIsolatedDiffTag ;
81
- } elseif ($ openIsolatedDiffTags > 0 && $ this ->isClosingIsolatedDiffTag ($ word , $ currentIsolatedDiffTag )) {
81
+ } elseif ($ openIsolatedDiffTags > 0 && $ this ->isClosingIsolatedDiffTag ($ word , $ currentIsolatedDiffTag )) {
82
82
$ openIsolatedDiffTags --;
83
- if ($ openIsolatedDiffTags == 0 ){
83
+ if ($ openIsolatedDiffTags == 0 ) {
84
84
$ isolatedDiffTagIndicies [] = array ('start ' => $ isolatedDiffTagStart , 'length ' => $ index - $ isolatedDiffTagStart + 1 , 'tagType ' => $ currentIsolatedDiffTag );
85
85
$ currentIsolatedDiffTag = null ;
86
86
}
@@ -107,17 +107,19 @@ protected function isOpeningIsolatedDiffTag($item, $currentIsolatedDiffTag = nul
107
107
return $ key ;
108
108
}
109
109
}
110
+
110
111
return false ;
111
112
}
112
113
113
114
protected function isClosingIsolatedDiffTag ($ item , $ currentIsolatedDiffTag = null )
114
115
{
115
116
$ tagsToMatch = $ currentIsolatedDiffTag !== null ? array ($ currentIsolatedDiffTag => $ this ->isolatedDiffTags [$ currentIsolatedDiffTag ]) : $ this ->isolatedDiffTags ;
116
117
foreach ($ tagsToMatch as $ key => $ value ) {
117
- if (preg_match ("#</ " .$ key ."[^>]*> \\s*#iU " , $ item )) {
118
+ if (preg_match ("#</ " .$ key ."[^>]*> \\s*#iU " , $ item )) {
118
119
return $ key ;
119
120
}
120
121
}
122
+
121
123
return false ;
122
124
}
123
125
@@ -152,7 +154,7 @@ protected function processInsertOperation($operation, $cssClass)
152
154
$ text = array ();
153
155
foreach ($ this ->newWords as $ pos => $ s ) {
154
156
if ($ pos >= $ operation ->startInNew && $ pos < $ operation ->endInNew ) {
155
- if (in_array ($ s , $ this ->isolatedDiffTags ) && isset ($ this ->newIsolatedDiffTags [$ pos ])) {
157
+ if (in_array ($ s , $ this ->isolatedDiffTags ) && isset ($ this ->newIsolatedDiffTags [$ pos ])) {
156
158
foreach ($ this ->newIsolatedDiffTags [$ pos ] as $ word ) {
157
159
$ text [] = $ word ;
158
160
}
@@ -195,6 +197,7 @@ protected function diffElements($oldText, $newText)
195
197
$ newText = preg_replace ($ pattern , '' , $ newText );
196
198
197
199
$ diff = new HtmlDiff ($ oldText , $ newText , $ this ->encoding , $ this ->isolatedDiffTags , $ this ->groupDiffs );
200
+
198
201
return $ wrapStart . $ diff ->build () . $ wrapEnd ;
199
202
}
200
203
0 commit comments