mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/CodeMirror
synced 2024-11-23 22:03:28 +00:00
add highlighting double underscore Magic words (v 1.12.0)
Change-Id: I4eceaa790ca053de49f5d0983bdd8ae288ba985f
This commit is contained in:
parent
b70b84a762
commit
30a3ae4319
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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' );
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue