* feat(#132): added option to ignore accented characters * fixed lf Co-authored-by: Jamie Peabody <jpeabody@axway.com>
This commit is contained in:
@@ -1,5 +1,8 @@
|
|||||||
# Changes
|
# Changes
|
||||||
|
|
||||||
|
## 4.2.0:
|
||||||
|
* minor: added new option `ignoreaccents` to ignore accented characters.
|
||||||
|
|
||||||
## 4.1.2:
|
## 4.1.2:
|
||||||
* patch: fixes issue #134 where the readme had broken links.
|
* patch: fixes issue #134 where the readme had broken links.
|
||||||
|
|
||||||
|
|||||||
@@ -99,7 +99,8 @@ $(document).ready(function () {
|
|||||||
|<a name="fadein"></a>fadein|string|`fast`|A jQuery [fadein](http://api.jquery.com/fadein) value to enable the editor to fade in. Set to empty string to disable.|
|
|<a name="fadein"></a>fadein|string|`fast`|A jQuery [fadein](http://api.jquery.com/fadein) value to enable the editor to fade in. Set to empty string to disable.|
|
||||||
|<a name="fgcolor"></a>fgcolor|string\|number\|object|`{a:'#4ba3fa', c:'#a3a3a3', d:'#ff7f7f', ca:'#4b73ff', cc:'#434343', cd:'#ff4f4f'}`|The foreground color that mergely marks changes with on the canvas. The value **a** is additions, **c** changes, **d** deletions, and the prefix *c* indicates current/active change (e.g. **cd** current delection).|
|
|<a name="fgcolor"></a>fgcolor|string\|number\|object|`{a:'#4ba3fa', c:'#a3a3a3', d:'#ff7f7f', ca:'#4b73ff', cc:'#434343', cd:'#ff4f4f'}`|The foreground color that mergely marks changes with on the canvas. The value **a** is additions, **c** changes, **d** deletions, and the prefix *c* indicates current/active change (e.g. **cd** current delection).|
|
||||||
|<a name="ignorews"></a>ignorews|boolean|`false`|Ignores white-space.|
|
|<a name="ignorews"></a>ignorews|boolean|`false`|Ignores white-space.|
|
||||||
|<a name="ignorecase"></a>ignorecase|boolean|`false`|Ignores case when differientiating.
|
|<a name="ignorecase"></a>ignorecase|boolean|`false`|Ignores case when differientiating.|
|
||||||
|
|<a name="ignoreaccents"></a>ignorews|boolean|`false`|Ignores accented characters.|
|
||||||
|<a name="lcs"></a>lcs|boolean|`true`|Enables/disables LCS computation for paragraphs (word-by-word changes). Disabling can give a performance gain for large documents.|
|
|<a name="lcs"></a>lcs|boolean|`true`|Enables/disables LCS computation for paragraphs (word-by-word changes). Disabling can give a performance gain for large documents.|
|
||||||
|<a name="license"></a>license|string|`lgpl`|The choice of license to use with Mergely. Valid values are: `lgpl`, `gpl`, `mpl` or `lgpl-separate-notice`, `gpl-separate-notice`, `mpl-separate-notice` (the license requirements are met in a separate notice file).|
|
|<a name="license"></a>license|string|`lgpl`|The choice of license to use with Mergely. Valid values are: `lgpl`, `gpl`, `mpl` or `lgpl-separate-notice`, `gpl-separate-notice`, `mpl-separate-notice` (the license requirements are met in a separate notice file).|
|
||||||
|<a name="line_numbers"></a>line_numbers|boolean|`true`|Enables/disables line numbers. Enabling line numbers will toggle the visibility of the line number margins.|
|
|<a name="line_numbers"></a>line_numbers|boolean|`true`|Enables/disables line numbers. Enabling line numbers will toggle the visibility of the line number margins.|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "mergely",
|
"name": "mergely",
|
||||||
"version": "4.1.2",
|
"version": "4.2.0",
|
||||||
"description": "A javascript UI for diff/merge",
|
"description": "A javascript UI for diff/merge",
|
||||||
"directories": {
|
"directories": {
|
||||||
"doc": "doc",
|
"doc": "doc",
|
||||||
|
|||||||
@@ -41,15 +41,19 @@ Mgly.sizeOf = function(obj) {
|
|||||||
return size;
|
return size;
|
||||||
};
|
};
|
||||||
|
|
||||||
Mgly.LCS = function(x, y) {
|
Mgly.LCS = function(x, y, options) {
|
||||||
this.x = (x && x.replace(/[ ]{1}/g, '\n')) || '';
|
this.x = (x && x.replace(/[ ]{1}/g, '\n')) || '';
|
||||||
this.y = (y && y.replace(/[ ]{1}/g, '\n')) || '';
|
this.y = (y && y.replace(/[ ]{1}/g, '\n')) || '';
|
||||||
|
this.options = options;
|
||||||
};
|
};
|
||||||
|
|
||||||
jQuery.extend(Mgly.LCS.prototype, {
|
jQuery.extend(Mgly.LCS.prototype, {
|
||||||
clear: function() { this.ready = 0; },
|
clear: function() { this.ready = 0; },
|
||||||
diff: function(added, removed) {
|
diff: function(added, removed) {
|
||||||
var d = new Mgly.diff(this.x, this.y, {ignorews: false});
|
var d = new Mgly.diff(this.x, this.y, {
|
||||||
|
ignorews: false,
|
||||||
|
ignoreaccents: !!this.options.ignoreaccents
|
||||||
|
});
|
||||||
var changes = Mgly.DiffParser(d.normal_form());
|
var changes = Mgly.DiffParser(d.normal_form());
|
||||||
var li = 0, lj = 0;
|
var li = 0, lj = 0;
|
||||||
for (var i = 0; i < changes.length; ++i) {
|
for (var i = 0; i < changes.length; ++i) {
|
||||||
@@ -86,7 +90,6 @@ Mgly.CodeifyText = function(settings) {
|
|||||||
this._max_code = 0;
|
this._max_code = 0;
|
||||||
this._diff_codes = {};
|
this._diff_codes = {};
|
||||||
this.ctxs = {};
|
this.ctxs = {};
|
||||||
this.options = {ignorews: false};
|
|
||||||
jQuery.extend(this, settings);
|
jQuery.extend(this, settings);
|
||||||
this.lhs = settings.lhs.split('\n');
|
this.lhs = settings.lhs.split('\n');
|
||||||
this.rhs = settings.rhs.split('\n');
|
this.rhs = settings.rhs.split('\n');
|
||||||
@@ -119,6 +122,9 @@ jQuery.extend(Mgly.CodeifyText.prototype, {
|
|||||||
if (this.options.ignorecase) {
|
if (this.options.ignorecase) {
|
||||||
line = line.toLowerCase();
|
line = line.toLowerCase();
|
||||||
}
|
}
|
||||||
|
if (this.options.ignoreaccents) {
|
||||||
|
line = line.normalize('NFD').replace(/[\u0300-\u036f]/g, '');
|
||||||
|
}
|
||||||
var aCode = this._diff_codes[line];
|
var aCode = this._diff_codes[line];
|
||||||
if (aCode != undefined) {
|
if (aCode != undefined) {
|
||||||
ctx.codes[i] = aCode;
|
ctx.codes[i] = aCode;
|
||||||
@@ -133,7 +139,7 @@ jQuery.extend(Mgly.CodeifyText.prototype, {
|
|||||||
});
|
});
|
||||||
|
|
||||||
Mgly.diff = function(lhs, rhs, options) {
|
Mgly.diff = function(lhs, rhs, options) {
|
||||||
var opts = jQuery.extend({ignorews: false}, options);
|
var opts = jQuery.extend({ignorews: false, ignoreaccents: false}, options);
|
||||||
this.codeify = new Mgly.CodeifyText({
|
this.codeify = new Mgly.CodeifyText({
|
||||||
lhs: lhs,
|
lhs: lhs,
|
||||||
rhs: rhs,
|
rhs: rhs,
|
||||||
@@ -385,6 +391,7 @@ jQuery.extend(Mgly.CodeMirrorDiffView.prototype, {
|
|||||||
viewport: false,
|
viewport: false,
|
||||||
ignorews: false,
|
ignorews: false,
|
||||||
ignorecase: false,
|
ignorecase: false,
|
||||||
|
ignoreaccents: false,
|
||||||
fadein: 'fast',
|
fadein: 'fast',
|
||||||
resize_timeout: 500,
|
resize_timeout: 500,
|
||||||
change_timeout: 150,
|
change_timeout: 150,
|
||||||
@@ -438,7 +445,6 @@ jQuery.extend(Mgly.CodeMirrorDiffView.prototype, {
|
|||||||
_debug: '', //scroll,draw,calc,diff,markup,change,init
|
_debug: '', //scroll,draw,calc,diff,markup,change,init
|
||||||
resized: function() { }
|
resized: function() { }
|
||||||
}, options);
|
}, options);
|
||||||
|
|
||||||
// save this element for faster queries
|
// save this element for faster queries
|
||||||
this.element = jQuery(el);
|
this.element = jQuery(el);
|
||||||
|
|
||||||
@@ -1391,7 +1397,9 @@ jQuery.extend(Mgly.CodeMirrorDiffView.prototype, {
|
|||||||
}
|
}
|
||||||
lhs_line = led.getLine( j );
|
lhs_line = led.getLine( j );
|
||||||
rhs_line = red.getLine( k );
|
rhs_line = red.getLine( k );
|
||||||
var lcs = new Mgly.LCS(lhs_line, rhs_line);
|
var lcs = new Mgly.LCS(lhs_line, rhs_line, {
|
||||||
|
ignoreaccents: !!this.settings.ignoreaccents
|
||||||
|
});
|
||||||
lcs.diff(
|
lcs.diff(
|
||||||
function added (from, to) {
|
function added (from, to) {
|
||||||
if (self._is_change_in_view('rhs', rhsvp, change)) {
|
if (self._is_change_in_view('rhs', rhsvp, change)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user