One of the nice things about moving away from use.perl to your own site is that you can install whatever toys you want.
I’ll eventually get round to posting code on this blog. And when I do it would be nice if it had some nice syntax highlighting. I could, of course, write my own syntax higlighter (probably based on something like PPI:HTML) but that sounds far too much like hard work, so a couple of days ago I decided to poke around to see what prior art was out there.
Initially, it looked like I was in luck. In the Movable Type plugins directory I found a link to SyntaxHighlighter for Movable Type, which is an MT wrapper around SyntaxHighlighter 2.0. The example output looked rather nice.
I downloaded it and installed it. And then I prodded at it for an hour or so. But all to no avail. It didn’t seem to work as advertised (or, indeed, at all). I fixed one obvious bug in the Perl support but it didn’t seem to help. I hope that the problem is just that Perl support hasn’t had as much testing as other languages[1]. There’s no obvious route for support, so I’ve left a message for the author on his blog. Hopefully he’ll get back to me and we can get this ironed out.
But, all in all, it looks like I’m not going to be able to be as lazy I’d like to be.
Unless, dear readers, you know better. Do you know of a syntax highlighting plugin for Movable Type? Have you patched this one to work? Is there an alternative solution that I’m missing completely?
[1] Which is only to be expected as Perl is, as I’m sure you realise, a dead language ๐
Update: Thought I’d take a look at the Javascript to see if I stood any chance of debugging it. Look at this!
Updated update: People more on the ball than me have pointed out that a) the horrible-looking Javascript has been minified and b) the original code is on bitbucket.
The JavaScript is just minified, I guess. There is a link to a wiki in the comments, which links to the source at http://bitbucket.org/alexg/syntaxhighlighter/
I use PPI::HTML on my blog, but that one is blosxom-based, so I have the luxury of running all my posts through TT before handing them to blosxom.
Also have a look at Yuval’s solution of using Github’s gists: http://blog.woobling.org/2009/05/graceful-degrading-of-gists.html
Marcel
You can do it easily using Vim. I described the technique in my blog:
http://www.haboogo.com/matching_patterns/2009/01/code-syntax-highlighting.html
Enrique