wikiparser-node 1.10.0 → 1.11.0-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 (173) hide show
  1. package/bundle/bundle.min.js +38 -0
  2. package/config/enwiki.json +1 -814
  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 +64 -0
  7. package/extensions/dist/editor.js +159 -0
  8. package/extensions/dist/highlight.js +56 -0
  9. package/extensions/dist/lint.js +72 -0
  10. package/extensions/editor.css +64 -0
  11. package/extensions/ui.css +144 -0
  12. package/i18n/zh-hans.json +1 -1
  13. package/i18n/zh-hant.json +1 -1
  14. package/package.json +43 -33
  15. package/config/.schema.json +0 -186
  16. package/dist/addon/table.js +0 -486
  17. package/dist/addon/token.js +0 -324
  18. package/dist/addon/transclude.js +0 -185
  19. package/dist/base.d.ts +0 -81
  20. package/dist/base.js +0 -39
  21. package/dist/index.d.ts +0 -33
  22. package/dist/index.js +0 -231
  23. package/dist/internal.d.ts +0 -46
  24. package/dist/lib/element.d.ts +0 -125
  25. package/dist/lib/element.js +0 -374
  26. package/dist/lib/node.d.ts +0 -173
  27. package/dist/lib/node.js +0 -478
  28. package/dist/lib/range.d.ts +0 -105
  29. package/dist/lib/range.js +0 -406
  30. package/dist/lib/ranges.d.ts +0 -28
  31. package/dist/lib/ranges.js +0 -126
  32. package/dist/lib/rect.d.ts +0 -18
  33. package/dist/lib/rect.js +0 -34
  34. package/dist/lib/text.d.ts +0 -58
  35. package/dist/lib/text.js +0 -361
  36. package/dist/lib/title.d.ts +0 -42
  37. package/dist/lib/title.js +0 -205
  38. package/dist/mixin/attributesParent.d.ts +0 -49
  39. package/dist/mixin/attributesParent.js +0 -79
  40. package/dist/mixin/fixed.d.ts +0 -5
  41. package/dist/mixin/fixed.js +0 -32
  42. package/dist/mixin/flagsParent.d.ts +0 -41
  43. package/dist/mixin/flagsParent.js +0 -60
  44. package/dist/mixin/hidden.d.ts +0 -7
  45. package/dist/mixin/hidden.js +0 -37
  46. package/dist/mixin/magicLinkParent.d.ts +0 -19
  47. package/dist/mixin/magicLinkParent.js +0 -43
  48. package/dist/mixin/singleLine.d.ts +0 -5
  49. package/dist/mixin/singleLine.js +0 -25
  50. package/dist/mixin/sol.d.ts +0 -6
  51. package/dist/mixin/sol.js +0 -44
  52. package/dist/mixin/syntax.d.ts +0 -8
  53. package/dist/mixin/syntax.js +0 -46
  54. package/dist/parser/braces.js +0 -150
  55. package/dist/parser/commentAndExt.js +0 -79
  56. package/dist/parser/converter.js +0 -39
  57. package/dist/parser/externalLinks.js +0 -37
  58. package/dist/parser/hrAndDoubleUnderscore.js +0 -42
  59. package/dist/parser/html.js +0 -38
  60. package/dist/parser/links.js +0 -101
  61. package/dist/parser/list.js +0 -99
  62. package/dist/parser/magicLinks.js +0 -53
  63. package/dist/parser/quotes.js +0 -67
  64. package/dist/parser/redirect.js +0 -26
  65. package/dist/parser/selector.js +0 -394
  66. package/dist/parser/table.js +0 -123
  67. package/dist/src/arg.d.ts +0 -51
  68. package/dist/src/arg.js +0 -214
  69. package/dist/src/atom.d.ts +0 -14
  70. package/dist/src/atom.js +0 -52
  71. package/dist/src/attribute.d.ts +0 -64
  72. package/dist/src/attribute.js +0 -483
  73. package/dist/src/attributes.d.ts +0 -101
  74. package/dist/src/attributes.js +0 -382
  75. package/dist/src/converter.d.ts +0 -28
  76. package/dist/src/converter.js +0 -147
  77. package/dist/src/converterFlags.d.ts +0 -80
  78. package/dist/src/converterFlags.js +0 -242
  79. package/dist/src/converterRule.d.ts +0 -71
  80. package/dist/src/converterRule.js +0 -216
  81. package/dist/src/extLink.d.ts +0 -36
  82. package/dist/src/extLink.js +0 -198
  83. package/dist/src/gallery.d.ts +0 -47
  84. package/dist/src/gallery.js +0 -142
  85. package/dist/src/heading.d.ts +0 -40
  86. package/dist/src/heading.js +0 -191
  87. package/dist/src/hidden.d.ts +0 -9
  88. package/dist/src/hidden.js +0 -80
  89. package/dist/src/html.d.ts +0 -57
  90. package/dist/src/html.js +0 -343
  91. package/dist/src/imageParameter.d.ts +0 -58
  92. package/dist/src/imageParameter.js +0 -247
  93. package/dist/src/imagemap.d.ts +0 -47
  94. package/dist/src/imagemap.js +0 -146
  95. package/dist/src/imagemapLink.d.ts +0 -31
  96. package/dist/src/imagemapLink.js +0 -97
  97. package/dist/src/index.d.ts +0 -141
  98. package/dist/src/index.js +0 -795
  99. package/dist/src/link/base.d.ts +0 -54
  100. package/dist/src/link/base.js +0 -263
  101. package/dist/src/link/category.d.ts +0 -22
  102. package/dist/src/link/category.js +0 -34
  103. package/dist/src/link/file.d.ts +0 -96
  104. package/dist/src/link/file.js +0 -276
  105. package/dist/src/link/galleryImage.d.ts +0 -29
  106. package/dist/src/link/galleryImage.js +0 -132
  107. package/dist/src/link/index.d.ts +0 -39
  108. package/dist/src/link/index.js +0 -99
  109. package/dist/src/link/redirectTarget.d.ts +0 -27
  110. package/dist/src/link/redirectTarget.js +0 -72
  111. package/dist/src/magicLink.d.ts +0 -61
  112. package/dist/src/magicLink.js +0 -261
  113. package/dist/src/nested.d.ts +0 -40
  114. package/dist/src/nested.js +0 -106
  115. package/dist/src/nowiki/base.d.ts +0 -30
  116. package/dist/src/nowiki/base.js +0 -89
  117. package/dist/src/nowiki/comment.d.ts +0 -14
  118. package/dist/src/nowiki/comment.js +0 -124
  119. package/dist/src/nowiki/dd.d.ts +0 -8
  120. package/dist/src/nowiki/dd.js +0 -72
  121. package/dist/src/nowiki/doubleUnderscore.d.ts +0 -15
  122. package/dist/src/nowiki/doubleUnderscore.js +0 -97
  123. package/dist/src/nowiki/hr.d.ts +0 -5
  124. package/dist/src/nowiki/hr.js +0 -70
  125. package/dist/src/nowiki/index.d.ts +0 -14
  126. package/dist/src/nowiki/index.js +0 -31
  127. package/dist/src/nowiki/list.d.ts +0 -5
  128. package/dist/src/nowiki/list.js +0 -65
  129. package/dist/src/nowiki/listBase.d.ts +0 -17
  130. package/dist/src/nowiki/listBase.js +0 -75
  131. package/dist/src/nowiki/noinclude.d.ts +0 -6
  132. package/dist/src/nowiki/noinclude.js +0 -75
  133. package/dist/src/nowiki/quote.d.ts +0 -14
  134. package/dist/src/nowiki/quote.js +0 -135
  135. package/dist/src/onlyinclude.d.ts +0 -13
  136. package/dist/src/onlyinclude.js +0 -58
  137. package/dist/src/paramTag/index.d.ts +0 -30
  138. package/dist/src/paramTag/index.js +0 -78
  139. package/dist/src/paramTag/inputbox.d.ts +0 -8
  140. package/dist/src/paramTag/inputbox.js +0 -22
  141. package/dist/src/parameter.d.ts +0 -60
  142. package/dist/src/parameter.js +0 -268
  143. package/dist/src/pre.d.ts +0 -28
  144. package/dist/src/pre.js +0 -60
  145. package/dist/src/redirect.d.ts +0 -30
  146. package/dist/src/redirect.js +0 -126
  147. package/dist/src/syntax.d.ts +0 -17
  148. package/dist/src/syntax.js +0 -87
  149. package/dist/src/table/base.d.ts +0 -28
  150. package/dist/src/table/base.js +0 -81
  151. package/dist/src/table/index.d.ts +0 -230
  152. package/dist/src/table/index.js +0 -505
  153. package/dist/src/table/td.d.ts +0 -72
  154. package/dist/src/table/td.js +0 -370
  155. package/dist/src/table/tr.d.ts +0 -30
  156. package/dist/src/table/tr.js +0 -59
  157. package/dist/src/table/trBase.d.ts +0 -49
  158. package/dist/src/table/trBase.js +0 -164
  159. package/dist/src/tagPair/ext.d.ts +0 -29
  160. package/dist/src/tagPair/ext.js +0 -220
  161. package/dist/src/tagPair/include.d.ts +0 -33
  162. package/dist/src/tagPair/include.js +0 -130
  163. package/dist/src/tagPair/index.d.ts +0 -23
  164. package/dist/src/tagPair/index.js +0 -128
  165. package/dist/src/transclude.d.ts +0 -159
  166. package/dist/src/transclude.js +0 -587
  167. package/dist/util/constants.js +0 -25
  168. package/dist/util/debug.js +0 -95
  169. package/dist/util/diff.js +0 -83
  170. package/dist/util/lint.js +0 -32
  171. package/dist/util/string.js +0 -84
  172. package/errors/README +0 -3
  173. package/printed/README +0 -3
