0

I am using PEAR text_diff class to get comparison of text. It works correct for plain text, but when I try to compare text with HTML tags, It gives wrong result

is there any way to compare two HTML blocks and in result display text that pre-serv its HTML and show differences like svn

3 Answers 3

0

In my experience, these two are fantastic:

Yes, none of the programs are written in plain PHP. You just run them via PHP:

// Python script:
$html_diff = shell_exec ('python /path/to/htmldiff version1.html version2.html');
// C program:
$html_diff = shell_exec ('/path/to/htmldiff --start-delete="<span class=\'delete\'>" --end-delete="</span>" --start-insert="<span class=\'insert\'>" --end-insert="</span>" version1.html version2.html');

Since they aren't written in PHP, you can enjoy the incredible high speed :)

0

I'm not sure which OS you're on, but I always use Meld on Ubuntu for diff:ing non-versioned files. It doesn't have any problems diffing HTML code (or anything else afaik):

http://meldmerge.org/

1
  • thanks for your reply, But I want text differences using PHP.
    – 235
    Aug 13, 2012 at 12:50
-1

You can do this right in javascript itself. Check out google-diff-match-patch.

Diff demo here.

1
  • 1
    That is not a HTML diff tool.
    – DavidS
    Aug 7, 2012 at 12:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.