# Mathematica Syntax Coloring in GitHub README

GitHub doesn't auto-detect and color Mathematica code in its markdown. Can we make it do so?

This may be trivial, but many README files don't seem to have it.

• My README files actually have highlighting ;). – jkuczm Aug 16 '17 at 19:51
• @jkuczm Good to know. I'll add that as a note. (I must have missed the purple on the Get) – b3m2a1 Aug 16 '17 at 19:53

It seems to have been possible at least since March 16th 2016 and probably earlier (thanks to jkuczm) I found it here (cannot remember how I ended up there). Here's another example using it.

If we look at how that works, though, we see this:

Mathematica
Manipulate[
Module[{
Graphics3D[{
{ColorData["B...
etc.



And so just sticking your code in a block like that headed by Mathematica does it. I suppose this should have been obvious. But maybe it's good to have it here for those of use who only use GitHub sparingly.

I used this trick here. Admittedly, the highlighting is poorly implemented and the colors are garish, but it's fun, at the very least. And maybe GitHub will improve it some day.

One caveat: As Szabolcs notes, this is not necessarily assured to work on other Markdown-using sites.

• It may be good to note that only fenced code blocks support this, and fenced code blocks are not standard Markdown (hence may not render properly if the project is moved to a different hosting than GitHub). [Also, I do not think this QA is off topic at all.] – Szabolcs Aug 16 '17 at 7:54
• @Szabolcs They are standard: spec.commonmark.org/0.28/#fenced-code-blocks – Riking Aug 16 '17 at 17:48
• @Riking There seem to be disagreements and no proper standard ... Once I was told that some tool didn't support fenced code blocks because "it's not standard" and I believed it. Python markdown also doesn't support it, and the extension to add support did not play well with the syntax colouring extension I once tried to use. So as you say, my statement about the standard was incorrect. But using this still have the risk I mentioned. All implementations support indented code blocks, but several don't support fenced ones (e.g. the one used here on SE). – Szabolcs Aug 16 '17 at 19:49
• @b3m2a1 Sorry I accidentally linked to highlight.js, while it seems that GitHub uses Linguist – jkuczm Aug 16 '17 at 20:05
• @JohnJosephM.Carrasco interesting. Alternatively you can also use halirutan's prettify.js plugin. That's what I do and I think what Szabolcs does. – b3m2a1 Aug 17 '17 at 22:14