a stroke of luck

Plugin to add GeSHi syntax highlighting to Textpattern

Update 2:

This is a very old page imported from my previous blog. If there is missing content below or anything that doesn’t make sense then please check the page on my old blog.


see the krl_geshiSyntaxHighlight project page for more information.

So I have this new blog thing and it occured to me that one thing I would want to do with it is to post code I’ve written. I had a look around and it didn’t seem like there was a plugin available to do syntax highlighting for code posted to Textpattern. So I thought that it would be a good quick project for me to get to know abit more about Textpattern to try and add the syntax highlighting capabilities of GeSHi to it.

And thats exactly what I’ve done! It’s functional but not quite perfect at the moment and it’s past my bedtime so this is as far as I got…

First download GeSHi from here (I got 1.0.4 – the latest at the time of writing). Then extract it so that the geshi.php file is somewhere in your include path and so that the geshi folder (which contains all the language files) sits at the same level as this file.

Then edit the geshi.php file so that the relevant lines look like this:

function GeSHi ($source, $language, $path = '')
if ($path == '') {
$path = dirname( __FILE__ ).'/geshi/';

D’oh! Just looking at that I have noticed that there is a problem with where htmlentities is called within GeSHi. As you can see, the quote marks have got all messed up in the code above. So I’m going to have to leave it for the moment I think and return to getting this polished along with providing the plugin tomorrow…

No Comments, Comment or Ping

Reply to “Plugin to add GeSHi syntax highlighting to Textpattern”