wikiparser-node 0.11.0-b → 0.11.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.
Files changed (176) hide show
  1. package/config/.schema.json +18 -0
  2. package/config/default.json +1 -0
  3. package/config/llwiki.json +35 -0
  4. package/config/moegirl.json +44 -0
  5. package/config/zhwiki.json +466 -0
  6. package/dist/index.d.ts +114 -0
  7. package/dist/lib/element.d.ts +162 -0
  8. package/dist/lib/node.d.ts +291 -0
  9. package/dist/lib/ranges.d.ts +37 -0
  10. package/dist/lib/text.d.ts +64 -0
  11. package/dist/lib/title.d.ts +21 -0
  12. package/dist/mixin/attributeParent.d.ts +9 -0
  13. package/dist/mixin/fixedToken.d.ts +8 -0
  14. package/dist/mixin/hidden.d.ts +8 -0
  15. package/dist/mixin/singleLine.d.ts +8 -0
  16. package/dist/mixin/sol.d.ts +8 -0
  17. package/dist/parser/brackets.d.ts +12 -0
  18. package/dist/parser/commentAndExt.d.ts +8 -0
  19. package/dist/parser/converter.d.ts +7 -0
  20. package/dist/parser/externalLinks.d.ts +7 -0
  21. package/dist/parser/hrAndDoubleUnderscore.d.ts +11 -0
  22. package/dist/parser/html.d.ts +7 -0
  23. package/dist/parser/links.d.ts +7 -0
  24. package/dist/parser/list.d.ts +7 -0
  25. package/dist/parser/magicLinks.d.ts +7 -0
  26. package/dist/parser/quotes.d.ts +7 -0
  27. package/dist/parser/selector.d.ts +12 -0
  28. package/dist/parser/table.d.ts +11 -0
  29. package/dist/src/arg.d.ts +54 -0
  30. package/dist/src/atom/hidden.d.ts +5 -0
  31. package/dist/src/atom/index.d.ts +15 -0
  32. package/dist/src/attribute.d.ts +65 -0
  33. package/dist/src/attributes.d.ts +112 -0
  34. package/dist/src/charinsert.d.ts +32 -0
  35. package/dist/src/converter.d.ts +103 -0
  36. package/dist/src/converterFlags.d.ts +83 -0
  37. package/dist/src/converterRule.d.ts +75 -0
  38. package/dist/src/extLink.d.ts +62 -0
  39. package/dist/src/gallery.d.ts +33 -0
  40. package/dist/src/hasNowiki/index.d.ts +14 -0
  41. package/dist/src/hasNowiki/pre.d.ts +13 -0
  42. package/dist/src/heading.d.ts +44 -0
  43. package/dist/src/html.d.ts +56 -0
  44. package/dist/src/imageParameter.d.ts +65 -0
  45. package/dist/src/imagemap.d.ts +37 -0
  46. package/dist/src/imagemapLink.d.ts +21 -0
  47. package/dist/src/index.d.ts +186 -0
  48. package/dist/src/link/category.d.ts +16 -0
  49. package/dist/src/link/file.d.ts +85 -0
  50. package/dist/src/link/galleryImage.d.ts +15 -0
  51. package/dist/src/link/index.d.ts +88 -0
  52. package/dist/src/magicLink.d.ts +36 -0
  53. package/dist/src/nested/choose.d.ts +13 -0
  54. package/dist/src/nested/combobox.d.ts +13 -0
  55. package/dist/src/nested/index.d.ts +18 -0
  56. package/dist/src/nested/references.d.ts +13 -0
  57. package/dist/src/nowiki/comment.d.ts +31 -0
  58. package/dist/src/nowiki/dd.d.ts +17 -0
  59. package/dist/src/nowiki/doubleUnderscore.d.ts +22 -0
  60. package/dist/src/nowiki/hr.d.ts +13 -0
  61. package/dist/src/nowiki/index.d.ts +27 -0
  62. package/dist/src/nowiki/list.d.ts +8 -0
  63. package/dist/src/nowiki/noinclude.d.ts +8 -0
  64. package/dist/src/nowiki/quote.d.ts +13 -0
  65. package/dist/src/onlyinclude.d.ts +24 -0
  66. package/dist/src/paramTag/index.d.ts +29 -0
  67. package/dist/src/paramTag/inputbox.d.ts +8 -0
  68. package/dist/src/parameter.d.ts +75 -0
  69. package/dist/src/syntax.d.ts +20 -0
  70. package/dist/src/table/index.d.ts +273 -0
  71. package/dist/src/table/td.d.ts +100 -0
  72. package/dist/src/table/tr.d.ts +91 -0
  73. package/dist/src/tagPair/ext.d.ts +18 -0
  74. package/dist/src/tagPair/include.d.ts +25 -0
  75. package/dist/src/tagPair/index.d.ts +41 -0
  76. package/dist/src/transclude.d.ts +199 -0
  77. package/dist/tool/index.d.ts +420 -0
  78. package/dist/util/base.d.ts +10 -0
  79. package/dist/util/debug.d.ts +20 -0
  80. package/dist/util/diff.d.ts +8 -0
  81. package/dist/util/lint.d.ts +28 -0
  82. package/dist/util/string.d.ts +55 -0
  83. package/index.js +333 -0
  84. package/lib/element.js +618 -0
  85. package/lib/node.js +730 -0
  86. package/lib/ranges.js +130 -0
  87. package/lib/text.js +265 -0
  88. package/lib/title.js +83 -0
  89. package/mixin/attributeParent.js +117 -0
  90. package/mixin/fixedToken.js +40 -0
  91. package/mixin/hidden.js +21 -0
  92. package/mixin/singleLine.js +31 -0
  93. package/mixin/sol.js +54 -0
  94. package/package.json +17 -13
  95. package/parser/brackets.js +128 -0
  96. package/parser/commentAndExt.js +62 -0
  97. package/parser/converter.js +46 -0
  98. package/parser/externalLinks.js +33 -0
  99. package/parser/hrAndDoubleUnderscore.js +49 -0
  100. package/parser/html.js +42 -0
  101. package/parser/links.js +94 -0
  102. package/parser/list.js +59 -0
  103. package/parser/magicLinks.js +41 -0
  104. package/parser/quotes.js +64 -0
  105. package/parser/selector.js +180 -0
  106. package/parser/table.js +114 -0
  107. package/src/arg.js +207 -0
  108. package/src/atom/hidden.js +13 -0
  109. package/src/atom/index.js +43 -0
  110. package/src/attribute.js +472 -0
  111. package/src/attributes.js +453 -0
  112. package/src/charinsert.js +97 -0
  113. package/src/converter.js +176 -0
  114. package/src/converterFlags.js +284 -0
  115. package/src/converterRule.js +256 -0
  116. package/src/extLink.js +180 -0
  117. package/src/gallery.js +149 -0
  118. package/src/hasNowiki/index.js +44 -0
  119. package/src/hasNowiki/pre.js +40 -0
  120. package/src/heading.js +134 -0
  121. package/src/html.js +254 -0
  122. package/src/imageParameter.js +303 -0
  123. package/src/imagemap.js +199 -0
  124. package/src/imagemapLink.js +41 -0
  125. package/src/index.js +938 -0
  126. package/src/link/category.js +44 -0
  127. package/src/link/file.js +287 -0
  128. package/src/link/galleryImage.js +120 -0
  129. package/src/link/index.js +388 -0
  130. package/src/magicLink.js +151 -0
  131. package/src/nested/choose.js +24 -0
  132. package/src/nested/combobox.js +23 -0
  133. package/src/nested/index.js +96 -0
  134. package/src/nested/references.js +23 -0
  135. package/src/nowiki/comment.js +71 -0
  136. package/src/nowiki/dd.js +59 -0
  137. package/src/nowiki/doubleUnderscore.js +56 -0
  138. package/src/nowiki/hr.js +41 -0
  139. package/src/nowiki/index.js +56 -0
  140. package/src/nowiki/list.js +16 -0
  141. package/src/nowiki/noinclude.js +28 -0
  142. package/src/nowiki/quote.js +69 -0
  143. package/src/onlyinclude.js +64 -0
  144. package/src/paramTag/index.js +89 -0
  145. package/src/paramTag/inputbox.js +35 -0
  146. package/src/parameter.js +239 -0
  147. package/src/syntax.js +91 -0
  148. package/src/table/index.js +985 -0
  149. package/src/table/td.js +343 -0
  150. package/src/table/tr.js +319 -0
  151. package/src/tagPair/ext.js +146 -0
  152. package/src/tagPair/include.js +50 -0
  153. package/src/tagPair/index.js +131 -0
  154. package/src/transclude.js +843 -0
  155. package/tool/index.js +1209 -0
  156. package/typings/api.d.ts +9 -0
  157. package/typings/array.d.ts +29 -0
  158. package/typings/event.d.ts +22 -0
  159. package/typings/index.d.ts +118 -0
  160. package/typings/node.d.ts +35 -0
  161. package/typings/parser.d.ts +12 -0
  162. package/typings/table.d.ts +10 -0
  163. package/typings/token.d.ts +31 -0
  164. package/typings/tool.d.ts +6 -0
  165. package/util/base.js +17 -0
  166. package/util/debug.js +73 -0
  167. package/util/diff.js +76 -0
  168. package/util/lint.js +57 -0
  169. package/util/string.js +126 -0
  170. package/bundle/bundle.min.js +0 -38
  171. package/config/minimum.json +0 -135
  172. package/extensions/base.js +0 -154
  173. package/extensions/editor.css +0 -63
  174. package/extensions/editor.js +0 -183
  175. package/extensions/highlight.js +0 -40
  176. package/extensions/ui.css +0 -119
