Skip to content

Commit

Permalink
Fix <em> issue with mixed content #1410 (#1451)
Browse files Browse the repository at this point in the history
Fix `<em>` issue with mixed content #1410
  • Loading branch information
styfle authored May 22, 2019
2 parents 4704e29 + 88f99db commit 92d0124
Show file tree
Hide file tree
Showing 4 changed files with 98 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/marked.js
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,7 @@ var inline = {
reflink: /^!?\[(label)\]\[(?!\s*\])((?:\\[\[\]]?|[^\[\]\\])+)\]/,
nolink: /^!?\[(?!\s*\])((?:\[[^\[\]]*\]|\\[\[\]]|[^\[\]])*)\](?:\[\])?/,
strong: /^__([^\s_])__(?!_)|^\*\*([^\s*])\*\*(?!\*)|^__([^\s][\s\S]*?[^\s])__(?!_)|^\*\*([^\s][\s\S]*?[^\s])\*\*(?!\*)/,
em: /^_([^\s_])_(?!_)|^\*([^\s*"<\[])\*(?!\*)|^_([^\s][\s\S]*?[^\s_])_(?!_|[^\spunctuation])|^_([^\s_][\s\S]*?[^\s])_(?!_|[^\spunctuation])|^\*([^\s"<\[][\s\S]*?[^\s*])\*(?!\*)|^\*([^\s*"<\[][\s\S]*?[^\s])\*(?!\*)/,
em: /^_([^\s_])_(?!_)|^\*([^\s*<\[])\*(?!\*)|^_([^\s<][\s\S]*?[^\s_])_(?!_|[^\spunctuation])|^_([^\s_<][\s\S]*?[^\s])_(?!_|[^\spunctuation])|^\*([^\s<"][\s\S]*?[^\s\*])\*(?!\*|[^\spunctuation])|^\*([^\s*"<\[][\s\S]*?[^\s])\*(?!\*)/,
code: /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,
br: /^( {2,}|\\)\n(?!\s*$)/,
del: noop,
Expand Down
6 changes: 2 additions & 4 deletions test/specs/commonmark/commonmark.0.29.json
Original file line number Diff line number Diff line change
Expand Up @@ -3414,8 +3414,7 @@
"example": 418,
"start_line": 6935,
"end_line": 6939,
"section": "Emphasis and strong emphasis",
"shouldFail": true
"section": "Emphasis and strong emphasis"
},
{
"markdown": "** is not an empty emphasis\n",
Expand Down Expand Up @@ -3909,8 +3908,7 @@
"example": 477,
"start_line": 7399,
"end_line": 7403,
"section": "Emphasis and strong emphasis",
"shouldFail": true
"section": "Emphasis and strong emphasis"
},
{
"markdown": "_a `_`_\n",
Expand Down
55 changes: 55 additions & 0 deletions test/specs/new/em_list_links.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<ul>
<li>italic<ul>
<li><a href="https://www.google.com"><em>named link</em></a></li>
<li><em><a href="https://www.google.com">named link</a></em></li>
<li><a href="https://www.google.com"><em>named link</em></a></li>
<li><em><a href="https://www.google.com">named link</a></em></li>
</ul>
</li>
<li>bold<ul>
<li><a href="https://www.google.com"><strong>named link</strong></a></li>
<li><strong><a href="https://www.google.com">named link</a></strong></li>
<li><a href="https://www.google.com"><strong>named link</strong></a></li>
<li><strong><a href="https://www.google.com">named link</a></strong></li>
</ul>
</li>
<li>bold italic<ul>
<li><a href="https://www.google.com"><strong><em>named link</em></strong></a></li>
<li><strong><em><a href="https://www.google.com">named link</a></em></strong></li>
<li><a href="https://www.google.com"><strong><em>named link</em></strong></a></li>
<li><strong><em><a href="https://www.google.com">named link</a></em></strong></li>
<li><a href="https://www.google.com"><em><strong>named link</strong></em></a></li>
<li><a href="https://www.google.com"><strong><em>named link</em></strong></a></li>
<li><strong><em><a href="https://www.google.com">named link</a></em></strong></li>
</ul>
</li>
<li>code<ul>
<li><a href="https://www.google.com"><code>named link</code></a></li>
</ul>
</li>
<li>code italic<ul>
<li><em><a href="https://www.google.com"><code>named link</code></a></em></li>
<li><a href="https://www.google.com"><em><code>named link</code></em></a></li>
<li><em><a href="https://www.google.com"><code>named link</code></a></em></li>
<li><a href="https://www.google.com"><em><code>named link</code></em></a></li>
</ul>
</li>
<li>code bold<ul>
<li><strong><a href="https://www.google.com"><code>named link</code></a></strong></li>
<li><a href="https://www.google.com"><strong><code>named link</code></strong></a></li>
<li><strong><a href="https://www.google.com"><code>named link</code></a></strong></li>
<li><a href="https://www.google.com"><strong><code>named link</code></strong></a></li>
</ul>
</li>
<li>code bold italic<ul>
<li><a href="https://www.google.com"><strong><em><code>named link</code></em></strong></a></li>
<li><strong><em><a href="https://www.google.com"><code>named link</code></a></em></strong></li>
<li><a href="https://www.google.com"><strong><em><code>named link</code></em></strong></a></li>
<li><strong><em><a href="https://www.google.com"><code>named link</code></a></em></strong></li>
<li><a href="https://www.google.com"><em><strong><code>named link</code></strong></em></a></li>
<li><a href="https://www.google.com"><strong><em><code>named link</code></em></strong></a></li>
<li><strong><em><a href="https://www.google.com"><code>named link</code></a></em></strong></li>
</ul>
</li>
</ul>

40 changes: 40 additions & 0 deletions test/specs/new/em_list_links.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
- italic
- [*named link*][some-url]
- *[named link][some-url]*
- [_named link_][some-url]
- _[named link][some-url]_
- bold
- [**named link**][some-url]
- **[named link][some-url]**
- [__named link__][some-url]
- __[named link][some-url]__
- bold italic
- [***named link***][some-url]
- ***[named link][some-url]***
- [___named link___][some-url]
- ___[named link][some-url]___
- [*__named link__*][some-url]
- [__*named link*__][some-url]
- __*[named link][some-url]*__
- code
- [`named link`][some-url]
- code italic
- *[`named link`][some-url]*
- [*`named link`*][some-url]
- _[`named link`][some-url]_
- [_`named link`_][some-url]
- code bold
- **[`named link`][some-url]**
- [**`named link`**][some-url]
- __[`named link`][some-url]__
- [__`named link`__][some-url]
- code bold italic
- [***`named link`***][some-url]
- ***[`named link`][some-url]***
- [___`named link`___][some-url]
- ___[`named link`][some-url]___
- [*__`named link`__*][some-url]
- [__*`named link`*__][some-url]
- __*[`named link`][some-url]*__

[some-url]: https://www.google.com

0 comments on commit 92d0124

Please sign in to comment.