wikiparser-node 1.25.0 → 1.26.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 +2 -2
- package/bundle/bundle-es8.min.js +25 -24
- package/bundle/bundle-lsp.min.js +31 -30
- package/bundle/bundle.min.js +25 -25
- package/config/default.json +3 -0
- package/config/enwiki.json +3 -0
- package/config/jawiki.json +3 -0
- package/config/minimum.json +1 -0
- package/config/moegirl.json +0 -20
- package/config/zhwiki.json +3 -0
- package/data/ext/math.json +41 -0
- package/dist/addon/token.js +1 -1
- package/dist/base.d.mts +17 -4
- package/dist/base.d.ts +17 -4
- package/dist/bin/config.js +8 -2
- package/dist/index.d.ts +5 -3
- package/dist/index.js +74 -53
- package/dist/lib/element.js +34 -30
- package/dist/lib/lintConfig.d.ts +18 -7
- package/dist/lib/lintConfig.js +55 -15
- package/dist/lib/lsp.js +16 -8
- package/dist/lib/text.js +176 -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 +41 -33
- package/dist/src/attribute.js +63 -39
- package/dist/src/attributes.js +62 -51
- package/dist/src/commented.js +2 -1
- package/dist/src/converterFlags.js +22 -18
- package/dist/src/converterRule.js +6 -3
- package/dist/src/extLink.js +6 -4
- package/dist/src/gallery.js +50 -42
- package/dist/src/heading.js +75 -61
- package/dist/src/html.js +85 -72
- package/dist/src/imageParameter.js +21 -15
- package/dist/src/imagemap.js +22 -18
- package/dist/src/index.js +107 -97
- package/dist/src/link/base.js +46 -33
- package/dist/src/link/category.js +11 -6
- package/dist/src/link/file.js +93 -77
- package/dist/src/link/galleryImage.js +10 -6
- package/dist/src/link/index.js +10 -6
- package/dist/src/link/redirectTarget.js +12 -8
- package/dist/src/magicLink.js +25 -20
- package/dist/src/nested.js +31 -27
- package/dist/src/nowiki/comment.js +13 -9
- package/dist/src/nowiki/index.js +11 -7
- package/dist/src/nowiki/listBase.js +8 -5
- package/dist/src/nowiki/quote.js +33 -25
- package/dist/src/paramTag/index.js +26 -22
- package/dist/src/parameter.js +31 -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 +26 -19
- package/dist/src/table/trBase.js +13 -11
- package/dist/src/tagPair/ext.js +13 -10
- package/dist/src/tagPair/include.js +17 -11
- package/dist/src/transclude.js +45 -37
- package/dist/util/constants.js +2 -1
- package/dist/util/lint.js +2 -1
- package/extensions/dist/base.js +1 -1
- package/extensions/editor.css +2 -2
- package/package.json +6 -6
|
@@ -54,15 +54,19 @@ class RedirectTargetToken extends base_1.LinkBaseToken {
|
|
|
54
54
|
}
|
|
55
55
|
/** @private */
|
|
56
56
|
lint(start = this.getAbsoluteIndex()) {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
57
|
+
LINT: { // eslint-disable-line no-unused-labels
|
|
58
|
+
const errors = super.lint(start, false), rule = 'no-ignored', { lintConfig } = index_1.default, s = lintConfig.getSeverity(rule, 'redirect');
|
|
59
|
+
if (s && this.length === 2) {
|
|
60
|
+
const e = (0, lint_1.generateForChild)(this.lastChild, { start }, rule, 'useless-link-text', s);
|
|
61
|
+
e.startIndex--;
|
|
62
|
+
e.startCol--;
|
|
63
|
+
if (lintConfig.computeEditInfo || lintConfig.fix) {
|
|
64
|
+
e.fix = (0, lint_1.fixByRemove)(e);
|
|
65
|
+
}
|
|
66
|
+
errors.push(e);
|
|
67
|
+
}
|
|
68
|
+
return errors;
|
|
64
69
|
}
|
|
65
|
-
return errors;
|
|
66
70
|
}
|
|
67
71
|
/* NOT FOR BROWSER */
|
|
68
72
|
/** @private */
|
package/dist/src/magicLink.js
CHANGED
|
@@ -179,29 +179,34 @@ let MagicLinkToken = (() => {
|
|
|
179
179
|
}
|
|
180
180
|
/** @private */
|
|
181
181
|
lint(start = this.getAbsoluteIndex(), re) {
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
182
|
+
LINT: { // eslint-disable-line no-unused-labels
|
|
183
|
+
const errors = super.lint(start, re), rect = new rect_1.BoundingRect(this, start), { lintConfig } = index_1.default, { type, childNodes } = this;
|
|
184
|
+
if (type === 'magic-link') {
|
|
185
|
+
const rule = 'invalid-isbn', s = lintConfig.getSeverity(rule);
|
|
186
|
+
if (s && this.#lint()) {
|
|
187
|
+
errors.push((0, lint_1.generateForSelf)(this, rect, rule, 'invalid-isbn', s));
|
|
188
|
+
}
|
|
189
|
+
return errors;
|
|
187
190
|
}
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
191
|
+
const pipe = type === 'ext-link-url', rule = 'unterminated-url', severity = lintConfig.getSeverity(rule, pipe ? 'pipe' : 'punctuation');
|
|
192
|
+
if (severity) {
|
|
193
|
+
const regex = pipe ? /\|/u : /[,;。:!?()]+/u, child = childNodes.find((c) => c.type === 'text' && regex.test(c.data));
|
|
194
|
+
if (child) {
|
|
195
|
+
const { data } = child, e = (0, lint_1.generateForChild)(child, rect, rule, index_1.default.msg('in-url', pipe ? '"|"' : 'full-width-punctuation'), severity);
|
|
196
|
+
if (lintConfig.computeEditInfo) {
|
|
197
|
+
const { index, 0: s } = regex.exec(data), i = e.startIndex + index;
|
|
198
|
+
e.suggestions = pipe
|
|
199
|
+
? [(0, lint_1.fixBySpace)(i, 1)]
|
|
200
|
+
: [
|
|
201
|
+
(0, lint_1.fixBySpace)(i),
|
|
202
|
+
{ desc: index_1.default.msg('encode'), range: [i, i + s.length], text: encodeURI(s) },
|
|
203
|
+
];
|
|
204
|
+
}
|
|
205
|
+
errors.push(e);
|
|
206
|
+
}
|
|
202
207
|
}
|
|
208
|
+
return errors;
|
|
203
209
|
}
|
|
204
|
-
return errors;
|
|
205
210
|
}
|
|
206
211
|
/**
|
|
207
212
|
* Get the URL
|
package/dist/src/nested.js
CHANGED
|
@@ -50,12 +50,12 @@ const noinclude_1 = require("./nowiki/noinclude");
|
|
|
50
50
|
const debug_1 = require("../util/debug");
|
|
51
51
|
const constants_1 = require("../util/constants");
|
|
52
52
|
const clone_1 = require("../mixin/clone");
|
|
53
|
-
const childTypes = new Set(['comment', 'include', 'arg', 'template', 'magic-word']), lintRegex = [false, true].map(article => {
|
|
53
|
+
const childTypes = new Set(['comment', 'include', 'arg', 'template', 'magic-word']), lintRegex = /* #__PURE__ */ (() => [false, true].map(article => {
|
|
54
54
|
const noinclude = article ? 'includeonly' : 'noinclude';
|
|
55
55
|
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
|
|
56
56
|
/^(?:<noinclude(?:\s[^>]*)?\/?>|<\/noinclude\s*>)$/iu;
|
|
57
57
|
return new RegExp(String.raw `^(?:<${noinclude}(?:\s[^>]*)?/?>|</${noinclude}\s*>)$`, 'iu');
|
|
58
|
-
});
|
|
58
|
+
}))();
|
|
59
59
|
/**
|
|
60
60
|
* extension tag that has a nested structure
|
|
61
61
|
*
|
|
@@ -110,32 +110,36 @@ let NestedToken = (() => {
|
|
|
110
110
|
}
|
|
111
111
|
/** @private */
|
|
112
112
|
lint(start = this.getAbsoluteIndex(), re) {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
113
|
+
LINT: { // eslint-disable-line no-unused-labels
|
|
114
|
+
const errors = super.lint(start, re), rule = 'no-ignored', { lintConfig } = index_1.default, s = lintConfig.getSeverity(rule, this.name);
|
|
115
|
+
if (!s) {
|
|
116
|
+
return errors;
|
|
117
|
+
}
|
|
118
|
+
const rect = new rect_1.BoundingRect(this, start), regex = typeof this.#regex === 'boolean' ? lintRegex[this.#regex ? 1 : 0] : /^<!--[\s\S]*-->$/u;
|
|
119
|
+
return [
|
|
120
|
+
...errors,
|
|
121
|
+
...this.childNodes.filter(child => {
|
|
122
|
+
const { type, name } = child;
|
|
123
|
+
if (type === 'ext') {
|
|
124
|
+
return !this.#tags.includes(name);
|
|
125
|
+
}
|
|
126
|
+
else if (childTypes.has(type)) {
|
|
127
|
+
return false;
|
|
128
|
+
}
|
|
129
|
+
const str = child.toString().trim();
|
|
130
|
+
return str && !regex.test(str);
|
|
131
|
+
}).map(child => {
|
|
132
|
+
const e = (0, lint_1.generateForChild)(child, rect, rule, index_1.default.msg('invalid-content', this.name), s);
|
|
133
|
+
if (lintConfig.computeEditInfo) {
|
|
134
|
+
e.suggestions = [
|
|
135
|
+
(0, lint_1.fixByRemove)(e),
|
|
136
|
+
(0, lint_1.fixByComment)(e, child.toString()),
|
|
137
|
+
];
|
|
138
|
+
}
|
|
139
|
+
return e;
|
|
140
|
+
}),
|
|
141
|
+
];
|
|
116
142
|
}
|
|
117
|
-
const rect = new rect_1.BoundingRect(this, start), regex = typeof this.#regex === 'boolean' ? lintRegex[this.#regex ? 1 : 0] : /^<!--[\s\S]*-->$/u;
|
|
118
|
-
return [
|
|
119
|
-
...errors,
|
|
120
|
-
...this.childNodes.filter(child => {
|
|
121
|
-
const { type, name } = child;
|
|
122
|
-
if (type === 'ext') {
|
|
123
|
-
return !this.#tags.includes(name);
|
|
124
|
-
}
|
|
125
|
-
else if (childTypes.has(type)) {
|
|
126
|
-
return false;
|
|
127
|
-
}
|
|
128
|
-
const str = child.toString().trim();
|
|
129
|
-
return str && !regex.test(str);
|
|
130
|
-
}).map(child => {
|
|
131
|
-
const e = (0, lint_1.generateForChild)(child, rect, rule, index_1.default.msg('invalid-content', this.name), s);
|
|
132
|
-
e.suggestions = [
|
|
133
|
-
(0, lint_1.fixByRemove)(e),
|
|
134
|
-
(0, lint_1.fixByComment)(e, child.toString()),
|
|
135
|
-
];
|
|
136
|
-
return e;
|
|
137
|
-
}),
|
|
138
|
-
];
|
|
139
143
|
}
|
|
140
144
|
/* NOT FOR BROWSER */
|
|
141
145
|
/**
|
|
@@ -87,16 +87,20 @@ let CommentToken = (() => {
|
|
|
87
87
|
}
|
|
88
88
|
/** @private */
|
|
89
89
|
lint(start = this.getAbsoluteIndex()) {
|
|
90
|
-
|
|
91
|
-
|
|
90
|
+
LINT: { // eslint-disable-line no-unused-labels
|
|
91
|
+
if (this.closed) {
|
|
92
|
+
return [];
|
|
93
|
+
}
|
|
94
|
+
const rule = 'unclosed-comment', { lintConfig } = index_1.default, s = lintConfig.getSeverity(rule);
|
|
95
|
+
if (!s) {
|
|
96
|
+
return [];
|
|
97
|
+
}
|
|
98
|
+
const e = (0, lint_1.generateForSelf)(this, { start }, rule, index_1.default.msg('unclosed', 'html-comment'), s);
|
|
99
|
+
if (lintConfig.computeEditInfo) {
|
|
100
|
+
e.suggestions = [(0, lint_1.fixByClose)(e.endIndex, '-->')];
|
|
101
|
+
}
|
|
102
|
+
return [e];
|
|
92
103
|
}
|
|
93
|
-
const rule = 'unclosed-comment', s = index_1.default.lintConfig.getSeverity(rule);
|
|
94
|
-
if (!s) {
|
|
95
|
-
return [];
|
|
96
|
-
}
|
|
97
|
-
const e = (0, lint_1.generateForSelf)(this, { start }, rule, index_1.default.msg('unclosed', 'html-comment'), s);
|
|
98
|
-
e.suggestions = [(0, lint_1.fixByClose)(e.endIndex, '-->')];
|
|
99
|
-
return [e];
|
|
100
104
|
}
|
|
101
105
|
/** @private */
|
|
102
106
|
toString(skip) {
|
package/dist/src/nowiki/index.js
CHANGED
|
@@ -12,7 +12,7 @@ const base_1 = require("./base");
|
|
|
12
12
|
const constants_1 = require("../../util/constants");
|
|
13
13
|
/* NOT FOR BROWSER END */
|
|
14
14
|
/<\s*(?:\/\s*)?(nowiki)\b/giu; // eslint-disable-line @typescript-eslint/no-unused-expressions
|
|
15
|
-
const getLintRegex = (0, common_1.getRegex)(name => new RegExp(String.raw `<\s*(?:/\s*)${name === 'nowiki' ? '' : '?'}(${name})\b`, 'giu'));
|
|
15
|
+
const getLintRegex = /* #__PURE__ */ (0, common_1.getRegex)(name => new RegExp(String.raw `<\s*(?:/\s*)${name === 'nowiki' ? '' : '?'}(${name})\b`, 'giu'));
|
|
16
16
|
const voidExt = new Set(['languages', 'section', 'templatestyles']);
|
|
17
17
|
/**
|
|
18
18
|
* text-only token inside an extension tag
|
|
@@ -31,13 +31,17 @@ class NowikiToken extends base_1.NowikiBaseToken {
|
|
|
31
31
|
}
|
|
32
32
|
/** @private */
|
|
33
33
|
lint(start = this.getAbsoluteIndex()) {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
34
|
+
LINT: { // eslint-disable-line no-unused-labels
|
|
35
|
+
const { name } = this, rule = 'void-ext', { lintConfig } = index_1.default, s = lintConfig.getSeverity(rule, name);
|
|
36
|
+
if (s && this.#lint()) {
|
|
37
|
+
const e = (0, lint_1.generateForSelf)(this, { start }, rule, index_1.default.msg('nothing-in', name), s);
|
|
38
|
+
if (lintConfig.computeEditInfo) {
|
|
39
|
+
e.suggestions = [(0, lint_1.fixByRemove)(e)];
|
|
40
|
+
}
|
|
41
|
+
return [e];
|
|
42
|
+
}
|
|
43
|
+
return super.lint(start, getLintRegex(name));
|
|
39
44
|
}
|
|
40
|
-
return super.lint(start, getLintRegex(name));
|
|
41
45
|
}
|
|
42
46
|
/* PRINT ONLY */
|
|
43
47
|
/** @private */
|
|
@@ -17,7 +17,7 @@ class ListBaseToken extends base_1.NowikiBaseToken {
|
|
|
17
17
|
* @since v1.16.5
|
|
18
18
|
*/
|
|
19
19
|
get indent() {
|
|
20
|
-
return this.innerText.split(':').length - 1;
|
|
20
|
+
LSP: return this.innerText.split(':').length - 1; // eslint-disable-line no-unused-labels
|
|
21
21
|
}
|
|
22
22
|
/* PRINT ONLY END */
|
|
23
23
|
/* NOT FOR BROWSER */
|
|
@@ -47,11 +47,14 @@ class ListBaseToken extends base_1.NowikiBaseToken {
|
|
|
47
47
|
/* NOT FOR BROWSER END */
|
|
48
48
|
/** @private */
|
|
49
49
|
json(_, start = this.getAbsoluteIndex()) {
|
|
50
|
-
const json = super.json(undefined, start)
|
|
51
|
-
|
|
52
|
-
|
|
50
|
+
const json = super.json(undefined, start);
|
|
51
|
+
LSP: { // eslint-disable-line no-unused-labels
|
|
52
|
+
const { indent } = this;
|
|
53
|
+
if (indent) {
|
|
54
|
+
json['indent'] = indent;
|
|
55
|
+
}
|
|
56
|
+
return json;
|
|
53
57
|
}
|
|
54
|
-
return json;
|
|
55
58
|
}
|
|
56
59
|
/* NOT FOR BROWSER */
|
|
57
60
|
/**
|
package/dist/src/nowiki/quote.js
CHANGED
|
@@ -113,37 +113,45 @@ let QuoteToken = (() => {
|
|
|
113
113
|
}
|
|
114
114
|
/** @private */
|
|
115
115
|
lint(start = this.getAbsoluteIndex()) {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
(
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
116
|
+
LINT: { // eslint-disable-line no-unused-labels
|
|
117
|
+
const { previousSibling, bold, closing } = this, previousData = previousSibling?.type === 'text' ? previousSibling.data : undefined, errors = [], rect = new rect_1.BoundingRect(this, start), rules = ['lonely-apos', 'bold-header'], { lintConfig } = index_1.default, { computeEditInfo } = lintConfig, severities = [undefined, 'word'].map(key => lintConfig.getSeverity(rules[0], key)), s = lintConfig.getSeverity(rules[1]);
|
|
118
|
+
if (previousData?.endsWith(`'`)) {
|
|
119
|
+
const severity = severities[(closing.bold || closing.italic) && /[a-z\d]'$/iu.test(previousData) ? 1 : 0];
|
|
120
|
+
if (severity) {
|
|
121
|
+
const e = (0, lint_1.generateForSelf)(this, rect, rules[0], index_1.default.msg('lonely', `'`), severity), { startLine: endLine, startCol: endCol } = e, [, { length }] = /(?:^|[^'])('+)$/u.exec(previousData), startIndex = start - length, eNew = {
|
|
122
|
+
...e,
|
|
123
|
+
startIndex,
|
|
124
|
+
endIndex: start,
|
|
125
|
+
endLine,
|
|
126
|
+
startCol: endCol - length,
|
|
127
|
+
endCol,
|
|
128
|
+
};
|
|
129
|
+
if (computeEditInfo) {
|
|
130
|
+
eNew.suggestions = [
|
|
131
|
+
(0, lint_1.fixByEscape)(startIndex, ''', length),
|
|
132
|
+
(0, lint_1.fixByRemove)(eNew),
|
|
133
|
+
];
|
|
134
|
+
}
|
|
135
|
+
errors.push(eNew);
|
|
136
|
+
}
|
|
133
137
|
}
|
|
138
|
+
if (s && bold && this.closest('heading-title,ext')?.type === 'heading-title') {
|
|
139
|
+
const e = (0, lint_1.generateForSelf)(this, rect, rules[1], 'bold-in-header', s);
|
|
140
|
+
if (computeEditInfo) {
|
|
141
|
+
e.suggestions = [(0, lint_1.fixByRemove)(e)];
|
|
142
|
+
}
|
|
143
|
+
errors.push(e);
|
|
144
|
+
}
|
|
145
|
+
return errors;
|
|
134
146
|
}
|
|
135
|
-
if (s && bold && this.closest('heading-title,ext')?.type === 'heading-title') {
|
|
136
|
-
const e = (0, lint_1.generateForSelf)(this, rect, rules[1], 'bold-in-header', s);
|
|
137
|
-
e.suggestions = [(0, lint_1.fixByRemove)(e)];
|
|
138
|
-
errors.push(e);
|
|
139
|
-
}
|
|
140
|
-
return errors;
|
|
141
147
|
}
|
|
142
148
|
/** @private */
|
|
143
149
|
json(_, start = this.getAbsoluteIndex()) {
|
|
144
150
|
const json = super.json(undefined, start);
|
|
145
|
-
|
|
146
|
-
|
|
151
|
+
LSP: { // eslint-disable-line no-unused-labels
|
|
152
|
+
Object.assign(json, { bold: this.bold, italic: this.italic });
|
|
153
|
+
return json;
|
|
154
|
+
}
|
|
147
155
|
}
|
|
148
156
|
/* NOT FOR BROWSER */
|
|
149
157
|
cloneNode() {
|
|
@@ -96,35 +96,39 @@ let ParamTagToken = (() => {
|
|
|
96
96
|
}
|
|
97
97
|
/** @private */
|
|
98
98
|
lint(start = this.getAbsoluteIndex()) {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
const rect = new rect_1.BoundingRect(this, start), msg = index_1.default.msg('invalid-parameter', this.name), errors = [];
|
|
104
|
-
for (const child of this.childNodes) {
|
|
105
|
-
child.setAttribute('aIndex', start);
|
|
106
|
-
const grandChildren = child.childNodes
|
|
107
|
-
.filter(({ type }) => type !== 'comment' && type !== 'include' && type !== 'noinclude');
|
|
108
|
-
if (grandChildren.some(({ type }) => type === 'ext')) {
|
|
109
|
-
errors.push((0, lint_1.generateForChild)(child, rect, rule, msg, s));
|
|
99
|
+
LINT: { // eslint-disable-line no-unused-labels
|
|
100
|
+
const rule = 'no-ignored', { lintConfig } = index_1.default, s = lintConfig.getSeverity(rule, this.name);
|
|
101
|
+
if (!s) {
|
|
102
|
+
return [];
|
|
110
103
|
}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
104
|
+
const rect = new rect_1.BoundingRect(this, start), msg = index_1.default.msg('invalid-parameter', this.name), errors = [];
|
|
105
|
+
for (const child of this.childNodes) {
|
|
106
|
+
child.setAttribute('aIndex', start);
|
|
107
|
+
const grandChildren = child.childNodes
|
|
108
|
+
.filter(({ type }) => type !== 'comment' && type !== 'include' && type !== 'noinclude');
|
|
109
|
+
if (grandChildren.some(({ type }) => type === 'ext')) {
|
|
110
|
+
errors.push((0, lint_1.generateForChild)(child, rect, rule, msg, s));
|
|
117
111
|
}
|
|
118
112
|
else {
|
|
119
|
-
const
|
|
120
|
-
if (
|
|
121
|
-
|
|
113
|
+
const i = grandChildren.findIndex(({ type }) => type !== 'text'), str = grandChildren.slice(0, i === -1 ? undefined : i).map(String).join('');
|
|
114
|
+
if (str && !(i === -1 ? /^[a-z]+(?:\[\])?\s*=/iu : /^[a-z]+(?:\[\])?\s*(?:=|$)/iu).test(str)) {
|
|
115
|
+
const e = (0, lint_1.generateForChild)(child, rect, rule, msg, s);
|
|
116
|
+
if (lintConfig.computeEditInfo) {
|
|
117
|
+
e.suggestions = [(0, lint_1.fixByRemove)(e)];
|
|
118
|
+
}
|
|
119
|
+
errors.push(e);
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
const childErrors = child.lint(start, false);
|
|
123
|
+
if (childErrors.length > 0) {
|
|
124
|
+
errors.push(...childErrors);
|
|
125
|
+
}
|
|
122
126
|
}
|
|
123
127
|
}
|
|
128
|
+
start += child.toString().length + 1;
|
|
124
129
|
}
|
|
125
|
-
|
|
130
|
+
return errors;
|
|
126
131
|
}
|
|
127
|
-
return errors;
|
|
128
132
|
}
|
|
129
133
|
/* NOT FOR BROWSER */
|
|
130
134
|
cloneNode() {
|
package/dist/src/parameter.js
CHANGED
|
@@ -49,7 +49,7 @@ const fixed_1 = require("../mixin/fixed");
|
|
|
49
49
|
/* NOT FOR BROWSER END */
|
|
50
50
|
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
|
|
51
51
|
/https?:\/\/(?:\[[\da-f:.]+\]|[^[\]<>"\t\n\p{Zs}])[^[\]<>"\0\t\n\p{Zs}]*$/iu;
|
|
52
|
-
const linkRegex = new RegExp(`https?://${string_1.extUrlCharFirst}${string_1.extUrlChar}$`, 'iu');
|
|
52
|
+
const linkRegex = /* #__PURE__ */ (() => new RegExp(`https?://${string_1.extUrlCharFirst}${string_1.extUrlChar}$`, 'iu'))();
|
|
53
53
|
/**
|
|
54
54
|
* template or magic word parameter
|
|
55
55
|
*
|
|
@@ -82,11 +82,13 @@ let ParameterToken = (() => {
|
|
|
82
82
|
/* PRINT ONLY */
|
|
83
83
|
/** whether to be a duplicated parameter / 是否是重复参数 */
|
|
84
84
|
get duplicated() {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
85
|
+
LSP: { // eslint-disable-line no-unused-labels
|
|
86
|
+
try {
|
|
87
|
+
return Boolean(this.parentNode?.getDuplicatedArgs().some(([key]) => key === this.name));
|
|
88
|
+
}
|
|
89
|
+
catch {
|
|
90
|
+
return false;
|
|
91
|
+
}
|
|
90
92
|
}
|
|
91
93
|
}
|
|
92
94
|
/* PRINT ONLY END */
|
|
@@ -175,24 +177,28 @@ let ParameterToken = (() => {
|
|
|
175
177
|
}
|
|
176
178
|
/** @private */
|
|
177
179
|
lint(start = this.getAbsoluteIndex(), re) {
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
180
|
+
LINT: { // eslint-disable-line no-unused-labels
|
|
181
|
+
const errors = super.lint(start, re), rule = 'unescaped', { lintConfig } = index_1.default, s = lintConfig.getSeverity(rule);
|
|
182
|
+
if (s) {
|
|
183
|
+
const { firstChild } = this, link = linkRegex.exec(firstChild.text())?.[0];
|
|
184
|
+
try {
|
|
185
|
+
if (link && new URL(link).search) {
|
|
186
|
+
const e = (0, lint_1.generateForChild)(firstChild, { start }, rule, 'unescaped-query', s);
|
|
187
|
+
e.startIndex = e.endIndex;
|
|
188
|
+
e.startLine = e.endLine;
|
|
189
|
+
e.startCol = e.endCol;
|
|
190
|
+
e.endIndex++;
|
|
191
|
+
e.endCol++;
|
|
192
|
+
if (lintConfig.computeEditInfo || lintConfig.fix) {
|
|
193
|
+
e.fix = (0, lint_1.fixByEscape)(e.startIndex, '{{=}}');
|
|
194
|
+
}
|
|
195
|
+
errors.push(e);
|
|
196
|
+
}
|
|
191
197
|
}
|
|
198
|
+
catch { }
|
|
192
199
|
}
|
|
193
|
-
|
|
200
|
+
return errors;
|
|
194
201
|
}
|
|
195
|
-
return errors;
|
|
196
202
|
}
|
|
197
203
|
/** @private */
|
|
198
204
|
print() {
|
|
@@ -201,8 +207,10 @@ let ParameterToken = (() => {
|
|
|
201
207
|
/** @private */
|
|
202
208
|
json(_, start = this.getAbsoluteIndex()) {
|
|
203
209
|
const json = super.json(undefined, start);
|
|
204
|
-
|
|
205
|
-
|
|
210
|
+
LSP: { // eslint-disable-line no-unused-labels
|
|
211
|
+
Object.assign(json, { anon: this.anon }, this.duplicated && { duplicated: true });
|
|
212
|
+
return json;
|
|
213
|
+
}
|
|
206
214
|
}
|
|
207
215
|
/* NOT FOR BROWSER */
|
|
208
216
|
cloneNode() {
|
package/dist/src/pre.js
CHANGED
|
@@ -96,7 +96,7 @@ let PreToken = (() => {
|
|
|
96
96
|
}
|
|
97
97
|
/** @private */
|
|
98
98
|
lint(start = this.getAbsoluteIndex()) {
|
|
99
|
-
return super.lint(start, /<\s*\/\s*(pre)\b/giu);
|
|
99
|
+
LINT: return super.lint(start, /<\s*\/\s*(pre)\b/giu); // eslint-disable-line no-unused-labels
|
|
100
100
|
}
|
|
101
101
|
/* NOT FOR BROWSER */
|
|
102
102
|
cloneNode() {
|
package/dist/src/redirect.js
CHANGED
|
@@ -100,9 +100,11 @@ let RedirectToken = (() => {
|
|
|
100
100
|
}
|
|
101
101
|
/** @private */
|
|
102
102
|
lint(start = this.getAbsoluteIndex()) {
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
103
|
+
LINT: { // eslint-disable-line no-unused-labels
|
|
104
|
+
const index = start + this.#pre.length + this.firstChild.toString().length;
|
|
105
|
+
this.lastChild.setAttribute('aIndex', index);
|
|
106
|
+
return this.lastChild.lint(index);
|
|
107
|
+
}
|
|
106
108
|
}
|
|
107
109
|
/** @private */
|
|
108
110
|
print() {
|
package/dist/src/syntax.js
CHANGED
package/dist/src/table/index.js
CHANGED
|
@@ -138,40 +138,42 @@ let TableToken = (() => {
|
|
|
138
138
|
}
|
|
139
139
|
/** @private */
|
|
140
140
|
lint(start = this.getAbsoluteIndex(), re) {
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
141
|
+
LINT: { // eslint-disable-line no-unused-labels
|
|
142
|
+
const errors = super.lint(start, re), rect = new rect_1.BoundingRect(this, start), rules = ['unclosed-table', 'table-layout'], s = rules.map(rule => index_1.default.lintConfig.getSeverity(rule));
|
|
143
|
+
if (s[0] && !this.closed) {
|
|
144
|
+
errors.push((0, lint_1.generateForChild)(this.firstChild, rect, rules[0], index_1.default.msg('unclosed', 'table'), s[0]));
|
|
145
|
+
}
|
|
146
|
+
if (s[1]) {
|
|
147
|
+
const layout = this.getLayout(), { length } = layout;
|
|
148
|
+
if (length > 1) {
|
|
149
|
+
let low = 1, high = Infinity, j = 0;
|
|
150
|
+
for (; j < length; j++) {
|
|
151
|
+
const row = layout[j], max = row.length;
|
|
152
|
+
if (max < low) {
|
|
153
|
+
break;
|
|
154
|
+
}
|
|
155
|
+
else if (max < high) {
|
|
156
|
+
high = max;
|
|
157
|
+
}
|
|
158
|
+
const min = row.indexOf(row[max - 1]) + 1;
|
|
159
|
+
if (min > high) {
|
|
160
|
+
break;
|
|
161
|
+
}
|
|
162
|
+
else if (min > low) {
|
|
163
|
+
low = min;
|
|
164
|
+
}
|
|
160
165
|
}
|
|
161
|
-
|
|
162
|
-
|
|
166
|
+
if (j < length) {
|
|
167
|
+
const row = this.getNthRow(j), e = (0, lint_1.generateForChild)(row, rect, rules[1], 'inconsistent-table', s[1]);
|
|
168
|
+
e.startIndex++;
|
|
169
|
+
e.startLine++;
|
|
170
|
+
e.startCol = 0;
|
|
171
|
+
errors.push(e);
|
|
163
172
|
}
|
|
164
173
|
}
|
|
165
|
-
if (j < length) {
|
|
166
|
-
const row = this.getNthRow(j), e = (0, lint_1.generateForChild)(row, rect, rules[1], 'inconsistent-table', s[1]);
|
|
167
|
-
e.startIndex++;
|
|
168
|
-
e.startLine++;
|
|
169
|
-
e.startCol = 0;
|
|
170
|
-
errors.push(e);
|
|
171
|
-
}
|
|
172
174
|
}
|
|
175
|
+
return errors;
|
|
173
176
|
}
|
|
174
|
-
return errors;
|
|
175
177
|
}
|
|
176
178
|
// eslint-disable-next-line jsdoc/require-param
|
|
177
179
|
/**
|
|
@@ -303,8 +305,10 @@ let TableToken = (() => {
|
|
|
303
305
|
/** @private */
|
|
304
306
|
json(_, start = this.getAbsoluteIndex()) {
|
|
305
307
|
const json = super.json(undefined, start);
|
|
306
|
-
|
|
307
|
-
|
|
308
|
+
LSP: { // eslint-disable-line no-unused-labels
|
|
309
|
+
json['closed'] = this.closed;
|
|
310
|
+
return json;
|
|
311
|
+
}
|
|
308
312
|
}
|
|
309
313
|
/* NOT FOR BROWSER */
|
|
310
314
|
/**
|