wikilint 2.9.1 → 2.9.3
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/dist/base.d.ts +9 -3
- package/dist/index.js +5 -6
- package/dist/lib/element.js +11 -11
- package/dist/lib/node.d.ts +4 -1
- package/dist/lib/node.js +1 -4
- package/dist/lib/text.d.ts +1 -1
- package/dist/lib/text.js +3 -2
- package/dist/parser/braces.js +11 -7
- package/dist/parser/table.js +3 -3
- package/dist/src/arg.d.ts +1 -1
- package/dist/src/arg.js +3 -1
- package/dist/src/atom.d.ts +5 -2
- package/dist/src/atom.js +25 -1
- package/dist/src/attribute.d.ts +1 -1
- package/dist/src/attribute.js +6 -1
- package/dist/src/attributes.d.ts +2 -1
- package/dist/src/attributes.js +9 -4
- package/dist/src/converter.d.ts +1 -1
- package/dist/src/converter.js +3 -1
- package/dist/src/converterFlags.d.ts +1 -1
- package/dist/src/converterFlags.js +4 -1
- package/dist/src/converterRule.d.ts +1 -1
- package/dist/src/converterRule.js +3 -1
- package/dist/src/extLink.d.ts +1 -1
- package/dist/src/extLink.js +3 -1
- package/dist/src/gallery.d.ts +1 -1
- package/dist/src/gallery.js +5 -3
- package/dist/src/heading.d.ts +1 -1
- package/dist/src/heading.js +3 -1
- package/dist/src/hidden.d.ts +1 -1
- package/dist/src/hidden.js +3 -1
- package/dist/src/html.d.ts +1 -1
- package/dist/src/html.js +3 -1
- package/dist/src/imageParameter.d.ts +1 -1
- package/dist/src/imageParameter.js +4 -1
- package/dist/src/imagemap.d.ts +1 -1
- package/dist/src/imagemap.js +3 -1
- package/dist/src/imagemapLink.d.ts +1 -1
- package/dist/src/imagemapLink.js +3 -1
- package/dist/src/index.d.ts +2 -1
- package/dist/src/index.js +17 -8
- package/dist/src/link/base.d.ts +1 -1
- package/dist/src/link/base.js +1 -0
- package/dist/src/link/category.d.ts +1 -1
- package/dist/src/link/category.js +3 -1
- package/dist/src/link/file.d.ts +1 -1
- package/dist/src/link/file.js +3 -1
- package/dist/src/link/galleryImage.d.ts +1 -2
- package/dist/src/link/galleryImage.js +7 -12
- package/dist/src/link/index.d.ts +1 -1
- package/dist/src/link/index.js +3 -1
- package/dist/src/link/redirectTarget.d.ts +1 -1
- package/dist/src/link/redirectTarget.js +3 -1
- package/dist/src/magicLink.d.ts +2 -1
- package/dist/src/magicLink.js +7 -3
- package/dist/src/nested.d.ts +1 -1
- package/dist/src/nested.js +3 -1
- package/dist/src/nowiki/base.d.ts +1 -1
- package/dist/src/nowiki/comment.d.ts +1 -1
- package/dist/src/nowiki/comment.js +3 -1
- package/dist/src/nowiki/dd.d.ts +1 -1
- package/dist/src/nowiki/dd.js +3 -1
- package/dist/src/nowiki/doubleUnderscore.d.ts +1 -1
- package/dist/src/nowiki/doubleUnderscore.js +3 -1
- package/dist/src/nowiki/hr.d.ts +1 -1
- package/dist/src/nowiki/hr.js +3 -1
- package/dist/src/nowiki/index.d.ts +1 -1
- package/dist/src/nowiki/index.js +3 -1
- package/dist/src/nowiki/list.d.ts +1 -1
- package/dist/src/nowiki/list.js +3 -1
- package/dist/src/nowiki/listBase.d.ts +1 -1
- package/dist/src/nowiki/noinclude.d.ts +1 -1
- package/dist/src/nowiki/noinclude.js +3 -1
- package/dist/src/nowiki/quote.d.ts +1 -1
- package/dist/src/nowiki/quote.js +3 -1
- package/dist/src/onlyinclude.d.ts +1 -1
- package/dist/src/onlyinclude.js +3 -1
- package/dist/src/paramTag/index.d.ts +1 -1
- package/dist/src/paramTag/index.js +3 -1
- package/dist/src/parameter.d.ts +1 -2
- package/dist/src/parameter.js +4 -2
- package/dist/src/pre.d.ts +1 -1
- package/dist/src/pre.js +3 -1
- package/dist/src/redirect.d.ts +1 -1
- package/dist/src/redirect.js +3 -1
- package/dist/src/syntax.d.ts +4 -3
- package/dist/src/syntax.js +6 -2
- package/dist/src/table/base.d.ts +4 -2
- package/dist/src/table/base.js +3 -2
- package/dist/src/table/index.d.ts +1 -1
- package/dist/src/table/index.js +8 -6
- package/dist/src/table/td.d.ts +1 -5
- package/dist/src/table/td.js +9 -8
- package/dist/src/table/tr.d.ts +1 -1
- package/dist/src/table/tr.js +4 -2
- package/dist/src/table/trBase.d.ts +1 -1
- package/dist/src/tagPair/ext.d.ts +1 -1
- package/dist/src/tagPair/ext.js +7 -3
- package/dist/src/tagPair/include.d.ts +1 -1
- package/dist/src/tagPair/include.js +3 -1
- package/dist/src/tagPair/index.d.ts +1 -1
- package/dist/src/transclude.d.ts +1 -1
- package/dist/src/transclude.js +6 -2
- package/dist/util/debug.js +5 -0
- package/package.json +2 -2
|
@@ -8,7 +8,6 @@ import type { AttributesToken, ExtToken } from '../../internal';
|
|
|
8
8
|
* @classdesc `{childNodes: ...AtomToken}`
|
|
9
9
|
*/
|
|
10
10
|
export declare abstract class ParamTagToken extends Token {
|
|
11
|
-
readonly type = "ext-inner";
|
|
12
11
|
readonly name: string;
|
|
13
12
|
readonly childNodes: readonly AtomToken[];
|
|
14
13
|
abstract get firstChild(): AtomToken | undefined;
|
|
@@ -16,6 +15,7 @@ export declare abstract class ParamTagToken extends Token {
|
|
|
16
15
|
abstract get nextSibling(): undefined;
|
|
17
16
|
abstract get previousSibling(): AttributesToken;
|
|
18
17
|
abstract get parentNode(): ExtToken | undefined;
|
|
18
|
+
get type(): 'ext-inner';
|
|
19
19
|
/** @class */
|
|
20
20
|
constructor(wikitext?: string, config?: Parser.Config, accum?: Token[], acceptable?: Acceptable);
|
|
21
21
|
}
|
|
@@ -11,7 +11,9 @@ const atom_1 = require("../atom");
|
|
|
11
11
|
* @classdesc `{childNodes: ...AtomToken}`
|
|
12
12
|
*/
|
|
13
13
|
class ParamTagToken extends index_2.Token {
|
|
14
|
-
type
|
|
14
|
+
get type() {
|
|
15
|
+
return 'ext-inner';
|
|
16
|
+
}
|
|
15
17
|
/** @class */
|
|
16
18
|
constructor(wikitext, config = index_1.default.getConfig(), accum = [], acceptable = {}) {
|
|
17
19
|
super(undefined, config, accum, {});
|
package/dist/src/parameter.d.ts
CHANGED
|
@@ -7,7 +7,6 @@ import type { AtomToken, SyntaxToken, TranscludeToken } from '../internal';
|
|
|
7
7
|
* @classdesc `{childNodes: [Token, Token]}`
|
|
8
8
|
*/
|
|
9
9
|
export declare abstract class ParameterToken extends Token {
|
|
10
|
-
readonly type = "parameter";
|
|
11
10
|
readonly name: string;
|
|
12
11
|
readonly childNodes: readonly [Token, Token];
|
|
13
12
|
abstract get firstChild(): Token;
|
|
@@ -15,6 +14,7 @@ export declare abstract class ParameterToken extends Token {
|
|
|
15
14
|
abstract get parentNode(): TranscludeToken | undefined;
|
|
16
15
|
abstract get nextSibling(): this | undefined;
|
|
17
16
|
abstract get previousSibling(): AtomToken | SyntaxToken | this;
|
|
17
|
+
get type(): 'parameter';
|
|
18
18
|
/** 是否是匿名参数 */
|
|
19
19
|
get anon(): boolean;
|
|
20
20
|
/**
|
|
@@ -22,6 +22,5 @@ export declare abstract class ParameterToken extends Token {
|
|
|
22
22
|
* @param value 参数值
|
|
23
23
|
*/
|
|
24
24
|
constructor(key?: string | number, value?: string, config?: Parser.Config, accum?: Token[]);
|
|
25
|
-
/** @override */
|
|
26
25
|
text(): string;
|
|
27
26
|
}
|
package/dist/src/parameter.js
CHANGED
|
@@ -16,7 +16,9 @@ const linkRegex = new RegExp(`https?://${string_1.extUrlCharFirst}${string_1.ext
|
|
|
16
16
|
* @classdesc `{childNodes: [Token, Token]}`
|
|
17
17
|
*/
|
|
18
18
|
class ParameterToken extends index_2.Token {
|
|
19
|
-
type
|
|
19
|
+
get type() {
|
|
20
|
+
return 'parameter';
|
|
21
|
+
}
|
|
20
22
|
/** 是否是匿名参数 */
|
|
21
23
|
get anon() {
|
|
22
24
|
return this.firstChild.length === 0;
|
|
@@ -42,12 +44,12 @@ class ParameterToken extends index_2.Token {
|
|
|
42
44
|
parentNode.getArgs(name, false, false).add(this);
|
|
43
45
|
}
|
|
44
46
|
}
|
|
47
|
+
super.afterBuild();
|
|
45
48
|
}
|
|
46
49
|
/** @private */
|
|
47
50
|
toString() {
|
|
48
51
|
return this.anon ? this.lastChild.toString() : super.toString('=');
|
|
49
52
|
}
|
|
50
|
-
/** @override */
|
|
51
53
|
text() {
|
|
52
54
|
return this.anon ? this.lastChild.text() : super.text('=');
|
|
53
55
|
}
|
package/dist/src/pre.d.ts
CHANGED
|
@@ -8,7 +8,6 @@ import type { AstText, AttributesToken, ExtToken, ConverterToken } from '../inte
|
|
|
8
8
|
* @classdesc `{childNodes: [...AstText|NoincludeToken|ConverterToken]}`
|
|
9
9
|
*/
|
|
10
10
|
export declare abstract class PreToken extends Token {
|
|
11
|
-
readonly type = "ext-inner";
|
|
12
11
|
readonly name: 'pre';
|
|
13
12
|
readonly childNodes: readonly (AstText | NoincludeToken | ConverterToken)[];
|
|
14
13
|
abstract get firstChild(): AstText | NoincludeToken | ConverterToken | undefined;
|
|
@@ -16,6 +15,7 @@ export declare abstract class PreToken extends Token {
|
|
|
16
15
|
abstract get nextSibling(): undefined;
|
|
17
16
|
abstract get previousSibling(): AttributesToken;
|
|
18
17
|
abstract get parentNode(): ExtToken | undefined;
|
|
18
|
+
get type(): 'ext-inner';
|
|
19
19
|
/** @class */
|
|
20
20
|
constructor(wikitext?: string, config?: Parser.Config, accum?: Token[]);
|
|
21
21
|
}
|
package/dist/src/pre.js
CHANGED
|
@@ -10,7 +10,9 @@ const noinclude_1 = require("./nowiki/noinclude");
|
|
|
10
10
|
* @classdesc `{childNodes: [...AstText|NoincludeToken|ConverterToken]}`
|
|
11
11
|
*/
|
|
12
12
|
class PreToken extends index_2.Token {
|
|
13
|
-
type
|
|
13
|
+
get type() {
|
|
14
|
+
return 'ext-inner';
|
|
15
|
+
}
|
|
14
16
|
/** @class */
|
|
15
17
|
constructor(wikitext, config = index_1.default.getConfig(), accum = []) {
|
|
16
18
|
if (wikitext) {
|
package/dist/src/redirect.d.ts
CHANGED
|
@@ -9,11 +9,11 @@ import type { LintError } from '../base';
|
|
|
9
9
|
*/
|
|
10
10
|
export declare abstract class RedirectToken extends Token {
|
|
11
11
|
#private;
|
|
12
|
-
readonly type = "redirect";
|
|
13
12
|
readonly childNodes: readonly [SyntaxToken, RedirectTargetToken];
|
|
14
13
|
abstract get firstChild(): SyntaxToken;
|
|
15
14
|
abstract get lastChild(): RedirectTargetToken;
|
|
16
15
|
abstract get previousSibling(): undefined;
|
|
16
|
+
get type(): 'redirect';
|
|
17
17
|
/**
|
|
18
18
|
* @param pre leading whitespace
|
|
19
19
|
* @param syntax 重定向魔术字
|
package/dist/src/redirect.js
CHANGED
|
@@ -59,9 +59,11 @@ let RedirectToken = (() => {
|
|
|
59
59
|
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
60
60
|
__runInitializers(_classThis, _classExtraInitializers);
|
|
61
61
|
}
|
|
62
|
-
type = 'redirect';
|
|
63
62
|
#pre;
|
|
64
63
|
#post;
|
|
64
|
+
get type() {
|
|
65
|
+
return 'redirect';
|
|
66
|
+
}
|
|
65
67
|
/**
|
|
66
68
|
* @param pre leading whitespace
|
|
67
69
|
* @param syntax 重定向魔术字
|
package/dist/src/syntax.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { Token } from './index';
|
|
2
2
|
import type { Config } from '../base';
|
|
3
|
-
declare type SyntaxTypes = '
|
|
3
|
+
declare type SyntaxTypes = 'heading-trail' | 'magic-word-name' | 'table-syntax' | 'redirect-syntax';
|
|
4
4
|
/** 满足特定语法格式的plain Token */
|
|
5
5
|
export declare class SyntaxToken extends Token {
|
|
6
|
-
|
|
6
|
+
#private;
|
|
7
|
+
get type(): SyntaxTypes;
|
|
7
8
|
/** @param pattern 语法正则 */
|
|
8
|
-
constructor(wikitext: string | undefined, pattern: RegExp, type
|
|
9
|
+
constructor(wikitext: string | undefined, pattern: RegExp, type: SyntaxTypes, config?: Config, accum?: Token[], acceptable?: Acceptable);
|
|
9
10
|
}
|
|
10
11
|
export {};
|
package/dist/src/syntax.js
CHANGED
|
@@ -4,10 +4,14 @@ exports.SyntaxToken = void 0;
|
|
|
4
4
|
const index_1 = require("./index");
|
|
5
5
|
/** 满足特定语法格式的plain Token */
|
|
6
6
|
class SyntaxToken extends index_1.Token {
|
|
7
|
+
#type;
|
|
8
|
+
get type() {
|
|
9
|
+
return this.#type;
|
|
10
|
+
}
|
|
7
11
|
/** @param pattern 语法正则 */
|
|
8
|
-
constructor(wikitext, pattern, type
|
|
12
|
+
constructor(wikitext, pattern, type, config, accum, acceptable) {
|
|
9
13
|
super(wikitext, config, accum, acceptable);
|
|
10
|
-
this
|
|
14
|
+
this.#type = type;
|
|
11
15
|
}
|
|
12
16
|
/** @private */
|
|
13
17
|
lint() {
|
package/dist/src/table/base.d.ts
CHANGED
|
@@ -3,18 +3,20 @@ import { Token } from '../index';
|
|
|
3
3
|
import { SyntaxToken } from '../syntax';
|
|
4
4
|
import { AttributesToken } from '../attributes';
|
|
5
5
|
import type { AttributesParentBase } from '../../mixin/attributesParent';
|
|
6
|
+
declare type TableTypes = 'table' | 'tr' | 'td';
|
|
6
7
|
export interface TableBaseToken extends AttributesParentBase {
|
|
7
8
|
}
|
|
8
9
|
export declare abstract class TableBaseToken extends Token {
|
|
9
|
-
type:
|
|
10
|
+
abstract get type(): TableTypes;
|
|
10
11
|
readonly childNodes: readonly [SyntaxToken, AttributesToken, ...Token[]];
|
|
11
12
|
abstract get firstChild(): SyntaxToken;
|
|
12
13
|
abstract get lastChild(): Token;
|
|
13
14
|
/**
|
|
14
15
|
* @param pattern 表格语法正则
|
|
15
16
|
* @param syntax 表格语法
|
|
17
|
+
* @param type 节点类型
|
|
16
18
|
* @param attr 表格属性
|
|
17
19
|
*/
|
|
18
|
-
constructor(pattern: RegExp, syntax
|
|
20
|
+
constructor(pattern: RegExp, syntax: string, type: TableTypes, attr?: string, config?: Parser.Config, accum?: Token[], acceptable?: Acceptable);
|
|
19
21
|
}
|
|
20
22
|
export {};
|
package/dist/src/table/base.js
CHANGED
|
@@ -14,13 +14,14 @@ class TableBaseToken extends (0, attributesParent_1.attributesParent)(1)(index_2
|
|
|
14
14
|
/**
|
|
15
15
|
* @param pattern 表格语法正则
|
|
16
16
|
* @param syntax 表格语法
|
|
17
|
+
* @param type 节点类型
|
|
17
18
|
* @param attr 表格属性
|
|
18
19
|
*/
|
|
19
|
-
constructor(pattern, syntax, attr, config = index_1.default.getConfig(), accum = [], acceptable = {}) {
|
|
20
|
+
constructor(pattern, syntax, type, attr, config = index_1.default.getConfig(), accum = [], acceptable = {}) {
|
|
20
21
|
super(undefined, config, accum, acceptable);
|
|
21
22
|
this.append(new syntax_1.SyntaxToken(syntax, pattern, 'table-syntax', config, accum, {}),
|
|
22
23
|
// @ts-expect-error abstract class
|
|
23
|
-
new attributes_1.AttributesToken(attr, 'table-attrs',
|
|
24
|
+
new attributes_1.AttributesToken(attr, 'table-attrs', type, config, accum));
|
|
24
25
|
}
|
|
25
26
|
}
|
|
26
27
|
exports.TableBaseToken = TableBaseToken;
|
|
@@ -16,9 +16,9 @@ export declare class Layout extends Array<TableCoords[]> {
|
|
|
16
16
|
* @classdesc `{childNodes: [SyntaxToken, AttributesToken, ?Token, ...TdToken, ...TrToken, ?SyntaxToken]}`
|
|
17
17
|
*/
|
|
18
18
|
export declare abstract class TableToken extends TrBaseToken {
|
|
19
|
-
readonly type = "table";
|
|
20
19
|
readonly childNodes: readonly [SyntaxToken, AttributesToken, ...(TdToken | TrToken)[], SyntaxToken] | readonly [SyntaxToken, AttributesToken, ...(TdToken | TrToken)[]];
|
|
21
20
|
abstract get lastChild(): AttributesToken | TdToken | TrToken | SyntaxToken;
|
|
21
|
+
get type(): 'table';
|
|
22
22
|
/** 表格是否闭合 */
|
|
23
23
|
get closed(): boolean;
|
|
24
24
|
/**
|
package/dist/src/table/index.js
CHANGED
|
@@ -23,7 +23,9 @@ exports.Layout = Layout;
|
|
|
23
23
|
* @classdesc `{childNodes: [SyntaxToken, AttributesToken, ?Token, ...TdToken, ...TrToken, ?SyntaxToken]}`
|
|
24
24
|
*/
|
|
25
25
|
class TableToken extends trBase_1.TrBaseToken {
|
|
26
|
-
type
|
|
26
|
+
get type() {
|
|
27
|
+
return 'table';
|
|
28
|
+
}
|
|
27
29
|
/** 表格是否闭合 */
|
|
28
30
|
get closed() {
|
|
29
31
|
return this.lastChild.type === 'table-syntax';
|
|
@@ -33,7 +35,7 @@ class TableToken extends trBase_1.TrBaseToken {
|
|
|
33
35
|
* @param attr 表格属性
|
|
34
36
|
*/
|
|
35
37
|
constructor(syntax, attr, config, accum) {
|
|
36
|
-
super(/^(?:\{\||\{\{\{\s*!\s*\}\}|\{\{\s*\(!\s*\}\})$/u, syntax, attr, config, accum, {});
|
|
38
|
+
super(/^(?:\{\||\{\{\{\s*!\s*\}\}|\{\{\s*\(!\s*\}\})$/u, syntax, 'table', attr, config, accum, {});
|
|
37
39
|
}
|
|
38
40
|
/** @private */
|
|
39
41
|
lint(start = this.getAbsoluteIndex(), re) {
|
|
@@ -73,10 +75,10 @@ class TableToken extends trBase_1.TrBaseToken {
|
|
|
73
75
|
/** @private */
|
|
74
76
|
close(syntax = '\n|}', halfParsed) {
|
|
75
77
|
const config = this.getAttribute('config'), accum = this.getAttribute('accum'), inner = halfParsed ? [syntax] : index_1.default.parse(syntax, this.getAttribute('include'), 2, config).childNodes;
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
}
|
|
78
|
+
debug_1.Shadow.run(() => {
|
|
79
|
+
const token = new syntax_1.SyntaxToken(undefined, closingPattern, 'table-syntax', config, accum, {});
|
|
80
|
+
super.insertAt(token);
|
|
81
|
+
});
|
|
80
82
|
this.lastChild.replaceChildren(...inner);
|
|
81
83
|
}
|
|
82
84
|
/**
|
package/dist/src/table/td.d.ts
CHANGED
|
@@ -15,11 +15,11 @@ declare type TdAttrGetter<T extends string> = T extends keyof TdSpanAttrs ? numb
|
|
|
15
15
|
*/
|
|
16
16
|
export declare abstract class TdToken extends TableBaseToken {
|
|
17
17
|
#private;
|
|
18
|
-
readonly type = "td";
|
|
19
18
|
readonly childNodes: readonly [SyntaxToken, AttributesToken, Token];
|
|
20
19
|
abstract get parentNode(): TrToken | TableToken | undefined;
|
|
21
20
|
abstract get nextSibling(): this | TrToken | SyntaxToken | undefined;
|
|
22
21
|
abstract get previousSibling(): Token | undefined;
|
|
22
|
+
get type(): 'td';
|
|
23
23
|
/** rowspan */
|
|
24
24
|
get rowspan(): number;
|
|
25
25
|
/** colspan */
|
|
@@ -33,10 +33,6 @@ export declare abstract class TdToken extends TableBaseToken {
|
|
|
33
33
|
constructor(syntax: string, inner?: string, config?: Parser.Config, accum?: Token[]);
|
|
34
34
|
/** 是否位于行首 */
|
|
35
35
|
isIndependent(): boolean;
|
|
36
|
-
/**
|
|
37
|
-
* @override
|
|
38
|
-
* @param key 属性键
|
|
39
|
-
*/
|
|
40
36
|
getAttr<T extends string>(key: T): TdAttrGetter<T>;
|
|
41
37
|
}
|
|
42
38
|
export {};
|
package/dist/src/table/td.js
CHANGED
|
@@ -4,6 +4,7 @@ exports.TdToken = void 0;
|
|
|
4
4
|
const lint_1 = require("../../util/lint");
|
|
5
5
|
const rect_1 = require("../../lib/rect");
|
|
6
6
|
const constants_1 = require("../../util/constants");
|
|
7
|
+
const debug_1 = require("../../util/debug");
|
|
7
8
|
const index_1 = require("../../index");
|
|
8
9
|
const index_2 = require("../index");
|
|
9
10
|
const base_1 = require("./base");
|
|
@@ -12,9 +13,11 @@ const base_1 = require("./base");
|
|
|
12
13
|
* @classdesc `{childNodes: [SyntaxToken, AttributesToken, Token]}`
|
|
13
14
|
*/
|
|
14
15
|
class TdToken extends base_1.TableBaseToken {
|
|
15
|
-
type = 'td';
|
|
16
16
|
#innerSyntax = '';
|
|
17
17
|
#syntax;
|
|
18
|
+
get type() {
|
|
19
|
+
return 'td';
|
|
20
|
+
}
|
|
18
21
|
/** rowspan */
|
|
19
22
|
get rowspan() {
|
|
20
23
|
return this.getAttr('rowspan');
|
|
@@ -37,7 +40,7 @@ class TdToken extends base_1.TableBaseToken {
|
|
|
37
40
|
innerSyntax = null;
|
|
38
41
|
attr = '';
|
|
39
42
|
}
|
|
40
|
-
super(/^(?:\n[^\S\n]*(?:[|!]|\|\+|\{\{\s*!\s*\}\}\+?)|(?:\||\{\{\s*!\s*\}\}){2}|!!|\{\{\s*!!\s*\}\})$/u, syntax, attr, config, accum);
|
|
43
|
+
super(/^(?:\n[^\S\n]*(?:[|!]|\|\+|\{\{\s*!\s*\}\}\+?)|(?:\||\{\{\s*!\s*\}\}){2}|!!|\{\{\s*!!\s*\}\})$/u, syntax, 'td', attr, config, accum);
|
|
41
44
|
if (innerSyntax) {
|
|
42
45
|
[this.#innerSyntax] = innerSyntax;
|
|
43
46
|
}
|
|
@@ -48,8 +51,9 @@ class TdToken extends base_1.TableBaseToken {
|
|
|
48
51
|
}
|
|
49
52
|
/** 表格语法信息 */
|
|
50
53
|
#getSyntax() {
|
|
51
|
-
|
|
52
|
-
|
|
54
|
+
const { rev } = debug_1.Shadow;
|
|
55
|
+
this.#syntax ??= [rev, this.#computeSyntax()];
|
|
56
|
+
return this.#syntax[1];
|
|
53
57
|
}
|
|
54
58
|
/** 表格语法信息 */
|
|
55
59
|
#computeSyntax() {
|
|
@@ -75,6 +79,7 @@ class TdToken extends base_1.TableBaseToken {
|
|
|
75
79
|
if (this.#innerSyntax.includes('\0')) {
|
|
76
80
|
this.#innerSyntax = this.buildFromStr(this.#innerSyntax, constants_1.BuildMethod.String);
|
|
77
81
|
}
|
|
82
|
+
super.afterBuild();
|
|
78
83
|
}
|
|
79
84
|
/** @private */
|
|
80
85
|
toString() {
|
|
@@ -127,10 +132,6 @@ class TdToken extends base_1.TableBaseToken {
|
|
|
127
132
|
isIndependent() {
|
|
128
133
|
return this.firstChild.text().startsWith('\n');
|
|
129
134
|
}
|
|
130
|
-
/**
|
|
131
|
-
* @override
|
|
132
|
-
* @param key 属性键
|
|
133
|
-
*/
|
|
134
135
|
getAttr(key) {
|
|
135
136
|
const value = super.getAttr(key);
|
|
136
137
|
return (key === 'rowspan' || key === 'colspan' ? parseInt(value) || 1 : value);
|
package/dist/src/table/tr.d.ts
CHANGED
|
@@ -6,12 +6,12 @@ import type { Token, TdToken, TableToken, SyntaxToken, AttributesToken } from '.
|
|
|
6
6
|
* @classdesc `{childNodes: [SyntaxToken, AttributesToken, ?Token, ...TdToken]}`
|
|
7
7
|
*/
|
|
8
8
|
export declare abstract class TrToken extends TrBaseToken {
|
|
9
|
-
readonly type = "tr";
|
|
10
9
|
readonly childNodes: readonly [SyntaxToken, AttributesToken, ...TdToken[]];
|
|
11
10
|
abstract get lastChild(): AttributesToken | TdToken;
|
|
12
11
|
abstract get parentNode(): TableToken | undefined;
|
|
13
12
|
abstract get nextSibling(): this | SyntaxToken | undefined;
|
|
14
13
|
abstract get previousSibling(): Token;
|
|
14
|
+
get type(): 'tr';
|
|
15
15
|
/**
|
|
16
16
|
* @param syntax 表格语法
|
|
17
17
|
* @param attr 表格属性
|
package/dist/src/table/tr.js
CHANGED
|
@@ -7,13 +7,15 @@ const trBase_1 = require("./trBase");
|
|
|
7
7
|
* @classdesc `{childNodes: [SyntaxToken, AttributesToken, ?Token, ...TdToken]}`
|
|
8
8
|
*/
|
|
9
9
|
class TrToken extends trBase_1.TrBaseToken {
|
|
10
|
-
type
|
|
10
|
+
get type() {
|
|
11
|
+
return 'tr';
|
|
12
|
+
}
|
|
11
13
|
/**
|
|
12
14
|
* @param syntax 表格语法
|
|
13
15
|
* @param attr 表格属性
|
|
14
16
|
*/
|
|
15
17
|
constructor(syntax, attr, config, accum) {
|
|
16
|
-
super(/^\n[^\S\n]*(?:\|-+|\{\{\s*!\s*\}\}-+|\{\{\s*!-\s*\}\}-*)$/u, syntax, attr, config, accum, {});
|
|
18
|
+
super(/^\n[^\S\n]*(?:\|-+|\{\{\s*!\s*\}\}-+|\{\{\s*!-\s*\}\}-*)$/u, syntax, 'tr', attr, config, accum, {});
|
|
17
19
|
}
|
|
18
20
|
}
|
|
19
21
|
exports.TrToken = TrToken;
|
|
@@ -8,11 +8,11 @@ import type { LintError } from '../../base';
|
|
|
8
8
|
* @classdesc `{childNodes: [AttributesToken, Token]}`
|
|
9
9
|
*/
|
|
10
10
|
export declare abstract class ExtToken extends TagPairToken {
|
|
11
|
-
readonly type = "ext";
|
|
12
11
|
closed: true;
|
|
13
12
|
readonly childNodes: readonly [AttributesToken, Token];
|
|
14
13
|
abstract get firstChild(): AttributesToken;
|
|
15
14
|
abstract get lastChild(): Token;
|
|
15
|
+
get type(): 'ext';
|
|
16
16
|
/**
|
|
17
17
|
* @param name 标签名
|
|
18
18
|
* @param attr 标签属性
|
package/dist/src/tagPair/ext.js
CHANGED
|
@@ -22,7 +22,9 @@ const del = (arr, ele) => {
|
|
|
22
22
|
* @classdesc `{childNodes: [AttributesToken, Token]}`
|
|
23
23
|
*/
|
|
24
24
|
class ExtToken extends index_3.TagPairToken {
|
|
25
|
-
type
|
|
25
|
+
get type() {
|
|
26
|
+
return 'ext';
|
|
27
|
+
}
|
|
26
28
|
/**
|
|
27
29
|
* @param name 标签名
|
|
28
30
|
* @param attr 标签属性
|
|
@@ -111,11 +113,13 @@ class ExtToken extends index_3.TagPairToken {
|
|
|
111
113
|
default: {
|
|
112
114
|
const { NowikiToken } = require('../nowiki/index');
|
|
113
115
|
// @ts-expect-error abstract class
|
|
114
|
-
innerToken = new NowikiToken(inner, newConfig);
|
|
116
|
+
innerToken = new NowikiToken(inner, newConfig, accum);
|
|
115
117
|
}
|
|
116
118
|
}
|
|
117
119
|
innerToken.setAttribute('name', lcName);
|
|
118
|
-
innerToken.type
|
|
120
|
+
if (innerToken.type === 'plain') {
|
|
121
|
+
innerToken.type = 'ext-inner';
|
|
122
|
+
}
|
|
119
123
|
super(name, attrToken, innerToken, closed, config, accum);
|
|
120
124
|
this.seal('closed', true);
|
|
121
125
|
}
|
|
@@ -6,10 +6,10 @@ import type { AstText, Token } from '../../internal';
|
|
|
6
6
|
* @classdesc `{childNodes: [AstText, AstText]}`
|
|
7
7
|
*/
|
|
8
8
|
export declare abstract class IncludeToken extends TagPairToken {
|
|
9
|
-
readonly type = "include";
|
|
10
9
|
readonly childNodes: readonly [AstText, AstText];
|
|
11
10
|
abstract get firstChild(): AstText;
|
|
12
11
|
abstract get lastChild(): AstText;
|
|
12
|
+
get type(): 'include';
|
|
13
13
|
/**
|
|
14
14
|
* @param name 标签名
|
|
15
15
|
* @param attr 标签属性
|
|
@@ -58,7 +58,9 @@ let IncludeToken = (() => {
|
|
|
58
58
|
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
59
59
|
__runInitializers(_classThis, _classExtraInitializers);
|
|
60
60
|
}
|
|
61
|
-
type
|
|
61
|
+
get type() {
|
|
62
|
+
return 'include';
|
|
63
|
+
}
|
|
62
64
|
/**
|
|
63
65
|
* @param name 标签名
|
|
64
66
|
* @param attr 标签属性
|
|
@@ -4,10 +4,10 @@ import type { AstNodes } from '../../lib/node';
|
|
|
4
4
|
/** 成对标签 */
|
|
5
5
|
export declare abstract class TagPairToken extends Token {
|
|
6
6
|
#private;
|
|
7
|
-
type: 'ext' | 'include';
|
|
8
7
|
readonly name: string;
|
|
9
8
|
closed: boolean;
|
|
10
9
|
selfClosing: boolean;
|
|
10
|
+
abstract get type(): 'ext' | 'include';
|
|
11
11
|
readonly childNodes: readonly [AstNodes, AstNodes];
|
|
12
12
|
abstract get firstChild(): AstNodes;
|
|
13
13
|
abstract get lastChild(): AstNodes;
|
package/dist/src/transclude.d.ts
CHANGED
|
@@ -10,11 +10,11 @@ import type { LintError } from '../base';
|
|
|
10
10
|
*/
|
|
11
11
|
export declare abstract class TranscludeToken extends Token {
|
|
12
12
|
#private;
|
|
13
|
-
type: 'template' | 'magic-word';
|
|
14
13
|
readonly modifier: string;
|
|
15
14
|
readonly childNodes: readonly [AtomToken | SyntaxToken, ...ParameterToken[]] | readonly [SyntaxToken, AtomToken, AtomToken, ...ParameterToken[]];
|
|
16
15
|
abstract get firstChild(): AtomToken | SyntaxToken;
|
|
17
16
|
abstract get lastChild(): AtomToken | SyntaxToken | ParameterToken;
|
|
17
|
+
get type(): 'template' | 'magic-word';
|
|
18
18
|
/**
|
|
19
19
|
* @param title 模板标题或魔术字
|
|
20
20
|
* @param parts 参数各部分
|
package/dist/src/transclude.js
CHANGED
|
@@ -24,10 +24,13 @@ const insensitiveVars = new Set([
|
|
|
24
24
|
* @classdesc `{childNodes: [AtomToken|SyntaxToken, ...AtomToken, ...ParameterToken]}`
|
|
25
25
|
*/
|
|
26
26
|
class TranscludeToken extends index_2.Token {
|
|
27
|
-
type = 'template';
|
|
28
27
|
modifier = '';
|
|
28
|
+
#type = 'template';
|
|
29
29
|
#raw = false;
|
|
30
30
|
#args = new Map();
|
|
31
|
+
get type() {
|
|
32
|
+
return this.#type;
|
|
33
|
+
}
|
|
31
34
|
/**
|
|
32
35
|
* @param title 模板标题或魔术字
|
|
33
36
|
* @param parts 参数各部分
|
|
@@ -51,7 +54,7 @@ class TranscludeToken extends index_2.Token {
|
|
|
51
54
|
const [magicWord, ...arg] = title.split(':'), cleaned = (0, string_1.removeComment)(magicWord), name = cleaned[arg.length > 0 ? 'trimStart' : 'trim'](), lcName = name.toLowerCase(), canonicalName = insensitive[lcName], isSensitive = sensitive.includes(name), isVar = isSensitive || insensitiveVars.has(canonicalName);
|
|
52
55
|
if (isVar || isFunction && canonicalName) {
|
|
53
56
|
this.setAttribute('name', canonicalName ?? lcName);
|
|
54
|
-
this
|
|
57
|
+
this.#type = 'magic-word';
|
|
55
58
|
const pattern = new RegExp(String.raw `^\s*${name}\s*$`, isSensitive ? 'u' : 'iu'), token = new syntax_1.SyntaxToken(magicWord, pattern, 'magic-word-name', config, accum, {});
|
|
56
59
|
super.insertAt(token);
|
|
57
60
|
if (arg.length > 0) {
|
|
@@ -128,6 +131,7 @@ class TranscludeToken extends index_2.Token {
|
|
|
128
131
|
if (this.modifier.includes('\0')) {
|
|
129
132
|
this.setAttribute('modifier', this.buildFromStr(this.modifier, constants_1.BuildMethod.String));
|
|
130
133
|
}
|
|
134
|
+
super.afterBuild();
|
|
131
135
|
}
|
|
132
136
|
/** @private */
|
|
133
137
|
toString() {
|
package/dist/util/debug.js
CHANGED
|
@@ -8,7 +8,11 @@ exports.Shadow = {
|
|
|
8
8
|
const { running } = this;
|
|
9
9
|
this.running = true;
|
|
10
10
|
try {
|
|
11
|
+
const { Token: AnyToken } = require('../src/index');
|
|
11
12
|
const result = callback();
|
|
13
|
+
if (result instanceof AnyToken && !result.getAttribute('built')) {
|
|
14
|
+
result.afterBuild();
|
|
15
|
+
}
|
|
12
16
|
this.running = running;
|
|
13
17
|
return result;
|
|
14
18
|
}
|
|
@@ -17,6 +21,7 @@ exports.Shadow = {
|
|
|
17
21
|
throw e;
|
|
18
22
|
}
|
|
19
23
|
},
|
|
24
|
+
rev: 0,
|
|
20
25
|
};
|
|
21
26
|
/**
|
|
22
27
|
* 是否是某一特定类型的节点
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wikilint",
|
|
3
|
-
"version": "2.9.
|
|
3
|
+
"version": "2.9.3",
|
|
4
4
|
"description": "A Node.js linter for MediaWiki markup",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"mediawiki",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"!/dist/bin/declaration.js"
|
|
25
25
|
],
|
|
26
26
|
"bin": {
|
|
27
|
-
"wikilint": "
|
|
27
|
+
"wikilint": "bin/cli.js"
|
|
28
28
|
},
|
|
29
29
|
"main": "./dist/index.js",
|
|
30
30
|
"types": "./dist/index.d.ts",
|