Extension:SyntaxHighlight

The SyntaxHighlight GeSHi extension provides rich formatting of source code using the   tag. It is powered by the Pygments library and supports hundreds of different programming language and file format.

Like the  tag and   tags, the text is rendered exactly as it was typed, preserving any white space.

Usage
Once installed, you can use "syntaxhighlight" tags on wiki pages:

This is the result of the following markup:

In older versions (before MediaWiki 1.16), the extension used the tag. This is still supported, but  may help avoid conflicts if your source code itself contains   tags (for example XML).

lang
The  attribute defines what lexer should be used. This affects how the extension highlights the source code. See the section Supported languages in this page for details of supported languages.

line
The  attribute enables line numbers.

start
The  attribute (in combination with  ) defines the first line number of the code block. For example,  will make line numbering start at 55.

highlight
The  attribute specifies one or more lines that should be marked (by highlighting those lines with a different background color). You can specify multiple line number by separating them with commas (for example, ).

inline
The  attribute indicates that the source code should be inline as part of a paragraph (as opposed to being its own block). For backwards-compatibility, the  attibutes is also supported and results in the same behaviour.

For example,  is a lambda expression in Python.

Supported languages
The Pygments library provides support for hundreds of computer languages and file formats (full list).

Below is the full list of languages that Pygments can highlight.

Configuration

 * (optional): The extension bundles the Pygments package, but you can point to a different version.
 * : Configure the default lexer for some wiki pages. By default this will highlight javascript and css pages. Additional content models can be configured by extensions (e.g. Lua, JSON, ..).

VisualEditor integration
The plugin enables direct editing with VisualEditor. A popup is opened when a user wants to edit  or   sections. For this to work, VisualEditor must be installed and configured from the latest git version, same for Parsoid. The feature randomly does not work with older Parsoid versions.