wikiparser-node 1.12.4 → 1.12.5-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 (175) hide show
  1. package/bundle/bundle.min.js +37 -0
  2. package/config/default.json +29 -30
  3. package/config/enwiki.json +15 -829
  4. package/config/llwiki.json +21 -56
  5. package/config/minimum.json +6 -1
  6. package/config/moegirl.json +21 -65
  7. package/config/zhwiki.json +28 -494
  8. package/extensions/dist/base.js +163 -0
  9. package/extensions/dist/codejar.js +52 -0
  10. package/extensions/dist/editor.js +159 -0
  11. package/extensions/dist/highlight.js +30 -0
  12. package/extensions/dist/lint.js +72 -0
  13. package/extensions/editor.css +59 -0
  14. package/extensions/ui.css +162 -0
  15. package/package.json +28 -21
  16. package/config/.schema.json +0 -203
  17. package/dist/addon/table.js +0 -494
  18. package/dist/addon/token.js +0 -392
  19. package/dist/addon/transclude.js +0 -184
  20. package/dist/base.d.ts +0 -81
  21. package/dist/base.js +0 -40
  22. package/dist/index.d.ts +0 -33
  23. package/dist/index.js +0 -275
  24. package/dist/internal.d.ts +0 -47
  25. package/dist/lib/element.d.ts +0 -125
  26. package/dist/lib/element.js +0 -377
  27. package/dist/lib/node.d.ts +0 -173
  28. package/dist/lib/node.js +0 -478
  29. package/dist/lib/range.d.ts +0 -105
  30. package/dist/lib/range.js +0 -406
  31. package/dist/lib/ranges.d.ts +0 -28
  32. package/dist/lib/ranges.js +0 -126
  33. package/dist/lib/rect.d.ts +0 -18
  34. package/dist/lib/rect.js +0 -36
  35. package/dist/lib/text.d.ts +0 -58
  36. package/dist/lib/text.js +0 -414
  37. package/dist/lib/title.d.ts +0 -49
  38. package/dist/lib/title.js +0 -253
  39. package/dist/mixin/attributesParent.d.ts +0 -49
  40. package/dist/mixin/attributesParent.js +0 -80
  41. package/dist/mixin/fixed.d.ts +0 -5
  42. package/dist/mixin/fixed.js +0 -32
  43. package/dist/mixin/flagsParent.d.ts +0 -43
  44. package/dist/mixin/flagsParent.js +0 -64
  45. package/dist/mixin/hidden.d.ts +0 -7
  46. package/dist/mixin/hidden.js +0 -39
  47. package/dist/mixin/magicLinkParent.d.ts +0 -19
  48. package/dist/mixin/magicLinkParent.js +0 -43
  49. package/dist/mixin/singleLine.d.ts +0 -5
  50. package/dist/mixin/singleLine.js +0 -25
  51. package/dist/mixin/sol.d.ts +0 -6
  52. package/dist/mixin/sol.js +0 -45
  53. package/dist/mixin/syntax.d.ts +0 -8
  54. package/dist/mixin/syntax.js +0 -46
  55. package/dist/parser/braces.js +0 -152
  56. package/dist/parser/commentAndExt.js +0 -84
  57. package/dist/parser/converter.js +0 -41
  58. package/dist/parser/externalLinks.js +0 -39
  59. package/dist/parser/hrAndDoubleUnderscore.js +0 -44
  60. package/dist/parser/html.js +0 -40
  61. package/dist/parser/links.js +0 -103
  62. package/dist/parser/list.js +0 -116
  63. package/dist/parser/magicLinks.js +0 -55
  64. package/dist/parser/quotes.js +0 -69
  65. package/dist/parser/redirect.js +0 -28
  66. package/dist/parser/selector.js +0 -393
  67. package/dist/parser/table.js +0 -125
  68. package/dist/src/arg.d.ts +0 -49
  69. package/dist/src/arg.js +0 -219
  70. package/dist/src/atom.d.ts +0 -14
  71. package/dist/src/atom.js +0 -54
  72. package/dist/src/attribute.d.ts +0 -64
  73. package/dist/src/attribute.js +0 -478
  74. package/dist/src/attributes.d.ts +0 -103
  75. package/dist/src/attributes.js +0 -380
  76. package/dist/src/converter.d.ts +0 -28
  77. package/dist/src/converter.js +0 -153
  78. package/dist/src/converterFlags.d.ts +0 -80
  79. package/dist/src/converterFlags.js +0 -241
  80. package/dist/src/converterRule.d.ts +0 -71
  81. package/dist/src/converterRule.js +0 -218
  82. package/dist/src/extLink.d.ts +0 -36
  83. package/dist/src/extLink.js +0 -223
  84. package/dist/src/gallery.d.ts +0 -47
  85. package/dist/src/gallery.js +0 -145
  86. package/dist/src/heading.d.ts +0 -44
  87. package/dist/src/heading.js +0 -222
  88. package/dist/src/hidden.d.ts +0 -9
  89. package/dist/src/hidden.js +0 -82
  90. package/dist/src/html.d.ts +0 -61
  91. package/dist/src/html.js +0 -344
  92. package/dist/src/imageParameter.d.ts +0 -60
  93. package/dist/src/imageParameter.js +0 -262
  94. package/dist/src/imagemap.d.ts +0 -47
  95. package/dist/src/imagemap.js +0 -148
  96. package/dist/src/imagemapLink.d.ts +0 -35
  97. package/dist/src/imagemapLink.js +0 -99
  98. package/dist/src/index.d.ts +0 -136
  99. package/dist/src/index.js +0 -790
  100. package/dist/src/link/base.d.ts +0 -52
  101. package/dist/src/link/base.js +0 -258
  102. package/dist/src/link/category.d.ts +0 -22
  103. package/dist/src/link/category.js +0 -36
  104. package/dist/src/link/file.d.ts +0 -102
  105. package/dist/src/link/file.js +0 -335
  106. package/dist/src/link/galleryImage.d.ts +0 -29
  107. package/dist/src/link/galleryImage.js +0 -133
  108. package/dist/src/link/index.d.ts +0 -39
  109. package/dist/src/link/index.js +0 -100
  110. package/dist/src/link/redirectTarget.d.ts +0 -27
  111. package/dist/src/link/redirectTarget.js +0 -71
  112. package/dist/src/magicLink.d.ts +0 -57
  113. package/dist/src/magicLink.js +0 -261
  114. package/dist/src/nested.d.ts +0 -40
  115. package/dist/src/nested.js +0 -108
  116. package/dist/src/nowiki/base.d.ts +0 -28
  117. package/dist/src/nowiki/base.js +0 -90
  118. package/dist/src/nowiki/comment.d.ts +0 -14
  119. package/dist/src/nowiki/comment.js +0 -123
  120. package/dist/src/nowiki/dd.d.ts +0 -8
  121. package/dist/src/nowiki/dd.js +0 -74
  122. package/dist/src/nowiki/doubleUnderscore.d.ts +0 -15
  123. package/dist/src/nowiki/doubleUnderscore.js +0 -101
  124. package/dist/src/nowiki/hr.d.ts +0 -5
  125. package/dist/src/nowiki/hr.js +0 -72
  126. package/dist/src/nowiki/index.d.ts +0 -14
  127. package/dist/src/nowiki/index.js +0 -30
  128. package/dist/src/nowiki/list.d.ts +0 -5
  129. package/dist/src/nowiki/list.js +0 -67
  130. package/dist/src/nowiki/listBase.d.ts +0 -23
  131. package/dist/src/nowiki/listBase.js +0 -100
  132. package/dist/src/nowiki/noinclude.d.ts +0 -6
  133. package/dist/src/nowiki/noinclude.js +0 -77
  134. package/dist/src/nowiki/quote.d.ts +0 -14
  135. package/dist/src/nowiki/quote.js +0 -149
  136. package/dist/src/onlyinclude.d.ts +0 -13
  137. package/dist/src/onlyinclude.js +0 -60
  138. package/dist/src/paramTag/index.d.ts +0 -28
  139. package/dist/src/paramTag/index.js +0 -80
  140. package/dist/src/paramTag/inputbox.d.ts +0 -8
  141. package/dist/src/paramTag/inputbox.js +0 -24
  142. package/dist/src/parameter.d.ts +0 -60
  143. package/dist/src/parameter.js +0 -267
  144. package/dist/src/pre.d.ts +0 -28
  145. package/dist/src/pre.js +0 -62
  146. package/dist/src/redirect.d.ts +0 -30
  147. package/dist/src/redirect.js +0 -128
  148. package/dist/src/syntax.d.ts +0 -15
  149. package/dist/src/syntax.js +0 -87
  150. package/dist/src/table/base.d.ts +0 -28
  151. package/dist/src/table/base.js +0 -81
  152. package/dist/src/table/index.d.ts +0 -230
  153. package/dist/src/table/index.js +0 -506
  154. package/dist/src/table/td.d.ts +0 -72
  155. package/dist/src/table/td.js +0 -375
  156. package/dist/src/table/tr.d.ts +0 -30
  157. package/dist/src/table/tr.js +0 -61
  158. package/dist/src/table/trBase.d.ts +0 -49
  159. package/dist/src/table/trBase.js +0 -165
  160. package/dist/src/tagPair/ext.d.ts +0 -29
  161. package/dist/src/tagPair/ext.js +0 -217
  162. package/dist/src/tagPair/include.d.ts +0 -33
  163. package/dist/src/tagPair/include.js +0 -132
  164. package/dist/src/tagPair/index.d.ts +0 -23
  165. package/dist/src/tagPair/index.js +0 -130
  166. package/dist/src/transclude.d.ts +0 -159
  167. package/dist/src/transclude.js +0 -598
  168. package/dist/util/constants.js +0 -26
  169. package/dist/util/debug.js +0 -95
  170. package/dist/util/diff.js +0 -83
  171. package/dist/util/html.js +0 -146
  172. package/dist/util/lint.js +0 -32
  173. package/dist/util/string.js +0 -107
  174. package/errors/README +0 -3
  175. package/printed/README +0 -3
