wikilint 2.43.0 → 2.45.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/config/default.json +32 -2
- package/config/enwiki.json +1 -1
- package/config/jawiki.json +1 -1
- package/config/minimum.json +1 -1
- package/config/moegirl.json +39 -1
- package/config/zhwiki.json +1 -1
- package/data/ext/templatedata.json +13 -5
- package/data/signatures.json +38 -32
- package/dist/base.d.mts +5 -5
- package/dist/base.d.ts +5 -5
- package/dist/base.js +1 -0
- package/dist/base.mjs +1 -0
- package/dist/bin/config.js +6 -5
- package/dist/index.js +9 -6
- package/dist/internal.d.ts +6 -1
- package/dist/lib/document.d.ts +17 -14
- package/dist/lib/element.js +5 -5
- package/dist/lib/lintConfig.js +11 -1
- package/dist/lib/lsp.d.ts +1 -2
- package/dist/lib/lsp.js +18 -42
- package/dist/lib/node.js +2 -2
- package/dist/lib/text.js +2 -2
- package/dist/lib/title.d.ts +4 -1
- package/dist/lib/title.js +5 -1
- package/dist/map.d.ts +4 -1
- package/dist/mixin/attributesParent.js +1 -1
- package/dist/mixin/elementLike.js +29 -31
- package/dist/mixin/hidden.js +0 -1
- package/dist/mixin/paramLineParent.d.ts +26 -0
- package/dist/mixin/paramLineParent.js +51 -0
- package/dist/parser/converter.js +1 -1
- package/dist/src/arg.js +17 -35
- package/dist/src/atom.d.ts +1 -1
- package/dist/src/atom.js +2 -0
- package/dist/src/attribute.js +10 -5
- package/dist/src/attributes.d.ts +1 -0
- package/dist/src/attributes.js +41 -15
- package/dist/src/commented.d.ts +1 -0
- package/dist/src/commented.js +1 -3
- package/dist/src/converterFlags.js +17 -8
- package/dist/src/converterRule.js +3 -3
- package/dist/src/funcTag.d.ts +23 -0
- package/dist/src/funcTag.js +85 -0
- package/dist/src/heading.js +8 -3
- package/dist/src/hidden.d.ts +3 -2
- package/dist/src/hidden.js +29 -5
- package/dist/src/imageParameter.d.ts +4 -3
- package/dist/src/imageParameter.js +29 -9
- package/dist/src/index.js +2 -2
- package/dist/src/link/base.js +14 -2
- package/dist/src/link/categorytree.d.ts +2 -0
- package/dist/src/link/categorytree.js +8 -5
- package/dist/src/link/file.d.ts +5 -4
- package/dist/src/link/file.js +19 -13
- package/dist/src/multiLine/charinsert.d.ts +16 -0
- package/dist/src/multiLine/charinsert.js +84 -0
- package/dist/src/multiLine/gallery.js +4 -4
- package/dist/src/multiLine/imagemap.d.ts +1 -1
- package/dist/src/multiLine/imagemap.js +7 -7
- package/dist/src/multiLine/index.d.ts +3 -0
- package/dist/src/multiLine/index.js +79 -18
- package/dist/src/multiLine/inputbox.d.ts +1 -0
- package/dist/src/multiLine/paramTag.d.ts +3 -0
- package/dist/src/multiLine/paramTag.js +60 -13
- package/dist/src/nested.js +7 -7
- package/dist/src/nowiki/index.d.ts +1 -0
- package/dist/src/nowiki/index.js +39 -28
- package/dist/src/nowiki/quote.js +6 -5
- package/dist/src/paramLine.d.ts +17 -3
- package/dist/src/paramLine.js +123 -31
- package/dist/src/parameter.d.ts +6 -0
- package/dist/src/parameter.js +15 -1
- package/dist/src/singleLine/charinsertLine.d.ts +21 -0
- package/dist/src/singleLine/charinsertLine.js +69 -0
- package/dist/src/{imagemapLink.d.ts → singleLine/imagemapLink.d.ts} +8 -7
- package/dist/src/singleLine/imagemapLink.js +95 -0
- package/dist/src/singleLine/index.d.ts +10 -0
- package/dist/src/singleLine/index.js +16 -0
- package/dist/src/tag/html.js +26 -8
- package/dist/src/tag/index.js +18 -17
- package/dist/src/tagPair/ext.d.ts +1 -0
- package/dist/src/tagPair/ext.js +59 -5
- package/dist/src/tagPair/index.js +1 -10
- package/dist/src/transclude.js +13 -13
- package/dist/util/sharable.js +22 -0
- package/dist/util/sharable.mjs +22 -0
- package/dist/util/string.js +33 -2
- package/dist/vendor/search.js +34 -0
- package/i18n/en.json +11 -0
- package/i18n/zh-hans.json +11 -0
- package/i18n/zh-hant.json +11 -0
- package/package.json +16 -25
- package/dist/src/imagemapLink.js +0 -34
- package/dist/util/search.js +0 -16
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { Token } from './index';
|
|
2
|
-
import type { LintError, Config
|
|
2
|
+
import type { LintError, Config } from '../base';
|
|
3
3
|
import type { Title } from '../lib/title';
|
|
4
4
|
import type { AtomToken, FileToken } from '../internal';
|
|
5
|
+
export type GalleryImageTypes = 'gallery-image' | 'imagemap-image';
|
|
5
6
|
/**
|
|
6
7
|
* image parameter
|
|
7
8
|
*
|
|
@@ -26,9 +27,9 @@ export declare abstract class ImageParameterToken extends Token {
|
|
|
26
27
|
/**
|
|
27
28
|
* @param str 图片参数
|
|
28
29
|
* @param extension 文件扩展名
|
|
29
|
-
* @param type
|
|
30
|
+
* @param type 图库节点类型
|
|
30
31
|
*/
|
|
31
|
-
constructor(str: string, extension: string | undefined, type:
|
|
32
|
+
constructor(str: string, extension: string | undefined, type: GalleryImageTypes | undefined, config: Config, accum?: Token[]);
|
|
32
33
|
/**
|
|
33
34
|
* Get the parameter value
|
|
34
35
|
*
|
|
@@ -62,7 +62,8 @@ const getUrl = (link) => {
|
|
|
62
62
|
}
|
|
63
63
|
return new URL(link).href;
|
|
64
64
|
};
|
|
65
|
-
|
|
65
|
+
const pdfExtensions = new Set(['djvu', 'djv', 'pdf']);
|
|
66
|
+
function validate(key, val, config, extOrType, halfParsed, accum) {
|
|
66
67
|
val = (0, string_1.removeComment)(val).trim();
|
|
67
68
|
let value = val.replace(key === 'link' ? /\0\d+[tq]\x7F/gu : /\0\d+t\x7F/gu, '').trim();
|
|
68
69
|
switch (key) {
|
|
@@ -70,6 +71,7 @@ function validate(key, val, config, extOrType, halfParsed) {
|
|
|
70
71
|
return !value && Boolean(val) || /^(?:\d+x?|\d*x\d+)(?:\s*px)?$/u.test(value);
|
|
71
72
|
case 'link': {
|
|
72
73
|
const isGalleryImage = extOrType === 'gallery-image';
|
|
74
|
+
let nowiki = true;
|
|
73
75
|
if (!value) {
|
|
74
76
|
return val;
|
|
75
77
|
}
|
|
@@ -78,8 +80,9 @@ function validate(key, val, config, extOrType, halfParsed) {
|
|
|
78
80
|
}
|
|
79
81
|
else if (value.startsWith('[[') && value.endsWith(']]')) {
|
|
80
82
|
value = value.slice(2, -2);
|
|
83
|
+
nowiki = false;
|
|
81
84
|
}
|
|
82
|
-
const title = index_1.default.normalizeTitle(value, 0, false, config, { halfParsed, decode: true, selfLink: true, page: '' });
|
|
85
|
+
const title = index_1.default.normalizeTitle(value, 0, false, config, { halfParsed, decode: true, selfLink: true, page: '', nowiki }, accum);
|
|
83
86
|
return title.valid ? title : isGalleryImage;
|
|
84
87
|
}
|
|
85
88
|
case 'lang':
|
|
@@ -89,7 +92,7 @@ function validate(key, val, config, extOrType, halfParsed) {
|
|
|
89
92
|
case 'manualthumb':
|
|
90
93
|
return true;
|
|
91
94
|
case 'page':
|
|
92
|
-
return (extOrType
|
|
95
|
+
return pdfExtensions.has(extOrType) && Number(value) > 0;
|
|
93
96
|
default:
|
|
94
97
|
return Boolean(value) && !isNaN(value);
|
|
95
98
|
}
|
|
@@ -137,12 +140,12 @@ let ImageParameterToken = (() => {
|
|
|
137
140
|
}
|
|
138
141
|
const value = super.text().trim();
|
|
139
142
|
return debug_1.Shadow.run(() => {
|
|
140
|
-
const config = this.getAttribute('config'), token = new index_2.Token(value, config);
|
|
143
|
+
const config = this.getAttribute('config'), accum = [], token = new index_2.Token(value, config, accum);
|
|
141
144
|
token.parseOnce(0, this.getAttribute('include')).parseOnce();
|
|
142
145
|
if (/^\0\d+m\x7F/u.test(token.firstChild.toString())) {
|
|
143
146
|
return value;
|
|
144
147
|
}
|
|
145
|
-
const link = validate('link', value, config, this.parentNode?.type);
|
|
148
|
+
const link = validate('link', value, config, this.parentNode?.type, undefined, accum);
|
|
146
149
|
return link === true ? undefined : link;
|
|
147
150
|
}, index_1.default);
|
|
148
151
|
}
|
|
@@ -150,7 +153,7 @@ let ImageParameterToken = (() => {
|
|
|
150
153
|
/**
|
|
151
154
|
* @param str 图片参数
|
|
152
155
|
* @param extension 文件扩展名
|
|
153
|
-
* @param type
|
|
156
|
+
* @param type 图库节点类型
|
|
154
157
|
*/
|
|
155
158
|
constructor(str, extension, type, config, accum) {
|
|
156
159
|
let mt;
|
|
@@ -159,7 +162,7 @@ let ImageParameterToken = (() => {
|
|
|
159
162
|
mt = regex.exec(str);
|
|
160
163
|
return mt
|
|
161
164
|
&& (mt.length !== 4
|
|
162
|
-
|| validate(key, mt[2], config, key === 'link' ? type : extension, true) !== false);
|
|
165
|
+
|| validate(key, mt[2], config, key === 'link' ? type : extension, true, accum) !== false);
|
|
163
166
|
});
|
|
164
167
|
// @ts-expect-error mt already assigned
|
|
165
168
|
if (param && mt) {
|
|
@@ -199,7 +202,15 @@ let ImageParameterToken = (() => {
|
|
|
199
202
|
}
|
|
200
203
|
/** @private */
|
|
201
204
|
text() {
|
|
202
|
-
|
|
205
|
+
const { name } = this;
|
|
206
|
+
if (name === 'invalid') {
|
|
207
|
+
return '';
|
|
208
|
+
}
|
|
209
|
+
let str = super.text();
|
|
210
|
+
if (name !== 'caption') {
|
|
211
|
+
str = str.trim();
|
|
212
|
+
}
|
|
213
|
+
return this.#syntax ? this.#syntax.replace('$1', str).trim() : str;
|
|
203
214
|
}
|
|
204
215
|
/** @private */
|
|
205
216
|
isPlain() {
|
|
@@ -285,7 +296,16 @@ let ImageParameterToken = (() => {
|
|
|
285
296
|
* 获取参数值
|
|
286
297
|
*/
|
|
287
298
|
getValue() {
|
|
288
|
-
LINT:
|
|
299
|
+
LINT: {
|
|
300
|
+
const { name, childNodes } = this;
|
|
301
|
+
if (name === 'link') {
|
|
302
|
+
return (0, string_1.text)(childNodes.map(child => child.is('ext') && child.name === 'nowiki' ? child.innerText ?? '' : child)).trim();
|
|
303
|
+
}
|
|
304
|
+
else if (name === 'invalid') {
|
|
305
|
+
return '';
|
|
306
|
+
}
|
|
307
|
+
return name === 'caption' ? super.text() : this.#isVoid() || super.text().trim();
|
|
308
|
+
}
|
|
289
309
|
}
|
|
290
310
|
};
|
|
291
311
|
return ImageParameterToken = _classThis;
|
package/dist/src/index.js
CHANGED
|
@@ -372,12 +372,12 @@ class Token extends element_1.AstElement {
|
|
|
372
372
|
}
|
|
373
373
|
/** @private */
|
|
374
374
|
inTableAttrs() {
|
|
375
|
-
return this.isInside('table-attrs')
|
|
375
|
+
LINT: return this.isInside('table-attrs')
|
|
376
376
|
&& (this.closest('table-attrs,arg,parameter')?.is('table-attrs') ? 2 : 1);
|
|
377
377
|
}
|
|
378
378
|
/** @private */
|
|
379
379
|
inHtmlAttrs() {
|
|
380
|
-
return this.isInside('html-attrs') ? 2 : this.inTableAttrs();
|
|
380
|
+
LINT: return this.isInside('html-attrs') ? 2 : this.inTableAttrs();
|
|
381
381
|
}
|
|
382
382
|
/** @private */
|
|
383
383
|
lint(start = this.getAbsoluteIndex(), re) {
|
package/dist/src/link/base.js
CHANGED
|
@@ -41,6 +41,7 @@ exports.LinkBaseToken = void 0;
|
|
|
41
41
|
const lint_1 = require("../../util/lint");
|
|
42
42
|
const constants_1 = require("../../util/constants");
|
|
43
43
|
const debug_1 = require("../../util/debug");
|
|
44
|
+
const string_1 = require("../../util/string");
|
|
44
45
|
const rect_1 = require("../../lib/rect");
|
|
45
46
|
const padded_1 = require("../../mixin/padded");
|
|
46
47
|
const noEscape_1 = require("../../mixin/noEscape");
|
|
@@ -74,7 +75,7 @@ let LinkBaseToken = (() => {
|
|
|
74
75
|
#title;
|
|
75
76
|
/** full link / 完整链接 */
|
|
76
77
|
get link() {
|
|
77
|
-
|
|
78
|
+
return this.#title;
|
|
78
79
|
}
|
|
79
80
|
/**
|
|
80
81
|
* @param link 链接标题
|
|
@@ -130,7 +131,18 @@ let LinkBaseToken = (() => {
|
|
|
130
131
|
}
|
|
131
132
|
/** @private */
|
|
132
133
|
text() {
|
|
133
|
-
const
|
|
134
|
+
const { length, firstChild, childNodes, type, } = this, target = firstChild.text();
|
|
135
|
+
let str;
|
|
136
|
+
if (length === 1) {
|
|
137
|
+
str =
|
|
138
|
+
type === 'link' ?
|
|
139
|
+
(0, string_1.trimStart)(target) :
|
|
140
|
+
target.trim();
|
|
141
|
+
}
|
|
142
|
+
else {
|
|
143
|
+
str = `${target.trim()}|${(0, string_1.text)(childNodes.slice(1)
|
|
144
|
+
.filter(({ type: t, name }) => t !== 'image-parameter' || name !== 'invalid'), '|')}`;
|
|
145
|
+
}
|
|
134
146
|
if (this.#bracket) {
|
|
135
147
|
return `[[${str}]]`;
|
|
136
148
|
}
|
|
@@ -7,6 +7,8 @@ import type { Token, AtomToken, AttributesToken, ExtToken } from '../../internal
|
|
|
7
7
|
* @classdesc `{childNodes: [AtomToken]}`
|
|
8
8
|
*/
|
|
9
9
|
export declare abstract class CategorytreeToken extends LinkBaseToken {
|
|
10
|
+
#private;
|
|
11
|
+
readonly name: 'categorytree';
|
|
10
12
|
readonly childNodes: readonly [AtomToken];
|
|
11
13
|
abstract get lastChild(): AtomToken;
|
|
12
14
|
abstract get nextSibling(): undefined;
|
|
@@ -80,15 +80,18 @@ let CategorytreeToken = (() => {
|
|
|
80
80
|
lint(start = this.getAbsoluteIndex()) {
|
|
81
81
|
LINT: {
|
|
82
82
|
const rule = 'no-ignored', s = index_1.default.lintConfig.getSeverity(rule, 'categorytree');
|
|
83
|
-
if (s) {
|
|
84
|
-
|
|
85
|
-
if (!link.valid || link.ns !== 14) {
|
|
86
|
-
return [(0, lint_1.generateForSelf)(this, { start }, rule, 'invalid-category', s)];
|
|
87
|
-
}
|
|
83
|
+
if (s && this.#lint()) {
|
|
84
|
+
return [(0, lint_1.generateForSelf)(this, { start }, rule, 'invalid-category', s)];
|
|
88
85
|
}
|
|
89
86
|
return super.lint(start, false);
|
|
90
87
|
}
|
|
91
88
|
}
|
|
89
|
+
/** 无效的分类名 */
|
|
90
|
+
#lint() {
|
|
91
|
+
const { link } = this;
|
|
92
|
+
return !link.valid
|
|
93
|
+
|| link.ns !== 14;
|
|
94
|
+
}
|
|
92
95
|
};
|
|
93
96
|
return CategorytreeToken = _classThis;
|
|
94
97
|
})();
|
package/dist/src/link/file.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { LinkBaseToken } from './base';
|
|
2
2
|
import { ImageParameterToken } from '../imageParameter';
|
|
3
|
-
import type {
|
|
3
|
+
import type { Config, LintError } from '../../base';
|
|
4
|
+
import type { GalleryImageTypes } from '../imageParameter';
|
|
4
5
|
import type { Token, AtomToken } from '../../internal';
|
|
5
6
|
/**
|
|
6
7
|
* image
|
|
@@ -11,7 +12,7 @@ import type { Token, AtomToken } from '../../internal';
|
|
|
11
12
|
export declare abstract class FileToken extends LinkBaseToken {
|
|
12
13
|
readonly childNodes: readonly [AtomToken, ...ImageParameterToken[]];
|
|
13
14
|
abstract get lastChild(): AtomToken | ImageParameterToken;
|
|
14
|
-
get type(): 'file' |
|
|
15
|
+
get type(): 'file' | GalleryImageTypes;
|
|
15
16
|
/**
|
|
16
17
|
* file extension
|
|
17
18
|
*
|
|
@@ -23,9 +24,9 @@ export declare abstract class FileToken extends LinkBaseToken {
|
|
|
23
24
|
* @param link 文件名
|
|
24
25
|
* @param text 图片参数
|
|
25
26
|
* @param delimiter `|`
|
|
26
|
-
* @param type
|
|
27
|
+
* @param type 图库节点类型
|
|
27
28
|
*/
|
|
28
|
-
constructor(link: string, text?: string, config?: Config, accum?: Token[], delimiter?: string, type?:
|
|
29
|
+
constructor(link: string, text?: string, config?: Config, accum?: Token[], delimiter?: string, type?: GalleryImageTypes);
|
|
29
30
|
/**
|
|
30
31
|
* Get all image parameter tokens
|
|
31
32
|
*
|
package/dist/src/link/file.js
CHANGED
|
@@ -69,7 +69,7 @@ class FileToken extends base_1.LinkBaseToken {
|
|
|
69
69
|
* @param link 文件名
|
|
70
70
|
* @param text 图片参数
|
|
71
71
|
* @param delimiter `|`
|
|
72
|
-
* @param type
|
|
72
|
+
* @param type 图库节点类型
|
|
73
73
|
*/
|
|
74
74
|
constructor(link, text, config, accum = [], delimiter = '|', type) {
|
|
75
75
|
super(link, undefined, config, accum, delimiter);
|
|
@@ -86,7 +86,7 @@ class FileToken extends base_1.LinkBaseToken {
|
|
|
86
86
|
if (s
|
|
87
87
|
&& constants_1.extensions.has(extension)
|
|
88
88
|
&& this.isInside('ext-link-text')
|
|
89
|
-
&& this.getValue('link')
|
|
89
|
+
&& this.getValue('link') !== '') {
|
|
90
90
|
const e = (0, lint_1.generateForSelf)(this, rect, rule, 'link-in-extlink', s);
|
|
91
91
|
if (computeEditInfo || fix) {
|
|
92
92
|
const link = this.getArg('link');
|
|
@@ -146,18 +146,24 @@ class FileToken extends base_1.LinkBaseToken {
|
|
|
146
146
|
* @param p1 替换$1
|
|
147
147
|
* @param severity 错误等级
|
|
148
148
|
*/
|
|
149
|
-
const generate = (tokens, msg, p1, severity = true) =>
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
149
|
+
const generate = (tokens, msg, p1, severity = true) => {
|
|
150
|
+
const duplication = Array.from({ length: tokens.length });
|
|
151
|
+
for (let i = tokens.length - 1; i >= 0; i--) {
|
|
152
|
+
const arg = tokens[i];
|
|
153
|
+
s = severities[Number(typeof severity === 'function' ? severity(arg) : severity)];
|
|
154
|
+
if (!s) {
|
|
155
|
+
duplication[i] = false;
|
|
156
|
+
continue;
|
|
157
|
+
}
|
|
158
|
+
/** `conflicting-image-parameter`或`duplicate-image-parameter` */
|
|
159
|
+
const e = (0, lint_1.generateForChild)(arg, rect, rule, index_1.default.msg(`${msg}-image-parameter`, p1), s);
|
|
160
|
+
if (computeEditInfo) {
|
|
161
|
+
e.suggestions = [(0, lint_1.fixByRemove)(e, -1)];
|
|
162
|
+
}
|
|
163
|
+
duplication[i] = e;
|
|
158
164
|
}
|
|
159
|
-
return e;
|
|
160
|
-
}
|
|
165
|
+
return duplication.filter((e) => e !== false);
|
|
166
|
+
};
|
|
161
167
|
for (const key of keys) {
|
|
162
168
|
if (key === 'invalid' || key === 'width' && unscaled) {
|
|
163
169
|
continue;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { MultiLineToken } from './index';
|
|
2
|
+
import { CharinsertLineToken } from '../singleLine/charinsertLine';
|
|
3
|
+
import type { Config, LintError } from '../../base';
|
|
4
|
+
import type { Token } from '../../internal';
|
|
5
|
+
/**
|
|
6
|
+
* `<charinsert>`
|
|
7
|
+
* @classdesc `{childNodes: CharinsertLineToken[]}`
|
|
8
|
+
*/
|
|
9
|
+
export declare abstract class CharinsertToken extends MultiLineToken {
|
|
10
|
+
readonly name: 'charinsert';
|
|
11
|
+
readonly childNodes: readonly CharinsertLineToken[];
|
|
12
|
+
abstract get firstChild(): CharinsertLineToken | undefined;
|
|
13
|
+
abstract get lastChild(): CharinsertLineToken | undefined;
|
|
14
|
+
/** @class */
|
|
15
|
+
constructor(wikitext: string | undefined, config: Config, accum?: Token[]);
|
|
16
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.CharinsertToken = void 0;
|
|
7
|
+
const common_1 = require("@bhsd/common");
|
|
8
|
+
const lint_1 = require("../../util/lint");
|
|
9
|
+
const rect_1 = require("../../lib/rect");
|
|
10
|
+
const index_1 = __importDefault(require("../../index"));
|
|
11
|
+
const index_2 = require("./index");
|
|
12
|
+
const charinsertLine_1 = require("../singleLine/charinsertLine");
|
|
13
|
+
/* NOT FOR BROWSER ONLY */
|
|
14
|
+
const string_1 = require("../../util/string");
|
|
15
|
+
/* NOT FOR BROWSER ONLY END */
|
|
16
|
+
/**
|
|
17
|
+
* `<charinsert>`
|
|
18
|
+
* @classdesc `{childNodes: CharinsertLineToken[]}`
|
|
19
|
+
*/
|
|
20
|
+
class CharinsertToken extends index_2.MultiLineToken {
|
|
21
|
+
/** @class */
|
|
22
|
+
constructor(wikitext, config, accum = []) {
|
|
23
|
+
super(undefined, config, accum, {});
|
|
24
|
+
if (wikitext) {
|
|
25
|
+
this.safeAppend(wikitext.split('\n')
|
|
26
|
+
// @ts-expect-error abstract class
|
|
27
|
+
.map((line) => new charinsertLine_1.CharinsertLineToken(line, config, accum)));
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
/** @private */
|
|
31
|
+
lint(start = this.getAbsoluteIndex()) {
|
|
32
|
+
LINT: {
|
|
33
|
+
const { name, childNodes } = this, rule = 'no-ignored', { lintConfig } = index_1.default, { computeEditInfo } = lintConfig, s = lintConfig.getSeverity(rule, name);
|
|
34
|
+
if (!s) {
|
|
35
|
+
return [];
|
|
36
|
+
}
|
|
37
|
+
const rect = new rect_1.BoundingRect(this, start), msg = index_1.default.msg('invalid-space', name), trailing = [];
|
|
38
|
+
let errors = super.lint(start), begin = false;
|
|
39
|
+
for (const child of childNodes) {
|
|
40
|
+
const str = String(child), trimmed = str.trim();
|
|
41
|
+
if (trimmed) {
|
|
42
|
+
if (begin) {
|
|
43
|
+
const n = (0, common_1.numLeadingSpaces)(str);
|
|
44
|
+
if (n) {
|
|
45
|
+
const e = (0, lint_1.generateForChild)(child, rect, rule, msg, s);
|
|
46
|
+
e.endIndex = e.startIndex + n;
|
|
47
|
+
e.endCol = e.startCol + n;
|
|
48
|
+
if (computeEditInfo) {
|
|
49
|
+
e.fix = (0, lint_1.fixByRemove)(e);
|
|
50
|
+
}
|
|
51
|
+
errors.push(e);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
begin = true;
|
|
56
|
+
}
|
|
57
|
+
if (trailing.length > 0) {
|
|
58
|
+
errors = [...errors, ...trailing];
|
|
59
|
+
trailing.length = 0;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
if (begin) {
|
|
63
|
+
const [, { length }] = /(?:^|\S)(\s*)$/u.exec(str);
|
|
64
|
+
if (length) {
|
|
65
|
+
const e = (0, lint_1.generateForChild)(child, rect, rule, msg, s);
|
|
66
|
+
e.startIndex = e.endIndex - length;
|
|
67
|
+
e.startCol = e.endCol - length;
|
|
68
|
+
if (computeEditInfo) {
|
|
69
|
+
e.fix = (0, lint_1.fixByRemove)(e);
|
|
70
|
+
}
|
|
71
|
+
trailing.push(e);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return errors;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
/* NOT FOR BROWSER ONLY */
|
|
79
|
+
/** @private */
|
|
80
|
+
text() {
|
|
81
|
+
return (0, string_1.text)(this.childNodes, '\n').trim();
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
exports.CharinsertToken = CharinsertToken;
|
|
@@ -48,9 +48,9 @@ class GalleryToken extends index_2.MultiLineToken {
|
|
|
48
48
|
/** @private */
|
|
49
49
|
lint(start = this.getAbsoluteIndex(), re) {
|
|
50
50
|
LINT: {
|
|
51
|
-
const { top, left } = this.getRootNode().posFromIndex(start), errors = [], rule = 'no-ignored', { lintConfig } = index_1.default, s = ['Image', 'NoImage', 'Comment'].map(k => lintConfig.getSeverity(rule, `gallery${k}`));
|
|
52
|
-
for (let i = 0; i <
|
|
53
|
-
const child =
|
|
51
|
+
const { length: l, childNodes, name } = this, { top, left } = this.getRootNode().posFromIndex(start), errors = [], message = index_1.default.msg('invalid-content', name), rule = 'no-ignored', { lintConfig } = index_1.default, s = ['Image', 'NoImage', 'Comment'].map(k => lintConfig.getSeverity(rule, `gallery${k}`));
|
|
52
|
+
for (let i = 0; i < l; i++) {
|
|
53
|
+
const child = childNodes[i], str = child.toString(), { length } = str, trimmed = str.trim(), { type } = child, startLine = top + i, startCol = i ? 0 : left;
|
|
54
54
|
child.setAttribute('aIndex', start);
|
|
55
55
|
if (type === 'noinclude' && trimmed && !/^<!--.*-->$/u.test(trimmed)) {
|
|
56
56
|
let [severity] = s;
|
|
@@ -63,7 +63,7 @@ class GalleryToken extends index_2.MultiLineToken {
|
|
|
63
63
|
if (severity) {
|
|
64
64
|
const endIndex = start + length, e = {
|
|
65
65
|
rule,
|
|
66
|
-
message
|
|
66
|
+
message,
|
|
67
67
|
severity,
|
|
68
68
|
startIndex: start,
|
|
69
69
|
endIndex,
|
|
@@ -2,7 +2,7 @@ import Parser from '../../index';
|
|
|
2
2
|
import { MultiLineToken } from './index';
|
|
3
3
|
import { CommentLineToken } from '../nowiki/commentLine';
|
|
4
4
|
import { GalleryImageToken } from '../link/galleryImage';
|
|
5
|
-
import { ImagemapLinkToken } from '../imagemapLink';
|
|
5
|
+
import { ImagemapLinkToken } from '../singleLine/imagemapLink';
|
|
6
6
|
import type { LintError } from '../../base';
|
|
7
7
|
import type { AstText, Token } from '../../internal';
|
|
8
8
|
/**
|
|
@@ -11,7 +11,7 @@ const index_1 = __importDefault(require("../../index"));
|
|
|
11
11
|
const index_2 = require("./index");
|
|
12
12
|
const commentLine_1 = require("../nowiki/commentLine");
|
|
13
13
|
const galleryImage_1 = require("../link/galleryImage");
|
|
14
|
-
const imagemapLink_1 = require("../imagemapLink");
|
|
14
|
+
const imagemapLink_1 = require("../singleLine/imagemapLink");
|
|
15
15
|
/**
|
|
16
16
|
* `<imagemap>`
|
|
17
17
|
* @classdesc `{childNodes: [...CommentLineToken[], GalleryImageToken, ...(CommentLineToken|ImagemapLinkToken|AstText)[]]}`
|
|
@@ -52,8 +52,8 @@ class ImagemapToken extends index_2.MultiLineToken {
|
|
|
52
52
|
continue;
|
|
53
53
|
}
|
|
54
54
|
else if (line.includes('[')) {
|
|
55
|
-
const i = line.indexOf('['), substr = line.slice(i), mtIn = /^\[\[([^|]+)(?:\|([^\]]*))?\]\]
|
|
56
|
-
.exec(
|
|
55
|
+
const i = line.indexOf('['), substr = line.slice(i), trimmedSubstr = substr.trim(), mtIn = /^\[\[([^|]+)(?:\|([^\]]*))?\]\]\w*$/u
|
|
56
|
+
.exec(trimmedSubstr);
|
|
57
57
|
if (mtIn) {
|
|
58
58
|
if (this.normalizeTitle(mtIn[1], 0, { halfParsed: true, temporary: true, selfLink: true, page: '' }).valid) {
|
|
59
59
|
// @ts-expect-error abstract class
|
|
@@ -64,8 +64,8 @@ class ImagemapToken extends index_2.MultiLineToken {
|
|
|
64
64
|
else if (substr.startsWith('[//')
|
|
65
65
|
|| protocols.has(substr.slice(1, substr.indexOf(':') + 1))
|
|
66
66
|
|| protocols.has(substr.slice(1, substr.indexOf('//') + 2))) {
|
|
67
|
-
const mtEx = /^\[([^\]\s]+)(?:(\s+(?!\s))([^\]]*))?\]
|
|
68
|
-
.exec(
|
|
67
|
+
const mtEx = /^\[([^\]\s]+)(?:(\s+(?!\s))([^\]]*))?\]\w*$/u
|
|
68
|
+
.exec(trimmedSubstr);
|
|
69
69
|
if (mtEx) {
|
|
70
70
|
// @ts-expect-error abstract class
|
|
71
71
|
super.insertAt(new imagemapLink_1.ImagemapLinkToken(line.slice(0, i), mtEx.slice(1), substr.slice(substr.indexOf(']') + 1), config, accum));
|
|
@@ -80,7 +80,7 @@ class ImagemapToken extends index_2.MultiLineToken {
|
|
|
80
80
|
/** @private */
|
|
81
81
|
lint(start = this.getAbsoluteIndex(), re) {
|
|
82
82
|
LINT: {
|
|
83
|
-
const errors = super.lint(start, re), rect = new rect_1.BoundingRect(this, start), { childNodes, image } = this, rule = 'invalid-imagemap', { lintConfig } = index_1.default, s = lintConfig.getSeverity(rule, image ? 'link' : 'image');
|
|
83
|
+
const errors = super.lint(start, re), rect = new rect_1.BoundingRect(this, start), { childNodes, image } = this, rule = 'invalid-imagemap', { lintConfig } = index_1.default, { computeEditInfo } = lintConfig, s = lintConfig.getSeverity(rule, image ? 'link' : 'image');
|
|
84
84
|
if (s) {
|
|
85
85
|
if (image) {
|
|
86
86
|
Array.prototype.push.apply(errors, childNodes.filter(child => {
|
|
@@ -89,7 +89,7 @@ class ImagemapToken extends index_2.MultiLineToken {
|
|
|
89
89
|
&& str && !str.startsWith('#');
|
|
90
90
|
}).map(child => {
|
|
91
91
|
const e = (0, lint_1.generateForChild)(child, rect, rule, 'invalid-imagemap-link', s);
|
|
92
|
-
if (
|
|
92
|
+
if (computeEditInfo) {
|
|
93
93
|
e.suggestions = [
|
|
94
94
|
(0, lint_1.fixByRemove)(e, -1),
|
|
95
95
|
(0, lint_1.fixBy)(e, 'comment', '# '),
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import Parser from '../../index';
|
|
1
2
|
import { Token } from '../index';
|
|
2
3
|
import type { AttributesToken, ExtToken } from '../../internal';
|
|
3
4
|
/**
|
|
@@ -11,4 +12,6 @@ export declare abstract class MultiLineToken extends Token {
|
|
|
11
12
|
abstract get previousSibling(): AttributesToken | undefined;
|
|
12
13
|
abstract get parentNode(): ExtToken | undefined;
|
|
13
14
|
get type(): 'ext-inner';
|
|
15
|
+
/** @class */
|
|
16
|
+
constructor(wikitext?: string, config?: Parser.Config, accum?: Token[], acceptable?: WikiParserAcceptable);
|
|
14
17
|
}
|
|
@@ -1,27 +1,88 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
|
3
|
+
function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
|
|
4
|
+
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
|
5
|
+
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
|
|
6
|
+
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
|
|
7
|
+
var _, done = false;
|
|
8
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
9
|
+
var context = {};
|
|
10
|
+
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
|
|
11
|
+
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
|
|
12
|
+
context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
|
|
13
|
+
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
|
|
14
|
+
if (kind === "accessor") {
|
|
15
|
+
if (result === void 0) continue;
|
|
16
|
+
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
|
|
17
|
+
if (_ = accept(result.get)) descriptor.get = _;
|
|
18
|
+
if (_ = accept(result.set)) descriptor.set = _;
|
|
19
|
+
if (_ = accept(result.init)) initializers.unshift(_);
|
|
20
|
+
}
|
|
21
|
+
else if (_ = accept(result)) {
|
|
22
|
+
if (kind === "field") initializers.unshift(_);
|
|
23
|
+
else descriptor[key] = _;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
27
|
+
done = true;
|
|
28
|
+
};
|
|
29
|
+
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
|
|
30
|
+
var useValue = arguments.length > 2;
|
|
31
|
+
for (var i = 0; i < initializers.length; i++) {
|
|
32
|
+
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
|
33
|
+
}
|
|
34
|
+
return useValue ? value : void 0;
|
|
35
|
+
};
|
|
36
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
37
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
38
|
+
};
|
|
2
39
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
40
|
exports.MultiLineToken = void 0;
|
|
4
|
-
const
|
|
41
|
+
const gapped_1 = require("../../mixin/gapped");
|
|
42
|
+
const index_1 = __importDefault(require("../../index"));
|
|
43
|
+
const index_2 = require("../index");
|
|
44
|
+
const index_3 = require("../singleLine/index");
|
|
5
45
|
/**
|
|
6
46
|
* extension tag that is parsed line by line
|
|
7
47
|
*
|
|
8
48
|
* 逐行解析的扩展标签
|
|
9
49
|
*/
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
50
|
+
let MultiLineToken = (() => {
|
|
51
|
+
let _classDecorators = [(0, gapped_1.gapped)()];
|
|
52
|
+
let _classDescriptor;
|
|
53
|
+
let _classExtraInitializers = [];
|
|
54
|
+
let _classThis;
|
|
55
|
+
let _classSuper = index_2.Token;
|
|
56
|
+
var MultiLineToken = class extends _classSuper {
|
|
57
|
+
static { _classThis = this; }
|
|
58
|
+
static {
|
|
59
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
60
|
+
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
61
|
+
MultiLineToken = _classThis = _classDescriptor.value;
|
|
62
|
+
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
63
|
+
__runInitializers(_classThis, _classExtraInitializers);
|
|
64
|
+
}
|
|
65
|
+
get type() {
|
|
66
|
+
return 'ext-inner';
|
|
67
|
+
}
|
|
68
|
+
/** @class */
|
|
69
|
+
constructor(wikitext, config = index_1.default.getConfig(), accum = [], acceptable) {
|
|
70
|
+
super(undefined, config, accum, acceptable);
|
|
71
|
+
if (wikitext) {
|
|
72
|
+
const newConfig = { ...config, excludes: [...config.excludes, 'list'] };
|
|
73
|
+
// @ts-expect-error abstract class
|
|
74
|
+
this.safeAppend(wikitext.split('\n').map(line => new index_3.SingleLineToken(line, newConfig, accum)));
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
/** @private */
|
|
78
|
+
toString(skip) {
|
|
79
|
+
return super.toString(skip, '\n');
|
|
80
|
+
}
|
|
81
|
+
/** @private */
|
|
82
|
+
text() {
|
|
83
|
+
return super.text('\n').replace(/\n\s*\n/gu, '\n');
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
return MultiLineToken = _classThis;
|
|
87
|
+
})();
|
|
27
88
|
exports.MultiLineToken = MultiLineToken;
|
|
@@ -3,6 +3,7 @@ import type { Config } from '../../base';
|
|
|
3
3
|
import type { Token } from '../../internal';
|
|
4
4
|
/** `<inputbox>` */
|
|
5
5
|
export declare abstract class InputboxToken extends ParamTagToken {
|
|
6
|
+
readonly name: 'inputbox';
|
|
6
7
|
/** @param name 扩展标签名 */
|
|
7
8
|
constructor(name: string, include: boolean, wikitext: string | undefined, config: Config, accum?: Token[]);
|
|
8
9
|
}
|
|
@@ -2,6 +2,9 @@ import { MultiLineToken } from './index';
|
|
|
2
2
|
import { ParamLineToken } from '../paramLine';
|
|
3
3
|
import type { Config } from '../../base';
|
|
4
4
|
import type { Token } from '../../internal';
|
|
5
|
+
import type { ParamLineParentBase } from '../../mixin/paramLineParent';
|
|
6
|
+
export interface ParamTagToken extends ParamLineParentBase {
|
|
7
|
+
}
|
|
5
8
|
/**
|
|
6
9
|
* `<dynamicpagelist>`
|
|
7
10
|
* @classdesc `{childNodes: ParamLineToken[]}`
|