Possible Duplicate:
Syntax highlighting language hints
Interface options for specifying language prettify

How do I set the language being highlighted in Stack Overflow to be colored and formatted for ruby?

I've seen this somewhere but can't find it now.

Something like a one line option at the top of a file.


1 Answer 1


You can't highlight a language with Markdown. You need to outsource this to external libraries. Such as.

  1. SyntaxHighlighter
  2. Google Code Prettify
  3. Pygments

EDIT: The StackOverflow way of doing this is to have a comment at the top. Like so.

<!-- language: lang-js -->

Just replace lang-js with one of the language codes or a tag to set the language to the language associated with that tag. For example.

<!-- language: c# -->

Highlighting for c# is associated with the c# tag.

(use lowercase letters, uppercase letters like <!-- language: C# --> does not work.)

  • Good point, my question was not clear so i added more detail. May 4, 2012 at 1:18
  • 1
    +1 Yup, lang-rb for ruby worked for me (maybe I can do mutiple languages on one page even?) May 4, 2012 at 1:30
  • I would assume so.
    – user184498
    May 4, 2012 at 1:33

Not the answer you're looking for? Browse other questions tagged .