github/cmark-gfm

HTML output when img is listed in a nested list with the unsafe option

mugijiru opened this issue · 4 comments

I am describing the following list

- <img>
  - foo

When this listing is converted to HTML, the expected output is HTML like this

<ul>
<li><img>
<ul>
<li>foo</li>
</ul>
</li>
</ul>

However, the actual conversion yields the following output.

<ul>
<li>
<img>
- foo
</li>
</ul>

Similarly, the same problem occurs in the case of br and hr, where only the start tag is written.

Since there is no test case for this case in both the listing specification and HTML specification, I believe this is undefined behavior, but would you please consider taking action to achieve the above behavior?

This is how markdown works: https://spec.commonmark.org/dingus/?text=-%20%3Cimg%3E%0A%20%20-%20foo.
you link to 6.10 (inline) but should reference 4.6 (blocks): https://github.github.com/gfm/#html-blocks. Where this img matches start condition 7. Which ends with a blank line.

Thank you for your reply.
Also, thank you for informing us that img is ends by a blank line.

So am I correct in my understanding that the Markdown text I presented specifies that img ends after "- foo", so the output I thought was incorrect is the correct output according to the spec?

If so, then the result is as specified and not a cmark-gfm issue. I am thinking of closing this issue.

Indeed. This behavior follows the spec. "- foo" is still considered html.

Thank you.
You have cleared up my questions, so I'm closing.