wikiparser-node 1.32.0 → 1.34.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 +7 -0
- package/bundle/bundle-es8.min.js +28 -28
- package/bundle/bundle-lsp.min.js +29 -29
- package/bundle/bundle.min.js +24 -24
- package/coverage/badge.svg +1 -1
- package/dist/addon/attribute.js +27 -7
- package/dist/addon/link.js +15 -16
- package/dist/addon/table.js +139 -103
- package/dist/addon/token.js +3 -1
- package/dist/base.d.mts +1 -1
- package/dist/base.d.ts +1 -1
- package/dist/base.js +1 -0
- package/dist/base.mjs +1 -0
- package/dist/bin/config.js +1 -1
- package/dist/index.js +10 -10
- package/dist/internal.d.ts +3 -0
- package/dist/lib/lintConfig.js +8 -0
- package/dist/lib/lsp.js +20 -3
- package/dist/lib/node.js +3 -11
- package/dist/lib/text.js +18 -18
- package/dist/lib/title.js +8 -10
- package/dist/render/magicWords.js +13 -6
- package/dist/src/attribute.d.ts +4 -6
- package/dist/src/attribute.js +15 -11
- package/dist/src/attributes.d.ts +2 -2
- package/dist/src/attributes.js +11 -6
- package/dist/src/converterFlags.js +5 -7
- package/dist/src/imageParameter.d.ts +7 -3
- package/dist/src/imageParameter.js +15 -5
- package/dist/src/index.d.ts +8 -0
- package/dist/src/index.js +34 -21
- package/dist/src/link/base.d.ts +1 -1
- package/dist/src/link/base.js +12 -5
- package/dist/src/link/categorytree.d.ts +25 -0
- package/dist/src/link/categorytree.js +126 -0
- package/dist/src/link/file.d.ts +3 -2
- package/dist/src/link/file.js +4 -3
- package/dist/src/link/galleryImage.js +6 -7
- package/dist/src/multiLine/gallery.d.ts +1 -4
- package/dist/src/multiLine/gallery.js +1 -11
- package/dist/src/multiLine/imagemap.d.ts +0 -1
- package/dist/src/multiLine/imagemap.js +98 -152
- package/dist/src/multiLine/index.d.ts +1 -0
- package/dist/src/multiLine/index.js +77 -22
- package/dist/src/multiLine/inputbox.d.ts +3 -3
- package/dist/src/multiLine/inputbox.js +3 -7
- package/dist/src/multiLine/paramTag.d.ts +3 -4
- package/dist/src/multiLine/paramTag.js +6 -48
- package/dist/src/nowiki/index.d.ts +1 -1
- package/dist/src/nowiki/index.js +59 -13
- package/dist/src/nowiki/list.d.ts +0 -1
- package/dist/src/nowiki/list.js +1 -0
- package/dist/src/nowiki/noinclude.d.ts +0 -1
- package/dist/src/nowiki/noinclude.js +1 -0
- package/dist/src/nowiki/quote.d.ts +0 -4
- package/dist/src/nowiki/quote.js +4 -0
- package/dist/src/paramLine.d.ts +3 -0
- package/dist/src/paramLine.js +45 -7
- package/dist/src/parameter.js +5 -7
- package/dist/src/table/base.d.ts +1 -2
- package/dist/src/table/base.js +7 -8
- package/dist/src/table/index.d.ts +2 -3
- package/dist/src/table/index.js +4 -41
- package/dist/src/table/td.d.ts +0 -1
- package/dist/src/table/td.js +1 -0
- package/dist/src/table/tr.d.ts +1 -1
- package/dist/src/tag/html.d.ts +0 -1
- package/dist/src/tag/html.js +1 -0
- package/dist/src/tag/tvar.d.ts +0 -1
- package/dist/src/tag/tvar.js +1 -0
- package/dist/src/tagPair/ext.js +19 -10
- package/dist/src/tagPair/index.d.ts +4 -2
- package/dist/src/tagPair/index.js +47 -7
- package/dist/src/tagPair/translate.d.ts +1 -1
- package/dist/src/tagPair/translate.js +3 -1
- package/dist/src/transclude.js +2 -2
- package/dist/util/debug.js +10 -3
- package/dist/util/diff.js +6 -17
- package/dist/util/html.js +1 -0
- package/dist/util/sharable.d.mts +1 -0
- package/dist/util/sharable.js +62 -1
- package/dist/util/sharable.mjs +62 -0
- package/extensions/dist/base.js +1 -1
- package/extensions/typings.d.ts +40 -0
- package/extensions/ui.css +1 -1
- package/i18n/en.json +2 -0
- package/i18n/zh-hans.json +2 -0
- package/i18n/zh-hant.json +2 -0
- package/logo.png +0 -0
- package/package.json +7 -6
|
@@ -1,38 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
|
|
3
|
-
var useValue = arguments.length > 2;
|
|
4
|
-
for (var i = 0; i < initializers.length; i++) {
|
|
5
|
-
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
|
6
|
-
}
|
|
7
|
-
return useValue ? value : void 0;
|
|
8
|
-
};
|
|
9
|
-
var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
|
10
|
-
function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
|
|
11
|
-
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
|
12
|
-
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
|
|
13
|
-
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
|
|
14
|
-
var _, done = false;
|
|
15
|
-
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
16
|
-
var context = {};
|
|
17
|
-
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
|
|
18
|
-
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
|
|
19
|
-
context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
|
|
20
|
-
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
|
|
21
|
-
if (kind === "accessor") {
|
|
22
|
-
if (result === void 0) continue;
|
|
23
|
-
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
|
|
24
|
-
if (_ = accept(result.get)) descriptor.get = _;
|
|
25
|
-
if (_ = accept(result.set)) descriptor.set = _;
|
|
26
|
-
if (_ = accept(result.init)) initializers.unshift(_);
|
|
27
|
-
}
|
|
28
|
-
else if (_ = accept(result)) {
|
|
29
|
-
if (kind === "field") initializers.unshift(_);
|
|
30
|
-
else descriptor[key] = _;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
34
|
-
done = true;
|
|
35
|
-
};
|
|
36
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
37
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
38
4
|
};
|
|
@@ -48,146 +14,126 @@ const galleryImage_1 = require("../link/galleryImage");
|
|
|
48
14
|
const imagemapLink_1 = require("../imagemapLink");
|
|
49
15
|
/* NOT FOR BROWSER */
|
|
50
16
|
const constants_1 = require("../../util/constants");
|
|
51
|
-
const clone_1 = require("../../mixin/clone");
|
|
52
17
|
/* NOT FOR BROWSER END */
|
|
53
18
|
/**
|
|
54
19
|
* `<imagemap>`
|
|
55
20
|
* @classdesc `{childNodes: [...CommentLineToken[], GalleryImageToken, ...(CommentLineToken|ImagemapLinkToken|AstText)[]]}`
|
|
56
21
|
*/
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
get image() {
|
|
71
|
-
return this.childNodes.find((0, debug_1.isToken)('imagemap-image'));
|
|
22
|
+
class ImagemapToken extends index_2.MultiLineToken {
|
|
23
|
+
/* NOT FOR BROWSER END */
|
|
24
|
+
/** 图片 */
|
|
25
|
+
get image() {
|
|
26
|
+
return this.childNodes.find((0, debug_1.isToken)('imagemap-image'));
|
|
27
|
+
}
|
|
28
|
+
/** @param inner 标签内部wikitext */
|
|
29
|
+
constructor(inner, config = index_1.default.getConfig(), accum = []) {
|
|
30
|
+
super(undefined, config, accum, {
|
|
31
|
+
GalleryImageToken: ':', ImagemapLinkToken: ':', CommentLineToken: ':', AstText: ':',
|
|
32
|
+
});
|
|
33
|
+
if (!inner) {
|
|
34
|
+
return;
|
|
72
35
|
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
if (!inner) {
|
|
80
|
-
return;
|
|
36
|
+
const lines = inner.split('\n'), protocols = new Set(config.protocol.split('|'));
|
|
37
|
+
let first = true, error = false;
|
|
38
|
+
for (const line of lines) {
|
|
39
|
+
const trimmed = line.trim();
|
|
40
|
+
if (error || !trimmed || trimmed.startsWith('#')) {
|
|
41
|
+
//
|
|
81
42
|
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
43
|
+
else if (first) {
|
|
44
|
+
const pipe = line.indexOf('|'), file = pipe === -1 ? line : line.slice(0, pipe), title = this.normalizeTitle(file, 0, { halfParsed: true, temporary: true, page: '' });
|
|
45
|
+
if (title.valid && title.ns === 6
|
|
46
|
+
&& !title.interwiki) {
|
|
47
|
+
// @ts-expect-error abstract class
|
|
48
|
+
const token = new galleryImage_1.GalleryImageToken('imagemap', file, pipe === -1 ? undefined : line.slice(pipe + 1), config, accum);
|
|
49
|
+
super.insertAt(token);
|
|
50
|
+
first = false;
|
|
51
|
+
continue;
|
|
88
52
|
}
|
|
89
|
-
else
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
53
|
+
else {
|
|
54
|
+
error = true;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
else if (line.trim().split(/[\t ]/u, 1)[0] === 'desc') {
|
|
58
|
+
super.insertAt(line);
|
|
59
|
+
continue;
|
|
60
|
+
}
|
|
61
|
+
else if (line.includes('[')) {
|
|
62
|
+
const i = line.indexOf('['), substr = line.slice(i), mtIn = /^\[\[([^|]+)(?:\|([^\]]*))?\]\][\w\s]*$/u
|
|
63
|
+
.exec(substr);
|
|
64
|
+
if (mtIn) {
|
|
65
|
+
if (this.normalizeTitle(mtIn[1], 0, { halfParsed: true, temporary: true, selfLink: true, page: '' }).valid) {
|
|
96
66
|
// @ts-expect-error abstract class
|
|
97
|
-
|
|
98
|
-
super.insertAt(token);
|
|
99
|
-
first = false;
|
|
67
|
+
super.insertAt(new imagemapLink_1.ImagemapLinkToken(line.slice(0, i), mtIn.slice(1), substr.slice(substr.indexOf(']]') + 2), config, accum));
|
|
100
68
|
continue;
|
|
101
69
|
}
|
|
102
|
-
else {
|
|
103
|
-
error = true;
|
|
104
|
-
}
|
|
105
70
|
}
|
|
106
|
-
else if (
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
else if (line.includes('[')) {
|
|
111
|
-
const i = line.indexOf('['), substr = line.slice(i), mtIn = /^\[\[([^|]+)(?:\|([^\]]*))?\]\][\w\s]*$/u
|
|
71
|
+
else if (substr.startsWith('[//')
|
|
72
|
+
|| protocols.has(substr.slice(1, substr.indexOf(':') + 1))
|
|
73
|
+
|| protocols.has(substr.slice(1, substr.indexOf('//') + 2))) {
|
|
74
|
+
const mtEx = /^\[([^\]\s]+)(?:(\s+(?!\s))([^\]]*))?\][\w\s]*$/u
|
|
112
75
|
.exec(substr);
|
|
113
|
-
if (
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
continue;
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
else if (substr.startsWith('[//')
|
|
121
|
-
|| protocols.has(substr.slice(1, substr.indexOf(':') + 1))
|
|
122
|
-
|| protocols.has(substr.slice(1, substr.indexOf('//') + 2))) {
|
|
123
|
-
const mtEx = /^\[([^\]\s]+)(?:(\s+(?!\s))([^\]]*))?\][\w\s]*$/u
|
|
124
|
-
.exec(substr);
|
|
125
|
-
if (mtEx) {
|
|
126
|
-
// @ts-expect-error abstract class
|
|
127
|
-
super.insertAt(new imagemapLink_1.ImagemapLinkToken(line.slice(0, i), mtEx.slice(1), substr.slice(substr.indexOf(']') + 1), config, accum));
|
|
128
|
-
continue;
|
|
129
|
-
}
|
|
76
|
+
if (mtEx) {
|
|
77
|
+
// @ts-expect-error abstract class
|
|
78
|
+
super.insertAt(new imagemapLink_1.ImagemapLinkToken(line.slice(0, i), mtEx.slice(1), substr.slice(substr.indexOf(']') + 1), config, accum));
|
|
79
|
+
continue;
|
|
130
80
|
}
|
|
131
81
|
}
|
|
132
|
-
// @ts-expect-error abstract class
|
|
133
|
-
super.insertAt(new commentLine_1.CommentLineToken(line, config, accum));
|
|
134
82
|
}
|
|
83
|
+
// @ts-expect-error abstract class
|
|
84
|
+
super.insertAt(new commentLine_1.CommentLineToken(line, config, accum));
|
|
135
85
|
}
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
86
|
+
}
|
|
87
|
+
/** @private */
|
|
88
|
+
lint(start = this.getAbsoluteIndex(), re) {
|
|
89
|
+
LINT: {
|
|
90
|
+
const errors = super.lint(start, re), rect = new rect_1.BoundingRect(this, start), { childNodes, image } = this, rule = 'invalid-imagemap', { lintConfig } = index_1.default, s = lintConfig.getSeverity(rule, image ? 'link' : 'image');
|
|
91
|
+
if (s) {
|
|
92
|
+
if (image) {
|
|
93
|
+
Array.prototype.push.apply(errors, childNodes.filter(child => {
|
|
94
|
+
const str = child.toString().trim();
|
|
95
|
+
return child.is('noinclude')
|
|
96
|
+
&& str && !str.startsWith('#');
|
|
97
|
+
}).map(child => {
|
|
98
|
+
const e = (0, lint_1.generateForChild)(child, rect, rule, 'invalid-imagemap-link', s);
|
|
99
|
+
if (lintConfig.computeEditInfo) {
|
|
100
|
+
e.suggestions = [
|
|
101
|
+
(0, lint_1.fixByRemove)(e, -1),
|
|
102
|
+
(0, lint_1.fixBy)(e, 'comment', '# '),
|
|
103
|
+
];
|
|
104
|
+
}
|
|
105
|
+
return e;
|
|
106
|
+
}));
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
errors.push((0, lint_1.generateForSelf)(this, rect, rule, 'imagemap-without-image', s));
|
|
160
110
|
}
|
|
161
|
-
return errors;
|
|
162
111
|
}
|
|
112
|
+
return errors;
|
|
163
113
|
}
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
else if (image && typeof token !== 'string' && token.is('imagemap-image')) {
|
|
175
|
-
throw new RangeError('Already have a valid image!');
|
|
176
|
-
}
|
|
177
|
-
return super.insertAt(token, i);
|
|
114
|
+
}
|
|
115
|
+
/* PRINT ONLY */
|
|
116
|
+
/** @private */
|
|
117
|
+
getAttribute(key) {
|
|
118
|
+
return key === 'invalid' ? !this.image : super.getAttribute(key);
|
|
119
|
+
}
|
|
120
|
+
insertAt(token, i) {
|
|
121
|
+
const { image } = this;
|
|
122
|
+
if (!image && (typeof token === 'string' || token.is('imagemap-link') || token.type === 'text')) {
|
|
123
|
+
throw new Error('Missing a valid image!');
|
|
178
124
|
}
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
if (this.childNodes[i]?.is('imagemap-image')) {
|
|
182
|
-
throw new Error('Do not remove the image in <imagemap>!');
|
|
183
|
-
}
|
|
184
|
-
return super.removeAt(i);
|
|
125
|
+
else if (image && typeof token !== 'string' && token.is('imagemap-image')) {
|
|
126
|
+
throw new RangeError('Already have a valid image!');
|
|
185
127
|
}
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
128
|
+
return super.insertAt(token, i);
|
|
129
|
+
}
|
|
130
|
+
/** @private */
|
|
131
|
+
removeAt(i) {
|
|
132
|
+
if (!this.parentNode?.selfClosing && this.childNodes[i]?.is('imagemap-image')) {
|
|
133
|
+
throw new Error('Do not remove the image in <imagemap>!');
|
|
189
134
|
}
|
|
190
|
-
|
|
191
|
-
}
|
|
135
|
+
return super.removeAt(i);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
192
138
|
exports.ImagemapToken = ImagemapToken;
|
|
193
139
|
constants_1.classes['ImagemapToken'] = __filename;
|
|
@@ -1,36 +1,91 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
|
|
3
|
+
var useValue = arguments.length > 2;
|
|
4
|
+
for (var i = 0; i < initializers.length; i++) {
|
|
5
|
+
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
|
6
|
+
}
|
|
7
|
+
return useValue ? value : void 0;
|
|
8
|
+
};
|
|
9
|
+
var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
|
10
|
+
function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
|
|
11
|
+
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
|
12
|
+
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
|
|
13
|
+
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
|
|
14
|
+
var _, done = false;
|
|
15
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
16
|
+
var context = {};
|
|
17
|
+
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
|
|
18
|
+
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
|
|
19
|
+
context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
|
|
20
|
+
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
|
|
21
|
+
if (kind === "accessor") {
|
|
22
|
+
if (result === void 0) continue;
|
|
23
|
+
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
|
|
24
|
+
if (_ = accept(result.get)) descriptor.get = _;
|
|
25
|
+
if (_ = accept(result.set)) descriptor.set = _;
|
|
26
|
+
if (_ = accept(result.init)) initializers.unshift(_);
|
|
27
|
+
}
|
|
28
|
+
else if (_ = accept(result)) {
|
|
29
|
+
if (kind === "field") initializers.unshift(_);
|
|
30
|
+
else descriptor[key] = _;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
34
|
+
done = true;
|
|
35
|
+
};
|
|
2
36
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
37
|
exports.MultiLineToken = void 0;
|
|
4
38
|
const index_1 = require("../index");
|
|
5
39
|
/* NOT FOR BROWSER */
|
|
6
40
|
const constants_1 = require("../../util/constants");
|
|
41
|
+
const clone_1 = require("../../mixin/clone");
|
|
7
42
|
/* NOT FOR BROWSER END */
|
|
8
43
|
/**
|
|
9
44
|
* extension tag that is parsed line by line
|
|
10
45
|
*
|
|
11
46
|
* 逐行解析的扩展标签
|
|
12
47
|
*/
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
48
|
+
let MultiLineToken = (() => {
|
|
49
|
+
let _classSuper = index_1.Token;
|
|
50
|
+
let _instanceExtraInitializers = [];
|
|
51
|
+
let _cloneNode_decorators;
|
|
52
|
+
return class MultiLineToken extends _classSuper {
|
|
53
|
+
static {
|
|
54
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
55
|
+
_cloneNode_decorators = [clone_1.clone];
|
|
56
|
+
__esDecorate(this, null, _cloneNode_decorators, { kind: "method", name: "cloneNode", static: false, private: false, access: { has: obj => "cloneNode" in obj, get: obj => obj.cloneNode }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
57
|
+
if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
58
|
+
}
|
|
59
|
+
/* NOT FOR BROWSER END */
|
|
60
|
+
get type() {
|
|
61
|
+
return 'ext-inner';
|
|
62
|
+
}
|
|
63
|
+
/** @private */
|
|
64
|
+
toString(skip) {
|
|
65
|
+
return super.toString(skip, '\n');
|
|
66
|
+
}
|
|
67
|
+
/** @private */
|
|
68
|
+
text() {
|
|
69
|
+
return super.text('\n').replace(/\n\s*\n/gu, '\n');
|
|
70
|
+
}
|
|
71
|
+
/** @private */
|
|
72
|
+
getGaps() {
|
|
73
|
+
return 1;
|
|
74
|
+
}
|
|
75
|
+
/** @private */
|
|
76
|
+
print() {
|
|
77
|
+
PRINT: return super.print({ sep: '\n' });
|
|
78
|
+
}
|
|
79
|
+
/* NOT FOR BROWSER */
|
|
80
|
+
cloneNode() {
|
|
81
|
+
const C = this.constructor;
|
|
82
|
+
return new C(undefined, this.getAttribute('config'));
|
|
83
|
+
}
|
|
84
|
+
constructor() {
|
|
85
|
+
super(...arguments);
|
|
86
|
+
__runInitializers(this, _instanceExtraInitializers);
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
})();
|
|
35
90
|
exports.MultiLineToken = MultiLineToken;
|
|
36
91
|
constants_1.classes['MultiLineToken'] = __filename;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import Parser from '../../index';
|
|
2
1
|
import { ParamTagToken } from './paramTag';
|
|
2
|
+
import type { Config } from '../../base';
|
|
3
3
|
import type { Token } from '../../internal';
|
|
4
4
|
/** `<inputbox>` */
|
|
5
5
|
export declare abstract class InputboxToken extends ParamTagToken {
|
|
6
|
-
/** @
|
|
7
|
-
constructor(include: boolean, wikitext
|
|
6
|
+
/** @param name 扩展标签名 */
|
|
7
|
+
constructor(name: string, include: boolean, wikitext: string | undefined, config: Config, accum?: Token[]);
|
|
8
8
|
}
|
|
@@ -1,20 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.InputboxToken = void 0;
|
|
7
4
|
const commentAndExt_1 = require("../../parser/commentAndExt");
|
|
8
5
|
const braces_1 = require("../../parser/braces");
|
|
9
|
-
const index_1 = __importDefault(require("../../index"));
|
|
10
6
|
const paramTag_1 = require("./paramTag");
|
|
11
7
|
/* NOT FOR BROWSER */
|
|
12
8
|
const constants_1 = require("../../util/constants");
|
|
13
9
|
/* NOT FOR BROWSER END */
|
|
14
10
|
/** `<inputbox>` */
|
|
15
11
|
class InputboxToken extends paramTag_1.ParamTagToken {
|
|
16
|
-
/** @
|
|
17
|
-
constructor(include, wikitext, config
|
|
12
|
+
/** @param name 扩展标签名 */
|
|
13
|
+
constructor(name, include, wikitext, config, accum = []) {
|
|
18
14
|
const placeholder = Symbol('InputboxToken'), newConfig = config.excludes.includes('heading')
|
|
19
15
|
? config
|
|
20
16
|
: {
|
|
@@ -25,7 +21,7 @@ class InputboxToken extends paramTag_1.ParamTagToken {
|
|
|
25
21
|
wikitext &&= (0, commentAndExt_1.parseCommentAndExt)(wikitext, newConfig, accum, include);
|
|
26
22
|
wikitext &&= (0, braces_1.parseBraces)(wikitext, newConfig, accum);
|
|
27
23
|
accum.splice(length, 1);
|
|
28
|
-
super(include, wikitext, newConfig, accum, {
|
|
24
|
+
super(name, include, wikitext, newConfig, accum, {
|
|
29
25
|
ArgToken: ':', TranscludeToken: ':',
|
|
30
26
|
});
|
|
31
27
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import Parser from '../../index';
|
|
2
1
|
import { MultiLineToken } from './index';
|
|
3
2
|
import { ParamLineToken } from '../paramLine';
|
|
4
|
-
import type {
|
|
3
|
+
import type { Config } from '../../base';
|
|
5
4
|
import type { Token } from '../../internal';
|
|
6
5
|
/**
|
|
7
6
|
* `<dynamicpagelist>`
|
|
@@ -14,7 +13,7 @@ export declare abstract class ParamTagToken extends MultiLineToken {
|
|
|
14
13
|
abstract get children(): ParamLineToken[];
|
|
15
14
|
abstract get firstElementChild(): ParamLineToken | undefined;
|
|
16
15
|
abstract get lastElementChild(): ParamLineToken | undefined;
|
|
17
|
-
/** @
|
|
18
|
-
constructor(include: boolean, wikitext
|
|
16
|
+
/** @param name 扩展标签名 */
|
|
17
|
+
constructor(name: string, include: boolean, wikitext: string | undefined, config: Config, accum?: Token[], acceptable?: WikiParserAcceptable);
|
|
19
18
|
cloneNode(): this;
|
|
20
19
|
}
|
|
@@ -33,16 +33,10 @@ var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn,
|
|
|
33
33
|
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
34
34
|
done = true;
|
|
35
35
|
};
|
|
36
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
37
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
38
|
-
};
|
|
39
36
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
37
|
exports.ParamTagToken = void 0;
|
|
41
|
-
const lint_1 = require("../../util/lint");
|
|
42
|
-
const rect_1 = require("../../lib/rect");
|
|
43
38
|
const commentAndExt_1 = require("../../parser/commentAndExt");
|
|
44
|
-
const index_1 =
|
|
45
|
-
const index_2 = require("./index");
|
|
39
|
+
const index_1 = require("./index");
|
|
46
40
|
const paramLine_1 = require("../paramLine");
|
|
47
41
|
/* NOT FOR BROWSER */
|
|
48
42
|
const constants_1 = require("../../util/constants");
|
|
@@ -53,7 +47,7 @@ const clone_1 = require("../../mixin/clone");
|
|
|
53
47
|
* @classdesc `{childNodes: ParamLineToken[]}`
|
|
54
48
|
*/
|
|
55
49
|
let ParamTagToken = (() => {
|
|
56
|
-
let _classSuper =
|
|
50
|
+
let _classSuper = index_1.MultiLineToken;
|
|
57
51
|
let _instanceExtraInitializers = [];
|
|
58
52
|
let _cloneNode_decorators;
|
|
59
53
|
return class ParamTagToken extends _classSuper {
|
|
@@ -64,8 +58,8 @@ let ParamTagToken = (() => {
|
|
|
64
58
|
if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
65
59
|
}
|
|
66
60
|
/* NOT FOR BROWSER END */
|
|
67
|
-
/** @
|
|
68
|
-
constructor(include, wikitext, config
|
|
61
|
+
/** @param name 扩展标签名 */
|
|
62
|
+
constructor(name, include, wikitext, config, accum = [], acceptable) {
|
|
69
63
|
super(undefined, config, accum, {
|
|
70
64
|
ParamLineToken: ':',
|
|
71
65
|
});
|
|
@@ -74,53 +68,17 @@ let ParamTagToken = (() => {
|
|
|
74
68
|
this.safeAppend(wikitext.split('\n')
|
|
75
69
|
.map(line => acceptable ? line : (0, commentAndExt_1.parseCommentAndExt)(line, config, accum, include))
|
|
76
70
|
// @ts-expect-error abstract class
|
|
77
|
-
.map((line) => new paramLine_1.ParamLineToken(line, config, accum, {
|
|
71
|
+
.map((line) => new paramLine_1.ParamLineToken(name, line, config, accum, {
|
|
78
72
|
'Stage-1': ':', ...acceptable ?? { '!ExtToken': '' },
|
|
79
73
|
})));
|
|
80
74
|
}
|
|
81
75
|
accum.splice(accum.indexOf(this), 1);
|
|
82
76
|
accum.push(this);
|
|
83
77
|
}
|
|
84
|
-
/** @private */
|
|
85
|
-
lint(start = this.getAbsoluteIndex()) {
|
|
86
|
-
LINT: {
|
|
87
|
-
const rule = 'no-ignored', { lintConfig } = index_1.default, s = lintConfig.getSeverity(rule, this.name);
|
|
88
|
-
if (!s) {
|
|
89
|
-
return [];
|
|
90
|
-
}
|
|
91
|
-
const rect = new rect_1.BoundingRect(this, start), msg = index_1.default.msg('invalid-parameter', this.name), errors = [];
|
|
92
|
-
for (const child of this.childNodes) {
|
|
93
|
-
child.setAttribute('aIndex', start);
|
|
94
|
-
const grandChildren = child.childNodes
|
|
95
|
-
.filter(({ type }) => type !== 'comment' && type !== 'include' && type !== 'noinclude');
|
|
96
|
-
if (grandChildren.some(({ type }) => type === 'ext')) {
|
|
97
|
-
errors.push((0, lint_1.generateForChild)(child, rect, rule, msg, s));
|
|
98
|
-
}
|
|
99
|
-
else {
|
|
100
|
-
const i = grandChildren.findIndex(({ type }) => type !== 'text'), str = grandChildren.slice(0, i === -1 ? undefined : i).map(String).join('');
|
|
101
|
-
if (str && !(i === -1 ? /^[a-z]+(?:\[\])?\s*=/iu : /^[a-z]+(?:\[\])?\s*(?:=|$)/iu).test(str)) {
|
|
102
|
-
const e = (0, lint_1.generateForChild)(child, rect, rule, msg, s);
|
|
103
|
-
if (lintConfig.computeEditInfo) {
|
|
104
|
-
e.suggestions = [(0, lint_1.fixByRemove)(e)];
|
|
105
|
-
}
|
|
106
|
-
errors.push(e);
|
|
107
|
-
}
|
|
108
|
-
else {
|
|
109
|
-
const childErrors = child.lint(start, false);
|
|
110
|
-
if (childErrors.length > 0) {
|
|
111
|
-
Array.prototype.push.apply(errors, childErrors);
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
start += child.toString().length + 1;
|
|
116
|
-
}
|
|
117
|
-
return errors;
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
78
|
/* NOT FOR BROWSER */
|
|
121
79
|
cloneNode() {
|
|
122
80
|
const C = this.constructor;
|
|
123
|
-
return new C(this.getAttribute('include'), undefined, this.getAttribute('config'));
|
|
81
|
+
return new C(this.name, this.getAttribute('include'), undefined, this.getAttribute('config'));
|
|
124
82
|
}
|
|
125
83
|
};
|
|
126
84
|
})();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { NowikiBaseToken } from './base';
|
|
2
2
|
import type { LintError } from '../../base';
|
|
3
|
-
import type { AttributesToken, ExtToken } from '../../internal';
|
|
3
|
+
import type { AttributesToken, ExtToken, AstNodes } from '../../internal';
|
|
4
4
|
/**
|
|
5
5
|
* text-only token inside an extension tag
|
|
6
6
|
*
|