2007-04-03 22:34:07 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Syntax highlighting extension for MediaWiki 1.5 using GeSHi
|
|
|
|
* Copyright (C) 2005 Brion Vibber <brion@pobox.com>
|
|
|
|
* http://www.mediawiki.org/
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
2010-06-21 13:45:17 +00:00
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2007-04-03 22:34:07 +00:00
|
|
|
* http://www.gnu.org/copyleft/gpl.html
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2010-06-06 15:12:22 +00:00
|
|
|
* @file
|
|
|
|
* @ingroup Extensions
|
2007-04-03 22:34:07 +00:00
|
|
|
* @author Brion Vibber
|
|
|
|
*
|
|
|
|
* This extension wraps the GeSHi highlighter: http://qbnz.com/highlighter/
|
|
|
|
*
|
|
|
|
* Unlike the older GeSHi MediaWiki extension floating around, this makes
|
|
|
|
* use of the new extension parameter support in MediaWiki 1.5 so it only
|
|
|
|
* has to register one tag, <source>.
|
|
|
|
*
|
|
|
|
* A language is specified like: <source lang="c">void main() {}</source>
|
|
|
|
* If you forget, or give an unsupported value, the extension spits out
|
|
|
|
* some help text and a list of all supported languages.
|
|
|
|
*/
|
|
|
|
|
2010-08-09 06:56:38 +00:00
|
|
|
if( !defined( 'MEDIAWIKI' ) ) {
|
2007-04-03 22:34:07 +00:00
|
|
|
die();
|
2010-08-09 06:56:38 +00:00
|
|
|
}
|
2007-04-03 22:34:07 +00:00
|
|
|
|
2007-04-03 22:44:40 +00:00
|
|
|
$wgExtensionCredits['parserhook']['SyntaxHighlight_GeSHi'] = array(
|
2009-04-27 03:15:19 +00:00
|
|
|
'path' => __FILE__,
|
2008-02-06 23:37:30 +00:00
|
|
|
'name' => 'SyntaxHighlight',
|
2008-07-10 12:45:20 +00:00
|
|
|
'author' => array( 'Brion Vibber', 'Tim Starling', 'Rob Church', 'Niklas Laxström' ),
|
2008-02-06 23:37:30 +00:00
|
|
|
'descriptionmsg' => 'syntaxhighlight-desc',
|
2011-12-13 23:49:33 +00:00
|
|
|
'url' => 'https://www.mediawiki.org/wiki/Extension:SyntaxHighlight_GeSHi',
|
2007-04-03 22:34:07 +00:00
|
|
|
);
|
|
|
|
|
2009-05-17 15:21:37 +00:00
|
|
|
$wgSyntaxHighlightDefaultLang = null; //Change this in LocalSettings.php
|
2008-01-11 09:05:18 +00:00
|
|
|
$dir = dirname(__FILE__) . '/';
|
|
|
|
$wgExtensionMessagesFiles['SyntaxHighlight_GeSHi'] = $dir . 'SyntaxHighlight_GeSHi.i18n.php';
|
|
|
|
$wgAutoloadClasses['SyntaxHighlight_GeSHi'] = $dir . 'SyntaxHighlight_GeSHi.class.php';
|
2009-09-04 22:22:12 +00:00
|
|
|
$wgHooks['ParserFirstCallInit'][] = 'efSyntaxHighlight_GeSHiSetup';
|
2011-11-20 18:07:20 +00:00
|
|
|
$wgHooks['ExtensionTypes'][] = 'SyntaxHighlight_GeSHi::hSpecialVersion_GeSHi';
|
2007-04-03 22:34:07 +00:00
|
|
|
|
2013-03-05 20:00:27 +00:00
|
|
|
//if ( defined( 'MW_SUPPORTS_CONTENTHANDLER' ) ) {
|
2012-10-16 10:33:26 +00:00
|
|
|
// since MW 1.21
|
2013-03-05 20:00:27 +00:00
|
|
|
// $wgHooks['ContentGetParserOutput'][] = 'SyntaxHighlight_GeSHi::renderHook';
|
|
|
|
//} else {
|
2012-10-16 10:33:26 +00:00
|
|
|
// B/C until 1.20
|
|
|
|
$wgHooks['ShowRawCssJs'][] = 'SyntaxHighlight_GeSHi::viewHook';
|
2013-03-05 20:00:27 +00:00
|
|
|
//}
|
2012-10-16 10:33:26 +00:00
|
|
|
|
|
|
|
|
2011-11-20 18:07:20 +00:00
|
|
|
$wgAutoloadClasses['HighlightGeSHilocal'] = $dir . 'SyntaxHighlight_GeSHi.local.php';
|
|
|
|
$wgResourceModules['ext.geshi.local'] = array( 'class' => 'HighlightGeSHilocal' );
|
2010-08-09 06:25:28 +00:00
|
|
|
|
2012-10-16 10:33:26 +00:00
|
|
|
/**
|
|
|
|
* Map content models to the corresponding language names to be used with the highlighter.
|
|
|
|
* Pages with one of the given content models will automatically be highlighted.
|
|
|
|
*/
|
|
|
|
$wgSyntaxHighlightModels = array(
|
|
|
|
CONTENT_MODEL_CSS => 'css',
|
|
|
|
CONTENT_MODEL_JAVASCRIPT => 'javascript',
|
|
|
|
);
|
|
|
|
|
2007-04-03 22:34:07 +00:00
|
|
|
/**
|
2007-06-29 04:33:14 +00:00
|
|
|
* Register parser hook
|
2011-05-26 00:08:16 +00:00
|
|
|
*
|
|
|
|
* @param $parser Parser
|
2007-04-03 22:34:07 +00:00
|
|
|
*/
|
2009-09-04 01:05:04 +00:00
|
|
|
function efSyntaxHighlight_GeSHiSetup( &$parser ) {
|
|
|
|
$parser->setHook( 'source', array( 'SyntaxHighlight_GeSHi', 'parserHook' ) );
|
|
|
|
$parser->setHook( 'syntaxhighlight', array( 'SyntaxHighlight_GeSHi', 'parserHook' ) );
|
2008-05-25 21:09:41 +00:00
|
|
|
return true;
|
2008-01-11 09:05:18 +00:00
|
|
|
}
|