mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/CodeMirror
synced 2024-11-15 02:04:02 +00:00
Add highlighting of double underscore Magic Words as __TOC__
For testing: __NOTOC__ ___NOTOC___ ____NOTOC____ _____NOTOC_____ ______NO!TOC__NOTOC____ ______NO{{TOC}}_____ ______NO[[TOC]]_____ ______NO'''TOC'''_____ __nOtOc__ FFFFF___NOtoc______ '''____________NOTOC______''' __TOC___TOC__ __TOC____TOC__ ___TOC_____TOC___ __TOC___TOC__ ___NOTOC___ ____NOTOC____ _____NOTOC_____ ______NO!TOC__NOTOC____ ______NO{{TOC}}_____ ______NO[[TOC]]_____ ______NO'''TOC'''_____ __nOtOc__ FFFFF___NOtoc______ {{__TOC__|__TOC__}} Wrong, but not a big problem: [[__TOC__|__TOC__]] Bug: T170041 Change-Id: I0b2cfd02550c2685d241bdf3596507c5972878d5
This commit is contained in:
parent
d8d273b4af
commit
cd4bdebe8b
|
@ -8,7 +8,7 @@
|
||||||
|
|
||||||
.cm-mw-skipformatting { background-color: #adf; }
|
.cm-mw-skipformatting { background-color: #adf; }
|
||||||
.cm-mw-list { color: #08f; font-weight: bold; }
|
.cm-mw-list { color: #08f; font-weight: bold; }
|
||||||
.cm-mw-signature, .cm-mw-hr { color: #08f; font-weight: bold; background-color: #eee; }
|
.cm-mw-doubleUnderscore, .cm-mw-signature, .cm-mw-hr { color: #08f; font-weight: bold; background-color: #eee; }
|
||||||
.cm-mw-indenting { color: #08f; font-weight: bold; }
|
.cm-mw-indenting { color: #08f; font-weight: bold; }
|
||||||
.cm-mw-mnemonic { color: #290; }
|
.cm-mw-mnemonic { color: #290; }
|
||||||
.cm-mw-comment { color: #aaa; font-weight: normal; }
|
.cm-mw-comment { color: #aaa; font-weight: normal; }
|
||||||
|
|
|
@ -807,6 +807,29 @@
|
||||||
return 'mw-signature';
|
return 'mw-signature';
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case '_': // Maybe double undescored Magic Word as __TOC__
|
||||||
|
tmp = 1;
|
||||||
|
while ( stream.eat( '_' ) ) { // Optimize processing of many underscore symbols
|
||||||
|
tmp++;
|
||||||
|
}
|
||||||
|
if ( tmp > 2 ) { // Many underscore symbols
|
||||||
|
if ( !stream.eol() ) {
|
||||||
|
stream.backUp( 2 ); // Leave last two underscore symbols for processing again in next iteration
|
||||||
|
}
|
||||||
|
return makeStyle( style, state ); // Optimization: skip regex function at the end for EOL and backuped symbols
|
||||||
|
} else if ( tmp === 2 ) { // Check on double underscore Magic Word
|
||||||
|
name = stream.match( /([^\s\u00a0>}[\]<{'|&:~]+?)__/ ); // The same as the end of function except '_' inside and with '__' at the end of string
|
||||||
|
if ( name && name[ 0 ] ) {
|
||||||
|
if ( '__' + name[ 0 ].toLowerCase() in mwConfig.doubleUnderscore[ 0 ] || '__' + name[ 0 ] in mwConfig.doubleUnderscore[ 1 ] ) {
|
||||||
|
return 'mw-doubleUnderscore';
|
||||||
|
}
|
||||||
|
if ( !stream.eol() ) {
|
||||||
|
stream.backUp( 2 ); // Two underscore symbols at the end can be begining of other double undescored Magic Word
|
||||||
|
}
|
||||||
|
return makeStyle( style, state ); // Optimization: skip regex function at the end for EOL and backuped symbols
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
if ( /[\s\u00a0]/.test( ch ) ) {
|
if ( /[\s\u00a0]/.test( ch ) ) {
|
||||||
stream.eatSpace();
|
stream.eatSpace();
|
||||||
|
|
Loading…
Reference in a new issue