Now uses greedy replacement. Fixes #1
This commit is contained in:
parent
41ea00390e
commit
bd6fd498aa
|
@ -1,8 +1,13 @@
|
||||||
excelParser = {
|
excelParser = {
|
||||||
latexEscape: function(text) {
|
latexEscape: function(text) {
|
||||||
|
escapeRegExpr = function(str) {
|
||||||
|
return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
|
||||||
|
};
|
||||||
|
|
||||||
var specials = ['\\', '&', '%', '$', '#', '_', '{', '}', '~', '^'];
|
var specials = ['\\', '&', '%', '$', '#', '_', '{', '}', '~', '^'];
|
||||||
$.each(specials, function(i,special) {
|
$.each(specials, function() {
|
||||||
text = text.replace(special, '\\' + special);
|
var regexp = new RegExp(escapeRegExpr(this), 'g');
|
||||||
|
text = text.replace(regexp, '\\' + this, 'g');
|
||||||
});
|
});
|
||||||
|
|
||||||
return text;
|
return text;
|
||||||
|
|
Loading…
Reference in New Issue