添加 的简单内联 diff 算法<删除>与 PHP 和 HTML 一起使用的标签?删除>
我之前尝试过 Paul 的简单 Diff 算法,但效果非常糟糕。它甚至无法显示在字符串末尾仅添加了几个字符,而没有标记据称该字符串的某些内容已被删除。
我需要这样的东西:
string end
begin strngs
<ins>begin </ins>str<del>i</del>ng<ins>s</ins><del> end</del>
I've tried Paul's Simple Diff Algorithm before but it works terribly. It even can't show that only few characters were added at the end of the string without marking that allegedly some of this string was deleted.
I need something like this:
string end
begin strngs
<ins>begin </ins>str<del>i</del>ng<ins>s</ins><del> end</del>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我尝试了 http://www.raymondhill.net/finediff/viewdiff-ex.php 如果您选择“字符”粒度,结果正是您想要的。
I tried http://www.raymondhill.net/finediff/viewdiff-ex.php and the result is exactly what you want, if you select 'character' granularity.
我认为一个好的 diff 算法很大程度上基于启发式方法。这取决于您有什么样的变化以及您希望如何表示它们。
例如:
您可以将其 diff 为:
或:
两者都是准确的(忽略我的任何错误)。
I would argue that a good diff algorithm is largely based on heuristics. It depends on what kind of changes you have and how you would like to represent them.
For instance:
You could diff as:
or:
Both are accurate (omiting any mistakes on my part).