Clarify the following HTML comment case

In CommaonMark 0.31.2 you allowed “–” to be in a HTML comment. But the following example parses as setext heading. But why?

foo <!-- a comment
--
with two hyphens -->

What should be here?

It does seem odd, and a bit like a bug. Other markdown in there breaks it as well, e.g. a list item:

foo <!-- a comment
* lorem
with two hyphens -->

If you remove the asterisk the whole comment disappears (correctly).

But why?

Because breaking that input into multiple blocks takes precedence (see CommonMark Spec).

Once that happens, there is no block containing any raw HTML because in order to be recognized as comment, it needs both the opener and closer in the block.

You lie.

always take precedence over indicators of inline structure

And, for example:

<![CDATA[
text
-
]]>

Parses as:

<![CDATA[
text
-
]]>

You lie.

I shall assume this sounded less aggressive in your native language than it does in English.

In Commonmark, an HTML comment could be a leaf block, but for that the line would have to start with <!--, not just contain it – this is the essential difference in your <![CDATA[ example.
It could also be inline raw HTML, but then any block structures take precedence as @mity already pointed out correctly.

Therefore, <!-- this is an inline comment --> and
<!-- this is 
a block 
comment -->
but <!-- this

is neither 
-->

Ok, sorry for the lie. I see you. I miss-understood this case of standard, so I lied.

But yes, you are right, it wasn’t a lie in any case.

Guys, it’s not clear in CommonMark that HTML can be treated as inline content. I believe that it should be pointed to directly…

Guys, it’s not clear in CommonMark that HTML can be treated as inline content. I believe that it should be pointed to directly…

Chapter 6 contains whole sub-chapter 6.6 dedicated to inline HTML.

I apologize for any inconvenience in this question. You were right, I misunderstood everything in this case. Thank you for your calm.