Highlight text diff on client?

我们两清 提交于 2019-12-17 23:23:43

问题


I want to compare 2 text values on a web page and highlight the differences. Can I do this client-side, preferably with jQuery or Prototype?


回答1:


This diff-patch-match library appears to do a really good job:

http://code.google.com/p/google-diff-match-patch/

The project has JavaScript, C#, C++, Python, and Java implementations that all do the same thing.




回答2:


Check out the the wikEd diff library and the online tool and demo.

The library creates inline text comparisons with block move highlighting and is character/word-based. It has been optimized for Wikipedia, but works equally well for other text types and program code. The library code is customizable, has Unicode support, is extensively commented, and is free (PD).



来源:https://stackoverflow.com/questions/3892657/highlight-text-diff-on-client

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!