@@ -0,0 +1,162 @@
1
+ export = AstElement;
2
+ /** 类似HTMLElement */
3
+ declare class AstElement extends AstNode {
4
+ /** @type {string} */ name: string;
5
+ /** 子节点总数 */
6
+ get length(): number;
7
+ /**
8
+ * 全部非文本子节点
9
+ * @complexity `n`
10
+ */
11
+ get children(): AstElement[];
12
+ /**
13
+ * 首位非文本子节点
14
+ * @returns {this}
15
+ */
16
+ get firstElementChild(): AstElement;
17
+ /**
18
+ * 末位非文本子节点
19
+ * @complexity `n`
20
+ */
21
+ get lastElementChild(): AstElement;
22
+ /**
23
+ * 非文本子节点总数
24
+ * @complexity `n`
25
+ */
26
+ get childElementCount(): number;
27
+ /** 父节点 */
28
+ get parentElement(): this;
29
+ /**
30
+ * AstElement.prototype.text()的getter写法
31
+ * @complexity `n`
32
+ */
33
+ get outerText(): string;
34
+ /**
35
+ * 不可见
36
+ */
37
+ get hidden(): boolean;
38
+ /**
39
+ * 后一个可见的兄弟节点
40
+ * @complexity `n`
41
+ */
42
+ get nextVisibleSibling(): this;
43
+ /**
44
+ * 前一个可见的兄弟节点
45
+ * @complexity `n`
46
+ */
47
+ get previousVisibleSibling(): this;
48
+ /** 内部高度 */
49
+ get clientHeight(): number;
50
+ /** 内部宽度 */
51
+ get clientWidth(): number;
52
+ /**
53
+ * 销毁
54
+ * @complexity `n`
55
+ */
56
+ destroy(): void;
57
+ /**
58
+ * 检查是否符合选择器
59
+ * @param {string|SelectorArray[]} selector
60
+ * @returns {boolean}
61
+ * @complexity `n`
62
+ */
63
+ matches(selector: string | SelectorArray[]): boolean;
64
+ /**
65
+ * 符合选择器的第一个后代节点
66
+ * @param {string} selector
67
+ * @returns {this|undefined}
68
+ * @complexity `n`
69
+ */
70
+ querySelector(selector: string): this | undefined;
71
+ /**
72
+ * 符合选择器的所有后代节点
73
+ * @param {string} selector
74
+ * @complexity `n`
75
+ */
76
+ querySelectorAll(selector: string): AstElement[];
77
+ /**
78
+ * id选择器
79
+ * @param {string} id id名
80
+ */
81
+ getElementById(id: string): AstElement;
82
+ /**
83
+ * 类选择器
84
+ * @param {string} className 类名之一
85
+ */
86
+ getElementsByClassName(className: string): AstElement[];
87
+ /**
88
+ * 标签名选择器
89
+ * @param {string} name 标签名
90
+ */
91
+ getElementsByTagName(name: string): AstElement[];
92
+ /**
93
+ * 获取某一行的wikitext
94
+ * @param {number} n 行号
95
+ */
96
+ getLine(n: number): string;
97
+ /**
98
+ * 在开头批量插入子节点
99
+ * @param {...this} elements 插入节点
100
+ * @complexity `n`
101
+ */
102
+ prepend(...elements: AstElement[]): void;
103
+ /**
104
+ * 最近的祖先节点
105
+ * @param {string} selector
106
+ */
107
+ closest(selector: string): this;
108
+ /**
109
+ * 在末尾批量插入子节点
110
+ * @param {...this} elements 插入节点
111
+ * @complexity `n`
112
+ */
113
+ append(...elements: AstElement[]): void;
114
+ /**
115
+ * 批量替换子节点
116
+ * @param {...this} elements 新的子节点
117
+ * @complexity `n`
118
+ */
119
+ replaceChildren(...elements: AstElement[]): void;
120
+ /**
121
+ * 修改文本子节点
122
+ * @param {string} str 新文本
123
+ * @param {number} i 子节点位置
124
+ * @throws `RangeError` 对应位置的子节点不是文本节点
125
+ */
126
+ setText(str: string, i?: number): string;
127
+ /**
128
+ * 还原为wikitext
129
+ * @param {string} selector
130
+ * @param {string} separator 子节点间的连接符
131
+ * @returns {string}
132
+ */
133
+ toString(selector: string, separator?: string): string;
134
+ /**
135
+ * Linter
136
+ * @param {number} start 起始位置
137
+ */
138
+ lint(start?: number): import("../../typings/token").LintError[];
139
+ /**
140
+ * 以HTML格式打印
141
+ * @param {import('../../typings/node').printOpt} opt 选项
142
+ * @returns {string}
143
+ */
144
+ print(opt?: import('../../typings/node').printOpt): string;
145
+ /**
146
+ * 保存为JSON
147
+ * @param {string} file 文件名
148
+ * @returns {Record<string, *>}
149
+ */
150
+ json(file: string): Record<string, any>;
151
+ /**
152
+ * 输出AST
153
+ * @param {number} depth 当前深度
154
+ */
155
+ echo(depth?: number): void;
156
+ #private;
157
+ }
158
+ declare namespace AstElement {
159
+ export { SelectorArray };
160
+ }
161
+ import AstNode = require("./node");
162
+ type SelectorArray = import('../../typings/parser').SelectorArray;
@@ -0,0 +1,291 @@
1
+ export = AstNode;
2
+ /** 类似Node */
3
+ declare class AstNode {
4
+ /** @type {string} */ type: string;
5
+ /** @type {this[]} */ childNodes: this[];
6
+ /** 首位子节点 */
7
+ get firstChild(): this;
8
+ /** 末位子节点 */
9
+ get lastChild(): this;
10
+ /** 父节点 */
11
+ get parentNode(): this;
12
+ /**
13
+ * 后一个兄弟节点
14
+ * @complexity `n`
15
+ */
16
+ get nextSibling(): this;
17
+ /**
18
+ * 前一个兄弟节点
19
+ * @complexity `n`
20
+ */
21
+ get previousSibling(): this;
22
+ /**
23
+ * 后一个非文本兄弟节点
24
+ * @complexity `n`
25
+ * @returns {this}
26
+ */
27
+ get nextElementSibling(): this;
28
+ /**
29
+ * 前一个非文本兄弟节点
30
+ * @complexity `n`
31
+ * @returns {this}
32
+ */
33
+ get previousElementSibling(): this;
34
+ /** 是否具有根节点 */
35
+ get isConnected(): any;
36
+ /** 不是自身的根节点 */
37
+ get ownerDocument(): any;
38
+ /**
39
+ * 后方是否还有其他节点(不含后代)
40
+ * @returns {boolean}
41
+ * @complexity `n`
42
+ */
43
+ get eof(): boolean;
44
+ /**
45
+ * 标记仅用于代码调试的方法
46
+ * @param {string} method
47
+ * @throws `Error`
48
+ */
49
+ debugOnly(method?: string): void;
50
+ /**
51
+ * 抛出`TypeError`
52
+ * @param {string} method
53
+ * @param {...string} types 可接受的参数类型
54
+ */
55
+ typeError(method: string, ...types: string[]): never;
56
+ /**
57
+ * 冻结部分属性
58
+ * @param {string|string[]} keys 属性键
59
+ * @param {boolean} permanent 是否永久
60
+ */
61
+ seal(keys: string | string[], permanent: boolean): void;
62
+ /**
63
+ * 是否是全同节点
64
+ * @param {this} node 待比较的节点
65
+ * @throws `assert.AssertionError`
66
+ */
67
+ isEqualNode(node: this): boolean;
68
+ /**
69
+ * 是否具有某属性
70
+ * @param {PropertyKey} key 属性键
71
+ */
72
+ hasAttribute(key: PropertyKey): boolean;
73
+ /**
74
+ * 获取属性值。除非用于私有属性,否则总是返回字符串。
75
+ * @template {string} T
76
+ * @param {T} key 属性键
77
+ * @returns {TokenAttribute<T>}
78
+ */
79
+ getAttribute<T extends string>(key: T): import("../../typings/node").TokenAttribute<T>;
80
+ /**
81
+ * 设置属性
82
+ * @template {string} T
83
+ * @param {T} key 属性键
84
+ * @param {TokenAttribute<T>} value 属性值
85
+ */
86
+ setAttribute<T_1 extends string>(key: T_1, value: import("../../typings/node").TokenAttribute<T_1>): this;
87
+ /**
88
+ * 可见部分
89
+ * @param {string} separator 子节点间的连接符
90
+ * @returns {string}
91
+ * @complexity `n`
92
+ */
93
+ text(separator?: string): string;
94
+ /**
95
+ * 移除子节点
96
+ * @param {number} i 移除位置
97
+ */
98
+ removeAt(i: number): this;
99
+ /**
100
+ * 插入子节点
101
+ * @template {this} T
102
+ * @param {T} node 待插入的子节点
103
+ * @param {number} i 插入位置
104
+ * @complexity `n`
105
+ * @throws `RangeError` 不能插入祖先节点
106
+ */
107
+ insertAt<T_2 extends AstNode>(node: T_2, i?: number): T_2;
108
+ /**
109
+ * 移除子节点
110
+ * @template {this} T
111
+ * @param {T} node 子节点
112
+ * @complexity `n`
113
+ */
114
+ removeChild<T_3 extends AstNode>(node: T_3): T_3;
115
+ /**
116
+ * 在末尾插入子节点
117
+ * @template {this} T
118
+ * @param {T} node 插入节点
119
+ * @complexity `n`
120
+ */
121
+ appendChild<T_4 extends AstNode>(node: T_4): T_4;
122
+ /**
123
+ * 在指定位置前插入子节点
124
+ * @template {this} T
125
+ * @param {T} child 插入节点
126
+ * @param {this} reference 指定位置处的子节点
127
+ * @complexity `n`
128
+ */
129
+ insertBefore<T_5 extends AstNode>(child: T_5, reference: AstNode): T_5;
130
+ /**
131
+ * 替换子节点
132
+ * @template {this} T
133
+ * @param {this} newChild 新子节点
134
+ * @param {T} oldChild 原子节点
135
+ * @complexity `n`
136
+ */
137
+ replaceChild<T_6 extends AstNode>(newChild: AstNode, oldChild: T_6): T_6;
138
+ /**
139
+ * 在后方批量插入兄弟节点
140
+ * @param {...this} nodes 插入节点
141
+ * @complexity `n`
142
+ */
143
+ after(...nodes: AstNode[]): void;
144
+ /**
145
+ * 在前方批量插入兄弟节点
146
+ * @param {...this} nodes 插入节点
147
+ * @complexity `n`
148
+ */
149
+ before(...nodes: AstNode[]): void;
150
+ /**
151
+ * 移除当前节点
152
+ * @complexity `n`
153
+ * @throws `Error` 不存在父节点
154
+ */
155
+ remove(): void;
156
+ /**
157
+ * 将当前节点批量替换为新的节点
158
+ * @param {...this} nodes 插入节点
159
+ * @complexity `n`
160
+ */
161
+ replaceWith(...nodes: AstNode[]): void;
162
+ /**
163
+ * 是自身或后代节点
164
+ * @param {this} node 待检测节点
165
+ * @returns {boolean}
166
+ * @complexity `n`
167
+ */
168
+ contains(node: AstNode): boolean;
169
+ /**
170
+ * 添加事件监听
171
+ * @param {string|string[]} types 事件类型
172
+ * @param {AstListener} listener 监听函数
173
+ * @param {{once: boolean}} options 选项
174
+ */
175
+ addEventListener(types: string | string[], listener: AstListener, options: {
176
+ once: boolean;
177
+ }): void;
178
+ /**
179
+ * 移除事件监听
180
+ * @param {string|string[]} types 事件类型
181
+ * @param {AstListener} listener 监听函数
182
+ */
183
+ removeEventListener(types: string | string[], listener: AstListener): void;
184
+ /**
185
+ * 移除事件的所有监听
186
+ * @param {string|string[]} types 事件类型
187
+ */
188
+ removeAllEventListeners(types: string | string[]): void;
189
+ /**
190
+ * 列举事件监听
191
+ * @param {string} type 事件类型
192
+ * @returns {AstListener[]}
193
+ */
194
+ listEventListeners(type: string): AstListener[];
195
+ /**
196
+ * 触发事件
197
+ * @param {import('../../typings/event').AstEvent} e 事件对象
198
+ * @param {*} data 事件数据
199
+ */
200
+ dispatchEvent(e: import('../../typings/event').AstEvent, data: any): void;
201
+ /** 获取所有祖先节点 */
202
+ getAncestors(): AstNode[];
203
+ /**
204
+ * 比较和另一个节点的相对位置
205
+ * @param {this} other 待比较的节点
206
+ * @complexity `n`
207
+ * @throws `Error` 不在同一个语法树
208
+ */
209
+ compareDocumentPosition(other: AstNode): number;
210
+ /**
211
+ * 合并相邻的文本子节点
212
+ * @complexity `n`
213
+ */
214
+ normalize(): void;
215
+ /** 获取根节点 */
216
+ getRootNode(): any;
217
+ /**
218
+ * 将字符位置转换为行列号
219
+ * @param {number} index 字符位置
220
+ * @complexity `n`
221
+ */
222
+ posFromIndex(index: number): {
223
+ top: number;
224
+ left: number;
225
+ };
226
+ /**
227
+ * 将行列号转换为字符位置
228
+ * @param {number} top 行号
229
+ * @param {number} left 列号
230
+ * @complexity `n`
231
+ */
232
+ indexFromPos(top: number, left: number): number;
233
+ /** 第一个子节点前的间距 */
234
+ getPadding(): number;
235
+ /** 子节点间距 */
236
+ getGaps(): number;
237
+ /**
238
+ * 获取当前节点的相对字符位置,或其第`j`个子节点的相对字符位置
239
+ * @param {number|undefined} j 子节点序号
240
+ * @complexity `n`
241
+ */
242
+ getRelativeIndex(j: number | undefined): number;
243
+ /**
244
+ * 获取当前节点的绝对位置
245
+ * @returns {number}
246
+ * @complexity `n`
247
+ */
248
+ getAbsoluteIndex(): number;
249
+ /**
250
+ * 获取当前节点的行列位置和大小
251
+ * @complexity `n`
252
+ */
253
+ getBoundingClientRect(): any;
254
+ /**
255
+ * 行数
256
+ * @complexity `n`
257
+ */
258
+ get offsetHeight(): number;
259
+ /**
260
+ * 最后一行的列数
261
+ * @complexity `n`
262
+ */
263
+ get offsetWidth(): number;
264
+ /**
265
+ * 相对于父容器的行号
266
+ * @complexity `n`
267
+ */
268
+ get offsetTop(): number;
269
+ /**
270
+ * 相对于父容器的列号
271
+ * @complexity `n`
272
+ */
273
+ get offsetLeft(): number;
274
+ /**
275
+ * 位置、大小和padding
276
+ * @complexity `n`
277
+ */
278
+ get style(): {
279
+ padding: number;
280
+ height: number;
281
+ width: number;
282
+ top: number;
283
+ left: number;
284
+ };
285
+ #private;
286
+ }
287
+ declare namespace AstNode {
288
+ export { TokenAttribute, AstListener };
289
+ }
290
+ type AstListener = import('../../typings/event').AstListener;
291
+ type TokenAttribute<T> = import('../../typings/node').TokenAttribute<T>;
@@ -0,0 +1,37 @@
1
+ export = Ranges;
2
+ /** @extends {Array<number|Range>} */
3
+ declare class Ranges extends Array<number | Range> {
4
+ /**
5
+ * 检查某个下标是否符合表达式
6
+ * @param {string} str 表达式
7
+ * @param {number} i 待检查的下标
8
+ */
9
+ static nth(str: string, i: number): boolean;
10
+ /** @param {number|string|Range|(number|string|Range)[]} arr 表达式数组 */
11
+ constructor(arr: number | string | Range | (number | string | Range)[]);
12
+ /**
13
+ * 将Ranges转换为针对特定Array的下标集
14
+ * @param {number|*[]} arr 参考数组
15
+ * @complexity `n`
16
+ */
17
+ applyTo(arr: number | any[]): number[];
18
+ }
19
+ /** 模拟Python的Range对象。除`step`至少为`1`外,允许负数、小数或`end < start`的情形。 */
20
+ declare class Range {
21
+ /**
22
+ * @param {string|Range} str 表达式
23
+ * @throws `RangeError` 起点、终点和步长均应为整数
24
+ * @throws `RangeError` n的系数不能为0
25
+ * @throws `RangeError` 应使用CSS选择器或Python切片的格式
26
+ */
27
+ constructor(str: string | Range);
28
+ start: number;
29
+ end: number;
30
+ step: number;
31
+ /**
32
+ * 将Range转换为针对特定数组的下标集
33
+ * @param {number|*[]} arr 参考数组
34
+ * @complexity `n`
35
+ */
36
+ applyTo(arr: number | any[]): number[];
37
+ }
@@ -0,0 +1,64 @@
1
+ export = AstText;
2
+ /** 文本节点 */
3
+ declare class AstText extends AstNode {
4
+ /** @param {string} text 包含文本 */
5
+ constructor(text?: string);
6
+ /** @type {string} */ data: string;
7
+ /** 文本长度 */
8
+ get length(): number;
9
+ /** @override */
10
+ override text(): string;
11
+ /**
12
+ * Linter
13
+ * @this {AstText & {parentNode: AstElement}}
14
+ * @param {number} start 起始位置
15
+ * @returns {LintError[]}
16
+ */
17
+ lint(this: AstText & {
18
+ parentNode: AstElement;
19
+ }, start?: number): LintError[];
20
+ /**
21
+ * 替换字符串
22
+ * @param {string} text 替换的字符串
23
+ */
24
+ replaceData(text?: string): void;
25
+ /** 复制 */
26
+ cloneNode(): AstText;
27
+ /**
28
+ * 在后方添加字符串
29
+ * @param {string} text 添加的字符串
30
+ */
31
+ appendData(text: string): void;
32
+ /**
33
+ * 删减字符串
34
+ * @param {number} offset 起始位置
35
+ * @param {number} count 删减字符数
36
+ */
37
+ deleteData(offset: number, count: number): void;
38
+ /**
39
+ * 插入字符串
40
+ * @param {number} offset 插入位置
41
+ * @param {string} text 待插入的字符串
42
+ */
43
+ insertData(offset: number, text: string): void;
44
+ /**
45
+ * 提取子串
46
+ * @param {number} offset 起始位置
47
+ * @param {number} count 字符数
48
+ */
49
+ substringData(offset: number, count: number): string;
50
+ /**
51
+ * 将文本子节点分裂为两部分
52
+ * @param {number} offset 分裂位置
53
+ * @throws `RangeError` 错误的断开位置
54
+ * @throws `Error` 没有父节点
55
+ */
56
+ splitText(offset: number): AstText;
57
+ #private;
58
+ }
59
+ declare namespace AstText {
60
+ export { LintError };
61
+ }
62
+ import AstNode = require("./node");
63
+ import AstElement = require("./element");
64
+ type LintError = import('../../typings/token').LintError;
@@ -0,0 +1,21 @@
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
+ title: string;
16
+ main: string;
17
+ prefix: string;
18
+ interwiki: string;
19
+ /** @override */
20
+ override toString(): string;
21
+ }
@@ -0,0 +1,9 @@
1
+ export = attributeParent;
2
+ /**
3
+ * 子节点含有AttributesToken的类
4
+ * @template T
5
+ * @param {T} Constructor 基类
6
+ * @param {number} i AttributesToken子节点的位置
7
+ * @returns {T}
8
+ */
9
+ declare function attributeParent<T>(Constructor: T, i?: number): T;
@@ -0,0 +1,8 @@
1
+ export = fixedToken;
2
+ /**
3
+ * 不可增删子节点的类
4
+ * @template T
5
+ * @param {T} Constructor 基类
6
+ * @returns {T}
7
+ */
8
+ declare function fixedToken<T>(Constructor: T): T;
@@ -0,0 +1,8 @@
1
+ export = hidden;
2
+ /**
3
+ * 解析后不可见的类
4
+ * @template T
5
+ * @param {T} Constructor 基类
6
+ * @returns {T}
7
+ */
8
+ declare function hidden<T>(Constructor: T): T;
@@ -0,0 +1,8 @@
1
+ export = singleLine;
2
+ /**
3
+ * 不可包含换行符的类
4
+ * @template {Function} T
5
+ * @param {T} Constructor 基类
6
+ * @returns {T}
7
+ */
8
+ declare function singleLine<T extends Function>(Constructor: T): T;
@@ -0,0 +1,8 @@
1
+ export = sol;
2
+ /**
3
+ * 只能位于行首的类
4
+ * @template T
5
+ * @param {T} Constructor 基类
6
+ * @returns {T}
7
+ */
8
+ declare function sol<T>(Constructor: T): T;
@@ -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;