We're starting to get questions with reasonable code snippets in MATLAB and Python, and it would be very useful to enable syntax highlighting for Python, MATLAB, Fortran, C, C++, and R (these are the main languages I can think of in common use in computational science). An example question for which such a feature would be useful is Numerical integration for modelling curve for superconductors (Python).
As @hardmath pointed out, you can already explicitly enable syntax highlighting by prepending
<!-- language: lang-py --> (note the spaces) and an empty line before the code block. (This is mentioned on https://stackoverflow.com/editing-help#syntax-highlighting.)
What doesn't seem to be working on the SciComp.SE site is automatic syntax highlighting by associating specific tags (
matlab etc.) with the corresponding language code, as is done on the StackOverflow site. Jeff Atwood writes in a comment on https://meta.stackexchange.com/a/72163:
diamond moderators can now change syntax highlighting on a per-tag per-site basis.
I'm not sure if this refers to site moderators or only to SE network moderators.
This is an excellent idea! I'm surprised that stack overflow hasn't gone in this direction already...
GitHub has the code they use for syntax highlight open-sourced, it may be a good place to start.
Added: Apparently StackOverflow does support a number of manually specified language options for syntax highlighting, over a previous/default approach that used question tags to infer a language for syntax highlighting. Who knew?
Since the tags here are not terribly language directed, this may well work for us with little or no extra effort.
It's certainly a good question. Since some Markdown syntax options for code are quite minimalist, it's not obvious how a language designation would best be integrated with the monospace display context. Perhaps it really wants a new display context, analogous (but not as intricate) as the MathJAX/LaTeX context.
Likely what @RSFalcon7 is referring to above is GitHub Flavored Markdown. At any rate it shows what can be done, and what tradeoffs might be necessary.