refactor: add colon to escaped chars in images and anchors

This commit is contained in:
Estevao Soares dos Santos 2017-10-24 09:25:44 +01:00
parent 87b1422064
commit e862e242f7
7 changed files with 6 additions and 6 deletions

BIN
dist/showdown.js vendored

Binary file not shown.

BIN
dist/showdown.js.map vendored

Binary file not shown.

BIN
dist/showdown.min.js vendored

Binary file not shown.

Binary file not shown.

View File

@ -376,5 +376,5 @@ if (typeof(console) === 'undefined') {
* We declare some common regexes to improve performance
*/
showdown.helper.regexes = {
asteriskAndDash: /([*_])/g
asteriskDashAndColon: /([*_:])/g
};

View File

@ -33,14 +33,14 @@ showdown.subParser('anchors', function (text, options, globals) {
}
//url = showdown.helper.escapeCharacters(url, '*_', false); // replaced line to improve performance
url = url.replace(showdown.helper.regexes.asteriskAndDash, showdown.helper.escapeCharactersCallback);
url = url.replace(showdown.helper.regexes.asteriskDashAndColon, showdown.helper.escapeCharactersCallback);
var result = '<a href="' + url + '"';
if (title !== '' && title !== null) {
title = title.replace(/"/g, '&quot;');
//title = showdown.helper.escapeCharacters(title, '*_', false); // replaced line to improve performance
title = title.replace(showdown.helper.regexes.asteriskAndDash, showdown.helper.escapeCharactersCallback);
title = title.replace(showdown.helper.regexes.asteriskDashAndColon, showdown.helper.escapeCharactersCallback);
result += ' title="' + title + '"';
}

View File

@ -56,16 +56,16 @@ showdown.subParser('images', function (text, options, globals) {
altText = altText
.replace(/"/g, '&quot;')
//altText = showdown.helper.escapeCharacters(altText, '*_', false);
.replace(showdown.helper.regexes.asteriskAndDash, showdown.helper.escapeCharactersCallback);
.replace(showdown.helper.regexes.asteriskDashAndColon, showdown.helper.escapeCharactersCallback);
//url = showdown.helper.escapeCharacters(url, '*_', false);
url = url.replace(showdown.helper.regexes.asteriskAndDash, showdown.helper.escapeCharactersCallback);
url = url.replace(showdown.helper.regexes.asteriskDashAndColon, showdown.helper.escapeCharactersCallback);
var result = '<img src="' + url + '" alt="' + altText + '"';
if (title) {
title = title
.replace(/"/g, '&quot;')
//title = showdown.helper.escapeCharacters(title, '*_', false);
.replace(showdown.helper.regexes.asteriskAndDash, showdown.helper.escapeCharactersCallback);
.replace(showdown.helper.regexes.asteriskDashAndColon, showdown.helper.escapeCharactersCallback);
result += ' title="' + title + '"';
}