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