mirror of
https://github.com/showdownjs/showdown.git
synced 2024-03-22 13:30:55 +08:00
fix(subParsers/italicsAndBold.js): fix broken em/strong tags when used with literalMidWordUnderscores
When literalMidWordUnderscoresis set to true, em and strong tags that start or end a paragraph don't get parsed as such. This fixes this issue. Closes #174
This commit is contained in:
parent
47f3bbd2c6
commit
7ee2017c56
BIN
dist/showdown.js
vendored
BIN
dist/showdown.js
vendored
Binary file not shown.
BIN
dist/showdown.js.map
vendored
BIN
dist/showdown.js.map
vendored
Binary file not shown.
BIN
dist/showdown.min.js
vendored
BIN
dist/showdown.min.js
vendored
Binary file not shown.
BIN
dist/showdown.min.js.map
vendored
BIN
dist/showdown.min.js.map
vendored
Binary file not shown.
|
@ -4,8 +4,8 @@ showdown.subParser('italicsAndBold', function (text, options) {
|
|||
if (options.literalMidWordUnderscores) {
|
||||
//underscores
|
||||
// Since we are consuming a \s character, we need to add it
|
||||
text = text.replace(/(\s)__(?=\S)([^]+?)__(?=\s)/g, '$1<strong>$2</strong>');
|
||||
text = text.replace(/(\s)_(?=\S)([^]+?)_(?=\s)/g, '$1<em>$2</em>');
|
||||
text = text.replace(/(^|\s)__(?=\S)([^]+?)__(?=\s|$)/gm, '$1<strong>$2</strong>');
|
||||
text = text.replace(/(^|\s)_(?=\S)([^]+?)_(?=\s|$)/gm, '$1<em>$2</em>');
|
||||
//asterisks
|
||||
text = text.replace(/\*\*(?=\S)([^]+?)\*\*/g, '<strong>$1</strong>');
|
||||
text = text.replace(/\*(?=\S)([^]+?)\*/g, '<em>$1</em>');
|
||||
|
|
|
@ -9,3 +9,10 @@
|
|||
<p>this has just__one double underscore</p>
|
||||
|
||||
<p>this <strong>should be parsed</strong> as bold</p>
|
||||
|
||||
<p>emphasis at <em>end of sentence</em></p>
|
||||
|
||||
<p><em>emphasis at</em> line start</p>
|
||||
|
||||
<p>multi <em>line emphasis
|
||||
yeah it is</em> yeah</p>
|
||||
|
|
|
@ -9,3 +9,10 @@ this is double__underscore__mid word
|
|||
this has just__one double underscore
|
||||
|
||||
this __should be parsed__ as bold
|
||||
|
||||
emphasis at _end of sentence_
|
||||
|
||||
_emphasis at_ line start
|
||||
|
||||
multi _line emphasis
|
||||
yeah it is_ yeah
|
||||
|
|
Loading…
Reference in New Issue
Block a user