@@ -1,29 +0,0 @@
1
- import Parser from '../../index';
2
- import { Token } from '../index';
3
- import { TagPairToken } from './index';
4
- import { AttributesToken } from '../attributes';
5
- import type { LintError } from '../../base';
6
- import type { AttributesParentBase } from '../../mixin/attributesParent';
7
- export interface ExtToken extends AttributesParentBase {
8
- }
9
- /**
10
- * 扩展标签
11
- * @classdesc `{childNodes: [AttributesToken, Token]}`
12
- */
13
- export declare abstract class ExtToken extends TagPairToken {
14
- closed: true;
15
- readonly childNodes: readonly [AttributesToken, Token];
16
- abstract get firstChild(): AttributesToken;
17
- abstract get lastChild(): Token;
18
- abstract get children(): [AttributesToken, Token];
19
- abstract get firstElementChild(): AttributesToken;
20
- get type(): 'ext';
21
- /**
22
- * @param name 标签名
23
- * @param attr 标签属性
24
- * @param inner 内部wikitext
25
- * @param closed 是否封闭
26
- */
27
- constructor(name: string, attr?: string, inner?: string, closed?: string, config?: Parser.Config, accum?: Token[]);
28
- cloneNode(): this;
29
- }
@@ -1,217 +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.ExtToken = void 0;
38
- const lint_1 = require("../../util/lint");
39
- const rect_1 = require("../../lib/rect");
40
- const index_1 = require("../../index");
41
- const index_2 = require("../index");
42
- const index_3 = require("./index");
43
- const attributes_1 = require("../attributes");
44
- const pre_1 = require("../pre");
45
- const index_4 = require("../paramTag/index");
46
- const inputbox_1 = require("../paramTag/inputbox");
47
- const gallery_1 = require("../gallery");
48
- const imagemap_1 = require("../imagemap");
49
- const index_5 = require("../nowiki/index");
50
- /* NOT FOR BROWSER */
51
- const debug_1 = require("../../util/debug");
52
- const constants_1 = require("../../util/constants");
53
- const string_1 = require("../../util/string");
54
- const html_1 = require("../../util/html");
55
- const attributesParent_1 = require("../../mixin/attributesParent");
56
- /* NOT FOR BROWSER END */
57
- /**
58
- * 从数组中删除指定元素
59
- * @param arr 数组
60
- * @param ele 元素
61
- */
62
- const del = (arr, ele) => {
63
- const set = new Set(arr);
64
- set.delete(ele);
65
- return [...set];
66
- };
67
- /**
68
- * 扩展标签
69
- * @classdesc `{childNodes: [AttributesToken, Token]}`
70
- */
71
- let ExtToken = (() => {
72
- let _classDecorators = [(0, attributesParent_1.attributesParent)()];
73
- let _classDescriptor;
74
- let _classExtraInitializers = [];
75
- let _classThis;
76
- let _classSuper = index_3.TagPairToken;
77
- var ExtToken = class extends _classSuper {
78
- static { _classThis = this; }
79
- static {
80
- const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
81
- __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
82
- ExtToken = _classThis = _classDescriptor.value;
83
- if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
84
- __runInitializers(_classThis, _classExtraInitializers);
85
- }
86
- /* NOT FOR BROWSER END */
87
- get type() {
88
- return 'ext';
89
- }
90
- /**
91
- * @param name 标签名
92
- * @param attr 标签属性
93
- * @param inner 内部wikitext
94
- * @param closed 是否封闭
95
- */
96
- constructor(name, attr, inner, closed, config = index_1.default.getConfig(), accum = []) {
97
- const lcName = name.toLowerCase(),
98
- // @ts-expect-error abstract class
99
- attrToken = new attributes_1.AttributesToken(!attr || attr.trimStart() !== attr ? attr : ` ${attr}`, 'ext-attrs', lcName, config, accum), newConfig = { ...config, ext: del(config.ext, lcName), excludes: [...config.excludes ?? []] };
100
- let innerToken;
101
- switch (lcName) {
102
- case 'tab':
103
- newConfig.ext = del(newConfig.ext, 'tabs');
104
- // fall through
105
- case 'indicator':
106
- case 'poem':
107
- case 'ref':
108
- case 'option':
109
- case 'combooption':
110
- case 'tabs':
111
- case 'poll':
112
- case 'seo':
113
- if (lcName === 'poem') {
114
- newConfig.excludes.push('heading');
115
- }
116
- innerToken = new index_2.Token(inner, newConfig, accum);
117
- break;
118
- case 'pre':
119
- // @ts-expect-error abstract class
120
- innerToken = new pre_1.PreToken(inner, newConfig, accum);
121
- break;
122
- case 'dynamicpagelist':
123
- // @ts-expect-error abstract class
124
- innerToken = new index_4.ParamTagToken(inner, newConfig, accum);
125
- break;
126
- case 'inputbox':
127
- newConfig.excludes.push('heading');
128
- // @ts-expect-error abstract class
129
- innerToken = new inputbox_1.InputboxToken(inner, newConfig, accum);
130
- break;
131
- case 'references': {
132
- const { NestedToken } = require('../nested');
133
- // @ts-expect-error abstract class
134
- innerToken = new NestedToken(inner, /<!--.*?(?:-->|$)|<(ref)(\s[^>]*?)?(?:\/>|>(.*?)<\/(ref\s*)>)/gisu, ['ref'], newConfig, accum);
135
- break;
136
- }
137
- case 'choose': {
138
- const { NestedToken } = require('../nested');
139
- // @ts-expect-error abstract class
140
- innerToken = new NestedToken(inner, /<(option|choicetemplate)(\s[^>]*?)?(?:\/>|>(.*?)<\/(\1)>)/gsu, ['option', 'choicetemplate'], newConfig, accum);
141
- break;
142
- }
143
- case 'combobox': {
144
- const { NestedToken } = require('../nested');
145
- // @ts-expect-error abstract class
146
- innerToken = new NestedToken(inner, /<(combooption)(\s[^>]*?)?(?:\/>|>(.*?)<\/(combooption\s*)>)/gisu, ['combooption'], newConfig, accum);
147
- break;
148
- }
149
- case 'gallery':
150
- // @ts-expect-error abstract class
151
- innerToken = new gallery_1.GalleryToken(inner, newConfig, accum);
152
- break;
153
- case 'imagemap':
154
- // @ts-expect-error abstract class
155
- innerToken = new imagemap_1.ImagemapToken(inner, newConfig, accum);
156
- break;
157
- // 更多定制扩展的代码示例:
158
- // ```
159
- // case 'extensionName': {
160
- // const {ExtensionToken}: typeof import('../extension') = require('../extension');
161
- // innerToken = new ExtensionToken(inner, newConfig, accum);
162
- // break;
163
- // }
164
- // ```
165
- default:
166
- // @ts-expect-error abstract class
167
- innerToken = new index_5.NowikiToken(inner, newConfig, accum);
168
- }
169
- innerToken.setAttribute('name', lcName);
170
- if (innerToken.type === 'plain') {
171
- innerToken.type = 'ext-inner';
172
- }
173
- super(name, attrToken, innerToken, closed, config, accum);
174
- this.seal('closed', true);
175
- }
176
- /** @private */
177
- lint(start = this.getAbsoluteIndex(), re) {
178
- const errors = super.lint(start, re), rect = new rect_1.BoundingRect(this, start);
179
- if (this.name !== 'nowiki' && this.closest('html-attrs,table-attrs')) {
180
- errors.push((0, lint_1.generateForSelf)(this, rect, 'parsing-order', 'extension tag in HTML tag attributes'));
181
- }
182
- if (this.name === 'ref' && this.closest('heading-title')) {
183
- errors.push((0, lint_1.generateForSelf)(this, rect, 'var-anchor', 'variable anchor in a section header'));
184
- }
185
- return errors;
186
- }
187
- /* NOT FOR BROWSER */
188
- cloneNode() {
189
- const inner = this.lastChild.cloneNode(), tags = this.getAttribute('tags'), config = this.getAttribute('config'), attr = this.firstChild.toString();
190
- return debug_1.Shadow.run(() => {
191
- // @ts-expect-error abstract class
192
- const token = new ExtToken(tags[0], attr, '', this.selfClosing ? undefined : tags[1], config);
193
- token.lastChild.safeReplaceWith(inner);
194
- return token;
195
- });
196
- }
197
- /** @private */
198
- toHtmlInternal(_, nocc) {
199
- const { name, firstChild, lastChild } = this;
200
- switch (name) {
201
- case 'nowiki':
202
- return (0, html_1.font)(this, (0, string_1.newline)(lastChild.toHtmlInternal()));
203
- case 'pre':
204
- return (0, html_1.font)(this, `<pre${firstChild.toHtmlInternal()}>${(0, string_1.newline)(lastChild.toHtmlInternal(false, nocc))}</pre>`);
205
- case 'poem':
206
- firstChild.classList.add('poem');
207
- return (0, html_1.font)(this, `<div${firstChild.toHtmlInternal()}>${lastChild.toHtmlInternal(false, nocc).replace(/(?<!^|<hr>)\n(?!$)/gu, '<br>\n')
208
- .replace(/^ +/gmu, p => '&nbsp;'.repeat(p.length))}</div>`);
209
- default:
210
- return '';
211
- }
212
- }
213
- };
214
- return ExtToken = _classThis;
215
- })();
216
- exports.ExtToken = ExtToken;
217
- constants_1.classes['ExtToken'] = __filename;
@@ -1,33 +0,0 @@
1
- import { TagPairToken } from './index';
2
- import type { LintError, Config } from '../../base';
3
- import type { AstText, Token } from '../../internal';
4
- /**
5
- * `<includeonly>`或`<noinclude>`或`<onlyinclude>`
6
- * @classdesc `{childNodes: [AstText, AstText]}`
7
- */
8
- export declare abstract class IncludeToken extends TagPairToken {
9
- readonly childNodes: readonly [AstText, AstText];
10
- abstract get firstChild(): AstText;
11
- abstract get lastChild(): AstText;
12
- abstract get children(): [];
13
- abstract get firstElementChild(): undefined;
14
- abstract get lastElementChild(): undefined;
15
- get type(): 'include';
16
- get innerText(): string | undefined;
17
- set innerText(text: string | undefined);
18
- /**
19
- * @param name 标签名
20
- * @param attr 标签属性
21
- * @param inner 内部wikitext
22
- * @param closed 是否封闭
23
- */
24
- constructor(name: string, attr?: string, inner?: string, closed?: string, config?: Config, accum?: Token[]);
25
- cloneNode(): this;
26
- /**
27
- * @override
28
- * @param str 新文本
29
- */
30
- setText(str: string): string;
31
- /** 清除标签属性 */
32
- removeAttr(): void;
33
- }
@@ -1,132 +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.IncludeToken = void 0;
38
- const lint_1 = require("../../util/lint");
39
- const hidden_1 = require("../../mixin/hidden");
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
- /* NOT FOR BROWSER END */
46
- /**
47
- * `<includeonly>`或`<noinclude>`或`<onlyinclude>`
48
- * @classdesc `{childNodes: [AstText, AstText]}`
49
- */
50
- let IncludeToken = (() => {
51
- let _classDecorators = [(0, hidden_1.hiddenToken)(false)];
52
- let _classDescriptor;
53
- let _classExtraInitializers = [];
54
- let _classThis;
55
- let _classSuper = index_2.TagPairToken;
56
- var IncludeToken = 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
- IncludeToken = _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
- /* NOT FOR BROWSER END */
66
- get type() {
67
- return 'include';
68
- }
69
- /* NOT FOR BROWSER */
70
- get innerText() {
71
- return this.selfClosing ? undefined : this.lastChild.data;
72
- }
73
- set innerText(text) {
74
- if (text === undefined) {
75
- this.selfClosing = true;
76
- }
77
- else {
78
- this.selfClosing = false;
79
- this.setText(text);
80
- }
81
- }
82
- /* NOT FOR BROWSER END */
83
- /**
84
- * @param name 标签名
85
- * @param attr 标签属性
86
- * @param inner 内部wikitext
87
- * @param closed 是否封闭
88
- */
89
- constructor(name, attr = '', inner, closed, config, accum) {
90
- super(name, attr, inner ?? '', inner === undefined ? closed : closed ?? '', config, accum);
91
- }
92
- /** @private */
93
- toString(skip) {
94
- return skip ? '' : super.toString();
95
- }
96
- /** @private */
97
- lint(start = this.getAbsoluteIndex()) {
98
- if (this.closed) {
99
- return [];
100
- }
101
- const e = (0, lint_1.generateForSelf)(this, { start }, 'unclosed-comment', index_1.default.msg('unclosed $1', `<${this.name}>`));
102
- e.suggestions = [
103
- {
104
- desc: 'close',
105
- range: [e.endIndex, e.endIndex],
106
- text: `</${this.name}>`,
107
- },
108
- ];
109
- return [e];
110
- }
111
- /* NOT FOR BROWSER */
112
- cloneNode() {
113
- const tags = this.getAttribute('tags'), config = this.getAttribute('config'), { innerText } = this, closing = this.selfClosing || !this.closed ? undefined : tags[1];
114
- // @ts-expect-error abstract class
115
- return debug_1.Shadow.run(() => new IncludeToken(tags[0], this.firstChild.data, innerText, closing, config));
116
- }
117
- /**
118
- * @override
119
- * @param str 新文本
120
- */
121
- setText(str) {
122
- return super.setText(str, 1);
123
- }
124
- /** 清除标签属性 */
125
- removeAttr() {
126
- super.setText('');
127
- }
128
- };
129
- return IncludeToken = _classThis;
130
- })();
131
- exports.IncludeToken = IncludeToken;
132
- constants_1.classes['IncludeToken'] = __filename;
@@ -1,23 +0,0 @@
1
- import { Token } from '../index';
2
- import type { Config } from '../../base';
3
- import type { AstNodes } from '../../lib/node';
4
- /** 成对标签 */
5
- export declare abstract class TagPairToken extends Token {
6
- #private;
7
- readonly name: string;
8
- closed: boolean;
9
- selfClosing: boolean;
10
- abstract get type(): 'ext' | 'include';
11
- readonly childNodes: readonly [AstNodes, AstNodes];
12
- abstract get firstChild(): AstNodes;
13
- abstract get lastChild(): AstNodes;
14
- /** 内部wikitext */
15
- get innerText(): string | undefined;
16
- /**
17
- * @param name 标签名
18
- * @param attr 标签属性
19
- * @param inner 内部wikitext
20
- * @param closed 是否封闭;约定`undefined`表示自封闭,`''`表示未闭合
21
- */
22
- constructor(name: string, attr: string | Token, inner: string | Token, closed?: string, config?: Config, accum?: Token[]);
23
- }
@@ -1,130 +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.TagPairToken = void 0;
38
- const index_1 = require("../index");
39
- /* NOT FOR BROWSER */
40
- const constants_1 = require("../../util/constants");
41
- const fixed_1 = require("../../mixin/fixed");
42
- const index_2 = require("../../index");
43
- /* NOT FOR BROWSER END */
44
- /** 成对标签 */
45
- let TagPairToken = (() => {
46
- let _classDecorators = [fixed_1.fixedToken];
47
- let _classDescriptor;
48
- let _classExtraInitializers = [];
49
- let _classThis;
50
- let _classSuper = index_1.Token;
51
- var TagPairToken = class extends _classSuper {
52
- static { _classThis = this; }
53
- static {
54
- const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
55
- __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
56
- TagPairToken = _classThis = _classDescriptor.value;
57
- if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
58
- __runInitializers(_classThis, _classExtraInitializers);
59
- }
60
- #tags;
61
- closed;
62
- selfClosing;
63
- /* NOT FOR BROWSER END */
64
- /** 内部wikitext */
65
- get innerText() {
66
- return this.selfClosing ? undefined : this.lastChild.text();
67
- }
68
- /**
69
- * @param name 标签名
70
- * @param attr 标签属性
71
- * @param inner 内部wikitext
72
- * @param closed 是否封闭;约定`undefined`表示自封闭,`''`表示未闭合
73
- */
74
- constructor(name, attr, inner, closed, config, accum = []) {
75
- super(undefined, config);
76
- this.setAttribute('name', name.toLowerCase());
77
- this.#tags = [name, closed || name];
78
- this.closed = closed !== '';
79
- this.selfClosing = closed === undefined;
80
- this.append(attr, inner);
81
- const index = typeof attr === 'string' ? -1 : accum.indexOf(attr);
82
- accum.splice(index === -1 ? Infinity : index, 0, this);
83
- }
84
- /** @private */
85
- toString(skip) {
86
- const { selfClosing, firstChild, lastChild,
87
- /* NOT FOR BROWSER */
88
- nextSibling, name, closed, } = this, [opening, closing] = this.#tags;
89
- /* NOT FOR BROWSER */
90
- if (!closed && nextSibling) {
91
- index_2.default.error(`Auto-closing <${name}>`, lastChild);
92
- this.closed = true;
93
- }
94
- /* NOT FOR BROWSER END */
95
- return selfClosing
96
- ? `<${opening}${firstChild.toString(skip)}/>`
97
- : `<${opening}${firstChild.toString(skip)}>${lastChild.toString(skip)}${this.closed ? `</${closing}>` : ''}`;
98
- }
99
- /** @private */
100
- text() {
101
- const [opening, closing] = this.#tags;
102
- return this.selfClosing
103
- ? `<${opening}${this.firstChild.text()}/>`
104
- : `<${opening}${super.text('>')}${this.closed ? `</${closing}>` : ''}`;
105
- }
106
- /** @private */
107
- getAttribute(key) {
108
- /* NOT FOR BROWSER */
109
- if (key === 'tags') {
110
- return this.#tags;
111
- }
112
- /* NOT FOR BROWSER END */
113
- return key === 'padding' ? this.#tags[0].length + 1 : super.getAttribute(key);
114
- }
115
- /** @private */
116
- getGaps() {
117
- return 1;
118
- }
119
- /** @private */
120
- print() {
121
- const [opening, closing] = this.#tags;
122
- return super.print(this.selfClosing
123
- ? { pre: `&lt;${opening}`, post: '/&gt;' }
124
- : { pre: `&lt;${opening}`, sep: '&gt;', post: this.closed ? `&lt;/${closing}&gt;` : '' });
125
- }
126
- };
127
- return TagPairToken = _classThis;
128
- })();
129
- exports.TagPairToken = TagPairToken;
130
- constants_1.classes['TagPairToken'] = __filename;