@bhsd/codemirror-mediawiki 2.1.10 → 2.1.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/mediawiki.css CHANGED
@@ -161,85 +161,85 @@
161
161
  /* backgrounds */
162
162
  .cm-mw-tag-pre,
163
163
  .cm-mw-tag-nowiki {
164
- background-color: rgba( 0, 0, 0, 0.04 );
164
+ background-color: rgba(0, 0, 0, .04);
165
165
  }
166
166
  .cm-mw-template-ground {
167
- background-color: rgba( 170, 17, 17, 0.04 );
167
+ background-color: rgba(170, 17, 17, .04);
168
168
  }
169
169
  .cm-mw-template2-ground {
170
- background-color: rgba( 170, 17, 17, 0.08 );
170
+ background-color: rgba(170, 17, 17, .08);
171
171
  }
172
172
  .cm-mw-template3-ground {
173
- background-color: rgba( 170, 17, 17, 0.12 );
173
+ background-color: rgba(170, 17, 17, .12);
174
174
  }
175
175
  .cm-mw-template-ext-ground,
176
176
  .cm-mw-ext-ground,
177
177
  .cm-mw-exttag {
178
- background-color: rgba( 119, 0, 170, 0.04 );
178
+ background-color: rgba(119, 0, 170, .04);
179
179
  }
180
180
  .cm-mw-template-ext2-ground,
181
181
  .cm-mw-ext2-ground {
182
- background-color: rgba( 119, 0, 170, 0.08 );
182
+ background-color: rgba(119, 0, 170, .08);
183
183
  }
184
184
  .cm-mw-template-ext3-ground,
185
185
  .cm-mw-ext3-ground {
186
- background-color: rgba( 119, 0, 170, 0.12 );
186
+ background-color: rgba(119, 0, 170, .12);
187
187
  }
188
188
  .cm-mw-template-link-ground,
189
189
  .cm-mw-ext-link-ground,
190
190
  .cm-mw-link-ground {
191
- background-color: rgba( 34, 17, 153, 0.04 );
191
+ background-color: rgba(34, 17, 153, .04);
192
192
  }
193
193
  .cm-mw-template-ext-link-ground,
194
194
  .cm-mw-ext2-link-ground {
195
- background-color: rgba( 77, 9, 162, 0.08 );
195
+ background-color: rgba(77, 9, 162, .08);
196
196
  }
197
197
  .cm-mw-template-ext2-link-ground,
198
198
  .cm-mw-ext3-link-ground {
199
- background-color: rgba( 91, 6, 164, 0.12 );
199
+ background-color: rgba(91, 6, 164, .12);
200
200
  }
201
201
  .cm-mw-template-ext3-link-ground {
202
- background-color: rgba( 98, 4, 166, 0.16 );
202
+ background-color: rgba(98, 4, 166, .16);
203
203
  }
204
204
  .cm-mw-template2-ext-ground {
205
- background-color: rgba( 145, 9, 94, 0.08 );
205
+ background-color: rgba(145, 9, 94, .08);
206
206
  }
207
207
  .cm-mw-template2-ext2-ground {
208
- background-color: rgba( 136, 6, 119, 0.12 );
208
+ background-color: rgba(136, 6, 119, .12);
209
209
  }
210
210
  .cm-mw-template2-ext3-ground {
211
- background-color: rgba( 132, 4, 132, 0.16 );
211
+ background-color: rgba(132, 4, 132, .16);
212
212
  }
213
213
  .cm-mw-template2-link-ground {
214
- background-color: rgba( 102, 17, 85, 0.08 );
214
+ background-color: rgba(102, 17, 85, .08);
215
215
  }
216
216
  .cm-mw-template2-ext-link-ground {
217
- background-color: rgba( 108, 11, 113, 0.12 );
217
+ background-color: rgba(108, 11, 113, .12);
218
218
  }
219
219
  .cm-mw-template2-ext2-link-ground {
220
- background-color: rgba( 111, 9, 128, 0.16 );
220
+ background-color: rgba(111, 9, 128, .16);
221
221
  }
222
222
  .cm-mw-template2-ext3-link-ground {
223
- background-color: rgba( 112, 7, 136, 0.2 );
223
+ background-color: rgba(112, 7, 136, .2);
224
224
  }
225
225
  .cm-mw-template3-ext-ground {
226
- background-color: rgba( 153, 11, 68, 0.12 );
226
+ background-color: rgba(153, 11, 68, .12);
227
227
  }
