This has been asked before, when we were still in beta.

Now we've graduated and everything looks all spiffy, I thought it would be nice to have syntax highlighting. As Jivings points out in the previous thread, we are primarily not a programming site, but on the other hand, we do get a decent amount of relevant snippets, mostly python, but also some C, C# (e.g., Windows IoT) and the occasional bit of shell.

I'm someone who looks at unhighlighted code and goes, "What? I have to read that without colors?". Although it would not make a huge difference to the stuff we have around here, one useful thing it does do is set off comments, as in this example:

Optimize portion of code for similar event callbacks in RPi.GPIO

That person did not make an effort to create an SSCCE, which is perhaps why there's not an answer -- but it at least serves as an example here.

Highlighting is set on a per tag basis, so if you want to use it, make sure the appropriate tag is on the question. It should then apply to the answers as well, or, as per the formatting tips,1, you can provide a direct per snippet hint, e.g. in answers where you have a solution involving code but adding the tag would not be appropriate to the question (or you don't have the rep to do so). For example:

<!-- language: lang-cpp -->

    vector<foo> bar;

Notice here the <!-- line is not indented. There also needs to be a blank line before and after it. If you have several snippets using the same language, use language-all: and it will apply to everything after that.

Presuming we do want it, the floor is open for suggestions about which tags would be appropriate and what language would be suggested for them. This can be set (by moderators) once enabled on an ongoing basis.

1. An observation, now that this has been enabled: It seems you need to use lang-foo, not just foo. There's a bit of a list on the Google Prettify repo page, but e.g., for shell/bash use lang-bsh. Defaults should be shown on in tag wiki, and if you have any suggestions leave a comment here.

  • 1
    I would be in favor of this. Off the top of my head I would add HTML, node.js and JS to the list of tags. Dec 4, 2015 at 16:54
  • @SteveRobillard No python?
    – Jivings
    Dec 7, 2015 at 9:07
  • @Jivings goldilocks already mentioned python and C above Dec 7, 2015 at 13:27
  • I managed to get formatting working here, possibly by manually tagging it. Big thing on MetaSE here
    – Wilf
    Dec 7, 2015 at 22:05
  • @Wilf It was enabled today; anything tagged python should be auto..have a look in chat too for some caveats.
    – goldilocks Mod
    Dec 7, 2015 at 22:09

3 Answers 3


Yeah! Sure, what are we waiting for?

I completely subscribe to this notion of yours: "What? I have to read that without colors?" And I also take it that the feature is implemented yet (as working on SO), so the workload to get it running here is small?

  • Apparently it uses Google Prettify client side, so I don't think it is any added load for the servers either. However, it's ultimately not up to me, and whether someone who can wants to bother may depend on the response here ("Your community doesn't seem to care, and it's not strictly necessary, so...")
    – goldilocks Mod
    Dec 4, 2015 at 19:57
  • Ah, well, I mean the workload for the mods, @goldilocks, to make it work. I have all confidence that the servers can handle it.
    – Ghanima Mod
    Dec 4, 2015 at 19:59
  • 2
    +1 It's 2015, reading code in monochrome is just barbaric :P
    – Jacobm001
    Dec 7, 2015 at 8:21
  • @Jacobm001 Ok looks like it is done!
    – goldilocks Mod
    Dec 7, 2015 at 16:21

We have turned on the site setting to allow for formatted code blocks. There is no default syntax, so you'll need to figure out what tags need to have prettified code blocks.

  • Seems to be working -- thanks much!
    – goldilocks Mod
    Dec 7, 2015 at 16:12
  • @Ghanima You can check this MSE post to see how you can force syntax highlighting.
    – Taryn
    Dec 7, 2015 at 17:12
  • Yepp, thanks. I took it to chat.
    – Ghanima Mod
    Dec 7, 2015 at 18:45
  • status-completed? :)
    – Seth
    Dec 8, 2015 at 1:21
  • @Seth status added
    – Taryn
    Dec 8, 2015 at 13:53

Seems self evident to me. I have been using syntax highlighting for 30 years.

I just tried adding <!-- language: lang-bsh --> but it didn't seem to make any difference.


You must log in to answer this question.

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