GeSHi is a "generic syntax highlighter", originally designed for the phpBB forum system. It is licensed under the GNU general public license (open source). This article describes gotchas, fixes and improvements related to the stock install of GeSHi in Joomla 1.6.

Using GeSHi

GeSHi must be enabled in the administrator of Joomla. (Extensions > Plug-in Manager > Content - Code Highlighter (GeSHi))

A Joomla plugin scans the content of your articles and replaces the existing text with new text. In this case you will be replaceing your <pre> tag content with highlighed code. GeSHi is very subtle and won't highlight your code unless you explicitly tell it to. To tell GeSHi what language your code is in you add the xml:lang="php" attribute to your pre tag. Here are some examples:


<!-- html5 -->
<pre xml:lang="html5">
<header>test</header>
</pre>

<!-- php -->
<pre xml:lang="php">
<?php echo test; ?>
</pre>

The list of avaiable languages can be found in the folder: {joomla root}/plugins/content/geshi/geshi/geshi just replace the php in xml:lang="php" with the name of the file you would like to highlight (leaving out the extension).

Adding New Languages

GeSHi supports a lot of languages, but Joomla only has a minimum set in the default install. If you want to add languages to GeSHi, here is what you have to do.

  1. Download the current version of GeSHi
  2. Extract the files
  3. Navigate to the geshi/geshi folder
  4. Choose all the languages or just the ones you want to install
  5. Copy them to your Joomla geshi folder located here: {joomla root}/plugins/content/geshi/geshi/geshi

Technically this is a "core modification", which means you will wipe out any changes with future updates. If you are leaving the GeSHi files in their original state, this is not a problem as they will be updated or untouched with future Joomla upgrades. However, if you are changing the colours from the default colours you will want a version control system or another solution to manage future updates.