fix template page name regex perfomance (v 2.1.4)

Change-Id: If66d3a7cdb38c4d650f003083a6dea67f4220997
This commit is contained in:
Pavel Astakhov 2014-09-11 16:30:49 +06:00
parent 16c83240fd
commit 73963bb7a5
3 changed files with 15 additions and 18 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 = '2.1.3';
const EXT_CODEMIRROR_VERSION = '2.1.4';
// Register this extension on Special:Version
$wgExtensionCredits['parserhook'][] = array(

View file

@ -19,8 +19,8 @@ pre.cm-mw-section-6 {font-weight: bold;}
.cm-mw-section-heading {color: #08f;}
.cm-mw-templatepage {color: #a11; font-weight: normal;}
.cm-mw-templatepage-name {color: #a11; font-weight: bold; text-decoration: underline;}
.cm-mw-templatepage-name-mnemonic {text-decoration: underline; font-weight: normal;}
.cm-mw-templatepage-name {color: #a11; font-weight: bold;}
.cm-mw-templatepage-name-mnemonic {font-weight: normal;}
.cm-mw-templatepage-argument-name {color: #a11; font-weight: bold;}
.cm-mw-templatepage-delimiter {color: #a11; font-weight: bold;}
.cm-mw-templatepage-bracket {color: #a11; font-weight: bold;}

View file

@ -1,12 +1,12 @@
/*global CodeMirror, define, require */
/* global CodeMirror */
(function( mod ) {
if ( typeof exports === 'object' && typeof module === 'object' ) { // CommonJS
mod( require( '../../lib/codemirror' ), require( '../htmlmixed/htmlmixed' ) );
} else if ( typeof define === 'function' && define.amd ) { // AMD
define( ['../../lib/codemirror', '../htmlmixed/htmlmixed'], mod );
} else { // Plain browser env
// if ( typeof exports === 'object' && typeof module === 'object' ) { // CommonJS
// mod( require( '../../lib/codemirror' ) );
// } else if ( typeof define === 'function' && define.amd ) { // AMD
// define( ['../../lib/codemirror'], mod );
// } else { // Plain browser env
mod( CodeMirror );
}
// }
})(function( CodeMirror ) {
'use strict';
@ -161,8 +161,8 @@ CodeMirror.defineMode('mediawiki', function( config/*, parserConfig */ ) {
}
return null;
case 'TemplatePageName':
if ( stream.match( /[\s\u00a0]*[^\s\u00a0\}\|<\{\&]/ ) ) {
return 'mw-templatepage-name';
if ( stream.match( /[\s\u00a0]*[^\s\u00a0\}\|<\{\&]+/ ) ) {
return 'mw-templatepage-name mw-underline';
}
if ( stream.eat( '|' ) ) {
state.ImInBlock.pop();
@ -176,11 +176,11 @@ CodeMirror.defineMode('mediawiki', function( config/*, parserConfig */ ) {
return 'mw-templatepage-bracket';
}
if ( stream.peek() === '&' ) {
style = ['mw-templatepage-name'];
mnemonicStyle = ['mw-templatepage-name-mnemonic'];
style = ['mw-templatepage-name', 'mw-underline'];
mnemonicStyle = ['mw-templatepage-name-mnemonic', 'mw-underline'];
} else if ( stream.match( /[\s\u00a0]*&/ ) ) { // {{ PAGE & NAME }}
stream.backUp(1);
return 'mw-templatepage-name';
return 'mw-templatepage-name mw-underline';
}
break;
case 'TemplateArgument':
@ -479,9 +479,6 @@ CodeMirror.defineMode('mediawiki', function( config/*, parserConfig */ ) {
if ( state.isItalic ) {
style.push( 'em' );
}
// if ( state.skipFormatting ) {
// style.push( 'mw-skipformatting' );
// }
}
if ( style.length > 0 ) {