commonmark / commonmark-spec

CommonMark spec, with reference implementations in C and JavaScript
http://commonmark.org
Other
4.89k stars 317 forks source link

custom tag and html built-in tag are rendered inconsistently #758

Closed mantou132 closed 11 months ago

mantou132 commented 11 months ago

example:

<gbp-example
title="dy-avatar-group">

</gbp-example>

<details
title="dy-avatar-group">

</details>

current render result:

<p><gbp-example
title="dy-avatar-group"></p>
</gbp-example>
<details
title="dy-avatar-group">
</details>

Custom elements must have a closing tag, so rendering should be equivalent to <details>.

jgm commented 11 months ago

gbp-example is not recognized as a block-level tag, so this is parsed as raw inline HTML. As inline content, it gets put in a paragraph. Of course that's not what you intended, but it's in accord with the spec.

Since this is a custom tag, there's simply no way to know whether it's intended as inline or block level content.

Your best bet is to change the input a bit so that you have a type 7 raw HTML block. For this, the whole tag has to be on a line, followed by end of line.

<gbp-example title="dy-avatar-group">

</gbp-example>

You say:

Custom elements must have a closing tag.

Perhaps your thought is that we could defer classification of the element until we've finished the paragraph -- if we haven't hit a matching closing tag, we can take it as block-level.

I think that's too fancy, and it goes against our aim of being able to discern block-level content on a line-by-line basis.

mantou132 commented 11 months ago

Thank you for your explanation