@@ -1,268 +0,0 @@
1
- "use strict";
2
- var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
3
- function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
4
- var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
5
- var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
6
- var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
7
- var _, done = false;
8
- for (var i = decorators.length - 1; i >= 0; i--) {
9
- var context = {};
10
- for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
11
- for (var p in contextIn.access) context.access[p] = contextIn.access[p];
12
- context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
13
- var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
14
- if (kind === "accessor") {
15
- if (result === void 0) continue;
16
- if (result === null || typeof result !== "object") throw new TypeError("Object expected");
17
- if (_ = accept(result.get)) descriptor.get = _;
18
- if (_ = accept(result.set)) descriptor.set = _;
19
- if (_ = accept(result.init)) initializers.unshift(_);
20
- }
21
- else if (_ = accept(result)) {
22
- if (kind === "field") initializers.unshift(_);
23
- else descriptor[key] = _;
24
- }
25
- }
26
- if (target) Object.defineProperty(target, contextIn.name, descriptor);
27
- done = true;
28
- };
29
- var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
30
- var useValue = arguments.length > 2;
31
- for (var i = 0; i < initializers.length; i++) {
32
- value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
33
- }
34
- return useValue ? value : void 0;
35
- };
36
- Object.defineProperty(exports, "__esModule", { value: true });
37
- exports.ParameterToken = void 0;
38
- const string_1 = require("../util/string");
39
- const lint_1 = require("../util/lint");
40
- const debug_1 = require("../util/debug");
41
- const constants_1 = require("../util/constants");
42
- const fixed_1 = require("../mixin/fixed");
43
- const index_1 = require("../index");
44
- const index_2 = require("./index");
45
- // eslint-disable-next-line @typescript-eslint/no-unused-expressions
46
- /https?:\/\/(?:\[[\da-f:.]+\]|[^[\]<>"\t\n\p{Zs}])[^[\]<>"\0\t\n\p{Zs}]*$/iu;
47
- const linkRegex = new RegExp(`https?://${string_1.extUrlCharFirst}${string_1.extUrlChar}$`, 'iu');
48
- /**
49
- * 模板或魔术字参数
50
- * @classdesc `{childNodes: [Token, Token]}`
51
- */
52
- let ParameterToken = (() => {
53
- let _classDecorators = [fixed_1.fixedToken];
54
- let _classDescriptor;
55
- let _classExtraInitializers = [];
56
- let _classThis;
57
- let _classSuper = index_2.Token;
58
- var ParameterToken = class extends _classSuper {
59
- static { _classThis = this; }
60
- static {
61
- const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
62
- __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
63
- ParameterToken = _classThis = _classDescriptor.value;
64
- if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
65
- __runInitializers(_classThis, _classExtraInitializers);
66
- }
67
- /* NOT FOR BROWSER END */
68
- get type() {
69
- return 'parameter';
70
- }
71
- /** 是否是匿名参数 */
72
- get anon() {
73
- return this.firstChild.length === 0;
74
- }
75
- /* NOT FOR BROWSER */
76
- set anon(value) {
77
- if (value) {
78
- throw new Error('Cannot convert named parameter to anonymous parameter!');
79
- }
80
- this.parentNode?.anonToNamed();
81
- }
82
- /** getValue()的getter */
83
- get value() {
84
- return this.getValue();
85
- }
86
- set value(value) {
87
- this.setValue(value);
88
- }
89
- /** 是否是重复参数 */
90
- get duplicated() {
91
- try {
92
- return Boolean(this.parentNode?.getDuplicatedArgs().some(([key]) => key === this.name));
93
- }
94
- catch {
95
- return false;
96
- }
97
- }
98
- set duplicated(value) {
99
- if (this.duplicated && !value) {
100
- this.parentNode.fixDuplication();
101
- }
102
- }
103
- /* NOT FOR BROWSER END */
104
- /**
105
- * @param key 参数名
106
- * @param value 参数值
107
- */
108
- constructor(key, value, config = index_1.default.getConfig(), accum = []) {
109
- super(undefined, config, accum);
110
- const keyToken = new index_2.Token(typeof key === 'number' ? undefined : key, config, accum, {
111
- 'Stage-11': ':', '!HeadingToken': '',
112
- }), token = new index_2.Token(value, config, accum);
113
- keyToken.type = 'parameter-key';
114
- keyToken.setAttribute('stage', 2);
115
- token.type = 'parameter-value';
116
- token.setAttribute('stage', 2);
117
- this.append(keyToken, token);
118
- /* NOT FOR BROWSER */
119
- if (typeof key === 'string') {
120
- this.trimName((0, string_1.removeComment)(key));
121
- }
122
- }
123
- /** @private */
124
- trimName(name, set = true) {
125
- const trimmed = (typeof name === 'string' ? name : name.toString(true))
126
- .replace(/^[ \t\n\0\v]+|([^ \t\n\0\v])[ \t\n\0\v]+$/gu, '$1');
127
- if (set) {
128
- this.setAttribute('name', trimmed);
129
- }
130
- return trimmed;
131
- }
132
- /** @private */
133
- afterBuild() {
134
- if (!this.anon) {
135
- const { parentNode, firstChild } = this, name = this.trimName(firstChild);
136
- if (parentNode) {
137
- parentNode.getArgs(name, false, false).add(this);
138
- /* NOT FOR BROWSER */
139
- parentNode.getAttribute('keys').add(name);
140
- }
141
- }
142
- super.afterBuild();
143
- /* NOT FOR BROWSER */
144
- const /** @implements */ parameterListener = ({ prevTarget }, data) => {
145
- if (!this.anon) { // 匿名参数不管怎么变动还是匿名
146
- const { firstChild, name } = this;
147
- if (prevTarget === firstChild) {
148
- const newKey = this.trimName(firstChild);
149
- data.oldKey = name;
150
- data.newKey = newKey;
151
- }
152
- }
153
- };
154
- this.addEventListener(['remove', 'insert', 'replace', 'text'], parameterListener);
155
- }
156
- /** @private */
157
- toString(skip) {
158
- return this.anon ? this.lastChild.toString(skip) : super.toString(skip, '=');
159
- }
160
- text() {
161
- return this.anon ? this.lastChild.text() : super.text('=');
162
- }
163
- /** @private */
164
- getGaps() {
165
- return this.anon ? 0 : 1;
166
- }
167
- /** @private */
168
- lint(start = this.getAbsoluteIndex(), re) {
169
- const errors = super.lint(start, re), { firstChild } = this, link = linkRegex.exec(firstChild.text())?.[0];
170
- if (link && new URL(link).search) {
171
- const e = (0, lint_1.generateForChild)(firstChild, { start }, 'unescaped', 'unescaped query string in an anonymous parameter');
172
- e.startIndex = e.endIndex;
173
- e.startLine = e.endLine;
174
- e.startCol = e.endCol;
175
- e.endIndex++;
176
- e.endCol++;
177
- e.fix = {
178
- range: [e.startIndex, e.endIndex],
179
- text: '{{=}}',
180
- };
181
- errors.push(e);
182
- }
183
- return errors;
184
- }
185
- /** @private */
186
- print() {
187
- return super.print({ sep: this.anon ? '' : '=' });
188
- }
189
- /** @override */
190
- json() {
191
- const json = super.json();
192
- json['anon'] = this.anon;
193
- return json;
194
- }
195
- /* NOT FOR BROWSER */
196
- cloneNode() {
197
- const [key, value] = this.cloneChildNodes(), config = this.getAttribute('config');
198
- return debug_1.Shadow.run(() => {
199
- // @ts-expect-error abstract class
200
- const token = new ParameterToken(this.anon ? Number(this.name) : undefined, undefined, config);
201
- token.firstChild.safeReplaceWith(key);
202
- token.lastChild.safeReplaceWith(value);
203
- if (this.anon) {
204
- token.setAttribute('name', this.name);
205
- }
206
- return token;
207
- });
208
- }
209
- safeReplaceWith(token) {
210
- index_1.default.warn(`${this.constructor.name}.safeReplaceWith regress to AstNode.replaceWith.`);
211
- this.replaceWith(token);
212
- }
213
- /** 获取参数值 */
214
- getValue() {
215
- const value = (0, string_1.removeComment)(this.lastChild.text());
216
- return this.anon && this.parentNode?.isTemplate() !== false ? value : value.trim();
217
- }
218
- /**
219
- * 设置参数值
220
- * @param value 参数值
221
- */
222
- setValue(value) {
223
- const { childNodes } = index_1.default.parse(value, this.getAttribute('include'), undefined, this.getAttribute('config'));
224
- this.lastChild.replaceChildren(...childNodes);
225
- }
226
- /**
227
- * 修改参数名
228
- * @param key 新参数名
229
- * @param force 是否无视冲突命名
230
- * @throws `Error` 仅用于模板参数
231
- * @throws `RangeError` 更名造成重复参数
232
- */
233
- rename(key, force) {
234
- const { parentNode, anon } = this;
235
- // 必须检测是否是TranscludeToken
236
- if (parentNode?.isTemplate() === false) {
237
- throw new Error('ParameterToken.rename method is only for template parameters!');
238
- }
239
- else if (anon) {
240
- parentNode?.anonToNamed();
241
- }
242
- const root = index_1.default.parse(key, this.getAttribute('include'), undefined, this.getAttribute('config')), name = this.trimName(root, false);
243
- if (this.name === name) {
244
- index_1.default.warn('The actual parameter name is not changed', name);
245
- }
246
- else if (parentNode?.hasArg(name)) {
247
- if (force) {
248
- index_1.default.warn('Parameter renaming causes duplicated parameters', name);
249
- }
250
- else {
251
- throw new RangeError(`Parameter renaming causes duplicated parameters: ${name}`);
252
- }
253
- }
254
- this.firstChild.replaceChildren(...root.childNodes);
255
- }
256
- /** 转义 `=` */
257
- escape() {
258
- for (const child of this.lastChild.childNodes) {
259
- if (child.type === 'text') {
260
- child.escape();
261
- }
262
- }
263
- }
264
- };
265
- return ParameterToken = _classThis;
266
- })();
267
- exports.ParameterToken = ParameterToken;
268
- constants_1.classes['ParameterToken'] = __filename;
package/dist/src/pre.d.ts DELETED
@@ -1,28 +0,0 @@
1
- import Parser from '../index';
2
- import { Token } from './index';
3
- import { NoincludeToken } from './nowiki/noinclude';
4
- import type { LintError } from '../base';
5
- import type { AstText, AttributesToken, ExtToken, ConverterToken } from '../internal';
6
- /**
7
- * `<pre>`
8
- * @classdesc `{childNodes: [...AstText|NoincludeToken|ConverterToken]}`
9
- */
10
- export declare abstract class PreToken extends Token {
11
- readonly name: 'pre';
12
- readonly childNodes: readonly (AstText | NoincludeToken | ConverterToken)[];
13
- abstract get firstChild(): AstText | NoincludeToken | ConverterToken | undefined;
14
- abstract get lastChild(): AstText | NoincludeToken | ConverterToken | undefined;
15
- abstract get nextSibling(): undefined;
16
- abstract get previousSibling(): AttributesToken;
17
- abstract get parentNode(): ExtToken | undefined;
18
- abstract get children(): (NoincludeToken | ConverterToken)[];
19
- abstract get firstElementChild(): NoincludeToken | ConverterToken | undefined;
20
- abstract get lastElementChild(): NoincludeToken | ConverterToken | undefined;
21
- abstract get previousElementSibling(): AttributesToken;
22
- abstract get nextElementSibling(): undefined;
23
- abstract get parentElement(): ExtToken | undefined;
24
- get type(): 'ext-inner';
25
- /** @class */
26
- constructor(wikitext?: string, config?: Parser.Config, accum?: Token[]);
27
- cloneNode(): this;
28
- }
package/dist/src/pre.js DELETED
@@ -1,60 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PreToken = void 0;
4
- const constants_1 = require("../util/constants");
5
- const debug_1 = require("../util/debug");
6
- const index_1 = require("../index");
7
- const index_2 = require("./index");
8
- const noinclude_1 = require("./nowiki/noinclude");
9
- /**
10
- * `<pre>`
11
- * @classdesc `{childNodes: [...AstText|NoincludeToken|ConverterToken]}`
12
- */
13
- class PreToken extends index_2.Token {
14
- /* NOT FOR BROWSER END */
15
- get type() {
16
- return 'ext-inner';
17
- }
18
- /** @class */
19
- constructor(wikitext, config = index_1.default.getConfig(), accum = []) {
20
- if (wikitext) {
21
- const opening = '<nowiki>', closing = '</nowiki>', { length } = opening;
22
- let i = wikitext.indexOf(opening), j = wikitext.indexOf(closing, i + length), str = '';
23
- while (i !== -1 && j !== -1) {
24
- // @ts-expect-error abstract class
25
- new noinclude_1.NoincludeToken(opening, config, accum);
26
- // @ts-expect-error abstract class
27
- new noinclude_1.NoincludeToken(closing, config, accum);
28
- str += `${wikitext.slice(0, i)}\0${accum.length - 1}c\x7F${wikitext.slice(i + length, j)}\0${accum.length}c\x7F`;
29
- wikitext = wikitext.slice(j + length + 1);
30
- i = wikitext.indexOf(opening);
31
- j = wikitext.indexOf(closing, i + length);
32
- }
33
- wikitext = str + wikitext;
34
- }
35
- super(wikitext, config, accum, {
36
- AstText: ':', NoincludeToken: ':', ConverterToken: ':',
37
- });
38
- this.setAttribute('stage', constants_1.MAX_STAGE - 1);
39
- }
40
- /** @private */
41
- getAttribute(key) {
42
- return (key === 'plain') || super.getAttribute(key);
43
- }
44
- /** @private */
45
- lint(start = this.getAbsoluteIndex()) {
46
- return super.lint(start, /<\s*\/\s*(pre)\b/giu);
47
- }
48
- /* NOT FOR BROWSER */
49
- cloneNode() {
50
- const cloned = this.cloneChildNodes();
51
- return debug_1.Shadow.run(() => {
52
- // @ts-expect-error abstract class
53
- const token = new PreToken(undefined, this.getAttribute('config'));
54
- token.append(...cloned);
55
- return token;
56
- });
57
- }
58
- }
59
- exports.PreToken = PreToken;
60
- constants_1.classes['PreToken'] = __filename;
@@ -1,30 +0,0 @@
1
- import Parser from '../index';
2
- import { Token } from './index';
3
- import { SyntaxToken } from './syntax';
4
- import { RedirectTargetToken } from './link/redirectTarget';
5
- import type { LintError } from '../base';
6
- /**
7
- * 重定向
8
- * @classdesc `{childNodes: [SyntaxToken, LinkToken]}`
9
- */
10
- export declare abstract class RedirectToken extends Token {
11
- #private;
12
- readonly childNodes: readonly [SyntaxToken, RedirectTargetToken];
13
- abstract get firstChild(): SyntaxToken;
14
- abstract get lastChild(): RedirectTargetToken;
15
- abstract get previousSibling(): undefined;
16
- abstract get children(): [SyntaxToken, RedirectTargetToken];
17
- abstract get firstElementChild(): SyntaxToken;
18
- abstract get lastElementChild(): RedirectTargetToken;
19
- abstract get previousElementSibling(): undefined;
20
- get type(): 'redirect';
21
- /**
22
- * @param pre leading whitespace
23
- * @param syntax 重定向魔术字
24
- * @param link 重定向目标
25
- * @param text 重定向显示文本(无效)
26
- * @param post trailing whitespace
27
- */
28
- constructor(pre: string, syntax: string | undefined, link: string, text: string | undefined, post: string, config?: Parser.Config, accum?: Token[]);
29
- cloneNode(): this;
30
- }
@@ -1,126 +0,0 @@
1
- "use strict";
2
- var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
3
- function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
4
- var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
5
- var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
6
- var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
7
- var _, done = false;
8
- for (var i = decorators.length - 1; i >= 0; i--) {
9
- var context = {};
10
- for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
11
- for (var p in contextIn.access) context.access[p] = contextIn.access[p];
12
- context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
13
- var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
14
- if (kind === "accessor") {
15
- if (result === void 0) continue;
16
- if (result === null || typeof result !== "object") throw new TypeError("Object expected");
17
- if (_ = accept(result.get)) descriptor.get = _;
18
- if (_ = accept(result.set)) descriptor.set = _;
19
- if (_ = accept(result.init)) initializers.unshift(_);
20
- }
21
- else if (_ = accept(result)) {
22
- if (kind === "field") initializers.unshift(_);
23
- else descriptor[key] = _;
24
- }
25
- }
26
- if (target) Object.defineProperty(target, contextIn.name, descriptor);
27
- done = true;
28
- };
29
- var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
30
- var useValue = arguments.length > 2;
31
- for (var i = 0; i < initializers.length; i++) {
32
- value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
33
- }
34
- return useValue ? value : void 0;
35
- };
36
- Object.defineProperty(exports, "__esModule", { value: true });
37
- exports.RedirectToken = void 0;
38
- const constants_1 = require("../util/constants");
39
- const debug_1 = require("../util/debug");
40
- const hidden_1 = require("../mixin/hidden");
41
- const fixed_1 = require("../mixin/fixed");
42
- const index_1 = require("../index");
43
- const index_2 = require("./index");
44
- const syntax_1 = require("./syntax");
45
- const redirectTarget_1 = require("./link/redirectTarget");
46
- /**
47
- * 重定向
48
- * @classdesc `{childNodes: [SyntaxToken, LinkToken]}`
49
- */
50
- let RedirectToken = (() => {
51
- let _classDecorators = [fixed_1.fixedToken, (0, hidden_1.hiddenToken)(false, false)];
52
- let _classDescriptor;
53
- let _classExtraInitializers = [];
54
- let _classThis;
55
- let _classSuper = index_2.Token;
56
- var RedirectToken = class extends _classSuper {
57
- static { _classThis = this; }
58
- static {
59
- const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
60
- __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
61
- RedirectToken = _classThis = _classDescriptor.value;
62
- if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
63
- __runInitializers(_classThis, _classExtraInitializers);
64
- }
65
- #pre;
66
- #post;
67
- /* NOT FOR BROWSER END */
68
- get type() {
69
- return 'redirect';
70
- }
71
- /**
72
- * @param pre leading whitespace
73
- * @param syntax 重定向魔术字
74
- * @param link 重定向目标
75
- * @param text 重定向显示文本(无效)
76
- * @param post trailing whitespace
77
- */
78
- constructor(pre, syntax, link, text, post, config = index_1.default.getConfig(), accum = []) {
79
- super(undefined, config, accum);
80
- this.#pre = pre;
81
- this.#post = post;
82
- // eslint-disable-next-line @typescript-eslint/no-unused-expressions
83
- /^(?:#redirect|#重定向)\s*(?::\s*)?$/iu;
84
- const pattern = new RegExp(String.raw `^(?:${config.redirection.join('|')})\s*(?::\s*)?$`, 'iu');
85
- this.append(new syntax_1.SyntaxToken(syntax, pattern, 'redirect-syntax', config, accum, {
86
- AstText: ':',
87
- }),
88
- // @ts-expect-error abstract class
89
- new redirectTarget_1.RedirectTargetToken(link, text?.slice(1), config, accum));
90
- }
91
- /** @private */
92
- getAttribute(key) {
93
- return key === 'padding' ? this.#pre.length : super.getAttribute(key);
94
- }
95
- /** @private */
96
- toString(skip) {
97
- return this.#pre + super.toString(skip) + this.#post;
98
- }
99
- /** @private */
100
- lint(start = this.getAbsoluteIndex()) {
101
- return this.lastChild.lint(start + this.#pre.length + this.firstChild.toString().length);
102
- }
103
- /** @private */
104
- print() {
105
- return super.print({ pre: this.#pre, post: this.#post });
106
- }
107
- /* NOT FOR BROWSER */
108
- cloneNode() {
109
- const cloned = this.cloneChildNodes(), config = this.getAttribute('config');
110
- return debug_1.Shadow.run(() => {
111
- // @ts-expect-error abstract class
112
- const token = new RedirectToken([this.#pre, undefined, '', undefined, this.#post], config, []);
113
- token.firstChild.safeReplaceWith(cloned[0]);
114
- token.lastChild.safeReplaceWith(cloned[1]);
115
- return token;
116
- });
117
- }
118
- /** @private */
119
- toHtml() {
120
- return `<ul class="redirectText"><li>${this.lastChild.toHtml()}</li></ul>`;
121
- }
122
- };
123
- return RedirectToken = _classThis;
124
- })();
125
- exports.RedirectToken = RedirectToken;
126
- constants_1.classes['RedirectToken'] = __filename;
@@ -1,17 +0,0 @@
1
- import { Token } from './index';
2
- import type { Config, LintError } from '../base';
3
- import type { SyntaxBase } from '../mixin/syntax';
4
- declare type SyntaxTypes = 'heading-trail' | 'magic-word-name' | 'table-syntax' | 'redirect-syntax';
5
- /** NOT FOR BROWSER */
6
- export interface SyntaxToken extends SyntaxBase {
7
- }
8
- /** NOT FOR BROWSER END */
9
- /** 满足特定语法格式的plain Token */
10
- export declare class SyntaxToken extends Token {
11
- #private;
12
- get type(): SyntaxTypes;
13
- /** @param pattern 语法正则 */
14
- constructor(wikitext: string | undefined, pattern: RegExp, type: SyntaxTypes, config?: Config, accum?: Token[], acceptable?: Acceptable);
15
- cloneNode(): this;
16
- }
17
- export {};
@@ -1,87 +0,0 @@
1
- "use strict";
2
- var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
3
- function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
4
- var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
5
- var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
6
- var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
7
- var _, done = false;
8
- for (var i = decorators.length - 1; i >= 0; i--) {
9
- var context = {};
10
- for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
11
- for (var p in contextIn.access) context.access[p] = contextIn.access[p];
12
- context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
13
- var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
14
- if (kind === "accessor") {
15
- if (result === void 0) continue;
16
- if (result === null || typeof result !== "object") throw new TypeError("Object expected");
17
- if (_ = accept(result.get)) descriptor.get = _;
18
- if (_ = accept(result.set)) descriptor.set = _;
19
- if (_ = accept(result.init)) initializers.unshift(_);
20
- }
21
- else if (_ = accept(result)) {
22
- if (kind === "field") initializers.unshift(_);
23
- else descriptor[key] = _;
24
- }
25
- }
26
- if (target) Object.defineProperty(target, contextIn.name, descriptor);
27
- done = true;
28
- };
29
- var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
30
- var useValue = arguments.length > 2;
31
- for (var i = 0; i < initializers.length; i++) {
32
- value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
33
- }
34
- return useValue ? value : void 0;
35
- };
36
- Object.defineProperty(exports, "__esModule", { value: true });
37
- exports.SyntaxToken = void 0;
38
- const debug_1 = require("../util/debug");
39
- const constants_1 = require("../util/constants");
40
- const syntax_1 = require("../mixin/syntax");
41
- const index_1 = require("./index");
42
- /** NOT FOR BROWSER END */
43
- /** 满足特定语法格式的plain Token */
44
- let SyntaxToken = (() => {
45
- let _classDecorators = [(0, syntax_1.syntax)()];
46
- let _classDescriptor;
47
- let _classExtraInitializers = [];
48
- let _classThis;
49
- let _classSuper = index_1.Token;
50
- var SyntaxToken = class extends _classSuper {
51
- static { _classThis = this; }
52
- static {
53
- const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
54
- __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
55
- SyntaxToken = _classThis = _classDescriptor.value;
56
- if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
57
- __runInitializers(_classThis, _classExtraInitializers);
58
- }
59
- #type;
60
- get type() {
61
- return this.#type;
62
- }
63
- /** @param pattern 语法正则 */
64
- constructor(wikitext, pattern, type, config, accum, acceptable) {
65
- super(wikitext, config, accum, acceptable);
66
- this.#type = type;
67
- /* NOT FOR BROWSER */
68
- this.setAttribute('pattern', pattern);
69
- }
70
- /** @private */
71
- lint(start = this.getAbsoluteIndex()) {
72
- return super.lint(start, false);
73
- }
74
- /* NOT FOR BROWSER */
75
- cloneNode() {
76
- const cloned = this.cloneChildNodes(), config = this.getAttribute('config'), acceptable = this.getAcceptable();
77
- return debug_1.Shadow.run(() => {
78
- const token = new SyntaxToken(undefined, this.pattern, this.type, config, [], acceptable);
79
- token.append(...cloned);
80
- return token;
81
- });
82
- }
83
- };
84
- return SyntaxToken = _classThis;
85
- })();
86
- exports.SyntaxToken = SyntaxToken;
87
- constants_1.classes['SyntaxToken'] = __filename;
@@ -1,28 +0,0 @@
1
- import Parser from '../../index';
2
- import { Token } from '../index';
3
- import { SyntaxToken } from '../syntax';
4
- import { AttributesToken } from '../attributes';
5
- import type { AttributesParentBase } from '../../mixin/attributesParent';
6
- declare type TableTypes = 'table' | 'tr' | 'td';
7
- export interface TableBaseToken extends AttributesParentBase {
8
- }
9
- export declare abstract class TableBaseToken extends Token {
10
- abstract get type(): TableTypes;
11
- readonly childNodes: readonly [SyntaxToken, AttributesToken, ...Token[]];
12
- abstract get firstChild(): SyntaxToken;
13
- abstract get lastChild(): Token;
14
- abstract get children(): [SyntaxToken, AttributesToken, ...Token[]];
15
- abstract get firstElementChild(): SyntaxToken;
16
- abstract get lastElementChild(): Token;
17
- /**
18
- * @param pattern 表格语法正则
19
- * @param syntax 表格语法
20
- * @param type 节点类型
21
- * @param attr 表格属性
22
- */
23
- constructor(pattern: RegExp, syntax: string, type: TableTypes, attr?: string, config?: Parser.Config, accum?: Token[], acceptable?: Acceptable);
24
- cloneNode(): this;
25
- /** 转义表格语法 */
26
- escape(): void;
27
- }
28
- export {};