wikiparser-node 1.40.0 → 1.41.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 +50 -4
- package/bundle/bundle-es8.min.js +22 -22
- package/bundle/bundle-lsp.min.js +27 -27
- package/bundle/bundle.min.js +13 -13
- package/config/.schema.json +5 -0
- package/config/default.json +1 -1
- package/config/enwiki.json +3 -2
- package/config/jawiki.json +6 -5
- package/config/llwiki.json +2 -1
- package/config/minimum.json +1 -1
- package/config/moegirl.json +2 -1
- package/config/zhwiki.json +3 -2
- package/dist/base.d.mts +5 -3
- package/dist/base.d.ts +5 -3
- package/dist/bin/config.js +11 -10
- package/dist/lib/lintConfig.js +30 -23
- package/dist/lib/text.js +1 -1
- package/dist/render/magicWords.js +6 -3
- package/dist/src/attribute.js +1 -1
- package/dist/src/attributes.js +5 -5
- package/dist/util/sharable.js +2 -0
- package/dist/util/sharable.mjs +3 -1
- package/extensions/dist/base.js +1 -1
- package/extensions/dist/env.js +34 -0
- package/package.json +17 -18
package/dist/base.d.mts
CHANGED
|
@@ -9,13 +9,14 @@ export interface Config {
|
|
|
9
9
|
readonly parserFunction: [Record<string, string>, Record<string, string>, string[], string[]];
|
|
10
10
|
readonly doubleUnderscore: [string[], string[], Record<string, string>, Record<string, string>];
|
|
11
11
|
readonly protocol: string;
|
|
12
|
-
readonly interwiki: string[];
|
|
13
12
|
readonly img: Record<string, string>;
|
|
14
13
|
readonly redirection: string[];
|
|
15
14
|
readonly variants: string[];
|
|
16
15
|
articlePath?: string;
|
|
17
16
|
readonly conversionTable?: [string, string][];
|
|
18
17
|
readonly redirects?: [string, string][];
|
|
18
|
+
readonly interwiki: string[];
|
|
19
|
+
server?: string;
|
|
19
20
|
}
|
|
20
21
|
export type ConfigData = Omit<Config, 'excludes'>;
|
|
21
22
|
export type TokenTypes = 'root' | 'plain' | 'redirect' | 'redirect-syntax' | 'redirect-target' | 'translate' | 'translate-attr' | 'translate-inner' | 'tvar' | 'tvar-name' | 'onlyinclude' | 'noinclude' | 'include' | 'comment' | 'ext' | 'ext-attrs' | 'ext-attr-dirty' | 'ext-attr' | 'attr-key' | 'attr-value' | 'ext-inner' | 'arg' | 'arg-name' | 'arg-default' | 'hidden' | 'magic-word' | 'magic-word-name' | 'invoke-function' | 'invoke-module' | 'template' | 'template-name' | 'parameter' | 'parameter-key' | 'parameter-value' | 'heading' | 'heading-title' | 'heading-trail' | 'html' | 'html-attrs' | 'html-attr-dirty' | 'html-attr' | 'table' | 'tr' | 'td' | 'table-syntax' | 'table-attrs' | 'table-attr-dirty' | 'table-attr' | 'table-inter' | 'td-inner' | 'hr' | 'double-underscore' | 'link' | 'link-target' | 'link-text' | 'category' | 'file' | 'gallery-image' | 'imagemap-image' | 'image-parameter' | 'quote' | 'ext-link' | 'ext-link-text' | 'ext-link-url' | 'free-ext-link' | 'magic-link' | 'list' | 'dd' | 'converter' | 'converter-flags' | 'converter-flag' | 'converter-rule' | 'converter-rule-variant' | 'converter-rule-to' | 'converter-rule-from' | 'param-line' | 'imagemap-link' | 'list-range';
|
|
@@ -298,8 +299,9 @@ export interface LanguageService {
|
|
|
298
299
|
[Symbol.dispose](): void;
|
|
299
300
|
}
|
|
300
301
|
export type SeverityLevel = 0 | 1 | 2 | false | 'off' | 'warning' | 'error';
|
|
301
|
-
export type
|
|
302
|
-
export type
|
|
302
|
+
export type FullLintConfigValue = [SeverityLevel, Record<string, SeverityLevel>?];
|
|
303
|
+
export type LintConfigValue = SeverityLevel | FullLintConfigValue | Record<string, SeverityLevel>;
|
|
304
|
+
export type LintRuleConfig<T = LintConfigValue> = Partial<Record<LintError.Rule, T>>;
|
|
303
305
|
export interface FullLintConfig {
|
|
304
306
|
rules: LintRuleConfig;
|
|
305
307
|
configurationComment?: string;
|
package/dist/base.d.ts
CHANGED
|
@@ -9,13 +9,14 @@ export interface Config {
|
|
|
9
9
|
readonly parserFunction: [Record<string, string>, Record<string, string>, string[], string[]];
|
|
10
10
|
readonly doubleUnderscore: [string[], string[], Record<string, string>, Record<string, string>];
|
|
11
11
|
readonly protocol: string;
|
|
12
|
-
readonly interwiki: string[];
|
|
13
12
|
readonly img: Record<string, string>;
|
|
14
13
|
readonly redirection: string[];
|
|
15
14
|
readonly variants: string[];
|
|
16
15
|
articlePath?: string;
|
|
17
16
|
readonly conversionTable?: [string, string][];
|
|
18
17
|
readonly redirects?: [string, string][];
|
|
18
|
+
readonly interwiki: string[];
|
|
19
|
+
server?: string;
|
|
19
20
|
}
|
|
20
21
|
export type ConfigData = Omit<Config, 'excludes'>;
|
|
21
22
|
export type TokenTypes = 'root' | 'plain' | 'redirect' | 'redirect-syntax' | 'redirect-target' | 'translate' | 'translate-attr' | 'translate-inner' | 'tvar' | 'tvar-name' | 'onlyinclude' | 'noinclude' | 'include' | 'comment' | 'ext' | 'ext-attrs' | 'ext-attr-dirty' | 'ext-attr' | 'attr-key' | 'attr-value' | 'ext-inner' | 'arg' | 'arg-name' | 'arg-default' | 'hidden' | 'magic-word' | 'magic-word-name' | 'invoke-function' | 'invoke-module' | 'template' | 'template-name' | 'parameter' | 'parameter-key' | 'parameter-value' | 'heading' | 'heading-title' | 'heading-trail' | 'html' | 'html-attrs' | 'html-attr-dirty' | 'html-attr' | 'table' | 'tr' | 'td' | 'table-syntax' | 'table-attrs' | 'table-attr-dirty' | 'table-attr' | 'table-inter' | 'td-inner' | 'hr' | 'double-underscore' | 'link' | 'link-target' | 'link-text' | 'category' | 'file' | 'gallery-image' | 'imagemap-image' | 'image-parameter' | 'quote' | 'ext-link' | 'ext-link-text' | 'ext-link-url' | 'free-ext-link' | 'magic-link' | 'list' | 'dd' | 'converter' | 'converter-flags' | 'converter-flag' | 'converter-rule' | 'converter-rule-variant' | 'converter-rule-to' | 'converter-rule-from' | 'param-line' | 'imagemap-link' | 'list-range';
|
|
@@ -298,8 +299,9 @@ export interface LanguageService {
|
|
|
298
299
|
[Symbol.dispose](): void;
|
|
299
300
|
}
|
|
300
301
|
export type SeverityLevel = 0 | 1 | 2 | false | 'off' | 'warning' | 'error';
|
|
301
|
-
export type
|
|
302
|
-
export type
|
|
302
|
+
export type FullLintConfigValue = [SeverityLevel, Record<string, SeverityLevel>?];
|
|
303
|
+
export type LintConfigValue = SeverityLevel | FullLintConfigValue | Record<string, SeverityLevel>;
|
|
304
|
+
export type LintRuleConfig<T = LintConfigValue> = Partial<Record<LintError.Rule, T>>;
|
|
303
305
|
export interface FullLintConfig {
|
|
304
306
|
rules: LintRuleConfig;
|
|
305
307
|
configurationComment?: string;
|
package/dist/bin/config.js
CHANGED
|
@@ -40,7 +40,7 @@ const filterGadget = (id) => {
|
|
|
40
40
|
const n = Number(id);
|
|
41
41
|
return n < 2300 || n > 2303; // Gadget, Gadget talk, Gadget definition, Gadget definition talk
|
|
42
42
|
};
|
|
43
|
-
const pkg = "wikiparser-node", version = "1.
|
|
43
|
+
const pkg = "wikiparser-node", version = "1.41.0";
|
|
44
44
|
/**
|
|
45
45
|
* Get the parser configuration for a Wikimedia Foundation project.
|
|
46
46
|
* @param site site nickname
|
|
@@ -78,13 +78,7 @@ exports.default = async (site, url, user, force, internal) => {
|
|
|
78
78
|
'User-Agent': `${pkg}/${version} (https://www.npmjs.com/package/${pkg}; ${user}) Node.js/${process.version}`,
|
|
79
79
|
},
|
|
80
80
|
}
|
|
81
|
-
: undefined, m = await (await fetch(`${url}/load.php?modules=ext.CodeMirror.data|ext.CodeMirror`, headers)).text(),
|
|
82
|
-
action: 'query',
|
|
83
|
-
meta: 'siteinfo',
|
|
84
|
-
siprop: 'general|magicwords|functionhooks|namespaces|namespacealiases',
|
|
85
|
-
format: 'json',
|
|
86
|
-
formatversion: '2',
|
|
87
|
-
}, { general: { articlepath, variants, langconversion }, magicwords, namespaces, namespacealiases, functionhooks, } = (await (await fetch(`${url}/api.php?${new URLSearchParams(params).toString()}`, headers)).json()).query, tempFile = path_1.default.join(__dirname, 'mw.js');
|
|
81
|
+
: undefined, m = await (await fetch(`${url}/load.php?modules=ext.CodeMirror.data|ext.CodeMirror`, headers)).text(), tempFile = path_1.default.join(__dirname, 'mw.js');
|
|
88
82
|
fs_1.default.writeFileSync(tempFile, m);
|
|
89
83
|
const { stdout, stderr } = (0, child_process_1.spawnSync)(process.execPath, [
|
|
90
84
|
'-r',
|
|
@@ -108,13 +102,19 @@ exports.default = async (site, url, user, force, internal) => {
|
|
|
108
102
|
catch {
|
|
109
103
|
throw new RangeError('Extension:CodeMirror is not installed!');
|
|
110
104
|
}
|
|
111
|
-
const
|
|
105
|
+
const params = {
|
|
106
|
+
action: 'query',
|
|
107
|
+
meta: 'siteinfo',
|
|
108
|
+
siprop: `general|magicwords|namespaces|namespacealiases${mwConfig.functionHooks ? '' : '|functionhooks'}`,
|
|
109
|
+
format: 'json',
|
|
110
|
+
formatversion: '2',
|
|
111
|
+
}, { general: { articlepath, server, variants, langconversion }, magicwords, namespaces, namespacealiases, functionhooks, } = (await (await fetch(`${url}/api.php?${new URLSearchParams(params).toString()}`, headers)).json()).query, ns = Object.entries(namespaces).filter(([id]) => filterGadget(id))
|
|
112
112
|
.flatMap(([id, { name, canonical = '' }]) => [
|
|
113
113
|
[id, name],
|
|
114
114
|
...name === canonical ? [] : [[id, canonical]],
|
|
115
115
|
]), config = {
|
|
116
116
|
...(0, cm_util_1.getParserConfig)(require(path_1.default.join(dir, 'minimum.json')), mwConfig),
|
|
117
|
-
|
|
117
|
+
...!(mwConfig.imageKeywords && mwConfig.redirection) && (0, cm_util_1.getKeywords)(magicwords),
|
|
118
118
|
variants: langconversion ? (0, cm_util_1.getVariants)(variants) : [],
|
|
119
119
|
namespaces: Object.fromEntries(ns),
|
|
120
120
|
nsid: Object.fromEntries([
|
|
@@ -122,6 +122,7 @@ exports.default = async (site, url, user, force, internal) => {
|
|
|
122
122
|
...namespacealiases.filter(({ id }) => filterGadget(id)).map(({ id, alias }) => [alias.toLowerCase(), id]),
|
|
123
123
|
]),
|
|
124
124
|
articlePath: articlepath,
|
|
125
|
+
server,
|
|
125
126
|
}, { doubleUnderscore, parserFunction, variable } = config;
|
|
126
127
|
doubleUnderscore[0] = [];
|
|
127
128
|
doubleUnderscore[1] = [];
|
package/dist/lib/lintConfig.js
CHANGED
|
@@ -15,8 +15,8 @@ const dict = new Map([
|
|
|
15
15
|
['error', 'error'],
|
|
16
16
|
]);
|
|
17
17
|
const defaultLintRuleConfig = {
|
|
18
|
-
'arg-in-ext': 1,
|
|
19
|
-
'blank-alt': 1,
|
|
18
|
+
'arg-in-ext': [1],
|
|
19
|
+
'blank-alt': [1],
|
|
20
20
|
'bold-header': [
|
|
21
21
|
1,
|
|
22
22
|
{
|
|
@@ -50,7 +50,7 @@ const defaultLintRuleConfig = {
|
|
|
50
50
|
// value: 2,
|
|
51
51
|
},
|
|
52
52
|
],
|
|
53
|
-
'insecure-style': 2,
|
|
53
|
+
'insecure-style': [2],
|
|
54
54
|
'invalid-gallery': [
|
|
55
55
|
2,
|
|
56
56
|
{
|
|
@@ -75,14 +75,14 @@ const defaultLintRuleConfig = {
|
|
|
75
75
|
// name: 2,
|
|
76
76
|
},
|
|
77
77
|
],
|
|
78
|
-
'invalid-isbn': 2,
|
|
78
|
+
'invalid-isbn': [2],
|
|
79
79
|
'invalid-json': [
|
|
80
80
|
2,
|
|
81
81
|
{
|
|
82
82
|
duplicate: 1,
|
|
83
83
|
},
|
|
84
84
|
],
|
|
85
|
-
'invalid-url': 1,
|
|
85
|
+
'invalid-url': [1],
|
|
86
86
|
'lonely-apos': [
|
|
87
87
|
1,
|
|
88
88
|
{
|
|
@@ -113,7 +113,7 @@ const defaultLintRuleConfig = {
|
|
|
113
113
|
// ref: 2,
|
|
114
114
|
},
|
|
115
115
|
],
|
|
116
|
-
'no-arg': 1,
|
|
116
|
+
'no-arg': [1],
|
|
117
117
|
'no-duplicate': [
|
|
118
118
|
2,
|
|
119
119
|
{
|
|
@@ -147,8 +147,8 @@ const defaultLintRuleConfig = {
|
|
|
147
147
|
// references: 2,
|
|
148
148
|
},
|
|
149
149
|
],
|
|
150
|
-
'obsolete-attr': 1,
|
|
151
|
-
'obsolete-tag': 1,
|
|
150
|
+
'obsolete-attr': [1],
|
|
151
|
+
'obsolete-tag': [1],
|
|
152
152
|
'parsing-order': [
|
|
153
153
|
2,
|
|
154
154
|
{
|
|
@@ -185,7 +185,7 @@ const defaultLintRuleConfig = {
|
|
|
185
185
|
// redirect: 2,
|
|
186
186
|
},
|
|
187
187
|
],
|
|
188
|
-
'table-layout': 1,
|
|
188
|
+
'table-layout': [1],
|
|
189
189
|
'tag-like': [
|
|
190
190
|
2,
|
|
191
191
|
{
|
|
@@ -193,17 +193,17 @@ const defaultLintRuleConfig = {
|
|
|
193
193
|
invalid: 1,
|
|
194
194
|
},
|
|
195
195
|
],
|
|
196
|
-
'unbalanced-header': 2,
|
|
196
|
+
'unbalanced-header': [2],
|
|
197
197
|
'unclosed-comment': [
|
|
198
198
|
1,
|
|
199
199
|
{
|
|
200
200
|
// include: 1,
|
|
201
201
|
},
|
|
202
202
|
],
|
|
203
|
-
'unclosed-quote': 1,
|
|
204
|
-
'unclosed-table': 2,
|
|
205
|
-
unescaped: 2,
|
|
206
|
-
'unknown-page': 1,
|
|
203
|
+
'unclosed-quote': [1],
|
|
204
|
+
'unclosed-table': [2],
|
|
205
|
+
unescaped: [2],
|
|
206
|
+
'unknown-page': [1],
|
|
207
207
|
'unmatched-tag': [
|
|
208
208
|
1,
|
|
209
209
|
{
|
|
@@ -250,7 +250,7 @@ const defaultLintRuleConfig = {
|
|
|
250
250
|
warn: 1,
|
|
251
251
|
},
|
|
252
252
|
],
|
|
253
|
-
'invalid-math': 2,
|
|
253
|
+
'invalid-math': [2],
|
|
254
254
|
};
|
|
255
255
|
const defaultLintConfig = {
|
|
256
256
|
configurationComment: 'lint',
|
|
@@ -267,8 +267,9 @@ const validateSeverity = (severity) => dict.has(severity);
|
|
|
267
267
|
* 验证设置值是否符合规范
|
|
268
268
|
* @param value 设置值
|
|
269
269
|
*/
|
|
270
|
-
const validateConfigValue = (value) => validateSeverity(value)
|
|
271
|
-
|
|
270
|
+
const validateConfigValue = (value) => validateSeverity(value) || (Array.isArray(value)
|
|
271
|
+
? validateSeverity(value[0]) && (value.length === 1 || typeof value[1] === 'object')
|
|
272
|
+
: typeof value === 'object');
|
|
272
273
|
/**
|
|
273
274
|
* 设置语法检查规则
|
|
274
275
|
* @param obj 语法检查设置对象
|
|
@@ -285,7 +286,16 @@ const set = (obj, key, value) => {
|
|
|
285
286
|
return false;
|
|
286
287
|
}
|
|
287
288
|
if (validateConfigValue(value)) {
|
|
288
|
-
|
|
289
|
+
if (Array.isArray(value)) {
|
|
290
|
+
obj[key] = value;
|
|
291
|
+
}
|
|
292
|
+
else if (typeof value === 'object') {
|
|
293
|
+
const [base, options = {}] = defaultLintRuleConfig[key];
|
|
294
|
+
obj[key] = [base, { ...clone(options), ...value }];
|
|
295
|
+
}
|
|
296
|
+
else {
|
|
297
|
+
obj[key] = [value];
|
|
298
|
+
}
|
|
289
299
|
return true;
|
|
290
300
|
}
|
|
291
301
|
/* c8 ignore next */
|
|
@@ -308,11 +318,8 @@ class LintRuleConfiguration {
|
|
|
308
318
|
}
|
|
309
319
|
/** @implements */
|
|
310
320
|
getSeverity(rule, key) {
|
|
311
|
-
const
|
|
312
|
-
|
|
313
|
-
return dict.get(value);
|
|
314
|
-
}
|
|
315
|
-
return key ? dict.get(value[1]?.[key]) ?? dict.get(value[0]) : dict.get(value[0]);
|
|
321
|
+
const [base, options] = this[rule], severity = dict.get(base);
|
|
322
|
+
return key ? dict.get(options?.[key]) ?? severity : severity;
|
|
316
323
|
}
|
|
317
324
|
}
|
|
318
325
|
/** 语法检查设置 */
|
package/dist/lib/text.js
CHANGED
|
@@ -220,7 +220,7 @@ let AstText = (() => {
|
|
|
220
220
|
return [];
|
|
221
221
|
}
|
|
222
222
|
errorRegex.lastIndex = 0;
|
|
223
|
-
const errors = [], nextType = nextSibling?.type, nextName = nextSibling?.name, previousType = previousSibling?.type, root = this.getRootNode(), rootStr = root.toString(), { ext, html, variants } = root.getAttribute('config'), { top, left } = root.posFromIndex(start), { lintConfig } = index_1.default, tagLike = lintConfig.rules['tag-like'], specified =
|
|
223
|
+
const errors = [], nextType = nextSibling?.type, nextName = nextSibling?.name, previousType = previousSibling?.type, root = this.getRootNode(), rootStr = root.toString(), { ext, html, variants } = root.getAttribute('config'), { top, left } = root.posFromIndex(start), { lintConfig } = index_1.default, tagLike = lintConfig.rules['tag-like'], specified = tagLike[1]
|
|
224
224
|
? new Set(Object.keys(tagLike[1]).filter(tag => tag !== 'invalid' && tag !== 'disallowed'))
|
|
225
225
|
: new Set(), tags = new Set([
|
|
226
226
|
'onlyinclude',
|
|
@@ -150,7 +150,7 @@ function urlFunction(config, args, local) {
|
|
|
150
150
|
title.ns = 6;
|
|
151
151
|
title.fragment = undefined;
|
|
152
152
|
}
|
|
153
|
-
const link = title.getUrl(
|
|
153
|
+
const { articlePath, server = '' } = config, path = articlePath && (/^\/(?!\/)/u.test(articlePath) ? server : '') + articlePath, link = title.getUrl(path), protocol = link.startsWith('//') ? 'https:' : '';
|
|
154
154
|
try {
|
|
155
155
|
const url = new URL(protocol + link);
|
|
156
156
|
url.search = query ? `?${query.replaceAll(/\s/gu, '_')}` : '';
|
|
@@ -159,12 +159,15 @@ function urlFunction(config, args, local) {
|
|
|
159
159
|
catch (e) {
|
|
160
160
|
if (local) {
|
|
161
161
|
title.fragment = undefined;
|
|
162
|
-
return title.getUrl(
|
|
162
|
+
return title.getUrl(path) + (query ? `?${query}` : '');
|
|
163
163
|
}
|
|
164
164
|
throw e;
|
|
165
165
|
}
|
|
166
166
|
}
|
|
167
|
-
const parseUrl = ({
|
|
167
|
+
const parseUrl = ({ server = '', articlePath = '' }) => {
|
|
168
|
+
if (/^\/(?!\/)/u.test(articlePath)) {
|
|
169
|
+
articlePath = server + articlePath;
|
|
170
|
+
}
|
|
168
171
|
let offset = 0;
|
|
169
172
|
if (articlePath.startsWith('//')) {
|
|
170
173
|
offset = 6;
|
package/dist/src/attribute.js
CHANGED
|
@@ -279,7 +279,7 @@ let AttributeToken = (() => {
|
|
|
279
279
|
}
|
|
280
280
|
else if (typeof value === 'string' && ((/^xmlns:[\w:.-]+$/u.test(name) || urlAttrs.has(name)) && evil.test(value)
|
|
281
281
|
|| simple
|
|
282
|
-
&& (name === 'href' || tag === 'img' && name === 'src')
|
|
282
|
+
&& (name === 'href' || type === 'ext-attr' && tag === 'img' && name === 'src')
|
|
283
283
|
&& !new RegExp(String.raw `^(?:${this.getAttribute('config').protocol}|//)\S+$`, 'iu')
|
|
284
284
|
.test(value))) {
|
|
285
285
|
/* PRINT ONLY */
|
package/dist/src/attributes.js
CHANGED
|
@@ -263,7 +263,7 @@ let AttributesToken = (() => {
|
|
|
263
263
|
/** @private */
|
|
264
264
|
lint(start = this.getAbsoluteIndex(), re) {
|
|
265
265
|
LINT: {
|
|
266
|
-
const errors = super.lint(start, re), { parentNode, childNodes, type, name: tag } = this, attrs = new Map(), duplicated = new Set(), rect = new rect_1.BoundingRect(this, start), rules = ['no-ignored', '
|
|
266
|
+
const errors = super.lint(start, re), { parentNode, childNodes, type, name: tag } = this, attrs = new Map(), duplicated = new Set(), rect = new rect_1.BoundingRect(this, start), rules = ['no-ignored', 'required-attr', 'no-duplicate'], { lintConfig } = index_1.default, { computeEditInfo, fix } = lintConfig, s = ['closingTag', 'invalidAttributes', 'nonWordAttributes']
|
|
267
267
|
.map(k => lintConfig.getSeverity(rules[0], k));
|
|
268
268
|
if (s[0] && this.#lint()) {
|
|
269
269
|
const e = (0, lint_1.generateForSelf)(this, rect, rules[0], 'attributes-of-closing-tag', s[0]);
|
|
@@ -299,7 +299,7 @@ let AttributesToken = (() => {
|
|
|
299
299
|
}
|
|
300
300
|
}
|
|
301
301
|
if (type === 'ext-attrs' && required.has(tag)) {
|
|
302
|
-
const severity = lintConfig.getSeverity(rules[
|
|
302
|
+
const severity = lintConfig.getSeverity(rules[1], tag);
|
|
303
303
|
if (severity) {
|
|
304
304
|
for (const key of required.get(tag)) {
|
|
305
305
|
const keys = typeof key === 'string' ? [key] : key, missing = keys.every(k => {
|
|
@@ -307,12 +307,12 @@ let AttributesToken = (() => {
|
|
|
307
307
|
return value === true || !value;
|
|
308
308
|
});
|
|
309
309
|
if (missing) {
|
|
310
|
-
errors.push((0, lint_1.generateForSelf)(this, rect, rules[
|
|
310
|
+
errors.push((0, lint_1.generateForSelf)(this, rect, rules[1], index_1.default.msg('required-attribute', keys.join('/')), severity));
|
|
311
311
|
}
|
|
312
312
|
}
|
|
313
313
|
}
|
|
314
314
|
}
|
|
315
|
-
const severity = lintConfig.getSeverity(rules[
|
|
315
|
+
const severity = lintConfig.getSeverity(rules[2], 'attribute');
|
|
316
316
|
if (severity && duplicated.size > 0) {
|
|
317
317
|
for (const key of duplicated) {
|
|
318
318
|
const pairs = attrs.get(key).map(attr => {
|
|
@@ -320,7 +320,7 @@ let AttributesToken = (() => {
|
|
|
320
320
|
return [attr, value === true ? '' : value];
|
|
321
321
|
});
|
|
322
322
|
Array.prototype.push.apply(errors, pairs.map(([attr, value], i) => {
|
|
323
|
-
const e = (0, lint_1.generateForChild)(attr, rect, rules[
|
|
323
|
+
const e = (0, lint_1.generateForChild)(attr, rect, rules[2], index_1.default.msg('duplicate-attribute', key), severity);
|
|
324
324
|
if (computeEditInfo || fix) {
|
|
325
325
|
const remove = (0, lint_1.fixByRemove)(e);
|
|
326
326
|
if (!value || pairs.slice(0, i).some(([, v]) => v === value)) {
|
package/dist/util/sharable.js
CHANGED
|
@@ -88,6 +88,8 @@ exports.htmlAttrs = (() => ({
|
|
|
88
88
|
categorytree: blockAttrs,
|
|
89
89
|
combooption: blockAttrs,
|
|
90
90
|
img: new Set(['alt', 'src', 'width', 'height', 'loading', 'srcset']),
|
|
91
|
+
/* NOT FOR BROWSER ONLY */
|
|
92
|
+
a: new Set(['href', 'rel', 'rev']),
|
|
91
93
|
}))();
|
|
92
94
|
exports.extAttrs = (() => ({
|
|
93
95
|
pre: new Set(['format']),
|
package/dist/util/sharable.mjs
CHANGED
|
@@ -85,7 +85,9 @@ const htmlAttrs = /* @__PURE__ */ (() => ({
|
|
|
85
85
|
poem: blockAttrs,
|
|
86
86
|
categorytree: blockAttrs,
|
|
87
87
|
combooption: blockAttrs,
|
|
88
|
-
img: /* @__PURE__ */ new Set(["alt", "src", "width", "height", "loading", "srcset"])
|
|
88
|
+
img: /* @__PURE__ */ new Set(["alt", "src", "width", "height", "loading", "srcset"]),
|
|
89
|
+
/* NOT FOR BROWSER ONLY */
|
|
90
|
+
a: /* @__PURE__ */ new Set(["href", "rel", "rev"])
|
|
89
91
|
}))();
|
|
90
92
|
const extAttrs = /* @__PURE__ */ (() => ({
|
|
91
93
|
pre: /* @__PURE__ */ new Set(["format"]),
|
package/extensions/dist/base.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
(() => {
|
|
2
2
|
var _a;
|
|
3
|
-
const version = '1.
|
|
3
|
+
const version = '1.41.0', src = (_a = document.currentScript) === null || _a === void 0 ? void 0 : _a.src, file = /\/extensions\/dist\/base\.(?:min\.)?js$/u, CDN = src && file.test(src)
|
|
4
4
|
? src.replace(file, '')
|
|
5
5
|
: `https://fastly.jsdelivr.net/npm/wikiparser-node@${version}`;
|
|
6
6
|
const workerJS = () => {
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
(() => {
|
|
2
|
+
const execute = (obj) => {
|
|
3
|
+
Object.entries(obj.files).find(([k]) => k.endsWith('.data.js'))[1]();
|
|
4
|
+
};
|
|
5
|
+
Object.assign(globalThis, {
|
|
6
|
+
mw: {
|
|
7
|
+
loader: {
|
|
8
|
+
done: false,
|
|
9
|
+
impl(callback) {
|
|
10
|
+
execute(callback()[1]);
|
|
11
|
+
},
|
|
12
|
+
implement(name, callback) {
|
|
13
|
+
if (typeof callback === 'object') {
|
|
14
|
+
execute(callback);
|
|
15
|
+
}
|
|
16
|
+
else if (!this.done) {
|
|
17
|
+
callback();
|
|
18
|
+
}
|
|
19
|
+
if (name.startsWith('ext.CodeMirror.data')) {
|
|
20
|
+
this.done = true;
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
state() {
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
config: {
|
|
27
|
+
values: {},
|
|
28
|
+
set({ extCodeMirrorConfig }) {
|
|
29
|
+
this.values.extCodeMirrorConfig = extCodeMirrorConfig;
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
});
|
|
34
|
+
})();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wikiparser-node",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.41.0",
|
|
4
4
|
"description": "A Node.js parser for MediaWiki markup with AST",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"mediawiki",
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"parser",
|
|
9
9
|
"browser"
|
|
10
10
|
],
|
|
11
|
-
"homepage": "https://github.com/bhsd-harry/wikiparser-node
|
|
11
|
+
"homepage": "https://github.com/bhsd-harry/wikiparser-node#readme",
|
|
12
12
|
"bugs": {
|
|
13
13
|
"url": "https://github.com/bhsd-harry/wikiparser-node/issues"
|
|
14
14
|
},
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"/errors/README",
|
|
25
25
|
"/config/",
|
|
26
26
|
"!/config/mediawikiwiki.json",
|
|
27
|
-
"!/config/
|
|
27
|
+
"!/config/github.json",
|
|
28
28
|
"/data/",
|
|
29
29
|
"/i18n/",
|
|
30
30
|
"/coverage/badge.svg",
|
|
@@ -82,10 +82,10 @@
|
|
|
82
82
|
]
|
|
83
83
|
},
|
|
84
84
|
"dependencies": {
|
|
85
|
-
"@bhsd/cm-util": "^
|
|
85
|
+
"@bhsd/cm-util": "^2.0.1",
|
|
86
86
|
"@bhsd/common": "^2.2.1",
|
|
87
|
-
"@bhsd/nodejs": "^1.0.
|
|
88
|
-
"@bhsd/stylelint-util": "^1.0.
|
|
87
|
+
"@bhsd/nodejs": "^1.0.1",
|
|
88
|
+
"@bhsd/stylelint-util": "^1.0.3",
|
|
89
89
|
"binary-search": "^1.3.6",
|
|
90
90
|
"vscode-languageserver-types": "^3.17.5"
|
|
91
91
|
},
|
|
@@ -93,37 +93,36 @@
|
|
|
93
93
|
"color-name": "~2.0.2",
|
|
94
94
|
"entities": "^8.0.0",
|
|
95
95
|
"mathoid-texvcjs": "^0.6.0",
|
|
96
|
-
"prism-wiki": "^2.1.
|
|
96
|
+
"prism-wiki": "^2.1.1",
|
|
97
97
|
"prismjs": "^1.30.0",
|
|
98
|
-
"stylelint": "^17.
|
|
98
|
+
"stylelint": "^17.12.0",
|
|
99
99
|
"vscode-css-languageservice": "^6.3.10",
|
|
100
100
|
"vscode-html-languageservice": "^5.6.2",
|
|
101
101
|
"vscode-json-languageservice": "^5.7.2"
|
|
102
102
|
},
|
|
103
103
|
"devDependencies": {
|
|
104
|
-
"@bhsd/code-standard": "^2.
|
|
105
|
-
"@bhsd/test-util": "^1.
|
|
106
|
-
"@codemirror/lint": "^6.9.
|
|
104
|
+
"@bhsd/code-standard": "^2.5.1",
|
|
105
|
+
"@bhsd/test-util": "^1.3.1",
|
|
106
|
+
"@codemirror/lint": "^6.9.6",
|
|
107
107
|
"@eslint/markdown": "^8.0.1",
|
|
108
108
|
"@types/color-name": "^2.0.0",
|
|
109
109
|
"@types/color-rgba": "^2.1.3",
|
|
110
110
|
"@types/mocha": "^10.0.10",
|
|
111
|
-
"@types/node": "^
|
|
111
|
+
"@types/node": "^25.9.0",
|
|
112
112
|
"@types/prismjs": "^1.26.6",
|
|
113
|
-
"@typescript-eslint/
|
|
114
|
-
"@typescript-eslint/parser": "^8.59.2",
|
|
113
|
+
"@typescript-eslint/parser": "^8.59.4",
|
|
115
114
|
"c8": "^11.0.0",
|
|
116
|
-
"codejar-async": "^4.3.
|
|
115
|
+
"codejar-async": "^4.3.1",
|
|
117
116
|
"color-rgba": "^3.0.0",
|
|
118
117
|
"diff2html-cli": "^5.2.15",
|
|
119
118
|
"esbuild": "^0.28.0",
|
|
120
|
-
"eslint": "^10.
|
|
119
|
+
"eslint": "^10.4.0",
|
|
121
120
|
"markdownlint-cli2": "^0.22.1",
|
|
122
121
|
"mocha": "^11.7.5",
|
|
123
122
|
"monaco-editor": "~0.53.0",
|
|
124
|
-
"tsx": "^4.
|
|
123
|
+
"tsx": "^4.22.2",
|
|
125
124
|
"typescript": "^6.0.3",
|
|
126
|
-
"v8r": "^6.
|
|
125
|
+
"v8r": "^6.1.0",
|
|
127
126
|
"vscode-languageserver-textdocument": "^1.0.12"
|
|
128
127
|
},
|
|
129
128
|
"engines": {
|