From 73963bb7a59ca1c5591849653c75e40246990a42 Mon Sep 17 00:00:00 2001 From: Pavel Astakhov Date: Thu, 11 Sep 2014 16:30:49 +0600 Subject: [PATCH] fix template page name regex perfomance (v 2.1.4) Change-Id: If66d3a7cdb38c4d650f003083a6dea67f4220997 --- CodeMirror.php | 2 +- resources/mode/mediawiki/mediawiki.css | 4 ++-- resources/mode/mediawiki/mediawiki.js | 27 ++++++++++++-------------- 3 files changed, 15 insertions(+), 18 deletions(-) diff --git a/CodeMirror.php b/CodeMirror.php index 347facb1..ef05286e 100644 --- a/CodeMirror.php +++ b/CodeMirror.php @@ -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( diff --git a/resources/mode/mediawiki/mediawiki.css b/resources/mode/mediawiki/mediawiki.css index 590510a1..537b481c 100644 --- a/resources/mode/mediawiki/mediawiki.css +++ b/resources/mode/mediawiki/mediawiki.css @@ -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;} diff --git a/resources/mode/mediawiki/mediawiki.js b/resources/mode/mediawiki/mediawiki.js index f3cbae01..3195a537 100644 --- a/resources/mode/mediawiki/mediawiki.js +++ b/resources/mode/mediawiki/mediawiki.js @@ -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 ) {