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 <em> issue with mixed content #1410 #1451

Merged
merged 11 commits into from
May 22, 2019
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
55 changes: 55 additions & 0 deletions test/new/em_list_links.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<ul>
x13machine marked this conversation as resolved.
Show resolved Hide resolved
<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/new/em_list_links.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
- italic
x13machine marked this conversation as resolved.
Show resolved Hide resolved
- [*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
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