Skip to main content

Welcome to Geoff Hayward's Weblog

Commenting on Java, JavaFX, Java EE, Joomla, and IoT.

All the versions of Joomla I know have shipped with the GeSHi syntax highlighter. The GeSHi Syntax highlighter comes in the form of a plugin that is by default unpublished. Its power comes from the fact that it does all the syntax highlighting server side. Meaning caching can be taken full advantage of.

The GeSHi - Generic Syntax Highlighter is an award-winning piece of software released under the GNU GPL license and is packaged into a plugin by Joomla ready to be used by any author or publisher who needs to highlight the syntax of their examples.

When I found the Joomla GeSHi plugin, I discovered there was very little documentation on how to use the Joomla plugin. This may have been because it is quite easy to uses once you know how, however, I didn't know how at the time. I had to piece together very small snippets of information until the 'how to' for me came together.

Here is How to Use the Joomla GeSHi Plugin

The first step is to go to Joomla's plugin manager. Search for 'GeSHi' and publish the result. The Joomla GeSHi plugin will then be active ready for the Joomla's advanced event system (sometimes referred to as hooks in other CMS's terminology) to call it during 'onContentPrepare'.

Now when adding content simply use the HTML pre tag with the GeSHi xml:lang attribute. The value of the attribute needs to be the language that is to be syntax highlighted. For example:

<script type="text/javascrpt">
	/* Highlighted JavaScript stuff  */

will give you a syntax highlighted JavaScript snippet.

TinyMCE Gets in the Way of the Joomla GeSHi Plugin

Be warned TinyMCE is a bit of a pain when it comes to using the GeSHi plugin. The best solution is to just disable TinyMCE. What about the non-technical users? - you may ask. Well you can disable TinyMCE for your account only or the user group of authors who need syntax highlighting - for example you could set up a 'Technical Author' group. Another alternative I have found is to use the JCE editor. When the JCE editor is configured properly, it will play nicely with the GeSHi Joomla plugin.

What Languages Will the Joomla GeSHi Plugin Highlight?

Version 3 of Joomla will get GeSHi to highlight following:

  • CSS
  • Diff (Diff File Format)
  • HTML
  • ini (Configuration files)
  • JavaScript
  • MySQL
  • PHP
  • SQL
  • XML

They are All Triggered Respectively as Follows:

<pre xml:lang="CSS">
<pre xml:lang="Diff">
<pre xml:lang="HTML">
<pre xml:lang="INI">
<pre xml:lang="Javascript">
<pre xml:lang="MySQL">
<pre xml:lang="PHP">
<pre xml:lang="SQL">
<pre xml:lang="XML">


The Joomla GeSHi Plugin is a great tool for authors and publishers were syntax highlighting is in need. The Joomla GeSHi Plugin is not difficult to use as this article tries to show and help with. Out-of-the-box the Joomla GeSHi Plugin has a good selection of languages that technical bloggers and writers are likely to need. If the language you need is not included, please see below for: What if the language I need is not included? Otherwise I hope this article was helpful.

What if the Language I Need is Not Included?

Well you could just add it to the GeSHi folder within the plugin - that is how GeSHi itself works. However, as I am sure you know, this is hacking the Joomla core and is bad and unnecessary. The solution is to copy the Joomla GeSHi plugin folder to your local machine. Then add whichever languages you need that are available from the GeSHi project to the plugin's GeSHi folder. Then repackage it up with an amended install XML file, zip it, and install it back into Joomla. Do not forget to publish your extended version and you're away.

Here is one I prepared earlier that has all the languages GeSHi has available:


  • For performance reasons I recommend removing the languages you will not be using
  • It comes with no warranty

Tags: GeSHiJoomla


Mailing List

Responsive Media

With the ResponsiveMedia plugin for Joomla it is easy to add 3rd party content from YouTube, Vimeo, and Instagram right in to any Joomla! article.