Skip to content

Commit acd361c

Browse files
pharixcesAnne Zijlstra
andauthored
Correctly match newlines whitin htmltags. (#122)
* Correctly match newlines in tags. * Revert regex to current implementation while adding the PCRE_DOTALL modifier. --------- Co-authored-by: Anne Zijlstra <[email protected]>
1 parent 88f817a commit acd361c

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

lib/Caxy/HtmlDiff/AbstractDiff.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,7 @@ protected function convertHtmlToListOfWords(string $text) : array
433433
// Normalize no-break-spaces to regular spaces
434434
$text = str_replace("\xc2\xa0", ' ', $text);
435435

436-
preg_match_all('/<.+?>|[^<]+/mu', $text, $sentencesAndTags, PREG_SPLIT_NO_EMPTY);
436+
preg_match_all('/<.+?>|[^<]+/mus', $text, $sentencesAndTags, PREG_SPLIT_NO_EMPTY);
437437

438438
foreach ($sentencesAndTags[0] as $sentenceOrHtmlTag) {
439439
if ($sentenceOrHtmlTag === '') {
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<options>
2+
<option type="boolean" name="setKeepNewLines" value="true" />
3+
<option type="boolean" name="setPurifierEnabled" value="false" />
4+
</options>
5+
6+
<oldText>
7+
<li
8+
attribute="value">
9+
value
10+
</li>
11+
</oldText>
12+
13+
<newText>
14+
<li
15+
attribute="value">
16+
newvalue
17+
</li>
18+
</newText>
19+
20+
<expected>
21+
<li
22+
attribute="value">
23+
<del class="diffmod">value</del><ins class="diffmod">newvalue</ins>
24+
</li>
25+
</expected>

0 commit comments

Comments
 (0)