228
228
  .cm-mw-template3-ext2-ground {
229
- background-color: rgba( 145, 9, 94, 0.16 );
229
+ background-color: rgba(145, 9, 94, .16);
230
230
  }
231
231
  .cm-mw-template3-ext3-ground {
232
- background-color: rgba( 139, 7, 109, 0.2 );
232
+ background-color: rgba(139, 7, 109, .2);
233
233
  }
234
234
  .cm-mw-template3-link-ground {
235
- background-color: rgba( 125, 17, 62, 0.12 );
235
+ background-color: rgba(125, 17, 62, .12);
236
236
  }
237
237
  .cm-mw-template3-ext-link-ground {
238
- background-color: rgba( 123, 13, 89, 0.16 );
238
+ background-color: rgba(123, 13, 89, .16);
239
239
  }
240
240
  .cm-mw-template3-ext2-link-ground {
241
- background-color: rgba( 122, 10, 105, 0.2 );
241
+ background-color: rgba(122, 10, 105, .2);
242
242
  }
243
243
  .cm-mw-template3-ext3-link-ground {
244
- background-color: rgba( 122, 9, 116, 0.24 );
244
+ background-color: rgba(122, 9, 116, .24);
245
245
  }
package/mw/dist/base.js CHANGED
@@ -1,7 +1,7 @@
1
- import { CodeMirror6 } from 'https://testingcf.jsdelivr.net/npm/@bhsd/codemirror-mediawiki@2.1.10/dist/main.min.js';
1
+ import { CodeMirror6 } from 'https://testingcf.jsdelivr.net/npm/@bhsd/codemirror-mediawiki@2.1.12/dist/main.min.js';
2
2
  (() => {
3
3
  var _a;
4
- mw.loader.load('https://testingcf.jsdelivr.net/npm/@bhsd/codemirror-mediawiki@2.1.10/mediawiki.min.css', 'text/css');
4
+ mw.loader.load('https://testingcf.jsdelivr.net/npm/@bhsd/codemirror-mediawiki@2.1.12/mediawiki.min.css', 'text/css');
5
5
  mw.loader.addStyleTag('.wikiEditor-ui-toolbar{z-index:7}');
6
6
  const instances = new WeakMap();
7
7
  const getInstance = ($ele) => instances.get($ele[0]);
@@ -55,7 +55,7 @@ import { CodeMirror6 } from 'https://testingcf.jsdelivr.net/npm/@bhsd/codemirror
55
55
  return this;
56
56
  },
57
57
  };
