wikiparser-node 1.13.0-b → 1.13.0

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 (174) hide show
  1. package/config/.schema.json +203 -0
  2. package/config/default.json +32 -31
  3. package/config/enwiki.json +829 -15
  4. package/config/llwiki.json +56 -21
  5. package/config/moegirl.json +65 -21
  6. package/config/zhwiki.json +498 -32
  7. package/dist/addon/table.js +494 -0
  8. package/dist/addon/token.js +392 -0
  9. package/dist/addon/transclude.js +184 -0
  10. package/dist/base.d.ts +109 -0
  11. package/dist/base.js +67 -0
  12. package/dist/index.d.ts +33 -0
  13. package/dist/index.js +279 -0
  14. package/dist/internal.d.ts +47 -0
  15. package/dist/lib/element.d.ts +125 -0
  16. package/dist/lib/element.js +364 -0
  17. package/dist/lib/node.d.ts +173 -0
  18. package/dist/lib/node.js +478 -0
  19. package/dist/lib/range.d.ts +105 -0
  20. package/dist/lib/range.js +406 -0
  21. package/dist/lib/ranges.d.ts +28 -0
  22. package/dist/lib/ranges.js +126 -0
  23. package/dist/lib/rect.d.ts +18 -0
  24. package/dist/lib/rect.js +36 -0
  25. package/dist/lib/text.d.ts +58 -0
  26. package/dist/lib/text.js +414 -0
  27. package/dist/lib/title.d.ts +49 -0
  28. package/dist/lib/title.js +251 -0
  29. package/dist/mixin/attributesParent.d.ts +49 -0
  30. package/dist/mixin/attributesParent.js +80 -0
  31. package/dist/mixin/fixed.d.ts +5 -0
  32. package/dist/mixin/fixed.js +32 -0
  33. package/dist/mixin/flagsParent.d.ts +43 -0
  34. package/dist/mixin/flagsParent.js +64 -0
  35. package/dist/mixin/hidden.d.ts +7 -0
  36. package/dist/mixin/hidden.js +39 -0
  37. package/dist/mixin/magicLinkParent.d.ts +19 -0
  38. package/dist/mixin/magicLinkParent.js +43 -0
  39. package/dist/mixin/singleLine.d.ts +5 -0
  40. package/dist/mixin/singleLine.js +25 -0
  41. package/dist/mixin/sol.d.ts +6 -0
  42. package/dist/mixin/sol.js +45 -0
  43. package/dist/mixin/syntax.d.ts +8 -0
  44. package/dist/mixin/syntax.js +46 -0
  45. package/dist/parser/braces.js +152 -0
  46. package/dist/parser/commentAndExt.js +84 -0
  47. package/dist/parser/converter.js +41 -0
  48. package/dist/parser/externalLinks.js +39 -0
  49. package/dist/parser/hrAndDoubleUnderscore.js +44 -0
  50. package/dist/parser/html.js +40 -0
  51. package/dist/parser/links.js +103 -0
  52. package/dist/parser/list.js +116 -0
  53. package/dist/parser/magicLinks.js +55 -0
  54. package/dist/parser/quotes.js +69 -0
  55. package/dist/parser/redirect.js +28 -0
  56. package/dist/parser/selector.js +443 -0
  57. package/dist/parser/table.js +125 -0
  58. package/dist/src/arg.d.ts +49 -0
  59. package/dist/src/arg.js +220 -0
  60. package/dist/src/atom.d.ts +14 -0
  61. package/dist/src/atom.js +54 -0
  62. package/dist/src/attribute.d.ts +64 -0
  63. package/dist/src/attribute.js +482 -0
  64. package/dist/src/attributes.d.ts +103 -0
  65. package/dist/src/attributes.js +383 -0
  66. package/dist/src/converter.d.ts +28 -0
  67. package/dist/src/converter.js +153 -0
  68. package/dist/src/converterFlags.d.ts +80 -0
  69. package/dist/src/converterFlags.js +241 -0
  70. package/dist/src/converterRule.d.ts +71 -0
  71. package/dist/src/converterRule.js +218 -0
  72. package/dist/src/extLink.d.ts +36 -0
  73. package/dist/src/extLink.js +223 -0
  74. package/dist/src/gallery.d.ts +51 -0
  75. package/dist/src/gallery.js +166 -0
  76. package/dist/src/heading.d.ts +44 -0
  77. package/dist/src/heading.js +222 -0
  78. package/dist/src/hidden.d.ts +9 -0
  79. package/dist/src/hidden.js +82 -0
  80. package/dist/src/html.d.ts +61 -0
  81. package/dist/src/html.js +344 -0
  82. package/dist/src/imageParameter.d.ts +60 -0
  83. package/dist/src/imageParameter.js +262 -0
  84. package/dist/src/imagemap.d.ts +47 -0
  85. package/dist/src/imagemap.js +148 -0
  86. package/dist/src/imagemapLink.d.ts +35 -0
  87. package/dist/src/imagemapLink.js +99 -0
  88. package/dist/src/index.d.ts +136 -0
  89. package/dist/src/index.js +790 -0
  90. package/dist/src/link/base.d.ts +52 -0
  91. package/dist/src/link/base.js +258 -0
  92. package/dist/src/link/category.d.ts +22 -0
  93. package/dist/src/link/category.js +36 -0
  94. package/dist/src/link/file.d.ts +102 -0
  95. package/dist/src/link/file.js +345 -0
  96. package/dist/src/link/galleryImage.d.ts +29 -0
  97. package/dist/src/link/galleryImage.js +133 -0
  98. package/dist/src/link/index.d.ts +39 -0
  99. package/dist/src/link/index.js +100 -0
  100. package/dist/src/link/redirectTarget.d.ts +27 -0
  101. package/dist/src/link/redirectTarget.js +71 -0
  102. package/dist/src/magicLink.d.ts +57 -0
  103. package/dist/src/magicLink.js +261 -0
  104. package/dist/src/nested.d.ts +40 -0
  105. package/dist/src/nested.js +108 -0
  106. package/dist/src/nowiki/base.d.ts +28 -0
  107. package/dist/src/nowiki/base.js +90 -0
  108. package/dist/src/nowiki/comment.d.ts +14 -0
  109. package/dist/src/nowiki/comment.js +123 -0
  110. package/dist/src/nowiki/dd.d.ts +8 -0
  111. package/dist/src/nowiki/dd.js +74 -0
  112. package/dist/src/nowiki/doubleUnderscore.d.ts +15 -0
  113. package/dist/src/nowiki/doubleUnderscore.js +101 -0
  114. package/dist/src/nowiki/hr.d.ts +5 -0
  115. package/dist/src/nowiki/hr.js +72 -0
  116. package/dist/src/nowiki/index.d.ts +14 -0
  117. package/dist/src/nowiki/index.js +30 -0
  118. package/dist/src/nowiki/list.d.ts +5 -0
  119. package/dist/src/nowiki/list.js +67 -0
  120. package/dist/src/nowiki/listBase.d.ts +23 -0
  121. package/dist/src/nowiki/listBase.js +100 -0
  122. package/dist/src/nowiki/noinclude.d.ts +6 -0
  123. package/dist/src/nowiki/noinclude.js +77 -0
  124. package/dist/src/nowiki/quote.d.ts +14 -0
  125. package/dist/src/nowiki/quote.js +149 -0
  126. package/dist/src/onlyinclude.d.ts +13 -0
  127. package/dist/src/onlyinclude.js +60 -0
  128. package/dist/src/paramTag/index.d.ts +28 -0
  129. package/dist/src/paramTag/index.js +80 -0
  130. package/dist/src/paramTag/inputbox.d.ts +8 -0
  131. package/dist/src/paramTag/inputbox.js +24 -0
  132. package/dist/src/parameter.d.ts +60 -0
  133. package/dist/src/parameter.js +267 -0
  134. package/dist/src/pre.d.ts +28 -0
  135. package/dist/src/pre.js +62 -0
  136. package/dist/src/redirect.d.ts +30 -0
  137. package/dist/src/redirect.js +128 -0
  138. package/dist/src/syntax.d.ts +15 -0
  139. package/dist/src/syntax.js +87 -0
  140. package/dist/src/table/base.d.ts +28 -0
  141. package/dist/src/table/base.js +81 -0
  142. package/dist/src/table/index.d.ts +230 -0
  143. package/dist/src/table/index.js +506 -0
  144. package/dist/src/table/td.d.ts +72 -0
  145. package/dist/src/table/td.js +375 -0
  146. package/dist/src/table/tr.d.ts +30 -0
  147. package/dist/src/table/tr.js +61 -0
  148. package/dist/src/table/trBase.d.ts +49 -0
  149. package/dist/src/table/trBase.js +165 -0
  150. package/dist/src/tagPair/ext.d.ts +29 -0
  151. package/dist/src/tagPair/ext.js +229 -0
  152. package/dist/src/tagPair/include.d.ts +33 -0
  153. package/dist/src/tagPair/include.js +132 -0
  154. package/dist/src/tagPair/index.d.ts +23 -0
  155. package/dist/src/tagPair/index.js +130 -0
  156. package/dist/src/transclude.d.ts +159 -0
  157. package/dist/src/transclude.js +598 -0
  158. package/dist/util/constants.js +26 -0
  159. package/dist/util/debug.js +95 -0
  160. package/dist/util/diff.js +83 -0
  161. package/dist/util/html.js +146 -0
  162. package/dist/util/lint.js +32 -0
  163. package/dist/util/string.js +107 -0
  164. package/errors/README +3 -0
  165. package/package.json +21 -28
  166. package/printed/README +3 -0
  167. package/bundle/bundle.min.js +0 -37
  168. package/extensions/dist/base.js +0 -163
  169. package/extensions/dist/codejar.js +0 -53
  170. package/extensions/dist/editor.js +0 -159
  171. package/extensions/dist/highlight.js +0 -30
  172. package/extensions/dist/lint.js +0 -72
  173. package/extensions/editor.css +0 -59
  174. package/extensions/ui.css +0 -162
