Every once in a while I want to paste Mathematica code on my blog. When I do, I would like it to be somewhat readable, and it would be nice to have syntax highlighting. So far all my searches have turned up with nothing. There are plenty of ways to colorize pretty much every language known to man, except perhaps Mathematica code. See this site, for example. The closest I've gotten to that is using :TOhtml in vim, which is pretty awesome, but gives me a whole HTML file, with and everything, and I'm not savvy enough to figure out exactly how to use it without destroying the rest of my post.
Answer
When you're writing a blog, then I assume you take some content management system like Joomla because otherwise a blog is maybe to hard to keep up-to-date in pure html. I have personal experience with Joomla and know, that code-highlighting as described below works great.
As mentioned by J.M. we have worked and tested hard to get a highlighter running for this site. What we did is to write a plug-in for the famous google code prettify. Please read the discussion here.
Therefore, the only thing you have to do is to setup google code prettify for your blog and add our language extension for Mathematica code lang-mma.js into the language files folder. Then you replace (you can of course adjust the colors for your site) the prettify stylesheet with prettify-mma.css.
Look around on this site. All code you see here is highlighted using this plug-in.
Comments
Post a Comment