You cannot use HTML comments anywhere here on Stack Exchange. Comments such as <!-- filler -->
are sometimes used in answers and questions to bypass character limits, but get removed in the final output. Only some HTML is allowed in posts, the rest all gets filtered out.
If you think this should be allowed, you need to fill out a detailed reason why you think you should be able to do this, file a feature request, and let the community downvote it into oblivion.
As per your example, it is finding the <!-- <br>
first because the Markdown system doesn't care about your HTML comment. They're not allowed, so it doesn't search for the closing -->
. It just sees that <!-- <br>
looks like an HTML element, it's not allowed, and thus it gets removed.
Actual HTML source:
<pre><code>The first one <!-- this is the comment --> the second one <!-- this is the second comment >-->
</code></pre>
<hr>
<h3>Result</h3>
<hr>
<p>Result: The first one the second one --></p>
Notice the lack of actual, physical HTML comments in the source of the document.
>
is ending your HTML comment even though only-->
should end your HTML comment, as explained here? In other words,<!-- this is a comment -->
and<!-- this is a comment >
are being rendered identically (hidden) even though the latter isn't a valid HTML comment?<!-- language: lang-foo -->
is such a pain to type. How about[lang:foo]
?