wikiparser-node 1.0.0-beta.3 → 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 (146) 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/minimum.json +136 -0
  5. package/config/moegirl.json +1 -44
  6. package/config/zhwiki.json +1 -466
  7. package/extensions/dist/base.js +105 -0
  8. package/extensions/dist/editor.js +172 -0
  9. package/extensions/dist/highlight.js +46 -0
  10. package/extensions/dist/lint.js +43 -0
  11. package/extensions/editor.css +63 -0
  12. package/extensions/ui.css +119 -0
  13. package/package.json +35 -20
  14. package/config/.schema.json +0 -160
  15. package/dist/index.d.ts +0 -62
  16. package/dist/index.js +0 -305
  17. package/dist/internal.d.ts +0 -44
  18. package/dist/lib/element.d.ts +0 -186
  19. package/dist/lib/element.js +0 -659
  20. package/dist/lib/node.d.ts +0 -178
  21. package/dist/lib/node.js +0 -458
  22. package/dist/lib/range.d.ts +0 -132
  23. package/dist/lib/range.js +0 -387
  24. package/dist/lib/ranges.d.ts +0 -28
  25. package/dist/lib/ranges.js +0 -125
  26. package/dist/lib/text.d.ts +0 -78
  27. package/dist/lib/text.js +0 -227
  28. package/dist/lib/title.d.ts +0 -33
  29. package/dist/lib/title.js +0 -110
  30. package/dist/mixin/attributesParent.js +0 -93
  31. package/dist/mixin/fixed.js +0 -32
  32. package/dist/mixin/hidden.js +0 -23
  33. package/dist/mixin/singleLine.js +0 -26
  34. package/dist/mixin/sol.js +0 -44
  35. package/dist/parser/braces.js +0 -125
  36. package/dist/parser/commentAndExt.js +0 -58
  37. package/dist/parser/converter.js +0 -38
  38. package/dist/parser/externalLinks.js +0 -28
  39. package/dist/parser/hrAndDoubleUnderscore.js +0 -40
  40. package/dist/parser/html.js +0 -38
  41. package/dist/parser/links.js +0 -94
  42. package/dist/parser/list.js +0 -61
  43. package/dist/parser/magicLinks.js +0 -39
  44. package/dist/parser/quotes.js +0 -67
  45. package/dist/parser/selector.js +0 -165
  46. package/dist/parser/table.js +0 -117
  47. package/dist/src/arg.d.ts +0 -77
  48. package/dist/src/arg.js +0 -199
  49. package/dist/src/atom.d.ts +0 -11
  50. package/dist/src/atom.js +0 -24
  51. package/dist/src/attribute.d.ts +0 -106
  52. package/dist/src/attribute.js +0 -436
  53. package/dist/src/attributes.d.ts +0 -119
  54. package/dist/src/attributes.js +0 -366
  55. package/dist/src/converter.d.ts +0 -75
  56. package/dist/src/converter.js +0 -141
  57. package/dist/src/converterFlags.d.ts +0 -107
  58. package/dist/src/converterFlags.js +0 -238
  59. package/dist/src/converterRule.d.ts +0 -96
  60. package/dist/src/converterRule.js +0 -255
  61. package/dist/src/extLink.d.ts +0 -63
  62. package/dist/src/extLink.js +0 -157
  63. package/dist/src/gallery.d.ts +0 -70
  64. package/dist/src/gallery.js +0 -137
  65. package/dist/src/heading.d.ts +0 -82
  66. package/dist/src/heading.js +0 -135
  67. package/dist/src/hidden.d.ts +0 -19
  68. package/dist/src/hidden.js +0 -26
  69. package/dist/src/html.d.ts +0 -113
  70. package/dist/src/html.js +0 -245
  71. package/dist/src/imageParameter.d.ts +0 -82
  72. package/dist/src/imageParameter.js +0 -256
  73. package/dist/src/imagemap.d.ts +0 -77
  74. package/dist/src/imagemap.js +0 -169
  75. package/dist/src/imagemapLink.d.ts +0 -48
  76. package/dist/src/imagemapLink.js +0 -43
  77. package/dist/src/index.d.ts +0 -156
  78. package/dist/src/index.js +0 -819
  79. package/dist/src/link/base.d.ts +0 -69
  80. package/dist/src/link/base.js +0 -231
  81. package/dist/src/link/category.d.ts +0 -14
  82. package/dist/src/link/category.js +0 -28
  83. package/dist/src/link/file.d.ts +0 -105
  84. package/dist/src/link/file.js +0 -269
  85. package/dist/src/link/galleryImage.d.ts +0 -37
  86. package/dist/src/link/galleryImage.js +0 -100
  87. package/dist/src/link/index.d.ts +0 -50
  88. package/dist/src/link/index.js +0 -134
  89. package/dist/src/magicLink.d.ts +0 -46
  90. package/dist/src/magicLink.js +0 -131
  91. package/dist/src/nested.d.ts +0 -47
  92. package/dist/src/nested.js +0 -92
  93. package/dist/src/nowiki/base.d.ts +0 -38
  94. package/dist/src/nowiki/base.js +0 -31
  95. package/dist/src/nowiki/comment.d.ts +0 -42
  96. package/dist/src/nowiki/comment.js +0 -64
  97. package/dist/src/nowiki/dd.d.ts +0 -22
  98. package/dist/src/nowiki/dd.js +0 -46
  99. package/dist/src/nowiki/doubleUnderscore.d.ts +0 -35
  100. package/dist/src/nowiki/doubleUnderscore.js +0 -48
  101. package/dist/src/nowiki/hr.d.ts +0 -30
  102. package/dist/src/nowiki/hr.js +0 -36
  103. package/dist/src/nowiki/index.d.ts +0 -19
  104. package/dist/src/nowiki/index.js +0 -23
  105. package/dist/src/nowiki/list.d.ts +0 -16
  106. package/dist/src/nowiki/list.js +0 -13
  107. package/dist/src/nowiki/noinclude.d.ts +0 -21
  108. package/dist/src/nowiki/noinclude.js +0 -24
  109. package/dist/src/nowiki/quote.d.ts +0 -27
  110. package/dist/src/nowiki/quote.js +0 -58
  111. package/dist/src/onlyinclude.d.ts +0 -38
  112. package/dist/src/onlyinclude.js +0 -66
  113. package/dist/src/paramTag/index.d.ts +0 -50
  114. package/dist/src/paramTag/index.js +0 -78
  115. package/dist/src/paramTag/inputbox.d.ts +0 -7
  116. package/dist/src/paramTag/inputbox.js +0 -21
  117. package/dist/src/parameter.d.ts +0 -95
  118. package/dist/src/parameter.js +0 -204
  119. package/dist/src/pre.d.ts +0 -27
  120. package/dist/src/pre.js +0 -44
  121. package/dist/src/syntax.d.ts +0 -22
  122. package/dist/src/syntax.js +0 -67
  123. package/dist/src/table/base.d.ts +0 -60
  124. package/dist/src/table/base.js +0 -80
  125. package/dist/src/table/index.d.ts +0 -247
  126. package/dist/src/table/index.js +0 -783
  127. package/dist/src/table/td.d.ts +0 -119
  128. package/dist/src/table/td.js +0 -268
  129. package/dist/src/table/tr.d.ts +0 -31
  130. package/dist/src/table/tr.js +0 -50
  131. package/dist/src/table/trBase.d.ts +0 -62
  132. package/dist/src/table/trBase.js +0 -157
  133. package/dist/src/tagPair/ext.d.ts +0 -54
  134. package/dist/src/tagPair/ext.js +0 -150
  135. package/dist/src/tagPair/include.d.ts +0 -43
  136. package/dist/src/tagPair/include.js +0 -43
  137. package/dist/src/tagPair/index.d.ts +0 -57
  138. package/dist/src/tagPair/index.js +0 -113
  139. package/dist/src/transclude.d.ts +0 -200
  140. package/dist/src/transclude.js +0 -732
  141. package/dist/util/debug.js +0 -42
  142. package/dist/util/diff.js +0 -71
  143. package/dist/util/lint.js +0 -38
  144. package/dist/util/string.js +0 -74
  145. package/errors/README +0 -1
  146. package/printed/README +0 -1
