A problem occured while loading the plugin: krl_flickr_photoset -> : Assigning the return value of new by reference is deprecated on line 18
kelvinluck.com: Plugin to add GeSHi syntax highlighting to Textpattern - Part II
Get Firefox! creative commons

Plugin to add GeSHi syntax highlighting to Textpattern - Part II

Update – see the krl_geshiSyntaxHighlight project page for more information

...continued from yesterdays post

EDIT: Please note that the code samples in this look better than they did when I wrote it because I have since updated the engine which generates them (as you will see if you read my other entries) – so when I talk about quotes and underscores and the like being changed into wierd HTML entities it was true!

OK – thanks to some people on the textpattern forums I’ve managed to half fix the problem from yesterday. By placing tags around the code in my example I now have the quotes not being changed into strange HTML entities. As you can see here:

PHP:
  1. function GeSHi ($source, $language, $path = '')
  2. {
  3.   if ($path == '') {
  4.     $path = dirname( __FILE__ ).'/geshi/';
  5.   }

Unfortunately the FILE is still getting translated into first italic tags and then <i>FILE</i>.

While I was wondering if there was a way to avoid this I came across Johan Nilsson’s glx_code plugin…

How comes I didn’t find it yesterday when I was looking for a way to highlight my code? Oh well – I’ve gone far enough along my path now that I need to complete it! And the way that the glx_code plugin works gave me an idea. It avoids any issues with textile by loading the file with the code sample in rather than by having it included inside the page (as my approach did). So I thought I would add the option to do this to my plugin. And here is the result marking up the above bit of code:

PHP:
  1. function GeSHi ($source, $language, $path = '')
  2. {
  3.   if ($path == '') {
  4.     $path = dirname( __FILE__ ).'/geshi/';
  5.   }

Sweet – that seems to work nicely :D I’m not sure it is a perfect solution because it requires creating a file on my server for each code snippet I want to highlight but it is at least functional. I’ll leave it like that for now and see if I can find a way to get the contents of the tag without textile getting it’s grubby mits on it first!

And I’ll be back soon with another installment which will hopefully contain the final plugin and instructions for it’s use…