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/parser/links.js
CHANGED
|
@@ -14,8 +14,9 @@ const regexImg = /^((?:(?!\0\d+!\x7F)[^\n[\]{}|])+)(\||\0\d+!\x7F)([\s\S]*)$/u;
|
|
|
14
14
|
* @param wikitext
|
|
15
15
|
* @param config
|
|
16
16
|
* @param accum
|
|
17
|
+
* @param tidy 是否整理链接
|
|
17
18
|
*/
|
|
18
|
-
const parseLinks = (wikitext, config, accum) => {
|
|
19
|
+
const parseLinks = (wikitext, config, accum, tidy) => {
|
|
19
20
|
config.regexLinks ??= new RegExp(String.raw `^\s*(?:${config.protocol}|//)`, 'iu');
|
|
20
21
|
const regex = true // eslint-disable-line no-constant-condition, @typescript-eslint/no-unnecessary-condition
|
|
21
22
|
? /^((?:(?!\0\d+!\x7F)[^\n[\]{}|])+)(?:(\||\0\d+!\x7F)([\s\S]*?[^\]]))?\]\]([\s\S]*)$/u
|
|
@@ -47,13 +48,13 @@ const parseLinks = (wikitext, config, accum) => {
|
|
|
47
48
|
s += `[[${x}`;
|
|
48
49
|
continue;
|
|
49
50
|
}
|
|
50
|
-
const
|
|
51
|
+
const { ns, valid, } = index_1.default.normalizeTitle(link, 0, false, config, true, true, true, true);
|
|
51
52
|
if (!valid) {
|
|
52
53
|
s += `[[${x}`;
|
|
53
54
|
continue;
|
|
54
55
|
}
|
|
55
56
|
else if (mightBeImg) {
|
|
56
|
-
if (
|
|
57
|
+
if (ns !== 6) {
|
|
57
58
|
s += `[[${x}`;
|
|
58
59
|
continue;
|
|
59
60
|
}
|
|
@@ -74,20 +75,20 @@ const parseLinks = (wikitext, config, accum) => {
|
|
|
74
75
|
break;
|
|
75
76
|
}
|
|
76
77
|
}
|
|
77
|
-
text = (0, exports.parseLinks)(text, config, accum);
|
|
78
|
+
text = (0, exports.parseLinks)(text, config, accum, tidy);
|
|
78
79
|
if (!found) {
|
|
79
80
|
s += `[[${link}${delimiter}${text}`;
|
|
80
81
|
continue;
|
|
81
82
|
}
|
|
82
83
|
}
|
|
83
|
-
text &&= (0, quotes_1.parseQuotes)(text, config, accum);
|
|
84
|
+
text &&= (0, quotes_1.parseQuotes)(text, config, accum, tidy);
|
|
84
85
|
let SomeLinkToken = index_2.LinkToken;
|
|
85
86
|
if (!force) {
|
|
86
|
-
if (
|
|
87
|
+
if (ns === 6) {
|
|
87
88
|
text &&= (0, externalLinks_1.parseExternalLinks)(text, config, accum, true);
|
|
88
89
|
SomeLinkToken = file_1.FileToken;
|
|
89
90
|
}
|
|
90
|
-
else if (
|
|
91
|
+
else if (ns === 14) {
|
|
91
92
|
SomeLinkToken = category_1.CategoryToken;
|
|
92
93
|
}
|
|
93
94
|
}
|
package/dist/parser/list.js
CHANGED
|
@@ -31,7 +31,9 @@ const parseList = (wikitext, state, config, accum) => {
|
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
33
|
state.lastPrefix = prefix2;
|
|
34
|
-
let text = comment
|
|
34
|
+
let text = comment
|
|
35
|
+
+ parts.map((_, i) => `\0${accum.length + i}d\x7F`).join('')
|
|
36
|
+
+ wikitext.slice(total.length);
|
|
35
37
|
for (const part of parts) {
|
|
36
38
|
// @ts-expect-error abstract class
|
|
37
39
|
new list_1.ListToken(part, config, accum);
|
package/dist/parser/quotes.js
CHANGED
|
@@ -8,8 +8,9 @@ const quote_1 = require("../src/nowiki/quote");
|
|
|
8
8
|
* @param wikitext
|
|
9
9
|
* @param config
|
|
10
10
|
* @param accum
|
|
11
|
+
* @param tidy 是否整理
|
|
11
12
|
*/
|
|
12
|
-
const parseQuotes = (wikitext, config, accum) => {
|
|
13
|
+
const parseQuotes = (wikitext, config, accum, tidy) => {
|
|
13
14
|
const arr = wikitext.split(/('{2,})/u), { length } = arr;
|
|
14
15
|
if (length === 1) {
|
|
15
16
|
return wikitext;
|
package/dist/parser/redirect.js
CHANGED
|
@@ -13,7 +13,10 @@ const redirect_1 = require("../src/redirect");
|
|
|
13
13
|
const parseRedirect = (text, config, accum) => {
|
|
14
14
|
config.regexRedirect ??= new RegExp(String.raw `^(\s*)((?:${config.redirection.join('|')})\s*(?::\s*)?)\[\[([^\n|\]]+)(\|.*?)?\]\](\s*)`, 'iu');
|
|
15
15
|
const mt = config.regexRedirect.exec(text);
|
|
16
|
-
if (mt
|
|
16
|
+
if (mt
|
|
17
|
+
&& index_1.default
|
|
18
|
+
.normalizeTitle(mt[3], 0, false, config, true, true, true)
|
|
19
|
+
.valid) {
|
|
17
20
|
text = `\0${accum.length}o\x7F${text.slice(mt[0].length)}`;
|
|
18
21
|
// @ts-expect-error abstract class
|
|
19
22
|
new redirect_1.RedirectToken(...mt.slice(1), config, accum);
|
package/dist/src/arg.d.ts
CHANGED
|
@@ -4,8 +4,10 @@ import { AtomToken } from './atom';
|
|
|
4
4
|
import { HiddenToken } from './hidden';
|
|
5
5
|
import type { LintError } from '../base';
|
|
6
6
|
/**
|
|
7
|
+
* argument wrapped in `{{{}}}`
|
|
8
|
+
*
|
|
7
9
|
* `{{{}}}`包裹的参数
|
|
8
|
-
* @classdesc `{childNodes: [AtomToken, ?Token, ...HiddenToken]}`
|
|
10
|
+
* @classdesc `{childNodes: [AtomToken, ?Token, ...HiddenToken[]]}`
|
|
9
11
|
*/
|
|
10
12
|
export declare abstract class ArgToken extends Token {
|
|
11
13
|
#private;
|
|
@@ -14,7 +16,7 @@ export declare abstract class ArgToken extends Token {
|
|
|
14
16
|
abstract get firstChild(): AtomToken;
|
|
15
17
|
abstract get lastChild(): Token;
|
|
16
18
|
get type(): 'arg';
|
|
17
|
-
/** 预设值 */
|
|
19
|
+
/** default value / 预设值 */
|
|
18
20
|
get default(): string | false;
|
|
19
21
|
/** @param parts 以'|'分隔的各部分 */
|
|
20
22
|
constructor(parts: readonly string[], config?: Parser.Config, accum?: Token[]);
|
package/dist/src/arg.js
CHANGED
|
@@ -9,14 +9,16 @@ const index_2 = require("./index");
|
|
|
9
9
|
const atom_1 = require("./atom");
|
|
10
10
|
const hidden_1 = require("./hidden");
|
|
11
11
|
/**
|
|
12
|
+
* argument wrapped in `{{{}}}`
|
|
13
|
+
*
|
|
12
14
|
* `{{{}}}`包裹的参数
|
|
13
|
-
* @classdesc `{childNodes: [AtomToken, ?Token, ...HiddenToken]}`
|
|
15
|
+
* @classdesc `{childNodes: [AtomToken, ?Token, ...HiddenToken[]]}`
|
|
14
16
|
*/
|
|
15
17
|
class ArgToken extends index_2.Token {
|
|
16
18
|
get type() {
|
|
17
19
|
return 'arg';
|
|
18
20
|
}
|
|
19
|
-
/** 预设值 */
|
|
21
|
+
/** default value / 预设值 */
|
|
20
22
|
get default() {
|
|
21
23
|
return this.childNodes[1]?.text() ?? false;
|
|
22
24
|
}
|
|
@@ -58,11 +60,13 @@ class ArgToken extends index_2.Token {
|
|
|
58
60
|
}
|
|
59
61
|
/** 设置name */
|
|
60
62
|
#setName() {
|
|
61
|
-
|
|
63
|
+
// eslint-disable-next-line no-unused-labels
|
|
64
|
+
LSP: this.setAttribute('name', this.firstChild.toString(true).trim());
|
|
62
65
|
}
|
|
63
66
|
/** @private */
|
|
64
67
|
afterBuild() {
|
|
65
|
-
|
|
68
|
+
// eslint-disable-next-line no-unused-labels
|
|
69
|
+
LSP: this.#setName();
|
|
66
70
|
super.afterBuild();
|
|
67
71
|
}
|
|
68
72
|
/** @private */
|
package/dist/src/atom.d.ts
CHANGED
|
@@ -2,7 +2,11 @@ import { Token } from './index';
|
|
|
2
2
|
import type { Config } from '../base';
|
|
3
3
|
declare const atomTypes: readonly ["arg-name", "attr-key", "attr-value", "ext-attr-dirty", "html-attr-dirty", "table-attr-dirty", "converter-flag", "converter-rule-variant", "converter-rule-to", "converter-rule-from", "invoke-function", "invoke-module", "template-name", "link-target", "param-line"];
|
|
4
4
|
declare type AtomTypes = typeof atomTypes[number];
|
|
5
|
-
/**
|
|
5
|
+
/**
|
|
6
|
+
* plain Token that will not be parsed further
|
|
7
|
+
*
|
|
8
|
+
* 不会被继续解析的plain Token
|
|
9
|
+
*/
|
|
6
10
|
export declare class AtomToken extends Token {
|
|
7
11
|
#private;
|
|
8
12
|
get type(): AtomTypes;
|
package/dist/src/atom.js
CHANGED
|
@@ -20,7 +20,11 @@ const atomTypes = [
|
|
|
20
20
|
'link-target',
|
|
21
21
|
'param-line',
|
|
22
22
|
];
|
|
23
|
-
/**
|
|
23
|
+
/**
|
|
24
|
+
* plain Token that will not be parsed further
|
|
25
|
+
*
|
|
26
|
+
* 不会被继续解析的plain Token
|
|
27
|
+
*/
|
|
24
28
|
class AtomToken extends index_1.Token {
|
|
25
29
|
#type;
|
|
26
30
|
get type() {
|
package/dist/src/attribute.d.ts
CHANGED
|
@@ -6,6 +6,8 @@ import type { AttributesToken } from '../internal';
|
|
|
6
6
|
declare type Child = AtomToken | AttributeToken | undefined;
|
|
7
7
|
export type AttributeTypes = 'ext-attr' | 'html-attr' | 'table-attr';
|
|
8
8
|
/**
|
|
9
|
+
* attribute of extension and HTML tags
|
|
10
|
+
*
|
|
9
11
|
* 扩展和HTML标签属性
|
|
10
12
|
* @classdesc `{childNodes: [AtomToken, Token|AtomToken]}`
|
|
11
13
|
*/
|
|
@@ -19,9 +21,9 @@ export declare abstract class AttributeToken extends Token {
|
|
|
19
21
|
abstract get nextSibling(): Child;
|
|
20
22
|
abstract get previousSibling(): Child;
|
|
21
23
|
get type(): AttributeTypes;
|
|
22
|
-
/** 标签名 */
|
|
24
|
+
/** tag name / 标签名 */
|
|
23
25
|
get tag(): string;
|
|
24
|
-
/** 引号是否匹配 */
|
|
26
|
+
/** whether the quotes are balanced / 引号是否匹配 */
|
|
25
27
|
get balanced(): boolean;
|
|
26
28
|
/**
|
|
27
29
|
* @param type 标签类型
|
|
@@ -32,7 +34,11 @@ export declare abstract class AttributeToken extends Token {
|
|
|
32
34
|
* @param quotes 引号
|
|
33
35
|
*/
|
|
34
36
|
constructor(type: AttributeTypes, tag: string, key: string, equal?: string, value?: string, quotes?: readonly [string?, string?], config?: Parser.Config, accum?: Token[]);
|
|
35
|
-
/**
|
|
37
|
+
/**
|
|
38
|
+
* Get the attribute value
|
|
39
|
+
*
|
|
40
|
+
* 获取属性值
|
|
41
|
+
*/
|
|
36
42
|
getValue(): string | true;
|
|
37
43
|
}
|
|
38
44
|
export {};
|
package/dist/src/attribute.js
CHANGED
|
@@ -11,6 +11,8 @@ const index_2 = require("./index");
|
|
|
11
11
|
const atom_1 = require("./atom");
|
|
12
12
|
const insecureStyle = /expression|(?:accelerator|-o-link(?:-source)?|-o-replace)\s*:|(?:url|image(?:-set)?)\s*\(|attr\s*\([^)]+[\s,]url/u;
|
|
13
13
|
/**
|
|
14
|
+
* attribute of extension and HTML tags
|
|
15
|
+
*
|
|
14
16
|
* 扩展和HTML标签属性
|
|
15
17
|
* @classdesc `{childNodes: [AtomToken, Token|AtomToken]}`
|
|
16
18
|
*/
|
|
@@ -22,11 +24,11 @@ class AttributeToken extends index_2.Token {
|
|
|
22
24
|
get type() {
|
|
23
25
|
return this.#type;
|
|
24
26
|
}
|
|
25
|
-
/** 标签名 */
|
|
27
|
+
/** tag name / 标签名 */
|
|
26
28
|
get tag() {
|
|
27
29
|
return this.#tag;
|
|
28
30
|
}
|
|
29
|
-
/** 引号是否匹配 */
|
|
31
|
+
/** whether the quotes are balanced / 引号是否匹配 */
|
|
30
32
|
get balanced() {
|
|
31
33
|
return !this.#equal || this.#quotes[0] === this.#quotes[1];
|
|
32
34
|
}
|
|
@@ -129,7 +131,11 @@ class AttributeToken extends index_2.Token {
|
|
|
129
131
|
}
|
|
130
132
|
return errors;
|
|
131
133
|
}
|
|
132
|
-
/**
|
|
134
|
+
/**
|
|
135
|
+
* Get the attribute value
|
|
136
|
+
*
|
|
137
|
+
* 获取属性值
|
|
138
|
+
*/
|
|
133
139
|
getValue() {
|
|
134
140
|
return this.#equal ? this.lastChild.text().trim() : this.type === 'ext-attr' || '';
|
|
135
141
|
}
|
package/dist/src/attributes.d.ts
CHANGED
|
@@ -9,8 +9,10 @@ import type { TableTokens } from './table/index';
|
|
|
9
9
|
declare type AttributesTypes = `${AttributeTypes}s`;
|
|
10
10
|
declare type Child = AtomToken | AttributeToken;
|
|
11
11
|
/**
|
|
12
|
+
* attributes of extension and HTML tags
|
|
13
|
+
*
|
|
12
14
|
* 扩展和HTML标签属性
|
|
13
|
-
* @classdesc `{childNodes:
|
|
15
|
+
* @classdesc `{childNodes: (AtomToken|AttributeToken)[]}`
|
|
14
16
|
*/
|
|
15
17
|
export declare abstract class AttributesToken extends Token {
|
|
16
18
|
#private;
|
|
@@ -28,18 +30,24 @@ export declare abstract class AttributesToken extends Token {
|
|
|
28
30
|
*/
|
|
29
31
|
constructor(attr: string | undefined, type: AttributesTypes, name: string, config?: Parser.Config, accum?: Token[]);
|
|
30
32
|
/**
|
|
33
|
+
* Get all AttributeTokens with the specified attribute name
|
|
34
|
+
*
|
|
31
35
|
* 所有指定属性名的AttributeToken
|
|
32
|
-
* @param key 属性名
|
|
36
|
+
* @param key attribute name / 属性名
|
|
33
37
|
*/
|
|
34
38
|
getAttrTokens(key?: string): AttributeToken[];
|
|
35
39
|
/**
|
|
40
|
+
* Get the last AttributeToken with the specified attribute name
|
|
41
|
+
*
|
|
36
42
|
* 指定属性名的最后一个AttributeToken
|
|
37
|
-
* @param key 属性名
|
|
43
|
+
* @param key attribute name / 属性名
|
|
38
44
|
*/
|
|
39
45
|
getAttrToken(key: string): AttributeToken | undefined;
|
|
40
46
|
/**
|
|
47
|
+
* Get the attribute
|
|
48
|
+
*
|
|
41
49
|
* 获取指定属性
|
|
42
|
-
* @param key 属性键
|
|
50
|
+
* @param key attribute name / 属性键
|
|
43
51
|
*/
|
|
44
52
|
getAttr(key: string): string | true | undefined;
|
|
45
53
|
}
|
package/dist/src/attributes.js
CHANGED
|
@@ -27,8 +27,10 @@ catch /* istanbul ignore next */ {
|
|
|
27
27
|
wordRegex = /[^\W_]/u;
|
|
28
28
|
}
|
|
29
29
|
/**
|
|
30
|
+
* attributes of extension and HTML tags
|
|
31
|
+
*
|
|
30
32
|
* 扩展和HTML标签属性
|
|
31
|
-
* @classdesc `{childNodes:
|
|
33
|
+
* @classdesc `{childNodes: (AtomToken|AttributeToken)[]}`
|
|
32
34
|
*/
|
|
33
35
|
class AttributesToken extends index_2.Token {
|
|
34
36
|
#type;
|
|
@@ -82,23 +84,29 @@ class AttributesToken extends index_2.Token {
|
|
|
82
84
|
super.afterBuild();
|
|
83
85
|
}
|
|
84
86
|
/**
|
|
87
|
+
* Get all AttributeTokens with the specified attribute name
|
|
88
|
+
*
|
|
85
89
|
* 所有指定属性名的AttributeToken
|
|
86
|
-
* @param key 属性名
|
|
90
|
+
* @param key attribute name / 属性名
|
|
87
91
|
*/
|
|
88
92
|
getAttrTokens(key) {
|
|
89
93
|
return this.childNodes.filter((child) => child instanceof attribute_1.AttributeToken && (!key || child.name === key.toLowerCase().trim()));
|
|
90
94
|
}
|
|
91
95
|
/**
|
|
96
|
+
* Get the last AttributeToken with the specified attribute name
|
|
97
|
+
*
|
|
92
98
|
* 指定属性名的最后一个AttributeToken
|
|
93
|
-
* @param key 属性名
|
|
99
|
+
* @param key attribute name / 属性名
|
|
94
100
|
*/
|
|
95
101
|
getAttrToken(key) {
|
|
96
102
|
const tokens = this.getAttrTokens(key);
|
|
97
103
|
return tokens[tokens.length - 1];
|
|
98
104
|
}
|
|
99
105
|
/**
|
|
106
|
+
* Get the attribute
|
|
107
|
+
*
|
|
100
108
|
* 获取指定属性
|
|
101
|
-
* @param key 属性键
|
|
109
|
+
* @param key attribute name / 属性键
|
|
102
110
|
*/
|
|
103
111
|
getAttr(key) {
|
|
104
112
|
return this.getAttrToken(key)?.getValue();
|
package/dist/src/converter.d.ts
CHANGED
|
@@ -3,8 +3,10 @@ import { Token } from './index';
|
|
|
3
3
|
import { ConverterFlagsToken } from './converterFlags';
|
|
4
4
|
import { ConverterRuleToken } from './converterRule';
|
|
5
5
|
/**
|
|
6
|
+
* language conversion
|
|
7
|
+
*
|
|
6
8
|
* 转换
|
|
7
|
-
* @classdesc `{childNodes: [ConverterFlagsToken, ...ConverterRuleToken]}`
|
|
9
|
+
* @classdesc `{childNodes: [ConverterFlagsToken, ...ConverterRuleToken[]]}`
|
|
8
10
|
*/
|
|
9
11
|
export declare abstract class ConverterToken extends Token {
|
|
10
12
|
readonly childNodes: readonly [ConverterFlagsToken, ConverterRuleToken, ...ConverterRuleToken[]];
|
package/dist/src/converter.js
CHANGED
|
@@ -7,8 +7,10 @@ const index_2 = require("./index");
|
|
|
7
7
|
const converterFlags_1 = require("./converterFlags");
|
|
8
8
|
const converterRule_1 = require("./converterRule");
|
|
9
9
|
/**
|
|
10
|
+
* language conversion
|
|
11
|
+
*
|
|
10
12
|
* 转换
|
|
11
|
-
* @classdesc `{childNodes: [ConverterFlagsToken, ...ConverterRuleToken]}`
|
|
13
|
+
* @classdesc `{childNodes: [ConverterFlagsToken, ...ConverterRuleToken[]]}`
|
|
12
14
|
*/
|
|
13
15
|
class ConverterToken extends index_2.Token {
|
|
14
16
|
get type() {
|
|
@@ -27,13 +29,14 @@ class ConverterToken extends index_2.Token {
|
|
|
27
29
|
firstRuleToken = new converterRule_1.ConverterRuleToken(firstRule, hasColon, config, accum);
|
|
28
30
|
if (hasColon && firstRuleToken.length === 1
|
|
29
31
|
|| !hasColon && rules.length === 2 && !(0, string_1.removeComment)(rules[1]).trim()) {
|
|
32
|
+
this.insertAt(
|
|
30
33
|
// @ts-expect-error abstract class
|
|
31
|
-
|
|
34
|
+
new converterRule_1.ConverterRuleToken(rules.join(';'), false, config, accum));
|
|
32
35
|
}
|
|
33
36
|
else {
|
|
34
|
-
this.append(firstRuleToken,
|
|
35
|
-
|
|
36
|
-
|
|
37
|
+
this.append(firstRuleToken, ...rules.slice(1)
|
|
38
|
+
// @ts-expect-error abstract class
|
|
39
|
+
.map(rule => new converterRule_1.ConverterRuleToken(rule, true, config, accum)));
|
|
37
40
|
}
|
|
38
41
|
}
|
|
39
42
|
/** @private */
|
|
@@ -4,8 +4,10 @@ import { AtomToken } from './atom';
|
|
|
4
4
|
import type { LintError } from '../base';
|
|
5
5
|
import type { ConverterToken, ConverterRuleToken } from '../internal';
|
|
6
6
|
/**
|
|
7
|
+
* flags for language conversion
|
|
8
|
+
*
|
|
7
9
|
* 转换flags
|
|
8
|
-
* @classdesc `{childNodes:
|
|
10
|
+
* @classdesc `{childNodes: AtomToken[]}`
|
|
9
11
|
*/
|
|
10
12
|
export declare abstract class ConverterFlagsToken extends Token {
|
|
11
13
|
#private;
|
|
@@ -18,8 +20,16 @@ export declare abstract class ConverterFlagsToken extends Token {
|
|
|
18
20
|
get type(): 'converter-flags';
|
|
19
21
|
/** @param flags 转换类型标记 */
|
|
20
22
|
constructor(flags: readonly string[], config?: Parser.Config, accum?: Token[]);
|
|
21
|
-
/**
|
|
23
|
+
/**
|
|
24
|
+
* Get unknown language conversion flags
|
|
25
|
+
*
|
|
26
|
+
* 获取未知的转换类型标记
|
|
27
|
+
*/
|
|
22
28
|
getUnknownFlags(): Set<string>;
|
|
23
|
-
/**
|
|
29
|
+
/**
|
|
30
|
+
* Get language coversion flags that specify a language variant
|
|
31
|
+
*
|
|
32
|
+
* 获取指定语言变体的转换标记
|
|
33
|
+
*/
|
|
24
34
|
getVariantFlags(): Set<string>;
|
|
25
35
|
}
|
|
@@ -8,8 +8,10 @@ const index_2 = require("./index");
|
|
|
8
8
|
const atom_1 = require("./atom");
|
|
9
9
|
const definedFlags = new Set(['A', 'T', 'R', 'D', '-', 'H', 'N']);
|
|
10
10
|
/**
|
|
11
|
+
* flags for language conversion
|
|
12
|
+
*
|
|
11
13
|
* 转换flags
|
|
12
|
-
* @classdesc `{childNodes:
|
|
14
|
+
* @classdesc `{childNodes: AtomToken[]}`
|
|
13
15
|
*/
|
|
14
16
|
class ConverterFlagsToken extends index_2.Token {
|
|
15
17
|
#flags;
|
|
@@ -38,11 +40,19 @@ class ConverterFlagsToken extends index_2.Token {
|
|
|
38
40
|
getGaps() {
|
|
39
41
|
return 1;
|
|
40
42
|
}
|
|
41
|
-
/**
|
|
43
|
+
/**
|
|
44
|
+
* Get unknown language conversion flags
|
|
45
|
+
*
|
|
46
|
+
* 获取未知的转换类型标记
|
|
47
|
+
*/
|
|
42
48
|
getUnknownFlags() {
|
|
43
49
|
return new Set(this.#flags.filter(flag => /\{{3}[^{}]+\}{3}/u.test(flag)));
|
|
44
50
|
}
|
|
45
|
-
/**
|
|
51
|
+
/**
|
|
52
|
+
* Get language coversion flags that specify a language variant
|
|
53
|
+
*
|
|
54
|
+
* 获取指定语言变体的转换标记
|
|
55
|
+
*/
|
|
46
56
|
getVariantFlags() {
|
|
47
57
|
const variants = new Set(this.getAttribute('config').variants);
|
|
48
58
|
return new Set(this.#flags.filter(flag => variants.has(flag)));
|
|
@@ -3,8 +3,10 @@ import { Token } from './index';
|
|
|
3
3
|
import { AtomToken } from './atom';
|
|
4
4
|
import type { ConverterToken, ConverterFlagsToken } from '../internal';
|
|
5
5
|
/**
|
|
6
|
+
* language conversion rule
|
|
7
|
+
*
|
|
6
8
|
* 转换规则
|
|
7
|
-
* @classdesc `{childNodes:
|
|
9
|
+
* @classdesc `{childNodes: AtomToken[]}`
|
|
8
10
|
*/
|
|
9
11
|
export declare abstract class ConverterRuleToken extends Token {
|
|
10
12
|
readonly childNodes: readonly [AtomToken] | readonly [AtomToken, AtomToken] | readonly [AtomToken, AtomToken, AtomToken];
|
|
@@ -5,8 +5,10 @@ const index_1 = require("../index");
|
|
|
5
5
|
const index_2 = require("./index");
|
|
6
6
|
const atom_1 = require("./atom");
|
|
7
7
|
/**
|
|
8
|
+
* language conversion rule
|
|
9
|
+
*
|
|
8
10
|
* 转换规则
|
|
9
|
-
* @classdesc `{childNodes:
|
|
11
|
+
* @classdesc `{childNodes: AtomToken[]}`
|
|
10
12
|
*/
|
|
11
13
|
class ConverterRuleToken extends index_2.Token {
|
|
12
14
|
get type() {
|
package/dist/src/extLink.d.ts
CHANGED
package/dist/src/extLink.js
CHANGED
package/dist/src/gallery.d.ts
CHANGED
|
@@ -6,8 +6,10 @@ import type { LintError } from '../base';
|
|
|
6
6
|
import type { AstText, AttributesToken, ExtToken } from '../internal';
|
|
7
7
|
declare type Child = GalleryImageToken | NoincludeToken;
|
|
8
8
|
/**
|
|
9
|
+
* gallery tag
|
|
10
|
+
*
|
|
9
11
|
* gallery标签
|
|
10
|
-
* @classdesc `{childNodes:
|
|
12
|
+
* @classdesc `{childNodes: (GalleryImageToken|NoincludeToken|AstText)[]}`
|
|
11
13
|
*/
|
|
12
14
|
export declare abstract class GalleryToken extends Token {
|
|
13
15
|
#private;
|
package/dist/src/gallery.js
CHANGED
|
@@ -6,8 +6,10 @@ const index_2 = require("./index");
|
|
|
6
6
|
const galleryImage_1 = require("./link/galleryImage");
|
|
7
7
|
const noinclude_1 = require("./nowiki/noinclude");
|
|
8
8
|
/**
|
|
9
|
+
* gallery tag
|
|
10
|
+
*
|
|
9
11
|
* gallery标签
|
|
10
|
-
* @classdesc `{childNodes:
|
|
12
|
+
* @classdesc `{childNodes: (GalleryImageToken|NoincludeToken|AstText)[]}`
|
|
11
13
|
*/
|
|
12
14
|
class GalleryToken extends index_2.Token {
|
|
13
15
|
get type() {
|
|
@@ -39,7 +41,7 @@ class GalleryToken extends index_2.Token {
|
|
|
39
41
|
* @param file 文件名
|
|
40
42
|
*/
|
|
41
43
|
#checkFile(file) {
|
|
42
|
-
return this.normalizeTitle(file, 6, true, true).valid;
|
|
44
|
+
return this.normalizeTitle(file, 6, true, true, true).valid;
|
|
43
45
|
}
|
|
44
46
|
/** @private */
|
|
45
47
|
toString(skip) {
|
|
@@ -57,8 +59,8 @@ class GalleryToken extends index_2.Token {
|
|
|
57
59
|
lint(start = this.getAbsoluteIndex(), re) {
|
|
58
60
|
const { top, left } = this.getRootNode().posFromIndex(start), errors = [];
|
|
59
61
|
for (const [i, child] of this.childNodes.entries()) {
|
|
60
|
-
const str = child.toString(), { length } = str, trimmed = str.trim(), startLine = top + i, startCol = i ? 0 : left;
|
|
61
|
-
if (
|
|
62
|
+
const str = child.toString(), { length } = str, trimmed = str.trim(), { type } = child, startLine = top + i, startCol = i ? 0 : left;
|
|
63
|
+
if (type === 'noinclude' && trimmed && !/^<!--.*-->$/u.test(trimmed)) {
|
|
62
64
|
const endIndex = start + length;
|
|
63
65
|
errors.push({
|
|
64
66
|
rule: 'no-ignored',
|
|
@@ -76,7 +78,7 @@ class GalleryToken extends index_2.Token {
|
|
|
76
78
|
],
|
|
77
79
|
});
|
|
78
80
|
}
|
|
79
|
-
else if (
|
|
81
|
+
else if (type !== 'noinclude' && type !== 'text') {
|
|
80
82
|
errors.push(...child.lint(start, re));
|
|
81
83
|
}
|
|
82
84
|
start += length + 1;
|
package/dist/src/heading.d.ts
CHANGED
|
@@ -4,6 +4,8 @@ import { SyntaxToken } from './syntax';
|
|
|
4
4
|
import type { LintError } from '../base';
|
|
5
5
|
import type { AstText } from '../internal';
|
|
6
6
|
/**
|
|
7
|
+
* section heading
|
|
8
|
+
*
|
|
7
9
|
* 章节标题
|
|
8
10
|
* @classdesc `{childNodes: [Token, SyntaxToken]}`
|
|
9
11
|
*/
|
|
@@ -14,7 +16,7 @@ export declare abstract class HeadingToken extends Token {
|
|
|
14
16
|
abstract get lastChild(): SyntaxToken;
|
|
15
17
|
abstract get nextSibling(): AstText | undefined;
|
|
16
18
|
get type(): 'heading';
|
|
17
|
-
/** 标题层级 */
|
|
19
|
+
/** level of the heading / 标题层级 */
|
|
18
20
|
get level(): number;
|
|
19
21
|
/**
|
|
20
22
|
* @param level 标题层级
|
package/dist/src/heading.js
CHANGED
|
@@ -8,6 +8,8 @@ const index_1 = require("../index");
|
|
|
8
8
|
const index_2 = require("./index");
|
|
9
9
|
const syntax_1 = require("./syntax");
|
|
10
10
|
/**
|
|
11
|
+
* section heading
|
|
12
|
+
*
|
|
11
13
|
* 章节标题
|
|
12
14
|
* @classdesc `{childNodes: [Token, SyntaxToken]}`
|
|
13
15
|
*/
|
|
@@ -16,11 +18,7 @@ class HeadingToken extends index_2.Token {
|
|
|
16
18
|
get type() {
|
|
17
19
|
return 'heading';
|
|
18
20
|
}
|
|
19
|
-
/**
|
|
20
|
-
get #equals() {
|
|
21
|
-
return '='.repeat(this.level);
|
|
22
|
-
}
|
|
23
|
-
/** 标题层级 */
|
|
21
|
+
/** level of the heading / 标题层级 */
|
|
24
22
|
get level() {
|
|
25
23
|
return this.#level;
|
|
26
24
|
}
|
|
@@ -37,14 +35,18 @@ class HeadingToken extends index_2.Token {
|
|
|
37
35
|
const trail = new syntax_1.SyntaxToken(input[1], /^\s*$/u, 'heading-trail', config, accum, {});
|
|
38
36
|
this.append(token, trail);
|
|
39
37
|
}
|
|
38
|
+
/** 标题格式的等号 */
|
|
39
|
+
#getEquals() {
|
|
40
|
+
return '='.repeat(this.level);
|
|
41
|
+
}
|
|
40
42
|
/** @private */
|
|
41
43
|
toString(skip) {
|
|
42
|
-
const equals = this.#
|
|
44
|
+
const equals = this.#getEquals();
|
|
43
45
|
return equals + this.firstChild.toString(skip) + equals + this.lastChild.toString(skip);
|
|
44
46
|
}
|
|
45
47
|
/** @private */
|
|
46
48
|
text() {
|
|
47
|
-
const equals = this.#
|
|
49
|
+
const equals = this.#getEquals();
|
|
48
50
|
return equals + this.firstChild.text() + equals;
|
|
49
51
|
}
|
|
50
52
|
/** @private */
|
|
@@ -87,7 +89,7 @@ class HeadingToken extends index_2.Token {
|
|
|
87
89
|
errors.push(e);
|
|
88
90
|
}
|
|
89
91
|
if (this.closest('html-attrs,table-attrs')) {
|
|
90
|
-
errors.push((0, lint_1.generateForSelf)(this, rect, 'parsing-order', 'section header in
|
|
92
|
+
errors.push((0, lint_1.generateForSelf)(this, rect, 'parsing-order', 'section header in an HTML tag'));
|
|
91
93
|
}
|
|
92
94
|
const rootStr = this.getRootNode().toString();
|
|
93
95
|
if (boldQuotes.length % 2) {
|
package/dist/src/hidden.d.ts
CHANGED
package/dist/src/hidden.js
CHANGED
|
@@ -37,7 +37,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
37
37
|
exports.HiddenToken = void 0;
|
|
38
38
|
const hidden_1 = require("../mixin/hidden");
|
|
39
39
|
const index_1 = require("./index");
|
|
40
|
-
/**
|
|
40
|
+
/**
|
|
41
|
+
* invisible token
|
|
42
|
+
*
|
|
43
|
+
* 不可见的节点
|
|
44
|
+
*/
|
|
41
45
|
let HiddenToken = (() => {
|
|
42
46
|
let _classDecorators = [(0, hidden_1.hiddenToken)()];
|
|
43
47
|
let _classDescriptor;
|