StackOverflow syntax highlighting override - lmmx/devnotes GitHub Wiki

I always forget the way to do this (and it's a little hard to search for):

  • Add <!-- language: lang-or-tag-here --> to an answer to get the markdown renderer's syntax highlighting
  • See this post for details

Some examples of language codes (via the full list here):

  • Python: <!-- language: lang-py --> or <!-- language: lang-python -->
  • R: <!-- language: lang-r -->
  • Bash: <!-- language: lang-sh --> or <!-- language: lang-bash -->
  • Javascript: <!-- language: lang-js --> or <!-- language: lang-javascript -->
  • Go: <!-- language: lang-go -->
  • HTML, XML: <!-- language: lang-html --> or <!-- language: lang-xml -->
  • CSS: <!-- language: lang-css -->
  • Regex: <!-- language: lang-regex -->
  • LaTeX, TeX: <!-- language: lang-latex --> or <!-- language: lang-tex -->

You can also specify no syntax highlighting with lang-none