fix(literalMidWordUnderscores): fix different behavior with asterisks

Closes #198
This commit is contained in:
Estevão Soares dos Santos 2015-10-19 03:09:50 +01:00
parent 5b1f716151
commit e86aea8183
8 changed files with 14 additions and 2 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

@ -7,8 +7,8 @@ showdown.subParser('italicsAndBold', function (text, options) {
text = text.replace(/(^|\s|>|\b)__(?=\S)([^]+?)__(?=\b|<|\s|$)/gm, '$1<strong>$2</strong>');
text = text.replace(/(^|\s|>|\b)_(?=\S)([^]+?)_(?=\b|<|\s|$)/gm, '$1<em>$2</em>');
//asterisks
text = text.replace(/\*\*(?=\S)([^]+?)\*\*/g, '<strong>$1</strong>');
text = text.replace(/\*(?=\S)([^]+?)\*/g, '<em>$1</em>');
text = text.replace(/(\*\*)(?=\S)([^\r]*?\S[*]*)\1/g, '<strong>$2</strong>');
text = text.replace(/(\*)(?=\S)([^\r]*?\S)\1/g, '<em>$2</em>');
} else {
// <strong> must go first:

View File

@ -0,0 +1,5 @@
<p>pointer *ptr *thing</p>
<p>something _else _bla</p>
<p>something __else __bla</p>

View File

@ -0,0 +1,5 @@
pointer *ptr *thing
something _else _bla
something __else __bla

View File

@ -27,6 +27,8 @@ describe('makeHtml() features testsuite', function () {
converter = new showdown.Converter({tasklists: true});
} else if (testsuite[i].name === 'autolink-and-disallow-underscores') {
converter = new showdown.Converter({literalMidWordUnderscores: true, simplifiedAutoLink: true});
} else if (testsuite[i].name === '#198.literalMidWordUnderscores-changes-behavior-of-asterisk') {
converter = new showdown.Converter({literalMidWordUnderscores: true});
} else {
converter = new showdown.Converter();
}