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.

有帮助吗?

解决方案

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.)

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top