@bhsd/codemirror-mediawiki 2.30.3 → 3.0.0
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/README.md +177 -27
- package/dist/codemirror.d.ts +74 -48
- package/dist/codemirror.js +180 -229
- package/dist/color.d.ts +1 -6
- package/dist/color.js +1 -8
- package/dist/config.js +5 -6
- package/dist/escape.js +2 -2
- package/dist/fold.d.ts +53 -6
- package/dist/fold.js +140 -136
- package/dist/hover.js +1 -1
- package/dist/indent.d.ts +5 -1
- package/dist/indent.js +2 -1
- package/dist/inlay.js +1 -1
- package/dist/javascript.d.ts +1 -0
- package/dist/javascript.js +2 -4
- package/dist/keybindings.js +1 -0
- package/dist/linter.d.ts +1 -1
- package/dist/linter.js +47 -11
- package/dist/lintsource.d.ts +14 -0
- package/dist/lintsource.js +159 -0
- package/dist/lsp.d.ts +3 -0
- package/dist/lsp.js +34 -0
- package/dist/main.min.js +25 -24
- package/dist/matchBrackets.d.ts +1 -1
- package/dist/matchTag.js +2 -2
- package/dist/mediawiki.js +3 -2
- package/dist/mw.min.js +30 -29
- package/dist/mwConfig.js +2 -5
- package/dist/ref.js +1 -1
- package/dist/signature.js +1 -1
- package/dist/statusBar.d.ts +1 -1
- package/dist/token.d.ts +14 -12
- package/dist/token.js +83 -62
- package/dist/vue.d.ts +3 -0
- package/dist/vue.js +14 -0
- package/dist/wiki.min.js +29 -28
- package/i18n/en.json +2 -3
- package/i18n/zh-hans.json +2 -3
- package/i18n/zh-hant.json +2 -3
- package/package.json +21 -12
package/dist/mwConfig.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// ../
|
|
1
|
+
// ../browser/dist/index.js
|
|
2
2
|
var CDN = "https://testingcf.jsdelivr.net";
|
|
3
3
|
var getObject = (key) => JSON.parse(String(localStorage.getItem(key)));
|
|
4
4
|
var setObject = (key, value) => {
|
|
@@ -10,7 +10,7 @@ var compareVersion = (version, baseVersion) => {
|
|
|
10
10
|
return major > baseMajor || major === baseMajor && minor >= baseMinor;
|
|
11
11
|
};
|
|
12
12
|
|
|
13
|
-
// ../
|
|
13
|
+
// ../cm-util/dist/index.mjs
|
|
14
14
|
var otherParserFunctions = /* @__PURE__ */ new Set(["msg", "raw", "subst", "safesubst"]);
|
|
15
15
|
var getConfig = (magicWords, rule, flip) => {
|
|
16
16
|
const words = magicWords.filter(rule);
|
|
@@ -198,9 +198,6 @@ var getParserConfig2 = (minConfig, mwConfig) => {
|
|
|
198
198
|
nsid,
|
|
199
199
|
variants
|
|
200
200
|
};
|
|
201
|
-
if (location.hostname.endsWith(".moegirl.org.cn")) {
|
|
202
|
-
config.html[2].push("img");
|
|
203
|
-
}
|
|
204
201
|
const noCM = mw.loader.getState("ext.CodeMirror") === null;
|
|
205
202
|
for (const [key, val] of Object.entries(insensitive)) {
|
|
206
203
|
if (others.has(val) && val !== "msgnw") {
|
package/dist/ref.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { hoverTooltip, EditorView } from '@codemirror/view';
|
|
2
2
|
import { ensureSyntaxTree } from '@codemirror/language';
|
|
3
|
-
import { getLSP } from '@bhsd/
|
|
3
|
+
import { getLSP } from '@bhsd/browser';
|
|
4
4
|
import { getTag } from './matchTag';
|
|
5
5
|
import { tokens } from './config';
|
|
6
6
|
import { indexToPos, posToIndex } from './hover';
|
package/dist/signature.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { EditorView, showTooltip } from '@codemirror/view';
|
|
2
2
|
import { StateField, StateEffect } from '@codemirror/state';
|
|
3
|
-
import { getLSP } from '@bhsd/
|
|
3
|
+
import { getLSP } from '@bhsd/browser';
|
|
4
4
|
import { indexToPos, createTooltipView } from './hover';
|
|
5
5
|
const stateEffect = StateEffect.define(), field = StateField.define({
|
|
6
6
|
create() {
|
package/dist/statusBar.d.ts
CHANGED
package/dist/token.d.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import { Tag } from '@lezer/highlight';
|
|
7
7
|
import { tokens } from './config';
|
|
8
|
-
import type { MwConfig as MwConfigBase } from '@bhsd/
|
|
8
|
+
import type { MwConfig as MwConfigBase } from '@bhsd/cm-util';
|
|
9
9
|
import type { EditorState } from '@codemirror/state';
|
|
10
10
|
import type { StreamParser, StringStream as StringStreamBase } from '@codemirror/language';
|
|
11
11
|
import type { SyntaxNode } from '@lezer/common';
|
|
@@ -102,6 +102,7 @@ export declare class MediaWiki {
|
|
|
102
102
|
readonly tags: string[];
|
|
103
103
|
readonly hasVariants: boolean;
|
|
104
104
|
readonly preRegex: [RegExp, RegExp];
|
|
105
|
+
readonly substRegex: RegExp;
|
|
105
106
|
readonly autocompleteNamespaces: {
|
|
106
107
|
0: string;
|
|
107
108
|
6: string;
|
|
@@ -126,11 +127,11 @@ export declare class MediaWiki {
|
|
|
126
127
|
* See makeLocalStyle() for how these tokens are used.
|
|
127
128
|
*/
|
|
128
129
|
registerGroundTokens(): void;
|
|
129
|
-
inChars({ length }: string, tag: TagName): Tokenizer
|
|
130
|
-
inStr(str: string, tag: TagName | false, errorTag?: TagName): Tokenizer
|
|
130
|
+
inChars({ length }: string, tag: TagName): Tokenizer<string>;
|
|
131
|
+
inStr(str: string, tag: TagName | false, errorTag?: TagName): Tokenizer<string>;
|
|
131
132
|
eatWikiText(style: string): Tokenizer;
|
|
132
133
|
eatApostrophes(obj: Pick<State, 'bold' | 'italic'>): Tokenizer<string | false>;
|
|
133
|
-
eatExternalLinkProtocol({ length }: string, free?: boolean): Tokenizer
|
|
134
|
+
eatExternalLinkProtocol({ length }: string, free?: boolean): Tokenizer<string>;
|
|
134
135
|
inExternalLink(text?: boolean): Tokenizer;
|
|
135
136
|
eatFreeExternalLink(this: void, stream: StringStream, state: State): Style;
|
|
136
137
|
inLink(file: boolean, section?: boolean): Tokenizer;
|
|
@@ -138,22 +139,23 @@ export declare class MediaWiki {
|
|
|
138
139
|
toEatImageParameter(stream: StringStream, state: State): void;
|
|
139
140
|
eatList(stream: StringStream, state: State): string;
|
|
140
141
|
eatDoubleUnderscore(style: string, stream: StringStream, state: State): Style;
|
|
141
|
-
get eatStartTable(): Tokenizer
|
|
142
|
+
get eatStartTable(): Tokenizer<string>;
|
|
142
143
|
inTableDefinition(tr?: boolean, quote?: string): Tokenizer;
|
|
143
144
|
get inTable(): Tokenizer;
|
|
144
145
|
inTableCell(style: string, needAttr?: boolean, firstLine?: boolean): Tokenizer;
|
|
145
146
|
inSectionHeader(str: string): Tokenizer;
|
|
146
|
-
get inComment(): Tokenizer
|
|
147
|
+
get inComment(): Tokenizer<string>;
|
|
147
148
|
eatExtTag(tagname: string, isCloseTag: boolean, state: State): string;
|
|
148
149
|
eatHtmlTag(tagname: string, isCloseTag: boolean, state: State): string;
|
|
149
|
-
eatTagName(name: string, isCloseTag?: boolean, isHtmlTag?: boolean): Tokenizer
|
|
150
|
+
eatTagName(name: string, isCloseTag?: boolean, isHtmlTag?: boolean): Tokenizer<string>;
|
|
150
151
|
inHtmlTagAttribute(name: string, quote?: string): Tokenizer;
|
|
151
|
-
inExtTagAttribute(name: string, quote?: string, isLang?: boolean, isPage?: boolean): Tokenizer
|
|
152
|
-
eatExtTagArea(name: string): Tokenizer
|
|
153
|
-
inExtTokens(origString: string): Tokenizer
|
|
152
|
+
inExtTagAttribute(name: string, quote?: string, isLang?: boolean, isPage?: boolean): Tokenizer<string>;
|
|
153
|
+
eatExtTagArea(name: string): Tokenizer<string>;
|
|
154
|
+
inExtTokens(origString: string): Tokenizer<string>;
|
|
154
155
|
inVariable(pos?: number): Tokenizer;
|
|
155
156
|
eatTransclusion(stream: StringStream, state: State): string | undefined;
|
|
156
|
-
|
|
157
|
+
inSubst(subst?: string): Tokenizer<string>;
|
|
158
|
+
inParserFunctionName(invoke?: number, n?: number, ns?: number): Tokenizer<string>;
|
|
157
159
|
inTemplatePageName(haveEaten?: boolean, anchor?: boolean): Tokenizer;
|
|
158
160
|
inParserFunctionArgument(module?: number, n?: number, ns?: number): Tokenizer;
|
|
159
161
|
inTemplateArgument(expectName?: boolean, parserFunction?: boolean): Tokenizer;
|
|
@@ -180,7 +182,7 @@ export declare class MediaWiki {
|
|
|
180
182
|
inGallery(section?: boolean): Tokenizer;
|
|
181
183
|
'text/gallery'(tags: string[]): StreamParser<State>;
|
|
182
184
|
javascript(): StreamParser<unknown>;
|
|
183
|
-
css(): StreamParser<unknown>;
|
|
184
185
|
json(): StreamParser<unknown>;
|
|
186
|
+
lua(): StreamParser<unknown>;
|
|
185
187
|
}
|
|
186
188
|
export {};
|
package/dist/token.js
CHANGED
|
@@ -38,10 +38,11 @@ var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn,
|
|
|
38
38
|
done = true;
|
|
39
39
|
};
|
|
40
40
|
import { Tag } from '@lezer/highlight';
|
|
41
|
-
import {
|
|
42
|
-
import {
|
|
43
|
-
import {
|
|
41
|
+
import { getRegex } from '@bhsd/common';
|
|
42
|
+
import { decodeHTML } from '@bhsd/browser';
|
|
43
|
+
import { otherParserFunctions } from '@bhsd/cm-util';
|
|
44
44
|
import { javascript, json } from '@codemirror/legacy-modes/mode/javascript';
|
|
45
|
+
import { lua } from '@codemirror/legacy-modes/mode/lua';
|
|
45
46
|
import { htmlTags, voidHtmlTags, selfClosingTags, tokenTable, tokens } from './config';
|
|
46
47
|
class MediaWikiData {
|
|
47
48
|
constructor(tags) {
|
|
@@ -136,11 +137,11 @@ typeof document !== 'object' || str.startsWith('#') || [...decodeHTML(`&${str}`)
|
|
|
136
137
|
/**
|
|
137
138
|
* 更新内部 Tokenizer
|
|
138
139
|
* @param state
|
|
139
|
-
* @param
|
|
140
|
+
* @param tokenizers
|
|
140
141
|
*/
|
|
141
|
-
const chain = (state,
|
|
142
|
-
state.stack.unshift(state.tokenize);
|
|
143
|
-
state.tokenize =
|
|
142
|
+
const chain = (state, ...tokenizers) => {
|
|
143
|
+
state.stack.unshift(...tokenizers.slice(1), state.tokenize);
|
|
144
|
+
state.tokenize = tokenizers[0];
|
|
144
145
|
};
|
|
145
146
|
/**
|
|
146
147
|
* 更新内部 Tokenizer
|
|
@@ -192,7 +193,7 @@ const needColon = (state) => {
|
|
|
192
193
|
return Boolean(dt.n) && dt.html === 0 && !state.bold && !state.italic && cmpNesting(dt, state, true);
|
|
193
194
|
};
|
|
194
195
|
/**
|
|
195
|
-
*
|
|
196
|
+
* 获取外部链接正则表达式,注意`<`和`>`大小写敏感
|
|
196
197
|
* @param punctuations 标点符号
|
|
197
198
|
*/
|
|
198
199
|
const getUrlRegex = (punctuations = '') => {
|
|
@@ -319,8 +320,6 @@ const peekSpace = (stream, sol) => {
|
|
|
319
320
|
return Boolean(peek && !peek.trim());
|
|
320
321
|
};
|
|
321
322
|
const syntaxHighlight = new Set(['syntaxhighlight', 'source', 'pre']), pageFunctions = new Set([
|
|
322
|
-
'subst',
|
|
323
|
-
'safesubst',
|
|
324
323
|
'raw',
|
|
325
324
|
'msg',
|
|
326
325
|
'filepath',
|
|
@@ -332,7 +331,7 @@ const syntaxHighlight = new Set(['syntaxhighlight', 'source', 'pre']), pageFunct
|
|
|
332
331
|
'canonicalurle',
|
|
333
332
|
'int',
|
|
334
333
|
'msgnw',
|
|
335
|
-
]), headerRegex = new RegExp(`^(?:[^&[<{~'-]|${lookahead("<{~'-")})+`, 'iu'), templateRegex = new RegExp(`^(?:[^|{}<]|${lookahead('{}<', true)})+`, 'u'), argumentRegex = new RegExp(`^(?:[^|[&:}{<~'_-]|${lookahead("}{<~'_-")})+`, 'iu'), styleRegex = new RegExp(`^(?:[^|[&}{<~'_-]|${lookahead("}{<~'_-")})+`, 'iu'), wikiRegex = new RegExp(`^(?:[^&'{[<~_:-]|${lookahead("'{[<~_-")})+`, '
|
|
334
|
+
]), substs = new Set(['subst', 'safesubst']), headerRegex = new RegExp(`^(?:[^&[<{~'-]|${lookahead("<{~'-")})+`, 'iu'), templateRegex = new RegExp(`^(?:[^|{}<]|${lookahead('{}<', true)})+`, 'u'), argumentRegex = new RegExp(`^(?:[^|[&:}{<~'_-]|${lookahead("}{<~'_-")})+`, 'iu'), styleRegex = new RegExp(`^(?:[^|[&}{<~'_-]|${lookahead("}{<~'_-")})+`, 'iu'), wikiRegex = new RegExp(`^(?:[^&'{[<~_:-]|${lookahead("'{[<~_-")})+`, 'iu'), tableDefinitionRegex = new RegExp(`^(?:[^&={<]|${lookahead('{<')})+`, 'iu'), tableCellRegex = /^\s*(?:[|!]|\{\{\s*![!)+-]?\s*\}\})/u, extLinkChars = "[{'<-", tableDefinitionChars = '{<', tableCellChars = "'<~_{-", htmlAttrChars = '{/', freeRegex = [false, true].map(lpar => {
|
|
336
335
|
const punctuations = getPunctuations(lpar), source = getUrlRegex(punctuations);
|
|
337
336
|
return new RegExp(`^(?:${source}|[${punctuations}]+(?=${source}))*`, 'u');
|
|
338
337
|
}), indentedTableRegex = [false, true].map(isTemplate => new RegExp(String.raw `^:*\s*(?=\{${getPipe(isTemplate)})`, 'u')), tableRegex = [false, true]
|
|
@@ -369,6 +368,7 @@ let MediaWiki = (() => {
|
|
|
369
368
|
let _eatExtTagArea_decorators;
|
|
370
369
|
let _inExtTokens_decorators;
|
|
371
370
|
let _inVariable_decorators;
|
|
371
|
+
let _inSubst_decorators;
|
|
372
372
|
let _inParserFunctionName_decorators;
|
|
373
373
|
let _inTemplatePageName_decorators;
|
|
374
374
|
let _inParserFunctionArgument_decorators;
|
|
@@ -381,33 +381,40 @@ let MediaWiki = (() => {
|
|
|
381
381
|
return class MediaWiki {
|
|
382
382
|
static {
|
|
383
383
|
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
|
|
384
|
-
_inChars_decorators = [getTokenizer
|
|
385
|
-
|
|
384
|
+
_inChars_decorators = [(getTokenizer)
|
|
385
|
+
// eslint-disable-next-line @typescript-eslint/class-methods-use-this
|
|
386
|
+
];
|
|
387
|
+
_inStr_decorators = [(getTokenizer)
|
|
388
|
+
// eslint-disable-next-line @typescript-eslint/class-methods-use-this
|
|
389
|
+
];
|
|
386
390
|
_eatWikiText_decorators = [getTokenizer];
|
|
387
391
|
_eatApostrophes_decorators = [getTokenizer];
|
|
388
|
-
_eatExternalLinkProtocol_decorators = [getTokenizer];
|
|
392
|
+
_eatExternalLinkProtocol_decorators = [(getTokenizer)];
|
|
389
393
|
_inExternalLink_decorators = [getTokenizer];
|
|
390
394
|
_inLink_decorators = [getTokenizer];
|
|
391
395
|
_inLinkText_decorators = [getTokenizer];
|
|
392
|
-
_get_eatStartTable_decorators = [getTokenizer];
|
|
396
|
+
_get_eatStartTable_decorators = [(getTokenizer)];
|
|
393
397
|
_inTableDefinition_decorators = [getTokenizer];
|
|
394
398
|
_get_inTable_decorators = [getTokenizer];
|
|
395
399
|
_inTableCell_decorators = [getTokenizer];
|
|
396
400
|
_inSectionHeader_decorators = [getTokenizer];
|
|
397
|
-
_get_inComment_decorators = [getTokenizer];
|
|
398
|
-
_eatTagName_decorators = [getTokenizer];
|
|
401
|
+
_get_inComment_decorators = [(getTokenizer)];
|
|
402
|
+
_eatTagName_decorators = [(getTokenizer)];
|
|
399
403
|
_inHtmlTagAttribute_decorators = [getTokenizer];
|
|
400
|
-
_inExtTagAttribute_decorators = [getTokenizer];
|
|
401
|
-
_eatExtTagArea_decorators = [getTokenizer];
|
|
402
|
-
_inExtTokens_decorators = [getTokenizer
|
|
404
|
+
_inExtTagAttribute_decorators = [(getTokenizer)];
|
|
405
|
+
_eatExtTagArea_decorators = [(getTokenizer)];
|
|
406
|
+
_inExtTokens_decorators = [(getTokenizer)
|
|
407
|
+
// eslint-disable-next-line @typescript-eslint/class-methods-use-this
|
|
408
|
+
];
|
|
403
409
|
_inVariable_decorators = [getTokenizer];
|
|
404
|
-
|
|
410
|
+
_inSubst_decorators = [(getTokenizer)];
|
|
411
|
+
_inParserFunctionName_decorators = [(getTokenizer)];
|
|
405
412
|
_inTemplatePageName_decorators = [getTokenizer];
|
|
406
413
|
_inParserFunctionArgument_decorators = [getTokenizer];
|
|
407
414
|
_inTemplateArgument_decorators = [getTokenizer];
|
|
408
415
|
_inConvert_decorators = [getTokenizer];
|
|
409
|
-
_inPre_decorators = [getTokenizer];
|
|
410
|
-
_inNested_decorators = [getTokenizer];
|
|
416
|
+
_inPre_decorators = [(getTokenizer)];
|
|
417
|
+
_inNested_decorators = [(getTokenizer)];
|
|
411
418
|
_get_inInputbox_decorators = [(getTokenizer)];
|
|
412
419
|
_inGallery_decorators = [getTokenizer];
|
|
413
420
|
__esDecorate(this, null, _inChars_decorators, { kind: "method", name: "inChars", static: false, private: false, access: { has: obj => "inChars" in obj, get: obj => obj.inChars }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
@@ -430,6 +437,7 @@ let MediaWiki = (() => {
|
|
|
430
437
|
__esDecorate(this, null, _eatExtTagArea_decorators, { kind: "method", name: "eatExtTagArea", static: false, private: false, access: { has: obj => "eatExtTagArea" in obj, get: obj => obj.eatExtTagArea }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
431
438
|
__esDecorate(this, null, _inExtTokens_decorators, { kind: "method", name: "inExtTokens", static: false, private: false, access: { has: obj => "inExtTokens" in obj, get: obj => obj.inExtTokens }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
432
439
|
__esDecorate(this, null, _inVariable_decorators, { kind: "method", name: "inVariable", static: false, private: false, access: { has: obj => "inVariable" in obj, get: obj => obj.inVariable }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
440
|
+
__esDecorate(this, null, _inSubst_decorators, { kind: "method", name: "inSubst", static: false, private: false, access: { has: obj => "inSubst" in obj, get: obj => obj.inSubst }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
433
441
|
__esDecorate(this, null, _inParserFunctionName_decorators, { kind: "method", name: "inParserFunctionName", static: false, private: false, access: { has: obj => "inParserFunctionName" in obj, get: obj => obj.inParserFunctionName }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
434
442
|
__esDecorate(this, null, _inTemplatePageName_decorators, { kind: "method", name: "inTemplatePageName", static: false, private: false, access: { has: obj => "inTemplatePageName" in obj, get: obj => obj.inTemplatePageName }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
435
443
|
__esDecorate(this, null, _inParserFunctionArgument_decorators, { kind: "method", name: "inParserFunctionArgument", static: false, private: false, access: { has: obj => "inParserFunctionArgument" in obj, get: obj => obj.inParserFunctionArgument }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
@@ -443,7 +451,7 @@ let MediaWiki = (() => {
|
|
|
443
451
|
}
|
|
444
452
|
constructor(config) {
|
|
445
453
|
__runInitializers(this, _instanceExtraInitializers);
|
|
446
|
-
const { urlProtocols, permittedHtmlTags, implicitlyClosedHtmlTags, tags, nsid, variants, redirection = ['#REDIRECT'], img = {}, } = config;
|
|
454
|
+
const { urlProtocols, permittedHtmlTags, implicitlyClosedHtmlTags, tags, nsid, variants, functionSynonyms: [insensitive], redirection = ['#REDIRECT'], img = {}, } = config;
|
|
447
455
|
this.config = config;
|
|
448
456
|
this.tokenTable = { ...tokenTable };
|
|
449
457
|
this.hiddenTable = {};
|
|
@@ -463,12 +471,15 @@ let MediaWiki = (() => {
|
|
|
463
471
|
this.imgRegex = new RegExp(String.raw `^(?:${this.img.filter(word => word.endsWith('$1')).map(word => word.slice(0, -2))
|
|
464
472
|
.join('|')}|(?:${this.img.filter(word => !word.endsWith('$1')).join('|')}|(?:\d+x?|\d*x\d+)\s*(?:px)?px)\s*(?=\||\]\]|$))`, 'u');
|
|
465
473
|
this.tags = [...Object.keys(tags), 'includeonly', 'noinclude', 'onlyinclude'];
|
|
466
|
-
this.convertRegex = new RegExp(String.raw `^(?:[^}|;&='{[<~_-]|\}(?!-)|=(?!>)|\[(?!\[|${urlProtocols})|${lookahead("'{<~_-")})+`, '
|
|
467
|
-
this.convertSemicolon = variants && new RegExp(String.raw `^;\s*(?=(?:[^;]*?=>\s*)?(?:${variants.join('|')})\s*:|(?:$|\}-))`, '
|
|
474
|
+
this.convertRegex = new RegExp(String.raw `^(?:[^}|;&='{[<~_-]|\}(?!-)|=(?!>)|\[(?!\[|${urlProtocols})|${lookahead("'{<~_-")})+`, 'iu');
|
|
475
|
+
this.convertSemicolon = variants && new RegExp(String.raw `^;\s*(?=(?:[^;]*?=>\s*)?(?:${variants.join('|')})\s*:|(?:$|\}-))`, 'iu');
|
|
468
476
|
this.convertLang = variants
|
|
469
|
-
&& new RegExp(String.raw `^(?:=>\s*)?(?:${variants.join('|')})\s*:`, '
|
|
477
|
+
&& new RegExp(String.raw `^(?:=>\s*)?(?:${variants.join('|')})\s*:`, 'iu');
|
|
470
478
|
this.hasVariants = Boolean(variants?.length);
|
|
471
479
|
this.preRegex = [false, true].map(begin => new RegExp(String.raw `^(?:[^<&-]|-${this.hasVariants ? String.raw `(?!\{)` : ''}|<(?!${begin ? '/' : ''}nowiki>))+`, 'iu'));
|
|
480
|
+
this.substRegex = new RegExp(String.raw `^\s*(?:(${Object.entries(insensitive).filter(([, v]) => substs.has(v))
|
|
481
|
+
.map(([k]) => k + (k.endsWith(':') ? '' : ':'))
|
|
482
|
+
.join('|')})\s*)?`, 'iu');
|
|
472
483
|
this.autocompleteNamespaces = {
|
|
473
484
|
0: '',
|
|
474
485
|
6: 'File:',
|
|
@@ -908,7 +919,11 @@ let MediaWiki = (() => {
|
|
|
908
919
|
const linkState = { bold: false, italic: false }, regex = linkTextRegex[file ? 1 : 0];
|
|
909
920
|
return (stream, state) => {
|
|
910
921
|
const tmpstyle = `${tokens[file ? 'fileText' : 'linkText']} ${linkState.bold ? tokens.strong : ''} ${linkState.italic ? tokens.em : ''} ${file && state.imgLink ? tokens.pageName : ''}`, { redirect, lbrack } = state, closing = stream.match(']]');
|
|
911
|
-
if (closing
|
|
922
|
+
if (closing
|
|
923
|
+
|| !file && stream.match('[[', false)
|
|
924
|
+
|| !gallery
|
|
925
|
+
&& state.stack[0]?.name === 'inTableCell'
|
|
926
|
+
&& stream.sol() && stream.match(tableCellRegex, false)) {
|
|
912
927
|
if (gallery) {
|
|
913
928
|
return makeStyle(tmpstyle, state);
|
|
914
929
|
}
|
|
@@ -1067,7 +1082,7 @@ let MediaWiki = (() => {
|
|
|
1067
1082
|
inTableCell(style, needAttr = true, firstLine = true) {
|
|
1068
1083
|
return (stream, state) => {
|
|
1069
1084
|
if (stream.sol()) {
|
|
1070
|
-
if (stream.match(
|
|
1085
|
+
if (stream.match(tableCellRegex, false)) {
|
|
1071
1086
|
state.tokenize = this.inTable;
|
|
1072
1087
|
return '';
|
|
1073
1088
|
}
|
|
@@ -1234,23 +1249,23 @@ let MediaWiki = (() => {
|
|
|
1234
1249
|
const advance = (stream, state, re) => {
|
|
1235
1250
|
const mt = stream.match(re);
|
|
1236
1251
|
if (isLang) {
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
state.extMode = css;
|
|
1244
|
-
break;
|
|
1245
|
-
case 'json':
|
|
1246
|
-
state.extMode = json;
|
|
1247
|
-
// no default
|
|
1252
|
+
let lang = mt[0].trim().toLowerCase();
|
|
1253
|
+
if (lang === 'js') {
|
|
1254
|
+
lang = 'javascript';
|
|
1255
|
+
}
|
|
1256
|
+
if (lang in this) {
|
|
1257
|
+
state.extMode = this[lang]();
|
|
1248
1258
|
}
|
|
1249
1259
|
}
|
|
1250
1260
|
return makeLocalStyle(tokens.extTagAttributeValue + (isPage ? ` ${tokens.pageName}` : ''), state);
|
|
1251
1261
|
};
|
|
1252
1262
|
return (stream, state) => {
|
|
1253
|
-
if (stream.
|
|
1263
|
+
if (stream.match('/>')) {
|
|
1264
|
+
state.extMode = false;
|
|
1265
|
+
pop(state);
|
|
1266
|
+
return makeLocalTagStyle('extTagBracket', state);
|
|
1267
|
+
}
|
|
1268
|
+
else if (stream.eat('>')) {
|
|
1254
1269
|
const { config: { tagModes } } = this;
|
|
1255
1270
|
state.extName = name;
|
|
1256
1271
|
state.extMode ||= name in tagModes
|
|
@@ -1261,11 +1276,6 @@ let MediaWiki = (() => {
|
|
|
1261
1276
|
state.tokenize = this.eatExtTagArea(name);
|
|
1262
1277
|
return makeLocalTagStyle('extTagBracket', state);
|
|
1263
1278
|
}
|
|
1264
|
-
else if (stream.match('/>')) {
|
|
1265
|
-
state.extMode = false;
|
|
1266
|
-
pop(state);
|
|
1267
|
-
return makeLocalTagStyle('extTagBracket', state);
|
|
1268
|
-
}
|
|
1269
1279
|
else if (quote) { // 有引号的属性值
|
|
1270
1280
|
if (stream.eat(quote[0])) {
|
|
1271
1281
|
const [, remains] = quote;
|
|
@@ -1372,12 +1382,12 @@ let MediaWiki = (() => {
|
|
|
1372
1382
|
};
|
|
1373
1383
|
}
|
|
1374
1384
|
eatTransclusion(stream, state) {
|
|
1375
|
-
const [{ length }] = stream.match(
|
|
1385
|
+
const [{ length }, subst] = stream.match(this.substRegex), tokenizers = subst ? [this.inSubst(subst)] : [];
|
|
1376
1386
|
// Parser function
|
|
1377
1387
|
if (stream.peek() === '#') {
|
|
1378
1388
|
stream.backUp(length);
|
|
1379
1389
|
state.nExt++;
|
|
1380
|
-
chain(state, this.inParserFunctionName());
|
|
1390
|
+
chain(state, ...tokenizers, this.inParserFunctionName());
|
|
1381
1391
|
return makeLocalTagStyle('parserFunctionBracket', state);
|
|
1382
1392
|
}
|
|
1383
1393
|
// Check for parser function without '#'
|
|
@@ -1397,13 +1407,14 @@ let MediaWiki = (() => {
|
|
|
1397
1407
|
&& functionSynonyms[0][ffLower];
|
|
1398
1408
|
if ((!delimiter || fullWidth || delimiter === ':' || delimiter === '}')
|
|
1399
1409
|
&& canonicalName
|
|
1410
|
+
&& !substs.has(canonicalName)
|
|
1400
1411
|
&& (fullWidth || delimiter === ':' || !variableIDs || variableIDs.includes(canonicalName))
|
|
1401
1412
|
&& (!fullWidth && delimiter !== ':'
|
|
1402
1413
|
|| !functionHooks
|
|
1403
1414
|
|| functionHooks.includes(canonicalName) || otherParserFunctions.has(canonicalName))) {
|
|
1404
1415
|
stream.backUp(length);
|
|
1405
1416
|
state.nExt++;
|
|
1406
|
-
chain(state, this.inParserFunctionName());
|
|
1417
|
+
chain(state, ...tokenizers, this.inParserFunctionName());
|
|
1407
1418
|
return makeLocalTagStyle('parserFunctionBracket', state);
|
|
1408
1419
|
}
|
|
1409
1420
|
}
|
|
@@ -1413,10 +1424,24 @@ let MediaWiki = (() => {
|
|
|
1413
1424
|
// Template
|
|
1414
1425
|
stream.backUp(length);
|
|
1415
1426
|
state.nTemplate++;
|
|
1416
|
-
chain(state, this.inTemplatePageName());
|
|
1427
|
+
chain(state, ...tokenizers, this.inTemplatePageName());
|
|
1417
1428
|
return makeLocalTagStyle('templateBracket', state);
|
|
1418
1429
|
}
|
|
1419
|
-
|
|
1430
|
+
inSubst(subst) {
|
|
1431
|
+
return (stream, state) => {
|
|
1432
|
+
if (subst) {
|
|
1433
|
+
stream.eatSpace();
|
|
1434
|
+
stream.match(subst);
|
|
1435
|
+
stream.backUp(1);
|
|
1436
|
+
state.tokenize = this.inSubst();
|
|
1437
|
+
return makeLocalTagStyle('parserFunctionName', state);
|
|
1438
|
+
}
|
|
1439
|
+
stream.next();
|
|
1440
|
+
pop(state);
|
|
1441
|
+
return makeLocalTagStyle('parserFunctionDelimiter', state);
|
|
1442
|
+
};
|
|
1443
|
+
}
|
|
1444
|
+
inParserFunctionName(invoke, n, ns) {
|
|
1420
1445
|
return (stream, state) => {
|
|
1421
1446
|
const sol = stream.sol(), space = stream.eatSpace();
|
|
1422
1447
|
if (stream.eol()) {
|
|
@@ -1438,9 +1463,7 @@ let MediaWiki = (() => {
|
|
|
1438
1463
|
}
|
|
1439
1464
|
const ch = stream.eat(/[::|]/u);
|
|
1440
1465
|
if (ch) {
|
|
1441
|
-
state.tokenize =
|
|
1442
|
-
? this.inParserFunctionName()
|
|
1443
|
-
: this.inParserFunctionArgument(invoke, n, ns);
|
|
1466
|
+
state.tokenize = this.inParserFunctionArgument(invoke, n, ns);
|
|
1444
1467
|
return makeLocalTagStyle(space || ch === '|' ? 'error' : 'parserFunctionDelimiter', state);
|
|
1445
1468
|
}
|
|
1446
1469
|
const mt = stream.match(/^(?:[^::}{|<>[\]\s]|\s(?![::]))+/u);
|
|
@@ -1485,9 +1508,7 @@ let MediaWiki = (() => {
|
|
|
1485
1508
|
namespace = 10;
|
|
1486
1509
|
// no default
|
|
1487
1510
|
}
|
|
1488
|
-
state.tokenize =
|
|
1489
|
-
? this.inParserFunctionName(invoke, n, ns, true)
|
|
1490
|
-
: this.inParserFunctionName(Infinity, Infinity, namespace);
|
|
1511
|
+
state.tokenize = this.inParserFunctionName(Infinity, Infinity, namespace);
|
|
1491
1512
|
}
|
|
1492
1513
|
}
|
|
1493
1514
|
return makeLocalTagStyle('parserFunctionName', state);
|
|
@@ -1637,8 +1658,8 @@ let MediaWiki = (() => {
|
|
|
1637
1658
|
return makeLocalTagStyle('convertBracket', state);
|
|
1638
1659
|
}
|
|
1639
1660
|
else if (needFlag && stream.match(/^[;\sa-z-]*(?=\|)/iu)) {
|
|
1640
|
-
|
|
1641
|
-
state
|
|
1661
|
+
state.tokenize = this.inConvert(style, false, true, plain);
|
|
1662
|
+
chain(state, this.inStr('|', 'convertDelimiter'));
|
|
1642
1663
|
return makeLocalTagStyle('convertFlag', state);
|
|
1643
1664
|
}
|
|
1644
1665
|
else if (stream.match(this.convertSemicolon)) {
|
|
@@ -1974,12 +1995,12 @@ let MediaWiki = (() => {
|
|
|
1974
1995
|
javascript() {
|
|
1975
1996
|
return javascript;
|
|
1976
1997
|
}
|
|
1977
|
-
css() {
|
|
1978
|
-
return css;
|
|
1979
|
-
}
|
|
1980
1998
|
json() {
|
|
1981
1999
|
return json;
|
|
1982
2000
|
}
|
|
2001
|
+
lua() {
|
|
2002
|
+
return lua;
|
|
2003
|
+
}
|
|
1983
2004
|
};
|
|
1984
2005
|
})();
|
|
1985
2006
|
export { MediaWiki };
|
package/dist/vue.d.ts
ADDED
package/dist/vue.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { vue } from '@codemirror/lang-vue';
|
|
2
|
+
import { htmlLanguage, htmlCompletionSource } from '@codemirror/lang-html';
|
|
3
|
+
import { javascript } from '@codemirror/lang-javascript';
|
|
4
|
+
import { LanguageSupport } from '@codemirror/language';
|
|
5
|
+
import { jsCompletion } from './javascript';
|
|
6
|
+
import css from './css';
|
|
7
|
+
export default () => vue({
|
|
8
|
+
base: new LanguageSupport(htmlLanguage, [
|
|
9
|
+
htmlLanguage.data.of({ autocomplete: htmlCompletionSource }),
|
|
10
|
+
javascript().support,
|
|
11
|
+
jsCompletion,
|
|
12
|
+
css(undefined).support,
|
|
13
|
+
]),
|
|
14
|
+
});
|