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