How to format code in your posts

Code Formatting

When pasting code in your posts, please use the following formatting options, in order to be sure your code is readable and well formatted for the rest of the users.

Inline code formatting

Surround a section of code with backticks (`) inline code formatting.

Typing:

`var x = 10;`

Results in:
var x = 10;

This can also be done as var x = 10; inline.

Multi-Line Blocks of Code

Surrounding code with three backticks ``` will allow for code to span multiple lines

Typing:

```
function foo(bar){
return bar+1;
}
```

Results in:

function foo(bar){
    return bar+1;
}

Syntax Highlighting

The code block will try to automatically choose a style for code, but you can explicitly call out the desired formatting.

```javascript
function foo(bar){
return bar+1;
}
```

Results in:

function foo(bar){
    return bar+1;
}
6 Likes