What is a PHP library that will show inline diffs?
I'm looking for a PHP library that will provide me inline diffing between two st开发者_如何学运维rings, like this: http://grabby.info/dfe2835f606443757ae7c18404e71781.png.
I'm using xdiff currently, but it's crossing out the entire line when a single word changes, and that's not what I want.
Any suggestions?
I used xdiff for this to highlight changes in the text of an html page. The basic workflow was:
- escape all HTML entities
- split HTML tags onto their own lines (append
\n
after the closing>
) - split the resulting text on whitespace (eliminating duplicate whitespace)
- rejoin the results of the previous split with
\n
as the separator, so now all tags and words are onseparate
lines - do the diff with
[xdiff_string_diff()][1]
- Patch up the diff output to highlight the additions/deletions with the appropriate tags
not particularly efficient, and very top-heavy on extra wrapping tags if you've got a long sequence of ads/deletions, but it did the job.
精彩评论