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