Extension:SyntaxHighlight

This extension adds the &lt;source&gt; tag to present formatted source code.

Installation

 * Step 1:

Download the extension files from the Subversion repository and save it into the extensions/SyntaxHighlight_GeSHi directory of your wiki. If you have shell access to your server, you may do the following to download the extension: cd extensions svn co http://svn.wikimedia.org/svnroot/mediawiki/trunk/extensions/SyntaxHighlight_GeSHi


 * Step 2:

(Recommended) Download 1.0.X stable release of Subversion repository in SourceForge.net: cd SyntaxHighlight_GeSHi svn co http://geshi.svn.sourceforge.net/svnroot/geshi/branches/RELEASE_1_0_X_STABLE/geshi-1.0.X/src/ geshi
 * 1) change to the directory of the SyntaxHighlight_GeSHi extension
 * 1) check out a current version of GeSHi into a directory called geshi

The geshi.php file can also be downloaded from GeSHi, and unzip it inside the extensions/SyntaxHighlight_GeSHi directory. (Note: the zip file creates a sub-directory called geshi/, and places the file geshi.php there - Also note that GeSHi 1.1.2alpha3 does not work with this extension!)

(Note: You need both - the mediawiki plugin files and the geshi files from sourceforge to make it work!)


 * Step 3.

Add this line to your LocalSettings.php:


 * step 4. (Optional)

If needed, change the following line in SyntaxHighlight_GeSHi.class.php to suit the path of your geshi.php file

Sometimes you'll need to add the absolute path to geshi (/var/www/html/.../geshi/geshi.php)

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

Parameters

 * lang: Defines the language
 * line: Corresponds to enable_line_numbers method on GeSHi
 * start: Corresponds to start_line_numbers_at method on GeSHi


 * enclose: 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.

Since r22246, you can override the colors using MediaWiki:Geshi.css.

C#
Results in:

PHP
Results in:

Python
Results in:

Fortran
bugs:
 * comments for fortran77 do not work (line starts with C)

Results in:

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