Well, very inspired by Aral Balkan yesterday, got straight in Dreamweaver and started following the instructions, until I found I only had one of the files he had. I didn’t realize b2evolution was not infact b2/cafelog, it has changed considerably, everything is now very OO. Thankfully now there’s no need for hacks to the source (I hope).
Now you have to create a PHP sub-class of Renderer, and get that to do some preg_match’ing of it’s own. My PHP hat is still fairly new, but I’ll try and go through what I had to do to get it all working….you can just download it if you feel lazy.
First of all, GeSHi will (at present) only work on PHP 4 and some PHP 5 installations (specifics yet to be confirmed), but I’ve written a workaround later on in this post.
- Unzip the first file, and put _geshi.renderer.php in “b2root/plugins/renderers/” (where b2root is your blog’s root directory)
- Place geshi.css in “your_skin_directory/geshi.css” (e.g. on mine this is “b2root/skins/custom/”)
- Add to “b2root/config/_config.php”:
include_once (dirname(__FILE__ ) . ‘/../geshi.php’);
- Add to “b2root/skins/custom/_main.php” (where custom is your current skin):
<link rel=”stylesheet” href=”geshi.css” type=”text/css” />
All done 🙂 you should now be good to go…
- Wrap any code in [as], [java] or [php] (etc) tags.
- Click the tick next to “Geshi” in the Renderers palette.
[as]Date.prototype.getDateOffset = function(offset)
var retDate = new Date(this);
Good news is, your code remains editable in the admin section, you save some CPU cycles as the CSS is pre-generated (you can generate more with cssgen.php provided with GeSHi). I’ve included CSS for Actionscript, PHP, Java, HTML, but the renderer is only looking for the 1st three of those for speed reasons, you can enable as many as you like in under a minute.
Now for PHP 5 :s :
(Un)lucky for me, my webhost is running PHP 5, which GeSHi doesn’t like, so in light of this, I’ve written a Proxy Renderer class, that will get a script on a PHP 4 server to generate the required highlighted code, and return it to the Proxy plug-in.
To install, simply download the geshiproxy_for_b2.zip files and modify the commented code in the “geshiproxy_Rendererplugin.php” file to point to your PHP 4 server (this could be a free host with banners for example). Put that file in your “b2root/plugins/renderers” folder. Next up, put the “doGeshi.php” file on your PHP 4 webhost, at the location defined in the Proxy class.
This is currently the method I am using, and so far so good as long as you’ve installed GeSHi to your other host of course.
Good luck, please feel free as always to comment on anything.