mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/SyntaxHighlight_GeSHi
synced 2024-11-15 02:24:07 +00:00
Add optional $wgSyntaxHighlightDefaultLang parameter; allows people to set a default language that shows up if the lang parameter is missing.
This commit is contained in:
parent
32c8d4d479
commit
72521f6b30
|
@ -21,6 +21,7 @@ class SyntaxHighlight_GeSHi {
|
|||
* @return string
|
||||
*/
|
||||
public static function parserHook( $text, $args = array(), $parser ) {
|
||||
global $wgSyntaxHighlightDefaultLang;
|
||||
self::initialise();
|
||||
$text = rtrim( $text );
|
||||
// Don't trim leading spaces away, just the linefeeds
|
||||
|
@ -29,7 +30,12 @@ class SyntaxHighlight_GeSHi {
|
|||
if( isset( $args['lang'] ) ) {
|
||||
$lang = strtolower( $args['lang'] );
|
||||
} else {
|
||||
return self::formatError( htmlspecialchars( wfMsgForContent( 'syntaxhighlight-err-language' ) ) );
|
||||
// language is not specified. Check if default exists, if yes, use it.
|
||||
if ( !is_null($wgSyntaxHighlightDefaultLang) ) {
|
||||
$lang = strtolower($wgSyntaxHighlightDefaultLang);
|
||||
} else {
|
||||
return self::formatError( htmlspecialchars( wfMsgForContent( 'syntaxhighlight-err-language' ) ) );
|
||||
}
|
||||
}
|
||||
if( !preg_match( '/^[a-z_0-9-]*$/', $lang ) )
|
||||
return self::formatError( htmlspecialchars( wfMsgForContent( 'syntaxhighlight-err-language' ) ) );
|
||||
|
|
|
@ -50,6 +50,7 @@ $wgExtensionCredits['parserhook']['SyntaxHighlight_GeSHi'] = array(
|
|||
'url' => 'http://www.mediawiki.org/wiki/Extension:SyntaxHighlight_GeSHi',
|
||||
);
|
||||
|
||||
$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';
|
||||
|
|
Loading…
Reference in a new issue