wikiparser-node 0.11.0-m → 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.
- package/config/.schema.json +7 -0
- package/config/default.json +1 -0
- package/config/llwiki.json +35 -0
- package/config/moegirl.json +44 -0
- package/config/zhwiki.json +466 -0
- package/dist/index.d.ts +4 -0
- package/dist/lib/element.d.ts +116 -2
- package/dist/lib/node.d.ts +193 -10
- package/dist/lib/ranges.d.ts +37 -0
- package/dist/lib/text.d.ts +35 -1
- package/dist/lib/title.d.ts +6 -0
- package/dist/mixin/attributeParent.d.ts +9 -0
- package/dist/mixin/fixedToken.d.ts +8 -0
- package/dist/mixin/singleLine.d.ts +8 -0
- package/dist/mixin/sol.d.ts +8 -0
- package/dist/parser/selector.d.ts +12 -0
- package/dist/src/arg.d.ts +30 -1
- package/dist/src/atom/index.d.ts +2 -1
- package/dist/src/attribute.d.ts +24 -1
- package/dist/src/attributes.d.ts +79 -0
- package/dist/src/charinsert.d.ts +32 -0
- package/dist/src/converter.d.ts +75 -1
- package/dist/src/converterFlags.d.ts +57 -1
- package/dist/src/converterRule.d.ts +47 -1
- package/dist/src/extLink.d.ts +41 -1
- package/dist/src/gallery.d.ts +15 -1
- package/dist/src/heading.d.ts +22 -2
- package/dist/src/html.d.ts +25 -2
- package/dist/src/imageParameter.d.ts +43 -1
- package/dist/src/imagemap.d.ts +12 -1
- package/dist/src/imagemapLink.d.ts +5 -0
- package/dist/src/index.d.ts +136 -3
- package/dist/src/link/category.d.ts +8 -0
- package/dist/src/link/file.d.ts +58 -0
- package/dist/src/link/index.d.ts +61 -2
- package/dist/src/magicLink.d.ts +22 -0
- package/dist/src/nested/index.d.ts +3 -5
- package/dist/src/nowiki/comment.d.ts +13 -1
- package/dist/src/nowiki/dd.d.ts +9 -0
- package/dist/src/nowiki/doubleUnderscore.d.ts +11 -1
- package/dist/src/nowiki/index.d.ts +11 -2
- package/dist/src/nowiki/quote.d.ts +0 -7
- package/dist/src/onlyinclude.d.ts +8 -1
- package/dist/src/paramTag/index.d.ts +8 -3
- package/dist/src/parameter.d.ts +48 -1
- package/dist/src/syntax.d.ts +6 -1
- package/dist/src/table/index.d.ts +257 -0
- package/dist/src/table/td.d.ts +67 -6
- package/dist/src/table/tr.d.ts +74 -0
- package/dist/src/tagPair/ext.d.ts +2 -1
- package/dist/src/tagPair/include.d.ts +9 -0
- package/dist/src/tagPair/index.d.ts +14 -1
- package/dist/src/transclude.d.ts +125 -1
- package/dist/tool/index.d.ts +420 -0
- package/dist/util/base.d.ts +10 -0
- package/dist/util/debug.d.ts +20 -0
- package/dist/util/diff.d.ts +8 -0
- package/dist/util/string.d.ts +24 -0
- package/index.js +256 -4
- package/lib/element.js +488 -6
- package/lib/node.js +495 -6
- package/lib/ranges.js +130 -0
- package/lib/text.js +96 -1
- package/lib/title.js +28 -1
- package/mixin/attributeParent.js +117 -0
- package/mixin/fixedToken.js +40 -0
- package/mixin/hidden.js +3 -0
- package/mixin/singleLine.js +31 -0
- package/mixin/sol.js +54 -0
- package/package.json +5 -2
- package/parser/brackets.js +1 -0
- package/parser/commentAndExt.js +1 -0
- package/parser/converter.js +1 -0
- package/parser/externalLinks.js +1 -0
- package/parser/hrAndDoubleUnderscore.js +1 -0
- package/parser/html.js +1 -0
- package/parser/links.js +5 -4
- package/parser/list.js +1 -0
- package/parser/magicLinks.js +1 -0
- package/parser/quotes.js +1 -0
- package/parser/selector.js +180 -0
- package/parser/table.js +1 -0
- package/src/arg.js +116 -2
- package/src/atom/hidden.js +2 -0
- package/src/atom/index.js +17 -0
- package/src/attribute.js +189 -3
- package/src/attributes.js +307 -4
- package/src/charinsert.js +97 -0
- package/src/converter.js +108 -2
- package/src/converterFlags.js +187 -0
- package/src/converterRule.js +183 -1
- package/src/extLink.js +121 -1
- package/src/gallery.js +54 -0
- package/src/hasNowiki/index.js +12 -0
- package/src/hasNowiki/pre.js +12 -0
- package/src/heading.js +54 -3
- package/src/html.js +118 -3
- package/src/imageParameter.js +164 -2
- package/src/imagemap.js +61 -2
- package/src/imagemapLink.js +13 -1
- package/src/index.js +530 -3
- package/src/link/category.js +32 -1
- package/src/link/file.js +157 -2
- package/src/link/galleryImage.js +60 -2
- package/src/link/index.js +270 -1
- package/src/magicLink.js +83 -0
- package/src/nested/choose.js +1 -0
- package/src/nested/combobox.js +1 -0
- package/src/nested/index.js +27 -0
- package/src/nested/references.js +1 -0
- package/src/nowiki/comment.js +25 -1
- package/src/nowiki/dd.js +47 -1
- package/src/nowiki/doubleUnderscore.js +31 -1
- package/src/nowiki/hr.js +20 -1
- package/src/nowiki/index.js +23 -1
- package/src/nowiki/list.js +5 -2
- package/src/nowiki/noinclude.js +14 -0
- package/src/nowiki/quote.js +14 -0
- package/src/onlyinclude.js +26 -1
- package/src/paramTag/index.js +24 -1
- package/src/paramTag/inputbox.js +4 -1
- package/src/parameter.js +147 -5
- package/src/syntax.js +68 -0
- package/src/table/index.js +941 -2
- package/src/table/td.js +230 -5
- package/src/table/tr.js +247 -2
- package/src/tagPair/ext.js +21 -1
- package/src/tagPair/include.js +24 -0
- package/src/tagPair/index.js +56 -2
- package/src/transclude.js +512 -5
- package/tool/index.js +1209 -0
- package/typings/array.d.ts +29 -0
- package/typings/event.d.ts +22 -0
- package/typings/index.d.ts +67 -0
- package/typings/node.d.ts +19 -0
- package/typings/parser.d.ts +7 -0
- package/typings/table.d.ts +10 -0
- package/typings/token.d.ts +3 -0
- package/typings/tool.d.ts +6 -0
- package/util/debug.js +73 -0
- package/util/string.js +51 -0
|
@@ -4,13 +4,270 @@ export = TableToken;
|
|
|
4
4
|
* @classdesc `{childNodes: [SyntaxToken, AttributesToken, ?Token, ...TdToken, ...TrToken, ?SyntaxToken]}`
|
|
5
5
|
*/
|
|
6
6
|
declare class TableToken extends TrToken {
|
|
7
|
+
/**
|
|
8
|
+
* @param {string} syntax 表格语法
|
|
9
|
+
* @param {string} attr 表格属性
|
|
10
|
+
* @param {import('../../../typings/token').accum} accum
|
|
11
|
+
*/
|
|
12
|
+
constructor(syntax: string, attr?: string, config?: import("../../../typings/token").ParserConfig, accum?: import('../../../typings/token').accum);
|
|
13
|
+
set closed(arg: boolean);
|
|
7
14
|
/** 表格是否闭合 */
|
|
8
15
|
get closed(): boolean;
|
|
16
|
+
/**
|
|
17
|
+
* @override
|
|
18
|
+
* @template {TrToken|SyntaxToken} T
|
|
19
|
+
* @param {T} token 待插入的子节点
|
|
20
|
+
* @param {number} i 插入位置
|
|
21
|
+
* @returns {T}
|
|
22
|
+
* @complexity `n`
|
|
23
|
+
* @throws `SyntaxError` 表格的闭合部分非法
|
|
24
|
+
*/
|
|
25
|
+
override insertAt<T extends SyntaxToken | TrToken>(token: T, i?: number): T;
|
|
9
26
|
/**
|
|
10
27
|
* 闭合表格语法
|
|
11
28
|
* @complexity `n`
|
|
12
29
|
* @param {string} syntax 表格结尾语法
|
|
30
|
+
* @throws `SyntaxError` 表格的闭合部分不符合语法
|
|
13
31
|
*/
|
|
14
32
|
close(syntax?: string, halfParsed?: boolean): void;
|
|
33
|
+
/**
|
|
34
|
+
* @override
|
|
35
|
+
* @returns {number}
|
|
36
|
+
* @complexity `n`
|
|
37
|
+
*/
|
|
38
|
+
override getRowCount(): number;
|
|
39
|
+
/** @override */
|
|
40
|
+
override getPreviousRow(): void;
|
|
41
|
+
/**
|
|
42
|
+
* @override
|
|
43
|
+
* @complexity `n`
|
|
44
|
+
*/
|
|
45
|
+
override getNextRow(): TrToken;
|
|
46
|
+
/**
|
|
47
|
+
* 获取第n行
|
|
48
|
+
* @param {number} n 行号
|
|
49
|
+
* @param {boolean} force 是否将表格自身视为第一行
|
|
50
|
+
* @param {boolean} insert 是否用于判断插入新行的位置
|
|
51
|
+
* @returns {TrToken}
|
|
52
|
+
* @complexity `n`
|
|
53
|
+
* @throws `RangeError` 不存在该行
|
|
54
|
+
*/
|
|
55
|
+
getNthRow(n: number, force: boolean, insert: boolean): TrToken;
|
|
56
|
+
/**
|
|
57
|
+
* 获取所有行
|
|
58
|
+
* @returns {TrToken[]}
|
|
59
|
+
* @complexity `n`
|
|
60
|
+
*/
|
|
61
|
+
getAllRows(): TrToken[];
|
|
62
|
+
/**
|
|
63
|
+
* 获取指定坐标的单元格
|
|
64
|
+
* @param {TableCoords & TableRenderedCoords} coords 表格坐标
|
|
65
|
+
* @complexity `n`
|
|
66
|
+
*/
|
|
67
|
+
getNthCell(coords: TableCoords & TableRenderedCoords): TdToken;
|
|
68
|
+
/**
|
|
69
|
+
* 获取表格布局
|
|
70
|
+
* @param {TableCoords & TableRenderedCoords} stop 中止条件
|
|
71
|
+
* @complexity `n`
|
|
72
|
+
*/
|
|
73
|
+
getLayout(stop?: TableCoords & TableRenderedCoords): Layout;
|
|
74
|
+
/**
|
|
75
|
+
* 打印表格布局
|
|
76
|
+
* @complexity `n`
|
|
77
|
+
*/
|
|
78
|
+
printLayout(): void;
|
|
79
|
+
/**
|
|
80
|
+
* 转换为渲染后的表格坐标
|
|
81
|
+
* @param {TableCoords} coord wikitext中的表格坐标
|
|
82
|
+
* @returns {TableRenderedCoords}
|
|
83
|
+
* @complexity `n`
|
|
84
|
+
*/
|
|
85
|
+
toRenderedCoords({ row, column }: TableCoords): TableRenderedCoords;
|
|
86
|
+
/**
|
|
87
|
+
* 转换为wikitext中的表格坐标
|
|
88
|
+
* @param {TableRenderedCoords} coord 渲染后的表格坐标
|
|
89
|
+
* @complexity `n`
|
|
90
|
+
*/
|
|
91
|
+
toRawCoords({ x, y }: TableRenderedCoords): {
|
|
92
|
+
row: number;
|
|
93
|
+
column: any;
|
|
94
|
+
start: boolean;
|
|
95
|
+
};
|
|
96
|
+
/**
|
|
97
|
+
* 获取完整行
|
|
98
|
+
* @param {number} y 行号
|
|
99
|
+
* @complexity `n²`
|
|
100
|
+
*/
|
|
101
|
+
getFullRow(y: number): Map<TdToken, boolean>;
|
|
102
|
+
/**
|
|
103
|
+
* 获取完整列
|
|
104
|
+
* @param {number} x 列号
|
|
105
|
+
* @complexity `n`
|
|
106
|
+
*/
|
|
107
|
+
getFullCol(x: number): Map<TdToken, boolean>;
|
|
108
|
+
/**
|
|
109
|
+
* 设置行格式
|
|
110
|
+
* @param {number} y 行号
|
|
111
|
+
* @param {string|Record<string, string|boolean>} attr 表格属性
|
|
112
|
+
* @param {boolean} multiRow 是否对所有单元格设置,或是仅对行首单元格设置
|
|
113
|
+
* @complexity `n²`
|
|
114
|
+
*/
|
|
115
|
+
formatTableRow(y: number, attr?: string | Record<string, string | boolean>, multiRow?: boolean): void;
|
|
116
|
+
/**
|
|
117
|
+
* 设置列格式
|
|
118
|
+
* @param {number} x 列号
|
|
119
|
+
* @param {string|Record<string, string|boolean>} attr 表格属性
|
|
120
|
+
* @param {boolean} multiCol 是否对所有单元格设置,或是仅对行首单元格设置
|
|
121
|
+
* @complexity `n`
|
|
122
|
+
*/
|
|
123
|
+
formatTableCol(x: number, attr?: string | Record<string, string | boolean>, multiCol?: boolean): void;
|
|
124
|
+
/**
|
|
125
|
+
* 填补表格行
|
|
126
|
+
* @param {number} y 行号
|
|
127
|
+
* @param {string|Token} inner 填充内容
|
|
128
|
+
* @param {'td'|'th'|'caption'} subtype 单元格类型
|
|
129
|
+
* @param {Record<string, string>} attr 表格属性
|
|
130
|
+
* @complexity `n`
|
|
131
|
+
*/
|
|
132
|
+
fillTableRow(y: number, inner: string | Token, subtype?: 'td' | 'th' | 'caption', attr?: Record<string, string>): void;
|
|
133
|
+
/**
|
|
134
|
+
* 填补表格
|
|
135
|
+
* @param {string|Token} inner 填充内容
|
|
136
|
+
* @param {'td'|'th'|'caption'} subtype 单元格类型
|
|
137
|
+
* @param {Record<string, string>} attr 表格属性
|
|
138
|
+
* @complexity `n`
|
|
139
|
+
*/
|
|
140
|
+
fillTable(inner: string | Token, subtype?: 'td' | 'th' | 'caption', attr?: Record<string, string>): void;
|
|
141
|
+
/**
|
|
142
|
+
* @override
|
|
143
|
+
* @param {string|Token} inner 单元格内部wikitext
|
|
144
|
+
* @param {TableCoords & TableRenderedCoords} coords 单元格坐标
|
|
145
|
+
* @param {'td'|'th'|'caption'} subtype 单元格类型
|
|
146
|
+
* @param {Record<string, string|boolean>} attr 单元格属性
|
|
147
|
+
* @returns {TdToken}
|
|
148
|
+
* @complexity `n`
|
|
149
|
+
* @throws `RangeError` 指定的坐标不是单元格起始点
|
|
150
|
+
*/
|
|
151
|
+
override insertTableCell(inner: string | Token, coords: TableCoords & TableRenderedCoords, subtype?: 'td' | 'th' | 'caption', attr?: Record<string, string | boolean>): TdToken;
|
|
152
|
+
/**
|
|
153
|
+
* 插入表格行
|
|
154
|
+
* @param {number} y 行号
|
|
155
|
+
* @param {Record<string, string|boolean>} attr 表格行属性
|
|
156
|
+
* @param {string|Token} inner 内部wikitext
|
|
157
|
+
* @param {'td'|'th'|'caption'} subtype 单元格类型
|
|
158
|
+
* @param {Record<string, string|boolean>} innerAttr 单元格属性
|
|
159
|
+
* @complexity `n`
|
|
160
|
+
*/
|
|
161
|
+
insertTableRow(y: number, attr?: Record<string, string | boolean>, inner?: string | Token, subtype?: 'td' | 'th' | 'caption', innerAttr?: Record<string, string | boolean>): TrToken & import("../attributes");
|
|
162
|
+
/**
|
|
163
|
+
* 插入表格列
|
|
164
|
+
* @param {number} x 列号
|
|
165
|
+
* @param {string|Token} inner 内部wikitext
|
|
166
|
+
* @param {'td'|'th'|'caption'} subtype 单元格类型
|
|
167
|
+
* @param {Record<string, string>} attr 单元格属性
|
|
168
|
+
* @complexity `n²`
|
|
169
|
+
* @throws `RangeError` 列号过大
|
|
170
|
+
*/
|
|
171
|
+
insertTableCol(x: number, inner: string | Token, subtype?: 'td' | 'th' | 'caption', attr?: Record<string, string>): void;
|
|
172
|
+
/**
|
|
173
|
+
* 移除表格行
|
|
174
|
+
* @param {number} y 行号
|
|
175
|
+
* @complexity `n²`
|
|
176
|
+
*/
|
|
177
|
+
removeTableRow(y: number): TrToken;
|
|
178
|
+
/**
|
|
179
|
+
* 移除表格列
|
|
180
|
+
* @param {number} x 列号
|
|
181
|
+
* @complexity `n²`
|
|
182
|
+
*/
|
|
183
|
+
removeTableCol(x: number): void;
|
|
184
|
+
/**
|
|
185
|
+
* 合并单元格
|
|
186
|
+
* @param {[number, number]} xlim 列范围
|
|
187
|
+
* @param {[number, number]} ylim 行范围
|
|
188
|
+
* @complexity `n²`
|
|
189
|
+
* @throws `RangeError` 待合并区域与外侧区域有重叠
|
|
190
|
+
*/
|
|
191
|
+
mergeCells(xlim: [number, number], ylim: [number, number]): TdToken;
|
|
192
|
+
/**
|
|
193
|
+
* 分裂成多行
|
|
194
|
+
* @param {TableCoords & TableRenderedCoords} coords 单元格坐标
|
|
195
|
+
* @complexity `n²`
|
|
196
|
+
*/
|
|
197
|
+
splitIntoRows(coords: TableCoords & TableRenderedCoords): void;
|
|
198
|
+
/**
|
|
199
|
+
* 分裂成多列
|
|
200
|
+
* @param {TableCoords & TableRenderedCoords} coords 单元格坐标
|
|
201
|
+
* @complexity `n²`
|
|
202
|
+
*/
|
|
203
|
+
splitIntoCols(coords: TableCoords & TableRenderedCoords): void;
|
|
204
|
+
/**
|
|
205
|
+
* 分裂成单元格
|
|
206
|
+
* @param {TableCoords & TableRenderedCoords} coords 单元格坐标
|
|
207
|
+
* @complexity `n²`
|
|
208
|
+
*/
|
|
209
|
+
splitIntoCells(coords: TableCoords & TableRenderedCoords): void;
|
|
210
|
+
/**
|
|
211
|
+
* 复制一行并插入该行之前
|
|
212
|
+
* @param {number} row 行号
|
|
213
|
+
* @complexity `n²`
|
|
214
|
+
*/
|
|
215
|
+
replicateTableRow(row: number): TrToken;
|
|
216
|
+
/**
|
|
217
|
+
* 复制一列并插入该列之前
|
|
218
|
+
* @param {number} x 列号
|
|
219
|
+
* @complexity `n`
|
|
220
|
+
*/
|
|
221
|
+
replicateTableCol(x: number): TdToken[];
|
|
222
|
+
/**
|
|
223
|
+
* 移动表格行
|
|
224
|
+
* @param {number} y 行号
|
|
225
|
+
* @param {number} before 新位置
|
|
226
|
+
* @complexity `n²`
|
|
227
|
+
* @throws `RangeError` 无法移动
|
|
228
|
+
*/
|
|
229
|
+
moveTableRowBefore(y: number, before: number): TrToken;
|
|
230
|
+
/**
|
|
231
|
+
* 移动表格行
|
|
232
|
+
* @param {number} y 行号
|
|
233
|
+
* @param {number} after 新位置
|
|
234
|
+
* @complexity `n²`
|
|
235
|
+
* @throws `RangeError` 无法移动
|
|
236
|
+
*/
|
|
237
|
+
moveTableRowAfter(y: number, after: number): TrToken;
|
|
238
|
+
/**
|
|
239
|
+
* 移动表格列
|
|
240
|
+
* @param {number} x 列号
|
|
241
|
+
* @param {number} before 新位置
|
|
242
|
+
* @complexity `n`
|
|
243
|
+
*/
|
|
244
|
+
moveTableColBefore(x: number, before: number): void;
|
|
245
|
+
/**
|
|
246
|
+
* 移动表格列
|
|
247
|
+
* @param {number} x 列号
|
|
248
|
+
* @param {number} after 新位置
|
|
249
|
+
* @complexity `n`
|
|
250
|
+
*/
|
|
251
|
+
moveTableColAfter(x: number, after: number): void;
|
|
252
|
+
#private;
|
|
253
|
+
}
|
|
254
|
+
declare namespace TableToken {
|
|
255
|
+
export { TableCoords, TableRenderedCoords };
|
|
15
256
|
}
|
|
16
257
|
import TrToken = require("./tr");
|
|
258
|
+
import SyntaxToken = require("../syntax");
|
|
259
|
+
type TableCoords = import('../../../typings/table').TableCoords;
|
|
260
|
+
type TableRenderedCoords = import('../../../typings/table').TableRenderedCoords;
|
|
261
|
+
import TdToken = require("./td");
|
|
262
|
+
/** @extends {Array<TableCoords[]>} */
|
|
263
|
+
declare class Layout extends Array<import("../../../typings/table").TableCoords[]> {
|
|
264
|
+
constructor(arrayLength?: number);
|
|
265
|
+
constructor(arrayLength: number);
|
|
266
|
+
constructor(...items: import("../../../typings/table").TableCoords[][]);
|
|
267
|
+
/**
|
|
268
|
+
* 打印表格布局
|
|
269
|
+
* @complexity `n`
|
|
270
|
+
*/
|
|
271
|
+
print(): void;
|
|
272
|
+
}
|
|
273
|
+
import Token = require("..");
|
package/dist/src/table/td.d.ts
CHANGED
|
@@ -4,36 +4,97 @@ export = TdToken;
|
|
|
4
4
|
* @classdesc `{childNodes: [SyntaxToken, AttributesToken, Token]}`
|
|
5
5
|
*/
|
|
6
6
|
declare class TdToken extends TrToken {
|
|
7
|
+
/**
|
|
8
|
+
* 创建新的单元格
|
|
9
|
+
* @param {string|Token} inner 内部wikitext
|
|
10
|
+
* @param {'td'|'th'|'caption'} subtype 单元格类型
|
|
11
|
+
* @param {Record<string, string>} attr 单元格属性
|
|
12
|
+
* @param {boolean} include 是否嵌入
|
|
13
|
+
* @throws `RangeError` 非法的单元格类型
|
|
14
|
+
*/
|
|
15
|
+
static create(inner: string | Token, subtype?: 'td' | 'th' | 'caption', attr?: Record<string, string>, include?: boolean, config?: import("../../../typings/token").ParserConfig): TdToken;
|
|
7
16
|
/**
|
|
8
17
|
* @param {string} syntax 单元格语法
|
|
9
18
|
* @param {string} inner 内部wikitext
|
|
10
19
|
* @param {import('../../../typings/token').accum} accum
|
|
11
20
|
*/
|
|
12
21
|
constructor(syntax: string, inner: string, config?: import("../../../typings/token").ParserConfig, accum?: import('../../../typings/token').accum);
|
|
22
|
+
set subtype(arg: "caption" | "td" | "th");
|
|
13
23
|
/**
|
|
14
24
|
* 单元格类型
|
|
15
25
|
* @complexity `n`
|
|
16
26
|
*/
|
|
17
27
|
get subtype(): "caption" | "td" | "th";
|
|
28
|
+
set rowspan(arg: number);
|
|
29
|
+
/** rowspan */
|
|
30
|
+
get rowspan(): number;
|
|
31
|
+
set colspan(arg: number);
|
|
32
|
+
/** colspan */
|
|
33
|
+
get colspan(): number;
|
|
34
|
+
/** 内部wikitext */
|
|
35
|
+
get innerText(): string;
|
|
36
|
+
/** 是否位于行首 */
|
|
37
|
+
isIndependent(): boolean;
|
|
18
38
|
/**
|
|
19
39
|
* 获取单元格语法信息
|
|
20
|
-
* @returns {{subtype: 'td'|'th'|'caption'}}
|
|
40
|
+
* @returns {{subtype: 'td'|'th'|'caption', escape: boolean, correction: boolean}}
|
|
21
41
|
* @complexity `n`
|
|
22
42
|
*/
|
|
23
43
|
getSyntax(): {
|
|
24
44
|
subtype: 'td' | 'th' | 'caption';
|
|
45
|
+
escape: boolean;
|
|
46
|
+
correction: boolean;
|
|
25
47
|
};
|
|
26
48
|
/**
|
|
27
49
|
* @override
|
|
28
|
-
* @
|
|
29
|
-
* @complexity `n`
|
|
50
|
+
* @param {number} i 子节点位置
|
|
30
51
|
*/
|
|
31
|
-
override
|
|
52
|
+
override getGaps(i?: number): number;
|
|
53
|
+
/** @override */
|
|
54
|
+
override print(): string;
|
|
55
|
+
/** @override */
|
|
56
|
+
override cloneNode(): TdToken;
|
|
32
57
|
/**
|
|
33
58
|
* @override
|
|
34
|
-
* @
|
|
59
|
+
* @template {string} T
|
|
60
|
+
* @param {T} key 属性键
|
|
61
|
+
* @param {TokenAttribute<T>} value 属性值
|
|
62
|
+
* @returns {this}
|
|
35
63
|
*/
|
|
36
|
-
override
|
|
64
|
+
override setAttribute<T extends string>(key: T, value: import("../../../typings/node").TokenAttribute<T>): this;
|
|
65
|
+
/**
|
|
66
|
+
* 改为独占一行
|
|
67
|
+
* @complexity `n`
|
|
68
|
+
*/
|
|
69
|
+
independence(): void;
|
|
70
|
+
/**
|
|
71
|
+
* 获取单元格属性
|
|
72
|
+
* @template {string} T
|
|
73
|
+
* @param {T} key 属性键
|
|
74
|
+
* @returns {T extends 'rowspan'|'colspan' ? number : string|true}
|
|
75
|
+
*/
|
|
76
|
+
getAttr<T_1 extends string>(key: T_1): T_1 extends "rowspan" | "colspan" ? number : string | true;
|
|
77
|
+
/**
|
|
78
|
+
* 获取全部单元格属性
|
|
79
|
+
* @returns {{rowspan: number, colspan: number, [key: string]: string|true}}
|
|
80
|
+
*/
|
|
81
|
+
getAttrs(): {
|
|
82
|
+
[key: string]: string | true;
|
|
83
|
+
rowspan: number;
|
|
84
|
+
colspan: number;
|
|
85
|
+
};
|
|
86
|
+
/**
|
|
87
|
+
* 设置单元格属性
|
|
88
|
+
* @template {string} T
|
|
89
|
+
* @param {T} key 属性键
|
|
90
|
+
* @param {T extends 'rowspan'|'colspan' ? number : string|boolean} value 属性值
|
|
91
|
+
*/
|
|
92
|
+
setAttr<T_2 extends string>(key: T_2, value: T_2 extends "rowspan" | "colspan" ? number : string | boolean): boolean;
|
|
37
93
|
#private;
|
|
38
94
|
}
|
|
95
|
+
declare namespace TdToken {
|
|
96
|
+
export { TokenAttribute };
|
|
97
|
+
}
|
|
39
98
|
import TrToken = require("./tr");
|
|
99
|
+
import Token = require("..");
|
|
100
|
+
type TokenAttribute<T> = import('../../../typings/node').TokenAttribute<T>;
|
package/dist/src/table/tr.d.ts
CHANGED
|
@@ -13,5 +13,79 @@ declare class TrToken extends Token {
|
|
|
13
13
|
constructor(syntax: string, attr?: string, config?: import("../../../typings/token").ParserConfig, accum?: import('../../../typings/token').accum, pattern?: RegExp);
|
|
14
14
|
/** @override */
|
|
15
15
|
override text(): string;
|
|
16
|
+
/**
|
|
17
|
+
* @override
|
|
18
|
+
* @this {TrToken & {constructor: typeof TrToken}}
|
|
19
|
+
*/
|
|
20
|
+
override cloneNode(this: TrToken & {
|
|
21
|
+
constructor: typeof TrToken;
|
|
22
|
+
}): TrToken;
|
|
23
|
+
/**
|
|
24
|
+
* @override
|
|
25
|
+
* @param {string} selector
|
|
26
|
+
*/
|
|
27
|
+
override toString(selector: string): string;
|
|
28
|
+
/**
|
|
29
|
+
* 转义表格语法
|
|
30
|
+
* @complexity `n`
|
|
31
|
+
*/
|
|
32
|
+
escape(): void;
|
|
33
|
+
/**
|
|
34
|
+
* 设置表格语法
|
|
35
|
+
* @param {string} syntax 表格语法
|
|
36
|
+
* @param {boolean} esc 是否需要转义
|
|
37
|
+
*/
|
|
38
|
+
setSyntax(syntax: string, esc: boolean): void;
|
|
39
|
+
/**
|
|
40
|
+
* @override
|
|
41
|
+
* @template {AstText|Token} T
|
|
42
|
+
* @param {T} token 待插入的子节点
|
|
43
|
+
* @param {number} i 插入位置
|
|
44
|
+
* @returns {T}
|
|
45
|
+
* @complexity `n`
|
|
46
|
+
*/
|
|
47
|
+
override insertAt<T extends Token | AstText>(token: T, i?: number): T;
|
|
48
|
+
/**
|
|
49
|
+
* 获取行数
|
|
50
|
+
* @returns {0|1}
|
|
51
|
+
* @complexity `n`
|
|
52
|
+
*/
|
|
53
|
+
getRowCount(): 0 | 1;
|
|
54
|
+
/**
|
|
55
|
+
* 获取下一行
|
|
56
|
+
* @complexity `n`
|
|
57
|
+
*/
|
|
58
|
+
getNextRow(): Token & TrToken;
|
|
59
|
+
/**
|
|
60
|
+
* 获取前一行
|
|
61
|
+
* @complexity `n`
|
|
62
|
+
*/
|
|
63
|
+
getPreviousRow(): Token & TrToken;
|
|
64
|
+
/**
|
|
65
|
+
* 获取列数
|
|
66
|
+
* @complexity `n`
|
|
67
|
+
*/
|
|
68
|
+
getColCount(): number;
|
|
69
|
+
/**
|
|
70
|
+
* 获取第n列
|
|
71
|
+
* @param {number} n 列号
|
|
72
|
+
* @param {boolean} insert 是否用于判断插入新列的位置
|
|
73
|
+
* @returns {TdToken}
|
|
74
|
+
* @complexity `n`
|
|
75
|
+
* @throws `RangeError` 不存在对应单元格
|
|
76
|
+
*/
|
|
77
|
+
getNthCol(n: number, insert: boolean): import("./td");
|
|
78
|
+
/**
|
|
79
|
+
* 插入新的单元格
|
|
80
|
+
* @param {string|Token} inner 单元格内部wikitext
|
|
81
|
+
* @param {import('../../../typings/table').TableCoords} coord 单元格坐标
|
|
82
|
+
* @param {'td'|'th'|'caption'} subtype 单元格类型
|
|
83
|
+
* @param {Record<string, string|boolean>} attr 单元格属性
|
|
84
|
+
* @returns {TdToken}
|
|
85
|
+
* @complexity `n`
|
|
86
|
+
*/
|
|
87
|
+
insertTableCell(inner: string | Token, { column }: import('../../../typings/table').TableCoords, subtype?: 'td' | 'th' | 'caption', attr?: Record<string, string | boolean>): import("./td");
|
|
88
|
+
#private;
|
|
16
89
|
}
|
|
17
90
|
import Token = require("..");
|
|
91
|
+
import AstText = require("../../lib/text");
|
|
@@ -12,6 +12,7 @@ declare class ExtToken extends TagPairToken {
|
|
|
12
12
|
* @param {import('../../../typings/token').accum} accum
|
|
13
13
|
*/
|
|
14
14
|
constructor(name: string, attr?: string, inner?: string, closed?: string | undefined, config?: import("../../../typings/token").ParserConfig, accum?: import('../../../typings/token').accum);
|
|
15
|
-
|
|
15
|
+
/** @override */
|
|
16
|
+
override cloneNode(): ExtToken;
|
|
16
17
|
}
|
|
17
18
|
import TagPairToken = require(".");
|
|
@@ -12,5 +12,14 @@ declare class IncludeToken extends TagPairToken {
|
|
|
12
12
|
* @param {import('../../../typings/token').accum} accum
|
|
13
13
|
*/
|
|
14
14
|
constructor(name: string, attr?: string, inner?: string | undefined, closed?: string | undefined, config?: import("../../../typings/token").ParserConfig, accum?: import('../../../typings/token').accum);
|
|
15
|
+
/** @override */
|
|
16
|
+
override cloneNode(): IncludeToken;
|
|
17
|
+
/**
|
|
18
|
+
* @override
|
|
19
|
+
* @param {string} str 新文本
|
|
20
|
+
*/
|
|
21
|
+
override setText(str: string): string;
|
|
22
|
+
/** 清除标签属性 */
|
|
23
|
+
removeAttr(): void;
|
|
15
24
|
}
|
|
16
25
|
import TagPairToken = require(".");
|
|
@@ -12,17 +12,30 @@ declare class TagPairToken extends Token {
|
|
|
12
12
|
* @param {import('../../../typings/token').accum} accum
|
|
13
13
|
*/
|
|
14
14
|
constructor(name: string, attr: string | Token, inner: string | Token, closed: string | undefined, config?: import("../../../typings/token").ParserConfig, accum?: import('../../../typings/token').accum);
|
|
15
|
+
set closed(arg: boolean);
|
|
15
16
|
/** getter */
|
|
16
17
|
get closed(): boolean;
|
|
18
|
+
set selfClosing(arg: boolean);
|
|
19
|
+
/** getter */
|
|
20
|
+
get selfClosing(): boolean;
|
|
21
|
+
/** 内部wikitext */
|
|
22
|
+
get innerText(): string;
|
|
17
23
|
/**
|
|
18
24
|
* @override
|
|
25
|
+
* @param {string} selector
|
|
19
26
|
*/
|
|
20
|
-
override toString(selector:
|
|
27
|
+
override toString(selector: string): string;
|
|
21
28
|
/**
|
|
22
29
|
* @override
|
|
23
30
|
* @returns {string}
|
|
24
31
|
*/
|
|
25
32
|
override text(): string;
|
|
33
|
+
/** @override */
|
|
34
|
+
override print(): string;
|
|
26
35
|
#private;
|
|
27
36
|
}
|
|
37
|
+
declare namespace TagPairToken {
|
|
38
|
+
export { TokenAttribute };
|
|
39
|
+
}
|
|
28
40
|
import Token = require("..");
|
|
41
|
+
type TokenAttribute<T> = import('../../../typings/node').TokenAttribute<T>;
|
package/dist/src/transclude.d.ts
CHANGED
|
@@ -13,6 +13,8 @@ declare class TranscludeToken extends Token {
|
|
|
13
13
|
*/
|
|
14
14
|
constructor(title: string, parts: [string, string | undefined][], config?: import("../../typings/token").ParserConfig, accum?: import('../../typings/token').accum);
|
|
15
15
|
modifier: string;
|
|
16
|
+
/** 是否存在重复参数 */
|
|
17
|
+
get duplication(): boolean;
|
|
16
18
|
/**
|
|
17
19
|
* 设置引用修饰符
|
|
18
20
|
* @param {string} modifier 引用修饰符
|
|
@@ -21,14 +23,17 @@ declare class TranscludeToken extends Token {
|
|
|
21
23
|
setModifier(modifier?: string): boolean;
|
|
22
24
|
/**
|
|
23
25
|
* @override
|
|
26
|
+
* @param {string} selector
|
|
24
27
|
*/
|
|
25
|
-
override toString(selector:
|
|
28
|
+
override toString(selector: string): string;
|
|
26
29
|
/**
|
|
27
30
|
* @override
|
|
28
31
|
* @returns {string}
|
|
29
32
|
* @complexity `n`
|
|
30
33
|
*/
|
|
31
34
|
override text(): string;
|
|
35
|
+
/** @override */
|
|
36
|
+
override print(): string;
|
|
32
37
|
/** 是否是模板 */
|
|
33
38
|
isTemplate(): boolean;
|
|
34
39
|
/**
|
|
@@ -61,6 +66,7 @@ declare class TranscludeToken extends Token {
|
|
|
61
66
|
* 获取重名参数
|
|
62
67
|
* @complexity `n`
|
|
63
68
|
* @returns {[string, ParameterToken[]][]}
|
|
69
|
+
* @throws `Error` 仅用于模板
|
|
64
70
|
*/
|
|
65
71
|
getDuplicatedArgs(): [string, ParameterToken[]][];
|
|
66
72
|
/**
|
|
@@ -69,6 +75,124 @@ declare class TranscludeToken extends Token {
|
|
|
69
75
|
* @throws `Error` 不是可接受的魔术字
|
|
70
76
|
*/
|
|
71
77
|
getPossibleValues(this: ParameterToken): Token[];
|
|
78
|
+
/** @override */
|
|
79
|
+
override cloneNode(): TranscludeToken;
|
|
80
|
+
/** 替换引用 */
|
|
81
|
+
subst(): void;
|
|
82
|
+
/** 安全的替换引用 */
|
|
83
|
+
safesubst(): void;
|
|
84
|
+
/**
|
|
85
|
+
* @override
|
|
86
|
+
* @param {number} i 移除位置
|
|
87
|
+
* @complexity `n`
|
|
88
|
+
*/
|
|
89
|
+
override removeAt(i: number): ParameterToken;
|
|
90
|
+
/**
|
|
91
|
+
* 是否具有某参数
|
|
92
|
+
* @param {string|number} key 参数名
|
|
93
|
+
* @param {boolean} exact 是否匹配匿名性
|
|
94
|
+
* @complexity `n`
|
|
95
|
+
*/
|
|
96
|
+
hasArg(key: string | number, exact: boolean): boolean;
|
|
97
|
+
/**
|
|
98
|
+
* 获取生效的指定参数
|
|
99
|
+
* @param {string|number} key 参数名
|
|
100
|
+
* @param {boolean} exact 是否匹配匿名性
|
|
101
|
+
* @complexity `n`
|
|
102
|
+
*/
|
|
103
|
+
getArg(key: string | number, exact: boolean): ParameterToken;
|
|
104
|
+
/**
|
|
105
|
+
* 移除指定参数
|
|
106
|
+
* @param {string|number} key 参数名
|
|
107
|
+
* @param {boolean} exact 是否匹配匿名性
|
|
108
|
+
* @complexity `n`
|
|
109
|
+
*/
|
|
110
|
+
removeArg(key: string | number, exact: boolean): void;
|
|
111
|
+
/**
|
|
112
|
+
* 获取所有参数名
|
|
113
|
+
* @complexity `n`
|
|
114
|
+
*/
|
|
115
|
+
getKeys(): string[];
|
|
116
|
+
/**
|
|
117
|
+
* 获取参数值
|
|
118
|
+
* @param {string|number} key 参数名
|
|
119
|
+
* @complexity `n`
|
|
120
|
+
*/
|
|
121
|
+
getValues(key: string | number): string[];
|
|
122
|
+
/**
|
|
123
|
+
* 获取生效的参数值
|
|
124
|
+
* @template {string|number|undefined} T
|
|
125
|
+
* @param {T} key 参数名
|
|
126
|
+
* @returns {T extends undefined ? Record<string, string> : string}
|
|
127
|
+
* @complexity `n`
|
|
128
|
+
*/
|
|
129
|
+
getValue<T extends string | number>(key: T): T extends undefined ? Record<string, string> : string;
|
|
130
|
+
/**
|
|
131
|
+
* 插入匿名参数
|
|
132
|
+
* @param {string} val 参数值
|
|
133
|
+
* @returns {ParameterToken}
|
|
134
|
+
* @complexity `n`
|
|
135
|
+
* @throws `SyntaxError` 非法的匿名参数
|
|
136
|
+
*/
|
|
137
|
+
newAnonArg(val: string): ParameterToken;
|
|
138
|
+
/**
|
|
139
|
+
* 设置参数值
|
|
140
|
+
* @param {string} key 参数名
|
|
141
|
+
* @param {string} value 参数值
|
|
142
|
+
* @complexity `n`
|
|
143
|
+
* @throws `Error` 仅用于模板
|
|
144
|
+
* @throws `SyntaxError` 非法的命名参数
|
|
145
|
+
*/
|
|
146
|
+
setValue(key: string, value: string): void;
|
|
147
|
+
/**
|
|
148
|
+
* 将匿名参数改写为命名参数
|
|
149
|
+
* @complexity `n`
|
|
150
|
+
* @throws `Error` 仅用于模板
|
|
151
|
+
*/
|
|
152
|
+
anonToNamed(): void;
|
|
153
|
+
/**
|
|
154
|
+
* 替换模板名
|
|
155
|
+
* @param {string} title 模板名
|
|
156
|
+
* @throws `Error` 仅用于模板
|
|
157
|
+
* @throws `SyntaxError` 非法的模板名称
|
|
158
|
+
*/
|
|
159
|
+
replaceTemplate(title: string): void;
|
|
160
|
+
/**
|
|
161
|
+
* 替换模块名
|
|
162
|
+
* @param {string} title 模块名
|
|
163
|
+
* @throws `Error` 仅用于模块
|
|
164
|
+
* @throws `SyntaxError` 非法的模块名称
|
|
165
|
+
*/
|
|
166
|
+
replaceModule(title: string): void;
|
|
167
|
+
/**
|
|
168
|
+
* 替换模块函数
|
|
169
|
+
* @param {string} func 模块函数名
|
|
170
|
+
* @throws `Error` 仅用于模块
|
|
171
|
+
* @throws `Error` 尚未指定模块名称
|
|
172
|
+
* @throws `SyntaxError` 非法的模块函数名
|
|
173
|
+
*/
|
|
174
|
+
replaceFunction(func: string): void;
|
|
175
|
+
/**
|
|
176
|
+
* 是否存在重名参数
|
|
177
|
+
* @complexity `n`
|
|
178
|
+
* @throws `Error` 仅用于模板
|
|
179
|
+
*/
|
|
180
|
+
hasDuplicatedArgs(): number;
|
|
181
|
+
/**
|
|
182
|
+
* 修复重名参数:
|
|
183
|
+
* `aggressive = false`时只移除空参数和全同参数,优先保留匿名参数,否则将所有匿名参数更改为命名。
|
|
184
|
+
* `aggressive = true`时还会尝试处理连续的以数字编号的参数。
|
|
185
|
+
* @param {boolean} aggressive 是否使用有更大风险的修复手段
|
|
186
|
+
* @complexity `n²`
|
|
187
|
+
*/
|
|
188
|
+
fixDuplication(aggressive: boolean): string[];
|
|
189
|
+
/**
|
|
190
|
+
* 转义模板内的表格
|
|
191
|
+
* @returns {TranscludeToken}
|
|
192
|
+
* @complexity `n`
|
|
193
|
+
* @throws `Error` 转义失败
|
|
194
|
+
*/
|
|
195
|
+
escapeTables(): TranscludeToken;
|
|
72
196
|
#private;
|
|
73
197
|
}
|
|
74
198
|
import Token = require(".");
|