-
Notifications
You must be signed in to change notification settings - Fork 0
GeSHi Syntax Highlighter Plugin
This article describes a plugin that I wrote that enables GeSHi syntax highlighting in CodeIgniter Sites.
[h2]What this Is[/h2]
This is a plugin (aka "hook") for CodeIgniter that will convert anything between ... tags to GeSHi-higlighted content. If you're not familiar with GeSHi, you can read more about it at the GeSHi Webiste ([url]http://qbnz.com/highlighter/[/url]).
[h2]How to Install[/h2]
-
Download the GeShi plugin from [url]http://caseyamcl.com/downloads/ci_geshi.zip[/url]
-
Unzip the files, and extract the "geshi_hook.php" file and "geshi" folder to your hooks directory in your application folder. (you may have to create the "hooks" folder if it doesn't already exist)
-
Add the following code to your application/config/hooks.php:
[code] /* ----------------------------------------------------- / / -- GeSHi Plugin Hook -- / / ----------------------------------------------------- */ $hook['display_override'] = array( 'class' => 'Geshi_hook', 'function' => 'run_geshi_filter', 'filename' => 'geshi_hook.php', 'filepath' => 'hooks', 'params' => array('line_numbers_on')); [/code]
[h2]How to Use[/h2]
It's simple. Anywhere that you put ... in your output code (in your view files), this plugin will convert it to <pre class='geshi'>..., and automatically highlight everything between the tags.
If you want to specify a language to highlight the code, simply add an attribute to the tag: ... or ..., etc... GeSHi supports dozens of langauges.
[h2]More Inforamtion[/h2]
I have a more detailed explanation of this plugin at my website: [url]http://caseyamcl.com/resources/geshiForCI[/url]