caxy/php-htmldiff

Why my test result is always wrong?

argb opened this issue · 2 comments

argb commented

$a = "<span>abcd</span>";
$b = 'abcd';
$diffConfig = new HtmlDiffConfig();
$diffConfig->setEncoding('UTF-8');
$diff = HtmlDiff::create($a, $b, $diffConfig);

    $diffResult = $diff->build();
    dump($diffResult);

the result is <ins class="mod">abcd</span>
But it should be same. :)

If I change it to below, except the wrong result, the close tag lost also.
$a = '<span>你好</span>';
$b = '你好';
$diffConfig = new HtmlDiffConfig();
$diffConfig->setEncoding('UTF-8');
$diff = HtmlDiff::create($a, $b, $diffConfig);

    $diffResult = $diff->build();

<ins class="mod"><ins class="diffmod"></ins>你好</span>

@argb That is certainly an issue...

Your comment originally mentioned (before edits) that it was working on the demo site but not with your code - this might be related to some of the configuration on the demo site. You can see the configuration here: https://github.com/caxy/php-htmldiff-demo-api/blob/master/src/Diff/DiffEngine/CaxyPhpHtmlDiff.php#L56

This certainly is an issue we'll need fixed.

argb commented

Thanks for your replay. :)
Acctually it has same problems in the demo http://php-htmldiff.caxy.com/. At beginning I thought the demo works well, just my code has problems, but then I checked the html of diff result of the demo, same issue with me, just the css style don't display the changing.
if you check the html source code, you will find the problem. :D

and there is another problem, the the old text has newline symbols \r\n or \n, after diffing, the newline symbols was removed, i think it should keep any text in the old text.