@@ -1,77 +0,0 @@
1
- import { Token } from '.';
2
- import { NoincludeToken } from './nowiki/noinclude';
3
- import { GalleryImageToken } from './link/galleryImage';
4
- import { ImagemapLinkToken } from './imagemapLink';
5
- import type { LintError } from '../index';
6
- import type { AstNodes, AstText, AttributesToken, ExtToken } from '../internal';
7
- /**
8
- * `<imagemap>`
9
- * @classdesc `{childNodes: ...NoincludeToken, GalleryImageToken, ...(NoincludeToken|ImagemapLinkToken|AstText)}`
10
- */
11
- export declare abstract class ImagemapToken extends Token {
12
- /** @browser */
13
- readonly type = "ext-inner";
14
- childNodes: (GalleryImageToken | NoincludeToken | ImagemapLinkToken | AstText)[];
15
- abstract get children(): (GalleryImageToken | NoincludeToken | ImagemapLinkToken)[];
16
- abstract get firstChild(): NoincludeToken | GalleryImageToken;
17
- abstract get firstElementChild(): NoincludeToken | GalleryImageToken;
18
- abstract get lastChild(): GalleryImageToken | NoincludeToken | ImagemapLinkToken | AstText;
19
- abstract get lastElementChild(): GalleryImageToken | NoincludeToken | ImagemapLinkToken;
20
- abstract get nextSibling(): undefined;
21
- abstract get nextElementSibling(): undefined;
22
- abstract get previousSibling(): AttributesToken;
23
- abstract get previousElementSibling(): AttributesToken;
24
- abstract get parentNode(): ExtToken | undefined;
25
- abstract get parentElement(): ExtToken | undefined;
26
- /**
27
- * 图片
28
- * @browser
29
- */
30
- get image(): GalleryImageToken | undefined;
31
- /** 链接 */
32
- get links(): ImagemapLinkToken[];
33
- /**
34
- * @browser
35
- * @param inner 标签内部wikitext
36
- * @throws `SyntaxError` 没有合法图片
37
- */
38
- constructor(inner?: string, config?: import("../index").Config, accum?: Token[]);
39
- /**
40
- * @override
41
- * @browser
42
- */
43
- toString(selector?: string): string;
44
- /**
45
- * @override
46
- * @browser
47
- */
48
- text(): string;
49
- /**
50
- * @override
51
- * @browser
52
- */
53
- print(): string;
54
- /**
55
- * @override
56
- * @browser
57
- */
58
- lint(start?: number): LintError[];
59
- /**
60
- * @override
61
- * @param token 待插入的节点
62
- * @param i 插入位置
63
- * @throws `Error` 当前缺少合法图片
64
- * @throws `RangeError` 已有一张合法图片
65
- */
66
- insertAt(token: string, i?: number): AstText;
67
- /** @ignore */
68
- insertAt<T extends AstNodes>(token: T, i?: number): T;
69
- /**
70
- * @override
71
- * @param i 移除位置
72
- * @throws `Error` 禁止移除图片
73
- */
74
- removeAt(i: number): AstNodes;
75
- /** @override */
76
- cloneNode(): this;
77
- }
@@ -1,169 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ImagemapToken = void 0;
4
- const lint_1 = require("../util/lint");
5
- const singleLine_1 = require("../mixin/singleLine");
6
- const index_1 = require("../index");
7
- const _1 = require(".");
8
- const noinclude_1 = require("./nowiki/noinclude");
9
- const galleryImage_1 = require("./link/galleryImage");
10
- const imagemapLink_1 = require("./imagemapLink");
11
- /**
12
- * `<imagemap>`
13
- * @classdesc `{childNodes: ...NoincludeToken, GalleryImageToken, ...(NoincludeToken|ImagemapLinkToken|AstText)}`
14
- */
15
- class ImagemapToken extends _1.Token {
16
- /** @browser */
17
- type = 'ext-inner';
18
- /**
19
- * 图片
20
- * @browser
21
- */
22
- get image() {
23
- return this.childNodes.find(({ type }) => type === 'imagemap-image');
24
- }
25
- /** 链接 */
26
- get links() {
27
- return this.childNodes.filter(({ type }) => type === 'imagemap-link');
28
- }
29
- /**
30
- * @browser
31
- * @param inner 标签内部wikitext
32
- * @throws `SyntaxError` 没有合法图片
33
- */
34
- constructor(inner, config = index_1.default.getConfig(), accum = []) {
35
- super(undefined, config, true, accum, {
36
- GalleryImageToken: ':', ImagemapLinkToken: ':', SingleLineNoincludeToken: ':', AstText: ':',
37
- });
38
- if (!inner) {
39
- return;
40
- }
41
- const lines = inner.split('\n'), protocols = new Set(config.protocol.split('|')), SingleLineNoincludeToken = (0, singleLine_1.singleLine)(noinclude_1.NoincludeToken);
42
- let first = true, error = false;
43
- for (const line of lines) {
44
- const trimmed = line.trim();
45
- if (error || !trimmed || trimmed.startsWith('#')) {
46
- //
47
- }
48
- else if (first) {
49
- const [file, ...options] = line.split('|'), title = this.normalizeTitle(file, 0, true);
50
- if (title.valid && !title.interwiki && title.ns === 6) {
51
- // @ts-expect-error abstract class
52
- const token = new galleryImage_1.GalleryImageToken('imagemap', file, options.length > 0 ? options.join('|') : undefined, config, accum);
53
- super.insertAt(token);
54
- first = false;
55
- continue;
56
- }
57
- else {
58
- index_1.default.error('<imagemap>标签内必须先包含一张合法图片!', line);
59
- error = true;
60
- }
61
- }
62
- else if (line.trim().split(/[\t ]/u)[0] === 'desc') {
63
- super.insertAt(line);
64
- continue;
65
- }
66
- else if (line.includes('[')) {
67
- const i = line.indexOf('['), substr = line.slice(i), mtIn = /^\[{2}([^|]+)(?:\|([^\]]+))?\]{2}[\w\s]*$/u
68
- .exec(substr);
69
- if (mtIn) {
70
- const title = this.normalizeTitle(mtIn[1], 0, true, false, true);
71
- if (title.valid) {
72
- // @ts-expect-error abstract class
73
- super.insertAt(new imagemapLink_1.ImagemapLinkToken(line.slice(0, i), mtIn.slice(1), substr.slice(substr.indexOf(']]') + 2), config, accum));
74
- continue;
75
- }
76
- }
77
- else if (protocols.has(substr.slice(1, substr.indexOf(':') + 1))
78
- || protocols.has(substr.slice(1, substr.indexOf('//') + 2))) {
79
- const mtEx = /^\[([^\]\s]+)(?:(\s+)(\S[^\]]*)?)?\][\w\s]*$/u
80
- .exec(substr);
81
- if (mtEx) {
82
- // @ts-expect-error abstract class
83
- super.insertAt(new imagemapLink_1.ImagemapLinkToken(line.slice(0, i), mtEx.slice(1), substr.slice(substr.indexOf(']') + 1), config, accum));
84
- continue;
85
- }
86
- }
87
- }
88
- // @ts-expect-error abstract class
89
- super.insertAt(new SingleLineNoincludeToken(line, config, accum));
90
- }
91
- }
92
- /**
93
- * @override
94
- * @browser
95
- */
96
- toString(selector) {
97
- return super.toString(selector, '\n');
98
- }
99
- /**
100
- * @override
101
- * @browser
102
- */
103
- text() {
104
- return super.text('\n').replace(/\n{2,}/gu, '\n');
105
- }
106
- /** @private */
107
- getGaps(i) {
108
- return i < this.length - 1 ? 1 : 0;
109
- }
110
- /**
111
- * @override
112
- * @browser
113
- */
114
- print() {
115
- return super.print({ sep: '\n' });
116
- }
117
- /**
118
- * @override
119
- * @browser
120
- */
121
- lint(start = this.getAbsoluteIndex()) {
122
- const errors = super.lint(start), rect = { start, ...this.getRootNode().posFromIndex(start) };
123
- if (this.image) {
124
- errors.push(...this.childNodes.filter(child => {
125
- const str = String(child).trim();
126
- return child.type === 'noinclude' && str && !str.startsWith('#');
127
- }).map(child => (0, lint_1.generateForChild)(child, rect, 'invalid link in <imagemap>')));
128
- }
129
- else {
130
- errors.push((0, lint_1.generateForSelf)(this, rect, '<imagemap> without an image'));
131
- }
132
- return errors;
133
- }
134
- /** @ignore */
135
- insertAt(token, i = 0) {
136
- const { image } = this;
137
- if (!image && (typeof token === 'string' || token.type === 'imagemap-link' || token.type === 'text')) {
138
- throw new Error('当前缺少一张合法图片!');
139
- }
140
- else if (image && typeof token !== 'string' && token.type === 'imagemap-image') {
141
- throw new RangeError('已有一张合法图片!');
142
- }
143
- return super.insertAt(token, i);
144
- }
145
- /**
146
- * @override
147
- * @param i 移除位置
148
- * @throws `Error` 禁止移除图片
149
- */
150
- removeAt(i) {
151
- const child = this.childNodes[i];
152
- if (child.type === 'imagemap-image') {
153
- throw new Error('禁止移除<imagemap>内的图片!');
154
- }
155
- return super.removeAt(i);
156
- }
157
- /** @override */
158
- cloneNode() {
159
- const cloned = this.cloneChildNodes();
160
- return index_1.default.run(() => {
161
- // @ts-expect-error abstract class
162
- const token = new ImagemapToken(undefined, this.getAttribute('config'));
163
- token.append(...cloned);
164
- return token;
165
- });
166
- }
167
- }
168
- exports.ImagemapToken = ImagemapToken;
169
- index_1.default.classes['ImagemapToken'] = __filename;
@@ -1,48 +0,0 @@
1
- import { Token } from '.';
2
- import { NoincludeToken } from './nowiki/noinclude';
3
- import { LinkToken } from './link';
4
- import { ExtLinkToken } from './extLink';
5
- import type { Title } from '../lib/title';
6
- import type { AstText, ImagemapToken } from '../internal';
7
- declare const ImagemapLinkToken_base: ((abstract new (...args: any[]) => {
8
- removeAt(): never;
9
- insertAt(token: string, i?: number | undefined): AstText;
10
- insertAt<T extends import("../index").AstNodes>(token: T, i?: number | undefined): T;
11
- length: number;
12
- toString(selector?: string | undefined, separator?: string | undefined): string;
13
- text(separator?: string | undefined): string;
14
- }) & {
15
- readonly fixed: true;
16
- }) & (abstract new (...args: any[]) => {
17
- toString(selector?: string | undefined): string;
18
- text(): string;
19
- length: number;
20
- insertAt(token: unknown, i?: number | undefined): unknown;
21
- }) & typeof Token;
22
- /**
23
- * `<imagemap>`内的链接
24
- * @classdesc `{childNodes: [AstText, LinkToken|ExtLinkToken, NoincludeToken]}`
25
- */
26
- export declare abstract class ImagemapLinkToken extends ImagemapLinkToken_base {
27
- /** @browser */
28
- readonly type = "imagemap-link";
29
- childNodes: [AstText, LinkToken | ExtLinkToken, NoincludeToken];
30
- abstract get children(): [LinkToken | ExtLinkToken, NoincludeToken];
31
- abstract get firstChild(): AstText;
32
- abstract get firstElementChild(): LinkToken | ExtLinkToken;
33
- abstract get lastChild(): NoincludeToken;
34
- abstract get lastElementChild(): NoincludeToken;
35
- abstract get parentNode(): ImagemapToken | undefined;
36
- abstract get parentElement(): ImagemapToken | undefined;
37
- /** 内外链接 */
38
- get link(): string | Title;
39
- set link(link: string | Title);
40
- /**
41
- * @browser
42
- * @param pre 链接前的文本
43
- * @param linkStuff 内外链接
44
- * @param post 链接后的文本
45
- */
46
- constructor(pre: string, linkStuff: [string, string | undefined, string | Title | undefined] | [string, string | undefined], post: string, config?: import("../index").Config, accum?: Token[]);
47
- }
48
- export {};
@@ -1,43 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ImagemapLinkToken = void 0;
4
- const fixed_1 = require("../mixin/fixed");
5
- const singleLine_1 = require("../mixin/singleLine");
6
- const index_1 = require("../index");
7
- const _1 = require(".");
8
- const noinclude_1 = require("./nowiki/noinclude");
9
- const link_1 = require("./link");
10
- const extLink_1 = require("./extLink");
11
- /**
12
- * `<imagemap>`内的链接
13
- * @classdesc `{childNodes: [AstText, LinkToken|ExtLinkToken, NoincludeToken]}`
14
- */
15
- class ImagemapLinkToken extends (0, fixed_1.fixed)((0, singleLine_1.singleLine)(_1.Token)) {
16
- /** @browser */
17
- type = 'imagemap-link';
18
- /** 内外链接 */
19
- get link() {
20
- return this.childNodes[1].link;
21
- }
22
- set link(link) {
23
- this.childNodes[1].link = link;
24
- }
25
- /**
26
- * @browser
27
- * @param pre 链接前的文本
28
- * @param linkStuff 内外链接
29
- * @param post 链接后的文本
30
- */
31
- constructor(pre, linkStuff, post, config = index_1.default.getConfig(), accum = []) {
32
- super(undefined, config, true, accum);
33
- this.append(pre, linkStuff.length === 2
34
- // @ts-expect-error abstract class
35
- ? new link_1.LinkToken(...linkStuff, config, accum)
36
- // @ts-expect-error abstract class
37
- : new extLink_1.ExtLinkToken(...linkStuff, config, accum),
38
- // @ts-expect-error abstract class
39
- new noinclude_1.NoincludeToken(post, config, accum));
40
- }
41
- }
42
- exports.ImagemapLinkToken = ImagemapLinkToken;
43
- index_1.default.classes['ImagemapLinkToken'] = __filename;
@@ -1,156 +0,0 @@
1
- import { AstRange } from '../lib/range';
2
- import { AstElement } from '../lib/element';
3
- import { AstText } from '../lib/text';
4
- import type { Range } from '../lib/ranges';
5
- import type { Title } from '../lib/title';
6
- import type { AstNodes, IncludeToken, HtmlToken, ExtToken, TranscludeToken, CommentToken } from '../internal';
7
- import type { TokenTypes, CaretPosition } from '../lib/node';
8
- declare type TagToken = IncludeToken | ExtToken | HtmlToken;
9
- /**
10
- * 所有节点的基类
11
- * @classdesc `{childNodes: ...(AstText|Token)}`
12
- */
13
- export declare class Token extends AstElement {
14
- #private;
15
- /** @browser */
16
- type: TokenTypes;
17
- /** 所有图片,包括图库 */
18
- get images(): Token[];
19
- /** 所有内链、外链和自由外链 */
20
- get links(): Token[];
21
- /** 所有模板和模块 */
22
- get embeds(): TranscludeToken[];
23
- /** @browser */
24
- constructor(wikitext?: string, config?: import("../index").Config, halfParsed?: boolean, accum?: Token[], acceptable?: Acceptable);
25
- /**
26
- * 解析、重构、生成部分Token的`name`属性
27
- * @browser
28
- * @param n 最大解析层级
29
- * @param include 是否嵌入
30
- */
31
- parse(n?: number, include?: boolean): this;
32
- /**
33
- * @override
34
- * @browser
35
- * @param child 待插入的子节点
36
- * @param i 插入位置
37
- * @throws `RangeError` 不可插入的子节点
38
- */
39
- insertAt(child: string, i?: number): AstText;
40
- /** @ignore */
41
- insertAt<T extends AstNodes>(child: T, i?: number): T;
42
- /**
43
- * 规范化页面标题
44
- * @browser
45
- * @param title 标题(含或不含命名空间前缀)
46
- * @param defaultNs 命名空间
47
- * @param halfParsed 仅供内部使用
48
- * @param decode 是否需要解码
49
- * @param selfLink 是否允许selfLink
50
- */
51
- normalizeTitle(title: string, defaultNs?: number, halfParsed?: boolean, decode?: boolean, selfLink?: boolean): Title;
52
- /**
53
- * @override
54
- * @param i 移除位置
55
- * @throws `Error` 不可移除的子节点
56
- */
57
- removeAt(i: number): AstNodes;
58
- /**
59
- * 替换为同类节点
60
- * @param token 待替换的节点
61
- * @throws `Error` 不存在父节点
62
- * @throws `Error` 待替换的节点具有不同属性
63
- */
64
- safeReplaceWith(token: this): void;
65
- /**
66
- * 创建HTML注释
67
- * @param data 注释内容
68
- */
69
- createComment(data?: string): CommentToken;
70
- /**
71
- * 创建标签
72
- * @param tagName 标签名
73
- * @param options 选项
74
- * @param options.selfClosing 是否自封闭
75
- * @param options.closing 是否是闭合标签
76
- * @throws `RangeError` 非法的标签名
77
- */
78
- createElement(tagName: string, { selfClosing, closing }?: {
79
- selfClosing?: boolean;
80
- closing?: boolean;
81
- }): TagToken;
82
- /**
83
- * 创建纯文本节点
84
- * @param data 文本内容
85
- */
86
- createTextNode(data?: string): AstText;
87
- /** 创建AstRange对象 */
88
- createRange(): AstRange;
89
- /**
90
- * 找到给定位置所在的节点
91
- * @param index 位置
92
- */
93
- caretPositionFromIndex(index?: number): CaretPosition | undefined;
94
- /**
95
- * 找到给定位置所在的节点
96
- * @param x 列数
97
- * @param y 行数
98
- */
99
- caretPositionFromPoint(x: number, y: number): CaretPosition | undefined;
100
- /**
101
- * 找到给定位置所在的最外层节点
102
- * @param index 位置
103
- * @throws `Error` 不是根节点
104
- */
105
- elementFromIndex(index?: number): AstNodes | undefined;
106
- /**
107
- * 找到给定位置所在的最外层节点
108
- * @param x 列数
109
- * @param y 行数
110
- */
111
- elementFromPoint(x: number, y: number): AstNodes | undefined;
112
- /**
113
- * 找到给定位置所在的所有节点
114
- * @param index 位置
115
- */
116
- elementsFromIndex(index?: number): AstNodes[];
117
- /**
118
- * 找到给定位置所在的所有节点
119
- * @param x 列数
120
- * @param y 行数
121
- */
122
- elementsFromPoint(x: number, y: number): AstNodes[];
123
- /**
124
- * 判断标题是否是跨维基链接
125
- * @param title 标题
126
- */
127
- isInterwiki(title: string): [string, string] | null;
128
- /**
129
- * 深拷贝节点
130
- * @throws `Error` 未定义复制方法
131
- */
132
- cloneNode(): this;
133
- /** 获取全部章节 */
134
- sections(): (AstText | Token)[][] | undefined;
135
- /**
136
- * 获取指定章节
137
- * @param n 章节序号
138
- */
139
- section(n: number): (AstText | Token)[] | undefined;
140
- /**
141
- * 获取指定的外层HTML标签
142
- * @param tag HTML标签名
143
- * @throws `RangeError` 非法的标签或空标签
144
- */
145
- findEnclosingHtml(tag?: string): [HtmlToken, HtmlToken] | undefined;
146
- /** 获取全部分类 */
147
- getCategories(): [string, string | undefined][];
148
- /**
149
- * 重新解析单引号
150
- * @throws `Error` 不接受QuoteToken作为子节点
151
- */
152
- redoQuotes(): void;
153
- /** 解析部分魔术字 */
154
- solveConst(): void;
155
- }
156
- export {};