-
Notifications
You must be signed in to change notification settings - Fork 0
/
SyntaxHighlight_GeSHi_ParserFunction.php
78 lines (58 loc) · 2.58 KB
/
SyntaxHighlight_GeSHi_ParserFunction.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<?php
/**
* This file contais the source code of SyntaxHighlight_Geshi_ParserFunction extension
* of MediaWiki. This code is released under the GNU General Public License.
*
* This source is highly based on SyntaxHighlight_Geshi extension, which works great, but
* as it was implemented to use tags, it was not able to be used with Semantic MediaWiki
* to output semantic properties as highlighted source code. That's why I created this
* extension as a parser function.
*
* Important: please note that this is a very simplifyed version of the original extension.
* At the moment it is only possible to specify the programming language and the source code.
*
* @author Matheus Garcia Barbosa de Figueiredo <[email protected]>
* @copyright Copyright 2005, Edmund Mielach
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
* @package MediaWikiExtensions
* @version 0.1
*/
/**
* Register the FileProtocolLinks extension with MediaWiki
*/
$wgExtensionFunctions[] = 'registerSourceHighlight';
$wgHooks['LanguageGetMagic'][] = 'registerSourceHighlight_Magic';
$wgSyntaxHighlightDefaultLang = null; //Change this in LocalSettings.php
$dir = dirname(__FILE__) . '/';
$wgExtensionMessagesFiles['SyntaxHighlight_GeSHi'] = $dir . 'SyntaxHighlight_GeSHi.i18n.php';
$wgAutoloadClasses['SyntaxHighlight_GeSHi'] = $dir . 'SyntaxHighlight_GeSHi.class.php';
$wgHooks['ShowRawCssJs'][] = 'SyntaxHighlight_GeSHi::viewHook';
$wgHooks['SpecialVersionExtensionTypes'][] = 'SyntaxHighlight_GeSHi::hSpecialVersion_GeSHi';
function registerSourceHighlight()
{
global $wgParser;
$wgParser->setFunctionHook( 'source', 'parserHookMGBF' );
$wgParser->setFunctionHook( 'syntaxhighlight', 'parserHookMGBF' );
return true;
}
function registerSourceHighlight_Magic( &$magicWords, $langCode ) {
$magicWords['source'] = array( 0, 'source' );
$magicWords['syntaxhighlight'] = array( 0, 'syntaxhighlight' );
return true;
}
function renderSourceHighlight(&$parser, $lang, $source)
{
return $source;
}
#credits for [[Special:Version]]
$wgExtensionCredits['parserhook'][] = array(
'name' => 'SourceHighlight_Geshi_ParserFunction',
'author' => 'Matheus Garcia Barbosa de Figueiredo',
'description' => 'Parser function extension to highlight source code',
'url' => 'http://www.mediawiki.org/wiki/Extension:SourceHighlight_Geshi_ParserFunction');
function parserHookMGBF( &$parser, $lang, $source) {
$args=array();
$args['lang']=$lang;
return SyntaxHighlight_GeSHi::parserHook( $source, $args, $parser );
}
?>