Code Highlighting Added
I just added code highlighting to my WP installation, after having fantasized about it for so long. First I tried a plugin based on Enscript, but that wasn’t ideal: it didn’t cache, so it would call enscript everytime the page is displayed!, and it had an ugly “Generated by Enscript” footer passed in from when it called enscript.
Rather than try to hack away these annoyances, I figured that there had to be an uber highlighter out there for WP, considering the type of people who are attracted to it. I was right: I found iG:Syntax, a plugin based on Geshi; it handles all the types of code I’m likely to be messing around with– even if not nearly as many as Enscript–, so I’m satisfied for now; supposedly it is easy to add support for a new language to Geshi, so if I ever want to show Scheme code, I can probably modify the Lisp syntax rules.
Even after finding iG:Syntax, I had to undo a few IMO weird defaults, like the fact that code is usually displayed in a pseudo-textbox, with scrollbars, line-numbers, and the language is displayed as a header over the code. The manual for iG:Syntax wasn’t too helpful here; I ended up delving into the code further than one should have to, just to get a sane setup. In this case, I guess it doesn’t matter: after all, who’s going to be using the plugin, yet not be capable of figuring out how to modify it? Apart from that one customization problem, the plugin is working great– it even links to documentation for functions called in the script. The thing I was most worried about, handling of > and other non-alphanumeric characters seems to be a non-issue, and considering that I tested it using a Perl script, that brings me great faith in its ability to handle them correctly in the future.
The next step is to install a plugin like Staticize, once I understand what it does correctly. I’m looking for something that will trap all the calls iG:Syntax makes to the Geshi script, and caches the generated HTML, to reduce the server load. From a cursory inspection of the description, Staticize seems like it might be the tool for that.
Possibly relevant posts:
- Further notes on spamming (6/16/2005)
- TeX/MetaFONT/MetaPOST (2/16/2003)
- JsMath and WP (5/3/2005)