Code
Display inline code and code blocks
Basic
Inline Code
To denote a word
or phrase
as code, enclose it in backticks (`).
Code Block
Use fenced code blocks by enclosing code in three backticks and follow the leading ticks with the programming language of your snippet to get syntax highlighting. Optionally, you can also write the name of your code after the programming language.
Syntax Highlighting
Put the name of your programming language after the three backticks to get syntax highlighting.
We use Prism for syntax highlighting. Test Drive Prism lists all the languages supported.
Names
Add a title after the programming language to set the name of your code example. The text can be anything as long as its all in one line.
Line Highlighting
Highlight specific lines in your code blocks by adding a special comment after the language identifier. Use curly braces {}
and specify line numbers or ranges separated by commas.
Expandable
If you have a long code block and [expandable]
after your title to make it close and expand.