mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/CodeMirror
synced 2024-11-23 22:03:28 +00:00
Merge "add highlighting template variables (v 1.8.0)"
This commit is contained in:
commit
8ebd9d3f36
|
@ -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.7.4';
|
||||
const EXT_CODEMIRROR_VERSION = '1.8.0';
|
||||
|
||||
// Register this extension on Special:Version
|
||||
$wgExtensionCredits['parserhook'][] = array(
|
||||
|
|
|
@ -155,6 +155,21 @@ CodeMirror.defineMode('mediawiki', function( /*config, parserConfig*/ ) {
|
|||
}
|
||||
style.push( 'string' );
|
||||
break;
|
||||
case 'TemplateVariable':
|
||||
if ( stream.eatWhile( /[^\}\&]/ ) ) {
|
||||
return 'variable-2';
|
||||
}
|
||||
if ( stream.match( '}}}' ) ) {
|
||||
state.ImInBlock.pop();
|
||||
return 'variable-2';
|
||||
}
|
||||
if ( stream.peek() === '&' ) {
|
||||
style = ['variable-2'];
|
||||
} else {
|
||||
stream.next();
|
||||
return 'variable-2';
|
||||
}
|
||||
break;
|
||||
case 'ParserFunctionName':
|
||||
if ( stream.eatWhile( /\w/ ) ) {
|
||||
return 'keyword strong';
|
||||
|
@ -267,7 +282,11 @@ CodeMirror.defineMode('mediawiki', function( /*config, parserConfig*/ ) {
|
|||
state.bTempArgName = false;
|
||||
switch ( ch ) {
|
||||
case '{':
|
||||
if ( stream.eat( '{' ) ) { // Templates
|
||||
if ( stream.match( '{{' ) ) { // Variable
|
||||
stream.eatSpace();
|
||||
state.ImInBlock.push( 'TemplateVariable' );
|
||||
return 'variable-2';
|
||||
} else if ( stream.eat( '{' ) ) { // Templates
|
||||
stream.eatSpace();
|
||||
state.ImInBlock.push( 'TemplatePageName' );
|
||||
return 'tag bracket';
|
||||
|
|
Loading…
Reference in a new issue