Right now the code blocks on SF don't support syntax highlighting. Instead we get boring, grey, hard to read code.

I spent some time today on the Unix & Linux SE, which does offer syntax highlighting. It does so based on the assumption that any code in blocks is probably in some sort of shell language like bash.

Could we have a similar system on SF that uses the tags to form assumptions?

E.g. if a question is tagged PowerShell, the code blocks in the question and answers will probably contain PowerShell.

  • 4
    See Jeff's comment in meta.stackexchange.com/questions/72082/… -- "diamond moderators can now change syntax highlighting on a per-tag per-site basis. We're also looking at an in-source override syntax soon". Also meta.stackexchange.com/questions/981/…
    – jscott
    Commented Jan 19, 2012 at 12:58
  • Ok, so lets lay down some ground-rules and choose the tags we want to use :) Commented Jan 19, 2012 at 13:03
  • 1
    @jscott The in-source override syntax doesn't work. Commented Jan 19, 2012 at 16:09
  • 2
    Changed tag to bug from feature-request since it is expected-functionality-not-working.
    – sysadmin1138 Mod
    Commented Jan 19, 2012 at 16:52

4 Answers 4


We do have syntax highlighting on some tags. We just don't turn it on by default since we get sooooo vastly more log-snippets than code-snippets that generic highlighting doesn't work. We had it on at the w-a-y beginning in 2009, but turned it off since it didn't do anything for us.

I just can't find where mods set it on the tags. I do know it's per-tag though.

  • 1
    +1 It'd be pretty useless even on a per-tag basis. Too many logs...
    – Chris S
    Commented Jan 19, 2012 at 14:01
  • Manual specification of the language, supposedly overriding the highlighting from the tags, doesn't work. See this answer, for instance; I specified <!-- language: lang-c --> at the top of the code block and it didn't do anything. Commented Jan 19, 2012 at 16:04
  • What'd be nice is if there were some good coloring for some of the common config file types we see - XML coloring would catch the handful of XML configs, but it'd be really cool to see some good coloring on Puppet manifests, Apache configs, Cisco configs, etc. I wonder how much of a pain it'd be to add types? Commented Jan 19, 2012 at 16:18
  • 2
    You can't find the setting because code highlighting is turned off for Server Fault. Let us know if you want to give it another try, we can turn it on then.
    – balpha StaffMod
    Commented Jan 20, 2012 at 7:04
  • @balpha Looks like a "yes": meta.serverfault.com/questions/2717/… Commented Jan 25, 2012 at 16:44

As proposed by balpha, we should make up our mind about this and put it to a vote. I'll check back for comments here but if I haven't heard back before monday I'll make a vote-Question.


We should enable Manually specify language for syntax highlighting so people in the know can add the relevant language descriptor to posts. It'd be nice too if the Question box auto prompted you (a box on the right side perhaps) when you paste a log/code snipet, giving you a list of possible lang specifications that the user can easily click on.


While on the surface this sounds like a great idea it's not as attractive after giving it some more thought. Due to the diversity of what we work with I just can't see tags being a good way to go.

What if someone used the powershell tag but is actually asking "how can I do the equivalent of this bash script in PS?"

A question may have bind9 and perl tags. What syntax gets applied? The code may refer to either a Perl code snippet or to part of a BIND config file. Possibly even one of each.

If the user has to over-ride that with special markup things just get messier. The markup used on SE sites is quite unintuitive and many (most?) of us only use the small sub-set we've managed to remember, or none at all.

  • Indeed, a common case on ServerFault would be to see a question tagged with [apache2] and [php] with code blocks containing log files as well as those two languages. Worse, the log files can even contain snippets of PHP. Heuristically identifying the language might be plausible but I think manually specifying or getting no highlighting would be the only safe option. The markup syntax problem should be solved by adding a dropdown in the buttons above the text area.
    – Ladadadada
    Commented Jan 24, 2012 at 22:01

You must log in to answer this question.

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