Formatting code on GitHub

I see a fair number of issues, pull requests, and comments on GitHub from folks who don’t know how to highlight snippets of code. While this is a problem in it’s own right and we should solve that, I figure I’d drop some knowledge until we figure that…

I see a fair number of issues, pull requests, and comments on GitHub from folks who don’t know how to highlight snippets of code. While this is a problem in it’s own right and we should solve that, I figure I’d drop some knowledge until we figure that other stuff out at GitHub.

Inline code

Inline code is wrapped in backticks—the “` character.

This is an example of inline ```.

Unlike normal HTML, there is no need to escape angle brackets—GitHub Flavored Markdown does that for you.

Code blocks

Multiple lines of code are easily created by placing three backticks before and after a code block.

```
.element {
  ...
}
```

Language-specific code blocks

You can optional specify a language for proper syntax highlighting on code blocks. Just add the language identifier after the first set of backticks.

```css
.element {
  ...
}
```

Further reading

More of the GitHub Flavored Markdown nuances are documented on the GitHub Help site. Check it out for information on autolinking, task lists, Emoji, and more.


Print Share Comment Cite Upload Translate
APA
Mark Otto | Sciencx (2024-03-28T22:05:07+00:00) » Formatting code on GitHub. Retrieved from https://www.scien.cx/2013/04/23/formatting-code-on-github/.
MLA
" » Formatting code on GitHub." Mark Otto | Sciencx - Tuesday April 23, 2013, https://www.scien.cx/2013/04/23/formatting-code-on-github/
HARVARD
Mark Otto | Sciencx Tuesday April 23, 2013 » Formatting code on GitHub., viewed 2024-03-28T22:05:07+00:00,<https://www.scien.cx/2013/04/23/formatting-code-on-github/>
VANCOUVER
Mark Otto | Sciencx - » Formatting code on GitHub. [Internet]. [Accessed 2024-03-28T22:05:07+00:00]. Available from: https://www.scien.cx/2013/04/23/formatting-code-on-github/
CHICAGO
" » Formatting code on GitHub." Mark Otto | Sciencx - Accessed 2024-03-28T22:05:07+00:00. https://www.scien.cx/2013/04/23/formatting-code-on-github/
IEEE
" » Formatting code on GitHub." Mark Otto | Sciencx [Online]. Available: https://www.scien.cx/2013/04/23/formatting-code-on-github/. [Accessed: 2024-03-28T22:05:07+00:00]
rf:citation
» Formatting code on GitHub | Mark Otto | Sciencx | https://www.scien.cx/2013/04/23/formatting-code-on-github/ | 2024-03-28T22:05:07+00:00
https://github.com/addpipe/simple-recorderjs-demo