wikiparser-node 1.25.0 → 1.25.1
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 +2 -2
- package/bundle/bundle-es8.min.js +25 -24
- package/bundle/bundle-lsp.min.js +29 -28
- package/bundle/bundle.min.js +25 -25
- package/dist/addon/token.js +1 -1
- package/dist/base.d.mts +2 -1
- package/dist/base.d.ts +2 -1
- package/dist/bin/config.js +1 -1
- package/dist/index.d.ts +4 -3
- package/dist/index.js +74 -52
- package/dist/lib/element.js +33 -29
- package/dist/lib/text.js +174 -171
- package/dist/mixin/hidden.js +1 -1
- package/dist/mixin/noEscape.js +9 -7
- package/dist/parser/links.js +10 -4
- package/dist/src/arg.js +39 -33
- package/dist/src/attribute.js +52 -38
- package/dist/src/attributes.js +54 -51
- package/dist/src/commented.js +2 -1
- package/dist/src/converterFlags.js +20 -18
- package/dist/src/converterRule.js +6 -3
- package/dist/src/extLink.js +6 -4
- package/dist/src/gallery.js +48 -42
- package/dist/src/heading.js +65 -61
- package/dist/src/html.js +75 -71
- package/dist/src/imageParameter.js +17 -15
- package/dist/src/imagemap.js +20 -18
- package/dist/src/index.js +100 -99
- package/dist/src/link/base.js +38 -33
- package/dist/src/link/category.js +11 -6
- package/dist/src/link/file.js +87 -77
- package/dist/src/link/galleryImage.js +8 -6
- package/dist/src/link/index.js +8 -6
- package/dist/src/link/redirectTarget.js +10 -8
- package/dist/src/magicLink.js +22 -20
- package/dist/src/nested.js +29 -27
- package/dist/src/nowiki/comment.js +11 -9
- package/dist/src/nowiki/index.js +9 -7
- package/dist/src/nowiki/listBase.js +8 -5
- package/dist/src/nowiki/quote.js +29 -25
- package/dist/src/paramTag/index.js +24 -22
- package/dist/src/parameter.js +29 -23
- package/dist/src/pre.js +1 -1
- package/dist/src/redirect.js +5 -3
- package/dist/src/syntax.js +1 -1
- package/dist/src/table/index.js +35 -31
- package/dist/src/table/td.js +24 -19
- package/dist/src/table/trBase.js +13 -11
- package/dist/src/tagPair/ext.js +13 -10
- package/dist/src/tagPair/include.js +13 -11
- package/dist/src/transclude.js +39 -37
- package/dist/util/constants.js +2 -1
- package/dist/util/lint.js +2 -1
- package/extensions/dist/base.js +1 -1
- package/package.json +2 -2
package/dist/src/attribute.js
CHANGED
|
@@ -212,11 +212,13 @@ let AttributeToken = (() => {
|
|
|
212
212
|
return true;
|
|
213
213
|
}
|
|
214
214
|
/* PRINT ONLY END */
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
215
|
+
LINT: { // eslint-disable-line no-unused-labels
|
|
216
|
+
const s = index_1.default.lintConfig.getSeverity(rule, 'unknown');
|
|
217
|
+
if (s) {
|
|
218
|
+
const e = (0, lint_1.generateForChild)(firstChild, rect, rule, 'illegal-attribute-name', s);
|
|
219
|
+
e.suggestions = [(0, lint_1.fixByRemove)(start, length)];
|
|
220
|
+
return e;
|
|
221
|
+
}
|
|
220
222
|
}
|
|
221
223
|
}
|
|
222
224
|
else if (name === 'style' && typeof value === 'string' && insecureStyle.test(value)) {
|
|
@@ -225,9 +227,11 @@ let AttributeToken = (() => {
|
|
|
225
227
|
return true;
|
|
226
228
|
}
|
|
227
229
|
/* PRINT ONLY END */
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
230
|
+
LINT: { // eslint-disable-line no-unused-labels
|
|
231
|
+
rule = 'insecure-style';
|
|
232
|
+
const s = index_1.default.lintConfig.getSeverity(rule);
|
|
233
|
+
return s && (0, lint_1.generateForChild)(lastChild, rect, rule, 'insecure-style', s);
|
|
234
|
+
}
|
|
231
235
|
}
|
|
232
236
|
else if (name === 'tabindex' && typeof value === 'string' && value !== '0') {
|
|
233
237
|
/* PRINT ONLY */
|
|
@@ -235,14 +239,16 @@ let AttributeToken = (() => {
|
|
|
235
239
|
return true;
|
|
236
240
|
}
|
|
237
241
|
/* PRINT ONLY END */
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
242
|
+
LINT: { // eslint-disable-line no-unused-labels
|
|
243
|
+
const s = index_1.default.lintConfig.getSeverity(rule, 'tabindex');
|
|
244
|
+
if (s) {
|
|
245
|
+
const e = (0, lint_1.generateForChild)(lastChild, rect, rule, 'nonzero-tabindex', s);
|
|
246
|
+
e.suggestions = [
|
|
247
|
+
(0, lint_1.fixByRemove)(start, length),
|
|
248
|
+
(0, lint_1.fixBy)(e, '0 tabindex', '0'),
|
|
249
|
+
];
|
|
250
|
+
return e;
|
|
251
|
+
}
|
|
246
252
|
}
|
|
247
253
|
}
|
|
248
254
|
else if (simple && type !== 'ext-attr') {
|
|
@@ -253,8 +259,10 @@ let AttributeToken = (() => {
|
|
|
253
259
|
return true;
|
|
254
260
|
}
|
|
255
261
|
/* PRINT ONLY END */
|
|
256
|
-
|
|
257
|
-
|
|
262
|
+
LINT: { // eslint-disable-line no-unused-labels
|
|
263
|
+
const s = index_1.default.lintConfig.getSeverity(rule, 'value');
|
|
264
|
+
return s && (0, lint_1.generateForChild)(lastChild, rect, rule, 'illegal-attribute-value', s);
|
|
265
|
+
}
|
|
258
266
|
}
|
|
259
267
|
}
|
|
260
268
|
else if (typeof value === 'string' && ((/^xmlns:[\w:.-]+$/u.test(name) || urlAttrs.has(name)) && evil.test(value)
|
|
@@ -267,29 +275,33 @@ let AttributeToken = (() => {
|
|
|
267
275
|
return true;
|
|
268
276
|
}
|
|
269
277
|
/* PRINT ONLY END */
|
|
270
|
-
|
|
271
|
-
|
|
278
|
+
LINT: { // eslint-disable-line no-unused-labels
|
|
279
|
+
const s = index_1.default.lintConfig.getSeverity(rule, 'value');
|
|
280
|
+
return s && (0, lint_1.generateForChild)(lastChild, rect, rule, 'illegal-attribute-value', s);
|
|
281
|
+
}
|
|
272
282
|
}
|
|
273
283
|
return false;
|
|
274
284
|
}
|
|
275
285
|
/** @private */
|
|
276
286
|
lint(start = this.getAbsoluteIndex(), re) {
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
287
|
+
LINT: { // eslint-disable-line no-unused-labels
|
|
288
|
+
const errors = super.lint(start, re), { balanced, firstChild, lastChild, name, tag } = this, rect = new rect_1.BoundingRect(this, start), rules = ['unclosed-quote', 'obsolete-attr'], s = rules.map(rule => index_1.default.lintConfig.getSeverity(rule, name));
|
|
289
|
+
if (s[0] && !balanced) {
|
|
290
|
+
const e = (0, lint_1.generateForChild)(lastChild, rect, rules[0], index_1.default.msg('unclosed', 'quotes'), s[0]);
|
|
291
|
+
e.startIndex--;
|
|
292
|
+
e.startCol--;
|
|
293
|
+
e.suggestions = [(0, lint_1.fixByClose)(e.endIndex, this.#quotes[0])];
|
|
294
|
+
errors.push(e);
|
|
295
|
+
}
|
|
296
|
+
const e = this.#lint(start, rect);
|
|
297
|
+
if (e) {
|
|
298
|
+
errors.push(e);
|
|
299
|
+
}
|
|
300
|
+
if (s[1] && sharable_1.obsoleteAttrs[tag]?.has(name)) {
|
|
301
|
+
errors.push((0, lint_1.generateForChild)(firstChild, rect, rules[1], 'obsolete-attribute', s[1]));
|
|
302
|
+
}
|
|
303
|
+
return errors;
|
|
304
|
+
}
|
|
293
305
|
}
|
|
294
306
|
/**
|
|
295
307
|
* Get the attribute value
|
|
@@ -318,8 +330,10 @@ let AttributeToken = (() => {
|
|
|
318
330
|
/** @private */
|
|
319
331
|
json(_, start = this.getAbsoluteIndex()) {
|
|
320
332
|
const json = super.json(undefined, start);
|
|
321
|
-
|
|
322
|
-
|
|
333
|
+
LSP: { // eslint-disable-line no-unused-labels
|
|
334
|
+
json['tag'] = this.tag;
|
|
335
|
+
return json;
|
|
336
|
+
}
|
|
323
337
|
}
|
|
324
338
|
/* PRINT ONLY END */
|
|
325
339
|
/* NOT FOR BROWSER */
|
package/dist/src/attributes.js
CHANGED
|
@@ -62,14 +62,15 @@ const toAttributeType = (type) => type.slice(0, -1);
|
|
|
62
62
|
* @param type 属性类型
|
|
63
63
|
*/
|
|
64
64
|
const toDirty = (type) => `${toAttributeType(type)}-dirty`;
|
|
65
|
-
|
|
66
|
-
try {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
}
|
|
70
|
-
catch /* istanbul ignore next */ {
|
|
71
|
-
|
|
72
|
-
}
|
|
65
|
+
const wordRegex = /* #__PURE__ */ (() => {
|
|
66
|
+
try {
|
|
67
|
+
// eslint-disable-next-line prefer-regex-literals
|
|
68
|
+
return new RegExp(String.raw `[\p{L}\p{N}]`, 'u');
|
|
69
|
+
}
|
|
70
|
+
catch /* istanbul ignore next */ {
|
|
71
|
+
return /[^\W_]/u;
|
|
72
|
+
}
|
|
73
|
+
})();
|
|
73
74
|
/**
|
|
74
75
|
* attributes of extension and HTML tags
|
|
75
76
|
*
|
|
@@ -248,56 +249,58 @@ let AttributesToken = (() => {
|
|
|
248
249
|
}
|
|
249
250
|
/** @private */
|
|
250
251
|
lint(start = this.getAbsoluteIndex(), re) {
|
|
251
|
-
|
|
252
|
-
.
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
252
|
+
LINT: { // eslint-disable-line no-unused-labels
|
|
253
|
+
const errors = super.lint(start, re), { parentNode, childNodes } = this, attrs = new Map(), duplicated = new Set(), rect = new rect_1.BoundingRect(this, start), rules = ['no-ignored', 'no-duplicate'], s = ['closingTag', 'invalidAttributes', 'nonWordAttributes']
|
|
254
|
+
.map(k => index_1.default.lintConfig.getSeverity(rules[0], k));
|
|
255
|
+
if (s[0] && this.#lint()) {
|
|
256
|
+
const e = (0, lint_1.generateForSelf)(this, rect, rules[0], 'attributes-of-closing-tag', s[0]), index = parentNode.getAbsoluteIndex();
|
|
257
|
+
e.suggestions = [
|
|
258
|
+
(0, lint_1.fixByRemove)(e),
|
|
259
|
+
(0, lint_1.fixByOpen)(index),
|
|
260
|
+
];
|
|
261
|
+
errors.push(e);
|
|
262
|
+
}
|
|
263
|
+
for (const attr of childNodes) {
|
|
264
|
+
if (attr instanceof attribute_1.AttributeToken) {
|
|
265
|
+
const { name } = attr;
|
|
266
|
+
if (attrs.has(name)) {
|
|
267
|
+
duplicated.add(name);
|
|
268
|
+
attrs.get(name).push(attr);
|
|
269
|
+
}
|
|
270
|
+
else {
|
|
271
|
+
attrs.set(name, [attr]);
|
|
272
|
+
}
|
|
267
273
|
}
|
|
268
274
|
else {
|
|
269
|
-
|
|
275
|
+
const str = attr.text().trim(), severity = s[wordRegex.test(str) ? 1 : 2];
|
|
276
|
+
if (str && severity) {
|
|
277
|
+
const e = (0, lint_1.generateForChild)(attr, rect, rules[0], 'invalid-attribute', severity);
|
|
278
|
+
e.suggestions = [(0, lint_1.fixByRemove)(e, 0, ' ')];
|
|
279
|
+
errors.push(e);
|
|
280
|
+
}
|
|
270
281
|
}
|
|
271
282
|
}
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
const
|
|
276
|
-
|
|
277
|
-
|
|
283
|
+
const severity = index_1.default.lintConfig.getSeverity(rules[1], 'attribute');
|
|
284
|
+
if (severity && duplicated.size > 0) {
|
|
285
|
+
for (const key of duplicated) {
|
|
286
|
+
const pairs = attrs.get(key).map(attr => {
|
|
287
|
+
const value = attr.getValue();
|
|
288
|
+
return [attr, value === true ? '' : value];
|
|
289
|
+
});
|
|
290
|
+
errors.push(...pairs.map(([attr, value], i) => {
|
|
291
|
+
const e = (0, lint_1.generateForChild)(attr, rect, rules[1], index_1.default.msg('duplicate-attribute', key), severity), remove = (0, lint_1.fixByRemove)(e);
|
|
292
|
+
if (!value || pairs.slice(0, i).some(([, v]) => v === value)) {
|
|
293
|
+
e.fix = remove;
|
|
294
|
+
}
|
|
295
|
+
else {
|
|
296
|
+
e.suggestions = [remove];
|
|
297
|
+
}
|
|
298
|
+
return e;
|
|
299
|
+
}));
|
|
278
300
|
}
|
|
279
301
|
}
|
|
302
|
+
return errors;
|
|
280
303
|
}
|
|
281
|
-
const severity = index_1.default.lintConfig.getSeverity(rules[1], 'attribute');
|
|
282
|
-
if (severity && duplicated.size > 0) {
|
|
283
|
-
for (const key of duplicated) {
|
|
284
|
-
const pairs = attrs.get(key).map(attr => {
|
|
285
|
-
const value = attr.getValue();
|
|
286
|
-
return [attr, value === true ? '' : value];
|
|
287
|
-
});
|
|
288
|
-
errors.push(...pairs.map(([attr, value], i) => {
|
|
289
|
-
const e = (0, lint_1.generateForChild)(attr, rect, rules[1], index_1.default.msg('duplicate-attribute', key), severity), remove = (0, lint_1.fixByRemove)(e);
|
|
290
|
-
if (!value || pairs.slice(0, i).some(([, v]) => v === value)) {
|
|
291
|
-
e.fix = remove;
|
|
292
|
-
}
|
|
293
|
-
else {
|
|
294
|
-
e.suggestions = [remove];
|
|
295
|
-
}
|
|
296
|
-
return e;
|
|
297
|
-
}));
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
return errors;
|
|
301
304
|
}
|
|
302
305
|
/* PRINT ONLY */
|
|
303
306
|
/** @private */
|
package/dist/src/commented.js
CHANGED
|
@@ -85,7 +85,8 @@ let CommentedToken = (() => {
|
|
|
85
85
|
}
|
|
86
86
|
/** @private */
|
|
87
87
|
lint(start = this.getAbsoluteIndex()) {
|
|
88
|
-
|
|
88
|
+
// eslint-disable-next-line no-unused-labels
|
|
89
|
+
LINT: return super.lint(start, new RegExp(String.raw `<\s*(?:\/\s*)?(${this.name})\b`, 'giu'));
|
|
89
90
|
}
|
|
90
91
|
/* NOT FOR BROWSER */
|
|
91
92
|
cloneNode() {
|
|
@@ -150,28 +150,30 @@ let ConverterFlagsToken = (() => {
|
|
|
150
150
|
}
|
|
151
151
|
/** @private */
|
|
152
152
|
lint(start = this.getAbsoluteIndex(), re) {
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
153
|
+
LINT: { // eslint-disable-line no-unused-labels
|
|
154
|
+
const variantFlags = this.getVariantFlags(), unknownFlags = this.getUnknownFlags(), validFlags = new Set(this.#flags.filter(flag => definedFlags.has(flag))), emptyFlagCount = this.#flags.filter(flag => !flag).length, knownFlagCount = this.#flags.length - unknownFlags.size - emptyFlagCount, errors = super.lint(start, re);
|
|
155
|
+
if (variantFlags.size === knownFlagCount || validFlags.size === knownFlagCount) {
|
|
156
|
+
return errors;
|
|
157
|
+
}
|
|
158
|
+
const rule = 'no-ignored', s = index_1.default.lintConfig.getSeverity(rule, 'conversionFlag');
|
|
159
|
+
if (s) {
|
|
160
|
+
const rect = new rect_1.BoundingRect(this, start);
|
|
161
|
+
for (let i = 0; i < this.length; i++) {
|
|
162
|
+
const child = this.childNodes[i], flag = child.text().trim();
|
|
163
|
+
if (this.isInvalidFlag(flag, variantFlags, unknownFlags, validFlags)) {
|
|
164
|
+
const e = (0, lint_1.generateForChild)(child, rect, rule, 'invalid-conversion-flag', s);
|
|
165
|
+
if (variantFlags.size === 0 && definedFlags.has(flag.toUpperCase())) {
|
|
166
|
+
e.fix = (0, lint_1.fixByUpper)(e, flag);
|
|
167
|
+
}
|
|
168
|
+
else {
|
|
169
|
+
e.suggestions = [(0, lint_1.fixByRemove)(e, i && -1)];
|
|
170
|
+
}
|
|
171
|
+
errors.push(e);
|
|
169
172
|
}
|
|
170
|
-
errors.push(e);
|
|
171
173
|
}
|
|
172
174
|
}
|
|
175
|
+
return errors;
|
|
173
176
|
}
|
|
174
|
-
return errors;
|
|
175
177
|
}
|
|
176
178
|
/** @private */
|
|
177
179
|
print() {
|
|
@@ -71,7 +71,8 @@ let ConverterRuleToken = (() => {
|
|
|
71
71
|
/* PRINT ONLY */
|
|
72
72
|
/** language variant / 语言变体 */
|
|
73
73
|
get variant() {
|
|
74
|
-
|
|
74
|
+
// eslint-disable-next-line no-unused-labels
|
|
75
|
+
LSP: return this.childNodes[this.length - 2]?.text().trim().toLowerCase() ?? '';
|
|
75
76
|
}
|
|
76
77
|
/* PRINT ONLY END */
|
|
77
78
|
/* NOT FOR BROWSER */
|
|
@@ -168,8 +169,10 @@ let ConverterRuleToken = (() => {
|
|
|
168
169
|
/** @private */
|
|
169
170
|
json(_, start = this.getAbsoluteIndex()) {
|
|
170
171
|
const json = super.json(undefined, start);
|
|
171
|
-
|
|
172
|
-
|
|
172
|
+
LSP: { // eslint-disable-line no-unused-labels
|
|
173
|
+
json['variant'] = this.variant;
|
|
174
|
+
return json;
|
|
175
|
+
}
|
|
173
176
|
}
|
|
174
177
|
/* NOT FOR BROWSER */
|
|
175
178
|
cloneNode() {
|
package/dist/src/extLink.js
CHANGED
|
@@ -157,11 +157,13 @@ let ExtLinkToken = (() => {
|
|
|
157
157
|
}
|
|
158
158
|
/** @private */
|
|
159
159
|
lint(start = this.getAbsoluteIndex(), re) {
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
160
|
+
LINT: { // eslint-disable-line no-unused-labels
|
|
161
|
+
const errors = super.lint(start, re), rule = 'var-anchor', s = index_1.default.lintConfig.getSeverity(rule, 'extLink');
|
|
162
|
+
if (s && this.length === 1 && this.closest('heading-title')) {
|
|
163
|
+
errors.push((0, lint_1.generateForSelf)(this, { start }, rule, 'variable-anchor', s));
|
|
164
|
+
}
|
|
165
|
+
return errors;
|
|
163
166
|
}
|
|
164
|
-
return errors;
|
|
165
167
|
}
|
|
166
168
|
/** @private */
|
|
167
169
|
print() {
|
package/dist/src/gallery.js
CHANGED
|
@@ -90,7 +90,7 @@ let GalleryToken = (() => {
|
|
|
90
90
|
* @since v1.12.5
|
|
91
91
|
*/
|
|
92
92
|
get widths() {
|
|
93
|
-
return this.#getSize('widths');
|
|
93
|
+
LSP: return this.#getSize('widths'); // eslint-disable-line no-unused-labels
|
|
94
94
|
}
|
|
95
95
|
/**
|
|
96
96
|
* image heights
|
|
@@ -99,7 +99,7 @@ let GalleryToken = (() => {
|
|
|
99
99
|
* @since v1.12.5
|
|
100
100
|
*/
|
|
101
101
|
get heights() {
|
|
102
|
-
return this.#getSize('heights');
|
|
102
|
+
LSP: return this.#getSize('heights'); // eslint-disable-line no-unused-labels
|
|
103
103
|
}
|
|
104
104
|
/* PRINT ONLY END */
|
|
105
105
|
/* NOT FOR BROWSER */
|
|
@@ -141,46 +141,48 @@ let GalleryToken = (() => {
|
|
|
141
141
|
}
|
|
142
142
|
/** @private */
|
|
143
143
|
lint(start = this.getAbsoluteIndex(), re) {
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
144
|
+
LINT: { // eslint-disable-line no-unused-labels
|
|
145
|
+
const { top, left } = this.getRootNode().posFromIndex(start), errors = [], rule = 'no-ignored', s = ['Image', 'NoImage', 'Comment'].map(k => index_1.default.lintConfig.getSeverity(rule, `gallery${k}`));
|
|
146
|
+
for (let i = 0; i < this.length; i++) {
|
|
147
|
+
const child = this.childNodes[i], str = child.toString(), { length } = str, trimmed = str.trim(), { type } = child, startLine = top + i, startCol = i ? 0 : left;
|
|
148
|
+
child.setAttribute('aIndex', start);
|
|
149
|
+
if (type === 'noinclude' && trimmed && !/^<!--.*-->$/u.test(trimmed)) {
|
|
150
|
+
let [severity] = s;
|
|
151
|
+
if (trimmed.startsWith('|')) {
|
|
152
|
+
[, severity] = s;
|
|
153
|
+
}
|
|
154
|
+
else if (trimmed.startsWith('<!--') || trimmed.endsWith('-->')) {
|
|
155
|
+
[, , severity] = s;
|
|
156
|
+
}
|
|
157
|
+
if (severity) {
|
|
158
|
+
const endIndex = start + length, e = {
|
|
159
|
+
rule,
|
|
160
|
+
message: index_1.default.msg('invalid-content', 'gallery'),
|
|
161
|
+
severity,
|
|
162
|
+
startIndex: start,
|
|
163
|
+
endIndex,
|
|
164
|
+
startLine,
|
|
165
|
+
endLine: startLine,
|
|
166
|
+
startCol,
|
|
167
|
+
endCol: startCol + length,
|
|
168
|
+
};
|
|
169
|
+
e.suggestions = [
|
|
170
|
+
(0, lint_1.fixByRemove)(e),
|
|
171
|
+
(0, lint_1.fixByComment)(e, str),
|
|
172
|
+
];
|
|
173
|
+
errors.push(e);
|
|
174
|
+
}
|
|
152
175
|
}
|
|
153
|
-
else if (
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
rule,
|
|
159
|
-
message: index_1.default.msg('invalid-content', 'gallery'),
|
|
160
|
-
severity,
|
|
161
|
-
startIndex: start,
|
|
162
|
-
endIndex,
|
|
163
|
-
startLine,
|
|
164
|
-
endLine: startLine,
|
|
165
|
-
startCol,
|
|
166
|
-
endCol: startCol + length,
|
|
167
|
-
};
|
|
168
|
-
e.suggestions = [
|
|
169
|
-
(0, lint_1.fixByRemove)(e),
|
|
170
|
-
(0, lint_1.fixByComment)(e, str),
|
|
171
|
-
];
|
|
172
|
-
errors.push(e);
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
else if (type !== 'noinclude' && type !== 'text') {
|
|
176
|
-
const childErrors = child.lint(start, re);
|
|
177
|
-
if (childErrors.length > 0) {
|
|
178
|
-
errors.push(...childErrors);
|
|
176
|
+
else if (type !== 'noinclude' && type !== 'text') {
|
|
177
|
+
const childErrors = child.lint(start, re);
|
|
178
|
+
if (childErrors.length > 0) {
|
|
179
|
+
errors.push(...childErrors);
|
|
180
|
+
}
|
|
179
181
|
}
|
|
182
|
+
start += length + 1;
|
|
180
183
|
}
|
|
181
|
-
|
|
184
|
+
return errors;
|
|
182
185
|
}
|
|
183
|
-
return errors;
|
|
184
186
|
}
|
|
185
187
|
/* PRINT ONLY */
|
|
186
188
|
/**
|
|
@@ -188,14 +190,18 @@ let GalleryToken = (() => {
|
|
|
188
190
|
* @param key `widths` 或 `heights`
|
|
189
191
|
*/
|
|
190
192
|
#getSize(key) {
|
|
191
|
-
|
|
192
|
-
|
|
193
|
+
LSP: { // eslint-disable-line no-unused-labels
|
|
194
|
+
const widths = this.parentNode?.getAttr(key), mt = typeof widths === 'string' && /^(\d+)\s*(?:px)?$/u.exec(widths)?.[1];
|
|
195
|
+
return mt && Number(mt) || 120;
|
|
196
|
+
}
|
|
193
197
|
}
|
|
194
198
|
/** @private */
|
|
195
199
|
json(_, start = this.getAbsoluteIndex()) {
|
|
196
200
|
const json = super.json(undefined, start);
|
|
197
|
-
|
|
198
|
-
|
|
201
|
+
LSP: { // eslint-disable-line no-unused-labels
|
|
202
|
+
Object.assign(json, { widths: this.widths, heights: this.heights });
|
|
203
|
+
return json;
|
|
204
|
+
}
|
|
199
205
|
}
|
|
200
206
|
/* PRINT ONLY END */
|
|
201
207
|
/* NOT FOR BROWSER */
|