Extension:SyntaxHighlight

This extension adds the source tag to present formatted source code.

Restrictions of the pre tag
The pre tag is useful to present pre-formatted text. But since MediaWiki will pass the tag contents without escaping it first, HTML codes will be interpreted and not shown as is. For instance:

forcedSpace = "&amp;nbsp;";

will be shown as: forcedSpace= " ";

Installation
Download the extension from the Subversion repository and save it into the extensions\SyntaxHighlight_GeSHi of your wiki.

Download the latest stable build of GeSHi, and unzip it inside the extensions\SyntaxHighlight_GeSHi directory. (Note: the zip file creates a sub-directory called geshi/, and places a file geshi.php there)

Add this line to your LocalSettings.php:

require_once("extensions/SyntaxHighlight_GeSHi/SyntaxHighlight.php");

If needed, change the following line on SyntaxHighlight.php to suit the path of your geshi.php file require_once( 'geshi/geshi.php' );

Usage
On the wiki page, you can now use "source" elements:

C# Example
Results in:



PHP Example
Results in:



Parameters

 * lang: Defines the language
 * line: Corresponds to enable_line_numbers method on GeSHi
 * start: Corresponds to start_line_numbers_at method on GeSHi
 * case: Corresponds to set_case_keywords method on GeSHi
 * tab: Corresponds to set_tab_width method on GeSHi
 * header: Corresponds to set_header_type method on GeSHi
 * strict: Corresponds to enable_strict_mode method on GeSHi

The effect and usage of these parameters can be consulted in GeSHi's documentation.

Supported languages
These are the languages known by GeSHi that can be used in the lang parameter: