Skip to content

Commit 21194c8

Browse files
committed
fix(literalMidWordAsterisks): no longer treats colon as alphanumeric char
Closes #461
1 parent dd7efb5 commit 21194c8

14 files changed

Lines changed: 73 additions & 17 deletions

File tree

dist/showdown.js

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/showdown.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/showdown.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/showdown.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/subParsers/italicsAndBold.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,14 @@ showdown.subParser('italicsAndBold', function (text, options, globals) {
4242

4343
// Now parse asterisks
4444
if (options.literalMidWordAsterisks) {
45-
text = text.trim().replace(/(^| )\*{3}(\S[\s\S]*?)\*{3}([ ,;!?.]|$)/g, function (wm, lead, txt, trail) {
46-
return parseInside (txt, lead + '<strong><em>', '</em></strong>' + trail);
45+
text = text.replace(/([^*]|^)\B\*\*\*(\S[\s\S]+?)\*\*\*\B(?!\*)/g, function (wm, lead, txt) {
46+
return parseInside (txt, lead + '<strong><em>', '</em></strong>');
4747
});
48-
text = text.trim().replace(/(^| )\*{2}(\S[\s\S]*?)\*{2}([ ,;!?.]|$)/g, function (wm, lead, txt, trail) {
49-
return parseInside (txt, lead + '<strong>', '</strong>' + trail);
48+
text = text.replace(/([^*]|^)\B\*\*(\S[\s\S]+?)\*\*\B(?!\*)/g, function (wm, lead, txt) {
49+
return parseInside (txt, lead + '<strong>', '</strong>');
5050
});
51-
text = text.trim().replace(/(^| )\*(\S[\s\S]*?)\*([ ,;!?.]|$)/g, function (wm, lead, txt, trail) {
52-
return parseInside (txt, lead + '<em>', '</em>' + trail);
51+
text = text.replace(/([^*]|^)\B\*(\S[\s\S]+?)\*\B(?!\*)/g, function (wm, lead, txt) {
52+
return parseInside (txt, lead + '<em>', '</em>');
5353
});
5454
} else {
5555
text = text.replace(/\*\*\*(\S[\s\S]*?)\*\*\*/g, function (wm, m) {

test/features/literalMidWordAsterisks/basic.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
<p>this is a sentence*with*mid asterisks</p>
22
<p>this is a sentence**with**two mid asterisks</p>
33
<p>this is a sentence***with***three mid asterisks</p>
4+
<p>this is double*asterisk*mid word with another**asterisk**word</p>
5+
<p>this is double**asterisk**mid word with another**asterisk**word</p>
6+
<p>this is double***asterisk***mid word with another***asterisk***word</p>
7+
<p>this is double*asterisk**mid word with another***asterisk*word</p>
8+
<p>this is double**asterisk*mid word with another***asterisk**word</p>
49
<p>this is a sentence with just*one asterisk</p>
510
<p>this is a sentence with just**one asterisk</p>
611
<p>this is a sentence with just***one asterisk</p>

test/features/literalMidWordAsterisks/basic.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,16 @@ this is a sentence**with**two mid asterisks
44

55
this is a sentence***with***three mid asterisks
66

7+
this is double*asterisk*mid word with another**asterisk**word
8+
9+
this is double**asterisk**mid word with another**asterisk**word
10+
11+
this is double***asterisk***mid word with another***asterisk***word
12+
13+
this is double*asterisk**mid word with another***asterisk*word
14+
15+
this is double**asterisk*mid word with another***asterisk**word
16+
717
this is a sentence with just*one asterisk
818

919
this is a sentence with just**one asterisk
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<p><strong>Bold:</strong></p>
2+
<p><strong>Bold</strong></p>
3+
<p><strong>Bold</strong>:</p>
4+
<ul>
5+
<li><strong>Bold</strong><ul>
6+
<li>Tier 2</li></ul></li>
7+
</ul>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
**Bold:**
2+
3+
**Bold**
4+
5+
**Bold**:
6+
7+
- **Bold**
8+
- Tier 2
File renamed without changes.

0 commit comments

Comments
 (0)