fix word boundary for not english parser functions (v 1.9.1)

Change-Id: I7399b7787cec57745a1cf7401d519f145e65845c
This commit is contained in:
Pavel Astakhov 2014-08-29 12:20:54 +06:00
parent cb05c04e85
commit 89e584b947
2 changed files with 8 additions and 5 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.9.0';
const EXT_CODEMIRROR_VERSION = '1.9.1';
// Register this extension on Special:Version
$wgExtensionCredits['parserhook'][] = array(

View file

@ -117,8 +117,11 @@ CodeMirror.defineMode('mediawiki', function( config/*, parserConfig */ ) {
return 'attribute';
}
if ( stream.peek() === '&' ) {
style = ['attribute', 'mw-underline'];
style = ['attribute', 'strong', 'mw-underline'];
mnemonicStyle = ['mw-underline'];
} else if ( stream.match( /[\s\u00a0]*&/ ) ) { // {{ PAGE & NAME }}
stream.backUp(1);
return 'attribute strong mw-underline';
}
break;
case 'TemplateArgument':
@ -155,7 +158,7 @@ CodeMirror.defineMode('mediawiki', function( config/*, parserConfig */ ) {
}
break;
case 'ParserFunctionName':
if ( stream.match( /#?\w+/ ) ) { // FIXME: {{#name}} and and {{uc}} are wrong, must have ':'
if ( stream.match( /#?[^\s\u00a0\}\[\]<\{\'\|\&\:]+/ ) ) { // FIXME: {{#name}} and and {{uc}} are wrong, must have ':'
return 'keyword strong';
}
if ( stream.eat( ':' ) ) {
@ -279,7 +282,7 @@ CodeMirror.defineMode('mediawiki', function( config/*, parserConfig */ ) {
return 'keyword';
}
// Check for parser function without '#'
var name = stream.match( /(\w+)(\:|[\s\u00a0]*)(\}\}?)?(.)?/ );
var name = stream.match( /([^\s\u00a0\}\[\]<\{\'\|\&\:]+)(\:|[\s\u00a0]*)(\}\}?)?(.)?/ );
if ( name ) {
stream.backUp( name[0].length );
if ( (name[2] === ':' || name[4] === undefined || name[3] === '}}') && (config.mwextFunctionSynonyms[0][name[1].toLowerCase()] || config.mwextFunctionSynonyms[1][name[1]]) ) {
@ -320,7 +323,7 @@ CodeMirror.defineMode('mediawiki', function( config/*, parserConfig */ ) {
}
break;
}
stream.eatWhile( /[^\s\u00a0>\}\[\]<\{\'\|\&]/ );
stream.eatWhile( /[^\s\u00a0>\}\[\]<\{\'\|\&\:]/ );
if ( state.isBold ) {
style.push( 'strong' );
}