Recently I've seen a lot of code being formatted as quote. This is not how it should be done.
All code should be formatted with one of two styles.
If it is just 1 line, with other text around it, use the ` ` formatting, like this:
Hello. This is code
and continued sentence.If it is one line, but on its own, it should have 4 spaces before it:
Hello. This is code
To save adding the 4 spaces to each line manually, highlight your block of code and then click the { } button on the editing toolbar or press CTRL+k.
If it is multi line, use the 4 spaces before each line:
Hello. This is code
To save adding the 4 spaces to each line manually, highlight your block of code and click the { } button on the editing toolbar.
If it's multi line and in a list, indent the code 8 spaces:
- Hello
This is a list
Hello This is code.
How not to do it.
Accent (
``
) formatting on a multi-line code block:Hello. This is badly formatted code
Quote format (even if you append the 2 spaces):
Hello. This is badly formatted code
2 line breaks between each line:
Hello. This is badly formatted code
No formatting. Seriously, this is so hard to read. Compare this with this:
Hello. This is badly formatted code
HTML tags (
<code>
)Hello. This is badly formatted code
HTML tags (
<pre>
). It looks okay, but is less nice to edit.Hello. This is badly formatted code
Using speech marks
"Hello. This is badly formatted code"
Reminder:
All code should be between ` characters (grave accent, often found below the ESC key), or have 4 spaces at the start of the question.
`Only format inline code with this syntax`
Format multiline code with this syntax
{}
. If it's a multi-line excerpt this will automatically add the four spaces at the start of every line for you. MUCH more convenient than adding the spaces yourself, if your code excerpt is more than a couple of lines.