Formatting code on GitHubApril 23, 2013
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 is wrapped in backticks—the ``` character.
Unlike normal HTML, there is no need to escape angle brackets—GitHub Flavored Markdown does that for you.
Multiple lines of code are easily created by placing three backticks before and after a code block.
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.
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.