wikiparser-node 1.21.2 → 1.21.3
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 +3 -5
- package/bundle/bundle-es8.min.js +25 -25
- package/bundle/bundle-lsp.min.js +26 -26
- package/bundle/bundle.min.js +25 -25
- package/dist/base.d.mts +6 -1
- package/dist/base.d.ts +6 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +10 -1
- package/dist/lib/element.js +2 -1
- package/dist/lib/lintConfig.d.ts +13 -0
- package/dist/lib/lintConfig.js +161 -0
- package/dist/lib/lsp.js +6 -4
- package/dist/lib/node.js +646 -606
- package/dist/lib/text.js +4 -0
- package/dist/mixin/attributesParent.d.ts +6 -6
- package/dist/mixin/attributesParent.js +4 -4
- package/dist/mixin/cached.d.ts +5 -0
- package/dist/mixin/cached.js +22 -0
- package/dist/mixin/clone.d.ts +5 -0
- package/dist/mixin/clone.js +23 -0
- package/dist/mixin/hidden.js +68 -18
- package/dist/mixin/sol.js +1 -1
- package/dist/parser/commentAndExt.js +1 -1
- package/dist/parser/html.js +3 -3
- package/dist/parser/table.js +2 -2
- package/dist/src/arg.js +13 -7
- package/dist/src/atom.js +76 -31
- package/dist/src/attribute.js +49 -21
- package/dist/src/attributes.d.ts +7 -7
- package/dist/src/attributes.js +415 -366
- package/dist/src/commented.js +81 -35
- package/dist/src/converter.js +13 -7
- package/dist/src/converterFlags.js +33 -22
- package/dist/src/converterRule.js +263 -216
- package/dist/src/extLink.js +21 -16
- package/dist/src/gallery.js +18 -8
- package/dist/src/heading.js +66 -57
- package/dist/src/hidden.js +14 -9
- package/dist/src/html.js +28 -9
- package/dist/src/imageParameter.js +13 -6
- package/dist/src/imagemap.js +32 -25
- package/dist/src/index.js +53 -44
- package/dist/src/link/base.js +13 -8
- package/dist/src/link/file.js +401 -354
- package/dist/src/link/galleryImage.js +9 -5
- package/dist/src/link/index.js +7 -3
- package/dist/src/link/redirectTarget.js +7 -3
- package/dist/src/magicLink.js +23 -14
- package/dist/src/nested.js +122 -74
- package/dist/src/nowiki/base.js +5 -2
- package/dist/src/nowiki/comment.js +5 -1
- package/dist/src/nowiki/index.js +3 -3
- package/dist/src/nowiki/quote.js +13 -8
- package/dist/src/onlyinclude.js +17 -9
- package/dist/src/paramTag/index.js +21 -14
- package/dist/src/parameter.js +26 -20
- package/dist/src/pre.js +91 -45
- package/dist/src/syntax.js +14 -10
- package/dist/src/table/index.js +550 -503
- package/dist/src/table/td.js +65 -58
- package/dist/src/table/trBase.js +179 -129
- package/dist/src/tagPair/ext.js +32 -20
- package/dist/src/tagPair/include.js +5 -5
- package/dist/src/tagPair/translate.js +150 -103
- package/dist/src/transclude.js +13 -8
- package/dist/util/html.js +46 -41
- package/dist/util/lint.js +4 -4
- package/dist/util/string.js +13 -7
- package/extensions/dist/base.js +2 -2
- package/package.json +15 -15
package/dist/src/gallery.js
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
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
|
+
};
|
|
2
9
|
var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
|
3
10
|
function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
|
|
4
11
|
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
|
@@ -26,13 +33,6 @@ var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn,
|
|
|
26
33
|
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
27
34
|
done = true;
|
|
28
35
|
};
|
|
29
|
-
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
|
|
30
|
-
var useValue = arguments.length > 2;
|
|
31
|
-
for (var i = 0; i < initializers.length; i++) {
|
|
32
|
-
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
|
33
|
-
}
|
|
34
|
-
return useValue ? value : void 0;
|
|
35
|
-
};
|
|
36
36
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
37
37
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
38
38
|
};
|
|
@@ -47,6 +47,8 @@ const noinclude_1 = require("./nowiki/noinclude");
|
|
|
47
47
|
const debug_1 = require("../util/debug");
|
|
48
48
|
const constants_1 = require("../util/constants");
|
|
49
49
|
const html_1 = require("../util/html");
|
|
50
|
+
const clone_1 = require("../mixin/clone");
|
|
51
|
+
const cached_1 = require("../mixin/cached");
|
|
50
52
|
/**
|
|
51
53
|
* gallery tag
|
|
52
54
|
*
|
|
@@ -59,10 +61,17 @@ let GalleryToken = (() => {
|
|
|
59
61
|
let _classExtraInitializers = [];
|
|
60
62
|
let _classThis;
|
|
61
63
|
let _classSuper = index_2.Token;
|
|
64
|
+
let _instanceExtraInitializers = [];
|
|
65
|
+
let _cloneNode_decorators;
|
|
66
|
+
let _toHtmlInternal_decorators;
|
|
62
67
|
var GalleryToken = class extends _classSuper {
|
|
63
68
|
static { _classThis = this; }
|
|
64
69
|
static {
|
|
65
70
|
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
71
|
+
_cloneNode_decorators = [clone_1.clone];
|
|
72
|
+
_toHtmlInternal_decorators = [(0, cached_1.cached)()];
|
|
73
|
+
__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);
|
|
74
|
+
__esDecorate(this, null, _toHtmlInternal_decorators, { kind: "method", name: "toHtmlInternal", static: false, private: false, access: { has: obj => "toHtmlInternal" in obj, get: obj => obj.toHtmlInternal }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
66
75
|
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
67
76
|
GalleryToken = _classThis = _classDescriptor.value;
|
|
68
77
|
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
@@ -103,6 +112,7 @@ let GalleryToken = (() => {
|
|
|
103
112
|
super(undefined, config, accum, {
|
|
104
113
|
AstText: ':', GalleryImageToken: ':', NoincludeToken: ':',
|
|
105
114
|
});
|
|
115
|
+
__runInitializers(this, _instanceExtraInitializers);
|
|
106
116
|
for (const line of inner?.split('\n') ?? []) {
|
|
107
117
|
const matches = /^([^|]+)(?:\|(.*))?/u.exec(line);
|
|
108
118
|
if (!matches) {
|
|
@@ -183,7 +193,7 @@ let GalleryToken = (() => {
|
|
|
183
193
|
/* NOT FOR BROWSER */
|
|
184
194
|
cloneNode() {
|
|
185
195
|
// @ts-expect-error abstract class
|
|
186
|
-
return
|
|
196
|
+
return new GalleryToken(undefined, this.getAttribute('config'));
|
|
187
197
|
}
|
|
188
198
|
/**
|
|
189
199
|
* Insert an image
|
package/dist/src/heading.js
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
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
|
+
};
|
|
2
9
|
var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
|
3
10
|
function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
|
|
4
11
|
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
|
@@ -26,13 +33,6 @@ var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn,
|
|
|
26
33
|
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
27
34
|
done = true;
|
|
28
35
|
};
|
|
29
|
-
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
|
|
30
|
-
var useValue = arguments.length > 2;
|
|
31
|
-
for (var i = 0; i < initializers.length; i++) {
|
|
32
|
-
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
|
33
|
-
}
|
|
34
|
-
return useValue ? value : void 0;
|
|
35
|
-
};
|
|
36
36
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
37
37
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
38
38
|
};
|
|
@@ -47,9 +47,11 @@ const syntax_1 = require("./syntax");
|
|
|
47
47
|
/* NOT FOR BROWSER */
|
|
48
48
|
const constants_1 = require("../util/constants");
|
|
49
49
|
const string_1 = require("../util/string");
|
|
50
|
+
const html_1 = require("../util/html");
|
|
50
51
|
const fixed_1 = require("../mixin/fixed");
|
|
51
52
|
const sol_1 = require("../mixin/sol");
|
|
52
53
|
const noEscape_1 = require("../mixin/noEscape");
|
|
54
|
+
const cached_1 = require("../mixin/cached");
|
|
53
55
|
/* NOT FOR BROWSER END */
|
|
54
56
|
/**
|
|
55
57
|
* section heading
|
|
@@ -63,16 +65,20 @@ let HeadingToken = (() => {
|
|
|
63
65
|
let _classExtraInitializers = [];
|
|
64
66
|
let _classThis;
|
|
65
67
|
let _classSuper = index_2.Token;
|
|
68
|
+
let _instanceExtraInitializers = [];
|
|
69
|
+
let _toHtmlInternal_decorators;
|
|
66
70
|
var HeadingToken = class extends _classSuper {
|
|
67
71
|
static { _classThis = this; }
|
|
68
72
|
static {
|
|
69
73
|
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
74
|
+
_toHtmlInternal_decorators = [(0, cached_1.cached)()];
|
|
75
|
+
__esDecorate(this, null, _toHtmlInternal_decorators, { kind: "method", name: "toHtmlInternal", static: false, private: false, access: { has: obj => "toHtmlInternal" in obj, get: obj => obj.toHtmlInternal }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
70
76
|
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
71
77
|
HeadingToken = _classThis = _classDescriptor.value;
|
|
72
78
|
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
73
79
|
__runInitializers(_classThis, _classExtraInitializers);
|
|
74
80
|
}
|
|
75
|
-
#level;
|
|
81
|
+
#level = __runInitializers(this, _instanceExtraInitializers);
|
|
76
82
|
/* NOT FOR BROWSER END */
|
|
77
83
|
get type() {
|
|
78
84
|
return 'heading';
|
|
@@ -152,60 +158,69 @@ let HeadingToken = (() => {
|
|
|
152
158
|
lint(start = this.getAbsoluteIndex(), re) {
|
|
153
159
|
const errors = super.lint(start, re), { firstChild, level } = this, innerStr = firstChild.toString(), unbalancedStart = innerStr.startsWith('='), unbalanced = unbalancedStart || innerStr.endsWith('='), quotes = firstChild.childNodes.filter((0, debug_1.isToken)('quote')), boldQuotes = quotes.filter(({ bold }) => bold), italicQuotes = quotes.filter(({ italic }) => italic), rect = new rect_1.BoundingRect(this, start), s = this.inHtmlAttrs();
|
|
154
160
|
if (this.level === 1) {
|
|
155
|
-
const
|
|
156
|
-
if (
|
|
157
|
-
e
|
|
161
|
+
const rule = 'h1', severity = index_1.default.lintConfig.getSeverity(rule);
|
|
162
|
+
if (severity) {
|
|
163
|
+
const e = (0, lint_1.generateForChild)(firstChild, rect, rule, '<h1>', severity);
|
|
164
|
+
if (!unbalanced) {
|
|
165
|
+
e.suggestions = [{ desc: 'h2', range: [e.startIndex, e.endIndex], text: `=${innerStr}=` }];
|
|
166
|
+
}
|
|
167
|
+
errors.push(e);
|
|
158
168
|
}
|
|
159
|
-
errors.push(e);
|
|
160
169
|
}
|
|
161
170
|
if (unbalanced) {
|
|
162
|
-
const
|
|
163
|
-
if (
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
const [extra] = /^=+/u.exec(innerStr), newLevel = level + extra.length;
|
|
168
|
-
e.suggestions = [{ desc: `h${level}`, range: [e.startIndex, e.startIndex + extra.length], text: '' }];
|
|
169
|
-
if (newLevel < 7) {
|
|
170
|
-
e.suggestions.push({ desc: `h${newLevel}`, range: [e.endIndex, e.endIndex], text: extra });
|
|
171
|
+
const rule = 'unbalanced-header', severity = index_1.default.lintConfig.getSeverity(rule);
|
|
172
|
+
if (severity) {
|
|
173
|
+
const msg = index_1.default.msg('unbalanced $1 in a section header', '"="'), e = (0, lint_1.generateForChild)(firstChild, rect, rule, msg, severity);
|
|
174
|
+
if (innerStr === '=') {
|
|
175
|
+
//
|
|
171
176
|
}
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
177
|
+
else if (unbalancedStart) {
|
|
178
|
+
const [extra] = /^=+/u.exec(innerStr), newLevel = level + extra.length;
|
|
179
|
+
e.suggestions = [{ desc: `h${level}`, range: [e.startIndex, e.startIndex + extra.length], text: '' }];
|
|
180
|
+
if (newLevel < 7) {
|
|
181
|
+
e.suggestions.push({ desc: `h${newLevel}`, range: [e.endIndex, e.endIndex], text: extra });
|
|
182
|
+
}
|
|
178
183
|
}
|
|
184
|
+
else {
|
|
185
|
+
const extra = /[^=](=+)$/u.exec(innerStr)[1], newLevel = level + extra.length;
|
|
186
|
+
e.suggestions = [{ desc: `h${level}`, range: [e.endIndex - extra.length, e.endIndex], text: '' }];
|
|
187
|
+
if (newLevel < 7) {
|
|
188
|
+
e.suggestions.push({ desc: `h${newLevel}`, range: [e.startIndex, e.startIndex], text: extra });
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
errors.push(e);
|
|
179
192
|
}
|
|
180
|
-
errors.push(e);
|
|
181
193
|
}
|
|
182
194
|
if (s) {
|
|
183
195
|
errors.push((0, lint_1.generateForSelf)(this, rect, 'parsing-order', 'section header in HTML tag attributes', s));
|
|
184
196
|
}
|
|
185
|
-
const
|
|
186
|
-
if (
|
|
187
|
-
const
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
const e = (0, lint_1.generateForChild)(italicQuotes[italicQuotes.length - 1], { start: start + level }, 'format-leakage', index_1.default.msg('unbalanced $1 in a section header', 'italic apostrophes')), end = start + level + innerStr.length;
|
|
202
|
-
if (rootStr.slice(e.endIndex, end).trim()) {
|
|
203
|
-
e.suggestions = [{ desc: 'close', range: [end, end], text: `''` }];
|
|
197
|
+
const rule = 'format-leakage', severity = index_1.default.lintConfig.getSeverity(rule, 'apostrophe');
|
|
198
|
+
if (severity) {
|
|
199
|
+
const rootStr = this.getRootNode().toString();
|
|
200
|
+
if (boldQuotes.length % 2) {
|
|
201
|
+
const e = (0, lint_1.generateForChild)(boldQuotes[boldQuotes.length - 1], {
|
|
202
|
+
...rect, // eslint-disable-line @typescript-eslint/no-misused-spread
|
|
203
|
+
start: start + level,
|
|
204
|
+
left: rect.left + level,
|
|
205
|
+
}, rule, index_1.default.msg('unbalanced $1 in a section header', 'bold apostrophes'), severity), end = start + level + innerStr.length;
|
|
206
|
+
if (rootStr.slice(e.endIndex, end).trim()) {
|
|
207
|
+
e.suggestions = [{ desc: 'close', range: [end, end], text: `'''` }];
|
|
208
|
+
}
|
|
209
|
+
else {
|
|
210
|
+
e.fix = { desc: 'remove', range: [e.startIndex, e.endIndex], text: '' };
|
|
211
|
+
}
|
|
212
|
+
errors.push(e);
|
|
204
213
|
}
|
|
205
|
-
|
|
206
|
-
e
|
|
214
|
+
if (italicQuotes.length % 2) {
|
|
215
|
+
const e = (0, lint_1.generateForChild)(italicQuotes[italicQuotes.length - 1], { start: start + level }, rule, index_1.default.msg('unbalanced $1 in a section header', 'italic apostrophes'), severity), end = start + level + innerStr.length;
|
|
216
|
+
if (rootStr.slice(e.endIndex, end).trim()) {
|
|
217
|
+
e.suggestions = [{ desc: 'close', range: [end, end], text: `''` }];
|
|
218
|
+
}
|
|
219
|
+
else {
|
|
220
|
+
e.fix = { desc: 'remove', range: [e.startIndex, e.endIndex], text: '' };
|
|
221
|
+
}
|
|
222
|
+
errors.push(e);
|
|
207
223
|
}
|
|
208
|
-
errors.push(e);
|
|
209
224
|
}
|
|
210
225
|
return errors;
|
|
211
226
|
}
|
|
@@ -253,13 +268,7 @@ let HeadingToken = (() => {
|
|
|
253
268
|
* @param expand 是否展开模板
|
|
254
269
|
*/
|
|
255
270
|
#getId(expand) {
|
|
256
|
-
|
|
257
|
-
let id = (0, string_1.decodeHtml)((0, string_1.sanitizeAlt)(token.toHtmlInternal({ nocc: true })))
|
|
258
|
-
.replace(/[\s_]+/gu, '_');
|
|
259
|
-
if (id.endsWith('_')) {
|
|
260
|
-
id = id.slice(0, -1);
|
|
261
|
-
}
|
|
262
|
-
return id;
|
|
271
|
+
return (0, html_1.getId)(this.firstChild[expand ? 'expand' : 'cloneNode']());
|
|
263
272
|
}
|
|
264
273
|
/** @private */
|
|
265
274
|
toHtmlInternal() {
|
package/dist/src/hidden.js
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
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
|
+
};
|
|
2
9
|
var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
|
3
10
|
function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
|
|
4
11
|
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
|
@@ -26,20 +33,13 @@ var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn,
|
|
|
26
33
|
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
27
34
|
done = true;
|
|
28
35
|
};
|
|
29
|
-
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
|
|
30
|
-
var useValue = arguments.length > 2;
|
|
31
|
-
for (var i = 0; i < initializers.length; i++) {
|
|
32
|
-
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
|
33
|
-
}
|
|
34
|
-
return useValue ? value : void 0;
|
|
35
|
-
};
|
|
36
36
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
37
37
|
exports.HiddenToken = void 0;
|
|
38
38
|
const hidden_1 = require("../mixin/hidden");
|
|
39
39
|
const index_1 = require("./index");
|
|
40
40
|
/* NOT FOR BROWSER */
|
|
41
41
|
const constants_1 = require("../util/constants");
|
|
42
|
-
const
|
|
42
|
+
const clone_1 = require("../mixin/clone");
|
|
43
43
|
/* NOT FOR BROWSER END */
|
|
44
44
|
/**
|
|
45
45
|
* invisible token
|
|
@@ -52,10 +52,14 @@ let HiddenToken = (() => {
|
|
|
52
52
|
let _classExtraInitializers = [];
|
|
53
53
|
let _classThis;
|
|
54
54
|
let _classSuper = index_1.Token;
|
|
55
|
+
let _instanceExtraInitializers = [];
|
|
56
|
+
let _cloneNode_decorators;
|
|
55
57
|
var HiddenToken = class extends _classSuper {
|
|
56
58
|
static { _classThis = this; }
|
|
57
59
|
static {
|
|
58
60
|
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
61
|
+
_cloneNode_decorators = [clone_1.clone];
|
|
62
|
+
__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);
|
|
59
63
|
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
60
64
|
HiddenToken = _classThis = _classDescriptor.value;
|
|
61
65
|
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
@@ -76,9 +80,10 @@ let HiddenToken = (() => {
|
|
|
76
80
|
super(wikitext, config, accum, {
|
|
77
81
|
'Stage-2': ':', '!HeadingToken': '',
|
|
78
82
|
});
|
|
83
|
+
__runInitializers(this, _instanceExtraInitializers);
|
|
79
84
|
}
|
|
80
85
|
cloneNode() {
|
|
81
|
-
return
|
|
86
|
+
return new HiddenToken(undefined, this.getAttribute('config'));
|
|
82
87
|
}
|
|
83
88
|
};
|
|
84
89
|
return HiddenToken = _classThis;
|
package/dist/src/html.js
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
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
|
+
};
|
|
2
9
|
var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
|
3
10
|
function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
|
|
4
11
|
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
|
@@ -26,13 +33,6 @@ var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn,
|
|
|
26
33
|
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
27
34
|
done = true;
|
|
28
35
|
};
|
|
29
|
-
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
|
|
30
|
-
var useValue = arguments.length > 2;
|
|
31
|
-
for (var i = 0; i < initializers.length; i++) {
|
|
32
|
-
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
|
33
|
-
}
|
|
34
|
-
return useValue ? value : void 0;
|
|
35
|
-
};
|
|
36
36
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
37
37
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
38
38
|
};
|
|
@@ -48,7 +48,9 @@ const index_2 = __importDefault(require("../index"));
|
|
|
48
48
|
/* PRINT ONLY END */
|
|
49
49
|
/* NOT FOR BROWSER */
|
|
50
50
|
const constants_1 = require("../util/constants");
|
|
51
|
+
const html_1 = require("../util/html");
|
|
51
52
|
const fixed_1 = require("../mixin/fixed");
|
|
53
|
+
const cached_1 = require("../mixin/cached");
|
|
52
54
|
const magicWords = new Set(['if', 'ifeq', 'ifexpr', 'ifexist', 'iferror', 'switch']), formattingTags = new Set([
|
|
53
55
|
'b',
|
|
54
56
|
'big',
|
|
@@ -88,16 +90,20 @@ let HtmlToken = (() => {
|
|
|
88
90
|
let _classExtraInitializers = [];
|
|
89
91
|
let _classThis;
|
|
90
92
|
let _classSuper = index_1.Token;
|
|
93
|
+
let _instanceExtraInitializers = [];
|
|
94
|
+
let _toHtmlInternal_decorators;
|
|
91
95
|
var HtmlToken = class extends _classSuper {
|
|
92
96
|
static { _classThis = this; }
|
|
93
97
|
static {
|
|
94
98
|
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
99
|
+
_toHtmlInternal_decorators = [(0, cached_1.cached)()];
|
|
100
|
+
__esDecorate(this, null, _toHtmlInternal_decorators, { kind: "method", name: "toHtmlInternal", static: false, private: false, access: { has: obj => "toHtmlInternal" in obj, get: obj => obj.toHtmlInternal }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
95
101
|
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
96
102
|
HtmlToken = _classThis = _classDescriptor.value;
|
|
97
103
|
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
98
104
|
__runInitializers(_classThis, _classExtraInitializers);
|
|
99
105
|
}
|
|
100
|
-
#closing;
|
|
106
|
+
#closing = __runInitializers(this, _instanceExtraInitializers);
|
|
101
107
|
#selfClosing;
|
|
102
108
|
#tag;
|
|
103
109
|
#match;
|
|
@@ -367,7 +373,20 @@ let HtmlToken = (() => {
|
|
|
367
373
|
if (voidTags.includes(name)) {
|
|
368
374
|
return closing && name !== 'br' ? '' : `<${tag}>`;
|
|
369
375
|
}
|
|
370
|
-
|
|
376
|
+
const result = `<${closing ? '/' : ''}${tag}>${this.#selfClosing && !closing && selfClosingTags.includes(name) ? `</${name}>` : ''}`;
|
|
377
|
+
if (/^h\d$/u.test(name) && (this.closing || !this.id)) {
|
|
378
|
+
const matched = this.findMatchingTag();
|
|
379
|
+
if (matched) {
|
|
380
|
+
if (closing) {
|
|
381
|
+
return result + (matched.id ? '' : '</div>');
|
|
382
|
+
}
|
|
383
|
+
const range = this.createRange();
|
|
384
|
+
range.setStartAfter(this);
|
|
385
|
+
range.setEndBefore(matched);
|
|
386
|
+
return `<div class="mw-heading mw-heading${name.slice(-1)}">${result.slice(0, -1)} id="${(0, html_1.getId)(range.cloneContents())}">`;
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
return result;
|
|
371
390
|
}
|
|
372
391
|
};
|
|
373
392
|
return HtmlToken = _classThis;
|
|
@@ -55,6 +55,7 @@ function validate(key, val, config, halfParsed, ext) {
|
|
|
55
55
|
return Boolean(value) && !isNaN(value);
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
|
+
/* eslint-enable jsdoc/check-param-names */
|
|
58
59
|
/**
|
|
59
60
|
* image parameter
|
|
60
61
|
*
|
|
@@ -197,14 +198,20 @@ class ImageParameterToken extends index_2.Token {
|
|
|
197
198
|
lint(start = this.getAbsoluteIndex(), re) {
|
|
198
199
|
const errors = super.lint(start, re), { link, name } = this;
|
|
199
200
|
if (name === 'invalid') {
|
|
200
|
-
const
|
|
201
|
-
|
|
202
|
-
|
|
201
|
+
const rule = 'invalid-gallery', s = index_1.default.lintConfig.getSeverity(rule, 'parameter');
|
|
202
|
+
if (s) {
|
|
203
|
+
const e = (0, lint_1.generateForSelf)(this, { start }, rule, 'invalid image parameter', s);
|
|
204
|
+
e.fix = { desc: 'remove', range: [start - 1, e.endIndex], text: '' };
|
|
205
|
+
errors.push(e);
|
|
206
|
+
}
|
|
203
207
|
}
|
|
204
208
|
else if (typeof link === 'object' && link.encoded) {
|
|
205
|
-
const
|
|
206
|
-
|
|
207
|
-
|
|
209
|
+
const rule = 'url-encoding', s = index_1.default.lintConfig.getSeverity(rule, 'file');
|
|
210
|
+
if (s) {
|
|
211
|
+
const e = (0, lint_1.generateForSelf)(this, { start }, rule, 'unnecessary URL encoding in an internal link', s);
|
|
212
|
+
e.suggestions = [{ desc: 'decode', range: [start, e.endIndex], text: (0, string_1.rawurldecode)(this.text()) }];
|
|
213
|
+
errors.push(e);
|
|
214
|
+
}
|
|
208
215
|
}
|
|
209
216
|
return errors;
|
|
210
217
|
}
|
package/dist/src/imagemap.js
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
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
|
+
};
|
|
2
9
|
var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
|
3
10
|
function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
|
|
4
11
|
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
|
@@ -26,13 +33,6 @@ var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn,
|
|
|
26
33
|
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
27
34
|
done = true;
|
|
28
35
|
};
|
|
29
|
-
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
|
|
30
|
-
var useValue = arguments.length > 2;
|
|
31
|
-
for (var i = 0; i < initializers.length; i++) {
|
|
32
|
-
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
|
33
|
-
}
|
|
34
|
-
return useValue ? value : void 0;
|
|
35
|
-
};
|
|
36
36
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
37
37
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
38
38
|
};
|
|
@@ -49,7 +49,7 @@ const galleryImage_1 = require("./link/galleryImage");
|
|
|
49
49
|
const imagemapLink_1 = require("./imagemapLink");
|
|
50
50
|
/* NOT FOR BROWSER */
|
|
51
51
|
const constants_1 = require("../util/constants");
|
|
52
|
-
const
|
|
52
|
+
const clone_1 = require("../mixin/clone");
|
|
53
53
|
const singleLine_1 = require("../mixin/singleLine");
|
|
54
54
|
/**
|
|
55
55
|
* `<imagemap>`
|
|
@@ -61,10 +61,14 @@ let ImagemapToken = (() => {
|
|
|
61
61
|
let _classExtraInitializers = [];
|
|
62
62
|
let _classThis;
|
|
63
63
|
let _classSuper = index_2.Token;
|
|
64
|
+
let _instanceExtraInitializers = [];
|
|
65
|
+
let _cloneNode_decorators;
|
|
64
66
|
var ImagemapToken = class extends _classSuper {
|
|
65
67
|
static { _classThis = this; }
|
|
66
68
|
static {
|
|
67
69
|
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
70
|
+
_cloneNode_decorators = [clone_1.clone];
|
|
71
|
+
__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);
|
|
68
72
|
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
69
73
|
ImagemapToken = _classThis = _classDescriptor.value;
|
|
70
74
|
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
@@ -83,6 +87,7 @@ let ImagemapToken = (() => {
|
|
|
83
87
|
super(undefined, config, accum, {
|
|
84
88
|
GalleryImageToken: ':', ImagemapLinkToken: ':', NoincludeToken: ':', AstText: ':',
|
|
85
89
|
});
|
|
90
|
+
__runInitializers(this, _instanceExtraInitializers);
|
|
86
91
|
if (!inner) {
|
|
87
92
|
return;
|
|
88
93
|
}
|
|
@@ -143,22 +148,24 @@ let ImagemapToken = (() => {
|
|
|
143
148
|
}
|
|
144
149
|
/** @private */
|
|
145
150
|
lint(start = this.getAbsoluteIndex(), re) {
|
|
146
|
-
const errors = super.lint(start, re), rect = new rect_1.BoundingRect(this, start);
|
|
147
|
-
if (
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
151
|
+
const errors = super.lint(start, re), rect = new rect_1.BoundingRect(this, start), { childNodes, image } = this, rule = 'invalid-imagemap', s = index_1.default.lintConfig.getSeverity(rule, image ? 'link' : 'image');
|
|
152
|
+
if (s) {
|
|
153
|
+
if (image) {
|
|
154
|
+
errors.push(...childNodes.filter(child => {
|
|
155
|
+
const str = child.toString().trim();
|
|
156
|
+
return child.is('noinclude') && str && !str.startsWith('#');
|
|
157
|
+
}).map(child => {
|
|
158
|
+
const e = (0, lint_1.generateForChild)(child, rect, rule, 'invalid link in <imagemap>', s);
|
|
159
|
+
e.suggestions = [
|
|
160
|
+
{ desc: 'remove', range: [e.startIndex - 1, e.endIndex], text: '' },
|
|
161
|
+
{ desc: 'comment', range: [e.startIndex, e.startIndex], text: '# ' },
|
|
162
|
+
];
|
|
163
|
+
return e;
|
|
164
|
+
}));
|
|
165
|
+
}
|
|
166
|
+
else {
|
|
167
|
+
errors.push((0, lint_1.generateForSelf)(this, rect, rule, '<imagemap> without an image', s));
|
|
168
|
+
}
|
|
162
169
|
}
|
|
163
170
|
return errors;
|
|
164
171
|
}
|
|
@@ -190,7 +197,7 @@ let ImagemapToken = (() => {
|
|
|
190
197
|
}
|
|
191
198
|
cloneNode() {
|
|
192
199
|
// @ts-expect-error abstract class
|
|
193
|
-
return
|
|
200
|
+
return new ImagemapToken(undefined, this.getAttribute('config'));
|
|
194
201
|
}
|
|
195
202
|
};
|
|
196
203
|
return ImagemapToken = _classThis;
|