1.0.4 • Published 5 years ago

diffchinesebot v1.0.4

Weekly downloads
-
License
ISC
Repository
-
Last release
5 years ago

diffChineseBot

介绍

该模块对两个字符串进行比较并输出差异。

它基于John Resig的Javascript Diff算法,并大量借鉴了该算法。

主要区别在于,该模块支持在包含中文或其他使用多字节字符和不使用空格分隔单词的语言的字符串中查找差异。

使用效果:

Image text

npm安装

$ npm install diffchinesebot

RequireJS

require.config({
	paths: {
		diffChineseBot: './diffChineseBot/index.js'
	}
});

require( [ 'diffChineseBot' ], function( diffChineseBot ) {
	...
});

直接引用

<script src="./diffChineseBot.js"></script>
<script>
window.diffChineseBot(beforeString, afterString, option)
</script>

使用方式

diffChineseBot包只包含一个函数diffChinese,可以这样使用:

var beforeString = 'the quick brown fox';
var afterString = 'the quick brown dog';

var diff = diffChineseBot( beforeString, afterString, option);

// => { before: 'the quick brown <del>fox</del>', after: 'the quick brown <ins>dog</ins>' }
  • diffChineseBot( beforeString, afterString, option)
  • option对象参数值:
1.0.4

5 years ago

1.0.22

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago