wikilint 1.0.1 → 1.1.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/README.md +1 -1
- package/dist/index.d.ts +110 -0
- package/dist/lib/element.d.ts +42 -0
- package/dist/lib/node.d.ts +102 -0
- package/dist/lib/text.d.ts +30 -0
- package/dist/lib/title.d.ts +15 -0
- package/dist/mixin/hidden.d.ts +8 -0
- package/dist/parser/brackets.d.ts +12 -0
- package/dist/parser/commentAndExt.d.ts +8 -0
- package/dist/parser/converter.d.ts +7 -0
- package/dist/parser/externalLinks.d.ts +7 -0
- package/dist/parser/hrAndDoubleUnderscore.d.ts +11 -0
- package/dist/parser/html.d.ts +7 -0
- package/dist/parser/links.d.ts +7 -0
- package/dist/parser/list.d.ts +7 -0
- package/dist/parser/magicLinks.d.ts +7 -0
- package/dist/parser/quotes.d.ts +7 -0
- package/dist/parser/table.d.ts +11 -0
- package/dist/src/arg.d.ts +31 -0
- package/dist/src/atom/hidden.d.ts +5 -0
- package/dist/src/atom/index.d.ts +14 -0
- package/dist/src/attribute.d.ts +47 -0
- package/dist/src/attributes.d.ts +41 -0
- package/dist/src/converter.d.ts +29 -0
- package/dist/src/converterFlags.d.ts +32 -0
- package/dist/src/converterRule.d.ts +29 -0
- package/dist/src/extLink.d.ts +22 -0
- package/dist/src/gallery.d.ts +24 -0
- package/dist/src/hasNowiki/index.d.ts +14 -0
- package/dist/src/hasNowiki/pre.d.ts +13 -0
- package/dist/src/heading.d.ts +29 -0
- package/dist/src/html.d.ts +38 -0
- package/dist/src/imageParameter.d.ts +31 -0
- package/dist/src/imagemap.d.ts +31 -0
- package/dist/src/imagemapLink.d.ts +16 -0
- package/dist/src/index.d.ts +53 -0
- package/dist/src/link/category.d.ts +8 -0
- package/dist/src/link/file.d.ts +27 -0
- package/dist/src/link/galleryImage.d.ts +15 -0
- package/dist/src/link/index.d.ts +34 -0
- package/dist/src/magicLink.d.ts +19 -0
- package/dist/src/nested/choose.d.ts +13 -0
- package/dist/src/nested/combobox.d.ts +13 -0
- package/dist/src/nested/index.d.ts +20 -0
- package/dist/src/nested/references.d.ts +13 -0
- package/dist/src/nowiki/comment.d.ts +19 -0
- package/dist/src/nowiki/dd.d.ts +8 -0
- package/dist/src/nowiki/doubleUnderscore.d.ts +12 -0
- package/dist/src/nowiki/hr.d.ts +13 -0
- package/dist/src/nowiki/index.d.ts +18 -0
- package/dist/src/nowiki/list.d.ts +8 -0
- package/dist/src/nowiki/noinclude.d.ts +8 -0
- package/dist/src/nowiki/quote.d.ts +20 -0
- package/dist/src/onlyinclude.d.ts +17 -0
- package/dist/src/paramTag/index.d.ts +24 -0
- package/dist/src/paramTag/inputbox.d.ts +8 -0
- package/dist/src/parameter.d.ts +33 -0
- package/dist/src/syntax.d.ts +15 -0
- package/dist/src/table/index.d.ts +16 -0
- package/dist/src/table/td.d.ts +39 -0
- package/dist/src/table/tr.d.ts +22 -0
- package/dist/src/tagPair/ext.d.ts +22 -0
- package/dist/src/tagPair/include.d.ts +16 -0
- package/dist/src/tagPair/index.d.ts +28 -0
- package/dist/src/transclude.d.ts +80 -0
- package/dist/util/lint.d.ts +28 -0
- package/dist/util/string.d.ts +31 -0
- package/index.js +1 -1
- package/lib/element.js +1 -1
- package/lib/node.js +5 -0
- package/lib/text.js +2 -0
- package/package.json +9 -2
- package/parser/brackets.js +3 -1
- package/parser/commentAndExt.js +1 -1
- package/parser/converter.js +1 -1
- package/parser/externalLinks.js +1 -1
- package/parser/hrAndDoubleUnderscore.js +1 -1
- package/parser/html.js +1 -1
- package/parser/links.js +1 -1
- package/parser/list.js +1 -1
- package/parser/magicLinks.js +1 -1
- package/parser/quotes.js +1 -1
- package/parser/table.js +1 -1
- package/src/arg.js +2 -2
- package/src/atom/index.js +1 -1
- package/src/attribute.js +3 -1
- package/src/attributes.js +1 -1
- package/src/converter.js +1 -1
- package/src/converterFlags.js +1 -1
- package/src/converterRule.js +1 -1
- package/src/extLink.js +1 -1
- package/src/gallery.js +2 -2
- package/src/hasNowiki/index.js +1 -1
- package/src/hasNowiki/pre.js +1 -1
- package/src/heading.js +1 -1
- package/src/html.js +2 -2
- package/src/imageParameter.js +1 -1
- package/src/imagemap.js +1 -1
- package/src/imagemapLink.js +1 -1
- package/src/index.js +6 -1
- package/src/link/file.js +1 -1
- package/src/link/galleryImage.js +1 -1
- package/src/link/index.js +2 -2
- package/src/magicLink.js +1 -1
- package/src/nested/choose.js +1 -1
- package/src/nested/combobox.js +1 -1
- package/src/nested/index.js +1 -1
- package/src/nested/references.js +1 -1
- package/src/nowiki/comment.js +1 -1
- package/src/nowiki/hr.js +1 -1
- package/src/nowiki/index.js +1 -1
- package/src/nowiki/quote.js +2 -2
- package/src/onlyinclude.js +1 -1
- package/src/paramTag/index.js +1 -1
- package/src/paramTag/inputbox.js +1 -1
- package/src/parameter.js +1 -1
- package/src/syntax.js +1 -1
- package/src/table/td.js +1 -1
- package/src/table/tr.js +1 -1
- package/src/tagPair/ext.js +3 -2
- package/src/tagPair/include.js +1 -1
- package/src/tagPair/index.js +1 -1
- package/src/transclude.js +1 -1
- package/typings/api.d.ts +9 -0
- package/typings/index.d.ts +50 -0
- package/typings/node.d.ts +16 -0
- package/typings/parser.d.ts +5 -0
- package/typings/token.d.ts +28 -0
- package/util/lint.js +2 -0
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@ This is a minimal version of [wikiparser-node](https://www.npmjs.com/package/wik
|
|
|
7
7
|
You can also directly lint Wikitext articles in the command line using this package:
|
|
8
8
|
|
|
9
9
|
```sh
|
|
10
|
-
wikilint --config zhwiki --include *.wiki
|
|
10
|
+
npx wikilint --config zhwiki --include *.wiki
|
|
11
11
|
```
|
|
12
12
|
|
|
13
13
|
## CLI Options
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import AstElement = require("./lib/element.js")
|
|
2
|
+
import AstNode = require("./lib/node.js")
|
|
3
|
+
import AstText = require("./lib/text.js")
|
|
4
|
+
import Title = require("./lib/title.js")
|
|
5
|
+
import ArgToken = require("./src/arg.js")
|
|
6
|
+
import HiddenToken = require("./src/atom/hidden.js")
|
|
7
|
+
import AtomToken = require("./src/atom/index.js")
|
|
8
|
+
import AttributeToken = require("./src/attribute.js")
|
|
9
|
+
import AttributesToken = require("./src/attributes.js")
|
|
10
|
+
import ConverterToken = require("./src/converter.js")
|
|
11
|
+
import ConverterFlagsToken = require("./src/converterFlags.js")
|
|
12
|
+
import ConverterRuleToken = require("./src/converterRule.js")
|
|
13
|
+
import ExtLinkToken = require("./src/extLink.js")
|
|
14
|
+
import GalleryToken = require("./src/gallery.js")
|
|
15
|
+
import HasNowikiToken = require("./src/hasNowiki/index.js")
|
|
16
|
+
import PreToken = require("./src/hasNowiki/pre.js")
|
|
17
|
+
import HeadingToken = require("./src/heading.js")
|
|
18
|
+
import HtmlToken = require("./src/html.js")
|
|
19
|
+
import ImageParameterToken = require("./src/imageParameter.js")
|
|
20
|
+
import ImagemapToken = require("./src/imagemap.js")
|
|
21
|
+
import ImagemapLinkToken = require("./src/imagemapLink.js")
|
|
22
|
+
import Token = require("./src/index.js")
|
|
23
|
+
import CategoryToken = require("./src/link/category.js")
|
|
24
|
+
import FileToken = require("./src/link/file.js")
|
|
25
|
+
import GalleryImageToken = require("./src/link/galleryImage.js")
|
|
26
|
+
import LinkToken = require("./src/link/index.js")
|
|
27
|
+
import MagicLinkToken = require("./src/magicLink.js")
|
|
28
|
+
import ChooseToken = require("./src/nested/choose.js")
|
|
29
|
+
import ComboboxToken = require("./src/nested/combobox.js")
|
|
30
|
+
import NestedToken = require("./src/nested/index.js")
|
|
31
|
+
import ReferencesToken = require("./src/nested/references.js")
|
|
32
|
+
import CommentToken = require("./src/nowiki/comment.js")
|
|
33
|
+
import DdToken = require("./src/nowiki/dd.js")
|
|
34
|
+
import DoubleUnderscoreToken = require("./src/nowiki/doubleUnderscore.js")
|
|
35
|
+
import HrToken = require("./src/nowiki/hr.js")
|
|
36
|
+
import NowikiToken = require("./src/nowiki/index.js")
|
|
37
|
+
import ListToken = require("./src/nowiki/list.js")
|
|
38
|
+
import NoincludeToken = require("./src/nowiki/noinclude.js")
|
|
39
|
+
import QuoteToken = require("./src/nowiki/quote.js")
|
|
40
|
+
import OnlyincludeToken = require("./src/onlyinclude.js")
|
|
41
|
+
import ParamTagToken = require("./src/paramTag/index.js")
|
|
42
|
+
import InputboxToken = require("./src/paramTag/inputbox.js")
|
|
43
|
+
import ParameterToken = require("./src/parameter.js")
|
|
44
|
+
import SyntaxToken = require("./src/syntax.js")
|
|
45
|
+
import TableToken = require("./src/table/index.js")
|
|
46
|
+
import TdToken = require("./src/table/td.js")
|
|
47
|
+
import TrToken = require("./src/table/tr.js")
|
|
48
|
+
import ExtToken = require("./src/tagPair/ext.js")
|
|
49
|
+
import IncludeToken = require("./src/tagPair/include.js")
|
|
50
|
+
import TagPairToken = require("./src/tagPair/index.js")
|
|
51
|
+
import TranscludeToken = require("./src/transclude.js")
|
|
52
|
+
|
|
53
|
+
export = Parser;
|
|
54
|
+
declare const Parser: import('./../typings');
|
|
55
|
+
|
|
56
|
+
declare namespace Parser {
|
|
57
|
+
export {
|
|
58
|
+
AstElement,
|
|
59
|
+
AstNode,
|
|
60
|
+
AstText,
|
|
61
|
+
Title,
|
|
62
|
+
ArgToken,
|
|
63
|
+
HiddenToken,
|
|
64
|
+
AtomToken,
|
|
65
|
+
AttributeToken,
|
|
66
|
+
AttributesToken,
|
|
67
|
+
ConverterToken,
|
|
68
|
+
ConverterFlagsToken,
|
|
69
|
+
ConverterRuleToken,
|
|
70
|
+
ExtLinkToken,
|
|
71
|
+
GalleryToken,
|
|
72
|
+
HasNowikiToken,
|
|
73
|
+
PreToken,
|
|
74
|
+
HeadingToken,
|
|
75
|
+
HtmlToken,
|
|
76
|
+
ImageParameterToken,
|
|
77
|
+
ImagemapToken,
|
|
78
|
+
ImagemapLinkToken,
|
|
79
|
+
Token,
|
|
80
|
+
CategoryToken,
|
|
81
|
+
FileToken,
|
|
82
|
+
GalleryImageToken,
|
|
83
|
+
LinkToken,
|
|
84
|
+
MagicLinkToken,
|
|
85
|
+
ChooseToken,
|
|
86
|
+
ComboboxToken,
|
|
87
|
+
NestedToken,
|
|
88
|
+
ReferencesToken,
|
|
89
|
+
CommentToken,
|
|
90
|
+
DdToken,
|
|
91
|
+
DoubleUnderscoreToken,
|
|
92
|
+
HrToken,
|
|
93
|
+
NowikiToken,
|
|
94
|
+
ListToken,
|
|
95
|
+
NoincludeToken,
|
|
96
|
+
QuoteToken,
|
|
97
|
+
OnlyincludeToken,
|
|
98
|
+
ParamTagToken,
|
|
99
|
+
InputboxToken,
|
|
100
|
+
ParameterToken,
|
|
101
|
+
SyntaxToken,
|
|
102
|
+
TableToken,
|
|
103
|
+
TdToken,
|
|
104
|
+
TrToken,
|
|
105
|
+
ExtToken,
|
|
106
|
+
IncludeToken,
|
|
107
|
+
TagPairToken,
|
|
108
|
+
TranscludeToken,
|
|
109
|
+
}
|
|
110
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
export = AstElement;
|
|
2
|
+
/** 类似HTMLElement */
|
|
3
|
+
declare class AstElement extends AstNode {
|
|
4
|
+
/** @type {string} */ name: string;
|
|
5
|
+
/** 子节点总数 */
|
|
6
|
+
get length(): number;
|
|
7
|
+
/**
|
|
8
|
+
* 最近的祖先节点
|
|
9
|
+
* @param {string} selector
|
|
10
|
+
*/
|
|
11
|
+
closest(selector: string): AstElement;
|
|
12
|
+
/**
|
|
13
|
+
* 在末尾批量插入子节点
|
|
14
|
+
* @param {...this} elements 插入节点
|
|
15
|
+
* @complexity `n`
|
|
16
|
+
*/
|
|
17
|
+
append(...elements: AstElement[]): void;
|
|
18
|
+
/**
|
|
19
|
+
* 批量替换子节点
|
|
20
|
+
* @param {...this} elements 新的子节点
|
|
21
|
+
* @complexity `n`
|
|
22
|
+
*/
|
|
23
|
+
replaceChildren(...elements: AstElement[]): void;
|
|
24
|
+
/**
|
|
25
|
+
* 修改文本子节点
|
|
26
|
+
* @param {string} str 新文本
|
|
27
|
+
* @param {number} i 子节点位置
|
|
28
|
+
*/
|
|
29
|
+
setText(str: string, i?: number): string;
|
|
30
|
+
/**
|
|
31
|
+
* 还原为wikitext
|
|
32
|
+
* @param {string} separator 子节点间的连接符
|
|
33
|
+
* @returns {string}
|
|
34
|
+
*/
|
|
35
|
+
toString(selector: any, separator?: string): string;
|
|
36
|
+
/**
|
|
37
|
+
* Linter
|
|
38
|
+
* @param {number} start 起始位置
|
|
39
|
+
*/
|
|
40
|
+
lint(start?: number): import("../../typings/token").LintError[];
|
|
41
|
+
}
|
|
42
|
+
import AstNode = require("./node");
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
export = AstNode;
|
|
2
|
+
/** 类似Node */
|
|
3
|
+
declare class AstNode {
|
|
4
|
+
/** @type {string} */ type: string;
|
|
5
|
+
/** @type {this[]} */ childNodes: AstNode[];
|
|
6
|
+
/** 首位子节点 */
|
|
7
|
+
get firstChild(): AstNode;
|
|
8
|
+
/** 末位子节点 */
|
|
9
|
+
get lastChild(): AstNode;
|
|
10
|
+
/** 父节点 */
|
|
11
|
+
get parentNode(): AstNode;
|
|
12
|
+
/**
|
|
13
|
+
* 后一个兄弟节点
|
|
14
|
+
* @complexity `n`
|
|
15
|
+
*/
|
|
16
|
+
get nextSibling(): AstNode;
|
|
17
|
+
/**
|
|
18
|
+
* 前一个兄弟节点
|
|
19
|
+
* @complexity `n`
|
|
20
|
+
*/
|
|
21
|
+
get previousSibling(): AstNode;
|
|
22
|
+
/**
|
|
23
|
+
* 是否具有某属性
|
|
24
|
+
* @param {PropertyKey} key 属性键
|
|
25
|
+
*/
|
|
26
|
+
hasAttribute(key: PropertyKey): boolean;
|
|
27
|
+
/**
|
|
28
|
+
* 获取属性值。除非用于私有属性,否则总是返回字符串。
|
|
29
|
+
* @template {string} T
|
|
30
|
+
* @param {T} key 属性键
|
|
31
|
+
* @returns {TokenAttribute<T>}
|
|
32
|
+
*/
|
|
33
|
+
getAttribute<T extends string>(key: T): import("../../typings/node").TokenAttribute<T>;
|
|
34
|
+
/**
|
|
35
|
+
* 设置属性
|
|
36
|
+
* @template {string} T
|
|
37
|
+
* @param {T} key 属性键
|
|
38
|
+
* @param {TokenAttribute<T>} value 属性值
|
|
39
|
+
*/
|
|
40
|
+
setAttribute<T_1 extends string>(key: T_1, value: import("../../typings/node").TokenAttribute<T_1>): AstNode;
|
|
41
|
+
/**
|
|
42
|
+
* 可见部分
|
|
43
|
+
* @param {string} separator 子节点间的连接符
|
|
44
|
+
* @returns {string}
|
|
45
|
+
* @complexity `n`
|
|
46
|
+
*/
|
|
47
|
+
text(separator?: string): string;
|
|
48
|
+
/**
|
|
49
|
+
* 移除子节点
|
|
50
|
+
* @param {number} i 移除位置
|
|
51
|
+
*/
|
|
52
|
+
removeAt(i: number): AstNode;
|
|
53
|
+
/**
|
|
54
|
+
* 插入子节点
|
|
55
|
+
* @template {this} T
|
|
56
|
+
* @param {T} node 待插入的子节点
|
|
57
|
+
* @param {number} i 插入位置
|
|
58
|
+
* @complexity `n`
|
|
59
|
+
*/
|
|
60
|
+
insertAt<T_2 extends AstNode>(node: T_2, i?: number): T_2;
|
|
61
|
+
/**
|
|
62
|
+
* 合并相邻的文本子节点
|
|
63
|
+
* @complexity `n`
|
|
64
|
+
*/
|
|
65
|
+
normalize(): void;
|
|
66
|
+
/** 获取根节点 */
|
|
67
|
+
getRootNode(): AstNode;
|
|
68
|
+
/**
|
|
69
|
+
* 将字符位置转换为行列号
|
|
70
|
+
* @param {number} index 字符位置
|
|
71
|
+
* @complexity `n`
|
|
72
|
+
*/
|
|
73
|
+
posFromIndex(index: number): {
|
|
74
|
+
top: number;
|
|
75
|
+
left: number;
|
|
76
|
+
};
|
|
77
|
+
/** 第一个子节点前的间距 */
|
|
78
|
+
getPadding(): number;
|
|
79
|
+
/** 子节点间距 */
|
|
80
|
+
getGaps(): number;
|
|
81
|
+
/**
|
|
82
|
+
* 获取当前节点的相对字符位置,或其第`j`个子节点的相对字符位置
|
|
83
|
+
* @param {number|undefined} j 子节点序号
|
|
84
|
+
* @complexity `n`
|
|
85
|
+
*/
|
|
86
|
+
getRelativeIndex(j: number | undefined): number;
|
|
87
|
+
/**
|
|
88
|
+
* 行数
|
|
89
|
+
* @complexity `n`
|
|
90
|
+
*/
|
|
91
|
+
get offsetHeight(): number;
|
|
92
|
+
/**
|
|
93
|
+
* 最后一行的列数
|
|
94
|
+
* @complexity `n`
|
|
95
|
+
*/
|
|
96
|
+
get offsetWidth(): number;
|
|
97
|
+
#private;
|
|
98
|
+
}
|
|
99
|
+
declare namespace AstNode {
|
|
100
|
+
export { TokenAttribute };
|
|
101
|
+
}
|
|
102
|
+
type TokenAttribute<T> = import('../../typings/node').TokenAttribute<T>;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export = AstText;
|
|
2
|
+
/** 文本节点 */
|
|
3
|
+
declare class AstText extends AstNode {
|
|
4
|
+
/** @param {string} text 包含文本 */
|
|
5
|
+
constructor(text?: string);
|
|
6
|
+
/** @type {string} */ data: string;
|
|
7
|
+
/** @override */
|
|
8
|
+
override text(): string;
|
|
9
|
+
/**
|
|
10
|
+
* Linter
|
|
11
|
+
* @this {AstText & {parentNode: AstElement}}
|
|
12
|
+
* @param {number} start 起始位置
|
|
13
|
+
* @returns {LintError[]}
|
|
14
|
+
*/
|
|
15
|
+
lint(this: import("./text") & {
|
|
16
|
+
parentNode: AstElement;
|
|
17
|
+
}, start: number): LintError[];
|
|
18
|
+
/**
|
|
19
|
+
* 替换字符串
|
|
20
|
+
* @param {string} text 替换的字符串
|
|
21
|
+
*/
|
|
22
|
+
replaceData(text?: string): void;
|
|
23
|
+
#private;
|
|
24
|
+
}
|
|
25
|
+
declare namespace AstText {
|
|
26
|
+
export { LintError };
|
|
27
|
+
}
|
|
28
|
+
import AstNode = require("./node");
|
|
29
|
+
import AstElement = require("./element");
|
|
30
|
+
type LintError = import('../../typings/token').LintError;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export = Title;
|
|
2
|
+
/** MediaWiki页面标题对象 */
|
|
3
|
+
declare class Title {
|
|
4
|
+
/**
|
|
5
|
+
* @param {string} title 标题(含或不含命名空间前缀)
|
|
6
|
+
* @param {number} defaultNs 命名空间
|
|
7
|
+
* @param {boolean} decode 是否需要解码
|
|
8
|
+
* @param {boolean} selfLink 是否允许selfLink
|
|
9
|
+
*/
|
|
10
|
+
constructor(title: string, defaultNs?: number, config?: import("../../typings/token").ParserConfig, decode?: boolean, selfLink?: boolean);
|
|
11
|
+
valid: boolean;
|
|
12
|
+
ns: number;
|
|
13
|
+
fragment: string;
|
|
14
|
+
encoded: boolean;
|
|
15
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export = parseBrackets;
|
|
2
|
+
/**
|
|
3
|
+
* 解析花括号
|
|
4
|
+
* @param {string} text wikitext
|
|
5
|
+
* @param {import('../../typings/token').accum} accum
|
|
6
|
+
* @throws TranscludeToken.constructor()
|
|
7
|
+
*/
|
|
8
|
+
declare function parseBrackets(text: string, config?: import("../../typings/token").ParserConfig, accum?: import('../../typings/token').accum): string;
|
|
9
|
+
declare namespace parseBrackets {
|
|
10
|
+
export { BracketExecArray };
|
|
11
|
+
}
|
|
12
|
+
type BracketExecArray = import('../../typings/parser').BracketExecArray;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export = parseCommentAndExt;
|
|
2
|
+
/**
|
|
3
|
+
* 解析HTML注释和扩展标签
|
|
4
|
+
* @param {string} text wikitext
|
|
5
|
+
* @param {import('../../typings/token').accum} accum
|
|
6
|
+
* @param {boolean} includeOnly 是否嵌入
|
|
7
|
+
*/
|
|
8
|
+
declare function parseCommentAndExt(text: string, config?: import("../../typings/token").ParserConfig, accum?: import('../../typings/token').accum, includeOnly?: boolean): string;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export = parseConverter;
|
|
2
|
+
/**
|
|
3
|
+
* 解析语言变体转换
|
|
4
|
+
* @param {string} wikitext wikitext
|
|
5
|
+
* @param {import('../../typings/token').accum} accum
|
|
6
|
+
*/
|
|
7
|
+
declare function parseConverter(wikitext: string, config?: import("../../typings/token").ParserConfig, accum?: import('../../typings/token').accum): string;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export = parseExternalLinks;
|
|
2
|
+
/**
|
|
3
|
+
* 解析外部链接
|
|
4
|
+
* @param {string} wikitext wikitext
|
|
5
|
+
* @param {import('../../typings/token').accum} accum
|
|
6
|
+
*/
|
|
7
|
+
declare function parseExternalLinks(wikitext: string, config?: import("../../typings/token").ParserConfig, accum?: import('../../typings/token').accum): string;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export = parseHrAndDoubleUnderscore;
|
|
2
|
+
/**
|
|
3
|
+
* 解析\<hr\>和状态开关
|
|
4
|
+
* @param {Token & {firstChild: AstText}} root 根节点
|
|
5
|
+
* @param {import('../../typings/token').accum} accum
|
|
6
|
+
*/
|
|
7
|
+
declare function parseHrAndDoubleUnderscore({ firstChild: { data }, type, name }: Token & {
|
|
8
|
+
firstChild: AstText;
|
|
9
|
+
}, config?: import("../../typings/token").ParserConfig, accum?: import('../../typings/token').accum): string;
|
|
10
|
+
import Token = require("../src");
|
|
11
|
+
import AstText = require("../lib/text");
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export = parseHtml;
|
|
2
|
+
/**
|
|
3
|
+
* 解析HTML标签
|
|
4
|
+
* @param {string} wikitext wikitext
|
|
5
|
+
* @param {import('../../typings/token').accum} accum
|
|
6
|
+
*/
|
|
7
|
+
declare function parseHtml(wikitext: string, config?: import("../../typings/token").ParserConfig, accum?: import('../../typings/token').accum): string;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export = parseLinks;
|
|
2
|
+
/**
|
|
3
|
+
* 解析内部链接
|
|
4
|
+
* @param {string} wikitext wikitext
|
|
5
|
+
* @param {import('../../typings/token').accum} accum
|
|
6
|
+
*/
|
|
7
|
+
declare function parseLinks(wikitext: string, config?: import("../../typings/token").ParserConfig, accum?: import('../../typings/token').accum): string;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export = parseList;
|
|
2
|
+
/**
|
|
3
|
+
* 解析列表
|
|
4
|
+
* @param {string} text wikitext
|
|
5
|
+
* @param {import('../../typings/token').accum} accum
|
|
6
|
+
*/
|
|
7
|
+
declare function parseList(text: string, config?: import("../../typings/token").ParserConfig, accum?: import('../../typings/token').accum): string;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export = parseMagicLinks;
|
|
2
|
+
/**
|
|
3
|
+
* 解析自由外链
|
|
4
|
+
* @param {string} wikitext wikitext
|
|
5
|
+
* @param {import('../../typings/token').accum} accum
|
|
6
|
+
*/
|
|
7
|
+
declare function parseMagicLinks(wikitext: string, config?: import("../../typings/token").ParserConfig, accum?: import('../../typings/token').accum): string;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export = parseQuotes;
|
|
2
|
+
/**
|
|
3
|
+
* 解析单引号
|
|
4
|
+
* @param {string} text wikitext
|
|
5
|
+
* @param {import('../../typings/token').accum} accum
|
|
6
|
+
*/
|
|
7
|
+
declare function parseQuotes(text: string, config?: import("../../typings/token").ParserConfig, accum?: import('../../typings/token').accum): string;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export = parseTable;
|
|
2
|
+
/**
|
|
3
|
+
* 解析表格,注意`tr`和`td`包含开头的换行
|
|
4
|
+
* @param {Token & {firstChild: AstText}} root 根节点
|
|
5
|
+
* @param {import('../../typings/token').accum} accum
|
|
6
|
+
*/
|
|
7
|
+
declare function parseTable({ firstChild: { data }, type, name }: Token & {
|
|
8
|
+
firstChild: AstText;
|
|
9
|
+
}, config?: import("../../typings/token").ParserConfig, accum?: import('../../typings/token').accum): string;
|
|
10
|
+
import Token = require("../src");
|
|
11
|
+
import AstText = require("../lib/text");
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export = ArgToken;
|
|
2
|
+
/**
|
|
3
|
+
* `{{{}}}`包裹的参数
|
|
4
|
+
* @classdesc `{childNodes: [AtomToken, ?Token, ...HiddenToken]}`
|
|
5
|
+
*/
|
|
6
|
+
declare class ArgToken extends Token {
|
|
7
|
+
/**
|
|
8
|
+
* @param {string[]} parts 以'|'分隔的各部分
|
|
9
|
+
* @param {import('../../typings/token').accum} accum
|
|
10
|
+
* @complexity `n`
|
|
11
|
+
*/
|
|
12
|
+
constructor(parts: string[], config?: import("../../typings/token").ParserConfig, accum?: import('../../typings/token').accum);
|
|
13
|
+
/** default */
|
|
14
|
+
get default(): string | false;
|
|
15
|
+
/**
|
|
16
|
+
* @override
|
|
17
|
+
*/
|
|
18
|
+
override toString(selector: any): string;
|
|
19
|
+
/**
|
|
20
|
+
* @override
|
|
21
|
+
* @returns {string}
|
|
22
|
+
*/
|
|
23
|
+
override text(): string;
|
|
24
|
+
/**
|
|
25
|
+
* @override
|
|
26
|
+
* @param {number} start 起始位置
|
|
27
|
+
* @returns {import('../../typings/token').LintError[]}
|
|
28
|
+
*/
|
|
29
|
+
override lint(start: number): import('../../typings/token').LintError[];
|
|
30
|
+
}
|
|
31
|
+
import Token = require(".");
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export = AtomToken;
|
|
2
|
+
/**
|
|
3
|
+
* 不会被继续解析的plain Token
|
|
4
|
+
* @classdesc `{childNodes: ...AstText|Token}`
|
|
5
|
+
*/
|
|
6
|
+
declare class AtomToken extends Token {
|
|
7
|
+
/**
|
|
8
|
+
* @param {string} wikitext wikitext
|
|
9
|
+
* @param {string|undefined} type Token.type
|
|
10
|
+
* @param {import('../../../typings/token').accum} accum
|
|
11
|
+
*/
|
|
12
|
+
constructor(wikitext: string, type: string | undefined, config?: import("../../../typings/token").ParserConfig, accum?: import('../../../typings/token').accum, acceptable?: any);
|
|
13
|
+
}
|
|
14
|
+
import Token = require("..");
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
export = AttributeToken;
|
|
2
|
+
/**
|
|
3
|
+
* 扩展和HTML标签属性
|
|
4
|
+
* @classdesc `{childNodes: [AtomToken, Token|AtomToken]}`
|
|
5
|
+
*/
|
|
6
|
+
declare class AttributeToken extends Token {
|
|
7
|
+
/**
|
|
8
|
+
* @param {'ext-attr'|'html-attr'|'table-attr'} type 标签类型
|
|
9
|
+
* @param {string} tag 标签名
|
|
10
|
+
* @param {string} key 属性名
|
|
11
|
+
* @param {string} equal 等号
|
|
12
|
+
* @param {string} value 属性值
|
|
13
|
+
* @param {string[]} quotes 引号
|
|
14
|
+
* @param {import('../../typings/token').accum} accum
|
|
15
|
+
*/
|
|
16
|
+
constructor(type: 'ext-attr' | 'html-attr' | 'table-attr', tag: string, key: string, equal?: string, value?: string, quotes?: string[], config?: import("../../typings/token").ParserConfig, accum?: import('../../typings/token').accum);
|
|
17
|
+
/** 引号是否匹配 */
|
|
18
|
+
get balanced(): boolean;
|
|
19
|
+
/** getValue()的getter */
|
|
20
|
+
get value(): string | true;
|
|
21
|
+
/** 标签名 */
|
|
22
|
+
get tag(): string;
|
|
23
|
+
type: "ext-attr" | "html-attr" | "table-attr";
|
|
24
|
+
/**
|
|
25
|
+
* @override
|
|
26
|
+
* @returns {string}
|
|
27
|
+
*/
|
|
28
|
+
override toString(selector: any): string;
|
|
29
|
+
/**
|
|
30
|
+
* @override
|
|
31
|
+
* @returns {string}
|
|
32
|
+
*/
|
|
33
|
+
override text(): string;
|
|
34
|
+
/**
|
|
35
|
+
* @override
|
|
36
|
+
* @param {number} start 起始位置
|
|
37
|
+
*/
|
|
38
|
+
override lint(start: number): import("../../typings/token").LintError[];
|
|
39
|
+
/** 获取属性值 */
|
|
40
|
+
getValue(): string | true;
|
|
41
|
+
#private;
|
|
42
|
+
}
|
|
43
|
+
declare namespace AttributeToken {
|
|
44
|
+
export { ParserConfig };
|
|
45
|
+
}
|
|
46
|
+
import Token = require(".");
|
|
47
|
+
type ParserConfig = import('../../typings/token').ParserConfig;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export = AttributesToken;
|
|
2
|
+
/**
|
|
3
|
+
* 扩展和HTML标签属性
|
|
4
|
+
* @classdesc `{childNodes: ...AtomToken|AttributeToken}`
|
|
5
|
+
*/
|
|
6
|
+
declare class AttributesToken extends Token {
|
|
7
|
+
/**
|
|
8
|
+
* @param {string} attr 标签属性
|
|
9
|
+
* @param {'ext-attrs'|'html-attrs'|'table-attrs'} type 标签类型
|
|
10
|
+
* @param {string} name 标签名
|
|
11
|
+
* @param {import('../../typings/token').accum} accum
|
|
12
|
+
*/
|
|
13
|
+
constructor(attr: string, type: 'ext-attrs' | 'html-attrs' | 'table-attrs', name: string, config?: import("../../typings/token").ParserConfig, accum?: import('../../typings/token').accum);
|
|
14
|
+
type: "ext-attrs" | "html-attrs" | "table-attrs";
|
|
15
|
+
/**
|
|
16
|
+
* 所有指定属性名的AttributeToken
|
|
17
|
+
* @param {string} key 属性名
|
|
18
|
+
* @returns {AttributeToken[]}
|
|
19
|
+
*/
|
|
20
|
+
getAttrTokens(key: string): AttributeToken[];
|
|
21
|
+
/**
|
|
22
|
+
* 制定属性名的最后一个AttributeToken
|
|
23
|
+
* @param {string} key 属性名
|
|
24
|
+
*/
|
|
25
|
+
getAttrToken(key: string): AttributeToken;
|
|
26
|
+
/**
|
|
27
|
+
* 获取标签属性
|
|
28
|
+
* @param {string} key 属性键
|
|
29
|
+
*/
|
|
30
|
+
getAttr(key: string): string | true;
|
|
31
|
+
/**
|
|
32
|
+
* @override
|
|
33
|
+
* @this {AttributesToken & {parentNode: HtmlToken}}
|
|
34
|
+
* @param {number} start 起始位置
|
|
35
|
+
*/
|
|
36
|
+
override lint(this: AttributesToken & {
|
|
37
|
+
parentNode: import("./html");
|
|
38
|
+
}, start: number): import("../../typings/token").LintError[];
|
|
39
|
+
}
|
|
40
|
+
import Token = require(".");
|
|
41
|
+
import AttributeToken = require("./attribute");
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export = ConverterToken;
|
|
2
|
+
/**
|
|
3
|
+
* 转换
|
|
4
|
+
* @classdesc `{childNodes: [ConverterFlagsToken, ...ConverterRuleToken]}`
|
|
5
|
+
*/
|
|
6
|
+
declare class ConverterToken extends Token {
|
|
7
|
+
/**
|
|
8
|
+
* @param {string[]} flags 转换类型标记
|
|
9
|
+
* @param {string[]} rules 转换规则
|
|
10
|
+
* @param {import('../../typings/token').accum} accum
|
|
11
|
+
*/
|
|
12
|
+
constructor(flags: string[], rules: string[], config?: import("../../typings/token").ParserConfig, accum?: import('../../typings/token').accum);
|
|
13
|
+
/**
|
|
14
|
+
* @override
|
|
15
|
+
* @returns {string}
|
|
16
|
+
*/
|
|
17
|
+
override toString(selector: any): string;
|
|
18
|
+
/**
|
|
19
|
+
* @override
|
|
20
|
+
* @returns {string}
|
|
21
|
+
*/
|
|
22
|
+
override text(): string;
|
|
23
|
+
/**
|
|
24
|
+
* @override
|
|
25
|
+
* @param {number} i 子节点位置
|
|
26
|
+
*/
|
|
27
|
+
override getGaps(i?: number): 1 | 0;
|
|
28
|
+
}
|
|
29
|
+
import Token = require(".");
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export = ConverterFlagsToken;
|
|
2
|
+
/**
|
|
3
|
+
* 转换flags
|
|
4
|
+
* @classdesc `{childNodes: ...AtomToken}`
|
|
5
|
+
*/
|
|
6
|
+
declare class ConverterFlagsToken extends Token {
|
|
7
|
+
/**
|
|
8
|
+
* @param {string[]} flags 转换类型标记
|
|
9
|
+
* @param {import('../../typings/token').accum} accum
|
|
10
|
+
*/
|
|
11
|
+
constructor(flags: string[], config?: import("../../typings/token").ParserConfig, accum?: import('../../typings/token').accum);
|
|
12
|
+
/**
|
|
13
|
+
* @override
|
|
14
|
+
*/
|
|
15
|
+
override toString(selector: any): string;
|
|
16
|
+
/** @override */
|
|
17
|
+
override text(): string;
|
|
18
|
+
/**
|
|
19
|
+
* @override
|
|
20
|
+
* @param {number} start 起始位置
|
|
21
|
+
*/
|
|
22
|
+
override lint(start: number): import("../../typings/token").LintError[];
|
|
23
|
+
/**
|
|
24
|
+
* 获取未知转换类型标记
|
|
25
|
+
* @complexity `n`
|
|
26
|
+
*/
|
|
27
|
+
getUnknownFlags(): Set<string>;
|
|
28
|
+
/** 获取指定语言变体的转换标记 */
|
|
29
|
+
getVariantFlags(): Set<string>;
|
|
30
|
+
#private;
|
|
31
|
+
}
|
|
32
|
+
import Token = require(".");
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export = ConverterRuleToken;
|
|
2
|
+
/**
|
|
3
|
+
* 转换规则
|
|
4
|
+
* @classdesc `{childNodes: ...AtomToken)}`
|
|
5
|
+
*/
|
|
6
|
+
declare class ConverterRuleToken extends Token {
|
|
7
|
+
/**
|
|
8
|
+
* @param {string} rule 转换规则
|
|
9
|
+
* @param {boolean} hasColon 是否带有":"
|
|
10
|
+
* @param {import('../../typings/token').accum} accum
|
|
11
|
+
*/
|
|
12
|
+
constructor(rule: string, hasColon?: boolean, config?: import("../../typings/token").ParserConfig, accum?: import('../../typings/token').accum);
|
|
13
|
+
/**
|
|
14
|
+
* @override
|
|
15
|
+
* @returns {string}
|
|
16
|
+
*/
|
|
17
|
+
override toString(selector: any): string;
|
|
18
|
+
/**
|
|
19
|
+
* @override
|
|
20
|
+
* @returns {string}
|
|
21
|
+
*/
|
|
22
|
+
override text(): string;
|
|
23
|
+
/**
|
|
24
|
+
* @override
|
|
25
|
+
* @param {number} i 子节点序号
|
|
26
|
+
*/
|
|
27
|
+
override getGaps(i?: number): 1 | 2;
|
|
28
|
+
}
|
|
29
|
+
import Token = require(".");
|