Build web site

Build an own community web-site. A samurai path. A tutorial on Drupal

Sunday, December 04, 2005

Installing source code highlighting. Part 2

Codefilter module, we installed in the part 1 can be enhanced with the Generic Syntax Highlighter - GeSHi. With the GeSHi in action you can post to Drupal site really nicely coloured source-code.

1. Before applying the patch download the Geshi engine itself. (Link to the download page on the Sourceforge)

2. Upack it and upload everything, but contrib and docs directories to your site's modules/codefilter directory so that you had the following directory structure:
I am describing it in such a detail, because some people are really confused ending with the several enclosed directories with the same name

3. Download the latest version of the codefilter-geshi patch (Direct link to the version 4.6.0 from August 6 2005). Downloaded patch is in a special format created by the diff utility and supposed to be pathced by the patch utility (Generic Drupal instructions on creating and applying patches)

4. Update the patch to the codefilter directory

then log in to your server shell and apply the patch by running "patch
You could also apply patch on your Windows PC. For this, you'd have to locate the Windows version of the patch utility.

5. Go to admin->modules. Disable codefilter module and enable it back. This procedure will install the geshi-related settings into the settings menu

6. Visit the admin->settings->"Codefilter Config", enable the highlighting and select the default highlight language. It is c++ in the SymbianExample case

That's it now all your posted source code will be nicely formatted with the C++ language in mind. You can use any other language supported by geshi, by specifying it in the language argument. E.g. language="python". You can also turn autohighlighting for the particular code snipplet off by passing the highlight="false" argument. Note, that there should be no space before and after the "=" character.
Here's how the post source will be transormed into the nicely formatted output:

While the site is still under construction you are welcome try the feature yourself. Create an account on SymbianExample and post some code yourself.

The next step of the tutorial will be integration of the Rich Text editor, that will allow posting texts via almost Word interface.
Stay tuned


Post a Comment

Links to this post:

Create a Link

<< Home