-
Notifications
You must be signed in to change notification settings - Fork 1
/
SyntaxHighlight.php
50 lines (43 loc) · 2.04 KB
/
SyntaxHighlight.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
<?php
if (!defined('MEDIAWIKI')) {
die();
}
// Default options
if ( ! isset($wgSyntaxHighlightStyle) ) {
$wgSyntaxHighlightStyle = 'default';
}
$wgSyntaxHighlightCommonLanguages = array( 'apache', 'nginx', 'java', 'cs', 'cpp', 'objectivec', 'ini', 'diff', 'bash', 'makefile', 'sql', 'php', 'ruby', 'python', 'perl', 'css', 'xml', 'javascript', 'coffeescript', 'http', 'json', 'markdown' );
// Extention Credits
$wgExtensionCredits['parserhook'][] = array(
'path' => __FILE__,
'name' => 'SyntaxHighlight',
'author' => 'Artem Klevtsov',
'url' => 'https://github.com/unikum/MediaWiki-SyntaxHighlight',
'version' => '0.1',
'descriptionmsg' => 'syntaxhighlight-desc'
);
// Define localisation and body files
$wgAutoloadClasses['SyntaxHighlight'] = dirname( __FILE__ ).'/SyntaxHighlight.body.php';
$wgExtensionMessagesFiles['SyntaxHighlight'] = dirname( __FILE__ ).'/SyntaxHighlight.i18n.php';
$wgMessageDirs['SyntaxHighlight'] = dirname( __FILE__ ).'/i18n';
// Register hooks
$wgHooks['ParserFirstCallInit'][] = 'SyntaxHighlight::wfSyntaxHighlight_Setup';
$wgHooks['BeforePageDisplay'][] = 'SyntaxHighlight::onBeforePageDisplay';
// ResourceLoader modules
$wgResourceModules['ext.SyntaxHighlight'] = array(
'localBasePath' => dirname(__FILE__),
'remoteExtPath' => 'SyntaxHighlight',
'styles' => array('highlight.js/styles/'.$wgSyntaxHighlightStyle.'.min.css', 'ext.SyntaxHighlight.css'),
'scripts' => array('highlight.js/highlight.min.js', 'ext.SyntaxHighlight.js')
);
// Add additional languages
if ( isset($wgSyntaxHighlightAdditionalLanguages) ) {
if ( ! is_array($wgSyntaxHighlightAdditionalLanguages) ) {
$wgSyntaxHighlightAdditionalLanguages = array($wgSyntaxHighlightAdditionalLanguages);
}
foreach( $wgSyntaxHighlightAdditionalLanguages as $language ) {
if ( ! in_array($language, $wgSyntaxHighlightCommonLanguages) && file_exists(dirname(__FILE__).'/highlight.js/languages/'.$language.'.min.js') ) {
$wgResourceModules['ext.SyntaxHighlight']['scripts'][] = 'highlight.js/languages/'.$language.'.min.js';
}
}
}