Highlight text diff on client?

前端 未结 2 1098
一生所求
一生所求 2020-12-14 03:31

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?

相关标签:
2条回答
  • 2020-12-14 03:55

    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.

    0 讨论(0)
  • 2020-12-14 04:11

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

    0 讨论(0)
提交回复
热议问题