wikiparser-node 1.24.1 → 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 +9 -4
- package/bundle/bundle-es8.min.js +24 -23
- package/bundle/bundle-lsp.min.js +28 -27
- 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 +85 -55
- 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 -76
- 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 +3 -1
- package/dist/util/lint.js +12 -9
- package/extensions/dist/base.js +4 -1
- package/i18n/en.json +77 -0
- package/i18n/zh-hans.json +71 -56
- package/i18n/zh-hant.json +71 -56
- package/package.json +2 -2
package/dist/src/heading.js
CHANGED
|
@@ -156,78 +156,80 @@ let HeadingToken = (() => {
|
|
|
156
156
|
}
|
|
157
157
|
/** @private */
|
|
158
158
|
lint(start = this.getAbsoluteIndex(), re) {
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
errors.push(e);
|
|
166
|
-
}
|
|
167
|
-
if (severities[1] && unbalanced) {
|
|
168
|
-
const msg = index_1.default.msg('unbalanced $1 in a section header', '"="'), e = (0, lint_1.generateForChild)(firstChild, rect, rules[1], msg, severities[1]);
|
|
169
|
-
if (innerStr === '=') {
|
|
170
|
-
//
|
|
171
|
-
}
|
|
172
|
-
else if (unbalancedStart) {
|
|
173
|
-
const [extra] = /^=+/u.exec(innerStr), newLevel = level + extra.length;
|
|
174
|
-
e.suggestions = [{ desc: `h${level}`, range: [e.startIndex, e.startIndex + extra.length], text: '' }];
|
|
175
|
-
if (newLevel < 7) {
|
|
176
|
-
e.suggestions.push({ desc: `h${newLevel}`, range: [e.endIndex, e.endIndex], text: extra });
|
|
159
|
+
LINT: { // eslint-disable-line no-unused-labels
|
|
160
|
+
const errors = super.lint(start, re), { firstChild, level } = this, innerStr = firstChild.toString(), unbalancedStart = innerStr.startsWith('='), unbalanced = unbalancedStart || innerStr.endsWith('='), rect = new rect_1.BoundingRect(this, start), s = this.inHtmlAttrs(), rules = ['h1', 'unbalanced-header', 'format-leakage'], severities = rules.map(rule => index_1.default.lintConfig.getSeverity(rule, 'apostrophe'));
|
|
161
|
+
if (severities[0] && this.level === 1) {
|
|
162
|
+
const e = (0, lint_1.generateForChild)(firstChild, rect, rules[0], '<h1>', severities[0]);
|
|
163
|
+
if (!unbalanced) {
|
|
164
|
+
e.suggestions = [(0, lint_1.fixBy)(e, 'h2', `=${innerStr}=`)];
|
|
177
165
|
}
|
|
166
|
+
errors.push(e);
|
|
178
167
|
}
|
|
179
|
-
|
|
180
|
-
const
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
e.suggestions.push({ desc: `h${newLevel}`, range: [e.startIndex, e.startIndex], text: extra });
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
errors.push(e);
|
|
187
|
-
}
|
|
188
|
-
if (s) {
|
|
189
|
-
const rule = 'parsing-order', severity = index_1.default.lintConfig.getSeverity(rule, s === 2 ? 'heading' : 'templateInTable');
|
|
190
|
-
if (severity) {
|
|
191
|
-
errors.push((0, lint_1.generateForSelf)(this, rect, rule, 'section header in HTML tag attributes', severity));
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
if (severities[2]) {
|
|
195
|
-
const rootStr = this.getRootNode().toString(), quotes = firstChild.childNodes.filter((0, debug_1.isToken)('quote')), boldQuotes = quotes.filter(({ bold }) => bold), italicQuotes = quotes.filter(({ italic }) => italic);
|
|
196
|
-
if (boldQuotes.length % 2) {
|
|
197
|
-
const e = (0, lint_1.generateForChild)(boldQuotes[boldQuotes.length - 1], {
|
|
198
|
-
...rect, // eslint-disable-line @typescript-eslint/no-misused-spread
|
|
199
|
-
start: start + level,
|
|
200
|
-
left: rect.left + level,
|
|
201
|
-
}, rules[2], index_1.default.msg('unbalanced $1 in a section header', 'bold apostrophes'), severities[2]), end = start + level + innerStr.length, remove = (0, lint_1.fixByRemove)(e);
|
|
202
|
-
if (rootStr.slice(e.endIndex, end).trim()) {
|
|
203
|
-
e.suggestions = [
|
|
204
|
-
remove,
|
|
205
|
-
(0, lint_1.fixByClose)(end, `'''`),
|
|
206
|
-
];
|
|
168
|
+
if (severities[1] && unbalanced) {
|
|
169
|
+
const msg = index_1.default.msg('unbalanced-in-section-header', '"="'), e = (0, lint_1.generateForChild)(firstChild, rect, rules[1], msg, severities[1]);
|
|
170
|
+
if (innerStr === '=') {
|
|
171
|
+
//
|
|
207
172
|
}
|
|
208
|
-
else if (
|
|
209
|
-
|
|
173
|
+
else if (unbalancedStart) {
|
|
174
|
+
const [extra] = /^=+/u.exec(innerStr), newLevel = level + extra.length;
|
|
175
|
+
e.suggestions = [{ desc: `h${level}`, range: [e.startIndex, e.startIndex + extra.length], text: '' }];
|
|
176
|
+
if (newLevel < 7) {
|
|
177
|
+
e.suggestions.push({ desc: `h${newLevel}`, range: [e.endIndex, e.endIndex], text: extra });
|
|
178
|
+
}
|
|
210
179
|
}
|
|
211
180
|
else {
|
|
212
|
-
|
|
181
|
+
const extra = /[^=](=+)$/u.exec(innerStr)[1], newLevel = level + extra.length;
|
|
182
|
+
e.suggestions = [{ desc: `h${level}`, range: [e.endIndex - extra.length, e.endIndex], text: '' }];
|
|
183
|
+
if (newLevel < 7) {
|
|
184
|
+
e.suggestions.push({ desc: `h${newLevel}`, range: [e.startIndex, e.startIndex], text: extra });
|
|
185
|
+
}
|
|
213
186
|
}
|
|
214
187
|
errors.push(e);
|
|
215
188
|
}
|
|
216
|
-
if (
|
|
217
|
-
const
|
|
218
|
-
if (
|
|
219
|
-
|
|
189
|
+
if (s) {
|
|
190
|
+
const rule = 'parsing-order', severity = index_1.default.lintConfig.getSeverity(rule, s === 2 ? 'heading' : 'templateInTable');
|
|
191
|
+
if (severity) {
|
|
192
|
+
errors.push((0, lint_1.generateForSelf)(this, rect, rule, 'header-in-html', severity));
|
|
220
193
|
}
|
|
221
|
-
|
|
222
|
-
|
|
194
|
+
}
|
|
195
|
+
if (severities[2]) {
|
|
196
|
+
const rootStr = this.getRootNode().toString(), quotes = firstChild.childNodes.filter((0, debug_1.isToken)('quote')), boldQuotes = quotes.filter(({ bold }) => bold), italicQuotes = quotes.filter(({ italic }) => italic);
|
|
197
|
+
if (boldQuotes.length % 2) {
|
|
198
|
+
const e = (0, lint_1.generateForChild)(boldQuotes[boldQuotes.length - 1], {
|
|
199
|
+
...rect, // eslint-disable-line @typescript-eslint/no-misused-spread
|
|
200
|
+
start: start + level,
|
|
201
|
+
left: rect.left + level,
|
|
202
|
+
}, rules[2], index_1.default.msg('unbalanced-in-section-header', 'bold-apostrophes'), severities[2]), end = start + level + innerStr.length, remove = (0, lint_1.fixByRemove)(e);
|
|
203
|
+
if (rootStr.slice(e.endIndex, end).trim()) {
|
|
204
|
+
e.suggestions = [
|
|
205
|
+
remove,
|
|
206
|
+
(0, lint_1.fixByClose)(end, `'''`),
|
|
207
|
+
];
|
|
208
|
+
}
|
|
209
|
+
else if (boldQuotes.length === 1 && italicQuotes.length === 0) {
|
|
210
|
+
e.fix = remove;
|
|
211
|
+
}
|
|
212
|
+
else {
|
|
213
|
+
e.suggestions = [remove];
|
|
214
|
+
}
|
|
215
|
+
errors.push(e);
|
|
223
216
|
}
|
|
224
|
-
|
|
225
|
-
e
|
|
217
|
+
if (italicQuotes.length % 2) {
|
|
218
|
+
const e = (0, lint_1.generateForChild)(italicQuotes[italicQuotes.length - 1], { start: start + level }, rules[2], index_1.default.msg('unbalanced-in-section-header', 'italic-apostrophes'), severities[2]), end = start + level + innerStr.length;
|
|
219
|
+
if (rootStr.slice(e.endIndex, end).trim()) {
|
|
220
|
+
e.suggestions = [(0, lint_1.fixByClose)(end, `''`)];
|
|
221
|
+
}
|
|
222
|
+
else if (italicQuotes.length === 1 && boldQuotes.length === 0) {
|
|
223
|
+
e.fix = (0, lint_1.fixByRemove)(e);
|
|
224
|
+
}
|
|
225
|
+
else {
|
|
226
|
+
e.suggestions = [(0, lint_1.fixByRemove)(e)];
|
|
227
|
+
}
|
|
228
|
+
errors.push(e);
|
|
226
229
|
}
|
|
227
|
-
errors.push(e);
|
|
228
230
|
}
|
|
231
|
+
return errors;
|
|
229
232
|
}
|
|
230
|
-
return errors;
|
|
231
233
|
}
|
|
232
234
|
/** @private */
|
|
233
235
|
print() {
|
|
@@ -237,8 +239,10 @@ let HeadingToken = (() => {
|
|
|
237
239
|
/** @private */
|
|
238
240
|
json(_, start = this.getAbsoluteIndex()) {
|
|
239
241
|
const json = super.json(undefined, start);
|
|
240
|
-
|
|
241
|
-
|
|
242
|
+
LSP: { // eslint-disable-line no-unused-labels
|
|
243
|
+
json['level'] = this.level;
|
|
244
|
+
return json;
|
|
245
|
+
}
|
|
242
246
|
}
|
|
243
247
|
/* NOT FOR BROWSER */
|
|
244
248
|
cloneNode() {
|
package/dist/src/html.js
CHANGED
|
@@ -192,88 +192,90 @@ let HtmlToken = (() => {
|
|
|
192
192
|
}
|
|
193
193
|
/** @private */
|
|
194
194
|
lint(start = this.getAbsoluteIndex(), re) {
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
rule = 'parsing-order';
|
|
203
|
-
s = severity && index_1.default.lintConfig.getSeverity(rule, severity === 2 ? 'html' : 'templateInTable');
|
|
204
|
-
if (s) {
|
|
205
|
-
const e = (0, lint_1.generateForSelf)(this, rect, rule, 'HTML tag in table attributes', s);
|
|
206
|
-
if (severity === 2) {
|
|
207
|
-
e.suggestions = [(0, lint_1.fixByRemove)(e)];
|
|
195
|
+
LINT: { // eslint-disable-line no-unused-labels
|
|
196
|
+
const errors = super.lint(start, re), { name, parentNode, closing, selfClosing } = this, rect = new rect_1.BoundingRect(this, start), severity = this.inTableAttrs();
|
|
197
|
+
let rule = 'h1', s = index_1.default.lintConfig.getSeverity(rule, 'html');
|
|
198
|
+
if (s && name === 'h1' && !closing) {
|
|
199
|
+
const e = (0, lint_1.generateForSelf)(this, rect, rule, '<h1>', s);
|
|
200
|
+
e.suggestions = [{ desc: 'h2', range: [start + 2, start + 3], text: '2' }];
|
|
201
|
+
errors.push(e);
|
|
208
202
|
}
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
rule = 'obsolete-tag';
|
|
212
|
-
s = index_1.default.lintConfig.getSeverity(rule, name);
|
|
213
|
-
if (s && obsoleteTags.has(name)) {
|
|
214
|
-
errors.push((0, lint_1.generateForSelf)(this, rect, rule, 'obsolete HTML tag', s));
|
|
215
|
-
}
|
|
216
|
-
rule = 'bold-header';
|
|
217
|
-
s = index_1.default.lintConfig.getSeverity(rule, name);
|
|
218
|
-
if (s && (name === 'b' || name === 'strong')
|
|
219
|
-
&& this.closest('heading-title,ext')?.type === 'heading-title') {
|
|
220
|
-
const e = (0, lint_1.generateForSelf)(this, rect, rule, 'bold in section header', s);
|
|
221
|
-
e.suggestions = [(0, lint_1.fixByRemove)(e)];
|
|
222
|
-
errors.push(e);
|
|
223
|
-
}
|
|
224
|
-
const { html: [, flexibleTags, voidTags] } = this.getAttribute('config'), isVoid = voidTags.includes(name), isFlexible = flexibleTags.includes(name), isNormal = !isVoid && !isFlexible;
|
|
225
|
-
rule = 'unmatched-tag';
|
|
226
|
-
if (closing && (selfClosing || isVoid) || selfClosing && isNormal) {
|
|
227
|
-
s = index_1.default.lintConfig.getSeverity(rule, closing ? 'both' : 'selfClosing');
|
|
203
|
+
rule = 'parsing-order';
|
|
204
|
+
s = severity && index_1.default.lintConfig.getSeverity(rule, severity === 2 ? 'html' : 'templateInTable');
|
|
228
205
|
if (s) {
|
|
229
|
-
const e = (0, lint_1.generateForSelf)(this, rect, rule,
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
text: '',
|
|
233
|
-
};
|
|
234
|
-
if (isFlexible) {
|
|
235
|
-
e.suggestions = [open, noSelfClosing];
|
|
236
|
-
}
|
|
237
|
-
else if (closing) {
|
|
238
|
-
e.fix = isVoid ? open : noSelfClosing;
|
|
239
|
-
}
|
|
240
|
-
else {
|
|
241
|
-
e.suggestions = [
|
|
242
|
-
noSelfClosing,
|
|
243
|
-
(0, lint_1.fixByClose)(e.endIndex, `></${name}>`, -2),
|
|
244
|
-
];
|
|
206
|
+
const e = (0, lint_1.generateForSelf)(this, rect, rule, 'html-in-table', s);
|
|
207
|
+
if (severity === 2) {
|
|
208
|
+
e.suggestions = [(0, lint_1.fixByRemove)(e)];
|
|
245
209
|
}
|
|
246
210
|
errors.push(e);
|
|
247
211
|
}
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
s = index_1.default.lintConfig.getSeverity(rule, 'conditional');
|
|
212
|
+
rule = 'obsolete-tag';
|
|
213
|
+
s = index_1.default.lintConfig.getSeverity(rule, name);
|
|
214
|
+
if (s && obsoleteTags.has(name)) {
|
|
215
|
+
errors.push((0, lint_1.generateForSelf)(this, rect, rule, 'obsolete-tag', s));
|
|
253
216
|
}
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
217
|
+
rule = 'bold-header';
|
|
218
|
+
s = index_1.default.lintConfig.getSeverity(rule, name);
|
|
219
|
+
if (s && (name === 'b' || name === 'strong')
|
|
220
|
+
&& this.closest('heading-title,ext')?.type === 'heading-title') {
|
|
221
|
+
const e = (0, lint_1.generateForSelf)(this, rect, rule, 'bold-in-header', s);
|
|
222
|
+
e.suggestions = [(0, lint_1.fixByRemove)(e)];
|
|
223
|
+
errors.push(e);
|
|
257
224
|
}
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
225
|
+
const { html: [, flexibleTags, voidTags] } = this.getAttribute('config'), isVoid = voidTags.includes(name), isFlexible = flexibleTags.includes(name), isNormal = !isVoid && !isFlexible;
|
|
226
|
+
rule = 'unmatched-tag';
|
|
227
|
+
if (closing && (selfClosing || isVoid) || selfClosing && isNormal) {
|
|
228
|
+
s = index_1.default.lintConfig.getSeverity(rule, closing ? 'both' : 'selfClosing');
|
|
229
|
+
if (s) {
|
|
230
|
+
const e = (0, lint_1.generateForSelf)(this, rect, rule, closing ? 'closing-and-self-closing' : 'invalid-self-closing', s), open = (0, lint_1.fixByOpen)(start), noSelfClosing = {
|
|
231
|
+
desc: index_1.default.msg('no-self-closing'),
|
|
232
|
+
range: [e.endIndex - 2, e.endIndex - 1],
|
|
233
|
+
text: '',
|
|
234
|
+
};
|
|
235
|
+
if (isFlexible) {
|
|
236
|
+
e.suggestions = [open, noSelfClosing];
|
|
237
|
+
}
|
|
238
|
+
else if (closing) {
|
|
239
|
+
e.fix = isVoid ? open : noSelfClosing;
|
|
264
240
|
}
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
241
|
+
else {
|
|
242
|
+
e.suggestions = [
|
|
243
|
+
noSelfClosing,
|
|
244
|
+
(0, lint_1.fixByClose)(e.endIndex, `></${name}>`, -2),
|
|
245
|
+
];
|
|
268
246
|
}
|
|
247
|
+
errors.push(e);
|
|
269
248
|
}
|
|
270
249
|
}
|
|
271
|
-
if (
|
|
272
|
-
error.
|
|
273
|
-
|
|
250
|
+
else if (!this.findMatchingTag()) {
|
|
251
|
+
const error = (0, lint_1.generateForSelf)(this, rect, rule, closing ? 'unmatched-closing' : 'unclosed-tag'), ancestor = this.closest('magic-word');
|
|
252
|
+
if (ancestor && magicWords.has(ancestor.name)) {
|
|
253
|
+
s = index_1.default.lintConfig.getSeverity(rule, 'conditional');
|
|
254
|
+
}
|
|
255
|
+
else if (closing) {
|
|
256
|
+
s = index_1.default.lintConfig.getSeverity(rule, 'closing');
|
|
257
|
+
error.suggestions = [(0, lint_1.fixByRemove)(error)];
|
|
258
|
+
}
|
|
259
|
+
else {
|
|
260
|
+
s = index_1.default.lintConfig.getSeverity(rule, 'opening');
|
|
261
|
+
const childNodes = parentNode?.childNodes;
|
|
262
|
+
if (formattingTags.has(name)) {
|
|
263
|
+
if (childNodes?.slice(0, childNodes.indexOf(this)).some(tag => tag.type === 'html' && tag.name === name && !tag.findMatchingTag())) {
|
|
264
|
+
error.suggestions = [(0, lint_1.fixByClose)(start + 1, '/')];
|
|
265
|
+
}
|
|
266
|
+
if (this.closest('heading-title')) {
|
|
267
|
+
error.rule = 'format-leakage';
|
|
268
|
+
s = index_1.default.lintConfig.getSeverity('format-leakage', name);
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
if (s) {
|
|
273
|
+
error.severity = s;
|
|
274
|
+
errors.push(error);
|
|
275
|
+
}
|
|
274
276
|
}
|
|
277
|
+
return errors;
|
|
275
278
|
}
|
|
276
|
-
return errors;
|
|
277
279
|
}
|
|
278
280
|
/**
|
|
279
281
|
* Find the matching tag
|
|
@@ -331,8 +333,10 @@ let HtmlToken = (() => {
|
|
|
331
333
|
/** @private */
|
|
332
334
|
json(_, start = this.getAbsoluteIndex()) {
|
|
333
335
|
const json = super.json(undefined, start);
|
|
334
|
-
|
|
335
|
-
|
|
336
|
+
LSP: { // eslint-disable-line no-unused-labels
|
|
337
|
+
Object.assign(json, { closing: this.closing, selfClosing: this.#selfClosing });
|
|
338
|
+
return json;
|
|
339
|
+
}
|
|
336
340
|
}
|
|
337
341
|
/* NOT FOR BROWSER */
|
|
338
342
|
cloneNode() {
|
|
@@ -196,24 +196,26 @@ class ImageParameterToken extends index_2.Token {
|
|
|
196
196
|
}
|
|
197
197
|
/** @private */
|
|
198
198
|
lint(start = this.getAbsoluteIndex(), re) {
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
199
|
+
LINT: { // eslint-disable-line no-unused-labels
|
|
200
|
+
const errors = super.lint(start, re), { link, name } = this;
|
|
201
|
+
if (name === 'invalid') {
|
|
202
|
+
const rule = 'invalid-gallery', s = index_1.default.lintConfig.getSeverity(rule, 'parameter');
|
|
203
|
+
if (s) {
|
|
204
|
+
const e = (0, lint_1.generateForSelf)(this, { start }, rule, 'invalid-image-parameter', s);
|
|
205
|
+
e.fix = (0, lint_1.fixByRemove)(e, -1);
|
|
206
|
+
errors.push(e);
|
|
207
|
+
}
|
|
206
208
|
}
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
209
|
+
else if (typeof link === 'object' && link.encoded) {
|
|
210
|
+
const rule = 'url-encoding', s = index_1.default.lintConfig.getSeverity(rule, 'file');
|
|
211
|
+
if (s) {
|
|
212
|
+
const e = (0, lint_1.generateForSelf)(this, { start }, rule, 'unnecessary-encoding', s);
|
|
213
|
+
e.fix = (0, lint_1.fixByDecode)(e, this);
|
|
214
|
+
errors.push(e);
|
|
215
|
+
}
|
|
214
216
|
}
|
|
217
|
+
return errors;
|
|
215
218
|
}
|
|
216
|
-
return errors;
|
|
217
219
|
}
|
|
218
220
|
/** 是否是不可变参数 */
|
|
219
221
|
#isVoid() {
|
package/dist/src/imagemap.js
CHANGED
|
@@ -148,26 +148,28 @@ let ImagemapToken = (() => {
|
|
|
148
148
|
}
|
|
149
149
|
/** @private */
|
|
150
150
|
lint(start = this.getAbsoluteIndex(), re) {
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
if (
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
151
|
+
LINT: { // eslint-disable-line no-unused-labels
|
|
152
|
+
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');
|
|
153
|
+
if (s) {
|
|
154
|
+
if (image) {
|
|
155
|
+
errors.push(...childNodes.filter(child => {
|
|
156
|
+
const str = child.toString().trim();
|
|
157
|
+
return child.is('noinclude') && str && !str.startsWith('#');
|
|
158
|
+
}).map(child => {
|
|
159
|
+
const e = (0, lint_1.generateForChild)(child, rect, rule, 'invalid-imagemap-link', s);
|
|
160
|
+
e.suggestions = [
|
|
161
|
+
(0, lint_1.fixByRemove)(e, -1),
|
|
162
|
+
(0, lint_1.fixBy)(e, 'comment', '# '),
|
|
163
|
+
];
|
|
164
|
+
return e;
|
|
165
|
+
}));
|
|
166
|
+
}
|
|
167
|
+
else {
|
|
168
|
+
errors.push((0, lint_1.generateForSelf)(this, rect, rule, 'imagemap-without-image', s));
|
|
169
|
+
}
|
|
168
170
|
}
|
|
171
|
+
return errors;
|
|
169
172
|
}
|
|
170
|
-
return errors;
|
|
171
173
|
}
|
|
172
174
|
/* PRINT ONLY */
|
|
173
175
|
/** @private */
|