Extension:SyntaxHighlight GeSHi ParserFunction
SyntaxHighlight_GeSHi_ParserFunction Release status: stable |
|||
---|---|---|---|
Implementation | Parser function | ||
Description | Allows to render highlighted source code | ||
Author(s) | Matheus Garcia (Mgbftalk) | ||
Latest version | 0.1 (2010-01-05) | ||
MediaWiki | 1.15+ | ||
License | GPL | ||
Download |
GitHub: Note: README |
||
|
|||
Translate the SyntaxHighlight GeSHi ParserFunction extension if it is available at translatewiki.net |
|||
Check usage and version matrix; code metrics |
The SyntaxHighlight GeSHi ParserFunction extension is based on Extension:SyntaxHighlight_GeSHi, but implemented using parser functions instead of tags. Please note that actually it is a very simplified version of the original extension.
I´ve created it because tag-based extensions seems to not be easily integrated with Semantic MediaWiki, and I needed to use this extension to output value of highlighted source.
Please note that tag-based extensions can be called as parser functions using the workaround described here. This enables Extension:SyntaxHighlight_GeSHi to work without problem with Semantic MediaWiki, and makes this extension unnecessary.
Example[edit | edit source]
To use this extension you need to use the source parser function, which receives two parameters: the first one is the programming language, and the second is the source code.
For example, the following code
{{#source: java | class Whatever { public static void main() { int a = 0; while( a < 10 ) { System.out.println(a); } } } }}
would be rendered as
class Whatever { public static void main() { int a = 0; while( a < 10 ) { System.out.println(a); } } }
Note you can use this to output semantic properties. If you have, for example, a property javasourcecode defined in a template, it can be rendered as a java source code in any pages that use it if template code includes the following:
{{#source: java | {{{javasourcecode}}} }} [[javasourcecode::{{{javasourcecode}}}| ]]
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/mgbf/SyntaxHighlight_Geshi_ParserFunction.git
That would create directory SyntaxHighlight_Geshi_ParserFunction/, which contains the needed files, right under extensions/.
After that you just need to include the following line in LocalSettings.php:
require_once("$IP/extensions/SyntaxHighlight_Geshi_ParserFunction/SyntaxHighlight_GeSHi_ParserFunction.php");
See also[edit | edit source]
Language: | English • русский |
---|