caxy / php-htmldiff

A library for comparing two HTML files/snippets and highlighting the differences using simple HTML. Includes support for comparing complex lists and tables
http://php-htmldiff.caxy.com
GNU General Public License v2.0
202 stars 51 forks source link

Why my test result is always wrong? #68

Open argb opened 6 years ago

argb commented 6 years ago

$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>

jschroed91 commented 6 years ago

@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 6 years ago

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.