基于JavaScript的diff实用程序 [英] JavaScript based diff utility
问题描述
我正在寻找用JavaScript编写的 diff 等价物,它只返回/打印相关的行。我不希望两个全文显示在彼此旁边并突出显示差异,但只是想要实际的差异(加上一些缓冲线来了解差异的位置),类似于linux diff实用程序的输出。
I'm looking for a diff equivalent written in JavaScript that only returns/prints relevant lines. I don't want both full text displayed next to each other with the differences highlighted, but just want the actual differences (plus some buffer lines to know where the difference is), similar to the output from the linux diff utility.
有人知道这样做的javascript函数吗?应该识别所有差异(甚至改变空白)。谢谢。
Does anybody know a javascript function that does this? All differences should be recognized (even changed whitespace). Thanks.
推荐答案
jsdifflib 内联模式比较,尝试调整上下文大小以显示所需的所需更改窗口。有一个演示这里
jsdifflib inline mode comparison, try tweaking the context size to display just the desired window of change you want. There's a demo here
这篇关于基于JavaScript的diff实用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!