When writing articles about drupal or anything that requires code to be shown, its great to have syntax highlighting just to liven up the page.
UPDATE: Setup GeSHi on Drupal 7
- Drupal 6
- GeSHi Filter drupal Module http://drupal.org/project/geshifilter
- GeSHi Code http://qbnz.com/highlighter/
Step 1 Install GeSHi
Go to http://drupal.org/project/geshifilter and download the module and place it in sites/all/modules. Download the geshi library from http://qbnz.com/highlighter/ and extract the geshi folder in the zip file into sites/all/modules/geshifilter.
Right now you should have two folders:
- sites/all/modules/geshifilter (Module folder)
- sites/all/modules/geshifilter/geshifilter (geshi library folder)
Once everything has be copied over go to Administer >> Site Building >> Modules and enable the module.
Step2 Configure GeSHi
Go to Administer >> Site Configuration >> Input Filters and on your default filter click on configure.
Tick the GeSHi filter check box under filters.
Creating a story
Go to create content and click on story. If you click on “Input Filters” you’ll notice the following:
From there you can see that GeSHi is enabled.
To add php code just add the following code:
Make sure you wrap all php code around the
. Check out the end result.
The module also gives you a “Source code node” content type where you can paste in a bunch of code in the body and set language type via a drop down. You don’t have to wrap the code wrap the
tag. You would use this content type to just display code.
GeSHi Configuration options
To change any options for the module go to Administer >> Site Configuration >> GeSHi Filter.
By default the module doesn’t enable all languages, to enable or disable click on the languages tab then All to view available languages.
To enable a language just tick the check box and hit save configuration.