Add a pinned topic for how to add code?


Is it worth adding a pinned topic with a suggestion of how to add code snippets or how to post a flow? Currently the </> button adds preformated text, which is handled differently to four spaces indent.


Possibly. It may not be clear that posts are Markdown formatted so the easiest way to add a block of code is with 3 backticks on their own line to start and again to stop the block

` ` `
like this (but without the spaces between of course)
and this
` ` `

You can also indent by 4 spaces which is what the </> button does.

In addition, single backticks wrapped around some text give inline code formatting. ``<like><this>`` (but single not double).

The GitGub flavoured markdown help pages are good to understand the possibilities. Discourse is not quite the same but similar.


Unfortunately thats not what the </> does for me!
For me, the </> adds a single backtick


Ah, depends what you’ve selected first. If you select a whole line or more (at least one newline), you get the 4 space indent, otherwise you get single backticks. What you’d expect and a nice touch. You get the same in other markdown editors too.


Hopefully this is still accurate

1 Like

Cool, I learned some things there. Only recently started using discourse because of switching my blog to Hugo.