How to properly insert code in posts?


(davidmichaelkarr) #1

If I want to insert a code sample into a post, I would assume I would use the “Preformatted text” option. What’s strange about that is that this inserts two backticks along with the replaceable text. When I first saw that, I assumed that the posting software would use the wrapping backticks to detect that it should do something special with that. In practice, however, it doesn’t seem like it does anything with it. When I view the posting, it just has the code I inserted, surrounded by the backticks.


(Chris Doré) #2

If you use single backticks it will create inline formatting like this.

If you create a separate paragraph

indented with four spaces
you will get preformatted code blocks like this

Those are the only two I’ve been using.


(Stefan Oehme) #3

Use triple ticks for blocks.