Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(italicsAndBold): Make italicsAndBold lazy #608

Merged
merged 1 commit into from Oct 24, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
126 changes: 63 additions & 63 deletions dist/showdown.js

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions 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/makehtml/italicsAndBold.js
Expand Up @@ -13,10 +13,10 @@ showdown.subParser('makehtml.italicsAndBold', function (text, options, globals)

// Parse underscores
if (options.literalMidWordUnderscores) {
text = text.replace(/\b___(\S[\s\S]*)___\b/g, function (wm, txt) {
text = text.replace(/\b___(\S[\s\S]*?)___\b/g, function (wm, txt) {
return parseInside (txt, '<strong><em>', '</em></strong>');
});
text = text.replace(/\b__(\S[\s\S]*)__\b/g, function (wm, txt) {
text = text.replace(/\b__(\S[\s\S]*?)__\b/g, function (wm, txt) {
return parseInside (txt, '<strong>', '</strong>');
});
text = text.replace(/\b_(\S[\s\S]*?)_\b/g, function (wm, txt) {
Expand Down
Expand Up @@ -7,3 +7,6 @@
<p>strippers, <em>hitler</em>, and stalin</p>
<p>strippers, <strong>hitler</strong>, and stalin</p>
<p>strippers, <strong><em>hitler</em></strong>, and stalin</p>
<p><strong><em>multiple</em></strong> italics and bolds in a <strong><em>paragraph</em></strong></p>
<p><strong>multiple</strong> bolds in a <strong>paragraph</strong></p>
<p><em>multiple</em> italics in a <em>paragraph</em></p>
Expand Up @@ -15,3 +15,9 @@ strippers, _hitler_, and stalin
strippers, __hitler__, and stalin

strippers, ___hitler___, and stalin

___multiple___ italics and bolds in a ___paragraph___

__multiple__ bolds in a __paragraph__

_multiple_ italics in a _paragraph_
6 changes: 6 additions & 0 deletions test/functional/makehtml/cases/standard/emphasis.html
Expand Up @@ -37,3 +37,9 @@
<p>this is <strong><a href="//google.com">imbued link with strong</a></strong></p>
<p>this is <strong><a href="//google.com">imbued link with strong</a></strong></p>
<p>this link has underscore <a href="http://www.google.com/some_link">some_link</a></p>
<p><strong><em>multiple</em></strong> italics and bolds with underscores in a <strong><em>paragraph</em></strong></p>
<p><strong><em>multiple</em></strong> italics and bolds with asterisks in a <strong><em>paragraph</em></strong></p>
<p><strong>multiple</strong> bolds with underscores in a <strong>paragraph</strong></p>
<p><strong>multiple</strong> bolds with asterisks in a <strong>paragraph</strong></p>
<p><em>multiple</em> italics with underscores in a <em>paragraph</em></p>
<p><em>multiple</em> italics with asterisks in a <em>paragraph</em></p>
12 changes: 12 additions & 0 deletions test/functional/makehtml/cases/standard/emphasis.md
Expand Up @@ -74,3 +74,15 @@ this is **<a href="//google.com">imbued link with strong</a>**
this is __<a href="//google.com">imbued link with strong</a>__

this link has underscore [some_link](http://www.google.com/some_link)

___multiple___ italics and bolds with underscores in a ___paragraph___

***multiple*** italics and bolds with asterisks in a ***paragraph***

__multiple__ bolds with underscores in a __paragraph__

**multiple** bolds with asterisks in a **paragraph**

_multiple_ italics with underscores in a _paragraph_

_multiple_ italics with asterisks in a _paragraph_