You can include code blocks in your post, with automatic syntax highlighting (color!). See the highlight.js website for a demo and more details: https://highlightjs.org/static/demo/
Using ```
(triple backticks) to create a code fence around your block of code will automatically highlight the code. To tell the highlighter which language your code is in, type the language immediately after the beginning triple backtick like this: ```php
Usage
So, putting it all together, you can
```LANG
your code here
```
Or simply
```
your code here
```
And hope that your code is enough for the parser to figure out which language to use.
What languages are recognized/supported?
Right now, we’ve enabled apache, bash, cs, cpp, css, coffeescript, diff, xml, http, ini, json, java, javascript, makefile, markdown, nginx, objectivec, ruby, perl, php, python, sql, handlebars
We could add more, but don’t want to hurt performance of the site.
Examples
/* php */
echo "hello world";
// javascript
echo "hello world";
# bash
echo "hello world";
As an aside, single backticks around your content produce “preformatted text”
This is what text looks like when surrounded by single backticks
Also, indenting a whole block of text by four spaces turns on the syntax highlighter.
this
is
content
indented four spaces
echo "hello world"