12
$\begingroup$

We now have syntax highlighting for code. To use it, put your code in code fences and specify the language. See /editing-help for more details. Here's an example. It's pretty!

Some tags have highlighting turned on by default. These are mostly programming-related tags, like , , and . In this case, the interpreter will try to infer the language, but if it gets it wrong, you can always specify it. If you want syntax highlighting turned on by default for a certain tag, let a mod know. And even if the tag doesn't have highlighting turned on, you can turn it on in your post by specifying the language in your code fence.

Highlighting is not currently available for AMPL, GAMS, and some of our other favorite OR-specific languages. If you'd like to take a crack at writing a highlighter for one of these languages that is compatible with Google Prettify, have at it—the SE developer who handles this feature said they would try to hook it into the system ("no promises, I've never done it, but it should be easy enough").

For existing posts, highlighting won't be visible until the post is edited.

$\endgroup$
2
  • 2
    $\begingroup$ Also note this response to a request to add syntax highlighting for a language currently unavailable. The person wrote and submitted the file but it wasn't merged, as the prettifier isn't being maintained. That is not to say 'it can't happen' as Mathematica.SE has SH for Mathematica. We'll need to discuss what we really want (a lot) as there's a page load penalty and Dev time to consider. $\endgroup$
    – Rob
    Oct 3, 2019 at 6:58
  • $\begingroup$ @Rob Good data point to keep in mind. $\endgroup$ Oct 4, 2019 at 0:32

0

You must log in to answer this question.

Browse other questions tagged .