Meta Stack Exchange is where users like you discuss bugs, features, and support issues that affect the software powering all 155 Stack Exchange communities.

What is meta?
Here's how it works:
  1. Any Stack Exchange user can ask a question
  2. The community provides support, votes on ideas, and reports bugs
  3. Your voice helps shape the way Stack Exchange operates

MATLAB language posts don't look good under google-code-prettify. As far as I understand from this post, MATLAB is currently highlighted by using the default language syntax.

For example, you can see this question. Since % is the standard in MATLAB to write comments, but it is not known, comments look weird.

However, it has an option to write a custom .js that defines a new language. I was thinking about writing myself a custom .js that will do the trick, but before I do that, I want to make sure that it will actually be used in Stack Overflow, and my effort is not in vain.

Is it possible to add custom google-code-prettify .js files to the server of Stack Overflow?

share|improve this question
We do have custom prettify javascript for a few languages, TeX for one. Ideally it'd be contributed back to prettify. – Kevin Montrose Feb 23 '12 at 18:47
I've been looking for a simple MATLAB highlighter but so far I've had no luck. Did you do your custom prettify? It would be nice if you post it somewhere if you did. – jmlopez Apr 6 '12 at 7:45
Don't forget Octave. – Mechanical snail Sep 13 '12 at 10:12
@KevinMontrose, it's been integrated into prettify. Could you look at updating the version used on Stack Overflow? – Matthew Simoneau Mar 6 '13 at 21:09
@KevinMontrose, over a year later, it has yet to be integrated on Stack Overflow. Is that a possibility, for us MatLab developpers? – Sifu Jul 25 '14 at 18:15
@KevinMontrose With the risk of being repetitive: This would be an awesome feature for the Matlab tag, that still doesn't have syntax highlight even if TeX has. And TeX is now off topic in stackoverflow... – Ander Biguri Jul 21 '15 at 10:09
up vote 33 down vote accepted

Back in May 2012, I started a project hosted on GitHub that implements MATLAB syntax highlighting for google-code-prettify (released under the MIT License). See here for the initial announcement, plus there was some discussion in the MATLAB chat room.

It comes in two flavors, one that detects and stylize all core MATLAB functions (plus functions from select toolboxes), and another that doesn't (mainly to keep file size to a minimum).

Should Stack Overflow choose to use it, it's as simple as serving an additional JavaScript file, which extends the code prettifier to handle MATLAB code.

For the time being, I created a userscript version so people can try it immediately (I have been using it myself for some time now).

You can install the userscript directly from the link or choose the "lite" version,

share|improve this answer
I have been using this very happily until now, when Google decided to disable any extensions that didn't originate from their store, and there's no way to re-enable them. It looks like the only way for people using Chrome to use this is for the developer (s) to upload the extension into the Chrome Web Store. – am304 Jun 16 '14 at 8:27
@am304: Firefox is my main browser, so I hadn't noticed the change.. Apparently the workaround is easy: just download the userscript as a regular file (prettify-matlab.user.js), go to your extensions page (chrome://extensions/), and drag/drop the file onto the page. That will bypass the store-only limitation. I just tried it and it worked fine. Alternatively you could install the Tampermonkey extension, this is like Greasemonkey for Chrome browsers (it's a must have extension for anyone who uses userscripts regularly). – Amro Jun 16 '14 at 12:23
See here for detailed instructions for various browsers: – Amro Jun 16 '14 at 12:24
I tried it and it didn't work. That's what I used to do but this week-end Google pushed a new version of Chrome that doesn't allow you to do that (Version 35.0.1916.153 m). – am304 Jun 16 '14 at 12:49
Update: it looks like if I first delete the existing extension and drag & drop the file again, it works. I'll try closing and re-starting Chrome next to see if it holds. – am304 Jun 16 '14 at 12:50
Nope. I restarted Chrome and it got disabled again, without the possibility to re-enable it. – am304 Jun 16 '14 at 16:30
I just tried it on a freshly installed Chrome (latest v35), and now I see what mean. Apparently Google has started blocking all extensions on Windows not installed from the Web Store (even permanently disables installed ones too!), except installs via enterprise policy or developer mode (unfortunately those are not the most straightforward ways). IMO the easiest method to working with userscripts is to just install the Tampermonkey extension to manage all your userscripts. – Amro Jun 16 '14 at 18:47
Here is someone who asked about the same problem:… – Amro Jun 16 '14 at 18:53
Thanks, I think I have managed to get Tampermonkey to work... – am304 Jun 17 '14 at 8:30

Amro's support for the MATLAB language has been accepted into google-code-prettify and the new version has been released. Can we update the version used here on

share|improve this answer
I totally agree that MATLAB syntax highlighting on SO sucks! I really hope it gets updated soon. – Oleg Apr 12 '13 at 14:28
MATLAB support has been integrated into google-code-prettify for some time now, but one must explicitly enable support for any of the additional languages. Stack Overflow chose to enable some of them but not all... As of now (and according to the JS file being served), the following additional languages are enabled by SO (not listing the ones included in the base package): Closure, CSS, Go, Haskel, Lisp, Lua, F#, Pascal, Protocol Buffers, R, Scala, SQL, LaTeX, VB, VHDL – Amro Jun 16 '14 at 13:13

Shameless bump.

I think proper syntax highlighting for matlab would be a very welcome addition. Given the number of questions regarding matlab on a daily basis, I'd say it deserves pretty code.

I tried to use other languages' syntax highlighting as a workaround, but no other language seems to have syntax which resembles matlab closely.

share|improve this answer
You can apply as much colour as you like, matlab code will never be pretty. Understanding it did for that ever happening – Richard Tingle Sep 29 '13 at 8:51
@RichardTingle Yes the matlab language has some ugly quirks. That said, syntax highlighting can make code significantly more readable, which in turn makes it easier for us to provide clear questions/answers. A simple color difference for comments and actual code would already go a long way. – Marc Claesen Sep 29 '13 at 8:55
I am of course joking (sort of). Syntax highlighting would of course be a good thing – Richard Tingle Sep 29 '13 at 9:16
Judging by other answers (and the docs) it's already in Prettify so all that's required is SE to pull the latest version (if they haven't already) and apply default syntax highlighting to the tag. – ben is uǝq backwards Sep 29 '13 at 10:08

You must log in to answer this question.

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