Extension:SyntaxHighlighter
|
SyntaxHighlighter Release status: beta |
|||
|---|---|---|---|
| Implementation | Tag | ||
| Description | Allows source code to be syntax highlighted using SyntaxHighlighter. | ||
| Author(s) | Seong Jae Lee (seongjaeleeTalk) | ||
| Last version | 1.0 (2012-1-12) | ||
| MediaWiki | 1.18.0 | ||
| License | MIT | ||
| Download | Project page |
||
|
|||
|
|||
|
Check usage (experimental) |
|||
SyntaxHighlighter displays formatted source code with the <source> tag using the SyntaxHighlighter JavaScript library.
Contents |
[edit] Usage
On a wiki page, you can now use "source" elements:
<source lang="php" collapse="true" first-line="2">
<?php
$v = "string"; // sample initialization
?>
html text
</source>
The lang parameter specifies which language you are using. The list of supporting languages are shown below. The parameters such as collapse and first-line are passed into SyntaxHighlighter parameters. To see all the parameters, please refer to the SyntaxHighlighter configuration page. To see how the source codes are rendered, please refer to the sample page.
[edit] Installation
The source code is hosted on github and versioned using the git tool (not SVN, like most of the extensions). So, you'll need git to download or update the sources. Once git is installed, you can download the extension issuing the following command in the extensions/ directory:
git clone git://github.com/seongjaelee/SyntaxHighlighter.git
That would create directory SyntaxHighlighter/, which contains the needed files, right under extensions/.
If you don't want to be bothered, you can just download the zip file from the following address:
https://github.com/seongjaelee/SyntaxHighlighter/zipball/master
Unzip the downloaded file in the extensions/ directory, and change the name of directory to SyntaxHighlighter/.
Finally, add the following to LocalSettings.php:
require_once("$IP/extensions/SyntaxHighlighter/SyntaxHighlighter.php");
Many other syntax highlighting extensions also share source tag, so if you already use one, uncomment it from LocalSettings.php file.
[edit] Supporting Languages
Some of the supported languages and corresponding lang parameters are shown below. For the full list, please refer to the SyntaxHighlighter site.
- C++ : cpp, c
- C# : csharp, c-sharp
- CSS : css
- PHP : php
- XML : xml, html, xhtml
- Python : python, py
- Java : java
- JavaScript : jscript, js, javascript
[edit] See also
- Extension:ASHighlight - (MediaWiki support for Andre Simon's highlight utility)
- Extension:Geshi - includes every component - no additional downloads
- Extension:Include - yet another source code syntax highlighter
- Extension:SyntaxHighlight_GeSHi_ParserFunction - Parser function based alternative, can be used with Semantic MediaWiki
- Extension:GoogleCodePrettify - syntax highlighter that uses Google Code Prettify library.