Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/Tokenizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,15 @@ function outputLink(cap: string[], link: Pick<Tokens.Link, 'href' | 'title'>, ra
const text = cap[1].replace(rules.other.outputLinkReplace, '$1');
const isImage = cap[0].charAt(0) === '!';

lexer.state.inLink = true;
const outerInLink = lexer.state.inLink;
const outerLinkEmitted = lexer.state.linkEmitted;
const outerInRawBlock = lexer.state.inRawBlock;
lexer.state.inLink = true;
lexer.state.linkEmitted = false;
const tokens = lexer.inlineTokens(text);
const textHasLink = lexer.state.linkEmitted;
lexer.state.linkEmitted = outerLinkEmitted;
lexer.state.inLink = false;
lexer.state.inLink = outerInLink;

if (!isImage) {
// CommonMark: "Links may not contain other links, at any level of nesting."
Expand Down
6 changes: 6 additions & 0 deletions test/specs/new/autolink_after_image_in_link.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<p><a href="https://target.example"><img src="logo.png" alt="logo"> www.example.com</a></p>
<p><a href="https://target.example"><img src="logo.png" alt="logo"> https://example.com</a></p>
<p><a href="https://target.example"><img src="logo.png" alt="logo"> user@example.com</a></p>
<p><a href="https://target.example"><img src="logo.png" alt="logo"> www.example.com</a></p>
<p><a href="https://target.example"><img src="outer.png" alt="logo"> www.example.com</a></p>
<p><a href="https://target.example"><img src="logo.png" alt="logo"></a> <a href="http://www.example.com">www.example.com</a></p>
17 changes: 17 additions & 0 deletions test/specs/new/autolink_after_image_in_link.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
gfm: true
---
[![logo](logo.png) www.example.com](https://target.example)

[![logo](logo.png) https://example.com](https://target.example)

[![logo](logo.png) user@example.com](https://target.example)

[![logo][image] www.example.com][target]

[![![logo](inner.png)](outer.png) www.example.com](https://target.example)

[![logo](logo.png)](https://target.example) www.example.com

[image]: logo.png
[target]: https://target.example
Loading