add highlighting double underscore Magic words (v 1.12.0)

Change-Id: I4eceaa790ca053de49f5d0983bdd8ae288ba985f
This commit is contained in:
Pavel Astakhov 2014-09-04 10:23:05 +06:00
parent b70b84a762
commit 30a3ae4319
4 changed files with 25 additions and 2 deletions

View file

@ -22,6 +22,18 @@ class CodeMirrorHooks {
self::$globalVariableScript['Tags'] = $wgParser->getTags();
$mw = $wgContLang->getMagicWords();
self::$globalVariableScript['DoubleUnderscore'] = array( array(), array() );
foreach ( MagicWord::getDoubleUnderscoreArray()->names as $name ) {
if ( isset( $mw[$name] ) ) {
$caseSensitive = array_shift( $mw[$name] ) == 0 ? 0 : 1;
foreach ( $mw[$name] as $n ) {
self::$globalVariableScript['DoubleUnderscore'][$caseSensitive][ $caseSensitive ? $n : $wgContLang->lc( $n ) ] = $name;
}
} else {
self::$globalVariableScript['DoubleUnderscore'][0][] = $name;
}
}
self::$globalVariableScript['FunctionSynonyms'] = $wgParser->mFunctionSynonyms;
foreach ( MagicWord::getVariableIDs() as $name ) {
if ( isset( $mw[$name] ) ) {
@ -32,6 +44,7 @@ class CodeMirrorHooks {
}
}
// self::$globalVariableScript['LinkTrailCharacters'] = $wgContLang->linkTrail();
$output->addModules( 'ext.CodeMirror' );
return true;
}

View file

@ -15,7 +15,7 @@ if ( !defined( 'MEDIAWIKI' ) ) {
die( 'This file is an extension to MediaWiki and thus not a valid entry point.' );
}
const EXT_CODEMIRROR_VERSION = '1.11.2';
const EXT_CODEMIRROR_VERSION = '1.12.0';
// Register this extension on Special:Version
$wgExtensionCredits['parserhook'][] = array(

View file

@ -4,6 +4,7 @@ jQuery( document ).ready( function ( $ ) {
var codeMirror = CodeMirror.fromTextArea( textbox1[0], {
mwextFunctionSynonyms: mw.config.get( 'extCodeMirrorFunctionSynonyms' ),
mwextTags: mw.config.get( 'extCodeMirrorTags' ),
mwextDoubleUnderscore: mw.config.get( 'extCodeMirrorDoubleUnderscore' ),
styleActiveLine: true,
//lineNumbers: true,
lineWrapping: true,

View file

@ -361,8 +361,17 @@ CodeMirror.defineMode('mediawiki', function( config/*, parserConfig */ ) {
}
}
break;
case '_':
name = stream.match( /_[^\s\u00a0_>\}\[\]<\{\'\|\&\:]*__/ );
if ( name ) {
name = '_' + name[0];
if ( config.mwextDoubleUnderscore[0][name.toLowerCase()] || config.mwextDoubleUnderscore[1][name] ) {
return 'keyword strong';
}
}
break;
}
stream.eatWhile( /[^\s\u00a0>\}\[\]<\{\'\|\&\:]/ );
stream.eatWhile( /[^\s\u00a0_>\}\[\]<\{\'\|\&\:]/ );
if ( state.isBold ) {
style.push( 'strong' );
}