58
- const USING_LOCAL = mw.loader.getState('ext.CodeMirror') !== null, DATA_MODULE = mw.loader.getState('ext.CodeMirror.data') ? 'ext.CodeMirror.data' : 'ext.CodeMirror', ALL_SETTINGS_CACHE = (_a = JSON.parse(localStorage.getItem('InPageEditMwConfig'))) !== null && _a !== void 0 ? _a : {}, SITE_ID = `${mw.config.get('wgServerName')}${mw.config.get('wgScriptPath')}`, SITE_SETTINGS = ALL_SETTINGS_CACHE[SITE_ID], VALID = (SITE_SETTINGS === null || SITE_SETTINGS === void 0 ? void 0 : SITE_SETTINGS.time) > Date.now() - 86400 * 1000 * 30;
58
+ const USING_LOCAL = mw.loader.getState('ext.CodeMirror') !== null, DATA_MODULE = mw.loader.getState('ext.CodeMirror.data') ? 'ext.CodeMirror.data' : 'ext.CodeMirror', ALL_SETTINGS_CACHE = (_a = JSON.parse(localStorage.getItem('InPageEditMwConfig'))) !== null && _a !== void 0 ? _a : {}, SITE_ID = `${mw.config.get('wgServerName')}${mw.config.get('wgScriptPath')}`, SITE_SETTINGS = ALL_SETTINGS_CACHE[SITE_ID], VALID = Number(SITE_SETTINGS === null || SITE_SETTINGS === void 0 ? void 0 : SITE_SETTINGS.time) > Date.now() - 86400 * 1000 * 30;
59
59
  const getConfig = (magicWords, rule, flip) => {
60
60
  const words = magicWords.filter(rule).filter(({ 'case-sensitive': i }) => i !== flip)
61
61
  .flatMap(({ aliases, name, 'case-sensitive': i }) => aliases.map(alias => ({
@@ -166,7 +166,7 @@ import { CodeMirror6 } from 'https://testingcf.jsdelivr.net/npm/@bhsd/codemirror
166
166
  const { lang } = this;
167
167
  let opt;
168
168
  if (typeof optOrNs === 'number') {
169
- if (lang === 'mediawiki' && (optOrNs === 10 || optOrNs === 828)) {
169
+ if (lang === 'mediawiki' && (optOrNs === 10 || optOrNs === 828 || optOrNs === 2)) {
170
170
  opt = { include: true };
171
171
  }
172
172
  else if (lang === 'javascript' && (optOrNs === 8 || optOrNs === 2300)) {
@@ -180,6 +180,15 @@ import { CodeMirror6 } from 'https://testingcf.jsdelivr.net/npm/@bhsd/codemirror
180
180
  opt = optOrNs;
181
181
  }
182
182
  if (!(lang in linters)) {
183
+ if (lang === 'mediawiki') {
184
+ const i18n = mw.config.get('wgUserLanguage');
185
+ if (['zh', 'zh-hans', 'zh-cn', 'zh-sg', 'zh-my'].includes(i18n)) {
186
+ opt = { ...opt, i18n: 'zh-hans' };
187
+ }
188
+ else if (['zh-hant', 'zh-tw', 'zh-hk', 'zh-mo'].includes(i18n)) {
189
+ opt = { ...opt, i18n: 'zh-hant' };
190
+ }
191
+ }
183
192
  await this.getLinter(opt);
184
193
  if (lang === 'mediawiki') {
185
194
  const mwConfig = await getMwConfig(), config = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bhsd/codemirror-mediawiki",
3
- "version": "2.1.10",
3
+ "version": "2.1.12",
4
4
  "description": "Modified CodeMirror mode based on wikimedia/mediawiki-extensions-CodeMirror",
5
5
  "keywords": [
6
6
  "mediawiki",
@@ -35,7 +35,8 @@
35
35
  "lint:ts": "tsc --noEmit && tsc --project mw/tsconfig.json --noEmit && eslint --cache .",
36
36
  "lint:css": "stylelint *.css",
37
37
  "lint": "npm run lint:ts && npm run lint:css",
38
- "test": "npm run build:core && npm run build:gh-page && http-server .. -c-1 --cors &",
38
+ "server": "npm run test:end; http-server .. -c-1 --cors &",
39
+ "test": "npm run build:core && npm run build:gh-page && npm run server",
39
40
  "test:end": "pkill -x http-server"
40
41
  },
41
42
  "engines": {
@@ -51,24 +52,24 @@
51
52
  "@codemirror/state": "^6.3.3",
52
53
  "@codemirror/view": "^6.22.2",
53
54
  "@lezer/highlight": "^1.2.0",
54
- "@stylistic/eslint-plugin": "^1.5.3",
55
+ "@stylistic/eslint-plugin": "^1.5.4",
55
56
  "@stylistic/stylelint-plugin": "^2.0.0",
56
57
  "@types/jquery": "^3.5.29",
57
58
  "@types/oojs-ui": "^0.47.6",
58
- "@typescript-eslint/eslint-plugin": "^6.12.0",
59
- "@typescript-eslint/parser": "^6.12.0",
60
- "esbuild": "^0.19.7",
59
+ "@typescript-eslint/eslint-plugin": "^6.19.1",
60
+ "@typescript-eslint/parser": "^6.19.1",
61
+ "esbuild": "^0.19.12",
61
62
  "eslint": "^8.56.0",
62
- "eslint-plugin-es-x": "^7.3.0",
63
+ "eslint-plugin-es-x": "^7.5.0",
63
64
  "eslint-plugin-eslint-comments": "^3.2.0",
64
65
  "eslint-plugin-promise": "^6.1.1",
65
- "eslint-plugin-regexp": "^2.1.2",
66
+ "eslint-plugin-regexp": "^2.2.0",
66
67
  "eslint-plugin-unicorn": "^50.0.1",
67
68
  "http-server": "^14.1.0",
68
69
  "stylelint": "^16.1.0",
69
70
  "stylelint-config-recommended": "^14.0.0",
70
71
  "types-mediawiki": "^1.4.0",
71
- "typescript": "^5.1.6",
72
- "wikilint": "^2.3.2"
72
+ "typescript": "^5.3.3",
73
+ "wikilint": "^2.4.1"
73
74
  }
74
75
  }
package/src/codemirror.ts CHANGED
@@ -7,6 +7,7 @@ import {
7
7
  highlightActiveLine,
8
8
  highlightWhitespace,
9
9
  highlightTrailingWhitespace,
10
+ drawSelection,
10
11
  } from '@codemirror/view';
11
12
  import {
12
13
  syntaxHighlighting,
@@ -52,7 +53,15 @@ const avail: Record<string, [(config?: any) => Extension, Record<string, unknown
52
53
  highlightTrailingWhitespace: [highlightTrailingWhitespace, {}],
53
54
  bracketMatching: [bracketMatching, {mediawiki: {brackets: '[]{}'}}],
54
55
  closeBrackets: [closeBrackets, {}],
56
+ allowMultipleSelections: [
57
+ (): Extension => [
58
+ EditorState.allowMultipleSelections.of(true),
59
+ drawSelection(),
60
+ ],
61
+ {},
62
+ ],
55
63
  };
64
+ const CDN = 'https://testingcf.jsdelivr.net';
56
65
 
57
66
  /**
58
67
  * 使用传统方法加载脚本
@@ -65,7 +74,7 @@ const loadScript = (src: string, target: string): Promise<void> => new Promise(r
65
74
  return;
66
75
  }
67
76
  const script = document.createElement('script');
68
- script.src = `https://testingcf.jsdelivr.net/${src}`;
77
+ script.src = `${CDN}/${src}`;
69
78
  script.onload = (): void => {
70
79
  resolve();
71
80
  };
@@ -88,7 +97,7 @@ export class CodeMirror6 {
88
97
  readonly #indent;
89
98
  readonly #view;
90
99
  #lang;
91
- #visible = true;
100
+ #visible = false;
92
101
 
93
102
  get textarea(): HTMLTextAreaElement {
94
103
  return this.#textarea;
@@ -154,25 +163,12 @@ export class CodeMirror6 {
154
163
  extensions,
155
164
  doc: textarea.value,
156
165
  });
157
- const {selectionStart, selectionEnd, scrollTop} = textarea,
158
- {fontSize, lineHeight} = getComputedStyle(textarea),
159
- hasFocus = document.activeElement === textarea;
166
+ const {fontSize, lineHeight} = getComputedStyle(textarea);
160
167
  textarea.parentNode!.insertBefore(this.#view.dom, textarea);
161
168
  this.#minHeight();
162
- this.#refresh();
163
169
  this.#view.dom.style.fontSize = fontSize;
164
170
  this.#view.scrollDOM.style.lineHeight = lineHeight;
165
- this.#view.requestMeasure();
166
- this.#view.dispatch({
167
- selection: {anchor: selectionStart, head: selectionEnd},
168
- });
169
- textarea.style.display = 'none';
170
- if (hasFocus) {
171
- this.#view.focus();
172
- }
173
- requestAnimationFrame(() => {
174
- this.#view.scrollDOM.scrollTop = scrollTop;
175
- });
171
+ this.toggle(true);
176
172
  }
177
173
 
178
174
  /** 刷新编辑器高度 */
@@ -260,8 +256,12 @@ export class CodeMirror6 {
260
256
  this.#view.dispatch({
261
257
  effects: [
262
258
  this.#extensions.reconfigure(names.map(name => {
263
- const [extension, configs] = avail[name]!;
264
- return extension(configs[this.#lang]);
259
+ const option = avail[name];
260
+ if (option) {
261
+ const [extension, configs] = option;
262
+ return extension(configs[this.#lang]);
263
+ }
264
+ return [];
265
265
  })),
266
266
  ],
267
267
  });
@@ -281,11 +281,21 @@ export class CodeMirror6 {
281
281
  async getLinter(opt?: Record<string, unknown>): Promise<LintSource | undefined> {
282
282
  switch (this.#lang) {
283
283
  case 'mediawiki': {
284
- const CDN = 'npm/wikiparser-node@1.3.4-b/extensions/dist',
285
- src = `combine/${CDN}/base.min.js,${CDN}/lint.min.js`;
284
+ const REPO = 'npm/wikiparser-node@1.4.1-b',
285
+ DIR = `${REPO}/extensions/dist`,
286
+ src = `combine/${DIR}/base.min.js,${DIR}/lint.min.js`,
287
+ lang = opt?.['i18n'];
286
288
  await loadScript(src, 'wikiparse');
287
- const wikiLinter = new wikiparse.Linter(opt?.['include'] as boolean);
288
- return doc => wikiLinter.codemirror(doc.toString());
289
+ if (typeof lang === 'string') {
290
+ try {
291
+ const i18n: Record<string, string>
292
+ = await (await fetch(`${CDN}/${REPO}/i18n/${lang.toLowerCase()}.json`)).json();
293
+ wikiparse.setI18N(i18n);
294
+ } catch {}
295
+ }
296
+ const wikiLinter = new wikiparse.Linter(opt?.['include'] as boolean | undefined);
297
+ return async doc =>
298
+ (await wikiLinter.codemirror(doc.toString())).filter(({severity}) => severity === 'error');
289
299
  }
290
300
  case 'javascript': {
291
301
  await loadScript('npm/eslint-linter-browserify', 'eslint');
@@ -422,11 +432,39 @@ export class CodeMirror6 {
422
432
  */
423
433
  toggle(show = !this.#visible): void {
424
434
  if (show && !this.#visible) {
425
- this.setContent(this.#textarea.value);
435
+ const {value, selectionStart, selectionEnd, scrollTop} = this.#textarea,
436
+ hasFocus = document.activeElement === this.#textarea;
437
+ this.setContent(value);
426
438
  this.#refresh();
439
+ this.#view.dom.style.setProperty('display', '');
440
+ this.#textarea.style.display = 'none';
441
+ this.#view.requestMeasure();
442
+ this.#view.dispatch({
443
+ selection: {anchor: selectionStart, head: selectionEnd},
444
+ });
445
+ if (hasFocus) {
446
+ this.#view.focus();
447
+ }
448
+ requestAnimationFrame(() => {
449
+ this.#view.scrollDOM.scrollTop = scrollTop;
450
+ });
451
+ } else if (!show && this.#visible) {
452
+ const {state: {selection: {main: {from, to}}}, hasFocus} = this.#view,
453
+ {scrollDOM: {scrollTop}} = this.#view;
454
+ this.#view.dom.style.setProperty('display', 'none', 'important');
455
+ this.#textarea.style.display = '';
456
+ this.#textarea.setSelectionRange(
457
+ Math.min(from, to),
458
+ Math.max(from, to),
459
+ from > to ? 'backward' : 'forward',
460
+ );
461
+ if (hasFocus) {
462
+ this.#textarea.focus();
463
+ }
464
+ requestAnimationFrame(() => {
465
+ this.#textarea.scrollTop = scrollTop;
466
+ });
427
467
  }
428
468
  this.#visible = show;
429
- this.#view.dom.style.setProperty('display', show ? '' : 'none', 'important');
430
- this.#textarea.style.display = show ? 'none' : '';
431
469
  }
432
470
  }
package/src/mediawiki.ts CHANGED
@@ -151,7 +151,8 @@ class MediaWiki {
151
151
  }));
152
152
  }
153
153
 
154
- eatHtmlEntity(stream: StringStream, style: string): string { // eslint-disable-line class-methods-use-this
154
+ // eslint-disable-next-line @typescript-eslint/class-methods-use-this
155
+ eatHtmlEntity(stream: StringStream, style: string): string {
155
156
  const entity = stream.match(/^(?:#x[a-f\d]+|#\d+|[a-z\d]+);/iu) as RegExpMatchArray | false;
156
157
  return entity && isHtmlEntity(`&${entity[0]}`) ? modeConfig.tags.htmlEntity : style;
157
158
  }
@@ -164,7 +165,7 @@ class MediaWiki {
164
165
  );
165
166
  }
166
167
 
167
- // eslint-disable-next-line class-methods-use-this
168
+ // eslint-disable-next-line @typescript-eslint/class-methods-use-this
168
169
  makeLocalStyle(style: string, state: State, endGround?: 'nTemplate' | 'nLink' | 'nExt'): string {
169
170
  let ground = '';
170
171
 
@@ -619,8 +620,7 @@ class MediaWiki {
619
620
  eatExtTagArea(name: string): Tokenizer {
620
621
  return (stream, state) => {
621
622
  const from = stream.pos,
622
- pattern = new RegExp(`</${name}\\s*(?:>|$)`, 'iu'),
623
- m = pattern.exec(from ? stream.string.slice(from) : stream.string);
623
+ m = new RegExp(`</${name}\\s*(?:>|$)`, 'iu').exec(from ? stream.string.slice(from) : stream.string);
624
624
  let origString: string | false = false;
625
625
 
626
626
  if (m) {
@@ -633,9 +633,8 @@ class MediaWiki {
633
633
  }
634
634
  return state.tokenize(stream, state);
635
635
  }
636
- const to = m.index + from;
637
636
  origString = stream.string;
638
- stream.string = origString.slice(0, to);
637
+ stream.string = origString.slice(0, m.index + from);
639
638
  }
640
639
 
641
640
  state.stack.push(state.tokenize);
@@ -653,7 +652,8 @@ class MediaWiki {
653
652
  };
654
653
  }
655
654
 
656
- inExtTokens(origString: string | false): Tokenizer { // eslint-disable-line class-methods-use-this
655
+ // eslint-disable-next-line @typescript-eslint/class-methods-use-this
656
+ inExtTokens(origString: string | false): Tokenizer {
657
657
  return (stream, state) => {
658
658
  let ret: string;
659
659
  if (state.extMode === false) {
@@ -779,10 +779,11 @@ class MediaWiki {
779
779
 
780
780
  eatWikiText(style: string): Tokenizer {
781
781
  return (stream, state) => {
782
- let ch: string | void; // eslint-disable-line @typescript-eslint/no-invalid-void-type
783
- const sol = stream.sol();
782
+ let ch: string;
784
783
 
785
- if (sol) {
784
+ if (stream.eol()) {
785
+ return '';
786
+ } else if (stream.sol()) {
786
787
  if (stream.match('//')) {
787
788
  return this.makeStyle(style, state);
788
789
  // highlight free external links, see T108448
@@ -791,7 +792,7 @@ class MediaWiki {
791
792
  state.tokenize = this.inFreeExternalLink.bind(this);
792
793
  return this.makeStyle(modeConfig.tags.freeExtLinkProtocol, state);
793
794
  }
794
- ch = stream.next();
795
+ ch = stream.next()!;
795
796
  switch (ch) {
796
797
  case '-':
797
798
  if (stream.match(/^-{3,}/u)) {
@@ -863,7 +864,7 @@ class MediaWiki {
863
864
  // pass
864
865
  }
865
866
  } else {
866
- ch = stream.next();
867
+ ch = stream.next()!;
867
868
  }
868
869
 
869
870
  switch (ch) {
@@ -1101,12 +1102,7 @@ class MediaWiki {
1101
1102
  },
1102
1103
 
1103
1104
  token: (stream, state): string => {
1104
- let style: string,
1105
- p: number | null = null,
1106
- t: Token,
1107
- f: number | null,
1108
- tmpTokens: Token[] = [];
1109
- const readyTokens: Token[] = [];
1105
+ let t: Token;
1110
1106
 
1111
1107
  if (this.oldTokens.length > 0) {
1112
1108
  // just send saved tokens till they exists
@@ -1122,6 +1118,11 @@ class MediaWiki {
1122
1118
  this.firstSpace = null;
1123
1119
  }
1124
1120
 
1121
+ let style: string,
1122
+ p: number | null = null,
1123
+ f: number | null;
1124
+ const tmpTokens: Token[] = [],
1125
+ readyTokens: Token[] = [];
1125
1126
  do {
1126
1127
  // get token style
1127
1128
  style = state.tokenize(stream, state);
@@ -1135,7 +1136,7 @@ class MediaWiki {
1135
1136
  if (tmpTokens.length > 0) {
1136
1137
  // save tokens
1137
1138
  readyTokens.push(...tmpTokens);
1138
- tmpTokens = [];
1139
+ tmpTokens.length = 0;
1139
1140
  }
1140
1141
  }
1141
1142
  // save token
@@ -1217,10 +1218,9 @@ for (const [language, parser] of Object.entries(plugins)) {
1217
1218
  * @param config Configuration for the MediaWiki mode
1218
1219
  */
1219
1220
  export const mediawiki = (config: MwConfig): LanguageSupport => {
1220
- const mode = new MediaWiki(config);
1221
- const parser = mode.mediawiki;
1222
- const lang = StreamLanguage.define(parser);
1223
- const highlighter = syntaxHighlighting(HighlightStyle.define(mode.getTagStyles()) as Highlighter);
1221
+ const mode = new MediaWiki(config),
1222
+ lang = StreamLanguage.define(mode.mediawiki),
1223
+ highlighter = syntaxHighlighting(HighlightStyle.define(mode.getTagStyles()) as Highlighter);
1224
1224
  return new LanguageSupport(lang, highlighter);
1225
1225
  };
1226
1226