flexmark-java icon indicating copy to clipboard operation
flexmark-java copied to clipboard

Link text for inline content fails to inline MultiMarkdown-style image references

Open jingibus opened this issue 5 years ago • 2 comments

Followup for #407:

With newly landed fixes, the following example works correctly in ParserEmulationProfile.MULTI_MARKDOWN:

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

[moon]: moon.jpg

yields:

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

However, MultiMarkdown format image references with width and height included do not.

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

[moon]: moon.jpg width: 80px height: 90px

yields:

<p><a href=\"/uri\">![][moon]</a></p>
<p>[moon]: moon.jpg width: 80px height: 90px</p>

MultiMarkdown-style image references that include width and height metadata fail to parse the inner content as an ImageRef.

More info:

This repro is not quite as crystal clear as the previous one, because out of the box ParserEmulationProfile.MULTI_MARKDOWN does not render the correct HTML for the following non-inline content case:

![][moon]

[moon]: moon.jpg width: 80px height: 90px

yields:

<p>![][moon]</p>
<p>[moon]: moon.jpg width: 80px height: 90px</p>

It does, however, parse this as an ImageRef, which has been good enough to get me to the goal line in my project.

jingibus avatar Apr 29 '20 23:04 jingibus

@jingibus, parser family currently affects mostly list item nuances particular to a family, not all the possible extensions present in the markdown parser.

MultiMarkdown has a lot of extensions which are not implemented or would require writing new extensions.

As a workaround you can use the attributes extension then you can add any attributes to almost any node. For references the attributes need to be specified after the definition to keep them away from the reference definition line.

![][moon]

[moon]: moon.jpg
{width=80px height=90px}

Renders as:

<p><img src="moon.jpg" alt="" width="80px" height="90px" /></p>

vsch avatar Apr 30 '20 04:04 vsch

Thank you for the information. I have an opportunity to "clean up" Markdown source when it's imported into the system, so if the attributes will emit cleanly that workaround should serve.

I may have time to do the extensions work as well if it's not too much hassle.

jingibus avatar Apr 30 '20 05:04 jingibus