我正在尝试使用两个不同的 textarea
s 显示相同的代码,但有一个母版和另一个副本。在副本textarea
,我想强调更改,类似于 GitHub 在我们进行一些更改时提供的内容。
我想知道这是否可能,或者之前是否有人做过类似的事情。欢迎任何建议。
最佳答案
CodeMirror Merge add-on正是你想要的。见 demo ,与您的描述相符。
起初我以为你想要一个单独的差异,显示在 div
中在您的 textarea
下方s 而不是其中之一 textarea
s,我写了以下答案。它可能仍然有用。
Check out the google-diff-match-patch library, used by the CodeMirror Merge add-on. It’s not a drop-in solution, but it looks like you could use
diff_main
to get a list of original and changed text, and then display that yourself. The library also providesdiff_prettyHtml
, which outputs example markup for the diff.
关于textarea - 比较两个不同 CodeMirror textarea 的变化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18852566/