mirror of
https://github.com/showdownjs/showdown.git
synced 2024-03-22 13:30:55 +08:00
fix(italicsAndBold): Make italicsAndBold lazy (#608)
fix italicsAndBold if literalMidwordUnderscores option is enabled it should end at the nearest closing underscores, not the furthest Closes #544
This commit is contained in:
parent
e0fc6f8d6b
commit
4378abb4fa
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.
|
@ -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) {
|
||||
|
|
|
@ -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>
|
|
@ -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_
|
|
@ -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>
|
||||
|
|
|
@ -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_
|
||||
|
|
Loading…
Reference in New Issue
Block a user