jsdifflib
jsdifflib copied to clipboard
Ignore whitespaces
Please make an option to ignore whitespaces and tabs
@suther You may remove whitespaces before calling difflib.SequenceMatcher - with this function you can remove trailing whitespaces:
removeTrailingWhitespace = function(txt) {
var pattern = /\s*$/g;
var newtxt = [];
for(var i=0;i<txt.length;i++) {
newtxt.push(txt[i].replace(pattern, ''));
}
return newtxt;
}
var base = removeTrailingWhitespace( difflib.stringAsLines(basetxt) );
var new = removeTrailingWhitespace( difflib.stringAsLines(newtxt) );
var sm = new difflib.SequenceMatcher(base, new);
(...)