Merge "add highlighting template variables (v 1.8.0)"

This commit is contained in:
jenkins-bot 2014-08-28 09:47:50 +00:00 committed by Gerrit Code Review
commit 8ebd9d3f36
2 changed files with 21 additions and 2 deletions

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.7.4';
const EXT_CODEMIRROR_VERSION = '1.8.0';
// Register this extension on Special:Version
$wgExtensionCredits['parserhook'][] = array(

View file

@ -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';