# HTML \<details\> require an empty line before markdown blocks

**URL:** https://meta.discourse.org/t/html-details-require-an-empty-line-before-markdown-blocks/335019
**Category:** Support
**Created:** [November 7, 2024, 6:52pm UTC](https://meta.discourse.org/t/html-details-require-an-empty-line-before-markdown-blocks/335019 "2024-11-07T18:52:01Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![mbauman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mbauman/32/139835_2.png) [@mbauman](https://meta.discourse.org/u/mbauman)
#### Post date: [November 7, 2024, 6:52pm UTC](https://meta.discourse.org/t/html-details-require-an-empty-line-before-markdown-blocks/335019/1 "2024-11-07T18:52:01Z")

</div>

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:

````md
<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:
> 
> ````md
> <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?

---

<div class="post-metadata">

### Author: ![Heliosurge](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/heliosurge/32/571810_2.png) [@Heliosurge](https://meta.discourse.org/u/Heliosurge)
#### Post date: [November 8, 2024, 2:25am UTC](https://meta.discourse.org/t/html-details-require-an-empty-line-before-markdown-blocks/335019/2 "2024-11-08T02:25:40Z")

</div>

Maybe try it like this

```plaintext
[details="open"]

```

Not code

```plaintext
[/Details]

```

> **not code block**
>
> ```plaintext
> Not code
> 
> ```

And using the Square brackets.

> **Headers**
>
> # Header 1
> 
> ## Header 3

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

```

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [November 8, 2024, 2:54am UTC](https://meta.discourse.org/t/html-details-require-an-empty-line-before-markdown-blocks/335019/3 "2024-11-08T02:54:35Z")

</div>

Yeah, this is not a bug, this is the [common mark spec](https://spec.commonmark.org/)

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.

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

```

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [December 8, 2024, 2:55am UTC](https://meta.discourse.org/t/html-details-require-an-empty-line-before-markdown-blocks/335019/4 "2024-12-08T02:55:05Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
