wikiparser-node 1.42.0 → 1.44.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 +45 -19
- package/bundle/bundle-es8.min.js +40 -31
- package/bundle/bundle-lsp.min.js +35 -26
- package/bundle/bundle.min.js +22 -22
- package/config/default.json +31 -0
- package/config/moegirl.json +39 -1
- package/dist/addon/attribute.js +4 -6
- package/dist/addon/link.js +3 -2
- package/dist/addon/transclude.js +16 -26
- package/dist/base.d.mts +4 -4
- package/dist/base.d.ts +4 -4
- package/dist/base.js +1 -0
- package/dist/base.mjs +1 -0
- package/dist/bin/config.js +6 -5
- package/dist/extensions/typings.d.ts +1 -1
- package/dist/index.js +8 -5
- package/dist/lib/document.d.ts +17 -14
- package/dist/lib/document.js +5 -5
- package/dist/lib/lintConfig.js +4 -1
- package/dist/lib/ranges.js +2 -2
- package/dist/lib/title.d.ts +4 -1
- package/dist/lib/title.js +5 -1
- package/dist/mixin/attributesParent.js +1 -1
- package/dist/parser/converter.js +1 -1
- package/dist/render/expand.js +4 -2
- package/dist/render/extension.js +30 -24
- package/dist/render/magicWords.js +25 -132
- package/dist/render/math.js +31 -0
- package/dist/render/syntaxhighlight.js +3 -0
- package/dist/src/arg.js +1 -2
- package/dist/src/atom.js +1 -1
- package/dist/src/attributes.d.ts +1 -0
- package/dist/src/attributes.js +27 -3
- package/dist/src/converterFlags.js +10 -5
- package/dist/src/converterRule.js +5 -7
- package/dist/src/heading.js +1 -2
- package/dist/src/imageParameter.d.ts +4 -3
- package/dist/src/imageParameter.js +16 -9
- package/dist/src/index.js +1 -1
- package/dist/src/link/base.js +1 -1
- package/dist/src/link/file.d.ts +5 -4
- package/dist/src/link/file.js +14 -12
- package/dist/src/magicLink.js +1 -2
- package/dist/src/nowiki/index.d.ts +1 -0
- package/dist/src/nowiki/index.js +40 -28
- package/dist/src/onlyinclude.js +1 -2
- package/dist/src/parameter.js +1 -2
- package/dist/src/table/index.js +1 -2
- package/dist/src/table/td.js +4 -6
- package/dist/src/tagPair/ext.d.ts +1 -0
- package/dist/src/tagPair/ext.js +36 -3
- package/dist/src/transclude.js +5 -3
- package/dist/util/search.js +24 -6
- package/dist/util/string.js +7 -1
- package/extensions/dist/base.js +1 -1
- package/extensions/dist/codejar.js +1 -1
- package/i18n/en.json +7 -0
- package/i18n/zh-hans.json +7 -0
- package/i18n/zh-hant.json +7 -0
- package/package.json +64 -21
package/config/default.json
CHANGED
|
@@ -144,6 +144,10 @@
|
|
|
144
144
|
"105": "API talk",
|
|
145
145
|
"106": "Skin",
|
|
146
146
|
"107": "Skin talk",
|
|
147
|
+
"114": "Creation",
|
|
148
|
+
"115": "Creation talk",
|
|
149
|
+
"116": "Document",
|
|
150
|
+
"117": "Document talk",
|
|
147
151
|
"118": "Draft",
|
|
148
152
|
"119": "Draft talk",
|
|
149
153
|
"126": "MOS",
|
|
@@ -375,9 +379,36 @@
|
|
|
375
379
|
"skins": 106,
|
|
376
380
|
"skin talk": 107,
|
|
377
381
|
"skins talk": 107,
|
|
382
|
+
"creation": 114,
|
|
383
|
+
"创作": 114,
|
|
384
|
+
"萌创": 114,
|
|
385
|
+
"創作": 114,
|
|
386
|
+
"萌創": 114,
|
|
387
|
+
"萌娘创作": 114,
|
|
388
|
+
"萌娘創作": 114,
|
|
389
|
+
"creation talk": 115,
|
|
390
|
+
"萌娘创作 talk": 115,
|
|
391
|
+
"创作 talk": 115,
|
|
392
|
+
"萌创 talk": 115,
|
|
393
|
+
"萌娘創作 talk": 115,
|
|
394
|
+
"創作 talk": 115,
|
|
395
|
+
"萌創 talk": 115,
|
|
396
|
+
"萌娘创作讨论": 115,
|
|
397
|
+
"萌娘創作討論": 115,
|
|
398
|
+
"document": 116,
|
|
399
|
+
"library": 116,
|
|
400
|
+
"文档": 116,
|
|
401
|
+
"文檔": 116,
|
|
402
|
+
"document talk": 117,
|
|
403
|
+
"library talk": 117,
|
|
404
|
+
"文档 talk": 117,
|
|
405
|
+
"文檔 talk": 117,
|
|
406
|
+
"文档讨论": 117,
|
|
407
|
+
"文檔討論": 117,
|
|
378
408
|
"draft": 118,
|
|
379
409
|
"草稿": 118,
|
|
380
410
|
"draft talk": 119,
|
|
411
|
+
"草稿 talk": 119,
|
|
381
412
|
"草稿讨论": 119,
|
|
382
413
|
"草稿討論": 119,
|
|
383
414
|
"mos": 126,
|
package/config/moegirl.json
CHANGED
|
@@ -110,6 +110,12 @@
|
|
|
110
110
|
"13": "Help talk",
|
|
111
111
|
"14": "Category",
|
|
112
112
|
"15": "Category talk",
|
|
113
|
+
"114": "Creation",
|
|
114
|
+
"115": "Creation talk",
|
|
115
|
+
"116": "Document",
|
|
116
|
+
"117": "Document talk",
|
|
117
|
+
"118": "Draft",
|
|
118
|
+
"119": "Draft talk",
|
|
113
119
|
"274": "Widget",
|
|
114
120
|
"275": "Widget talk",
|
|
115
121
|
"710": "TimedText",
|
|
@@ -138,6 +144,12 @@
|
|
|
138
144
|
"help talk": 13,
|
|
139
145
|
"category": 14,
|
|
140
146
|
"category talk": 15,
|
|
147
|
+
"creation": 114,
|
|
148
|
+
"creation talk": 115,
|
|
149
|
+
"document": 116,
|
|
150
|
+
"document talk": 117,
|
|
151
|
+
"draft": 118,
|
|
152
|
+
"draft talk": 119,
|
|
141
153
|
"widget": 274,
|
|
142
154
|
"widget talk": 275,
|
|
143
155
|
"timedtext": 710,
|
|
@@ -146,6 +158,14 @@
|
|
|
146
158
|
"module talk": 829,
|
|
147
159
|
"media": -2,
|
|
148
160
|
"special": -1,
|
|
161
|
+
"创作": 114,
|
|
162
|
+
"萌创": 114,
|
|
163
|
+
"文档": 116,
|
|
164
|
+
"萌娘创作 talk": 115,
|
|
165
|
+
"创作 talk": 115,
|
|
166
|
+
"萌创 talk": 115,
|
|
167
|
+
"文档 talk": 117,
|
|
168
|
+
"草稿 talk": 119,
|
|
149
169
|
"媒体": -2,
|
|
150
170
|
"媒体文件": -2,
|
|
151
171
|
"媒体档案": -2,
|
|
@@ -291,7 +311,25 @@
|
|
|
291
311
|
"模組討論": 829,
|
|
292
312
|
"模组对话": 829,
|
|
293
313
|
"模组讨论": 829,
|
|
294
|
-
"モジュール・トーク": 829
|
|
314
|
+
"モジュール・トーク": 829,
|
|
315
|
+
"創作": 114,
|
|
316
|
+
"萌創": 114,
|
|
317
|
+
"文檔": 116,
|
|
318
|
+
"萌娘創作 talk": 115,
|
|
319
|
+
"創作 talk": 115,
|
|
320
|
+
"萌創 talk": 115,
|
|
321
|
+
"文檔 talk": 117,
|
|
322
|
+
"library": 116,
|
|
323
|
+
"library talk": 117,
|
|
324
|
+
"萌娘创作": 114,
|
|
325
|
+
"萌娘创作讨论": 115,
|
|
326
|
+
"文档讨论": 117,
|
|
327
|
+
"草稿": 118,
|
|
328
|
+
"草稿讨论": 119,
|
|
329
|
+
"萌娘創作": 114,
|
|
330
|
+
"萌娘創作討論": 115,
|
|
331
|
+
"文檔討論": 117,
|
|
332
|
+
"草稿討論": 119
|
|
295
333
|
},
|
|
296
334
|
"functionHook": [
|
|
297
335
|
"ns",
|
package/dist/addon/attribute.js
CHANGED
|
@@ -31,8 +31,7 @@ attribute_1.AttributeToken.prototype.setValue =
|
|
|
31
31
|
if (value.includes('"') && value.includes(`'`)) {
|
|
32
32
|
throw new RangeError('Attribute values cannot contain single and double quotes simultaneously!');
|
|
33
33
|
}
|
|
34
|
-
|
|
35
|
-
lastChild.safeReplaceChildren(childNodes);
|
|
34
|
+
lastChild.safeReplaceChildren(index_1.default.parseWithRef(value, lastChild, attribute_1.stages[type] + 1).childNodes);
|
|
36
35
|
this.setAttribute('equal', this.isInside('parameter') ? '{{=}}' : '=');
|
|
37
36
|
if (value.includes('"')) {
|
|
38
37
|
this.setAttribute('quotes', [`'`, `'`]);
|
|
@@ -47,13 +46,12 @@ attribute_1.AttributeToken.prototype.setValue =
|
|
|
47
46
|
attribute_1.AttributeToken.prototype.rename =
|
|
48
47
|
/** @implements */
|
|
49
48
|
function (key) {
|
|
50
|
-
const { type, name,
|
|
49
|
+
const { type, name, firstChild, lastChild } = this;
|
|
51
50
|
/* c8 ignore next 3 */
|
|
52
|
-
if (
|
|
51
|
+
if (!(lastChild instanceof atom_1.AtomToken)) {
|
|
53
52
|
throw new Error(`${name} attribute cannot be renamed!`);
|
|
54
53
|
}
|
|
55
|
-
|
|
56
|
-
firstChild.safeReplaceChildren(childNodes);
|
|
54
|
+
firstChild.safeReplaceChildren(index_1.default.parseWithRef(key, this, attribute_1.stages[type] + 1).childNodes);
|
|
57
55
|
};
|
|
58
56
|
attribute_1.AttributeToken.prototype.css =
|
|
59
57
|
/** @implements */
|
package/dist/addon/link.js
CHANGED
|
@@ -15,8 +15,9 @@ const atom_1 = require("../src/atom");
|
|
|
15
15
|
base_1.LinkBaseToken.prototype.setTarget =
|
|
16
16
|
/** @implements */
|
|
17
17
|
function (link) {
|
|
18
|
-
const
|
|
19
|
-
|
|
18
|
+
const token = debug_1.Shadow.run(() => new atom_1.AtomToken(undefined, 'link-target', this.getAttribute('config'), [], { 'Stage-2': ':', '!ExtToken': '', '!HeadingToken': '' }));
|
|
19
|
+
// eslint-disable-next-line unicorn/prefer-spread
|
|
20
|
+
token.concat(index_1.default.parseWithRef(link, this, 2).childNodes);
|
|
20
21
|
this.firstChild.safeReplaceWith(token);
|
|
21
22
|
};
|
|
22
23
|
base_1.LinkBaseToken.prototype.setFragment =
|
package/dist/addon/transclude.js
CHANGED
|
@@ -26,10 +26,10 @@ const format = (token) => {
|
|
|
26
26
|
transclude_1.TranscludeToken.prototype.newAnonArg =
|
|
27
27
|
/** @implements */
|
|
28
28
|
function (val, newline) {
|
|
29
|
-
const
|
|
29
|
+
const token = debug_1.Shadow.run(
|
|
30
30
|
// @ts-expect-error abstract class
|
|
31
31
|
() => new parameter_1.ParameterToken(undefined, undefined, this.getAttribute('config')));
|
|
32
|
-
token.lastChild.concat(childNodes); // eslint-disable-line unicorn/prefer-spread
|
|
32
|
+
token.lastChild.concat(index_1.default.parseWithRef(val, this).childNodes); // eslint-disable-line unicorn/prefer-spread
|
|
33
33
|
if (newline) {
|
|
34
34
|
format(this);
|
|
35
35
|
}
|
|
@@ -47,11 +47,12 @@ transclude_1.TranscludeToken.prototype.setValue =
|
|
|
47
47
|
arg.setValue(value);
|
|
48
48
|
return;
|
|
49
49
|
}
|
|
50
|
-
const
|
|
50
|
+
const token = debug_1.Shadow.run(
|
|
51
51
|
// @ts-expect-error abstract class
|
|
52
52
|
() => new parameter_1.ParameterToken(undefined, undefined, this.getAttribute('config')));
|
|
53
|
-
token.firstChild.safeAppend(
|
|
54
|
-
|
|
53
|
+
token.firstChild.safeAppend(index_1.default.parseWithRef(key, this).childNodes);
|
|
54
|
+
// eslint-disable-next-line unicorn/prefer-spread
|
|
55
|
+
token.lastChild.concat(index_1.default.parseWithRef(value, this).childNodes);
|
|
55
56
|
if (newline) {
|
|
56
57
|
format(this);
|
|
57
58
|
}
|
|
@@ -65,41 +66,30 @@ transclude_1.TranscludeToken.prototype.replaceTemplate =
|
|
|
65
66
|
if (type === 'magic-word') {
|
|
66
67
|
throw new Error('TranscludeToken.replaceTemplate method is only for templates!');
|
|
67
68
|
}
|
|
68
|
-
|
|
69
|
-
firstChild.safeReplaceChildren(childNodes);
|
|
69
|
+
firstChild.safeReplaceChildren(index_1.default.parseWithRef(title, this, 2).childNodes);
|
|
70
70
|
};
|
|
71
71
|
transclude_1.TranscludeToken.prototype.replaceModule =
|
|
72
72
|
/** @implements */
|
|
73
73
|
function (title) {
|
|
74
|
-
const { type, name,
|
|
74
|
+
const { type, name, childNodes: [, mod] } = this;
|
|
75
75
|
/* c8 ignore next 3 */
|
|
76
76
|
if (type !== 'magic-word' || name !== 'invoke') {
|
|
77
77
|
throw new Error('TranscludeToken.replaceModule method is only for modules!');
|
|
78
78
|
}
|
|
79
|
-
|
|
80
|
-
index_2.Token.prototype.insertAt.call(this, debug_1.Shadow.run(() => new atom_1.AtomToken(undefined, 'invoke-module', this.getAttribute('config'), [], { 'Stage-1': ':', '!ExtToken': '' })));
|
|
81
|
-
return;
|
|
82
|
-
}
|
|
83
|
-
const { childNodes } = index_1.default.parseWithRef(title, this, 2);
|
|
84
|
-
mod.safeReplaceChildren(childNodes);
|
|
79
|
+
mod.safeReplaceChildren(index_1.default.parseWithRef(title, this, 2).childNodes);
|
|
85
80
|
};
|
|
86
81
|
transclude_1.TranscludeToken.prototype.replaceFunction =
|
|
87
82
|
/** @implements */
|
|
88
83
|
function (func) {
|
|
89
|
-
const { type, name, length
|
|
84
|
+
const { type, name, length } = this;
|
|
90
85
|
/* c8 ignore next 6 */
|
|
91
86
|
if (type !== 'magic-word' || name !== 'invoke') {
|
|
92
87
|
throw new Error('TranscludeToken.replaceModule method is only for modules!');
|
|
93
88
|
}
|
|
94
|
-
if (length
|
|
95
|
-
|
|
96
|
-
}
|
|
97
|
-
if (length === 2) {
|
|
98
|
-
index_2.Token.prototype.insertAt.call(this, debug_1.Shadow.run(() => new atom_1.AtomToken(undefined, 'invoke-function', this.getAttribute('config'), [], { 'Stage-1': ':', '!ExtToken': '' })));
|
|
99
|
-
return;
|
|
89
|
+
else if (length === 2) {
|
|
90
|
+
index_2.Token.prototype.insertAt.call(this, debug_1.Shadow.run(() => new atom_1.AtomToken(undefined, 'invoke-function', this.getAttribute('config'), [], { 'Stage-2': ':', '!ExtToken': '', '!HeadingToken': '' })));
|
|
100
91
|
}
|
|
101
|
-
|
|
102
|
-
fun.safeReplaceChildren(childNodes);
|
|
92
|
+
this.childNodes[2].safeReplaceChildren(index_1.default.parseWithRef(func, this, 2).childNodes);
|
|
103
93
|
};
|
|
104
94
|
transclude_1.TranscludeToken.prototype.fixDuplication =
|
|
105
95
|
/** @implements */
|
|
@@ -168,11 +158,11 @@ transclude_1.TranscludeToken.prototype.fixDuplication =
|
|
|
168
158
|
}
|
|
169
159
|
}
|
|
170
160
|
if (remaining > 1) {
|
|
171
|
-
index_1.default.error(`${this.type === 'template'
|
|
161
|
+
index_1.default.error(`${JSON.stringify(this.type === 'template'
|
|
172
162
|
? this.name
|
|
173
|
-
: this.normalizeTitle(`Module:${this.childNodes[1].text()}`, 828, { temporary: true, page: '' }).title} still has ${remaining} duplicated ${key} parameters:\n${[...this.getArgs(key)].map(arg => {
|
|
163
|
+
: this.normalizeTitle(`Module:${this.childNodes[1].text()}`, 828, { temporary: true, page: '' }).title)} still has ${remaining} duplicated ${JSON.stringify(key)} parameters:\n${[...this.getArgs(key)].map(arg => {
|
|
174
164
|
const { top, left } = arg.getBoundingClientRect();
|
|
175
|
-
return `Line ${
|
|
165
|
+
return `Line ${top} Column ${left}`;
|
|
176
166
|
}).join('\n')}`);
|
|
177
167
|
duplicatedKeys.push(key);
|
|
178
168
|
}
|
package/dist/base.d.mts
CHANGED
|
@@ -4,14 +4,14 @@ export interface Config {
|
|
|
4
4
|
readonly html: [string[], string[], string[]];
|
|
5
5
|
readonly namespaces: Record<string, string>;
|
|
6
6
|
readonly nsid: Record<string, number>;
|
|
7
|
-
readonly variable: string[];
|
|
8
|
-
readonly functionHook: string[];
|
|
9
7
|
readonly parserFunction: [Record<string, string>, Record<string, string>, string[], string[]];
|
|
10
8
|
readonly doubleUnderscore: [string[], string[], Record<string, string>, Record<string, string>];
|
|
11
9
|
readonly protocol: string;
|
|
12
10
|
readonly img: Record<string, string>;
|
|
13
11
|
readonly redirection: string[];
|
|
14
|
-
|
|
12
|
+
variable: string[];
|
|
13
|
+
functionHook: string[];
|
|
14
|
+
variants: string[];
|
|
15
15
|
articlePath?: string;
|
|
16
16
|
readonly conversionTable?: [string, string][];
|
|
17
17
|
readonly redirects?: [string, string][];
|
|
@@ -48,7 +48,7 @@ export declare const stages: {
|
|
|
48
48
|
'list-range': number;
|
|
49
49
|
};
|
|
50
50
|
export type Stage = keyof typeof stages;
|
|
51
|
-
export declare const rules: readonly ["arg-in-ext", "blank-alt", "bold-header", "format-leakage", "fostered-content", "h1", "illegal-attr", "insecure-style", "invalid-gallery", "invalid-imagemap", "invalid-invoke", "invalid-isbn", "invalid-json", "invalid-url", "lonely-apos", "lonely-bracket", "lonely-http", "nested-link", "no-arg", "no-duplicate", "no-ignored", "obsolete-attr", "obsolete-tag", "parsing-order", "pipe-like", "required-attr", "syntax-like", "table-layout", "tag-like", "unbalanced-header", "unclosed-comment", "unclosed-quote", "unclosed-table", "unescaped", "unknown-page", "unmatched-tag", "unterminated-url", "url-encoding", "var-anchor", "void-ext", "invalid-css", "invalid-math"];
|
|
51
|
+
export declare const rules: readonly ["arg-in-ext", "blank-alt", "bold-header", "format-leakage", "fostered-content", "h1", "illegal-attr", "insecure-style", "invalid-gallery", "invalid-imagemap", "invalid-invoke", "invalid-isbn", "invalid-json", "invalid-ref", "invalid-url", "lonely-apos", "lonely-bracket", "lonely-http", "nested-link", "no-arg", "no-duplicate", "no-ignored", "obsolete-attr", "obsolete-tag", "parsing-order", "pipe-like", "required-attr", "syntax-like", "table-layout", "tag-like", "unbalanced-header", "unclosed-comment", "unclosed-quote", "unclosed-table", "unescaped", "unknown-page", "unmatched-tag", "unterminated-url", "url-encoding", "var-anchor", "void-ext", "invalid-css", "invalid-math"];
|
|
52
52
|
export declare namespace LintError {
|
|
53
53
|
type Severity = 'error' | 'warning';
|
|
54
54
|
type Rule = typeof rules[number];
|
package/dist/base.d.ts
CHANGED
|
@@ -4,14 +4,14 @@ export interface Config {
|
|
|
4
4
|
readonly html: [string[], string[], string[]];
|
|
5
5
|
readonly namespaces: Record<string, string>;
|
|
6
6
|
readonly nsid: Record<string, number>;
|
|
7
|
-
readonly variable: string[];
|
|
8
|
-
readonly functionHook: string[];
|
|
9
7
|
readonly parserFunction: [Record<string, string>, Record<string, string>, string[], string[]];
|
|
10
8
|
readonly doubleUnderscore: [string[], string[], Record<string, string>, Record<string, string>];
|
|
11
9
|
readonly protocol: string;
|
|
12
10
|
readonly img: Record<string, string>;
|
|
13
11
|
readonly redirection: string[];
|
|
14
|
-
|
|
12
|
+
variable: string[];
|
|
13
|
+
functionHook: string[];
|
|
14
|
+
variants: string[];
|
|
15
15
|
articlePath?: string;
|
|
16
16
|
readonly conversionTable?: [string, string][];
|
|
17
17
|
readonly redirects?: [string, string][];
|
|
@@ -48,7 +48,7 @@ export declare const stages: {
|
|
|
48
48
|
'list-range': number;
|
|
49
49
|
};
|
|
50
50
|
export type Stage = keyof typeof stages;
|
|
51
|
-
export declare const rules: readonly ["arg-in-ext", "blank-alt", "bold-header", "format-leakage", "fostered-content", "h1", "illegal-attr", "insecure-style", "invalid-gallery", "invalid-imagemap", "invalid-invoke", "invalid-isbn", "invalid-json", "invalid-url", "lonely-apos", "lonely-bracket", "lonely-http", "nested-link", "no-arg", "no-duplicate", "no-ignored", "obsolete-attr", "obsolete-tag", "parsing-order", "pipe-like", "required-attr", "syntax-like", "table-layout", "tag-like", "unbalanced-header", "unclosed-comment", "unclosed-quote", "unclosed-table", "unescaped", "unknown-page", "unmatched-tag", "unterminated-url", "url-encoding", "var-anchor", "void-ext", "invalid-css", "invalid-math"];
|
|
51
|
+
export declare const rules: readonly ["arg-in-ext", "blank-alt", "bold-header", "format-leakage", "fostered-content", "h1", "illegal-attr", "insecure-style", "invalid-gallery", "invalid-imagemap", "invalid-invoke", "invalid-isbn", "invalid-json", "invalid-ref", "invalid-url", "lonely-apos", "lonely-bracket", "lonely-http", "nested-link", "no-arg", "no-duplicate", "no-ignored", "obsolete-attr", "obsolete-tag", "parsing-order", "pipe-like", "required-attr", "syntax-like", "table-layout", "tag-like", "unbalanced-header", "unclosed-comment", "unclosed-quote", "unclosed-table", "unescaped", "unknown-page", "unmatched-tag", "unterminated-url", "url-encoding", "var-anchor", "void-ext", "invalid-css", "invalid-math"];
|
|
52
52
|
export declare namespace LintError {
|
|
53
53
|
type Severity = 'error' | 'warning';
|
|
54
54
|
type Rule = typeof rules[number];
|
package/dist/base.js
CHANGED
package/dist/base.mjs
CHANGED
package/dist/bin/config.js
CHANGED
|
@@ -10,6 +10,7 @@ const child_process_1 = require("child_process");
|
|
|
10
10
|
const strict_1 = __importDefault(require("assert/strict"));
|
|
11
11
|
const cm_util_1 = require("@bhsd/cm-util");
|
|
12
12
|
const diff_1 = require("../util/diff");
|
|
13
|
+
const string_1 = require("../util/string");
|
|
13
14
|
/**
|
|
14
15
|
* Converts an array to an object.
|
|
15
16
|
* @param config parser configuration
|
|
@@ -40,7 +41,7 @@ const filterGadget = (id) => {
|
|
|
40
41
|
const n = Number(id);
|
|
41
42
|
return n < 2300 || n > 2303; // Gadget, Gadget talk, Gadget definition, Gadget definition talk
|
|
42
43
|
};
|
|
43
|
-
const pkg = "wikiparser-node", version = "1.
|
|
44
|
+
const pkg = "wikiparser-node", version = "1.44.0";
|
|
44
45
|
/**
|
|
45
46
|
* Get the parser configuration for a Wikimedia Foundation project.
|
|
46
47
|
* @param site site nickname
|
|
@@ -108,7 +109,7 @@ exports.default = async (site, url, user, force, internal) => {
|
|
|
108
109
|
siprop: `general|magicwords|namespaces|namespacealiases${mwConfig.functionHooks ? '' : '|functionhooks'}`,
|
|
109
110
|
format: 'json',
|
|
110
111
|
formatversion: '2',
|
|
111
|
-
}, { general: { articlepath, server, variants, langconversion }, magicwords, namespaces, namespacealiases, functionhooks, } = (await (await fetch(`${url}/api.php?${new URLSearchParams(params)
|
|
112
|
+
}, { general: { articlepath, server, variants, langconversion }, magicwords, namespaces, namespacealiases, functionhooks, } = (await (await fetch(`${url}/api.php?${String(new URLSearchParams(params))}`, headers)).json()).query, ns = Object.entries(namespaces).filter(([id]) => filterGadget(id))
|
|
112
113
|
.flatMap(([id, { name, canonical = '' }]) => [
|
|
113
114
|
[id, name],
|
|
114
115
|
...name === canonical ? [] : [[id, canonical]],
|
|
@@ -130,11 +131,11 @@ exports.default = async (site, url, user, force, internal) => {
|
|
|
130
131
|
parserFunction[2] = getAliases(magicwords, new Set(['msg', 'raw']));
|
|
131
132
|
parserFunction[3] = getAliases(magicwords, new Set(['subst', 'safesubst']));
|
|
132
133
|
if (!mwConfig.functionHooks) {
|
|
133
|
-
|
|
134
|
+
config.functionHook = [...(0, string_1.toLowerCase)(functionhooks), 'msgnw'];
|
|
134
135
|
}
|
|
135
136
|
if (!mwConfig.variableIDs) {
|
|
136
|
-
const { variables } = (await (await fetch(`${url}/api.php?${new URLSearchParams({ ...params, siprop: 'variables' })
|
|
137
|
-
|
|
137
|
+
const { variables } = (await (await fetch(`${url}/api.php?${String(new URLSearchParams({ ...params, siprop: 'variables' }))}`, headers)).json()).query;
|
|
138
|
+
config.variable = [...new Set([...variables, '='])];
|
|
138
139
|
}
|
|
139
140
|
if ('#choose' in parserFunction[0]) {
|
|
140
141
|
delete parserFunction[0]['choose'];
|
|
@@ -78,7 +78,7 @@ declare global {
|
|
|
78
78
|
dones: Set<string>,
|
|
79
79
|
key: string,
|
|
80
80
|
) => void;
|
|
81
|
-
type HideOptGroup = (optgroup
|
|
81
|
+
type HideOptGroup = (optgroup?: HTMLOptGroupElement) => void;
|
|
82
82
|
type AddOption = (
|
|
83
83
|
optgroup: HTMLOptGroupElement | undefined,
|
|
84
84
|
select: HTMLSelectElement,
|
package/dist/index.js
CHANGED
|
@@ -3,6 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
/* eslint n/exports-style: 0 */
|
|
6
|
+
const cm_util_1 = require("@bhsd/cm-util");
|
|
6
7
|
const base_1 = require("./base");
|
|
7
8
|
const debug_1 = require("./util/debug");
|
|
8
9
|
const constants_1 = require("./util/constants");
|
|
@@ -145,7 +146,8 @@ const Parser = {
|
|
|
145
146
|
return this.getConfig();
|
|
146
147
|
}
|
|
147
148
|
/* NOT FOR BROWSER ONLY END */
|
|
148
|
-
const parserConfig = config ?? this.config
|
|
149
|
+
const parserConfig = config ?? this.config;
|
|
150
|
+
const { doubleUnderscore, ext, parserFunction, variable, variants,
|
|
149
151
|
/* NOT FOR BROWSER */
|
|
150
152
|
conversionTable, redirects, } = parserConfig;
|
|
151
153
|
for (let i = 0; i < 2; i++) {
|
|
@@ -157,6 +159,7 @@ const Parser = {
|
|
|
157
159
|
variable.push('translationlanguage');
|
|
158
160
|
parserFunction[1]['TRANSLATIONLANGUAGE'] = 'translationlanguage';
|
|
159
161
|
}
|
|
162
|
+
parserConfig.variants = (0, cm_util_1.getBCP47Variants)(variants);
|
|
160
163
|
/* NOT FOR BROWSER */
|
|
161
164
|
if (conversionTable) {
|
|
162
165
|
this.conversionTable = new Map(conversionTable);
|
|
@@ -176,19 +179,19 @@ const Parser = {
|
|
|
176
179
|
&& (this.i18n[msg] ?? msg).replace('$1', this.msg(arg));
|
|
177
180
|
},
|
|
178
181
|
/** @implements */
|
|
179
|
-
normalizeTitle(title, defaultNs = 0, include, config = Parser.getConfig(), opt) {
|
|
182
|
+
normalizeTitle(title, defaultNs = 0, include, config = Parser.getConfig(), opt, accum = []) {
|
|
180
183
|
let titleObj;
|
|
181
184
|
if (opt?.halfParsed) {
|
|
182
|
-
titleObj = new title_1.Title(title, defaultNs, config, opt);
|
|
185
|
+
titleObj = new title_1.Title(title, defaultNs, config, opt, accum);
|
|
183
186
|
}
|
|
184
187
|
else {
|
|
185
188
|
const { Token } = require('./src/index');
|
|
186
189
|
titleObj = debug_1.Shadow.run(() => {
|
|
187
|
-
const root = new Token(title, config);
|
|
190
|
+
const root = new Token(title, config, accum);
|
|
188
191
|
root.type = 'root';
|
|
189
192
|
root.pageName = opt?.page;
|
|
190
193
|
root.parseOnce(0, include).parseOnce();
|
|
191
|
-
const t = new title_1.Title(root.firstChild.toString(), defaultNs, config, opt);
|
|
194
|
+
const t = new title_1.Title(root.firstChild.toString(), defaultNs, config, opt, accum);
|
|
192
195
|
root.build();
|
|
193
196
|
const keys = [
|
|
194
197
|
'main',
|
package/dist/lib/document.d.ts
CHANGED
|
@@ -10,23 +10,26 @@ export interface TexvcLocation {
|
|
|
10
10
|
line: number;
|
|
11
11
|
column: number;
|
|
12
12
|
}
|
|
13
|
+
export type TexvcReport = {
|
|
14
|
+
status: '+';
|
|
15
|
+
output: string;
|
|
16
|
+
} | {
|
|
17
|
+
status: 'C';
|
|
18
|
+
} | {
|
|
19
|
+
status: 'F' | 'S';
|
|
20
|
+
error: {
|
|
21
|
+
message: string;
|
|
22
|
+
location: {
|
|
23
|
+
start: TexvcLocation;
|
|
24
|
+
end: TexvcLocation;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
};
|
|
13
28
|
declare interface Texvcjs {
|
|
14
29
|
check(input: string, options?: {
|
|
30
|
+
usemathrm?: boolean;
|
|
15
31
|
usemhchem?: boolean;
|
|
16
|
-
}):
|
|
17
|
-
status: '+';
|
|
18
|
-
} | {
|
|
19
|
-
status: 'C';
|
|
20
|
-
} | {
|
|
21
|
-
status: 'F' | 'S';
|
|
22
|
-
error: {
|
|
23
|
-
message: string;
|
|
24
|
-
location: {
|
|
25
|
-
start: TexvcLocation;
|
|
26
|
-
end: TexvcLocation;
|
|
27
|
-
};
|
|
28
|
-
};
|
|
29
|
-
};
|
|
32
|
+
}): TexvcReport;
|
|
30
33
|
}
|
|
31
34
|
export declare const loadTexvcjs: () => Texvcjs | null;
|
|
32
35
|
export declare const loadJsonLSP: () => JSONLanguageService | null;
|
package/dist/lib/document.js
CHANGED
|
@@ -9,19 +9,19 @@ const common_1 = require("@bhsd/common");
|
|
|
9
9
|
const constants_1 = require("../util/constants");
|
|
10
10
|
/* NOT FOR BROWSER */
|
|
11
11
|
const constants_2 = require("../util/constants");
|
|
12
|
-
let
|
|
12
|
+
let texvcjs;
|
|
13
13
|
const loadTexvcjs = () => {
|
|
14
14
|
NPM: {
|
|
15
|
-
if (
|
|
15
|
+
if (texvcjs === undefined) {
|
|
16
16
|
try {
|
|
17
|
-
|
|
17
|
+
texvcjs = require('mathoid-texvcjs');
|
|
18
18
|
}
|
|
19
19
|
catch /* c8 ignore start */ {
|
|
20
|
-
|
|
20
|
+
texvcjs = null;
|
|
21
21
|
}
|
|
22
22
|
/* c8 ignore stop */
|
|
23
23
|
}
|
|
24
|
-
return
|
|
24
|
+
return texvcjs;
|
|
25
25
|
}
|
|
26
26
|
};
|
|
27
27
|
exports.loadTexvcjs = loadTexvcjs;
|
package/dist/lib/lintConfig.js
CHANGED
|
@@ -82,6 +82,7 @@ const defaultLintRuleConfig = {
|
|
|
82
82
|
duplicate: 1,
|
|
83
83
|
},
|
|
84
84
|
],
|
|
85
|
+
'invalid-ref': [2],
|
|
85
86
|
'invalid-url': [1],
|
|
86
87
|
'lonely-apos': [
|
|
87
88
|
1,
|
|
@@ -237,9 +238,11 @@ const defaultLintRuleConfig = {
|
|
|
237
238
|
'void-ext': [
|
|
238
239
|
2,
|
|
239
240
|
{
|
|
240
|
-
//
|
|
241
|
+
// dynamicpagelist: 2,
|
|
241
242
|
// languages: 2,
|
|
243
|
+
// rss: 2,
|
|
242
244
|
// section: 2,
|
|
245
|
+
// templatedata: 2,
|
|
243
246
|
// templatestyles: 2,
|
|
244
247
|
},
|
|
245
248
|
],
|
package/dist/lib/ranges.js
CHANGED
|
@@ -47,13 +47,13 @@ class Range {
|
|
|
47
47
|
.exec(str);
|
|
48
48
|
/* c8 ignore next 3 */
|
|
49
49
|
if (!mt) {
|
|
50
|
-
throw new RangeError(`The argument
|
|
50
|
+
throw new RangeError(`The argument ${JSON.stringify(str)} should be either in the form of "an+b" as in CSS selectors or Python slices!`);
|
|
51
51
|
}
|
|
52
52
|
const [, sgnA = '+', a = 1, sgnB = '+'] = mt, b = Number(mt[4] ?? 0);
|
|
53
53
|
this.step = Number(a);
|
|
54
54
|
/* c8 ignore next 3 */
|
|
55
55
|
if (this.step === 0) {
|
|
56
|
-
throw new RangeError(`In the argument
|
|
56
|
+
throw new RangeError(`In the argument ${JSON.stringify(str)}, the coefficient of "n" must not be 0!`);
|
|
57
57
|
}
|
|
58
58
|
else if (sgnA === '+') { // `an+b` or `an-b`
|
|
59
59
|
this.start = sgnB === '+' || b === 0 ? b : this.step - 1 - (b - 1) % this.step;
|
package/dist/lib/title.d.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import type { Config } from '../base';
|
|
2
|
+
import type { Token } from '../internal';
|
|
2
3
|
export interface TitleOptions {
|
|
3
4
|
temporary?: boolean | undefined;
|
|
4
5
|
decode?: boolean | undefined;
|
|
5
6
|
selfLink?: boolean | undefined;
|
|
6
7
|
halfParsed?: boolean | undefined;
|
|
7
8
|
page?: string | undefined;
|
|
9
|
+
nowiki?: boolean;
|
|
8
10
|
}
|
|
9
11
|
/**
|
|
10
12
|
* title object of a MediaWiki page
|
|
@@ -55,8 +57,9 @@ export declare class Title {
|
|
|
55
57
|
* @param opt.decode 是否需要解码
|
|
56
58
|
* @param opt.selfLink 是否允许selfLink
|
|
57
59
|
* @param opt.page 当前页面标题
|
|
60
|
+
* @param opt.nowiki 是否剥离nowiki标签
|
|
58
61
|
*/
|
|
59
|
-
constructor(title: string, defaultNs: number, config: Config, { temporary, decode, selfLink, page }?: TitleOptions);
|
|
62
|
+
constructor(title: string, defaultNs: number, config: Config, { temporary, decode, selfLink, page, nowiki }?: TitleOptions, accum?: Token[]);
|
|
60
63
|
/**
|
|
61
64
|
* Check if the title is a redirect and get the redirect target
|
|
62
65
|
*
|
package/dist/lib/title.js
CHANGED
|
@@ -123,9 +123,13 @@ class Title {
|
|
|
123
123
|
* @param opt.decode 是否需要解码
|
|
124
124
|
* @param opt.selfLink 是否允许selfLink
|
|
125
125
|
* @param opt.page 当前页面标题
|
|
126
|
+
* @param opt.nowiki 是否剥离nowiki标签
|
|
126
127
|
*/
|
|
127
|
-
constructor(title, defaultNs, config, { temporary, decode, selfLink, page } = {}) {
|
|
128
|
+
constructor(title, defaultNs, config, { temporary, decode, selfLink, page, nowiki } = {}, accum = []) {
|
|
128
129
|
this.page = page;
|
|
130
|
+
if (nowiki) {
|
|
131
|
+
title = title.replace(/\0(\d+)e\x7F/gu, (_, p1) => accum[p1].innerText ?? '');
|
|
132
|
+
}
|
|
129
133
|
const trimmed = title.trim(), subpage = trimmed.startsWith('../');
|
|
130
134
|
if (decode && title.includes('%')) {
|
|
131
135
|
try {
|
|
@@ -39,7 +39,7 @@ const attributesParent = (i = 0) => (constructor) => {
|
|
|
39
39
|
return this.childNodes[i];
|
|
40
40
|
}
|
|
41
41
|
hasAttr(key) {
|
|
42
|
-
|
|
42
|
+
return this.#getAttributesChild().hasAttr(key);
|
|
43
43
|
}
|
|
44
44
|
getAttr(key) {
|
|
45
45
|
return this.#getAttributesChild().getAttr(key);
|
package/dist/parser/converter.js
CHANGED
|
@@ -14,7 +14,7 @@ const constants_1 = require("../util/constants");
|
|
|
14
14
|
const parseConverter = (text, config, accum) => {
|
|
15
15
|
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
|
|
16
16
|
/;(?=(?:[^;]*?=>)?\s*zh\s*:|(?:\s|\0\d+[cn]\x7F)*$)/u;
|
|
17
|
-
config.regexConverter ??= new RegExp(String.raw `;(?=(?:[^;]*?=>)?\s*(?:${config.variants.join('|')})\s*:|(?:\s|\0\d+[cn]\x7F)*$)`, '
|
|
17
|
+
config.regexConverter ??= new RegExp(String.raw `;(?=(?:[^;]*?=>)?\s*(?:${config.variants.join('|')})\s*:|(?:\s|\0\d+[cn]\x7F)*$)`, 'u');
|
|
18
18
|
const regex1 = /-\{/gu, regex2 = /-\{|\}-/gu, stack = [];
|
|
19
19
|
let regex = regex1, mt = regex.exec(text);
|
|
20
20
|
while (mt) {
|
package/dist/render/expand.js
CHANGED
|
@@ -186,7 +186,7 @@ const expand = (wikitext, page, callPage, config, include, context, now = index_
|
|
|
186
186
|
clean(accum, args);
|
|
187
187
|
return implicitNewLine(constants_1.functionHooks.get(name)(target, context || undefined), prev);
|
|
188
188
|
}
|
|
189
|
-
|
|
189
|
+
try {
|
|
190
190
|
const result = (0, magicWords_1.expandMagicWord)(name, args.map(({ anon, name: key, value }) => anon ? value : `${key}=${value}`), callPage, config, now, accum);
|
|
191
191
|
if (result === false) {
|
|
192
192
|
return m;
|
|
@@ -194,7 +194,9 @@ const expand = (wikitext, page, callPage, config, include, context, now = index_
|
|
|
194
194
|
clean(accum, args);
|
|
195
195
|
return implicitNewLine(result, prev);
|
|
196
196
|
}
|
|
197
|
-
|
|
197
|
+
catch {
|
|
198
|
+
return m;
|
|
199
|
+
}
|
|
198
200
|
});
|
|
199
201
|
plain.setText(expanded);
|
|
200
202
|
if (plain.type === 'parameter-key') {
|