I was looking for a way to collapse code blocks within a Talk post and discovered this little pearl that works within Discourse posts:
<details> <summary>Hint to show in post</summary> ```json Long block of code goes here ... ``` </details>
is rendered like this:
Hint to show in post
Long block of code goes here ...
TIP: The empty line after the
<summary/> element is needed to properly render the code block. Posts are limited to ~32K, so it’s still best practice to put large chunks of code into a website like pastebin.com and link to it.