cdauth / htmldiff

Calculate the difference between two HTML snippets
30 stars 6 forks source link

Fix splitUntil #2

Closed jabouillei closed 8 years ago

jabouillei commented 8 years ago

splitUntil() tries to replace "original" with "part1 part2", but before this commit, it took actions in the wrong order. It added part1, then added part2, then removed original. For example: a b original c d become a b part1 original c d then a b part2 part1 original c d then a b part1 original c d This commit changes the function to first remove original, then add part2, then add part1: a b c d a b part2 c d a b part1 part2 c d

Here is an example problem at the application level: <?php require_once('htmldiff/html_diff.php');

$old="Sentence

These word

"; $new="Sentence

These words

"; echo html_diff($old, $new)."\n"; ?>