wikiparser-node 1.0.0-beta.4 → 1.0.1-b

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 (145) hide show
  1. package/README.md +10 -9
  2. package/bundle/bundle.min.js +37 -0
  3. package/config/llwiki.json +1 -35
  4. package/config/moegirl.json +1 -44
  5. package/config/zhwiki.json +1 -466
  6. package/extensions/dist/base.js +105 -0
  7. package/extensions/dist/editor.js +172 -0
  8. package/extensions/dist/highlight.js +46 -0
  9. package/extensions/dist/lint.js +43 -0
  10. package/extensions/editor.css +63 -0
  11. package/extensions/ui.css +119 -0
  12. package/package.json +29 -16
  13. package/config/.schema.json +0 -160
  14. package/dist/index.d.ts +0 -62
  15. package/dist/index.js +0 -305
  16. package/dist/internal.d.ts +0 -44
  17. package/dist/lib/element.d.ts +0 -190
  18. package/dist/lib/element.js +0 -674
  19. package/dist/lib/node.d.ts +0 -178
  20. package/dist/lib/node.js +0 -457
  21. package/dist/lib/range.d.ts +0 -132
  22. package/dist/lib/range.js +0 -384
  23. package/dist/lib/ranges.d.ts +0 -28
  24. package/dist/lib/ranges.js +0 -125
  25. package/dist/lib/text.d.ts +0 -78
  26. package/dist/lib/text.js +0 -227
  27. package/dist/lib/title.d.ts +0 -34
  28. package/dist/lib/title.js +0 -111
  29. package/dist/mixin/attributesParent.js +0 -93
  30. package/dist/mixin/fixed.js +0 -32
  31. package/dist/mixin/hidden.js +0 -23
  32. package/dist/mixin/singleLine.js +0 -26
  33. package/dist/mixin/sol.js +0 -44
  34. package/dist/parser/braces.js +0 -120
  35. package/dist/parser/commentAndExt.js +0 -64
  36. package/dist/parser/converter.js +0 -39
  37. package/dist/parser/externalLinks.js +0 -27
  38. package/dist/parser/hrAndDoubleUnderscore.js +0 -37
  39. package/dist/parser/html.js +0 -35
  40. package/dist/parser/links.js +0 -93
  41. package/dist/parser/list.js +0 -58
  42. package/dist/parser/magicLinks.js +0 -39
  43. package/dist/parser/quotes.js +0 -66
  44. package/dist/parser/selector.js +0 -162
  45. package/dist/parser/table.js +0 -108
  46. package/dist/src/arg.d.ts +0 -78
  47. package/dist/src/arg.js +0 -203
  48. package/dist/src/atom.d.ts +0 -12
  49. package/dist/src/atom.js +0 -24
  50. package/dist/src/attribute.d.ts +0 -107
  51. package/dist/src/attribute.js +0 -446
  52. package/dist/src/attributes.d.ts +0 -120
  53. package/dist/src/attributes.js +0 -360
  54. package/dist/src/converter.d.ts +0 -76
  55. package/dist/src/converter.js +0 -134
  56. package/dist/src/converterFlags.d.ts +0 -108
  57. package/dist/src/converterFlags.js +0 -237
  58. package/dist/src/converterRule.d.ts +0 -97
  59. package/dist/src/converterRule.js +0 -253
  60. package/dist/src/extLink.d.ts +0 -64
  61. package/dist/src/extLink.js +0 -156
  62. package/dist/src/gallery.d.ts +0 -72
  63. package/dist/src/gallery.js +0 -133
  64. package/dist/src/heading.d.ts +0 -84
  65. package/dist/src/heading.js +0 -134
  66. package/dist/src/hidden.d.ts +0 -20
  67. package/dist/src/hidden.js +0 -26
  68. package/dist/src/html.d.ts +0 -115
  69. package/dist/src/html.js +0 -247
  70. package/dist/src/imageParameter.d.ts +0 -83
  71. package/dist/src/imageParameter.js +0 -255
  72. package/dist/src/imagemap.d.ts +0 -79
  73. package/dist/src/imagemap.js +0 -164
  74. package/dist/src/imagemapLink.d.ts +0 -49
  75. package/dist/src/imagemapLink.js +0 -39
  76. package/dist/src/index.d.ts +0 -157
  77. package/dist/src/index.js +0 -818
  78. package/dist/src/link/base.d.ts +0 -70
  79. package/dist/src/link/base.js +0 -229
  80. package/dist/src/link/category.d.ts +0 -14
  81. package/dist/src/link/category.js +0 -29
  82. package/dist/src/link/file.d.ts +0 -106
  83. package/dist/src/link/file.js +0 -271
  84. package/dist/src/link/galleryImage.d.ts +0 -37
  85. package/dist/src/link/galleryImage.js +0 -101
  86. package/dist/src/link/index.d.ts +0 -50
  87. package/dist/src/link/index.js +0 -136
  88. package/dist/src/magicLink.d.ts +0 -47
  89. package/dist/src/magicLink.js +0 -130
  90. package/dist/src/nested.d.ts +0 -49
  91. package/dist/src/nested.js +0 -88
  92. package/dist/src/nowiki/base.d.ts +0 -39
  93. package/dist/src/nowiki/base.js +0 -31
  94. package/dist/src/nowiki/comment.d.ts +0 -43
  95. package/dist/src/nowiki/comment.js +0 -62
  96. package/dist/src/nowiki/dd.d.ts +0 -22
  97. package/dist/src/nowiki/dd.js +0 -47
  98. package/dist/src/nowiki/doubleUnderscore.d.ts +0 -37
  99. package/dist/src/nowiki/doubleUnderscore.js +0 -48
  100. package/dist/src/nowiki/hr.d.ts +0 -24
  101. package/dist/src/nowiki/hr.js +0 -29
  102. package/dist/src/nowiki/index.d.ts +0 -20
  103. package/dist/src/nowiki/index.js +0 -24
  104. package/dist/src/nowiki/list.d.ts +0 -16
  105. package/dist/src/nowiki/list.js +0 -14
  106. package/dist/src/nowiki/noinclude.d.ts +0 -21
  107. package/dist/src/nowiki/noinclude.js +0 -25
  108. package/dist/src/nowiki/quote.d.ts +0 -20
  109. package/dist/src/nowiki/quote.js +0 -66
  110. package/dist/src/onlyinclude.d.ts +0 -39
  111. package/dist/src/onlyinclude.js +0 -66
  112. package/dist/src/paramTag/index.d.ts +0 -52
  113. package/dist/src/paramTag/index.js +0 -78
  114. package/dist/src/paramTag/inputbox.d.ts +0 -8
  115. package/dist/src/paramTag/inputbox.js +0 -22
  116. package/dist/src/parameter.d.ts +0 -96
  117. package/dist/src/parameter.js +0 -203
  118. package/dist/src/pre.d.ts +0 -29
  119. package/dist/src/pre.js +0 -49
  120. package/dist/src/syntax.d.ts +0 -23
  121. package/dist/src/syntax.js +0 -67
  122. package/dist/src/table/base.d.ts +0 -61
  123. package/dist/src/table/base.js +0 -78
  124. package/dist/src/table/index.d.ts +0 -248
  125. package/dist/src/table/index.js +0 -782
  126. package/dist/src/table/td.d.ts +0 -121
  127. package/dist/src/table/td.js +0 -267
  128. package/dist/src/table/tr.d.ts +0 -32
  129. package/dist/src/table/tr.js +0 -51
  130. package/dist/src/table/trBase.d.ts +0 -62
  131. package/dist/src/table/trBase.js +0 -157
  132. package/dist/src/tagPair/ext.d.ts +0 -55
  133. package/dist/src/tagPair/ext.js +0 -138
  134. package/dist/src/tagPair/include.d.ts +0 -43
  135. package/dist/src/tagPair/include.js +0 -42
  136. package/dist/src/tagPair/index.d.ts +0 -57
  137. package/dist/src/tagPair/index.js +0 -107
  138. package/dist/src/transclude.d.ts +0 -201
  139. package/dist/src/transclude.js +0 -727
  140. package/dist/util/debug.js +0 -42
  141. package/dist/util/diff.js +0 -71
  142. package/dist/util/lint.js +0 -48
  143. package/dist/util/string.js +0 -75
  144. package/errors/README +0 -1
  145. package/printed/README +0 -1
