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!) Compatibility note: This extension was tested on Media Wiki version 1.13.2 (and 1.14.0) and there were incompatibility problems with the edit screen interface which can easily be fixed with a few minor changes. In the GeshiCodeTag.php file, change the top couple of lines to the following: <?php // change directory accordingly include_once('geshi/geshi.php'); $languagesPath = "extensions/geshi/geshi"; // 1 - ENABLED, 0 - DISABLED // below line must be set to 0 for MediaWiki version 1.13.2 (and 1.14.0) $codeTag["simple"] = 0;                      // ex. echo $codeTag["advanced"]["mode"] = 1;            // ex.
 * MediaWiki 1.19.2, 1.17.0, 1.16.0, 1.15.3, 1.15.0, 1.14.0 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.8, 1.5.7, 1.5.3 (but see Issues below)
 * GeSHi 1.0.8.4, 1.0.8.3, 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.3.9, 5.3.3, 5.3.2, 5.2.5, 5.2.4, 5.2.1, 5.1.4, 5.1.2, 5.04 (for php5.3 see Issues below or Discussion)
 * 1) GeshiCodeTag.php
 * 2) Licensed under GPLv3
 * 3) by Paul Nolasco
 * 1) by Paul Nolasco

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, 1.16.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
Talk:GeSHiCodeTag for any questions/comments/suggestions regarding GeSHiCodeTag