HTML <details> require an empty line before markdown blocks

AI-generated summary

The discussion revolves around the requirement of an empty line before Markdown blocks inside HTML <details> tags, which prevents proper rendering. mbauman highlights issues with code blocks, headers, and block quotes not displaying correctly within <details>. Heliosurge suggests using BBCode syntax with square brackets as an alternative, while sam explains this behavior is expected due to the CommonMark spec and recommends using BBCode or properly formatted HTML with <pre> and <code> tags for reliable results.

It’d be nice if Markdown’s “block” syntaxes could work inside <details> without requiring an empty line. I frequently run into this with code segments. For example, this fairly straight-forward syntax is doesn’t render as I’d expect:

<details>
```
# not code
```
</details>

``` # not code ```

While I most commonly hit this with code blocks (given that we run a programming language forum), it’s true of other markdown “block” syntaxes:

For example, headers # are not headers

This is the code for this block:

<details><summary>For example, headers</summary>
# are not headers

This is the code for this block:
```md
(stack overflow)
```
</details>
And same for block quotes > this should be a quote, I'd expect

Is this expected?

Maybe try it like this

[details="open"]

Not code

[/Details]
not code block
Not code

And using the Square brackets.

Headers

Header 1

Header 3

[details="not code block"]
# Header 1
## Header 3
[/Details]

Yeah, this is not a bug, this is the common mark spec

When mixing and matching HTML and markdown you need an extra newline.

This monster works with no newlines, but I would recommend just using the BBCode that @Heliosurge suggested.

<details>
<pre>
<code># yes code
</pre>
</code>
</details>