How to have Code coloration?


#1

When I post code on this forum, how do I make it so that I have syntaxic coloration? It seems preformated text is not enough.


#3

Heya — I couldn’t find docs for Discourse specifically, but it works the same way as Github: https://help.github.com/articles/creating-and-highlighting-code-blocks/

In short, after the three backticks at the beginning of your preformatted text, add the file extension to indicate which syntax highlighter you want to use).

This would produce:

```js

// Formatted Javascript Code! console.log(‘hello’);

```

This:

// Formatted Javascript Code!
console.log('hello');