wikiparser-node 1.6.2 → 1.7.0-beta.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 (167) hide show
  1. package/bundle/bundle.min.js +38 -0
  2. package/config/default.json +5 -0
  3. package/config/enwiki.json +4 -814
  4. package/config/llwiki.json +5 -35
  5. package/config/minimum.json +3 -0
  6. package/config/moegirl.json +5 -44
  7. package/config/zhwiki.json +6 -466
  8. package/extensions/dist/base.js +64 -0
  9. package/extensions/dist/editor.js +159 -0
  10. package/extensions/dist/highlight.js +58 -0
  11. package/extensions/dist/lint.js +60 -0
  12. package/extensions/editor.css +64 -0
  13. package/extensions/ui.css +144 -0
  14. package/i18n/zh-hans.json +2 -1
  15. package/i18n/zh-hant.json +2 -1
  16. package/package.json +31 -16
  17. package/config/.schema.json +0 -172
  18. package/dist/addon/table.d.ts +0 -1
  19. package/dist/addon/table.js +0 -485
  20. package/dist/base.d.ts +0 -69
  21. package/dist/base.js +0 -38
  22. package/dist/index.d.ts +0 -31
  23. package/dist/index.js +0 -212
  24. package/dist/internal.d.ts +0 -44
  25. package/dist/lib/element.d.ts +0 -151
  26. package/dist/lib/element.js +0 -618
  27. package/dist/lib/node.d.ts +0 -146
  28. package/dist/lib/node.js +0 -426
  29. package/dist/lib/range.d.ts +0 -104
  30. package/dist/lib/range.js +0 -385
  31. package/dist/lib/ranges.d.ts +0 -28
  32. package/dist/lib/ranges.js +0 -126
  33. package/dist/lib/text.d.ts +0 -63
  34. package/dist/lib/text.js +0 -354
  35. package/dist/lib/title.d.ts +0 -40
  36. package/dist/lib/title.js +0 -179
  37. package/dist/mixin/attributesParent.d.ts +0 -50
  38. package/dist/mixin/attributesParent.js +0 -81
  39. package/dist/mixin/fixed.d.ts +0 -6
  40. package/dist/mixin/fixed.js +0 -30
  41. package/dist/mixin/flagsParent.d.ts +0 -72
  42. package/dist/mixin/flagsParent.js +0 -59
  43. package/dist/mixin/hidden.d.ts +0 -5
  44. package/dist/mixin/hidden.js +0 -24
  45. package/dist/mixin/magicLinkParent.d.ts +0 -40
  46. package/dist/mixin/magicLinkParent.js +0 -42
  47. package/dist/mixin/singleLine.d.ts +0 -6
  48. package/dist/mixin/singleLine.js +0 -26
  49. package/dist/mixin/sol.d.ts +0 -6
  50. package/dist/mixin/sol.js +0 -43
  51. package/dist/mixin/syntax.d.ts +0 -9
  52. package/dist/mixin/syntax.js +0 -50
  53. package/dist/parser/braces.js +0 -130
  54. package/dist/parser/commentAndExt.js +0 -89
  55. package/dist/parser/converter.js +0 -40
  56. package/dist/parser/externalLinks.js +0 -45
  57. package/dist/parser/hrAndDoubleUnderscore.js +0 -40
  58. package/dist/parser/html.js +0 -38
  59. package/dist/parser/links.js +0 -97
  60. package/dist/parser/list.js +0 -97
  61. package/dist/parser/magicLinks.js +0 -42
  62. package/dist/parser/quotes.js +0 -67
  63. package/dist/parser/selector.js +0 -190
  64. package/dist/parser/table.js +0 -123
  65. package/dist/src/arg.d.ts +0 -58
  66. package/dist/src/arg.js +0 -214
  67. package/dist/src/atom.d.ts +0 -12
  68. package/dist/src/atom.js +0 -27
  69. package/dist/src/attribute.d.ts +0 -71
  70. package/dist/src/attribute.js +0 -502
  71. package/dist/src/attributes.d.ts +0 -109
  72. package/dist/src/attributes.js +0 -356
  73. package/dist/src/converter.d.ts +0 -33
  74. package/dist/src/converter.js +0 -134
  75. package/dist/src/converterFlags.d.ts +0 -87
  76. package/dist/src/converterFlags.js +0 -242
  77. package/dist/src/converterRule.d.ts +0 -77
  78. package/dist/src/converterRule.js +0 -209
  79. package/dist/src/extLink.d.ts +0 -43
  80. package/dist/src/extLink.js +0 -191
  81. package/dist/src/gallery.d.ts +0 -54
  82. package/dist/src/gallery.js +0 -139
  83. package/dist/src/heading.d.ts +0 -47
  84. package/dist/src/heading.js +0 -190
  85. package/dist/src/hidden.d.ts +0 -7
  86. package/dist/src/hidden.js +0 -23
  87. package/dist/src/html.d.ts +0 -65
  88. package/dist/src/html.js +0 -358
  89. package/dist/src/imageParameter.d.ts +0 -65
  90. package/dist/src/imageParameter.js +0 -257
  91. package/dist/src/imagemap.d.ts +0 -54
  92. package/dist/src/imagemap.js +0 -144
  93. package/dist/src/imagemapLink.d.ts +0 -31
  94. package/dist/src/imagemapLink.js +0 -93
  95. package/dist/src/index.d.ts +0 -143
  96. package/dist/src/index.js +0 -851
  97. package/dist/src/link/base.d.ts +0 -52
  98. package/dist/src/link/base.js +0 -228
  99. package/dist/src/link/category.d.ts +0 -13
  100. package/dist/src/link/category.js +0 -28
  101. package/dist/src/link/file.d.ts +0 -98
  102. package/dist/src/link/file.js +0 -272
  103. package/dist/src/link/galleryImage.d.ts +0 -32
  104. package/dist/src/link/galleryImage.js +0 -158
  105. package/dist/src/link/index.d.ts +0 -56
  106. package/dist/src/link/index.js +0 -133
  107. package/dist/src/magicLink.d.ts +0 -59
  108. package/dist/src/magicLink.js +0 -223
  109. package/dist/src/nested.d.ts +0 -43
  110. package/dist/src/nested.js +0 -105
  111. package/dist/src/nowiki/base.d.ts +0 -31
  112. package/dist/src/nowiki/base.js +0 -93
  113. package/dist/src/nowiki/comment.d.ts +0 -25
  114. package/dist/src/nowiki/comment.js +0 -76
  115. package/dist/src/nowiki/dd.d.ts +0 -8
  116. package/dist/src/nowiki/dd.js +0 -24
  117. package/dist/src/nowiki/doubleUnderscore.d.ts +0 -18
  118. package/dist/src/nowiki/doubleUnderscore.js +0 -101
  119. package/dist/src/nowiki/hr.d.ts +0 -5
  120. package/dist/src/nowiki/hr.js +0 -63
  121. package/dist/src/nowiki/index.d.ts +0 -16
  122. package/dist/src/nowiki/index.js +0 -27
  123. package/dist/src/nowiki/list.d.ts +0 -16
  124. package/dist/src/nowiki/list.js +0 -109
  125. package/dist/src/nowiki/listBase.d.ts +0 -5
  126. package/dist/src/nowiki/listBase.js +0 -61
  127. package/dist/src/nowiki/noinclude.d.ts +0 -10
  128. package/dist/src/nowiki/noinclude.js +0 -23
  129. package/dist/src/nowiki/quote.d.ts +0 -14
  130. package/dist/src/nowiki/quote.js +0 -131
  131. package/dist/src/onlyinclude.d.ts +0 -16
  132. package/dist/src/onlyinclude.js +0 -57
  133. package/dist/src/paramTag/index.d.ts +0 -37
  134. package/dist/src/paramTag/index.js +0 -77
  135. package/dist/src/paramTag/inputbox.d.ts +0 -8
  136. package/dist/src/paramTag/inputbox.js +0 -22
  137. package/dist/src/parameter.d.ts +0 -70
  138. package/dist/src/parameter.js +0 -264
  139. package/dist/src/pre.d.ts +0 -31
  140. package/dist/src/pre.js +0 -59
  141. package/dist/src/syntax.d.ts +0 -20
  142. package/dist/src/syntax.js +0 -86
  143. package/dist/src/table/base.d.ts +0 -27
  144. package/dist/src/table/base.js +0 -81
  145. package/dist/src/table/index.d.ts +0 -242
  146. package/dist/src/table/index.js +0 -497
  147. package/dist/src/table/td.d.ts +0 -86
  148. package/dist/src/table/td.js +0 -355
  149. package/dist/src/table/tr.d.ts +0 -32
  150. package/dist/src/table/tr.js +0 -58
  151. package/dist/src/table/trBase.d.ts +0 -53
  152. package/dist/src/table/trBase.js +0 -156
  153. package/dist/src/tagPair/ext.d.ts +0 -32
  154. package/dist/src/tagPair/ext.js +0 -203
  155. package/dist/src/tagPair/include.d.ts +0 -35
  156. package/dist/src/tagPair/include.js +0 -74
  157. package/dist/src/tagPair/index.d.ts +0 -27
  158. package/dist/src/tagPair/index.js +0 -128
  159. package/dist/src/transclude.d.ts +0 -167
  160. package/dist/src/transclude.js +0 -717
  161. package/dist/util/constants.js +0 -27
  162. package/dist/util/debug.js +0 -81
  163. package/dist/util/diff.js +0 -83
  164. package/dist/util/lint.js +0 -31
  165. package/dist/util/string.js +0 -60
  166. package/errors/README +0 -1
  167. package/printed/README +0 -1