@@ -0,0 +1,77 @@
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.NoincludeToken = void 0;
38
+ const hidden_1 = require("../../mixin/hidden");
39
+ const base_1 = require("./base");
40
+ /* NOT FOR BROWSER */
41
+ const constants_1 = require("../../util/constants");
42
+ /* NOT FOR BROWSER END */
43
+ /** `<noinclude>`和`</noinclude>`,不可进行任何更改 */
44
+ let NoincludeToken = (() => {
45
+ let _classDecorators = [(0, hidden_1.hiddenToken)()];
46
+ let _classDescriptor;
47
+ let _classExtraInitializers = [];
48
+ let _classThis;
49
+ let _classSuper = base_1.NowikiBaseToken;
50
+ var NoincludeToken = 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
+ NoincludeToken = _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
+ get type() {
60
+ return 'noinclude';
61
+ }
62
+ /** @private */
63
+ toString(skip) {
64
+ return skip ? '' : super.toString();
65
+ }
66
+ /* NOT FOR BROWSER */
67
+ setText(str) {
68
+ if (/^<\/?(?:(?:no|only)include|includeonly)(?:\s[^>]*)?\/?>$/iu.test(this.innerText)) {
69
+ this.constructorError('cannot change the text content');
70
+ }
71
+ return super.setText(str);
72
+ }
73
+ };
74
+ return NoincludeToken = _classThis;
75
+ })();
76
+ exports.NoincludeToken = NoincludeToken;
77
+ constants_1.classes['NoincludeToken'] = __filename;
@@ -0,0 +1,14 @@
1
+ import { NowikiBaseToken } from './base';
2
+ import type { LintError, AST } from '../../base';
3
+ /** `''`和`'''` */
4
+ export declare abstract class QuoteToken extends NowikiBaseToken {
5
+ get type(): 'quote';
6
+ get bold(): boolean;
7
+ get italic(): boolean;
8
+ get font(): {
9
+ bold: boolean;
10
+ italic: boolean;
11
+ };
12
+ /** @override */
13
+ json(): AST;
14
+ }
@@ -0,0 +1,149 @@
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.QuoteToken = void 0;
38
+ const lint_1 = require("../../util/lint");
39
+ const rect_1 = require("../../lib/rect");
40
+ const index_1 = require("../../index");
41
+ const base_1 = require("./base");
42
+ /* NOT FOR BROWSER */
43
+ const constants_1 = require("../../util/constants");
44
+ const html_1 = require("../../util/html");
45
+ const syntax_1 = require("../../mixin/syntax");
46
+ /* NOT FOR BROWSER END */
47
+ /** `''`和`'''` */
48
+ let QuoteToken = (() => {
49
+ let _classDecorators = [(0, syntax_1.syntax)(/^(?:'{5}|'{2,3})$/u)];
50
+ let _classDescriptor;
51
+ let _classExtraInitializers = [];
52
+ let _classThis;
53
+ let _classSuper = base_1.NowikiBaseToken;
54
+ var QuoteToken = class extends _classSuper {
55
+ static { _classThis = this; }
56
+ static {
57
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
58
+ __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
59
+ QuoteToken = _classThis = _classDescriptor.value;
60
+ if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
61
+ __runInitializers(_classThis, _classExtraInitializers);
62
+ }
63
+ get type() {
64
+ return 'quote';
65
+ }
66
+ get bold() {
67
+ return this.innerText.length !== 2;
68
+ }
69
+ get italic() {
70
+ return this.innerText.length !== 3;
71
+ }
72
+ /* NOT FOR BROWSER */
73
+ get font() {
74
+ return { bold: this.bold, italic: this.italic };
75
+ }
76
+ /* NOT FOR BROWSER END */
77
+ /** @private */
78
+ text() {
79
+ const { parentNode, innerText } = this;
80
+ return parentNode?.type === 'image-parameter' && parentNode.name !== 'caption' ? '' : innerText;
81
+ }
82
+ /** @private */
83
+ lint(start = this.getAbsoluteIndex()) {
84
+ const { previousSibling, nextSibling, bold } = this, message = index_1.default.msg('lonely "$1"', `'`), errors = [], rect = new rect_1.BoundingRect(this, start);
85
+ let refError;
86
+ /**
87
+ * 获取建议
88
+ * @param startIndex 起点
89
+ * @param endIndex 终点
90
+ * @param length 长度
91
+ */
92
+ const getSuggestion = (startIndex, endIndex, length) => ({
93
+ desc: 'escape',
94
+ range: [startIndex, endIndex],
95
+ text: '&apos;'.repeat(length),
96
+ });
97
+ if (previousSibling?.type === 'text' && previousSibling.data.endsWith(`'`)) {
98
+ refError = (0, lint_1.generateForSelf)(this, rect, 'lonely-apos', message);
99
+ const { startIndex: endIndex, startLine: endLine, startCol: endCol } = refError, [, { length }] = /(?:^|[^'])('+)$/u.exec(previousSibling.data), startIndex = start - length;
100
+ errors.push({
101
+ ...refError,
102
+ startIndex,
103
+ endIndex,
104
+ startCol: endCol - length,
105
+ endLine,
106
+ endCol,
107
+ suggestions: [getSuggestion(startIndex, endIndex, length)],
108
+ });
109
+ }
110
+ if (nextSibling?.type === 'text' && nextSibling.data.startsWith(`'`)) {
111
+ refError ??= (0, lint_1.generateForSelf)(this, rect, 'lonely-apos', message);
112
+ const { endIndex: startIndex, endLine: startLine, endCol: startCol } = refError, [{ length }] = /^'+/u.exec(nextSibling.data), endIndex = startIndex + length;
113
+ errors.push({
114
+ ...refError,
115
+ startIndex,
116
+ endIndex,
117
+ startLine,
118
+ startCol,
119
+ endCol: startCol + length,
120
+ suggestions: [getSuggestion(startIndex, endIndex, length)],
121
+ });
122
+ }
123
+ if (bold && this.closest('heading-title')) {
124
+ errors.push((0, lint_1.generateForSelf)(this, rect, 'bold-header', 'bold in section header', 'warning'));
125
+ }
126
+ return errors;
127
+ }
128
+ /** @override */
129
+ json() {
130
+ const json = super.json();
131
+ Object.assign(json, { bold: this.bold, italic: this.italic });
132
+ return json;
133
+ }
134
+ /* NOT FOR BROWSER */
135
+ /** @private */
136
+ toHtmlInternal() {
137
+ const { previousVisibleSibling, nextVisibleSibling } = this;
138
+ return (!previousVisibleSibling
139
+ || previousVisibleSibling.type === 'text' && previousVisibleSibling.data.includes('\n'))
140
+ && nextVisibleSibling?.type === 'text'
141
+ && nextVisibleSibling.data.startsWith('\n')
142
+ ? (0, html_1.font)(this)
143
+ : '';
144
+ }
145
+ };
146
+ return QuoteToken = _classThis;
147
+ })();
148
+ exports.QuoteToken = QuoteToken;
149
+ constants_1.classes['QuoteToken'] = __filename;
@@ -0,0 +1,13 @@
1
+ import { Token } from './index';
2
+ /**
3
+ * 嵌入时的`<onlyinclude>`
4
+ * @classdesc `{childNodes: ...AstText|Token}`
5
+ */
6
+ export declare class OnlyincludeToken extends Token {
7
+ get type(): 'onlyinclude';
8
+ /** 内部wikitext */
9
+ get innerText(): string;
10
+ /** @throws `RangeError` 不允许包含`</onlyinclude>` */
11
+ set innerText(text: string);
12
+ cloneNode(): this;
13
+ }
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.OnlyincludeToken = void 0;
4
+ const index_1 = require("./index");
5
+ /* NOT FOR BROWSER */
6
+ const debug_1 = require("../util/debug");
7
+ const constants_1 = require("../util/constants");
8
+ const index_2 = require("../index");
9
+ /* NOT FOR BROWSER END */
10
+ /**
11
+ * 嵌入时的`<onlyinclude>`
12
+ * @classdesc `{childNodes: ...AstText|Token}`
13
+ */
14
+ class OnlyincludeToken extends index_1.Token {
15
+ get type() {
16
+ return 'onlyinclude';
17
+ }
18
+ /* NOT FOR BROWSER */
19
+ /** 内部wikitext */
20
+ get innerText() {
21
+ return this.text();
22
+ }
23
+ /** @throws `RangeError` 不允许包含`</onlyinclude>` */
24
+ set innerText(text) {
25
+ if (text.includes('</onlyinclude>')) {
26
+ throw new RangeError('"</onlyinclude>" is not allowed in the text!');
27
+ }
28
+ this.replaceChildren(...index_2.default.parse(text, true, undefined, this.getAttribute('config')).childNodes);
29
+ }
30
+ /* NOT FOR BROWSER END */
31
+ /** @private */
32
+ toString(skip) {
33
+ return `<onlyinclude>${super.toString(skip)}</onlyinclude>`;
34
+ }
35
+ /** @private */
36
+ getAttribute(key) {
37
+ if (key === 'padding') {
38
+ return 13;
39
+ }
40
+ return (key === 'plain') || super.getAttribute(key);
41
+ }
42
+ /** @private */
43
+ print() {
44
+ return super.print({
45
+ pre: '<span class="wpb-ext">&lt;onlyinclude&gt;</span>',
46
+ post: '<span class="wpb-ext">&lt;/onlyinclude&gt;</span>',
47
+ });
48
+ }
49
+ /* NOT FOR BROWSER */
50
+ cloneNode() {
51
+ const cloned = this.cloneChildNodes();
52
+ return debug_1.Shadow.run(() => {
53
+ const token = new OnlyincludeToken(undefined, this.getAttribute('config'));
54
+ token.append(...cloned);
55
+ return token;
56
+ });
57
+ }
58
+ }
59
+ exports.OnlyincludeToken = OnlyincludeToken;
60
+ constants_1.classes['OnlyincludeToken'] = __filename;
@@ -0,0 +1,28 @@
1
+ import Parser from '../../index';
2
+ import { Token } from '../index';
3
+ import { AtomToken } from '../atom';
4
+ import type { LintError } from '../../base';
5
+ import type { AttributesToken, ExtToken } from '../../internal';
6
+ /**
7
+ * `<dynamicpagelist>`
8
+ * @classdesc `{childNodes: ...AtomToken}`
9
+ */
10
+ export declare abstract class ParamTagToken extends Token {
11
+ readonly name: string;
12
+ readonly childNodes: readonly AtomToken[];
13
+ abstract get firstChild(): AtomToken | undefined;
14
+ abstract get lastChild(): AtomToken | undefined;
15
+ abstract get nextSibling(): undefined;
16
+ abstract get previousSibling(): AttributesToken;
17
+ abstract get parentNode(): ExtToken | undefined;
18
+ abstract get children(): AtomToken[];
19
+ abstract get firstElementChild(): AtomToken | undefined;
20
+ abstract get lastElementChild(): AtomToken | undefined;
21
+ abstract get nextElementSibling(): undefined;
22
+ abstract get previousElementSibling(): AttributesToken;
23
+ abstract get parentElement(): ExtToken | undefined;
24
+ get type(): 'ext-inner';
25
+ /** @class */
26
+ constructor(wikitext?: string, config?: Parser.Config, accum?: Token[], acceptable?: Acceptable);
27
+ cloneNode(): this;
28
+ }
@@ -0,0 +1,80 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ParamTagToken = void 0;
4
+ const lint_1 = require("../../util/lint");
5
+ const rect_1 = require("../../lib/rect");
6
+ const index_1 = require("../../index");
7
+ const index_2 = require("../index");
8
+ const atom_1 = require("../atom");
9
+ /* NOT FOR BROWSER */
10
+ const debug_1 = require("../../util/debug");
11
+ const constants_1 = require("../../util/constants");
12
+ const singleLine_1 = require("../../mixin/singleLine");
13
+ /* NOT FOR BROWSER END */
14
+ /**
15
+ * `<dynamicpagelist>`
16
+ * @classdesc `{childNodes: ...AtomToken}`
17
+ */
18
+ class ParamTagToken extends index_2.Token {
19
+ /* NOT FOR BROWSER END */
20
+ get type() {
21
+ return 'ext-inner';
22
+ }
23
+ /** @class */
24
+ constructor(wikitext, config = index_1.default.getConfig(), accum = [], acceptable = {}) {
25
+ super(undefined, config, accum, {
26
+ AtomToken: ':',
27
+ });
28
+ if (wikitext) {
29
+ const SingleLineAtomToken = (0, singleLine_1.singleLine)(atom_1.AtomToken);
30
+ this.append(...wikitext.split('\n').map(line => new SingleLineAtomToken(line, 'param-line', config, accum, {
31
+ AstText: ':', ...acceptable,
32
+ })));
33
+ }
34
+ }
35
+ /** @private */
36
+ toString(skip) {
37
+ return super.toString(skip, '\n');
38
+ }
39
+ /** @private */
40
+ text() {
41
+ return super.text('\n');
42
+ }
43
+ /** @private */
44
+ getGaps() {
45
+ return 1;
46
+ }
47
+ /** @private */
48
+ lint(start = this.getAbsoluteIndex()) {
49
+ const rect = new rect_1.BoundingRect(this, start);
50
+ return this.childNodes.filter(child => {
51
+ const { childNodes } = child, i = childNodes.findIndex(({ type }) => type !== 'text'), str = (i >= 0 ? childNodes.slice(0, i).map(String).join('') : child.toString()).trim();
52
+ return str && !(i >= 0 ? /^[a-z]+(?:\[\])?\s*(?:=|$)/iu : /^[a-z]+(?:\[\])?\s*=/iu).test(str);
53
+ }).map(child => {
54
+ const e = (0, lint_1.generateForChild)(child, rect, 'no-ignored', index_1.default.msg('invalid parameter of <$1>', this.name));
55
+ e.suggestions = [
56
+ {
57
+ desc: 'remove',
58
+ range: [e.startIndex, e.endIndex],
59
+ text: '',
60
+ },
61
+ ];
62
+ return e;
63
+ });
64
+ }
65
+ /** @private */
66
+ print() {
67
+ return super.print({ sep: '\n' });
68
+ }
69
+ /* NOT FOR BROWSER */
70
+ cloneNode() {
71
+ const cloned = this.cloneChildNodes();
72
+ return debug_1.Shadow.run(() => {
73
+ const C = this.constructor, token = new C(undefined, this.getAttribute('config'));
74
+ token.append(...cloned);
75
+ return token;
76
+ });
77
+ }
78
+ }
79
+ exports.ParamTagToken = ParamTagToken;
80
+ constants_1.classes['ParamTagToken'] = __filename;
@@ -0,0 +1,8 @@
1
+ import Parser from '../../index';
2
+ import { ParamTagToken } from './index';
3
+ import type { Token } from '../index';
4
+ /** `<inputbox>` */
5
+ export declare abstract class InputboxToken extends ParamTagToken {
6
+ /** @class */
7
+ constructor(wikitext?: string, config?: Parser.Config, accum?: Token[]);
8
+ }
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.InputboxToken = void 0;
4
+ const braces_1 = require("../../parser/braces");
5
+ const index_1 = require("../../index");
6
+ const index_2 = require("./index");
7
+ /* NOT FOR BROWSER */
8
+ const constants_1 = require("../../util/constants");
9
+ /* NOT FOR BROWSER END */
10
+ /** `<inputbox>` */
11
+ class InputboxToken extends index_2.ParamTagToken {
12
+ /** @class */
13
+ constructor(wikitext, config = index_1.default.getConfig(), accum = []) {
14
+ const placeholder = Symbol('InputboxToken'), { length } = accum;
15
+ accum.push(placeholder);
16
+ wikitext &&= (0, braces_1.parseBraces)(wikitext, config, accum);
17
+ accum.splice(length, 1);
18
+ super(wikitext, config, accum, {
19
+ ArgToken: ':', TranscludeToken: ':',
20
+ });
21
+ }
22
+ }
23
+ exports.InputboxToken = InputboxToken;
24
+ constants_1.classes['InputboxToken'] = __filename;
@@ -0,0 +1,60 @@
1
+ import Parser from '../index';
2
+ import { Token } from './index';
3
+ import type { LintError, AST } from '../base';
4
+ import type { AtomToken, SyntaxToken, TranscludeToken } from '../internal';
5
+ /**
6
+ * 模板或魔术字参数
7
+ * @classdesc `{childNodes: [Token, Token]}`
8
+ */
9
+ export declare abstract class ParameterToken extends Token {
10
+ readonly name: string;
11
+ readonly childNodes: readonly [Token, Token];
12
+ abstract get firstChild(): Token;
13
+ abstract get lastChild(): Token;
14
+ abstract get parentNode(): TranscludeToken | undefined;
15
+ abstract get nextSibling(): this | undefined;
16
+ abstract get previousSibling(): AtomToken | SyntaxToken | this;
17
+ abstract get children(): [Token, Token];
18
+ abstract get firstElementChild(): Token;
19
+ abstract get lastElementChild(): Token;
20
+ abstract get parentElement(): TranscludeToken | undefined;
21
+ abstract get nextElementSibling(): this | undefined;
22
+ abstract get previousElementSibling(): AtomToken | SyntaxToken | this;
23
+ get type(): 'parameter';
24
+ /** 是否是匿名参数 */
25
+ get anon(): boolean;
26
+ set anon(value: boolean);
27
+ /** getValue()的getter */
28
+ get value(): string;
29
+ set value(value: string);
30
+ /** 是否是重复参数 */
31
+ get duplicated(): boolean;
32
+ set duplicated(value: boolean);
33
+ /**
34
+ * @param key 参数名
35
+ * @param value 参数值
36
+ */
37
+ constructor(key?: string | number, value?: string, config?: Parser.Config, accum?: Token[]);
38
+ text(): string;
39
+ /** @override */
40
+ json(): AST;
41
+ cloneNode(): this;
42
+ safeReplaceWith(token: this): void;
43
+ /** 获取参数值 */
44
+ getValue(): string;
45
+ /**
46
+ * 设置参数值
47
+ * @param value 参数值
48
+ */
49
+ setValue(value: string): void;
50
+ /**
51
+ * 修改参数名
52
+ * @param key 新参数名
53
+ * @param force 是否无视冲突命名
54
+ * @throws `Error` 仅用于模板参数
55
+ * @throws `RangeError` 更名造成重复参数
56
+ */
57
+ rename(key: string, force?: boolean): void;
58
+ /** 转义 `=` */
59
+ escape(): void;
60
+ }