wikilint 2.44.0 → 2.46.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 +1 -2
- package/config/enwiki.json +1 -1
- package/config/jawiki.json +1 -1
- package/config/minimum.json +1 -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 +10 -2
- package/dist/base.d.ts +10 -2
- package/dist/bin/config.js +1 -1
- package/dist/index.js +1 -1
- package/dist/internal.d.ts +6 -1
- package/dist/lib/element.js +5 -5
- package/dist/lib/lintConfig.js +7 -0
- package/dist/lib/lsp.d.ts +11 -3
- package/dist/lib/lsp.js +91 -59
- package/dist/lib/node.js +2 -2
- package/dist/lib/text.js +2 -2
- package/dist/map.d.ts +4 -1
- package/dist/mixin/elementLike.js +29 -31
- package/dist/mixin/hidden.js +0 -1
- package/dist/mixin/paramLineParent.d.ts +29 -0
- package/dist/mixin/paramLineParent.js +51 -0
- 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.js +18 -15
- package/dist/src/commented.d.ts +1 -0
- package/dist/src/commented.js +1 -3
- package/dist/src/converterFlags.js +18 -21
- package/dist/src/converterRule.js +2 -2
- 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.js +16 -4
- 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.js +21 -14
- 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 +13 -12
- 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 +23 -25
- package/dist/src/nowiki/quote.js +6 -5
- package/dist/src/paramLine.d.ts +23 -3
- package/dist/src/paramLine.js +129 -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/table/td.js +5 -4
- package/dist/src/tag/html.js +26 -8
- package/dist/src/tag/index.js +30 -17
- package/dist/src/tagPair/ext.js +23 -2
- package/dist/src/tagPair/index.js +1 -10
- package/dist/src/transclude.js +15 -15
- package/dist/util/sharable.js +22 -0
- package/dist/util/sharable.mjs +22 -0
- package/dist/util/string.js +27 -2
- package/i18n/en.json +4 -0
- package/i18n/zh-hans.json +4 -0
- package/i18n/zh-hant.json +4 -0
- package/package.json +17 -25
- package/dist/src/imagemapLink.js +0 -34
- /package/dist/{util → vendor}/search.js +0 -0
|
@@ -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, length: l } = 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), leading = [], errors = super.lint(start);
|
|
38
|
+
let begin = false;
|
|
39
|
+
for (let i = l - 1; i >= 0; i--) {
|
|
40
|
+
const child = childNodes[i], str = child.toString(), trimmed = str.trim();
|
|
41
|
+
if (trimmed) {
|
|
42
|
+
if (begin) {
|
|
43
|
+
const [, { length }] = /(?:^|\S)(\s*)$/u.exec(str);
|
|
44
|
+
if (length) {
|
|
45
|
+
const e = (0, lint_1.generateForChild)(child, rect, rule, msg, s);
|
|
46
|
+
e.startIndex = e.endIndex - length;
|
|
47
|
+
e.startCol = e.endCol - length;
|
|
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 (leading.length > 0) {
|
|
58
|
+
Array.prototype.push.apply(errors, leading);
|
|
59
|
+
leading.length = 0;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
if (begin) {
|
|
63
|
+
const n = (0, common_1.numLeadingSpaces)(str);
|
|
64
|
+
if (n) {
|
|
65
|
+
const e = (0, lint_1.generateForChild)(child, rect, rule, msg, s);
|
|
66
|
+
e.endIndex = e.startIndex + n;
|
|
67
|
+
e.endCol = e.startCol + n;
|
|
68
|
+
if (computeEditInfo) {
|
|
69
|
+
e.fix = (0, lint_1.fixByRemove)(e);
|
|
70
|
+
}
|
|
71
|
+
leading.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,23 +80,24 @@ 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
|
+
const comments = childNodes.filter(child => {
|
|
87
87
|
const str = child.toString().trim();
|
|
88
88
|
return child.is('noinclude')
|
|
89
89
|
&& str && !str.startsWith('#');
|
|
90
|
-
})
|
|
91
|
-
|
|
92
|
-
|
|
90
|
+
});
|
|
91
|
+
for (let i = comments.length - 1; i >= 0; i--) {
|
|
92
|
+
const e = (0, lint_1.generateForChild)(comments[i], rect, rule, 'invalid-imagemap-link', s);
|
|
93
|
+
if (computeEditInfo) {
|
|
93
94
|
e.suggestions = [
|
|
94
95
|
(0, lint_1.fixByRemove)(e, -1),
|
|
95
96
|
(0, lint_1.fixBy)(e, 'comment', '# '),
|
|
96
97
|
];
|
|
97
98
|
}
|
|
98
|
-
|
|
99
|
-
}
|
|
99
|
+
errors.push(e);
|
|
100
|
+
}
|
|
100
101
|
}
|
|
101
102
|
else {
|
|
102
103
|
errors.push((0, lint_1.generateForSelf)(this, rect, rule, 'imagemap-without-image', s));
|
|
@@ -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[]}`
|
|
@@ -1,25 +1,72 @@
|
|
|
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
|
+
};
|
|
2
36
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
37
|
exports.ParamTagToken = void 0;
|
|
4
|
-
const
|
|
38
|
+
const paramLineParent_1 = require("../../mixin/paramLineParent");
|
|
5
39
|
const index_1 = require("./index");
|
|
6
40
|
const paramLine_1 = require("../paramLine");
|
|
7
41
|
/**
|
|
8
42
|
* `<dynamicpagelist>`
|
|
9
43
|
* @classdesc `{childNodes: ParamLineToken[]}`
|
|
10
44
|
*/
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
45
|
+
let ParamTagToken = (() => {
|
|
46
|
+
let _classDecorators = [paramLineParent_1.paramLineParent];
|
|
47
|
+
let _classDescriptor;
|
|
48
|
+
let _classExtraInitializers = [];
|
|
49
|
+
let _classThis;
|
|
50
|
+
let _classSuper = index_1.MultiLineToken;
|
|
51
|
+
var ParamTagToken = class extends _classSuper {
|
|
52
|
+
static { _classThis = this; }
|
|
53
|
+
static {
|
|
54
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
55
|
+
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
56
|
+
ParamTagToken = _classThis = _classDescriptor.value;
|
|
57
|
+
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
58
|
+
__runInitializers(_classThis, _classExtraInitializers);
|
|
59
|
+
}
|
|
60
|
+
/** @param name 扩展标签名 */
|
|
61
|
+
constructor(name, include, wikitext, config, accum = [], acceptable) {
|
|
62
|
+
super(undefined, config, accum, {});
|
|
63
|
+
if (wikitext) {
|
|
64
|
+
this.safeAppend(
|
|
18
65
|
// @ts-expect-error abstract class
|
|
19
|
-
.map((line) => new paramLine_1.ParamLineToken(name, line, config, accum
|
|
66
|
+
wikitext.split('\n').map((line) => new paramLine_1.ParamLineToken(name, line, config, accum)));
|
|
67
|
+
}
|
|
20
68
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
69
|
+
};
|
|
70
|
+
return ParamTagToken = _classThis;
|
|
71
|
+
})();
|
|
25
72
|
exports.ParamTagToken = ParamTagToken;
|
package/dist/src/nested.js
CHANGED
|
@@ -60,34 +60,32 @@ class NestedToken extends index_2.Token {
|
|
|
60
60
|
/** @private */
|
|
61
61
|
lint(start = this.getAbsoluteIndex(), re) {
|
|
62
62
|
LINT: {
|
|
63
|
-
const errors = super.lint(start, re), rule = 'no-ignored', { lintConfig } = index_1.default, s = lintConfig.getSeverity(rule,
|
|
63
|
+
const errors = super.lint(start, re), rule = 'no-ignored', { lintConfig } = index_1.default, { computeEditInfo } = lintConfig, { name, childNodes } = this, s = lintConfig.getSeverity(rule, name);
|
|
64
64
|
if (!s) {
|
|
65
65
|
return errors;
|
|
66
66
|
}
|
|
67
|
-
const rect = new rect_1.BoundingRect(this, start), regex = typeof this.#regex === 'boolean' ? lintRegex[this.#regex ? 1 : 0] : /^<!--[\s\S]*-->$/u
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
e.
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
}),
|
|
90
|
-
];
|
|
67
|
+
const rect = new rect_1.BoundingRect(this, start), msg = index_1.default.msg('invalid-content', name), regex = typeof this.#regex === 'boolean' ? lintRegex[this.#regex ? 1 : 0] : /^<!--[\s\S]*-->$/u, ignored = childNodes.filter(child => {
|
|
68
|
+
const { type, name: n } = child;
|
|
69
|
+
if (type === 'ext') {
|
|
70
|
+
return !this.#tags.includes(n);
|
|
71
|
+
}
|
|
72
|
+
else if (childTypes.has(type)) {
|
|
73
|
+
return false;
|
|
74
|
+
}
|
|
75
|
+
const str = child.toString().trim();
|
|
76
|
+
return str && !regex.test(str);
|
|
77
|
+
}), { length } = ignored, ignoredErrors = Array.from({ length });
|
|
78
|
+
for (let i = length - 1; i >= 0; i--) {
|
|
79
|
+
const child = ignored[i], e = (0, lint_1.generateForChild)(child, rect, rule, msg, s);
|
|
80
|
+
if (computeEditInfo) {
|
|
81
|
+
e.suggestions = [
|
|
82
|
+
(0, lint_1.fixByRemove)(e),
|
|
83
|
+
(0, lint_1.fixByComment)(e, child.toString()),
|
|
84
|
+
];
|
|
85
|
+
}
|
|
86
|
+
ignoredErrors[i] = e;
|
|
87
|
+
}
|
|
88
|
+
return [...errors, ...ignoredErrors];
|
|
91
89
|
}
|
|
92
90
|
}
|
|
93
91
|
}
|
package/dist/src/nowiki/quote.js
CHANGED
|
@@ -44,11 +44,6 @@ class QuoteToken extends base_1.NowikiBaseToken {
|
|
|
44
44
|
this.#closing = closing;
|
|
45
45
|
}
|
|
46
46
|
/** @private */
|
|
47
|
-
text() {
|
|
48
|
-
const { parentNode, innerText } = this;
|
|
49
|
-
return parentNode?.is('image-parameter') && parentNode.name !== 'caption' ? '' : innerText;
|
|
50
|
-
}
|
|
51
|
-
/** @private */
|
|
52
47
|
lint(start = this.getAbsoluteIndex()) {
|
|
53
48
|
LINT: {
|
|
54
49
|
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]);
|
|
@@ -82,5 +77,11 @@ class QuoteToken extends base_1.NowikiBaseToken {
|
|
|
82
77
|
return errors;
|
|
83
78
|
}
|
|
84
79
|
}
|
|
80
|
+
/* NOT FOR BROWSER ONLY */
|
|
81
|
+
/** @private */
|
|
82
|
+
text() {
|
|
83
|
+
const { parentNode, innerText } = this;
|
|
84
|
+
return parentNode?.is('image-parameter') && parentNode.name !== 'caption' ? '' : innerText;
|
|
85
|
+
}
|
|
85
86
|
}
|
|
86
87
|
exports.QuoteToken = QuoteToken;
|
package/dist/src/paramLine.d.ts
CHANGED
|
@@ -1,16 +1,36 @@
|
|
|
1
1
|
import { Token } from './index';
|
|
2
|
+
import { AtomToken } from './atom';
|
|
2
3
|
import type { Config, LintError } from '../base';
|
|
3
|
-
import type { ParamTagToken } from '../internal';
|
|
4
|
+
import type { ParamTagToken, FuncTagToken } from '../internal';
|
|
4
5
|
/**
|
|
5
6
|
* parameter of certain extension tags
|
|
6
7
|
*
|
|
7
8
|
* 某些扩展标签的参数
|
|
9
|
+
* @classdesc `{childNodes: [AtomToken] | [AtomToken, AtomToken]}`
|
|
8
10
|
*/
|
|
9
11
|
export declare abstract class ParamLineToken extends Token {
|
|
10
|
-
|
|
12
|
+
readonly name: string;
|
|
13
|
+
readonly childNodes: readonly [AtomToken] | readonly [AtomToken, AtomToken];
|
|
14
|
+
abstract get firstChild(): AtomToken;
|
|
15
|
+
abstract get lastChild(): AtomToken;
|
|
16
|
+
abstract get parentNode(): ParamTagToken | FuncTagToken | undefined;
|
|
11
17
|
abstract get nextSibling(): this | undefined;
|
|
12
18
|
abstract get previousSibling(): this | undefined;
|
|
13
19
|
get type(): 'param-line';
|
|
20
|
+
/**
|
|
21
|
+
* A reasonable parameter name
|
|
22
|
+
*
|
|
23
|
+
* 合理的参数名
|
|
24
|
+
* @since v1.45.0
|
|
25
|
+
*/
|
|
26
|
+
get key(): string | undefined;
|
|
14
27
|
/** @param name 扩展标签名 */
|
|
15
|
-
constructor(name: string, wikitext: string
|
|
28
|
+
constructor(name: string, wikitext: string, config: Config, accum: Token[], acceptable?: WikiParserAcceptable);
|
|
29
|
+
/**
|
|
30
|
+
* Get a reasonable parameter name
|
|
31
|
+
*
|
|
32
|
+
* 获取合理的参数名
|
|
33
|
+
* @since v1.45.0
|
|
34
|
+
*/
|
|
35
|
+
getKey(): string | undefined;
|
|
16
36
|
}
|