Extension:SyntaxHighlighter
Jump to navigation
Jump to search
Not to be confused with Extension:SyntaxHighlight.
![]() | This extension is currently not actively maintained! Although it may still work, any bug reports or feature requests will more than likely be ignored. Please see the following alternatives that you may wish to install instead of this extension: |
SyntaxHighlighter Release status: unmaintained |
|
---|---|
![]() |
|
Implementation | Tag |
Description | Allows source code to be syntax highlighted using SyntaxHighlighter. |
Author(s) | Seong Jae Lee (seongjaeleetalk) |
Latest version | 1.2 (2012-09-01) |
MediaWiki | 1.18+ |
Database changes | No |
License | MIT License |
Download | GitHub: Note: README |
<source> |
|
The SyntaxHighlighter extension displays formatted source code with the <source>
tag using the SyntaxHighlighter JavaScript library.
Usage[edit]
On a wiki page, you can now use "source" elements:
<source lang="javascript" line start="2" highlight="4-6"> // 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 above code produces the following result on the page:
// 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;
}
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]
- Download and place the file(s) in a directory called
SyntaxHighlighter
in yourextensions/
folder. - Add the following code at the bottom of your LocalSettings.php:
require_once "$IP/extensions/SyntaxHighlighter/SyntaxHighlighter.php";
Done – Navigate to Special:Version on your wiki to verify that the extension is successfully installed.
Supported lexers[edit]
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