Extension:SyntaxHighlighter
SyntaxHighlighter Release status: beta |
|||
---|---|---|---|
![]() |
|||
Implementation | Tag | ||
Description | Allows source code to be syntax highlighted using SyntaxHighlighter. | ||
Author(s) | Seong Jae Lee (seongjaeleetalk) | ||
Latest version | 1.0 (2012-09-01) | ||
MediaWiki | 1.18+ | ||
Database changes | No | ||
License | MIT | ||
Download | Project page Git [Help] |
||
|
|||
|
|||
Translate the SyntaxHighlighter extension if possible |
|||
Check usage and version matrix; code metrics |
The SyntaxHighlighter extension displays formatted source code with the <source>
tag using the SyntaxHighlighter JavaScript library.
Usage[edit | edit source]
On a wiki page, you can now use "source" elements:
<source lang="javascript" collapse="true" first-line="2"> // SyntaxHighlighter makes your code snippets beautiful without tiring your servers. // http://alexgorbatchev.com var setArray = function(elems) { this.length = 0; push.apply(this, elems); return this; } </source>
The lang parameter specifies which language you are using. For more information, please refer to the README.md file. To see how the source codes are rendered, please refer to the sample page.
Installation[edit | edit source]
The source code is hosted on Github and versioned using the Git tool (not SVN). 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.
Supporting languages[edit | edit source]
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
See also[edit | edit source]
- 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.