wikiparser-node 1.6.1 → 1.6.2-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 (163) hide show
  1. package/bundle/bundle.min.js +39 -0
  2. package/config/enwiki.json +1 -814
  3. package/config/llwiki.json +1 -35
  4. package/config/moegirl.json +1 -44
  5. package/config/zhwiki.json +1 -466
  6. package/extensions/dist/base.js +64 -0
  7. package/extensions/dist/editor.js +159 -0
  8. package/extensions/dist/highlight.js +59 -0
  9. package/extensions/dist/lint.js +60 -0
  10. package/extensions/editor.css +63 -0
  11. package/extensions/ui.css +144 -0
  12. package/package.json +32 -16
  13. package/config/.schema.json +0 -172
  14. package/dist/addon/table.d.ts +0 -1
  15. package/dist/addon/table.js +0 -485
  16. package/dist/base.d.ts +0 -72
  17. package/dist/base.js +0 -38
  18. package/dist/index.d.ts +0 -30
  19. package/dist/index.js +0 -214
  20. package/dist/internal.d.ts +0 -44
  21. package/dist/lib/element.d.ts +0 -151
  22. package/dist/lib/element.js +0 -615
  23. package/dist/lib/node.d.ts +0 -146
  24. package/dist/lib/node.js +0 -426
  25. package/dist/lib/range.d.ts +0 -104
  26. package/dist/lib/range.js +0 -385
  27. package/dist/lib/ranges.d.ts +0 -26
  28. package/dist/lib/ranges.js +0 -121
  29. package/dist/lib/text.d.ts +0 -63
  30. package/dist/lib/text.js +0 -354
  31. package/dist/lib/title.d.ts +0 -38
  32. package/dist/lib/title.js +0 -160
  33. package/dist/mixin/attributesParent.d.ts +0 -50
  34. package/dist/mixin/attributesParent.js +0 -81
  35. package/dist/mixin/fixed.d.ts +0 -6
  36. package/dist/mixin/fixed.js +0 -30
  37. package/dist/mixin/flagsParent.d.ts +0 -72
  38. package/dist/mixin/flagsParent.js +0 -59
  39. package/dist/mixin/hidden.d.ts +0 -5
  40. package/dist/mixin/hidden.js +0 -24
  41. package/dist/mixin/magicLinkParent.d.ts +0 -40
  42. package/dist/mixin/magicLinkParent.js +0 -42
  43. package/dist/mixin/singleLine.d.ts +0 -6
  44. package/dist/mixin/singleLine.js +0 -26
  45. package/dist/mixin/sol.d.ts +0 -6
  46. package/dist/mixin/sol.js +0 -43
  47. package/dist/mixin/syntax.d.ts +0 -9
  48. package/dist/mixin/syntax.js +0 -50
  49. package/dist/parser/braces.js +0 -131
  50. package/dist/parser/commentAndExt.js +0 -90
  51. package/dist/parser/converter.js +0 -41
  52. package/dist/parser/externalLinks.js +0 -32
  53. package/dist/parser/hrAndDoubleUnderscore.js +0 -41
  54. package/dist/parser/html.js +0 -39
  55. package/dist/parser/links.js +0 -95
  56. package/dist/parser/list.js +0 -98
  57. package/dist/parser/magicLinks.js +0 -43
  58. package/dist/parser/quotes.js +0 -68
  59. package/dist/parser/selector.js +0 -162
  60. package/dist/parser/table.js +0 -124
  61. package/dist/src/arg.d.ts +0 -58
  62. package/dist/src/arg.js +0 -214
  63. package/dist/src/atom.d.ts +0 -12
  64. package/dist/src/atom.js +0 -27
  65. package/dist/src/attribute.d.ts +0 -71
  66. package/dist/src/attribute.js +0 -502
  67. package/dist/src/attributes.d.ts +0 -109
  68. package/dist/src/attributes.js +0 -356
  69. package/dist/src/converter.d.ts +0 -33
  70. package/dist/src/converter.js +0 -134
  71. package/dist/src/converterFlags.d.ts +0 -87
  72. package/dist/src/converterFlags.js +0 -242
  73. package/dist/src/converterRule.d.ts +0 -77
  74. package/dist/src/converterRule.js +0 -209
  75. package/dist/src/extLink.d.ts +0 -43
  76. package/dist/src/extLink.js +0 -188
  77. package/dist/src/gallery.d.ts +0 -54
  78. package/dist/src/gallery.js +0 -139
  79. package/dist/src/heading.d.ts +0 -47
  80. package/dist/src/heading.js +0 -190
  81. package/dist/src/hidden.d.ts +0 -7
  82. package/dist/src/hidden.js +0 -23
  83. package/dist/src/html.d.ts +0 -65
  84. package/dist/src/html.js +0 -358
  85. package/dist/src/imageParameter.d.ts +0 -65
  86. package/dist/src/imageParameter.js +0 -257
  87. package/dist/src/imagemap.d.ts +0 -54
  88. package/dist/src/imagemap.js +0 -144
  89. package/dist/src/imagemapLink.d.ts +0 -31
  90. package/dist/src/imagemapLink.js +0 -93
  91. package/dist/src/index.d.ts +0 -143
  92. package/dist/src/index.js +0 -852
  93. package/dist/src/link/base.d.ts +0 -52
  94. package/dist/src/link/base.js +0 -228
  95. package/dist/src/link/category.d.ts +0 -13
  96. package/dist/src/link/category.js +0 -28
  97. package/dist/src/link/file.d.ts +0 -98
  98. package/dist/src/link/file.js +0 -272
  99. package/dist/src/link/galleryImage.d.ts +0 -32
  100. package/dist/src/link/galleryImage.js +0 -157
  101. package/dist/src/link/index.d.ts +0 -56
  102. package/dist/src/link/index.js +0 -133
  103. package/dist/src/magicLink.d.ts +0 -59
  104. package/dist/src/magicLink.js +0 -223
  105. package/dist/src/nested.d.ts +0 -43
  106. package/dist/src/nested.js +0 -105
  107. package/dist/src/nowiki/base.d.ts +0 -31
  108. package/dist/src/nowiki/base.js +0 -93
  109. package/dist/src/nowiki/comment.d.ts +0 -25
  110. package/dist/src/nowiki/comment.js +0 -76
  111. package/dist/src/nowiki/dd.d.ts +0 -8
  112. package/dist/src/nowiki/dd.js +0 -24
  113. package/dist/src/nowiki/doubleUnderscore.d.ts +0 -18
  114. package/dist/src/nowiki/doubleUnderscore.js +0 -101
  115. package/dist/src/nowiki/hr.d.ts +0 -5
  116. package/dist/src/nowiki/hr.js +0 -63
  117. package/dist/src/nowiki/index.d.ts +0 -16
  118. package/dist/src/nowiki/index.js +0 -27
  119. package/dist/src/nowiki/list.d.ts +0 -16
  120. package/dist/src/nowiki/list.js +0 -109
  121. package/dist/src/nowiki/listBase.d.ts +0 -5
  122. package/dist/src/nowiki/listBase.js +0 -61
  123. package/dist/src/nowiki/noinclude.d.ts +0 -10
  124. package/dist/src/nowiki/noinclude.js +0 -23
  125. package/dist/src/nowiki/quote.d.ts +0 -14
  126. package/dist/src/nowiki/quote.js +0 -131
  127. package/dist/src/onlyinclude.d.ts +0 -16
  128. package/dist/src/onlyinclude.js +0 -57
  129. package/dist/src/paramTag/index.d.ts +0 -37
  130. package/dist/src/paramTag/index.js +0 -77
  131. package/dist/src/paramTag/inputbox.d.ts +0 -8
  132. package/dist/src/paramTag/inputbox.js +0 -22
  133. package/dist/src/parameter.d.ts +0 -70
  134. package/dist/src/parameter.js +0 -264
  135. package/dist/src/pre.d.ts +0 -31
  136. package/dist/src/pre.js +0 -59
  137. package/dist/src/syntax.d.ts +0 -20
  138. package/dist/src/syntax.js +0 -86
  139. package/dist/src/table/base.d.ts +0 -27
  140. package/dist/src/table/base.js +0 -81
  141. package/dist/src/table/index.d.ts +0 -242
  142. package/dist/src/table/index.js +0 -495
  143. package/dist/src/table/td.d.ts +0 -86
  144. package/dist/src/table/td.js +0 -354
  145. package/dist/src/table/tr.d.ts +0 -32
  146. package/dist/src/table/tr.js +0 -58
  147. package/dist/src/table/trBase.d.ts +0 -53
  148. package/dist/src/table/trBase.js +0 -156
  149. package/dist/src/tagPair/ext.d.ts +0 -32
  150. package/dist/src/tagPair/ext.js +0 -203
  151. package/dist/src/tagPair/include.d.ts +0 -35
  152. package/dist/src/tagPair/include.js +0 -74
  153. package/dist/src/tagPair/index.d.ts +0 -27
  154. package/dist/src/tagPair/index.js +0 -128
  155. package/dist/src/transclude.d.ts +0 -167
  156. package/dist/src/transclude.js +0 -717
  157. package/dist/util/constants.js +0 -28
  158. package/dist/util/debug.js +0 -88
  159. package/dist/util/diff.js +0 -83
  160. package/dist/util/lint.js +0 -31
  161. package/dist/util/string.js +0 -54
  162. package/errors/README +0 -1
  163. package/printed/README +0 -1
