diff --git a/dist/showdown.js b/dist/showdown.js
index fbef218..b898c33 100644
Binary files a/dist/showdown.js and b/dist/showdown.js differ
diff --git a/dist/showdown.js.map b/dist/showdown.js.map
index 2aeb1cb..1950d65 100644
Binary files a/dist/showdown.js.map and b/dist/showdown.js.map differ
diff --git a/dist/showdown.min.js b/dist/showdown.min.js
index 4103dcf..54a0adf 100644
Binary files a/dist/showdown.min.js and b/dist/showdown.min.js differ
diff --git a/dist/showdown.min.js.map b/dist/showdown.min.js.map
index 3d839de..b2bb56b 100644
Binary files a/dist/showdown.min.js.map and b/dist/showdown.min.js.map differ
diff --git a/src/subParsers/italicsAndBold.js b/src/subParsers/italicsAndBold.js
index eb87847..e4f61b7 100644
--- a/src/subParsers/italicsAndBold.js
+++ b/src/subParsers/italicsAndBold.js
@@ -6,34 +6,31 @@ showdown.subParser('italicsAndBold', function (text, options, globals) {
// it's faster to have 2 separate regexes for each case than have just one
// because of backtracing, in some cases, it could lead to an exponential effect
// called "catastrophic backtrace". Ominous!
+
+ // Parse underscores
if (options.literalMidWordUnderscores) {
- //underscores
- // Since we are consuming a \s character, we need to add it
text = text.replace(/\b__(\S[\s\S]*?)__\b/gm, '$1');
text = text.replace(/\b_(\S[\s\S]*?)_\b/gm, '$1');
- //asterisks
- text = text.replace(/\*\*(?=\S)([\s\S]*?\S[*]*)\*\*/g, '$1');
- text = text.replace(/\*(?=\S)([\s\S]*?\S)\*/g, '$1');
-
} else {
- // must go first:
text = text.replace(/__(\S[\s\S]*?)__/g, function (wm, m) {
return (/\S$/.test(m)) ? '' + m + '' : wm;
});
- text = text.replace(/\*\*(\S[\s\S]*?)\*\*/g, function (wm, m) {
- return (/\S$/.test(m)) ? '' + m + '' : wm;
- });
- // now
text = text.replace(/_(\S[\s\S]*?)_/g, function (wm, m) {
// !/^_[^_]/.test(m) - test if it doesn't start with __ (since it seems redundant, we removed it)
return (/\S$/.test(m)) ? '' + m + '' : wm;
});
- text = text.replace(/\*(\S[\s\S]*?)\*/g, function (wm, m) {
- // !/^\*[^*]/.test(m) - test if it doesn't start with ** (since it seems redundant, we removed it)
- return (/\S$/.test(m)) ? '' + m + '' : wm;
- });
}
+ // Now parse asterisks
+ text = text.replace(/\*\*(\S[\s\S]*?)\*\*/g, function (wm, m) {
+ return (/\S$/.test(m)) ? '' + m + '' : wm;
+ });
+
+ text = text.replace(/\*(\S[\s\S]*?)\*/g, function (wm, m) {
+ // !/^\*[^*]/.test(m) - test if it doesn't start with ** (since it seems redundant, we removed it)
+ return (/\S$/.test(m)) ? '' + m + '' : wm;
+ });
+
text = globals.converter._dispatch('italicsAndBold.after', text, options, globals);
return text;
});
diff --git a/test/features/#198.literalMidWordUnderscores-changes-behavior-of-asterisk.html b/test/features/#198.literalMidWordUnderscores-changes-behavior-of-asterisk.html
index d931aab..442d9fc 100644
--- a/test/features/#198.literalMidWordUnderscores-changes-behavior-of-asterisk.html
+++ b/test/features/#198.literalMidWordUnderscores-changes-behavior-of-asterisk.html
@@ -1,3 +1,4 @@
-​pointer *ptr *thing
-something _else _bla
-something __else __bla
+foo *bar *baz
+foo **bar **baz
+foo _bar _baz
+foo __bar __baz
diff --git a/test/features/#198.literalMidWordUnderscores-changes-behavior-of-asterisk.md b/test/features/#198.literalMidWordUnderscores-changes-behavior-of-asterisk.md
index 9bc76b5..1c23c02 100644
--- a/test/features/#198.literalMidWordUnderscores-changes-behavior-of-asterisk.md
+++ b/test/features/#198.literalMidWordUnderscores-changes-behavior-of-asterisk.md
@@ -1,5 +1,7 @@
-​pointer *ptr *thing
+foo *bar *baz
-something _else _bla
+foo **bar **baz
-something __else __bla
+foo _bar _baz
+
+foo __bar __baz