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

Link text inline content fails to parse image references #407

Closed
jingibus opened this issue Apr 29, 2020 · 5 comments
Closed

Link text inline content fails to parse image references #407

jingibus opened this issue Apr 29, 2020 · 5 comments

Comments

@jingibus
Copy link

The CommonMark spec says that link text may itself contain inline content. Example 525:

[![moon](moon.jpg)](/uri)

yields:

<p><a href="/uri"><img src="moon.jpg" alt="moon" /></a></p>

In FlexMark, however, inline content that consists of an image reference fails to parse and is passed straight through as the link text. Example test case:

[![][moon]](/uri)

[moon]: moon.jpg

yields:

<p><a href=\"/uri\">![][moon]</a></p>

The expected output is:

<p><a href="/uri"><img src="moon.jpg" alt="moon" /></a></p>

Verified with ParserEmulationProfile.COMMONMARK_0_28 and ParserEmulationProfile.MULTI_MARKDOWN.

Additional context:
My application uses ParserEmulationProfile.MULTI_MARKDOWN. MultiMarkdown uses image references to encode width/height data, which I am reliant on. So this is a hard blocker for me that I will need to work around in one way or another.

@vsch
Copy link
Owner

vsch commented Apr 29, 2020

@jingibus, thank you for catching it. I can confirm it is a bug. Will release fix shortly.

@vsch vsch added the 🪲 bug label Apr 29, 2020
@vsch
Copy link
Owner

vsch commented Apr 29, 2020

@jingibus, btw, the expected output in your case would be:

<p><a href="/uri"><img src="moon.jpg" alt="" /></a></p>

the alt is empty because you are using syntax [![alt text][moon]](/uri), which overrides the default alt with one which is empty. Use [![moon]](/uri) or [![moon][]](/uri) to use the reference id as alt text.

vsch added a commit that referenced this issue Apr 29, 2020
@vsch
Copy link
Owner

vsch commented Apr 29, 2020

Fix for this is available. Repo updated, maven updated but may take a while to show up in maven central.

@vsch
Copy link
Owner

vsch commented Apr 29, 2020

@jingibus, had to make another release 0.61.24 to handle reference links in link text. This does not affect reference images but does cause issues with CommonMark reference implementation compatibility.

@jingibus
Copy link
Author

Unbelievable. Thank you so much!

I've got a followup that's specific to MultiMarkdown coming, but I've confirmed the issue reported here is fixed on my end.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants