How to make collapsible code?

Things I have tried

What I’m trying to do

I’m trying to have collapsible code blocks. But:

<details>
<summary>Code</summary>
// code block surrounded by triple back-ticks
</details>

does not work

From looking at this thread: Folding in preview - #127 by argentum

it seems like code blocks don’t work inside collapsible sections. Is there a good workaround?

Hi.

You do not consider use the option “Fold heading” or “Fold indent” instead of html code?

Obsidian > Settings > Editor