package/dist/index.d.ts DELETED
@@ -1,62 +0,0 @@
1
- import type { Title } from './lib/title';
2
- import type { Token } from './internal';
3
- export interface Config {
4
- ext: string[];
5
- html: [string[], string[], string[]];
6
- namespaces: Record<string, string>;
7
- nsid: Record<string, number>;
8
- parserFunction: [Record<string, string>, string[], string[], string[]];
9
- doubleUnderscore: [string[], string[]];
10
- protocol: string;
11
- img: Record<string, string>;
12
- variants: string[];
13
- interwiki: string[];
14
- excludes?: string[];
15
- conversionTable?: [string, string][];
16
- redirects?: [string, string][];
17
- }
18
- export interface LintError {
19
- message: string;
20
- severity: 'error' | 'warning';
21
- startIndex: number;
22
- endIndex: number;
23
- startLine: number;
24
- startCol: number;
25
- endLine: number;
26
- endCol: number;
27
- excerpt: string;
28
- }
29
- declare interface Parser {
30
- /** @browser */
31
- config: string | Config;
32
- /** @browser */
33
- i18n?: string | Record<string, string>;
34
- conversionTable: Map<string, string>;
35
- redirects: Map<string, string>;
36
- /**
37
- * 规范化页面标题
38
- * @browser
39
- * @param title 标题(含或不含命名空间前缀)
40
- * @param defaultNs 命名空间
41
- * @param include 是否嵌入
42
- * @param halfParsed 是否是半解析状态
43
- * @param decode 是否需要解码
44
- * @param selfLink 是否允许selfLink
45
- */
46
- normalizeTitle(title: string, defaultNs?: number, include?: boolean, config?: Config, halfParsed?: boolean, decode?: boolean, selfLink?: boolean): Title;
47
- /**
48
- * 解析wikitext
49
- * @browser
50
- * @param include 是否嵌入
51
- * @param maxStage 最大解析层级
52
- */
53
- parse(wikitext: string, include?: boolean, maxStage?: number, config?: Config): Token;
54
- /**
55
- * 是否是跨维基链接
56
- * @param title 链接标题
57
- */
58
- isInterwiki(title: string, config?: Config): [string, string] | null;
59
- }
60
- declare const Parser: Parser;
61
- export = Parser;
62
- export type * from './internal';
package/dist/index.js DELETED
@@ -1,305 +0,0 @@
1
- "use strict";
2
- /* eslint n/exports-style: 0 */
3
- const fs = require("fs");
4
- const path = require("path");
5
- /**
6
- * 从根路径require
7
- * @param file 文件名
8
- * @param dir 子路径
9
- */
10
- const rootRequire = (file, dir) => require(file.startsWith('/') ? file : `../${file.includes('/') ? '' : dir}${file}`);
11
- // eslint-disable-next-line @typescript-eslint/no-redeclare
12
- const Parser = {
13
- config: 'default',
14
- MAX_STAGE: 11,
15
- conversionTable: new Map(),
16
- redirects: new Map(),
17
- warning: true,
18
- debugging: false,
19
- running: false,
20
- classes: {},
21
- mixins: {},
22
- parsers: {},
23
- aliases: [
24
- ['AstText'],
25
- ['CommentToken', 'ExtToken', 'IncludeToken', 'NoincludeToken'],
26
- ['ArgToken', 'TranscludeToken', 'HeadingToken'],
27
- ['HtmlToken'],
28
- ['TableToken'],
29
- ['HrToken', 'DoubleUnderscoreToken'],
30
- ['LinkToken', 'FileToken', 'CategoryToken'],
31
- ['QuoteToken'],
32
- ['ExtLinkToken'],
33
- ['MagicLinkToken'],
34
- ['ListToken', 'DdToken'],
35
- ['ConverterToken'],
36
- ],
37
- typeAliases: {
38
- text: ['string', 'str'],
39
- plain: ['regular', 'normal'],
40
- // comment and extension
41
- onlyinclude: ['only-include'],
42
- noinclude: ['no-include'],
43
- include: ['includeonly', 'include-only'],
44
- comment: undefined,
45
- ext: ['extension'],
46
- 'ext-attrs': ['extension-attrs', 'ext-attributes', 'extension-attributes'],
47
- 'ext-attr-dirty': ['extension-attr-dirty', 'ext-attribute-dirty', 'extension-attribute-dirty'],
48
- 'ext-attr': ['extension-attr', 'ext-attribute', 'extension-attribute'],
49
- 'attr-key': ['attribute-key'],
50
- 'attr-value': ['attribute-value', 'attr-val', 'attribute-val'],
51
- 'ext-inner': ['extension-inner'],
52
- // triple braces
53
- arg: ['argument'],
54
- 'arg-name': ['argument-name'],
55
- 'arg-default': ['argument-default'],
56
- hidden: ['arg-redundant'],
57
- // double braces
58
- 'magic-word': ['parser-function', 'parser-func'],
59
- 'magic-word-name': ['parser-function-name', 'parser-func-name'],
60
- 'invoke-function': ['invoke-func', 'lua-function', 'lua-func', 'module-function', 'module-func'],
61
- 'invoke-module': ['lua-module'],
62
- template: undefined,
63
- 'template-name': undefined,
64
- parameter: ['param'],
65
- 'parameter-key': ['param-key'],
66
- 'parameter-value': ['parameter-val', 'param-value', 'param-val'],
67
- // heading
68
- heading: ['header'],
69
- 'heading-title': ['header-title'],
70
- 'heading-trail': ['header-trail'],
71
- // html
72
- html: undefined,
73
- 'html-attrs': ['html-attributes'],
74
- 'html-attr-dirty': ['html-attribute-dirty'],
75
- 'html-attr': ['html-attribute'],
76
- // table
77
- table: undefined,
78
- tr: ['table-row'],
79
- td: ['table-cell', 'table-data'],
80
- 'table-syntax': undefined,
81
- 'table-attrs': ['tr-attrs', 'td-attrs', 'table-attributes', 'tr-attributes', 'td-attributes'],
82
- 'table-attr-dirty': ['tr-attr-dirty', 'td-attr-dirty', 'table-attribute-dirty', 'tr-attribute-dirty', 'td-attribute-dirty'],
83
- 'table-attr': ['tr-attr', 'td-attr', 'table-attribute', 'tr-attribute', 'td-attribute'],
84
- 'table-inter': undefined,
85
- 'td-inner': ['table-cell-inner', 'table-data-inner'],
86
- // hr and double-underscore
87
- hr: ['horizontal'],
88
- 'double-underscore': ['underscore', 'behavior-switch', 'behaviour-switch'],
89
- // link
90
- link: ['wikilink'],
91
- 'link-target': ['wikilink-target'],
92
- 'link-text': ['wikilink-text'],
93
- category: ['category-link', 'cat', 'cat-link'],
94
- file: ['file-link', 'image', 'image-link', 'img', 'img-link'],
95
- 'gallery-image': ['gallery-file', 'gallery-img'],
96
- 'imagemap-image': ['imagemap-file', 'imagemap-img', 'image-map-image', 'image-map-file', 'image-map-img'],
97
- 'image-parameter': ['img-parameter', 'image-param', 'img-param'],
98
- // quotes
99
- quote: ['quotes', 'quot', 'apostrophe', 'apostrophes', 'apos'],
100
- // external link
101
- 'ext-link': ['external-link'],
102
- 'ext-link-text': ['external-link-text'],
103
- 'ext-link-url': ['external-link-url'],
104
- // magic link
105
- 'free-ext-link': ['free-external-link', 'magic-link'],
106
- // list
107
- list: ['ol', 'ordered-list', 'ul', 'unordered-list', 'dl', 'description-list'],
108
- dd: ['indent', 'indentation'],
109
- // converter
110
- converter: ['convert', 'conversion'],
111
- 'converter-flags': ['convert-flags', 'conversion-flags'],
112
- 'converter-flag': ['convert-flag', 'conversion-flag'],
113
- 'converter-rule': ['convert-rule', 'conversion-rule'],
114
- 'converter-rule-noconvert': ['convert-rule-noconvert', 'conversion-rule-noconvert'],
115
- 'converter-rule-variant': ['convert-rule-variant', 'conversion-rule-variant'],
116
- 'converter-rule-to': ['convert-rule-to', 'conversion-rule-to'],
117
- 'converter-rule-from': ['convert-rule-from', 'conversion-rule-from'],
118
- // specific extensions
119
- 'param-line': ['parameter-line'],
120
- 'imagemap-link': ['image-map-link'],
121
- },
122
- promises: [Promise.resolve()],
123
- /** @implements */
124
- getConfig() {
125
- if (typeof this.config === 'string') {
126
- this.config = rootRequire(this.config, 'config/');
127
- const { config: { conversionTable, redirects } } = this;
128
- if (conversionTable) {
129
- this.conversionTable = new Map(conversionTable);
130
- }
131
- if (redirects) {
132
- this.redirects = new Map(redirects);
133
- }
134
- return this.getConfig();
135
- }
136
- return { ...this.config, excludes: [] };
137
- },
138
- /** @implements */
139
- msg(msg, arg = '') {
140
- if (typeof this.i18n === 'string') {
141
- this.i18n = rootRequire(this.i18n, 'i18n/');
142
- return this.msg(msg, arg);
143
- }
144
- return (this.i18n?.[msg] ?? msg).replace('$1', arg);
145
- },
146
- /** @implements */
147
- normalizeTitle(title, defaultNs = 0, include = false, config = Parser.getConfig(), halfParsed = false, decode = false, selfLink = false) {
148
- const { Title } = require('./lib/title');
149
- if (halfParsed) {
150
- return new Title(title, defaultNs, config, decode, selfLink);
151
- }
152
- const { Token } = require('./src');
153
- const token = this.run(() => new Token(title, config).parseOnce(0, include).parseOnce()), titleObj = new Title(String(token.firstChild), defaultNs, config, decode, selfLink);
154
- this.run(() => {
155
- for (const key of ['main', 'fragment']) {
156
- if (titleObj[key]?.includes('\0')) {
157
- titleObj[key] = token.buildFromStr(titleObj[key], 'text');
158
- }
159
- }
160
- });
161
- titleObj.conversionTable = this.conversionTable;
162
- titleObj.redirects = this.redirects;
163
- return titleObj;
164
- },
165
- /** @implements */
166
- parse(wikitext, include, maxStage = Parser.MAX_STAGE, config = Parser.getConfig()) {
167
- const { Token } = require('./src');
168
- let token;
169
- this.run(() => {
170
- token = new Token(wikitext, config);
171
- try {
172
- token.parse(maxStage, include);
173
- }
174
- catch (e) {
175
- if (e instanceof Error) {
176
- const file = path.join(__dirname, '..', 'errors', new Date().toISOString()), stage = token.getAttribute('stage');
177
- fs.writeFileSync(file, stage === this.MAX_STAGE ? wikitext : String(token));
178
- fs.writeFileSync(`${file}.err`, e.stack);
179
- fs.writeFileSync(`${file}.json`, JSON.stringify({
180
- stage, include: token.getAttribute('include'), config: this.config,
181
- }, null, '\t'));
182
- }
183
- throw e;
184
- }
185
- });
186
- if (this.debugging) {
187
- let restored = String(token), process = '解析';
188
- if (restored === wikitext) {
189
- const entities = { lt: '<', gt: '>', amp: '&' };
190
- restored = token.print().replace(/<[^<]+?>|&([lg]t|amp);/gu, (_, s) => s ? entities[s] : '');
191
- process = '渲染HTML';
192
- }
193
- if (restored !== wikitext) {
194
- const { diff } = require('./util/diff');
195
- const { promises: { 0: cur, length } } = this;
196
- this.promises.unshift((async () => {
197
- await cur;
198
- this.error(`${process}过程中不可逆地修改了原始文本!`);
199
- return diff(wikitext, restored, length);
200
- })());
201
- }
202
- }
203
- return token;
204
- },
205
- /** @implements */
206
- run(callback) {
207
- const { running } = this;
208
- this.running = true;
209
- try {
210
- const result = callback();
211
- this.running = running;
212
- return result;
213
- }
214
- catch (e) {
215
- this.running = running;
216
- throw e;
217
- }
218
- },
219
- /** @implements */
220
- warn(msg, ...args) {
221
- if (this.warning) {
222
- console.warn('\x1B[33m%s\x1B[0m', msg, ...args);
223
- }
224
- },
225
- /** @implements */
226
- debug(msg, ...args) {
227
- if (this.debugging) {
228
- console.debug('\x1B[34m%s\x1B[0m', msg, ...args);
229
- }
230
- },
231
- /** @implements */
232
- error(msg, ...args) {
233
- console.error('\x1B[31m%s\x1B[0m', msg, ...args);
234
- },
235
- /** @implements */
236
- info(msg, ...args) {
237
- console.info('\x1B[32m%s\x1B[0m', msg, ...args);
238
- },
239
- /** @implements */
240
- log(f) {
241
- if (typeof f === 'function') {
242
- console.log(String(f));
243
- }
244
- },
245
- /** @implements */
246
- clearCache() {
247
- const entries = [
248
- ...Object.entries(this.classes),
249
- ...Object.entries(this.mixins),
250
- ...Object.entries(this.parsers),
251
- ];
252
- for (const [, filePath] of entries) {
253
- try {
254
- delete require.cache[require.resolve(filePath)];
255
- }
256
- catch { }
257
- }
258
- for (const [name, filePath] of entries) {
259
- if (name in global) {
260
- // @ts-expect-error noImplicitAny
261
- global[name] = require(filePath);
262
- }
263
- }
264
- },
265
- /** @implements */
266
- isInterwiki(title, { interwiki } = Parser.getConfig()) {
267
- return new RegExp(`^(${interwiki.join('|')})\\s*:`, 'iu')
268
- .exec(title.replaceAll('_', ' ').replace(/^\s*:?\s*/u, ''));
269
- },
270
- /** @implements */
271
- reparse(date) {
272
- const main = fs.readdirSync(path.join(__dirname, '..', 'errors'))
273
- .find(name => name.startsWith(date) && name.endsWith('Z'));
274
- if (!main) {
275
- throw new RangeError(`找不到对应时间戳的错误记录:${date}`);
276
- }
277
- const file = path.join(__dirname, '..', 'errors', main), wikitext = fs.readFileSync(file, 'utf8');
278
- const { stage, include, config } = require(`${file}.json`), { Token } = require('./src');
279
- this.config = config;
280
- return this.run(() => {
281
- const halfParsed = stage < this.MAX_STAGE, token = new Token(wikitext, this.getConfig(), halfParsed);
282
- if (halfParsed) {
283
- token.setAttribute('stage', stage).parseOnce(stage, include);
284
- }
285
- else {
286
- token.parse(undefined, include);
287
- }
288
- fs.unlinkSync(file);
289
- fs.unlinkSync(`${file}.err`);
290
- fs.unlinkSync(`${file}.json`);
291
- return token;
292
- });
293
- },
294
- };
295
- const def = {}, immutable = new Set(['MAX_STAGE', 'aliases', 'typeAliases', 'promises']), enumerable = new Set(['config', 'conversionTable', 'redirects', 'normalizeTitle', 'parse', 'isInterwiki']);
296
- for (const key in Parser) {
297
- if (immutable.has(key)) {
298
- def[key] = { enumerable: false, writable: false };
299
- }
300
- else if (!enumerable.has(key)) {
301
- def[key] = { enumerable: false };
302
- }
303
- }
304
- Object.defineProperties(Parser, def);
305
- module.exports = Parser;
@@ -1,44 +0,0 @@
1
- export type { AstNodes, } from './lib/node';
2
- export type * from './lib/text';
3
- export type * from './src';
4
- export type * from './src/onlyinclude';
5
- export type * from './src/nowiki/noinclude';
6
- export type * from './src/tagPair/include';
7
- export type * from './src/nowiki/comment';
8
- export type * from './src/atom';
9
- export type { AttributeToken } from './src/attribute';
10
- export type * from './src/attributes';
11
- export type * from './src/tagPair/ext';
12
- export type * from './src/hidden';
13
- export type * from './src/arg';
14
- export type * from './src/syntax';
15
- export type * from './src/parameter';
16
- export type * from './src/transclude';
17
- export type * from './src/heading';
18
- export type * from './src/html';
19
- export type { TdToken } from './src/table/td';
20
- export type * from './src/table/tr';
21
- export type * from './src/table';
22
- export type * from './src/nowiki/hr';
23
- export type * from './src/nowiki/doubleUnderscore';
24
- export type * from './src/link';
25
- export type * from './src/link/category';
26
- export type * from './src/imageParameter';
27
- export type * from './src/link/file';
28
- export type * from './src/link/galleryImage';
29
- export type * from './src/nowiki/quote';
30
- export type * from './src/magicLink';
31
- export type * from './src/extLink';
32
- export type * from './src/nowiki/dd';
33
- export type * from './src/nowiki/list';
34
- export type * from './src/converterFlags';
35
- export type * from './src/converterRule';
36
- export type * from './src/converter';
37
- export type * from './src/nowiki';
38
- export type * from './src/pre';
39
- export type * from './src/paramTag';
40
- export type * from './src/paramTag/inputbox';
41
- export type * from './src/nested';
42
- export type * from './src/gallery';
43
- export type * from './src/imagemapLink';
44
- export type * from './src/imagemap';
@@ -1,190 +0,0 @@
1
- import { AstNode } from './node';
2
- import type { LintError } from '../index';
3
- import type { AstNodes, AstText, Token } from '../internal';
4
- /** 类似HTMLElement */
5
- export declare abstract class AstElement extends AstNode {
6
- #private;
7
- /** @browser */
8
- name?: string;
9
- /**
10
- * 子节点总数
11
- * @browser
12
- */
13
- get length(): number;
14
- /** 全部非文本子节点 */
15
- get children(): Token[];
16
- /** 首位非文本子节点 */
17
- get firstElementChild(): Token | undefined;
18
- /** 末位非文本子节点 */
19
- get lastElementChild(): Token | undefined;
20
- /** 非文本子节点总数 */
21
- get childElementCount(): number;
22
- /** 父节点 */
23
- get parentElement(): Token | undefined;
24
- /** AstElement.prototype.text()的getter写法 */
25
- get outerText(): string;
26
- /** 不可见 */
27
- get hidden(): boolean;
28
- /** 后一个可见的兄弟节点 */
29
- get nextVisibleSibling(): AstNodes | undefined;
30
- /** 前一个可见的兄弟节点 */
31
- get previousVisibleSibling(): AstNodes | undefined;
32
- /** 内部高度 */
33
- get clientHeight(): number | undefined;
34
- /** 内部宽度 */
35
- get clientWidth(): number | undefined;
36
- constructor();
37
- /**
38
- * 可见部分
39
- * @browser
40
- * @param separator 子节点间的连接符
41
- */
42
- text(separator?: string): string;
43
- /**
44
- * 合并相邻的文本子节点
45
- * @browser
46
- */
47
- normalize(): void;
48
- /**
49
- * 移除子节点
50
- * @browser
51
- * @param i 移除位置
52
- */
53
- removeAt(i: number): AstNodes;
54
- /**
55
- * 插入子节点
56
- * @browser
57
- * @param node 待插入的子节点
58
- * @param i 插入位置
59
- * @throws `RangeError` 不能插入祖先节点
60
- */
61
- insertAt<T extends AstNodes>(node: T, i?: number): T;
62
- /**
63
- * 最近的祖先节点
64
- * @browser
65
- * @param selector 选择器
66
- */
67
- closest(selector: string): Token | undefined;
68
- /**
69
- * 在末尾批量插入子节点
70
- * @browser
71
- * @param elements 插入节点
72
- */
73
- append(...elements: (AstNodes | string)[]): void;
74
- /**
75
- * 批量替换子节点
76
- * @browser
77
- * @param elements 新的子节点
78
- */
79
- replaceChildren(...elements: (AstNodes | string)[]): void;
80
- /**
81
- * 修改文本子节点
82
- * @browser
83
- * @param str 新文本
84
- * @param i 子节点位置
85
- * @throws `RangeError` 对应位置的子节点不是文本节点
86
- */
87
- setText(str: string, i?: number): string;
88
- /**
89
- * 还原为wikitext
90
- * @browser
91
- * @param omit 忽略的节点类型
92
- * @param separator 子节点间的连接符
93
- */
94
- toString(omit?: Set<string>, separator?: string): string;
95
- /**
96
- * Linter
97
- * @browser
98
- * @param start
99
- */
100
- lint(start?: number): LintError[];
101
- /**
102
- * 以HTML格式打印
103
- * @browser
104
- * @param opt 选项
105
- */
106
- print(opt?: PrintOpt): string;
107
- /**
108
- * 保存为JSON
109
- * @param file 文件名
110
- */
111
- json(file?: string): unknown;
112
- /** 销毁 */
113
- destroy(): void;
114
- /**
115
- * 检查是否符合选择器
116
- * @param selector 选择器
117
- */
118
- matches(selector?: string): boolean;
119
- /**
120
- * 符合选择器的第一个后代节点
121
- * @param selector 选择器
122
- */
123
- querySelector(selector: string): Token | undefined;
124
- /**
125
- * 类型选择器
126
- * @param types
127
- */
128
- getElementByTypes(types: string): Token | undefined;
129
- /**
130
- * id选择器
131
- * @param id id名
132
- */
133
- getElementById(id: string): Token | undefined;
134
- /**
135
- * 符合选择器的所有后代节点
136
- * @param selector 选择器
137
- */
138
- querySelectorAll(selector: string): Token[];
139
- /**
140
- * 类选择器
141
- * @param className 类名之一
142
- */
143
- getElementsByClassName(className: string): Token[];
144
- /**
145
- * 标签名选择器
146
- * @param tag 标签名
147
- */
148
- getElementsByTagName(tag: string): Token[];
149
- /**
150
- * 获取某一行的wikitext
151
- * @param n 行号
152
- */
153
- getLine(n: number): string | undefined;
154
- /**
155
- * 在开头批量插入子节点
156
- * @param elements 插入节点
157
- */
158
- prepend(...elements: (AstNodes | string)[]): void;
159
- /**
160
- * 移除子节点
161
- * @param node 子节点
162
- */
163
- removeChild<T extends AstNodes>(node: T): T;
164
- /**
165
- * 在末尾插入子节点
166
- * @param node 插入节点
167
- */
168
- appendChild(node: string): AstText;
169
- /** @ignore */
170
- appendChild<T extends AstNodes>(node: T): T;
171
- /**
172
- * 在指定位置前插入子节点
173
- * @param child 插入节点
174
- * @param reference 指定位置处的子节点
175
- */
176
- insertBefore(child: string, reference?: AstNodes): AstText;
177
- /** @ignore */
178
- insertBefore<T extends AstNodes>(child: T, reference?: AstNodes): T;
179
- /**
180
- * 替换子节点
181
- * @param newChild 新子节点
182
- * @param oldChild 原子节点
183
- */
184
- replaceChild<T extends AstNodes>(newChild: AstNodes | string, oldChild: T): T;
185
- /**
186
- * 输出AST
187
- * @param depth 当前深度
188
- */
189
- echo(depth?: number): void;
190
- }