fix(subParsers/italicsAndBold): fix underscores not being correctly parsed when used in conjunction with literalMidWordsUnderscores option

This commit is contained in:
Estevão Soares dos Santos 2015-07-14 20:51:22 +01:00
parent 542194e916
commit c9e85f1294

View File

@ -4,8 +4,8 @@ showdown.subParser('italicsAndBold', function (text, options) {
if (options.literalMidWordUnderscores) { if (options.literalMidWordUnderscores) {
//underscores //underscores
// Since we are consuming a \s character, we need to add it // Since we are consuming a \s character, we need to add it
text = text.replace(/(^|\s)__(?=\S)([^]+?)__(?=\s|$)/gm, '$1<strong>$2</strong>'); text = text.replace(/(^|\s|>|\b)__(?=\S)([^]+?)__(?=\b|<|\s|$)/gm, '$1<strong>$2</strong>');
text = text.replace(/(^|\s)_(?=\S)([^]+?)_(?=\s|$)/gm, '$1<em>$2</em>'); text = text.replace(/(^|\s|>|\b)_(?=\S)([^]+?)_(?=\b|<|\s|$)/gm, '$1<em>$2</em>');
//asterisks //asterisks
text = text.replace(/\*\*(?=\S)([^]+?)\*\*/g, '<strong>$1</strong>'); text = text.replace(/\*\*(?=\S)([^]+?)\*\*/g, '<strong>$1</strong>');
text = text.replace(/\*(?=\S)([^]+?)\*/g, '<em>$1</em>'); text = text.replace(/\*(?=\S)([^]+?)\*/g, '<em>$1</em>');