wikilint 2.16.3 → 2.16.5
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/coverage/badge.svg +1 -1
- package/data/signatures.json +43 -0
- package/dist/base.d.mts +84 -27
- package/dist/base.d.ts +84 -27
- package/dist/bin/cli.js +2 -1
- package/dist/index.d.ts +8 -4
- package/dist/index.js +55 -11
- package/dist/lib/element.d.ts +56 -10
- package/dist/lib/element.js +97 -11
- package/dist/lib/lsp.d.ts +62 -27
- package/dist/lib/lsp.js +395 -304
- package/dist/lib/node.d.ts +51 -19
- package/dist/lib/node.js +80 -34
- package/dist/lib/text.d.ts +8 -2
- package/dist/lib/text.js +10 -3
- package/dist/lib/title.d.ts +23 -9
- package/dist/lib/title.js +56 -21
- package/dist/mixin/attributesParent.d.ts +4 -4
- package/dist/mixin/attributesParent.js +2 -4
- package/dist/mixin/hidden.d.ts +0 -2
- package/dist/mixin/hidden.js +0 -2
- package/dist/parser/braces.js +4 -2
- package/dist/parser/links.js +8 -7
- package/dist/parser/list.js +3 -1
- package/dist/parser/quotes.js +2 -1
- package/dist/parser/redirect.js +4 -1
- package/dist/src/arg.d.ts +4 -2
- package/dist/src/arg.js +8 -4
- package/dist/src/atom.d.ts +5 -1
- package/dist/src/atom.js +5 -1
- package/dist/src/attribute.d.ts +9 -3
- package/dist/src/attribute.js +9 -3
- package/dist/src/attributes.d.ts +12 -4
- package/dist/src/attributes.js +12 -4
- package/dist/src/converter.d.ts +3 -1
- package/dist/src/converter.js +8 -5
- package/dist/src/converterFlags.d.ts +13 -3
- package/dist/src/converterFlags.js +13 -3
- package/dist/src/converterRule.d.ts +3 -1
- package/dist/src/converterRule.js +3 -1
- package/dist/src/extLink.d.ts +2 -0
- package/dist/src/extLink.js +2 -0
- package/dist/src/gallery.d.ts +3 -1
- package/dist/src/gallery.js +7 -5
- package/dist/src/heading.d.ts +3 -1
- package/dist/src/heading.js +10 -8
- package/dist/src/hidden.d.ts +5 -1
- package/dist/src/hidden.js +5 -1
- package/dist/src/html.d.ts +9 -2
- package/dist/src/html.js +201 -146
- package/dist/src/imageParameter.d.ts +11 -3
- package/dist/src/imageParameter.js +12 -4
- package/dist/src/imagemap.d.ts +1 -1
- package/dist/src/imagemap.js +5 -4
- package/dist/src/imagemapLink.d.ts +2 -0
- package/dist/src/imagemapLink.js +2 -0
- package/dist/src/index.d.ts +5 -24
- package/dist/src/index.js +28 -73
- package/dist/src/link/base.d.ts +5 -1
- package/dist/src/link/base.js +17 -7
- package/dist/src/link/category.d.ts +4 -0
- package/dist/src/link/category.js +2 -0
- package/dist/src/link/file.d.ts +17 -7
- package/dist/src/link/file.js +28 -14
- package/dist/src/link/galleryImage.d.ts +5 -1
- package/dist/src/link/galleryImage.js +9 -5
- package/dist/src/link/index.d.ts +4 -0
- package/dist/src/link/index.js +2 -0
- package/dist/src/link/redirectTarget.d.ts +3 -1
- package/dist/src/link/redirectTarget.js +4 -2
- package/dist/src/magicLink.d.ts +12 -3
- package/dist/src/magicLink.js +36 -7
- package/dist/src/nested.d.ts +3 -1
- package/dist/src/nested.js +7 -4
- package/dist/src/nowiki/base.d.ts +3 -1
- package/dist/src/nowiki/base.js +3 -1
- package/dist/src/nowiki/comment.d.ts +5 -1
- package/dist/src/nowiki/comment.js +5 -1
- package/dist/src/nowiki/doubleUnderscore.d.ts +5 -1
- package/dist/src/nowiki/doubleUnderscore.js +5 -1
- package/dist/src/nowiki/index.d.ts +5 -1
- package/dist/src/nowiki/index.js +5 -1
- package/dist/src/nowiki/list.d.ts +5 -1
- package/dist/src/nowiki/list.js +5 -1
- package/dist/src/nowiki/noinclude.d.ts +5 -1
- package/dist/src/nowiki/noinclude.js +5 -1
- package/dist/src/nowiki/quote.d.ts +5 -1
- package/dist/src/nowiki/quote.js +5 -1
- package/dist/src/onlyinclude.d.ts +3 -1
- package/dist/src/onlyinclude.js +3 -1
- package/dist/src/paramTag/index.d.ts +1 -1
- package/dist/src/paramTag/index.js +1 -1
- package/dist/src/parameter.d.ts +3 -1
- package/dist/src/parameter.js +3 -1
- package/dist/src/pre.d.ts +1 -1
- package/dist/src/pre.js +1 -1
- package/dist/src/redirect.d.ts +2 -0
- package/dist/src/redirect.js +2 -0
- package/dist/src/syntax.d.ts +5 -1
- package/dist/src/syntax.js +5 -1
- package/dist/src/table/base.js +3 -1
- package/dist/src/table/index.d.ts +20 -15
- package/dist/src/table/index.js +22 -23
- package/dist/src/table/td.d.ts +9 -3
- package/dist/src/table/td.js +9 -3
- package/dist/src/table/tr.d.ts +3 -1
- package/dist/src/table/tr.js +4 -2
- package/dist/src/table/trBase.d.ts +9 -9
- package/dist/src/table/trBase.js +13 -18
- package/dist/src/tagPair/ext.d.ts +6 -1
- package/dist/src/tagPair/ext.js +151 -98
- package/dist/src/tagPair/include.d.ts +2 -0
- package/dist/src/tagPair/include.js +2 -0
- package/dist/src/tagPair/index.d.ts +6 -2
- package/dist/src/tagPair/index.js +6 -2
- package/dist/src/transclude.d.ts +39 -10
- package/dist/src/transclude.js +69 -18
- package/dist/util/debug.js +2 -16
- package/dist/util/string.js +2 -0
- package/i18n/zh-hans.json +1 -1
- package/i18n/zh-hant.json +1 -1
- package/package.json +3 -2
- package/dist/bin/coverage.js +0 -20
package/dist/src/table/td.d.ts
CHANGED
|
@@ -10,7 +10,9 @@ export interface TdSpanAttrs {
|
|
|
10
10
|
}
|
|
11
11
|
declare type TdAttrGetter<T extends string> = T extends keyof TdSpanAttrs ? number : string | true | undefined;
|
|
12
12
|
/**
|
|
13
|
-
* `<td
|
|
13
|
+
* `<td>`, `<th>` or `<caption>`
|
|
14
|
+
*
|
|
15
|
+
* `<td>`、`<th>`或`<caption>`
|
|
14
16
|
* @classdesc `{childNodes: [SyntaxToken, AttributesToken, Token]}`
|
|
15
17
|
*/
|
|
16
18
|
export declare abstract class TdToken extends TableBaseToken {
|
|
@@ -24,14 +26,18 @@ export declare abstract class TdToken extends TableBaseToken {
|
|
|
24
26
|
get rowspan(): number;
|
|
25
27
|
/** colspan */
|
|
26
28
|
get colspan(): number;
|
|
27
|
-
/** 单元格类型 */
|
|
29
|
+
/** cell type / 单元格类型 */
|
|
28
30
|
get subtype(): TdSubtypes;
|
|
29
31
|
/**
|
|
30
32
|
* @param syntax 单元格语法
|
|
31
33
|
* @param inner 内部wikitext
|
|
32
34
|
*/
|
|
33
35
|
constructor(syntax: string, inner?: string, config?: Parser.Config, accum?: Token[]);
|
|
34
|
-
/**
|
|
36
|
+
/**
|
|
37
|
+
* Check if the cell is at the beginning of a line
|
|
38
|
+
*
|
|
39
|
+
* 是否位于行首
|
|
40
|
+
*/
|
|
35
41
|
isIndependent(): boolean;
|
|
36
42
|
getAttr<T extends string>(key: T): TdAttrGetter<T>;
|
|
37
43
|
}
|
package/dist/src/table/td.js
CHANGED
|
@@ -8,7 +8,9 @@ const index_1 = require("../../index");
|
|
|
8
8
|
const index_2 = require("../index");
|
|
9
9
|
const base_1 = require("./base");
|
|
10
10
|
/**
|
|
11
|
-
* `<td
|
|
11
|
+
* `<td>`, `<th>` or `<caption>`
|
|
12
|
+
*
|
|
13
|
+
* `<td>`、`<th>`或`<caption>`
|
|
12
14
|
* @classdesc `{childNodes: [SyntaxToken, AttributesToken, Token]}`
|
|
13
15
|
*/
|
|
14
16
|
class TdToken extends base_1.TableBaseToken {
|
|
@@ -25,7 +27,7 @@ class TdToken extends base_1.TableBaseToken {
|
|
|
25
27
|
get colspan() {
|
|
26
28
|
return this.getAttr('colspan');
|
|
27
29
|
}
|
|
28
|
-
/** 单元格类型 */
|
|
30
|
+
/** cell type / 单元格类型 */
|
|
29
31
|
get subtype() {
|
|
30
32
|
return this.#getSyntax().subtype;
|
|
31
33
|
}
|
|
@@ -126,7 +128,11 @@ class TdToken extends base_1.TableBaseToken {
|
|
|
126
128
|
}
|
|
127
129
|
return errors;
|
|
128
130
|
}
|
|
129
|
-
/**
|
|
131
|
+
/**
|
|
132
|
+
* Check if the cell is at the beginning of a line
|
|
133
|
+
*
|
|
134
|
+
* 是否位于行首
|
|
135
|
+
*/
|
|
130
136
|
isIndependent() {
|
|
131
137
|
return this.firstChild.text().startsWith('\n');
|
|
132
138
|
}
|
package/dist/src/table/tr.d.ts
CHANGED
|
@@ -2,8 +2,10 @@ import { TrBaseToken } from './trBase';
|
|
|
2
2
|
import type { Config } from '../../base';
|
|
3
3
|
import type { Token, TdToken, TableToken, SyntaxToken, AttributesToken } from '../../internal';
|
|
4
4
|
/**
|
|
5
|
+
* table row that contains the newline at the beginning but not at the end
|
|
6
|
+
*
|
|
5
7
|
* 表格行,含开头的换行,不含结尾的换行
|
|
6
|
-
* @classdesc `{childNodes: [SyntaxToken, AttributesToken, ?Token, ...TdToken]}`
|
|
8
|
+
* @classdesc `{childNodes: [SyntaxToken, AttributesToken, ?Token, ...TdToken[]]}`
|
|
7
9
|
*/
|
|
8
10
|
export declare abstract class TrToken extends TrBaseToken {
|
|
9
11
|
readonly childNodes: readonly [SyntaxToken, AttributesToken, ...TdToken[]];
|
package/dist/src/table/tr.js
CHANGED
|
@@ -3,8 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.TrToken = void 0;
|
|
4
4
|
const trBase_1 = require("./trBase");
|
|
5
5
|
/**
|
|
6
|
+
* table row that contains the newline at the beginning but not at the end
|
|
7
|
+
*
|
|
6
8
|
* 表格行,含开头的换行,不含结尾的换行
|
|
7
|
-
* @classdesc `{childNodes: [SyntaxToken, AttributesToken, ?Token, ...TdToken]}`
|
|
9
|
+
* @classdesc `{childNodes: [SyntaxToken, AttributesToken, ?Token, ...TdToken[]]}`
|
|
8
10
|
*/
|
|
9
11
|
class TrToken extends trBase_1.TrBaseToken {
|
|
10
12
|
get type() {
|
|
@@ -15,7 +17,7 @@ class TrToken extends trBase_1.TrBaseToken {
|
|
|
15
17
|
* @param attr 表格属性
|
|
16
18
|
*/
|
|
17
19
|
constructor(syntax, attr, config, accum) {
|
|
18
|
-
super(/^\n[^\S\n]*(?:\|-+|\{\{\s*!\s*\}\}-+|\{\{\s*!-\s*\}\}-*)$/u, syntax, 'tr', attr, config, accum
|
|
20
|
+
super(/^\n[^\S\n]*(?:\|-+|\{\{\s*!\s*\}\}-+|\{\{\s*!-\s*\}\}-*)$/u, syntax, 'tr', attr, config, accum);
|
|
19
21
|
}
|
|
20
22
|
}
|
|
21
23
|
exports.TrToken = TrToken;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { TableBaseToken } from './base';
|
|
2
|
-
import { TdToken } from './td';
|
|
3
2
|
import type { LintError } from '../../base';
|
|
4
3
|
export interface TableCoords {
|
|
5
4
|
readonly row: number;
|
|
@@ -8,16 +7,17 @@ export interface TableCoords {
|
|
|
8
7
|
readonly y?: undefined;
|
|
9
8
|
readonly start?: boolean;
|
|
10
9
|
}
|
|
11
|
-
/**
|
|
10
|
+
/**
|
|
11
|
+
* table row or table
|
|
12
|
+
*
|
|
13
|
+
* 表格行或表格
|
|
14
|
+
*/
|
|
12
15
|
export declare abstract class TrBaseToken extends TableBaseToken {
|
|
13
16
|
abstract get type(): 'table' | 'tr';
|
|
14
|
-
/** 获取行数 */
|
|
15
|
-
getRowCount(): number;
|
|
16
17
|
/**
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
* @throws `RangeError` 不存在对应单元格
|
|
18
|
+
* Get the number of rows
|
|
19
|
+
*
|
|
20
|
+
* 获取行数
|
|
21
21
|
*/
|
|
22
|
-
|
|
22
|
+
getRowCount(): number;
|
|
23
23
|
}
|
package/dist/src/table/trBase.js
CHANGED
|
@@ -4,7 +4,11 @@ exports.TrBaseToken = void 0;
|
|
|
4
4
|
const lint_1 = require("../../util/lint");
|
|
5
5
|
const base_1 = require("./base");
|
|
6
6
|
const td_1 = require("./td");
|
|
7
|
-
/**
|
|
7
|
+
/**
|
|
8
|
+
* table row or table
|
|
9
|
+
*
|
|
10
|
+
* 表格行或表格
|
|
11
|
+
*/
|
|
8
12
|
class TrBaseToken extends base_1.TableBaseToken {
|
|
9
13
|
/** @private */
|
|
10
14
|
lint(start = this.getAbsoluteIndex(), re) {
|
|
@@ -34,24 +38,15 @@ class TrBaseToken extends base_1.TableBaseToken {
|
|
|
34
38
|
errors.push(error);
|
|
35
39
|
return errors;
|
|
36
40
|
}
|
|
37
|
-
/**
|
|
41
|
+
/**
|
|
42
|
+
* Get the number of rows
|
|
43
|
+
*
|
|
44
|
+
* 获取行数
|
|
45
|
+
*/
|
|
38
46
|
getRowCount() {
|
|
39
|
-
return Number(this.childNodes.some(child => child instanceof td_1.TdToken
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
let last = 0;
|
|
43
|
-
for (const child of this.childNodes.slice(2)) {
|
|
44
|
-
if (child instanceof td_1.TdToken) {
|
|
45
|
-
if (child.isIndependent()) {
|
|
46
|
-
last = Number(child.subtype !== 'caption');
|
|
47
|
-
}
|
|
48
|
-
n -= last;
|
|
49
|
-
if (n < 0) {
|
|
50
|
-
return child;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
return undefined;
|
|
47
|
+
return Number(this.childNodes.some(child => child instanceof td_1.TdToken
|
|
48
|
+
&& child.isIndependent()
|
|
49
|
+
&& !child.firstChild.text().endsWith('+')));
|
|
55
50
|
}
|
|
56
51
|
}
|
|
57
52
|
exports.TrBaseToken = TrBaseToken;
|
|
@@ -3,7 +3,12 @@ import { Token } from '../index';
|
|
|
3
3
|
import { TagPairToken } from './index';
|
|
4
4
|
import { AttributesToken } from '../attributes';
|
|
5
5
|
import type { LintError } from '../../base';
|
|
6
|
+
import type { AttributesParentBase } from '../../mixin/attributesParent';
|
|
7
|
+
export interface ExtToken extends AttributesParentBase {
|
|
8
|
+
}
|
|
6
9
|
/**
|
|
10
|
+
* extension tag
|
|
11
|
+
*
|
|
7
12
|
* 扩展标签
|
|
8
13
|
* @classdesc `{childNodes: [AttributesToken, Token]}`
|
|
9
14
|
*/
|
|
@@ -15,10 +20,10 @@ export declare abstract class ExtToken extends TagPairToken {
|
|
|
15
20
|
get type(): 'ext';
|
|
16
21
|
/**
|
|
17
22
|
* @param name 标签名
|
|
18
|
-
* @param include 是否嵌入
|
|
19
23
|
* @param attr 标签属性
|
|
20
24
|
* @param inner 内部wikitext
|
|
21
25
|
* @param closed 是否封闭
|
|
26
|
+
* @param include 是否嵌入
|
|
22
27
|
*/
|
|
23
28
|
constructor(name: string, attr?: string, inner?: string, closed?: string, config?: Parser.Config, include?: boolean, accum?: Token[]);
|
|
24
29
|
}
|
package/dist/src/tagPair/ext.js
CHANGED
|
@@ -1,9 +1,44 @@
|
|
|
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.ExtToken = void 0;
|
|
4
38
|
const lint_1 = require("../../util/lint");
|
|
5
39
|
const rect_1 = require("../../lib/rect");
|
|
6
40
|
const index_1 = require("../../index");
|
|
41
|
+
const attributesParent_1 = require("../../mixin/attributesParent");
|
|
7
42
|
const index_2 = require("../index");
|
|
8
43
|
const index_3 = require("./index");
|
|
9
44
|
const attributes_1 = require("../attributes");
|
|
@@ -24,111 +59,129 @@ const del = (arr, ele) => {
|
|
|
24
59
|
return [...set];
|
|
25
60
|
};
|
|
26
61
|
/**
|
|
62
|
+
* extension tag
|
|
63
|
+
*
|
|
27
64
|
* 扩展标签
|
|
28
65
|
* @classdesc `{childNodes: [AttributesToken, Token]}`
|
|
29
66
|
*/
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
67
|
+
let ExtToken = (() => {
|
|
68
|
+
let _classDecorators = [(0, attributesParent_1.attributesParent)()];
|
|
69
|
+
let _classDescriptor;
|
|
70
|
+
let _classExtraInitializers = [];
|
|
71
|
+
let _classThis;
|
|
72
|
+
let _classSuper = index_3.TagPairToken;
|
|
73
|
+
var ExtToken = class extends _classSuper {
|
|
74
|
+
static { _classThis = this; }
|
|
75
|
+
static {
|
|
76
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
77
|
+
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
78
|
+
ExtToken = _classThis = _classDescriptor.value;
|
|
79
|
+
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
80
|
+
__runInitializers(_classThis, _classExtraInitializers);
|
|
81
|
+
}
|
|
82
|
+
get type() {
|
|
83
|
+
return 'ext';
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* @param name 标签名
|
|
87
|
+
* @param attr 标签属性
|
|
88
|
+
* @param inner 内部wikitext
|
|
89
|
+
* @param closed 是否封闭
|
|
90
|
+
* @param include 是否嵌入
|
|
91
|
+
*/
|
|
92
|
+
constructor(name, attr, inner, closed, config = index_1.default.getConfig(), include = false, accum = []) {
|
|
93
|
+
const lcName = name.toLowerCase(),
|
|
94
|
+
// @ts-expect-error abstract class
|
|
95
|
+
attrToken = new attributes_1.AttributesToken(!attr || /^\s/u.test(attr) ? attr : ` ${attr}`, 'ext-attrs', lcName, config, accum), newConfig = { ...config, ext: del(config.ext, lcName), excludes: [...config.excludes ?? []] };
|
|
96
|
+
let innerToken;
|
|
97
|
+
switch (lcName) {
|
|
98
|
+
case 'tab':
|
|
99
|
+
newConfig.ext = del(newConfig.ext, 'tabs');
|
|
100
|
+
// fall through
|
|
101
|
+
case 'indicator':
|
|
102
|
+
case 'poem':
|
|
103
|
+
case 'ref':
|
|
104
|
+
case 'option':
|
|
105
|
+
case 'combooption':
|
|
106
|
+
case 'tabs':
|
|
107
|
+
case 'poll':
|
|
108
|
+
case 'seo':
|
|
109
|
+
if (lcName === 'poem') {
|
|
110
|
+
newConfig.excludes.push('heading');
|
|
111
|
+
}
|
|
112
|
+
innerToken = new index_2.Token(inner, newConfig, accum);
|
|
113
|
+
break;
|
|
114
|
+
case 'pre':
|
|
115
|
+
// @ts-expect-error abstract class
|
|
116
|
+
innerToken = new pre_1.PreToken(inner, newConfig, accum);
|
|
117
|
+
break;
|
|
118
|
+
case 'dynamicpagelist':
|
|
119
|
+
// @ts-expect-error abstract class
|
|
120
|
+
innerToken = new index_4.ParamTagToken(include, inner, newConfig, accum);
|
|
121
|
+
break;
|
|
122
|
+
case 'inputbox':
|
|
123
|
+
newConfig.excludes.push('heading');
|
|
124
|
+
// @ts-expect-error abstract class
|
|
125
|
+
innerToken = new inputbox_1.InputboxToken(include, inner, newConfig, accum);
|
|
126
|
+
break;
|
|
127
|
+
case 'references': {
|
|
128
|
+
const { NestedToken } = require('../nested');
|
|
59
129
|
newConfig.excludes.push('heading');
|
|
130
|
+
// @ts-expect-error abstract class
|
|
131
|
+
innerToken = new NestedToken(inner, include, ['ref'], newConfig, accum);
|
|
132
|
+
break;
|
|
60
133
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
const {
|
|
85
|
-
//
|
|
86
|
-
|
|
87
|
-
|
|
134
|
+
case 'choose': {
|
|
135
|
+
const { NestedToken } = require('../nested');
|
|
136
|
+
// @ts-expect-error abstract class
|
|
137
|
+
innerToken = new NestedToken(inner, /<(option|choicetemplate)(\s[^>]*?)?(?:\/>|>([\s\S]*?)<\/(\1)>)/gu, ['option', 'choicetemplate'], newConfig, accum);
|
|
138
|
+
break;
|
|
139
|
+
}
|
|
140
|
+
case 'combobox': {
|
|
141
|
+
const { NestedToken } = require('../nested');
|
|
142
|
+
// @ts-expect-error abstract class
|
|
143
|
+
innerToken = new NestedToken(inner, /<(combooption)(\s[^>]*?)?(?:\/>|>([\s\S]*?)<\/(combooption\s*)>)/giu, ['combooption'], newConfig, accum);
|
|
144
|
+
break;
|
|
145
|
+
}
|
|
146
|
+
case 'gallery':
|
|
147
|
+
// @ts-expect-error abstract class
|
|
148
|
+
innerToken = new gallery_1.GalleryToken(inner, newConfig, accum);
|
|
149
|
+
break;
|
|
150
|
+
case 'imagemap':
|
|
151
|
+
// @ts-expect-error abstract class
|
|
152
|
+
innerToken = new imagemap_1.ImagemapToken(inner, newConfig, accum);
|
|
153
|
+
break;
|
|
154
|
+
// 更多定制扩展的代码示例:
|
|
155
|
+
// ```
|
|
156
|
+
// case 'extensionName': {
|
|
157
|
+
// const {ExtensionToken}: typeof import('../extension') = require('../extension');
|
|
158
|
+
// innerToken = new ExtensionToken(inner, newConfig, accum);
|
|
159
|
+
// break;
|
|
160
|
+
// }
|
|
161
|
+
// ```
|
|
162
|
+
default:
|
|
163
|
+
// @ts-expect-error abstract class
|
|
164
|
+
innerToken = new index_5.NowikiToken(inner, newConfig, accum);
|
|
88
165
|
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
innerToken = new NestedToken(inner, /<(combooption)(\s[^>]*?)?(?:\/>|>([\s\S]*?)<\/(combooption\s*)>)/giu, ['combooption'], newConfig, accum);
|
|
93
|
-
break;
|
|
166
|
+
innerToken.setAttribute('name', lcName);
|
|
167
|
+
if (innerToken.type === 'plain') {
|
|
168
|
+
innerToken.type = 'ext-inner';
|
|
94
169
|
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
innerToken = new gallery_1.GalleryToken(inner, newConfig, accum);
|
|
98
|
-
break;
|
|
99
|
-
case 'imagemap':
|
|
100
|
-
// @ts-expect-error abstract class
|
|
101
|
-
innerToken = new imagemap_1.ImagemapToken(inner, newConfig, accum);
|
|
102
|
-
break;
|
|
103
|
-
// 更多定制扩展的代码示例:
|
|
104
|
-
// ```
|
|
105
|
-
// case 'extensionName': {
|
|
106
|
-
// const {ExtensionToken}: typeof import('../extension') = require('../extension');
|
|
107
|
-
// innerToken = new ExtensionToken(inner, newConfig, accum);
|
|
108
|
-
// break;
|
|
109
|
-
// }
|
|
110
|
-
// ```
|
|
111
|
-
default:
|
|
112
|
-
// @ts-expect-error abstract class
|
|
113
|
-
innerToken = new index_5.NowikiToken(inner, newConfig, accum);
|
|
170
|
+
super(name, attrToken, innerToken, closed, config, accum);
|
|
171
|
+
this.seal('closed', true);
|
|
114
172
|
}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
if (this.name !== 'nowiki' && this.closest('html-attrs,table-attrs')) {
|
|
126
|
-
errors.push((0, lint_1.generateForSelf)(this, rect, 'parsing-order', 'extension tag in HTML tag attributes'));
|
|
127
|
-
}
|
|
128
|
-
if (this.name === 'ref' && this.closest('heading-title')) {
|
|
129
|
-
errors.push((0, lint_1.generateForSelf)(this, rect, 'var-anchor', 'variable anchor in a section header'));
|
|
173
|
+
/** @private */
|
|
174
|
+
lint(start = this.getAbsoluteIndex(), re) {
|
|
175
|
+
const errors = super.lint(start, re), rect = new rect_1.BoundingRect(this, start);
|
|
176
|
+
if (this.name !== 'nowiki' && this.closest('html-attrs,table-attrs')) {
|
|
177
|
+
errors.push((0, lint_1.generateForSelf)(this, rect, 'parsing-order', 'extension tag in HTML tag attributes'));
|
|
178
|
+
}
|
|
179
|
+
if (this.name === 'ref' && this.closest('heading-title')) {
|
|
180
|
+
errors.push((0, lint_1.generateForSelf)(this, rect, 'var-anchor', 'variable anchor in a section header'));
|
|
181
|
+
}
|
|
182
|
+
return errors;
|
|
130
183
|
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
}
|
|
184
|
+
};
|
|
185
|
+
return ExtToken = _classThis;
|
|
186
|
+
})();
|
|
134
187
|
exports.ExtToken = ExtToken;
|
|
@@ -2,6 +2,8 @@ import { TagPairToken } from './index';
|
|
|
2
2
|
import type { LintError, Config } from '../../base';
|
|
3
3
|
import type { AstText, Token } from '../../internal';
|
|
4
4
|
/**
|
|
5
|
+
* `<includeonly>`, `<noinclude>` or `<onlyinclude>`
|
|
6
|
+
*
|
|
5
7
|
* `<includeonly>`或`<noinclude>`或`<onlyinclude>`
|
|
6
8
|
* @classdesc `{childNodes: [AstText, AstText]}`
|
|
7
9
|
*/
|
|
@@ -41,6 +41,8 @@ const hidden_1 = require("../../mixin/hidden");
|
|
|
41
41
|
const index_1 = require("../../index");
|
|
42
42
|
const index_2 = require("./index");
|
|
43
43
|
/**
|
|
44
|
+
* `<includeonly>`, `<noinclude>` or `<onlyinclude>`
|
|
45
|
+
*
|
|
44
46
|
* `<includeonly>`或`<noinclude>`或`<onlyinclude>`
|
|
45
47
|
* @classdesc `{childNodes: [AstText, AstText]}`
|
|
46
48
|
*/
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { Token } from '../index';
|
|
2
2
|
import type { Config } from '../../base';
|
|
3
3
|
import type { AstNodes } from '../../lib/node';
|
|
4
|
-
/**
|
|
4
|
+
/**
|
|
5
|
+
* Paired tags
|
|
6
|
+
*
|
|
7
|
+
* 成对标签
|
|
8
|
+
*/
|
|
5
9
|
export declare abstract class TagPairToken extends Token {
|
|
6
10
|
#private;
|
|
7
11
|
readonly name: string;
|
|
@@ -11,7 +15,7 @@ export declare abstract class TagPairToken extends Token {
|
|
|
11
15
|
readonly childNodes: readonly [AstNodes, AstNodes];
|
|
12
16
|
abstract get firstChild(): AstNodes;
|
|
13
17
|
abstract get lastChild(): AstNodes;
|
|
14
|
-
/** 内部wikitext */
|
|
18
|
+
/** inner wikitext / 内部wikitext */
|
|
15
19
|
get innerText(): string | undefined;
|
|
16
20
|
/**
|
|
17
21
|
* @param name 标签名
|
|
@@ -2,12 +2,16 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.TagPairToken = void 0;
|
|
4
4
|
const index_1 = require("../index");
|
|
5
|
-
/**
|
|
5
|
+
/**
|
|
6
|
+
* Paired tags
|
|
7
|
+
*
|
|
8
|
+
* 成对标签
|
|
9
|
+
*/
|
|
6
10
|
class TagPairToken extends index_1.Token {
|
|
7
11
|
#tags;
|
|
8
12
|
closed;
|
|
9
13
|
selfClosing;
|
|
10
|
-
/** 内部wikitext */
|
|
14
|
+
/** inner wikitext / 内部wikitext */
|
|
11
15
|
get innerText() {
|
|
12
16
|
return this.selfClosing ? undefined : this.lastChild.text();
|
|
13
17
|
}
|
package/dist/src/transclude.d.ts
CHANGED
|
@@ -6,8 +6,10 @@ import { SyntaxToken } from './syntax';
|
|
|
6
6
|
import type { LintError } from '../base';
|
|
7
7
|
declare type Child = AtomToken | SyntaxToken;
|
|
8
8
|
/**
|
|
9
|
+
* template or magic word
|
|
10
|
+
*
|
|
9
11
|
* 模板或魔术字
|
|
10
|
-
* @classdesc `{childNodes: [AtomToken|SyntaxToken, ...AtomToken, ...ParameterToken]}`
|
|
12
|
+
* @classdesc `{childNodes: [AtomToken|SyntaxToken, ...AtomToken[], ...ParameterToken[]]}`
|
|
11
13
|
*/
|
|
12
14
|
export declare abstract class TranscludeToken extends Token {
|
|
13
15
|
#private;
|
|
@@ -24,34 +26,61 @@ export declare abstract class TranscludeToken extends Token {
|
|
|
24
26
|
*/
|
|
25
27
|
constructor(title: string, parts: ([string] | [string | number, string])[], config?: Parser.Config, accum?: Token[]);
|
|
26
28
|
/**
|
|
29
|
+
* Set the transclusion modifier
|
|
30
|
+
*
|
|
27
31
|
* 设置引用修饰符
|
|
28
|
-
* @param modifier 引用修饰符
|
|
32
|
+
* @param modifier transclusion modifier / 引用修饰符
|
|
29
33
|
*/
|
|
30
34
|
setModifier(modifier: string): boolean;
|
|
31
|
-
/**
|
|
35
|
+
/**
|
|
36
|
+
* Check if it is a template or a module
|
|
37
|
+
*
|
|
38
|
+
* 是否是模板或模块
|
|
39
|
+
*/
|
|
32
40
|
isTemplate(): boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Get the module name and module function name
|
|
43
|
+
*
|
|
44
|
+
* 获取模块名和模块函数名
|
|
45
|
+
* @throws `Error` 仅用于模块
|
|
46
|
+
*/
|
|
47
|
+
getModule(): [string, string | undefined];
|
|
33
48
|
/**
|
|
34
49
|
* @override
|
|
35
|
-
* @param token 待插入的子节点
|
|
36
|
-
* @param i 插入位置
|
|
50
|
+
* @param token node to be inserted / 待插入的子节点
|
|
51
|
+
* @param i position to be inserted at / 插入位置
|
|
37
52
|
*/
|
|
38
53
|
insertAt<T extends ParameterToken>(token: T, i?: number): T;
|
|
39
|
-
/**
|
|
54
|
+
/**
|
|
55
|
+
* Get all parameters
|
|
56
|
+
*
|
|
57
|
+
* 获取所有参数
|
|
58
|
+
*/
|
|
40
59
|
getAllArgs(): ParameterToken[];
|
|
41
|
-
/**
|
|
60
|
+
/**
|
|
61
|
+
* Get all anonymous parameters
|
|
62
|
+
*
|
|
63
|
+
* 获取所有匿名参数
|
|
64
|
+
*/
|
|
42
65
|
getAnonArgs(): ParameterToken[];
|
|
43
66
|
/**
|
|
67
|
+
* Get parameters with the specified name
|
|
68
|
+
*
|
|
44
69
|
* 获取指定参数
|
|
45
|
-
* @param key 参数名
|
|
46
|
-
* @param exact 是否匹配匿名性
|
|
47
|
-
* @param copy 是否返回一个备份
|
|
70
|
+
* @param key parameter name / 参数名
|
|
71
|
+
* @param exact whether to match anonymosity / 是否匹配匿名性
|
|
72
|
+
* @param copy whether to return a copy / 是否返回一个备份
|
|
48
73
|
*/
|
|
49
74
|
getArgs(key: string | number, exact?: boolean, copy?: boolean): Set<ParameterToken>;
|
|
50
75
|
/**
|
|
76
|
+
* Get duplicated parameters
|
|
77
|
+
*
|
|
51
78
|
* 获取重名参数
|
|
52
79
|
*/
|
|
53
80
|
getDuplicatedArgs(): [string, ParameterToken[]][];
|
|
54
81
|
/**
|
|
82
|
+
* Get possible values of some magic words
|
|
83
|
+
*
|
|
55
84
|
* 对特定魔术字获取可能的取值
|
|
56
85
|
* @throws `Error` 不是可接受的魔术字
|
|
57
86
|
*/
|