This commit is contained in:
joyqi
2020-11-30 12:07:16 +08:00
parent 1cc3066569
commit f9dfb1bb85
3 changed files with 7 additions and 37 deletions
+4 -16
View File
@@ -291,7 +291,7 @@
};
Parser.prototype.parseInline = function(text, whiteList, clearHolders, enableAutoLink) {
var parseBackSlash, regex;
var regex;
if (whiteList == null) {
whiteList = '';
}
@@ -301,20 +301,7 @@
if (enableAutoLink == null) {
enableAutoLink = true;
}
parseBackSlash = (function(_this) {
return function(text) {
return text.replace(/\\{1,}/g, function(str) {
return str.length % 2 > 0 && '' + str + '\\' || str;
});
};
})(this);
text = this.call('beforeParseInline', text);
text = String.raw`` + text + '';
text = text.split(/(`.+?`)/g).reduce(function(str, cur) {
str = str || '';
cur = cur || '';
return ((str.match(/`.+?`/g)) && str || parseBackSlash(str)) + ((cur.match(/`.+?`/g)) && cur || parseBackSlash(cur));
});
text = text.replace(/(^|[^\\])(`+)(.+?)\2/mg, (function(_this) {
return function() {
var matches;
@@ -331,11 +318,12 @@
})(this));
text = text.replace(/\\(.)/g, (function(_this) {
return function() {
var escaped, matches;
var escaped, matches, prefix;
matches = 1 <= arguments.length ? slice.call(arguments, 0) : [];
prefix = matches[1].match(/^[-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]$/) ? '' : '\\';
escaped = htmlspecialchars(matches[1]);
escaped = escaped.replace(/\$/g, '&dollar;');
return _this.makeHolder(escaped);
return _this.makeHolder(prefix + escaped);
};
})(this));
text = text.replace(/<(https?:\/\/.+)>/ig, (function(_this) {