Extension:GeSHiCodeTag

See also: Extension:SyntaxHighlight GeSHi.

Introduction
I've been searching for a good syntax-highlighting code extension for MediaWiki but unfortunately I can't find one that fit my needs. So I decided to just create one myself since I'll also be using it heavily on my site. I also wrote the code as readable and customizale as possible so you can easily extend its features. Feel free to email me for questions/comments/suggestions/errors. Hope you all like my first (and hopefully not the last) MediaWiki extension!

README
Features:
 * Two types of code tags: simple and advanced.
 * Ability to list all languages supported by GeSHi.
 * Ability to disable/enable the code tags
 * Extendability and readability of the code.

Requirements:
 * GeSHi

Tested on: (If you've tested it and it's working on a different version please add it here! Thanks!)
 * MediaWiki 1.12.0 1.11.0, 1.10.1, 1.10.0, 1.9.3, 1.9.2, 1.8.2, 1.7.1, 1.6.8, 1.5.7, 1.5.3 (but see Issues below)
 * GeSHi 1.0.7.22, 1.0.7.21, 1.0.7.20, 1.0.7.19, 1.0.7.17, 1.0.7.12
 * PHP 5.2.5, 5.2.4, 5.2.1, 5.1.4, 5.1.2, 5.04

Instructions:

include("extensions/GeshiCodeTag.php");
 * 1) Download Geshi, extract it and place the entire folder content under yourWikiSite/extensions/
 * 2) Copy the GeshiCodeTag Source below and save it as GeshiCodeTag.php (Note: Be sure to change the $languagesPath depending on the path of your Geshi extension)
 * 3) Place GeshiCodeTag.php to yourWikiSite/extensions/
 * 4) Add the include tag below prior to the variable $wgSiteName in yourWikiSite/LocalSettings.php
 * 1) GeshiCodeTag extension

'''That's it! Copy the "Tag Examples" below to see if it's working correctly'''

Usage
There are two code tags that you can use:


 * 1) Simple Tag Format:      <'languages'>source code here
 * 2) Advanced Tag Format:

Tag Examples

- simple code tag echo "Hello World";

- advanced code tag

- advanced code tag with line numbers

- default code tag

- display a list of supported languages

DEMO: https://www.cs.colostate.edu/wiki/Test_GeSHiCodeTag

ChangeLog

 * Added 'version' and 'description' in the extension details. (as suggested by Servel333 in the discussion) --Paul516 04:06, 24 May 2008 (UTC)
 * Added changes suggested by Jonyo in the Discussion. It allows GeshiCodeTag to be interleaved with a list. --Paul516 08:17, 9 May 2007 (UTC)
 * Add default language "text" to satisfy legacy wiki code with


 * with




 * MediaWiki version less than 1.5 will only work in Simple Mode since older versions don't accept arguments in tags
 * MediaWiki versions (1.5.3, 1.5.7, 1.8.3, 1.9.2, 1.12.0 and probably others) - the "div.php" lang definition errantly highlights the MediaWiki copyrightwarning system message and other text in &lt;div&gt;&lt;/div&gt; tags.
 * The easiest fix is to delete the div.php language module from the geshi installation folder, or to rename it e.g. to div.php_
 * Alternatively, the extension code can be modified by removing "div" from the list of languages used in "simple" mode. If you need to highlight "div" code you can use the "advanced" syntax

Discussion
Click here for any questions/comments/suggestions regarding GeSHiCodeTag