package/dist/base.d.ts DELETED
@@ -1,69 +0,0 @@
1
- export interface Config {
2
- ext: string[];
3
- readonly html: [string[], string[], string[]];
4
- readonly namespaces: Record<string, string>;
5
- readonly nsid: Record<string, number>;
6
- readonly parserFunction: [Record<string, string>, string[], string[], string[]];
7
- readonly doubleUnderscore: [string[], string[]];
8
- readonly protocol: string;
9
- readonly img: Record<string, string>;
10
- readonly variants: string[];
11
- readonly excludes?: string[];
12
- readonly interwiki: string[];
13
- readonly conversionTable?: [string, string][];
14
- readonly redirects?: [string, string][];
15
- }
16
- export declare const rules: readonly ["bold-header", "format-leakage", "fostered-content", "h1", "illegal-attr", "insecure-style", "invalid-gallery", "invalid-imagemap", "invalid-invoke", "lonely-apos", "lonely-bracket", "lonely-http", "nested-link", "no-arg", "no-duplicate", "no-ignored", "obsolete-attr", "obsolete-tag", "parsing-order", "pipe-like", "table-layout", "tag-like", "unbalanced-header", "unclosed-comment", "unclosed-quote", "unclosed-table", "unescaped", "unknown-page", "unmatched-tag", "unterminated-url", "url-encoding", "var-anchor", "void-ext"];
17
- export declare namespace LintError {
18
- type Severity = 'error' | 'warning';
19
- type Rule = typeof rules[number];
20
- interface Fix {
21
- readonly range: [number, number];
22
- text: string;
23
- }
24
- }
25
- export interface LintError {
26
- rule: LintError.Rule;
27
- message: string;
28
- severity: LintError.Severity;
29
- startIndex: number;
30
- endIndex: number;
31
- startLine: number;
32
- startCol: number;
33
- endLine: number;
34
- endCol: number;
35
- fix?: LintError.Fix;
36
- suggestions?: (LintError.Fix & {
37
- desc: string;
38
- })[];
39
- }
40
- export type AST = Record<string, string | number | boolean> & {
41
- range: [number, number];
42
- type?: string;
43
- childNodes?: AST[];
44
- };
45
- /** 类似Node */
46
- export interface AstNode {
47
- type: string;
48
- readonly childNodes: readonly AstNode[];
49
- /** Linter */
50
- lint(): LintError[];
51
- /** 以HTML格式打印 */
52
- print(): string;
53
- }
54
- /** 类似HTMLElement */
55
- interface AstElement extends AstNode {
56
- /** 保存为JSON */
57
- json(): AST;
58
- }
59
- export interface Parser {
60
- config: string | Config;
61
- i18n: string | Record<string, string> | undefined;
62
- /**
63
- * 解析wikitext
64
- * @param include 是否嵌入
65
- * @param maxStage 最大解析层级
66
- */
67
- parse(wikitext: string, include?: boolean, maxStage?: number, config?: Config): AstElement;
68
- }
69
- export {};
package/dist/base.js DELETED
@@ -1,38 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.rules = void 0;
4
- exports.rules = [
5
- 'bold-header',
6
- 'format-leakage',
7
- 'fostered-content',
8
- 'h1',
9
- 'illegal-attr',
10
- 'insecure-style',
11
- 'invalid-gallery',
12
- 'invalid-imagemap',
13
- 'invalid-invoke',
14
- 'lonely-apos',
15
- 'lonely-bracket',
16
- 'lonely-http',
17
- 'nested-link',
18
- 'no-arg',
19
- 'no-duplicate',
20
- 'no-ignored',
21
- 'obsolete-attr',
22
- 'obsolete-tag',
23
- 'parsing-order',
24
- 'pipe-like',
25
- 'table-layout',
26
- 'tag-like',
27
- 'unbalanced-header',
28
- 'unclosed-comment',
29
- 'unclosed-quote',
30
- 'unclosed-table',
31
- 'unescaped',
32
- 'unknown-page',
33
- 'unmatched-tag',
34
- 'unterminated-url',
35
- 'url-encoding',
36
- 'var-anchor',
37
- 'void-ext',
38
- ];
package/dist/index.d.ts DELETED
@@ -1,31 +0,0 @@
1
- import type { log } from './util/diff';
2
- import type { Config, LintError, Parser as ParserBase } from './base';
3
- import type { Title } from './lib/title';
4
- import type { Token } from './internal';
5
- declare interface Parser extends ParserBase {
6
- rules: readonly LintError.Rule[];
7
- conversionTable: Map<string, string>;
8
- redirects: Map<string, string>;
9
- warning: boolean;
10
- debugging: boolean;
11
- /**
12
- * 规范化页面标题
13
- * @param title 标题(含或不含命名空间前缀)
14
- * @param defaultNs 命名空间
15
- * @param include 是否嵌入
16
- * @param halfParsed 是否是半解析状态
17
- * @param decode 是否需要解码
18
- * @param selfLink 是否允许selfLink
19
- */
20
- normalizeTitle(title: string, defaultNs?: number, include?: boolean, config?: Config, halfParsed?: boolean, decode?: boolean, selfLink?: boolean): Title;
21
- parse(wikitext: string, include?: boolean, maxStage?: number, config?: Config): Token;
22
- /**
23
- * 是否是跨维基链接
24
- * @param title 链接标题
25
- */
26
- isInterwiki(title: string, config?: Config): RegExpExecArray | null;
27
- }
28
- declare const Parser: Parser;
29
- export = Parser;
30
- export type { Config, LintError };
31
- export type * from './internal';
package/dist/index.js DELETED
@@ -1,212 +0,0 @@
1
- "use strict";
2
- /* eslint n/exports-style: 0 */
3
- const fs = require("fs");
4
- const path = require("path");
5
- const chalk = require("chalk");
6
- const base_1 = require("./base");
7
- const debug_1 = require("./util/debug");
8
- const constants_1 = require("./util/constants");
9
- const string_1 = require("./util/string");
10
- const diff_1 = require("./util/diff");
11
- /**
12
- * 从根路径require
13
- * @param file 文件名
14
- * @param dir 子路径
15
- */
16
- const rootRequire = (file, dir) => require(file.startsWith('/') ? file : `../${file.includes('/') ? '' : dir}${file}`);
17
- const promises = [Promise.resolve()];
18
- // eslint-disable-next-line @typescript-eslint/no-redeclare
19
- const Parser = {
20
- config: 'default',
21
- i18n: undefined,
22
- rules: base_1.rules,
23
- /* NOT FOR BROWSER */
24
- conversionTable: new Map(),
25
- redirects: new Map(),
26
- warning: true,
27
- debugging: false,
28
- /* NOT FOR BROWSER END */
29
- /** @implements */
30
- getConfig() {
31
- if (typeof this.config === 'string') {
32
- this.config = rootRequire(this.config, 'config/');
33
- /* NOT FOR BROWSER */
34
- const { config: { conversionTable, redirects } } = this;
35
- if (conversionTable) {
36
- this.conversionTable = new Map(conversionTable);
37
- }
38
- if (redirects) {
39
- this.redirects = new Map(redirects);
40
- }
41
- /* NOT FOR BROWSER END */
42
- return this.getConfig();
43
- }
44
- return {
45
- ...this.config,
46
- excludes: [],
47
- };
48
- },
49
- /** @implements */
50
- msg(msg, arg = '') {
51
- if (typeof this.i18n === 'string') {
52
- this.i18n = rootRequire(this.i18n, 'i18n/');
53
- return this.msg(msg, arg);
54
- }
55
- return msg && (this.i18n?.[msg] ?? msg).replace('$1', this.msg(arg));
56
- },
57
- /** @implements */
58
- normalizeTitle(title, defaultNs = 0, include, config = Parser.getConfig(), halfParsed, decode = false, selfLink = false) {
59
- const { Title } = require('./lib/title');
60
- if (halfParsed) {
61
- return new Title(title, defaultNs, config, decode, selfLink);
62
- }
63
- const { Token } = require('./src/index');
64
- const token = debug_1.Shadow.run(() => new Token(title, config).parseOnce(0, include).parseOnce()), titleObj = new Title(String(token), defaultNs, config, decode, selfLink);
65
- debug_1.Shadow.run(() => {
66
- for (const key of ['main', 'fragment']) {
67
- const str = titleObj[key];
68
- if (str?.includes('\0')) {
69
- titleObj[key] = token.buildFromStr(str, constants_1.BuildMethod.Text);
70
- }
71
- }
72
- });
73
- /* NOT FOR BROWSER */
74
- titleObj.conversionTable = this.conversionTable;
75
- titleObj.redirects = this.redirects;
76
- /* NOT FOR BROWSER END */
77
- return titleObj;
78
- },
79
- /** @implements */
80
- parse(wikitext, include, maxStage = constants_1.MAX_STAGE, config = Parser.getConfig()) {
81
- wikitext = (0, string_1.tidy)(wikitext);
82
- const { Token } = require('./src/index');
83
- const root = debug_1.Shadow.run(() => {
84
- const token = new Token(wikitext, config);
85
- try {
86
- return token.parse(maxStage, include);
87
- }
88
- catch (e) {
89
- if (e instanceof Error) {
90
- const file = path.join(__dirname, '..', 'errors', new Date().toISOString()), stage = token.getAttribute('stage');
91
- fs.writeFileSync(file, stage === constants_1.MAX_STAGE ? wikitext : String(token));
92
- fs.writeFileSync(`${file}.err`, e.stack);
93
- fs.writeFileSync(`${file}.json`, JSON.stringify({ stage, include, config }, null, '\t'));
94
- }
95
- throw e;
96
- }
97
- });
98
- /* NOT FOR BROWSER */
99
- if (this.debugging) {
100
- let restored = String(root), process = 'parsing';
101
- if (restored === wikitext) {
102
- const entities = { lt: '<', gt: '>', amp: '&' };
103
- restored = root.print().replace(/<[^<]+?>|&([lg]t|amp);/gu, (_, s) => s ? entities[s] : '');
104
- process = 'printing';
105
- }
106
- if (restored !== wikitext) {
107
- const { diff } = require('./util/diff');
108
- const { 0: cur, length } = promises;
109
- promises.unshift((async () => {
110
- await cur;
111
- this.error(`Original wikitext is altered when ${process}!`);
112
- return diff(wikitext, restored, length);
113
- })());
114
- }
115
- }
116
- /* NOT FOR BROWSER END */
117
- return root;
118
- },
119
- /* NOT FOR BROWSER */
120
- /** @implements */
121
- warn(msg, ...args) {
122
- if (this.warning) {
123
- console.warn(chalk.yellow(msg), ...args);
124
- }
125
- },
126
- /** @implements */
127
- debug(msg, ...args) {
128
- if (this.debugging) {
129
- console.debug(chalk.blue(msg), ...args);
130
- }
131
- },
132
- error: diff_1.error,
133
- info: diff_1.info,
134
- /** @implements */
135
- log(f) {
136
- if (typeof f === 'function') {
137
- console.log(String(f));
138
- }
139
- },
140
- /** @implements */
141
- async clearCache() {
142
- const promise = (0, diff_1.cmd)('npm', ['run', 'build']), entries = [
143
- ...Object.entries(constants_1.classes),
144
- ...Object.entries(constants_1.mixins),
145
- ...Object.entries(constants_1.parsers),
146
- ];
147
- for (const [, filePath] of entries) {
148
- try {
149
- delete require.cache[require.resolve(filePath)];
150
- }
151
- catch { }
152
- }
153
- await promise;
154
- for (const [name, filePath] of entries) {
155
- if (name in global) {
156
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
157
- Object.assign(global, { [name]: require(filePath)[name] });
158
- }
159
- }
160
- this.info('已重新加载Parser');
161
- },
162
- /** @implements */
163
- isInterwiki(title, { interwiki } = Parser.getConfig()) {
164
- return interwiki.length > 0
165
- ? new RegExp(`^(${interwiki.join('|')})\\s*:`, 'diu')
166
- .exec(title.replace(/_/gu, ' ').replace(/^\s*:?\s*/u, ''))
167
- : null;
168
- },
169
- /** @implements */
170
- reparse(date = '') {
171
- const main = fs.readdirSync(path.join(__dirname, '..', 'errors'))
172
- .find(name => name.startsWith(date) && name.endsWith('Z'));
173
- if (!main) {
174
- throw new RangeError(`找不到对应时间戳的错误记录:${date}`);
175
- }
176
- const file = path.join(__dirname, '..', 'errors', main), wikitext = fs.readFileSync(file, 'utf8');
177
- const { stage, include, config } = require(`${file}.json`), { Token } = require('./src/index');
178
- return debug_1.Shadow.run(() => {
179
- const halfParsed = stage < constants_1.MAX_STAGE, token = new Token(halfParsed ? wikitext : (0, string_1.tidy)(wikitext), config);
180
- if (halfParsed) {
181
- token.setAttribute('stage', stage);
182
- token.parseOnce(stage, include);
183
- }
184
- else {
185
- token.parse(undefined, include);
186
- }
187
- fs.unlinkSync(file);
188
- fs.unlinkSync(`${file}.err`);
189
- fs.unlinkSync(`${file}.json`);
190
- return token;
191
- });
192
- },
193
- };
194
- const def = {
195
- default: { value: Parser },
196
- }, enumerable = new Set([
197
- 'normalizeTitle',
198
- 'parse',
199
- /* NOT FOR BROWSER */
200
- 'conversionTable',
201
- 'redirects',
202
- 'warning',
203
- 'debugging',
204
- 'isInterwiki',
205
- ]);
206
- for (const key in Parser) {
207
- if (!enumerable.has(key)) {
208
- def[key] = { enumerable: false };
209
- }
210
- }
211
- Object.defineProperties(Parser, def);
212
- 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/index';
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 { TableToken } from './src/table/index';
22
- export type * from './src/nowiki/hr';
23
- export type * from './src/nowiki/doubleUnderscore';
24
- export type * from './src/link/index';
25
- export type * from './src/link/category';
26
- export type { ImageParameterToken } 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/index';
38
- export type * from './src/pre';
39
- export type * from './src/paramTag/index';
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,151 +0,0 @@
1
- import { AstNode } from './node';
2
- import type { LintError, AST } from '../base';
3
- import type { AstNodes, AstText, Token } from '../internal';
4
- /** 类似HTMLElement */
5
- export declare abstract class AstElement extends AstNode {
6
- #private;
7
- readonly name?: string;
8
- readonly data: undefined;
9
- /** 子节点总数 */
10
- get length(): number;
11
- /** 全部非文本子节点 */
12
- get children(): Token[];
13
- /** 首位非文本子节点 */
14
- get firstElementChild(): Token | undefined;
15
- /** 末位非文本子节点 */
16
- get lastElementChild(): Token | undefined;
17
- /** 非文本子节点总数 */
18
- get childElementCount(): number;
19
- /** 父节点 */
20
- get parentElement(): Token | undefined;
21
- /** AstElement.prototype.text()的getter写法 */
22
- get outerText(): string;
23
- /** 不可见 */
24
- get hidden(): boolean;
25
- /** 后一个可见的兄弟节点 */
26
- get nextVisibleSibling(): AstNodes | undefined;
27
- /** 前一个可见的兄弟节点 */
28
- get previousVisibleSibling(): AstNodes | undefined;
29
- /** 内部高度 */
30
- get clientHeight(): number | undefined;
31
- /** 内部宽度 */
32
- get clientWidth(): number | undefined;
33
- constructor();
34
- /**
35
- * 可见部分
36
- * @param separator 子节点间的连接符
37
- */
38
- text(separator?: string): string;
39
- /** 合并相邻的文本子节点 */
40
- normalize(): void;
41
- /**
42
- * 移除子节点
43
- * @param i 移除位置
44
- */
45
- removeAt(i: number): AstNodes;
46
- /**
47
- * 插入子节点
48
- * @param node 待插入的子节点
49
- * @param i 插入位置
50
- * @throws `RangeError` 不能插入祖先或子节点
51
- */
52
- insertAt<T extends AstNodes>(node: T, i?: number): T;
53
- /**
54
- * 最近的祖先节点
55
- * @param selector 选择器
56
- */
57
- closest<T = Token>(selector: string): T | undefined;
58
- /**
59
- * 符合选择器的所有后代节点
60
- * @param selector 选择器
61
- */
62
- querySelectorAll<T = Token>(selector: string): T[];
63
- /**
64
- * 在末尾批量插入子节点
65
- * @param elements 插入节点
66
- */
67
- append(...elements: (AstNodes | string)[]): void;
68
- /**
69
- * 批量替换子节点
70
- * @param elements 新的子节点
71
- */
72
- replaceChildren(...elements: (AstNodes | string)[]): void;
73
- /**
74
- * 修改文本子节点
75
- * @param str 新文本
76
- * @param i 子节点位置
77
- * @throws `RangeError` 对应位置的子节点不是文本节点
78
- */
79
- setText(str: string, i?: number): string;
80
- /**
81
- * @override
82
- * @param start
83
- * @param re 用于`AstText`后代节点的正则表达式
84
- */
85
- lint(start?: number, re?: RegExp): LintError[];
86
- /**
87
- * @override
88
- * @param opt 选项
89
- */
90
- print(opt?: PrintOpt): string;
91
- /**
92
- * 保存为JSON
93
- * @param file 文件名
94
- * @param start
95
- */
96
- json(file?: string, start?: number): AST;
97
- /** 销毁 */
98
- destroy(): void;
99
- /**
100
- * 检查是否符合选择器
101
- * @param selector 选择器
102
- */
103
- matches<T>(selector?: string): this is T;
104
- /**
105
- * 符合选择器的第一个后代节点
106
- * @param selector 选择器
107
- */
108
- querySelector<T = Token>(selector: string): T | undefined;
109
- /**
110
- * 类型选择器
111
- * @param types
112
- */
113
- getElementByTypes<T = Token>(types: string): T | undefined;
114
- /**
115
- * id选择器
116
- * @param id id名
117
- */
118
- getElementById<T = Token>(id: string): T | undefined;
119
- /**
120
- * 类选择器
121
- * @param className 类名之一
122
- */
123
- getElementsByClassName<T = Token>(className: string): T[];
124
- /**
125
- * 标签名选择器
126
- * @param tag 标签名
127
- */
128
- getElementsByTagName<T = Token>(tag: string): T[];
129
- /**
130
- * 获取某一行的wikitext
131
- * @param n 行号
132
- */
133
- getLine(n: number): string | undefined;
134
- /**
135
- * 在开头批量插入子节点
136
- * @param elements 插入节点
137
- */
138
- prepend(...elements: (AstNodes | string)[]): void;
139
- /**
140
- * 移除子节点
141
- * @param node 子节点
142
- */
143
- removeChild<T extends AstNodes>(node: T): T;
144
- /**
145
- * 在指定位置前插入子节点
146
- * @param child 插入节点
147
- * @param reference 指定位置处的子节点
148
- */
149
- insertBefore(child: string, reference?: AstNodes): AstText;
150
- insertBefore<T extends AstNodes>(child: T, reference?: AstNodes): T;
151
- }