Skip to content

Commit

Permalink
fix(literalMidWordUnderscores): fix different behavior with asterisks
Browse files Browse the repository at this point in the history
Closes #198
  • Loading branch information
tivie committed Oct 19, 2015
1 parent 5b1f716 commit e86aea8
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 7 deletions.
4 changes: 2 additions & 2 deletions dist/showdown.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/showdown.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/showdown.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/showdown.min.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/subParsers/italicsAndBold.js
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<p>​pointer *ptr *thing</p>

<p>something _else _bla</p>

<p>something __else __bla</p>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
​pointer *ptr *thing

something _else _bla

something __else __bla
2 changes: 2 additions & 0 deletions test/node/testsuite.features.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down

0 comments on commit e86aea8

Please sign in to comment.