SkillAgentSearch skills...

DiffChinese

Client side javascript string diff algorithm that supports Chinese

Install / Use

/learn @mailmangroup/DiffChinese
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

diffChinese

Introduction

This module comparea two strings and outputs the differences.

It is based on, and borrows heavily from, John Resig's Javascript Diff Algorithm (http://ejohn.org/projects/javascript-diff-algorithm/). Thanks, John!

The main difference is that this module supports finding differences in strings containing Chinese or other languages that use multi byte characters and/or don't separate words by spaces.

As an example here is how we at KAWO.com use this package in our app:

Usage example.

Installation

$ bower install diffChinese

Including diffChinese

RequireJS (recommended)

require.config({
	paths: {
		diffChinese: '../bower_components/diffChinese/dist/diffChinese'
	}
});

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

Basic Script Include

<script src="./bower-components/diffString/dist/diffString.min.js"></script>
<script>
...
</script>

Usage

The diffChinese package contains only one function diffChinese which can be used like this:

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

var diff = diffChinese( beforeString, afterString );

// => { before: 'the quick brown <del>fox</del>', after: 'the quick brown <ins>dog</ins>' }
View on GitHub
GitHub Stars24
CategoryCustomer
Updated2y ago
Forks4

Security Score

60/100

Audited on Apr 18, 2023

No findings