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…


This content originally appeared on @mdo and was authored by Mark Otto

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.


This content originally appeared on @mdo and was authored by Mark Otto


Print Share Comment Cite Upload Translate Updates
APA

Mark Otto | Sciencx (2013-04-23T00:00:00+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 ,<https://www.scien.cx/2013/04/23/formatting-code-on-github/>
VANCOUVER
Mark Otto | Sciencx - » Formatting code on GitHub. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2013/04/23/formatting-code-on-github/
CHICAGO
" » Formatting code on GitHub." Mark Otto | Sciencx - Accessed . 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: ]
rf:citation
» Formatting code on GitHub | Mark Otto | Sciencx | https://www.scien.cx/2013/04/23/formatting-code-on-github/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.