Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why my test result is always wrong? #68

Open
argb opened this issue Nov 26, 2017 · 2 comments
Open

Why my test result is always wrong? #68

argb opened this issue Nov 26, 2017 · 2 comments
Labels

Comments

@argb
Copy link

argb commented Nov 26, 2017

$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
Copy link
Member

@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.

@jschroed91 jschroed91 added the Bug label Nov 26, 2017
@argb
Copy link
Author

argb commented Nov 27, 2017

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants