updates @ m.blog

Source Highlighting for WordPress

I wanted to have a source code highlighting plugin for WordPress, and the best existing one seems to be Amit Gupta’s iG:Syntax Hiliter. However, a number of things about that plugin annoyed me… so I changed them. Three cheers for open source!

  • Added SCROLL_BOX and SHOW_LANG style variables to definitions, to make it easier for people to decide whether they want the language prefix header and/or fancy scroll box options (I didn’t).
  • Cut out about 500 lines to redundant code, reducing the size of the program source by about two thirds(!).
  • Added language support for Apache log files, Bash, C#, Lisp, Objective-C, and VB.NET. This depends on you installing a more recent version of GeSHi with all of the language support files (the author of iG:SyntaxHiliter bundles a version without the files for languages he doesnt support).
  • In addition, the new structure should make it trivial to implement any other language supported in GeSHi with two lines of code. I didn’t bother to add any others myself, since I’m lazy. If you look at the source you’ll be able to figure out how to do it.

Not bad for an hours worth of work in a language I’m not familiar with.

You can download a copy here: syntax_mhr.bz2

It’s not polished, and doesn’t come with instructions, so you may wish to refer to the original version if you need handholding, and then just substitute in the replacement files. Remember, you must install a copy of GeSHi for this to work.

As per the licensing on the original, this is released under a Creative Commons Attribution-ShareAlike-2.0 license.

This should be considered a “hack”. I may (or may not) clean up the code further and add more features in the future, but I do not plan on making this an official fork of the plugin, nor offering customer support. Amit is more than welcome to backport these changes into the official plugin under the terms of the license, and I encourage him to do so.