vsch / flexmark-java

CommonMark/Markdown Java parser with source level AST. CommonMark 0.28, emulation of: pegdown, kramdown, markdown.pl, MultiMarkdown. With HTML to MD, MD to PDF, MD to DOCX conversion modules.
BSD 2-Clause "Simplified" License
2.29k stars 271 forks source link

Image not getting rendered in HTML #486

Open lamyergeier opened 2 years ago

lamyergeier commented 2 years ago

Background

I was redirected to post my issues here: Image not getting rendered in HTML · Issue #1547 · gsantner/markor

Description

# Head 1

![Title](Image/Image.png)
# Head 1

![Title](Image/Image.png){#fig: width="1500px"}
# Head 1

![Title][]

  [Title]: Image/Image.png {#fig: width="1500px"}

Request

flexmark-java does not support {#fig: width="1500px"} for images. Could you please ignore it such that image is atleast rendered in Case 3?

vsch commented 2 years ago

If you add the Attributes extension, then {} syntax will be used for setting attributes. However, there are still limitations on the syntax. Specifically, the location of the attributes and whether there is a space between the opening { or not will determine with which element they are associated. See docs for that Attributes-Extension

For image and link refs the attributes have to go to the next line otherwise the link ref definition will not be recognized by the standard parser.

# Head 1

![Title][]

[Title]: Image/Image.png
{#fig: width="1500px"}

renders as you would expect:

<h1>Head 1</h1>
<p><img src="Image/Image.png" alt="Title" id="fig:" width="1500px" /></p>
lamyergeier commented 2 years ago

But pandoc, one of the most popular parser does

# Head 1

![Title][]

  [Title]: Image/Image.png {#fig: width="1500px"}

That is, it adds space between png and {, it does not add a newline between them. Is it possible to observe this behavior? I am requesting this as I use Pandoc on my laptop but am app uses your library on android.