Fenced code blocks don't work with ~~~…~~~

AI-generated summary

The discussion revolves around support for fenced code blocks using tildes (~) in addition to backticks (`) in Discourse. johnmuhl notes that while backticks work, tildes do not, despite being supported in other Markdown implementations like PHP Markdown Extra, kramdown, and GitHub. Mittineague raises the issue of keyboard accessibility, suggesting tildes may be more available on non-US keyboards. codinghorror initially states tildes aren’t part of Markdown or CommonMark, but johnmuhl provides a link to the CommonMark spec confirming tilde support. Mittineague references SourceForge’s Markdown flavor, which also supports tildes. codinghorror later acknowledges the spec and commits to adding support once the official CommonMark release is integrated — a process estimated to take at least 8 months. Finally, codinghorror confirms that tilde-based fenced code blocks now work with CommonMark enabled on the platform. The thread highlights community-driven feature requests, spec compliance, and accessibility considerations in Markdown rendering.

Both triple ` and ~ should be supported as the start and end of fenced code blocks but only backticks seem to work here.

This is a fenced code block
This is a fenced code block
1 Like

I’m only familiar with US keyboards, they have both backtick and tilde keys.

But I understand some keyboards (European) don’t have bactick keys.

Would those keyboards have tilde keys?

That is not part of Markdown or CommonMark as far as I know.

CommonMark Spec. PHP Markdown Extra, kramdown and GitHub markdown support it.

1 Like

Maybe unique to SourceForge flavor Markdown?

If you want some text to show up exactly as you write it, without Markdown doing anything to it, just indent every line by at least 4 spaces (or 1 tab). As an alternative to indenting, you can use 4 or more tildes before and after the text.
…
You can also designate a code block by surrounding it with lines of tildes. The type of code highlighting to apply will be inferred based on the code within, or you can specify like above.

Oh my bad, if it is in the CommonMark spec we will support it for the official release of the CommonMark spec, once we have time to integrate. There is no official final release yet. Probably will take at least 8 months for all of that to happen, if not more.

1 Like

Ok, this is now working with commonmark enabled here.

3 Likes