Minor optimizations to some patterns in mediawiki mode

Note that this .match() method is not the one you think it is.
This is StringStream.match() from the CodeMirror lib, not ES
String.match().

Change-Id: Ief5048ff78bcd035482e7a68044e24592d28cb6c
This commit is contained in:
Thiemo Kreuz 2021-01-13 16:56:59 +01:00
parent 58e17dc734
commit 7404a9f2a0

View file

@ -606,12 +606,12 @@
// @todo error message
} else if ( stream.match( /^[^\s\u00a0{[\]<>~).,']*/ ) ) {
if ( stream.peek() === '~' ) {
if ( !stream.match( /^~{3,}/, false ) ) {
if ( !stream.match( /^~~~+/, false ) ) {
stream.match( /^~*/ );
return makeLocalStyle( 'mw-free-extlink', state );
}
} else if ( stream.peek() === '{' ) {
if ( !stream.match( /^\{\{/, false ) ) {
if ( !stream.match( '{{', false ) ) {
stream.next();
return makeLocalStyle( 'mw-free-extlink', state );
}
@ -648,7 +648,7 @@
ch = stream.next();
switch ( ch ) {
case '-':
if ( stream.match( /^----*/ ) ) {
if ( stream.match( /^---+/ ) ) {
return 'mw-hr';
}
break;
@ -663,19 +663,17 @@
break;
case '*':
case '#':
if ( stream.match( /^[*#]*:*/ ) ) {
return 'mw-list';
}
break;
// Just consume all nested list and indention syntax when there is more
stream.match( /^[*#]*:*/ );
return 'mw-list';
case ':':
if ( stream.match( /^:*{\|/, false ) ) { // Highlight indented tables :{|, bug T108454
state.stack.push( state.tokenize );
state.tokenize = eatStartTable;
}
if ( stream.match( /^:*[*#]*/ ) ) {
return 'mw-indenting';
}
break;
// Just consume all nested list and indention syntax when there is more
stream.match( /^:*[*#]*/ );
return 'mw-indenting';
case ' ':
if ( stream.match( /^[\s\u00a0]*:*{\|/, false ) ) { // Leading spaces is the correct syntax for a table, bug T108454
stream.eatSpace();