@@ -1,109 +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.ListToken = void 0;
38
- const constants_1 = require("../../util/constants");
39
- const sol_1 = require("../../mixin/sol");
40
- const listBase_1 = require("./listBase");
41
- /** 位于行首的`;:*#` */
42
- let ListToken = (() => {
43
- let _classDecorators = [sol_1.sol];
44
- let _classDescriptor;
45
- let _classExtraInitializers = [];
46
- let _classThis;
47
- let _classSuper = listBase_1.ListBaseToken;
48
- var ListToken = class extends _classSuper {
49
- static { _classThis = this; }
50
- static {
51
- const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
52
- __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
53
- ListToken = _classThis = _classDescriptor.value;
54
- if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
55
- __runInitializers(_classThis, _classExtraInitializers);
56
- }
57
- type = 'list';
58
- /* NOT FOR BROWSER */
59
- /** 是否包含`:` */
60
- get dd() {
61
- return this.innerText.includes(':');
62
- }
63
- /** 是否包含`;` */
64
- get dt() {
65
- return this.innerText.includes(';');
66
- }
67
- /** 是否包含`*` */
68
- get ul() {
69
- return this.innerText.includes('*');
70
- }
71
- /** 是否包含`#` */
72
- get ol() {
73
- return this.innerText.includes('#');
74
- }
75
- /** 获取列表行的范围 */
76
- getRange() {
77
- const range = this.createRange();
78
- let nDt = this.dt ? this.innerText.split(';').length - 2 : 0;
79
- range.setStartBefore(this);
80
- let { nextSibling } = this;
81
- while (nextSibling && (nextSibling.type !== 'text' || !nextSibling.data.includes('\n'))) {
82
- if (nextSibling.type === 'dd') {
83
- nDt -= nextSibling.indent;
84
- }
85
- if (nDt < 0) {
86
- break;
87
- }
88
- ({ nextSibling } = nextSibling);
89
- }
90
- if (nextSibling) {
91
- if (nDt < 0) {
92
- range.setEndBefore(nextSibling);
93
- }
94
- else {
95
- const i = nextSibling.data.indexOf('\n');
96
- range.setEnd(nextSibling, i);
97
- }
98
- }
99
- else {
100
- const { parentNode } = this;
101
- range.setEnd(parentNode, parentNode.length);
102
- }
103
- return range;
104
- }
105
- };
106
- return ListToken = _classThis;
107
- })();
108
- exports.ListToken = ListToken;
109
- constants_1.classes['ListToken'] = __filename;
@@ -1,5 +0,0 @@
1
- import { NowikiBaseToken } from './base';
2
- /** `;:*#` */
3
- export declare abstract class ListBaseToken extends NowikiBaseToken {
4
- type: 'dd' | 'list';
5
- }
@@ -1,61 +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.ListBaseToken = void 0;
38
- const constants_1 = require("../../util/constants");
39
- const syntax_1 = require("../../mixin/syntax");
40
- const base_1 = require("./base");
41
- /** `;:*#` */
42
- let ListBaseToken = (() => {
43
- let _classDecorators = [(0, syntax_1.syntax)(/^[;:*#]+$/u)];
44
- let _classDescriptor;
45
- let _classExtraInitializers = [];
46
- let _classThis;
47
- let _classSuper = base_1.NowikiBaseToken;
48
- var ListBaseToken = class extends _classSuper {
49
- static { _classThis = this; }
50
- static {
51
- const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
52
- __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
53
- ListBaseToken = _classThis = _classDescriptor.value;
54
- if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
55
- __runInitializers(_classThis, _classExtraInitializers);
56
- }
57
- };
58
- return ListBaseToken = _classThis;
59
- })();
60
- exports.ListBaseToken = ListBaseToken;
61
- constants_1.classes['ListBase'] = __filename;
@@ -1,10 +0,0 @@
1
- import { NowikiBaseToken } from './base';
2
- export declare abstract class NoincludeToken extends NowikiBaseToken {
3
- readonly type = "noinclude";
4
- /**
5
- * @override
6
- * @param str 新文本
7
- */
8
- setText(str: string): string;
9
- }
10
- export {};
@@ -1,23 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.NoincludeToken = void 0;
4
- const constants_1 = require("../../util/constants");
5
- const hidden_1 = require("../../mixin/hidden");
6
- const base_1 = require("./base");
7
- /** `<noinclude>`和`</noinclude>`,不可进行任何更改 */
8
- class NoincludeToken extends (0, hidden_1.hiddenToken)(base_1.NowikiBaseToken) {
9
- type = 'noinclude';
10
- /* NOT FOR BROWSER */
11
- /**
12
- * @override
13
- * @param str 新文本
14
- */
15
- setText(str) {
16
- if (/^<\/?(?:(?:no|only)include|includeonly)(?:\s[^>]*)?\/?>$/iu.test(this.innerText)) {
17
- this.constructorError('不可更改文字内容');
18
- }
19
- return super.setText(str);
20
- }
21
- }
22
- exports.NoincludeToken = NoincludeToken;
23
- constants_1.classes['NoincludeToken'] = __filename;
@@ -1,14 +0,0 @@
1
- import { NowikiBaseToken } from './base';
2
- import type { LintError, AST } from '../../base';
3
- /** `''`和`'''` */
4
- export declare abstract class QuoteToken extends NowikiBaseToken {
5
- readonly type = "quote";
6
- /** 是否粗体 */
7
- get bold(): boolean;
8
- /** 是否斜体 */
9
- get italic(): boolean;
10
- /** @override */
11
- lint(start?: number): LintError[];
12
- /** @override */
13
- json(): AST;
14
- }
@@ -1,131 +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.QuoteToken = void 0;
38
- const lint_1 = require("../../util/lint");
39
- const constants_1 = require("../../util/constants");
40
- const syntax_1 = require("../../mixin/syntax");
41
- const index_1 = require("../../index");
42
- const base_1 = require("./base");
43
- /** `''`和`'''` */
44
- let QuoteToken = (() => {
45
- let _classDecorators = [(0, syntax_1.syntax)(/^(?:'{5}|'''?)$/u)];
46
- let _classDescriptor;
47
- let _classExtraInitializers = [];
48
- let _classThis;
49
- let _classSuper = base_1.NowikiBaseToken;
50
- var QuoteToken = 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
- QuoteToken = _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 = 'quote';
60
- /** 是否粗体 */
61
- get bold() {
62
- return this.innerText.length !== 2;
63
- }
64
- /** 是否斜体 */
65
- get italic() {
66
- return this.innerText.length !== 3;
67
- }
68
- /** @override */
69
- lint(start = this.getAbsoluteIndex()) {
70
- const { previousSibling, nextSibling, bold } = this, message = index_1.default.msg('lonely "$1"', `'`), errors = [];
71
- let refError;
72
- if (previousSibling?.type === 'text' && previousSibling.data.endsWith(`'`)) {
73
- refError = (0, lint_1.generateForSelf)(this, { start }, 'lonely-apos', message);
74
- const { startIndex: endIndex, startLine: endLine, startCol: endCol } = refError, [, { length }] = /(?:^|[^'])('+)$/u.exec(previousSibling.data), startIndex = start - length;
75
- errors.push({
76
- ...refError,
77
- startIndex,
78
- endIndex,
79
- startCol: endCol - length,
80
- endLine,
81
- endCol,
82
- suggestions: [
83
- {
84
- desc: 'escape',
85
- range: [startIndex, endIndex],
86
- text: '&apos;'.repeat(length),
87
- },
88
- ],
89
- });
90
- }
91
- if (nextSibling?.type === 'text' && nextSibling.data.startsWith(`'`)) {
92
- refError ??= (0, lint_1.generateForSelf)(this, { start }, 'lonely-apos', message);
93
- const { endIndex: startIndex, endLine: startLine, endCol: startCol } = refError, [{ length }] = /^'+/u.exec(nextSibling.data), endIndex = startIndex + length;
94
- errors.push({
95
- ...refError,
96
- startIndex,
97
- endIndex,
98
- startLine,
99
- startCol,
100
- endCol: startCol + length,
101
- suggestions: [
102
- {
103
- desc: 'escape',
104
- range: [startIndex, endIndex],
105
- text: '&apos;'.repeat(length),
106
- },
107
- ],
108
- });
109
- }
110
- if (bold && this.closest('heading-title')) {
111
- refError ??= (0, lint_1.generateForSelf)(this, { start }, 'lonely-apos', message);
112
- errors.push({
113
- ...refError,
114
- rule: 'bold-header',
115
- message: index_1.default.msg('bold in section header'),
116
- severity: 'warning',
117
- });
118
- }
119
- return errors;
120
- }
121
- /** @override */
122
- json() {
123
- const json = super.json();
124
- Object.assign(json, { bold: this.bold, italic: this.italic });
125
- return json;
126
- }
127
- };
128
- return QuoteToken = _classThis;
129
- })();
130
- exports.QuoteToken = QuoteToken;
131
- constants_1.classes['QuoteToken'] = __filename;
@@ -1,16 +0,0 @@
1
- import { Token } from './index';
2
- /**
3
- * 嵌入时的`<onlyinclude>`
4
- * @classdesc `{childNodes: ...AstText|Token}`
5
- */
6
- export declare class OnlyincludeToken extends Token {
7
- readonly type = "onlyinclude";
8
- /** 内部wikitext */
9
- get innerText(): string;
10
- /** @throws `RangeError` 不允许包含`</onlyinclude>` */
11
- set innerText(text: string);
12
- /** @override */
13
- print(): string;
14
- /** @override */
15
- cloneNode(): this;
16
- }
@@ -1,57 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.OnlyincludeToken = void 0;
4
- const debug_1 = require("../util/debug");
5
- const constants_1 = require("../util/constants");
6
- const index_1 = require("../index");
7
- const index_2 = require("./index");
8
- /**
9
- * 嵌入时的`<onlyinclude>`
10
- * @classdesc `{childNodes: ...AstText|Token}`
11
- */
12
- class OnlyincludeToken extends index_2.Token {
13
- type = 'onlyinclude';
14
- /* NOT FOR BROWSER */
15
- /** 内部wikitext */
16
- get innerText() {
17
- return this.text();
18
- }
19
- /** @throws `RangeError` 不允许包含`</onlyinclude>` */
20
- set innerText(text) {
21
- if (text.includes('</onlyinclude>')) {
22
- throw new RangeError('不允许包含 "</onlyinclude>"!');
23
- }
24
- this.replaceChildren(...index_1.default.parse(text, true, undefined, this.getAttribute('config')).childNodes);
25
- }
26
- /* NOT FOR BROWSER END */
27
- /** @private */
28
- toString() {
29
- return `<onlyinclude>${super.toString()}</onlyinclude>`;
30
- }
31
- /** @private */
32
- getAttribute(key) {
33
- if (key === 'padding') {
34
- return 13;
35
- }
36
- return (key === 'plain') || super.getAttribute(key);
37
- }
38
- /** @override */
39
- print() {
40
- return super.print({
41
- pre: '<span class="wpb-ext">&lt;onlyinclude&gt;</span>',
42
- post: '<span class="wpb-ext">&lt;/onlyinclude&gt;</span>',
43
- });
44
- }
45
- /* NOT FOR BROWSER */
46
- /** @override */
47
- cloneNode() {
48
- const cloned = this.cloneChildNodes();
49
- return debug_1.Shadow.run(() => {
50
- const token = new OnlyincludeToken(undefined, this.getAttribute('config'));
51
- token.append(...cloned);
52
- return token;
53
- });
54
- }
55
- }
56
- exports.OnlyincludeToken = OnlyincludeToken;
57
- constants_1.classes['OnlyincludeToken'] = __filename;
@@ -1,37 +0,0 @@
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 type = "ext-inner";
12
- readonly name: string;
13
- readonly childNodes: readonly AtomToken[];
14
- abstract get firstChild(): AtomToken | undefined;
15
- abstract get lastChild(): AtomToken | undefined;
16
- abstract get nextSibling(): undefined;
17
- abstract get previousSibling(): AttributesToken;
18
- abstract get parentNode(): ExtToken | undefined;
19
- abstract get children(): AtomToken[];
20
- abstract get firstElementChild(): AtomToken | undefined;
21
- abstract get lastElementChild(): AtomToken | undefined;
22
- abstract get nextElementSibling(): undefined;
23
- abstract get previousElementSibling(): AttributesToken;
24
- abstract get parentElement(): ExtToken | undefined;
25
- /** @class */
26
- constructor(wikitext?: string, config?: Parser.Config, accum?: Token[], acceptable?: Acceptable);
27
- /** @override */
28
- text(): string;
29
- /** @override */
30
- lint(start?: number): LintError[];
31
- /** @override */
32
- print(): string;
33
- /** @override */
34
- cloneNode(this: this & {
35
- constructor: new (...args: any[]) => unknown;
36
- }): this;
37
- }
@@ -1,77 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ParamTagToken = void 0;
4
- const lint_1 = require("../../util/lint");
5
- const debug_1 = require("../../util/debug");
6
- const constants_1 = require("../../util/constants");
7
- const singleLine_1 = require("../../mixin/singleLine");
8
- const index_1 = require("../../index");
9
- const index_2 = require("../index");
10
- const atom_1 = require("../atom");
11
- /**
12
- * `<dynamicpagelist>`
13
- * @classdesc `{childNodes: ...AtomToken}`
14
- */
15
- class ParamTagToken extends index_2.Token {
16
- type = 'ext-inner';
17
- /* NOT FOR BROWSER END */
18
- /** @class */
19
- constructor(wikitext, config = index_1.default.getConfig(), accum = [], acceptable = {}) {
20
- super(undefined, config, accum, {
21
- AtomToken: ':',
22
- });
23
- if (wikitext) {
24
- const SingleLineAtomToken = (0, singleLine_1.singleLine)(atom_1.AtomToken);
25
- this.append(...wikitext.split('\n').map(line => new SingleLineAtomToken(line, 'param-line', config, accum, {
26
- AstText: ':', ...acceptable,
27
- })));
28
- }
29
- }
30
- /** @private */
31
- toString() {
32
- return super.toString('\n');
33
- }
34
- /** @override */
35
- text() {
36
- return super.text('\n');
37
- }
38
- /** @private */
39
- getGaps() {
40
- return 1;
41
- }
42
- /** @override */
43
- lint(start = this.getAbsoluteIndex()) {
44
- let rect;
45
- return this.childNodes.filter(child => {
46
- const { childNodes } = child, i = childNodes.findIndex(({ type }) => type !== 'text'), str = (i >= 0 ? childNodes.slice(0, i).map(String).join('') : String(child)).trim();
47
- return str && !(i >= 0 ? /^[a-z]+(?:\[\])?\s*(?:=|$)/iu : /^[a-z]+(?:\[\])?\s*=/iu).test(str);
48
- }).map(child => {
49
- rect ??= { start, ...this.getRootNode().posFromIndex(start) };
50
- const e = (0, lint_1.generateForChild)(child, rect, 'no-ignored', index_1.default.msg('invalid parameter of <$1>', this.name));
51
- e.suggestions = [
52
- {
53
- desc: 'remove',
54
- range: [e.startIndex, e.endIndex],
55
- text: '',
56
- },
57
- ];
58
- return e;
59
- });
60
- }
61
- /** @override */
62
- print() {
63
- return super.print({ sep: '\n' });
64
- }
65
- /* NOT FOR BROWSER */
66
- /** @override */
67
- cloneNode() {
68
- const cloned = this.cloneChildNodes();
69
- return debug_1.Shadow.run(() => {
70
- const token = new this.constructor(undefined, this.getAttribute('config'));
71
- token.append(...cloned);
72
- return token;
73
- });
74
- }
75
- }
76
- exports.ParamTagToken = ParamTagToken;
77
- constants_1.classes['ParamTagToken'] = __filename;
@@ -1,8 +0,0 @@
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
- }
@@ -1,22 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.InputboxToken = void 0;
4
- const constants_1 = require("../../util/constants");
5
- const braces_1 = require("../../parser/braces");
6
- const index_1 = require("../../index");
7
- const index_2 = require("./index");
8
- /** `<inputbox>` */
9
- class InputboxToken extends index_2.ParamTagToken {
10
- /** @class */
11
- constructor(wikitext, config = index_1.default.getConfig(), accum = []) {
12
- const placeholder = Symbol('InputboxToken');
13
- accum.push(placeholder);
14
- wikitext &&= (0, braces_1.parseBraces)(wikitext, config, accum);
15
- accum.splice(accum.indexOf(placeholder), 1);
16
- super(wikitext, config, accum, {
17
- ArgToken: ':', TranscludeToken: ':',
18
- });
19
- }
20
- }
21
- exports.InputboxToken = InputboxToken;
22
- constants_1.classes['InputboxToken'] = __filename;
@@ -1,70 +0,0 @@
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 type = "parameter";
11
- readonly name: string;
12
- readonly childNodes: readonly [Token, Token];
13
- abstract get firstChild(): Token;
14
- abstract get lastChild(): Token;
15
- abstract get parentNode(): TranscludeToken | undefined;
16
- abstract get nextSibling(): this | undefined;
17
- abstract get previousSibling(): AtomToken | SyntaxToken | this;
18
- abstract get children(): [Token, Token];
19
- abstract get firstElementChild(): Token;
20
- abstract get lastElementChild(): Token;
21
- abstract get parentElement(): TranscludeToken | undefined;
22
- abstract get nextElementSibling(): this | undefined;
23
- abstract get previousElementSibling(): AtomToken | SyntaxToken | this;
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
- /** @override */
39
- text(): string;
40
- /** @override */
41
- lint(start?: number, re?: RegExp): LintError[];
42
- /** @override */
43
- print(): string;
44
- /** @override */
45
- json(): AST;
46
- /** @override */
47
- cloneNode(): this;
48
- /**
49
- * @override
50
- * @param token 待替换的节点
51
- */
52
- safeReplaceWith(token: this): void;
53
- /** 获取参数值 */
54
- getValue(): string;
55
- /**
56
- * 设置参数值
57
- * @param value 参数值
58
- */
59
- setValue(value: string): void;
60
- /**
61
- * 修改参数名
62
- * @param key 新参数名
63
- * @param force 是否无视冲突命名
64
- * @throws `Error` 仅用于模板参数
65
- * @throws `RangeError` 更名造成重复参数
66
- */
67
- rename(key: string, force?: boolean): void;
68
- /** 转义 `=` */
69
- escape(): void;
70
- }