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: krl_geshiSyntaxHighlight
Get Firefox! creative commons


This plug-in will allow you to to add syntax highlighted code to your TXP articles.

You can use the tag in one of two ways:

The first reads the code in from a file, the second reads it in-line in the tag itself. The second is more convenient, especially where you have a number of small code snippets you want to highlight (you don’t need to upload any code for each thing you want to highlight) but has a few problems (mainly that you need to wrap the code in notextile tags).


There are a number of optional attributes you can use to pass extra information to the plug-in:


2005-01-29 v0.1 First release


Here is the plug-in being used to highlight some of the code which makes the plug-in – how cool is that?

  1. require_once('geshi.php');
  2. $geshi = new GeSHi($code_to_highlight, $language);
  3. //$geshi->enable_classes();
  4. $geshi->set_url_for_keyword_group(3, ''); // this line prevents GeSHi from turning every call to a built in function into a link to the PHP manual...
  5. $geshi->set_encoding("ISO-8859-1");
  6. $geshi->enable_line_numbers($linenumbers);
  7. $geshi->set_header_type(GESHI_HEADER_DIV);
  8. if ($linenumbers) {
  9.     $geshi->start_line_numbers_at($start_line_numbers_at);
  10. }


If you want to use the plug-in in the “in-line in tag” mode then you may have to hack TXP as I describe here so that the textile engine doesn’t get over enthusiastic in it’s replacement of certain characters.

If you want the code to display in a nice manner you will need to add these style rules to the stylesheet which is loaded wherever you highlight code:

div.krl_highlighted_code {
  margin: 5px 20px 20px 10px;
div.krl_highlighted_code div.header {
  margin: 0 0 2px;
  font-weight: bold;
div.krl_highlighted_code div.codeblock {
  margin: 0;
  padding: 6px;
  border: 1px solid #666;
  overflow: auto;
  font-size: 1.1em;
div.krl_highlighted_code ol {
  padding: 0 0 0 40px;

You can obviously change the numbers in the styles to fit with your site. The ol rule is important – it seems that IE doesn’t show up the line numbers when you don’t have this rule. The other rules are just to make things look a little nicer…

You will also need to set GeSHi up… Download it 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:

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

This should insure that the plug-in can find it’s language files when you select a language to highlight in.


You can download the plug-in from here:

krl_geshiSyntaxHighlight 0.1


These are all things that I would like to do to the plug-in to make it more useful – if anyone has any ideas on how to approach them or any other ideas for extensions then please let me know…


Please provide / view any feedback on this plugin at the bottom of this blog entry. If it looks like there is the need I’ll try and set something a bit more permanent up but that should do for now…