wikiparser-node 1.25.1 → 1.27.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/bundle/bundle-es8.min.js +25 -25
- package/bundle/bundle-lsp.min.js +30 -30
- package/bundle/bundle.min.js +23 -23
- 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/coverage/badge.svg +1 -1
- package/data/.schema.json +2 -1
- package/data/ext/math.json +41 -0
- package/data/signatures.json +82 -16
- package/dist/base.d.mts +16 -4
- package/dist/base.d.ts +16 -4
- package/dist/bin/config.js +8 -2
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -3
- package/dist/lib/document.js +6 -0
- package/dist/lib/element.js +1 -1
- package/dist/lib/lintConfig.d.ts +18 -7
- package/dist/lib/lintConfig.js +68 -21
- package/dist/lib/lsp.js +16 -8
- package/dist/lib/text.js +36 -34
- package/dist/src/arg.js +8 -6
- package/dist/src/attribute.js +37 -27
- package/dist/src/attributes.js +23 -15
- package/dist/src/converterFlags.js +9 -7
- package/dist/src/gallery.js +7 -5
- package/dist/src/heading.js +35 -25
- package/dist/src/html.js +38 -29
- package/dist/src/imageParameter.js +14 -7
- package/dist/src/imagemap.js +7 -5
- package/dist/src/index.js +51 -42
- package/dist/src/link/base.js +19 -11
- package/dist/src/link/file.js +32 -19
- package/dist/src/link/galleryImage.js +4 -2
- package/dist/src/link/index.js +4 -2
- package/dist/src/link/redirectTarget.js +4 -2
- package/dist/src/magicLink.js +13 -10
- package/dist/src/nested.js +7 -5
- package/dist/src/nowiki/comment.js +5 -3
- package/dist/src/nowiki/index.js +4 -2
- package/dist/src/nowiki/quote.js +10 -6
- package/dist/src/paramTag/index.js +4 -2
- package/dist/src/parameter.js +4 -2
- package/dist/src/table/index.js +1 -1
- package/dist/src/table/td.js +9 -7
- package/dist/src/tagPair/ext.js +3 -3
- package/dist/src/tagPair/include.js +7 -3
- package/dist/src/transclude.js +13 -7
- package/dist/util/html.js +2 -1
- package/extensions/dist/base.js +1 -1
- package/extensions/editor.css +2 -2
- package/i18n/en.json +14 -13
- package/i18n/zh-hans.json +19 -18
- package/i18n/zh-hant.json +31 -30
- package/package.json +5 -5
package/dist/src/link/file.js
CHANGED
|
@@ -116,7 +116,7 @@ let FileToken = (() => {
|
|
|
116
116
|
* @since v1.5.3
|
|
117
117
|
*/
|
|
118
118
|
get extension() {
|
|
119
|
-
return this.getAttribute('title').extension;
|
|
119
|
+
LSP: return this.getAttribute('title').extension; // eslint-disable-line no-unused-labels
|
|
120
120
|
}
|
|
121
121
|
/* NOT FOR BROWSER */
|
|
122
122
|
/** image link / 图片链接 */
|
|
@@ -185,32 +185,44 @@ let FileToken = (() => {
|
|
|
185
185
|
/** @private */
|
|
186
186
|
lint(start = this.getAbsoluteIndex(), re) {
|
|
187
187
|
LINT: { // eslint-disable-line no-unused-labels
|
|
188
|
-
const errors = super.lint(start, re), args = filterArgs(this.getAllArgs(), argTypes), keys = [...new Set(args.map(({ name }) => name))], frameKeys = keys.filter(key => frame.has(key)), horizAlignKeys = keys.filter(key => horizAlign.has(key)), vertAlignKeys = keys.filter(key => vertAlign.has(key)), [fr] = frameKeys, unscaled = fr === 'framed' || fr === 'manualthumb', rect = new rect_1.BoundingRect(this, start), {
|
|
189
|
-
|
|
188
|
+
const errors = super.lint(start, re), args = filterArgs(this.getAllArgs(), argTypes), keys = [...new Set(args.map(({ name }) => name))], frameKeys = keys.filter(key => frame.has(key)), horizAlignKeys = keys.filter(key => horizAlign.has(key)), vertAlignKeys = keys.filter(key => vertAlign.has(key)), [fr] = frameKeys, unscaled = fr === 'framed' || fr === 'manualthumb', rect = new rect_1.BoundingRect(this, start), { lintConfig } = index_1.default, { computeEditInfo, fix } = lintConfig, { ns, extension,
|
|
189
|
+
/* NOT FOR BROWSER */
|
|
190
|
+
interwiki, } = this.getAttribute('title'), { firstChild } = this;
|
|
191
|
+
let rule = 'nested-link', s = lintConfig.getSeverity(rule, 'file');
|
|
190
192
|
if (s
|
|
191
193
|
&& extensions.has(extension)
|
|
192
194
|
&& this.closest('ext-link-text')
|
|
193
195
|
&& this.getValue('link')?.trim() !== '') {
|
|
194
|
-
const e = (0, lint_1.generateForSelf)(this, rect, rule, 'link-in-extlink', s)
|
|
195
|
-
if (
|
|
196
|
-
const
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
196
|
+
const e = (0, lint_1.generateForSelf)(this, rect, rule, 'link-in-extlink', s);
|
|
197
|
+
if (computeEditInfo || fix) {
|
|
198
|
+
const link = this.getArg('link');
|
|
199
|
+
if (link) {
|
|
200
|
+
const from = start + link.getRelativeIndex();
|
|
201
|
+
e.fix = {
|
|
202
|
+
desc: index_1.default.msg('delink'),
|
|
203
|
+
range: [from, from + link.toString().length],
|
|
204
|
+
text: 'link=',
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
else {
|
|
208
|
+
e.fix = (0, lint_1.fixByInsert)(e.endIndex - 2, 'delink', '|link=');
|
|
209
|
+
}
|
|
205
210
|
}
|
|
206
211
|
errors.push(e);
|
|
207
212
|
}
|
|
208
213
|
rule = 'invalid-gallery';
|
|
209
|
-
s =
|
|
214
|
+
s = lintConfig.getSeverity(rule, 'extension');
|
|
215
|
+
if (s && ns === 6 && !extension && !firstChild.querySelector('arg,magic-word,template')
|
|
216
|
+
&& !interwiki) {
|
|
217
|
+
errors.push((0, lint_1.generateForSelf)(this, rect, rule, 'missing-extension', s));
|
|
218
|
+
}
|
|
219
|
+
s = lintConfig.getSeverity(rule, 'parameter');
|
|
210
220
|
if (s && unscaled) {
|
|
211
221
|
for (const arg of args.filter(({ name }) => name === 'width')) {
|
|
212
222
|
const e = (0, lint_1.generateForChild)(arg, rect, rule, 'invalid-image-parameter', s);
|
|
213
|
-
|
|
223
|
+
if (computeEditInfo || fix) {
|
|
224
|
+
e.fix = (0, lint_1.fixByRemove)(e, -1);
|
|
225
|
+
}
|
|
214
226
|
errors.push(e);
|
|
215
227
|
}
|
|
216
228
|
}
|
|
@@ -221,8 +233,7 @@ let FileToken = (() => {
|
|
|
221
233
|
return errors;
|
|
222
234
|
}
|
|
223
235
|
rule = 'no-duplicate';
|
|
224
|
-
const severities = ['unknownImageParameter', 'imageParameter']
|
|
225
|
-
.map(k => index_1.default.lintConfig.getSeverity(rule, k));
|
|
236
|
+
const severities = ['unknownImageParameter', 'imageParameter'].map(k => lintConfig.getSeverity(rule, k));
|
|
226
237
|
/**
|
|
227
238
|
* 图片参数到语法错误的映射
|
|
228
239
|
* @param tokens 图片参数节点
|
|
@@ -237,7 +248,9 @@ let FileToken = (() => {
|
|
|
237
248
|
}
|
|
238
249
|
/** `conflicting-image-parameter`或`duplicate-image-parameter` */
|
|
239
250
|
const e = (0, lint_1.generateForChild)(arg, rect, rule, index_1.default.msg(`${msg}-image-parameter`, p1), s);
|
|
240
|
-
|
|
251
|
+
if (computeEditInfo) {
|
|
252
|
+
e.suggestions = [(0, lint_1.fixByRemove)(e, -1)];
|
|
253
|
+
}
|
|
241
254
|
return e;
|
|
242
255
|
}).filter((e) => e !== false);
|
|
243
256
|
for (const key of keys) {
|
|
@@ -121,10 +121,12 @@ let GalleryImageToken = (() => {
|
|
|
121
121
|
/** @private */
|
|
122
122
|
lint(start = this.getAbsoluteIndex(), re) {
|
|
123
123
|
LINT: { // eslint-disable-line no-unused-labels
|
|
124
|
-
const errors = super.lint(start, re), rule = 'invalid-gallery',
|
|
124
|
+
const errors = super.lint(start, re), rule = 'invalid-gallery', { lintConfig } = index_1.default, s = lintConfig.getSeverity(rule, 'image');
|
|
125
125
|
if (s && this.#lint()) {
|
|
126
126
|
const e = (0, lint_1.generateForSelf)(this, { start }, rule, 'invalid-gallery', s);
|
|
127
|
-
|
|
127
|
+
if (lintConfig.computeEditInfo) {
|
|
128
|
+
e.suggestions = [(0, lint_1.fixByInsert)(start, 'prefix', 'File:')];
|
|
129
|
+
}
|
|
128
130
|
errors.push(e);
|
|
129
131
|
}
|
|
130
132
|
return errors;
|
package/dist/src/link/index.js
CHANGED
|
@@ -47,10 +47,12 @@ class LinkToken extends base_1.LinkBaseToken {
|
|
|
47
47
|
/** @private */
|
|
48
48
|
lint(start = this.getAbsoluteIndex(), re) {
|
|
49
49
|
LINT: { // eslint-disable-line no-unused-labels
|
|
50
|
-
const errors = super.lint(start, re), rule = 'nested-link',
|
|
50
|
+
const errors = super.lint(start, re), rule = 'nested-link', { lintConfig } = index_1.default, s = lintConfig.getSeverity(rule);
|
|
51
51
|
if (s && this.closest('ext-link-text')) {
|
|
52
52
|
const e = (0, lint_1.generateForSelf)(this, { start }, rule, 'link-in-extlink', s);
|
|
53
|
-
|
|
53
|
+
if (lintConfig.computeEditInfo || lintConfig.fix) {
|
|
54
|
+
e.fix = (0, lint_1.fixBy)(e, 'delink', this.innerText);
|
|
55
|
+
}
|
|
54
56
|
errors.push(e);
|
|
55
57
|
}
|
|
56
58
|
return errors;
|
|
@@ -55,12 +55,14 @@ class RedirectTargetToken extends base_1.LinkBaseToken {
|
|
|
55
55
|
/** @private */
|
|
56
56
|
lint(start = this.getAbsoluteIndex()) {
|
|
57
57
|
LINT: { // eslint-disable-line no-unused-labels
|
|
58
|
-
const errors = super.lint(start, false), rule = 'no-ignored',
|
|
58
|
+
const errors = super.lint(start, false), rule = 'no-ignored', { lintConfig } = index_1.default, s = lintConfig.getSeverity(rule, 'redirect');
|
|
59
59
|
if (s && this.length === 2) {
|
|
60
60
|
const e = (0, lint_1.generateForChild)(this.lastChild, { start }, rule, 'useless-link-text', s);
|
|
61
61
|
e.startIndex--;
|
|
62
62
|
e.startCol--;
|
|
63
|
-
|
|
63
|
+
if (lintConfig.computeEditInfo || lintConfig.fix) {
|
|
64
|
+
e.fix = (0, lint_1.fixByRemove)(e);
|
|
65
|
+
}
|
|
64
66
|
errors.push(e);
|
|
65
67
|
}
|
|
66
68
|
return errors;
|
package/dist/src/magicLink.js
CHANGED
|
@@ -180,25 +180,28 @@ let MagicLinkToken = (() => {
|
|
|
180
180
|
/** @private */
|
|
181
181
|
lint(start = this.getAbsoluteIndex(), re) {
|
|
182
182
|
LINT: { // eslint-disable-line no-unused-labels
|
|
183
|
-
const errors = super.lint(start, re), rect = new rect_1.BoundingRect(this, start), { type, childNodes } = this;
|
|
183
|
+
const errors = super.lint(start, re), rect = new rect_1.BoundingRect(this, start), { lintConfig } = index_1.default, { type, childNodes } = this;
|
|
184
184
|
if (type === 'magic-link') {
|
|
185
|
-
const rule = 'invalid-isbn', s =
|
|
185
|
+
const rule = 'invalid-isbn', s = lintConfig.getSeverity(rule);
|
|
186
186
|
if (s && this.#lint()) {
|
|
187
187
|
errors.push((0, lint_1.generateForSelf)(this, rect, rule, 'invalid-isbn', s));
|
|
188
188
|
}
|
|
189
189
|
return errors;
|
|
190
190
|
}
|
|
191
|
-
const pipe = type === 'ext-link-url', rule = 'unterminated-url', severity =
|
|
191
|
+
const pipe = type === 'ext-link-url', rule = 'unterminated-url', severity = lintConfig.getSeverity(rule, pipe ? 'pipe' : 'punctuation');
|
|
192
192
|
if (severity) {
|
|
193
193
|
const regex = pipe ? /\|/u : /[,;。:!?()]+/u, child = childNodes.find((c) => c.type === 'text' && regex.test(c.data));
|
|
194
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
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
(0, lint_1.fixBySpace)(i)
|
|
200
|
-
|
|
201
|
-
|
|
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
|
+
}
|
|
202
205
|
errors.push(e);
|
|
203
206
|
}
|
|
204
207
|
}
|
package/dist/src/nested.js
CHANGED
|
@@ -111,7 +111,7 @@ let NestedToken = (() => {
|
|
|
111
111
|
/** @private */
|
|
112
112
|
lint(start = this.getAbsoluteIndex(), re) {
|
|
113
113
|
LINT: { // eslint-disable-line no-unused-labels
|
|
114
|
-
const errors = super.lint(start, re), rule = 'no-ignored',
|
|
114
|
+
const errors = super.lint(start, re), rule = 'no-ignored', { lintConfig } = index_1.default, s = lintConfig.getSeverity(rule, this.name);
|
|
115
115
|
if (!s) {
|
|
116
116
|
return errors;
|
|
117
117
|
}
|
|
@@ -130,10 +130,12 @@ let NestedToken = (() => {
|
|
|
130
130
|
return str && !regex.test(str);
|
|
131
131
|
}).map(child => {
|
|
132
132
|
const e = (0, lint_1.generateForChild)(child, rect, rule, index_1.default.msg('invalid-content', this.name), s);
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
133
|
+
if (lintConfig.computeEditInfo) {
|
|
134
|
+
e.suggestions = [
|
|
135
|
+
(0, lint_1.fixByRemove)(e),
|
|
136
|
+
(0, lint_1.fixByComment)(e, child.toString()),
|
|
137
|
+
];
|
|
138
|
+
}
|
|
137
139
|
return e;
|
|
138
140
|
}),
|
|
139
141
|
];
|
|
@@ -91,12 +91,14 @@ let CommentToken = (() => {
|
|
|
91
91
|
if (this.closed) {
|
|
92
92
|
return [];
|
|
93
93
|
}
|
|
94
|
-
const rule = 'unclosed-comment',
|
|
94
|
+
const rule = 'unclosed-comment', { lintConfig } = index_1.default, s = lintConfig.getSeverity(rule);
|
|
95
95
|
if (!s) {
|
|
96
96
|
return [];
|
|
97
97
|
}
|
|
98
|
-
const e = (0, lint_1.generateForSelf)(this, { start }, rule,
|
|
99
|
-
|
|
98
|
+
const e = (0, lint_1.generateForSelf)(this, { start }, rule, 'unclosed-comment', s);
|
|
99
|
+
if (lintConfig.computeEditInfo) {
|
|
100
|
+
e.suggestions = [(0, lint_1.fixByClose)(e.endIndex, '-->')];
|
|
101
|
+
}
|
|
100
102
|
return [e];
|
|
101
103
|
}
|
|
102
104
|
}
|
package/dist/src/nowiki/index.js
CHANGED
|
@@ -32,10 +32,12 @@ class NowikiToken extends base_1.NowikiBaseToken {
|
|
|
32
32
|
/** @private */
|
|
33
33
|
lint(start = this.getAbsoluteIndex()) {
|
|
34
34
|
LINT: { // eslint-disable-line no-unused-labels
|
|
35
|
-
const { name } = this, rule = 'void-ext',
|
|
35
|
+
const { name } = this, rule = 'void-ext', { lintConfig } = index_1.default, s = lintConfig.getSeverity(rule, name);
|
|
36
36
|
if (s && this.#lint()) {
|
|
37
37
|
const e = (0, lint_1.generateForSelf)(this, { start }, rule, index_1.default.msg('nothing-in', name), s);
|
|
38
|
-
|
|
38
|
+
if (lintConfig.computeEditInfo) {
|
|
39
|
+
e.suggestions = [(0, lint_1.fixByRemove)(e)];
|
|
40
|
+
}
|
|
39
41
|
return [e];
|
|
40
42
|
}
|
|
41
43
|
return super.lint(start, getLintRegex(name));
|
package/dist/src/nowiki/quote.js
CHANGED
|
@@ -114,7 +114,7 @@ let QuoteToken = (() => {
|
|
|
114
114
|
/** @private */
|
|
115
115
|
lint(start = this.getAbsoluteIndex()) {
|
|
116
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'], severities = [undefined, 'word'].map(key =>
|
|
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
118
|
if (previousData?.endsWith(`'`)) {
|
|
119
119
|
const severity = severities[(closing.bold || closing.italic) && /[a-z\d]'$/iu.test(previousData) ? 1 : 0];
|
|
120
120
|
if (severity) {
|
|
@@ -126,16 +126,20 @@ let QuoteToken = (() => {
|
|
|
126
126
|
startCol: endCol - length,
|
|
127
127
|
endCol,
|
|
128
128
|
};
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
129
|
+
if (computeEditInfo) {
|
|
130
|
+
eNew.suggestions = [
|
|
131
|
+
(0, lint_1.fixByEscape)(startIndex, ''', length),
|
|
132
|
+
(0, lint_1.fixByRemove)(eNew),
|
|
133
|
+
];
|
|
134
|
+
}
|
|
133
135
|
errors.push(eNew);
|
|
134
136
|
}
|
|
135
137
|
}
|
|
136
138
|
if (s && bold && this.closest('heading-title,ext')?.type === 'heading-title') {
|
|
137
139
|
const e = (0, lint_1.generateForSelf)(this, rect, rules[1], 'bold-in-header', s);
|
|
138
|
-
|
|
140
|
+
if (computeEditInfo) {
|
|
141
|
+
e.suggestions = [(0, lint_1.fixByRemove)(e)];
|
|
142
|
+
}
|
|
139
143
|
errors.push(e);
|
|
140
144
|
}
|
|
141
145
|
return errors;
|
|
@@ -97,7 +97,7 @@ let ParamTagToken = (() => {
|
|
|
97
97
|
/** @private */
|
|
98
98
|
lint(start = this.getAbsoluteIndex()) {
|
|
99
99
|
LINT: { // eslint-disable-line no-unused-labels
|
|
100
|
-
const rule = 'no-ignored',
|
|
100
|
+
const rule = 'no-ignored', { lintConfig } = index_1.default, s = lintConfig.getSeverity(rule, this.name);
|
|
101
101
|
if (!s) {
|
|
102
102
|
return [];
|
|
103
103
|
}
|
|
@@ -113,7 +113,9 @@ let ParamTagToken = (() => {
|
|
|
113
113
|
const i = grandChildren.findIndex(({ type }) => type !== 'text'), str = grandChildren.slice(0, i === -1 ? undefined : i).map(String).join('');
|
|
114
114
|
if (str && !(i === -1 ? /^[a-z]+(?:\[\])?\s*=/iu : /^[a-z]+(?:\[\])?\s*(?:=|$)/iu).test(str)) {
|
|
115
115
|
const e = (0, lint_1.generateForChild)(child, rect, rule, msg, s);
|
|
116
|
-
|
|
116
|
+
if (lintConfig.computeEditInfo) {
|
|
117
|
+
e.suggestions = [(0, lint_1.fixByRemove)(e)];
|
|
118
|
+
}
|
|
117
119
|
errors.push(e);
|
|
118
120
|
}
|
|
119
121
|
else {
|
package/dist/src/parameter.js
CHANGED
|
@@ -178,7 +178,7 @@ let ParameterToken = (() => {
|
|
|
178
178
|
/** @private */
|
|
179
179
|
lint(start = this.getAbsoluteIndex(), re) {
|
|
180
180
|
LINT: { // eslint-disable-line no-unused-labels
|
|
181
|
-
const errors = super.lint(start, re), rule = 'unescaped',
|
|
181
|
+
const errors = super.lint(start, re), rule = 'unescaped', { lintConfig } = index_1.default, s = lintConfig.getSeverity(rule);
|
|
182
182
|
if (s) {
|
|
183
183
|
const { firstChild } = this, link = linkRegex.exec(firstChild.text())?.[0];
|
|
184
184
|
try {
|
|
@@ -189,7 +189,9 @@ let ParameterToken = (() => {
|
|
|
189
189
|
e.startCol = e.endCol;
|
|
190
190
|
e.endIndex++;
|
|
191
191
|
e.endCol++;
|
|
192
|
-
|
|
192
|
+
if (lintConfig.computeEditInfo || lintConfig.fix) {
|
|
193
|
+
e.fix = (0, lint_1.fixByEscape)(e.startIndex, '{{=}}');
|
|
194
|
+
}
|
|
193
195
|
errors.push(e);
|
|
194
196
|
}
|
|
195
197
|
}
|
package/dist/src/table/index.js
CHANGED
|
@@ -141,7 +141,7 @@ let TableToken = (() => {
|
|
|
141
141
|
LINT: { // eslint-disable-line no-unused-labels
|
|
142
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
143
|
if (s[0] && !this.closed) {
|
|
144
|
-
errors.push((0, lint_1.generateForChild)(this.firstChild, rect, rules[0],
|
|
144
|
+
errors.push((0, lint_1.generateForChild)(this.firstChild, rect, rules[0], 'unclosed-table', s[0]));
|
|
145
145
|
}
|
|
146
146
|
if (s[1]) {
|
|
147
147
|
const layout = this.getLayout(), { length } = layout;
|
package/dist/src/table/td.js
CHANGED
|
@@ -219,7 +219,7 @@ let TdToken = (() => {
|
|
|
219
219
|
/** @private */
|
|
220
220
|
lint(start = this.getAbsoluteIndex(), re) {
|
|
221
221
|
LINT: { // eslint-disable-line no-unused-labels
|
|
222
|
-
const errors = super.lint(start, re), rect = new rect_1.BoundingRect(this, start + this.getRelativeIndex(this.length - 1)), rule = 'pipe-like', severities = ['td', 'double'].map(key =>
|
|
222
|
+
const errors = super.lint(start, re), rect = new rect_1.BoundingRect(this, start + this.getRelativeIndex(this.length - 1)), rule = 'pipe-like', { lintConfig } = index_1.default, { computeEditInfo, fix } = lintConfig, severities = ['td', 'double'].map(key => lintConfig.getSeverity(rule, key));
|
|
223
223
|
for (const child of this.lastChild.childNodes) {
|
|
224
224
|
if (child.type === 'text') {
|
|
225
225
|
const { data } = child;
|
|
@@ -227,12 +227,14 @@ let TdToken = (() => {
|
|
|
227
227
|
const double = data.includes('||'), s = severities[double ? 1 : 0];
|
|
228
228
|
if (s) {
|
|
229
229
|
const e = (0, lint_1.generateForChild)(child, rect, rule, 'pipe-in-table', s);
|
|
230
|
-
if (
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
230
|
+
if (computeEditInfo || fix) {
|
|
231
|
+
if (double) {
|
|
232
|
+
const syntax = { caption: '|+', td: '|', th: '!' }[this.subtype];
|
|
233
|
+
e.fix = (0, lint_1.fixBy)(e, 'newline', data.replace(/\|\|/gu, `\n${syntax}`));
|
|
234
|
+
}
|
|
235
|
+
else if (computeEditInfo) {
|
|
236
|
+
e.suggestions = [(0, lint_1.fixByPipe)(e.startIndex, data)];
|
|
237
|
+
}
|
|
236
238
|
}
|
|
237
239
|
errors.push(e);
|
|
238
240
|
}
|
package/dist/src/tagPair/ext.js
CHANGED
|
@@ -199,14 +199,14 @@ let ExtToken = (() => {
|
|
|
199
199
|
/** @private */
|
|
200
200
|
lint(start = this.getAbsoluteIndex(), re) {
|
|
201
201
|
LINT: { // eslint-disable-line no-unused-labels
|
|
202
|
-
const errors = super.lint(start, re), rect = new rect_1.BoundingRect(this, start);
|
|
202
|
+
const errors = super.lint(start, re), { lintConfig } = index_1.default, rect = new rect_1.BoundingRect(this, start);
|
|
203
203
|
if (this.name !== 'nowiki') {
|
|
204
|
-
const s = this.inHtmlAttrs(), rule = 'parsing-order', severity = s &&
|
|
204
|
+
const s = this.inHtmlAttrs(), rule = 'parsing-order', severity = s && lintConfig.getSeverity(rule, s === 2 ? 'ext' : 'templateInTable');
|
|
205
205
|
if (severity) {
|
|
206
206
|
errors.push((0, lint_1.generateForSelf)(this, rect, rule, 'ext-in-html', severity));
|
|
207
207
|
}
|
|
208
208
|
}
|
|
209
|
-
const rule = 'var-anchor', s =
|
|
209
|
+
const rule = 'var-anchor', s = lintConfig.getSeverity(rule, 'ref');
|
|
210
210
|
if (s && this.name === 'ref' && this.closest('heading-title')) {
|
|
211
211
|
errors.push((0, lint_1.generateForSelf)(this, rect, rule, 'variable-anchor', s));
|
|
212
212
|
}
|
|
@@ -102,15 +102,19 @@ let IncludeToken = (() => {
|
|
|
102
102
|
/** @private */
|
|
103
103
|
lint(start = this.getAbsoluteIndex()) {
|
|
104
104
|
LINT: { // eslint-disable-line no-unused-labels
|
|
105
|
-
const errors = [], { firstChild, closed, name } = this, rect = new rect_1.BoundingRect(this, start), rules = ['no-ignored', 'unclosed-comment'], s = rules.map(rule =>
|
|
105
|
+
const errors = [], { firstChild, closed, name } = this, rect = new rect_1.BoundingRect(this, start), rules = ['no-ignored', 'unclosed-comment'], { lintConfig } = index_1.default, { computeEditInfo } = lintConfig, s = rules.map(rule => lintConfig.getSeverity(rule, 'include'));
|
|
106
106
|
if (s[0] && firstChild.data.trim()) {
|
|
107
107
|
const e = (0, lint_1.generateForChild)(firstChild, rect, rules[0], 'useless-attribute', s[0]);
|
|
108
|
-
|
|
108
|
+
if (computeEditInfo) {
|
|
109
|
+
e.suggestions = [(0, lint_1.fixByRemove)(e)];
|
|
110
|
+
}
|
|
109
111
|
errors.push(e);
|
|
110
112
|
}
|
|
111
113
|
if (s[1] && !closed) {
|
|
112
114
|
const e = (0, lint_1.generateForSelf)(this, rect, rules[1], index_1.default.msg('unclosed', `<${name}>`), s[1]);
|
|
113
|
-
|
|
115
|
+
if (computeEditInfo) {
|
|
116
|
+
e.suggestions = [(0, lint_1.fixByClose)(e.endIndex, `</${name}>`)];
|
|
117
|
+
}
|
|
114
118
|
errors.push(e);
|
|
115
119
|
}
|
|
116
120
|
return errors;
|
package/dist/src/transclude.js
CHANGED
|
@@ -353,11 +353,11 @@ let TranscludeToken = (() => {
|
|
|
353
353
|
if (!this.isTemplate()) {
|
|
354
354
|
return errors;
|
|
355
355
|
}
|
|
356
|
-
const { type, childNodes, length } = this, rect = new rect_1.BoundingRect(this, start), invoke = type === 'magic-word';
|
|
357
|
-
let rule = 'no-ignored', s =
|
|
356
|
+
const { type, childNodes, length } = this, rect = new rect_1.BoundingRect(this, start), { lintConfig } = index_1.default, { computeEditInfo } = lintConfig, invoke = type === 'magic-word';
|
|
357
|
+
let rule = 'no-ignored', s = lintConfig.getSeverity(rule, 'fragment');
|
|
358
358
|
if (invoke && !this.#getTitle().valid) {
|
|
359
359
|
rule = 'invalid-invoke';
|
|
360
|
-
s =
|
|
360
|
+
s = lintConfig.getSeverity(rule, 'name');
|
|
361
361
|
if (s) {
|
|
362
362
|
errors.push((0, lint_1.generateForChild)(childNodes[1], rect, rule, 'illegal-module', s));
|
|
363
363
|
}
|
|
@@ -367,25 +367,31 @@ let TranscludeToken = (() => {
|
|
|
367
367
|
.findIndex(c => c.type === 'text' && (0, string_1.decodeHtml)(c.data).includes('#')), textNode = child.childNodes[i];
|
|
368
368
|
if (textNode) {
|
|
369
369
|
const e = (0, lint_1.generateForChild)(child, rect, rule, 'useless-fragment', s);
|
|
370
|
-
|
|
370
|
+
if (computeEditInfo) {
|
|
371
|
+
e.suggestions = [
|
|
372
|
+
(0, lint_1.fixByRemove)(e, child.getRelativeIndex(i) + textNode.data.indexOf('#')),
|
|
373
|
+
];
|
|
374
|
+
}
|
|
371
375
|
errors.push(e);
|
|
372
376
|
}
|
|
373
377
|
}
|
|
374
378
|
rule = 'invalid-invoke';
|
|
375
|
-
s =
|
|
379
|
+
s = lintConfig.getSeverity(rule, 'function');
|
|
376
380
|
if (s && invoke && length === 2) {
|
|
377
381
|
errors.push((0, lint_1.generateForSelf)(this, rect, rule, 'missing-function', s));
|
|
378
382
|
return errors;
|
|
379
383
|
}
|
|
380
384
|
rule = 'no-duplicate';
|
|
381
|
-
s =
|
|
385
|
+
s = lintConfig.getSeverity(rule, 'parameter');
|
|
382
386
|
if (s) {
|
|
383
387
|
const duplicatedArgs = this.getDuplicatedArgs()
|
|
384
388
|
.filter(([, parameter]) => !parameter[0].querySelector('ext')), msg = 'duplicate-parameter';
|
|
385
389
|
for (const [, args] of duplicatedArgs) {
|
|
386
390
|
errors.push(...args.map(arg => {
|
|
387
391
|
const e = (0, lint_1.generateForChild)(arg, rect, rule, msg, s);
|
|
388
|
-
|
|
392
|
+
if (computeEditInfo) {
|
|
393
|
+
e.suggestions = [(0, lint_1.fixByRemove)(e, -1)];
|
|
394
|
+
}
|
|
389
395
|
return e;
|
|
390
396
|
}));
|
|
391
397
|
}
|
package/dist/util/html.js
CHANGED
|
@@ -144,7 +144,8 @@ exports.html = html;
|
|
|
144
144
|
* @param tokens inner tokens of a section heading
|
|
145
145
|
*/
|
|
146
146
|
const getId = (tokens) => {
|
|
147
|
-
const opt = { nocc: true }, content = Array.isArray(tokens) ? (0, exports.html)(tokens, '', opt) : tokens.toHtmlInternal(opt), id = (0, string_1.decodeHtml)((0, string_1.sanitizeAlt)(content
|
|
147
|
+
const opt = { nocc: true }, content = Array.isArray(tokens) ? (0, exports.html)(tokens, '', opt) : tokens.toHtmlInternal(opt), id = (0, string_1.decodeHtml)((0, string_1.sanitizeAlt)(content.replaceAll('_', ' ')))
|
|
148
|
+
.replace(/[\s_]+/gu, '_');
|
|
148
149
|
return id.endsWith('_') ? id.slice(0, -1) : id;
|
|
149
150
|
};
|
|
150
151
|
exports.getId = getId;
|
package/extensions/dist/base.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
(() => {
|
|
2
2
|
var _a;
|
|
3
|
-
const version = '1.
|
|
3
|
+
const version = '1.27.0', src = (_a = document.currentScript) === null || _a === void 0 ? void 0 : _a.src, file = /\/extensions\/dist\/base\.(?:min\.)?js$/u, CDN = src && file.test(src)
|
|
4
4
|
? src.replace(file, '')
|
|
5
5
|
: `https://testingcf.jsdelivr.net/npm/wikiparser-node@${version}`;
|
|
6
6
|
const workerJS = () => {
|
package/extensions/editor.css
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
display: block;
|
|
4
4
|
box-sizing: border-box;
|
|
5
5
|
width: 100%;
|
|
6
|
-
resize: vertical;
|
|
6
|
+
resize: vertical; /* stylelint-disable-line plugin/use-baseline */
|
|
7
7
|
font-family: monospace;
|
|
8
8
|
background: none !important;
|
|
9
9
|
caret-color: #000;
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
position: absolute;
|
|
13
13
|
inset: 0;
|
|
14
14
|
-webkit-user-select: none;
|
|
15
|
-
user-select: none;
|
|
15
|
+
user-select: none; /* stylelint-disable-line plugin/use-baseline */
|
|
16
16
|
}
|
|
17
17
|
#wikiPretty + .wikiparsed, #wikiPretty {
|
|
18
18
|
outline: none;
|
package/i18n/en.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"attributes-of-closing-tag": "attributes of a closing tag",
|
|
3
3
|
"bold-apostrophes": "bold apostrophes",
|
|
4
|
-
"bold-in-header": "bold in section header",
|
|
4
|
+
"bold-in-header": "bold text in a section header",
|
|
5
5
|
"close": null,
|
|
6
6
|
"closing-and-self-closing": "tag that is both closing and self-closing",
|
|
7
7
|
"comment": null,
|
|
@@ -11,9 +11,9 @@
|
|
|
11
11
|
"delink": null,
|
|
12
12
|
"duplicate-attribute": "duplicate $1 attribute",
|
|
13
13
|
"duplicate-category": "duplicate category",
|
|
14
|
-
"duplicate-id": "duplicate id",
|
|
14
|
+
"duplicate-id": "duplicate HTML id",
|
|
15
15
|
"duplicate-image-parameter": "duplicate image $1 parameter",
|
|
16
|
-
"duplicate-parameter": "duplicate parameter",
|
|
16
|
+
"duplicate-parameter": "duplicate template parameter",
|
|
17
17
|
"encode": null,
|
|
18
18
|
"escape": null,
|
|
19
19
|
"expand": null,
|
|
@@ -22,16 +22,15 @@
|
|
|
22
22
|
"full-width-punctuation": "full-width punctuation",
|
|
23
23
|
"header-in-html": "section header in HTML tag attributes",
|
|
24
24
|
"horizontal-alignment": null,
|
|
25
|
-
"html-comment": "HTML comment",
|
|
26
25
|
"html-in-table": "HTML tag in table attributes",
|
|
27
|
-
"illegal-attribute-name": "
|
|
28
|
-
"illegal-attribute-value": "
|
|
29
|
-
"illegal-module": "
|
|
26
|
+
"illegal-attribute-name": "invalid attribute name",
|
|
27
|
+
"illegal-attribute-value": "invalid attribute value",
|
|
28
|
+
"illegal-module": "invalid Scribunto module name",
|
|
30
29
|
"imagemap-without-image": "<imagemap> without an image",
|
|
31
30
|
"in-url": "$1 in URL",
|
|
32
31
|
"inconsistent-table": "inconsistent table layout",
|
|
33
32
|
"insecure-style": "insecure style",
|
|
34
|
-
"invalid-attribute": "containing invalid attribute",
|
|
33
|
+
"invalid-attribute": "element containing an invalid attribute name",
|
|
35
34
|
"invalid-content": "invalid content in <$1>",
|
|
36
35
|
"invalid-conversion-flag": "invalid conversion flag",
|
|
37
36
|
"invalid-gallery": "invalid gallery image",
|
|
@@ -42,10 +41,11 @@
|
|
|
42
41
|
"invalid-self-closing": "invalid self-closing tag",
|
|
43
42
|
"invisible-triple-braces": "invisible content inside triple braces",
|
|
44
43
|
"italic-apostrophes": "italic apostrophes",
|
|
45
|
-
"left-bracket": "
|
|
44
|
+
"left-bracket": "opening bracket",
|
|
46
45
|
"link-in-extlink": "internal link in an external link",
|
|
47
46
|
"lonely": "lonely \"$1\"",
|
|
48
|
-
"missing-
|
|
47
|
+
"missing-extension": "missing file extension",
|
|
48
|
+
"missing-function": "missing Scribunto module function name",
|
|
49
49
|
"newline": null,
|
|
50
50
|
"no-self-closing": "no self-closing",
|
|
51
51
|
"nonzero-tabindex": "nonzero tabindex",
|
|
@@ -56,17 +56,18 @@
|
|
|
56
56
|
"prefix": null,
|
|
57
57
|
"pipe-in-link": "additional \"|\" in the link text",
|
|
58
58
|
"pipe-in-table": "additional \"|\" in a table cell",
|
|
59
|
-
"quotes": null,
|
|
60
59
|
"remove": null,
|
|
61
|
-
"table": null,
|
|
62
60
|
"template-in-link": "template in an internal link target",
|
|
63
61
|
"unbalanced-in-section-header": "unbalanced $1 in a section header",
|
|
64
62
|
"unclosed": "unclosed $1",
|
|
63
|
+
"unclosed-comment": "unclosed HTML comment",
|
|
64
|
+
"unclosed-quotes": "unclosed quotes",
|
|
65
|
+
"unclosed-table": "unclosed table",
|
|
65
66
|
"unclosed-tag": "unclosed tag",
|
|
66
67
|
"unescaped-query": "unescaped query string in an anonymous parameter",
|
|
67
68
|
"unexpected-argument": "unexpected template argument",
|
|
68
69
|
"unmatched-closing": "unmatched closing tag",
|
|
69
|
-
"unnecessary-encoding": "unnecessary
|
|
70
|
+
"unnecessary-encoding": "unnecessary percent-encoding in an internal link",
|
|
70
71
|
"uppercase": null,
|
|
71
72
|
"useless-attribute": "useless attribute",
|
|
72
73
|
"useless-fragment": "useless fragment",
|