wikiparser-node 1.9.3-b → 1.9.3

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 (171) hide show
  1. package/config/.schema.json +181 -0
  2. package/config/enwiki.json +814 -1
  3. package/config/llwiki.json +35 -1
  4. package/config/moegirl.json +44 -1
  5. package/config/zhwiki.json +466 -1
  6. package/dist/addon/table.js +486 -0
  7. package/dist/addon/token.js +240 -0
  8. package/dist/addon/transclude.js +185 -0
  9. package/dist/base.d.ts +79 -0
  10. package/dist/base.js +39 -0
  11. package/dist/index.d.ts +31 -0
  12. package/dist/index.js +231 -0
  13. package/dist/internal.d.ts +46 -0
  14. package/dist/lib/element.d.ts +125 -0
  15. package/dist/lib/element.js +374 -0
  16. package/dist/lib/node.d.ts +168 -0
  17. package/dist/lib/node.js +472 -0
  18. package/dist/lib/range.d.ts +105 -0
  19. package/dist/lib/range.js +406 -0
  20. package/dist/lib/ranges.d.ts +28 -0
  21. package/dist/lib/ranges.js +126 -0
  22. package/dist/lib/rect.d.ts +18 -0
  23. package/dist/lib/rect.js +34 -0
  24. package/dist/lib/text.d.ts +55 -0
  25. package/dist/lib/text.js +351 -0
  26. package/dist/lib/title.d.ts +40 -0
  27. package/dist/lib/title.js +197 -0
  28. package/dist/mixin/attributesParent.d.ts +49 -0
  29. package/dist/mixin/attributesParent.js +82 -0
  30. package/dist/mixin/fixed.d.ts +5 -0
  31. package/dist/mixin/fixed.js +32 -0
  32. package/dist/mixin/flagsParent.d.ts +41 -0
  33. package/dist/mixin/flagsParent.js +60 -0
  34. package/dist/mixin/hidden.d.ts +6 -0
  35. package/dist/mixin/hidden.js +34 -0
  36. package/dist/mixin/magicLinkParent.d.ts +19 -0
  37. package/dist/mixin/magicLinkParent.js +43 -0
  38. package/dist/mixin/singleLine.d.ts +5 -0
  39. package/dist/mixin/singleLine.js +27 -0
  40. package/dist/mixin/sol.d.ts +5 -0
  41. package/dist/mixin/sol.js +44 -0
  42. package/dist/mixin/syntax.d.ts +8 -0
  43. package/dist/mixin/syntax.js +48 -0
  44. package/dist/parser/braces.js +150 -0
  45. package/dist/parser/commentAndExt.js +79 -0
  46. package/dist/parser/converter.js +39 -0
  47. package/dist/parser/externalLinks.js +37 -0
  48. package/dist/parser/hrAndDoubleUnderscore.js +42 -0
  49. package/dist/parser/html.js +38 -0
  50. package/dist/parser/links.js +101 -0
  51. package/dist/parser/list.js +97 -0
  52. package/dist/parser/magicLinks.js +53 -0
  53. package/dist/parser/quotes.js +67 -0
  54. package/dist/parser/redirect.js +26 -0
  55. package/dist/parser/selector.js +393 -0
  56. package/dist/parser/table.js +123 -0
  57. package/dist/src/arg.d.ts +51 -0
  58. package/dist/src/arg.js +214 -0
  59. package/dist/src/atom.d.ts +14 -0
  60. package/dist/src/atom.js +52 -0
  61. package/dist/src/attribute.d.ts +64 -0
  62. package/dist/src/attribute.js +486 -0
  63. package/dist/src/attributes.d.ts +102 -0
  64. package/dist/src/attributes.js +355 -0
  65. package/dist/src/converter.d.ts +28 -0
  66. package/dist/src/converter.js +137 -0
  67. package/dist/src/converterFlags.d.ts +80 -0
  68. package/dist/src/converterFlags.js +242 -0
  69. package/dist/src/converterRule.d.ts +71 -0
  70. package/dist/src/converterRule.js +212 -0
  71. package/dist/src/extLink.d.ts +36 -0
  72. package/dist/src/extLink.js +194 -0
  73. package/dist/src/gallery.d.ts +47 -0
  74. package/dist/src/gallery.js +142 -0
  75. package/dist/src/heading.d.ts +40 -0
  76. package/dist/src/heading.js +186 -0
  77. package/dist/src/hidden.d.ts +9 -0
  78. package/dist/src/hidden.js +80 -0
  79. package/dist/src/html.d.ts +57 -0
  80. package/dist/src/html.js +335 -0
  81. package/dist/src/imageParameter.d.ts +58 -0
  82. package/dist/src/imageParameter.js +247 -0
  83. package/dist/src/imagemap.d.ts +47 -0
  84. package/dist/src/imagemap.js +146 -0
  85. package/dist/src/imagemapLink.d.ts +31 -0
  86. package/dist/src/imagemapLink.js +97 -0
  87. package/dist/src/index.d.ts +131 -0
  88. package/dist/src/index.js +746 -0
  89. package/dist/src/link/base.d.ts +45 -0
  90. package/dist/src/link/base.js +226 -0
  91. package/dist/src/link/category.d.ts +22 -0
  92. package/dist/src/link/category.js +34 -0
  93. package/dist/src/link/file.d.ts +96 -0
  94. package/dist/src/link/file.js +276 -0
  95. package/dist/src/link/galleryImage.d.ts +29 -0
  96. package/dist/src/link/galleryImage.js +132 -0
  97. package/dist/src/link/index.d.ts +51 -0
  98. package/dist/src/link/index.js +136 -0
  99. package/dist/src/link/redirectTarget.d.ts +36 -0
  100. package/dist/src/link/redirectTarget.js +98 -0
  101. package/dist/src/magicLink.d.ts +60 -0
  102. package/dist/src/magicLink.js +273 -0
  103. package/dist/src/nested.d.ts +40 -0
  104. package/dist/src/nested.js +106 -0
  105. package/dist/src/nowiki/base.d.ts +30 -0
  106. package/dist/src/nowiki/base.js +89 -0
  107. package/dist/src/nowiki/comment.d.ts +14 -0
  108. package/dist/src/nowiki/comment.js +124 -0
  109. package/dist/src/nowiki/dd.d.ts +8 -0
  110. package/dist/src/nowiki/dd.js +26 -0
  111. package/dist/src/nowiki/doubleUnderscore.d.ts +15 -0
  112. package/dist/src/nowiki/doubleUnderscore.js +97 -0
  113. package/dist/src/nowiki/hr.d.ts +5 -0
  114. package/dist/src/nowiki/hr.js +65 -0
  115. package/dist/src/nowiki/index.d.ts +14 -0
  116. package/dist/src/nowiki/index.js +31 -0
  117. package/dist/src/nowiki/list.d.ts +16 -0
  118. package/dist/src/nowiki/list.js +111 -0
  119. package/dist/src/nowiki/listBase.d.ts +5 -0
  120. package/dist/src/nowiki/listBase.js +61 -0
  121. package/dist/src/nowiki/noinclude.d.ts +6 -0
  122. package/dist/src/nowiki/noinclude.js +71 -0
  123. package/dist/src/nowiki/quote.d.ts +14 -0
  124. package/dist/src/nowiki/quote.js +130 -0
  125. package/dist/src/onlyinclude.d.ts +13 -0
  126. package/dist/src/onlyinclude.js +58 -0
  127. package/dist/src/paramTag/index.d.ts +30 -0
  128. package/dist/src/paramTag/index.js +78 -0
  129. package/dist/src/paramTag/inputbox.d.ts +8 -0
  130. package/dist/src/paramTag/inputbox.js +22 -0
  131. package/dist/src/parameter.d.ts +60 -0
  132. package/dist/src/parameter.js +261 -0
  133. package/dist/src/pre.d.ts +28 -0
  134. package/dist/src/pre.js +60 -0
  135. package/dist/src/redirect.d.ts +30 -0
  136. package/dist/src/redirect.js +122 -0
  137. package/dist/src/syntax.d.ts +17 -0
  138. package/dist/src/syntax.js +87 -0
  139. package/dist/src/table/base.d.ts +28 -0
  140. package/dist/src/table/base.js +81 -0
  141. package/dist/src/table/index.d.ts +230 -0
  142. package/dist/src/table/index.js +495 -0
  143. package/dist/src/table/td.d.ts +72 -0
  144. package/dist/src/table/td.js +364 -0
  145. package/dist/src/table/tr.d.ts +30 -0
  146. package/dist/src/table/tr.js +59 -0
  147. package/dist/src/table/trBase.d.ts +49 -0
  148. package/dist/src/table/trBase.js +156 -0
  149. package/dist/src/tagPair/ext.d.ts +29 -0
  150. package/dist/src/tagPair/ext.js +204 -0
  151. package/dist/src/tagPair/include.d.ts +33 -0
  152. package/dist/src/tagPair/include.js +126 -0
  153. package/dist/src/tagPair/index.d.ts +23 -0
  154. package/dist/src/tagPair/index.js +128 -0
  155. package/dist/src/transclude.d.ts +159 -0
  156. package/dist/src/transclude.js +582 -0
  157. package/dist/util/constants.js +25 -0
  158. package/dist/util/debug.js +95 -0
  159. package/dist/util/diff.js +83 -0
  160. package/dist/util/lint.js +32 -0
  161. package/dist/util/string.js +60 -0
  162. package/errors/README +1 -0
  163. package/package.json +22 -32
  164. package/printed/README +1 -0
  165. package/bundle/bundle.min.js +0 -39
  166. package/extensions/dist/base.js +0 -64
  167. package/extensions/dist/editor.js +0 -159
  168. package/extensions/dist/highlight.js +0 -58
  169. package/extensions/dist/lint.js +0 -72
  170. package/extensions/editor.css +0 -64
  171. package/extensions/ui.css +0 -144
@@ -0,0 +1,89 @@
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.NowikiBaseToken = void 0;
38
+ const debug_1 = require("../../util/debug");
39
+ const constants_1 = require("../../util/constants");
40
+ const fixed_1 = require("../../mixin/fixed");
41
+ const index_1 = require("../index");
42
+ /**
43
+ * 纯文字Token,不会被解析
44
+ * @classdesc `{childNodes: [AstText]}`
45
+ */
46
+ let NowikiBaseToken = (() => {
47
+ let _classDecorators = [fixed_1.fixedToken];
48
+ let _classDescriptor;
49
+ let _classExtraInitializers = [];
50
+ let _classThis;
51
+ let _classSuper = index_1.Token;
52
+ var NowikiBaseToken = class extends _classSuper {
53
+ static { _classThis = this; }
54
+ static {
55
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
56
+ __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
57
+ NowikiBaseToken = _classThis = _classDescriptor.value;
58
+ if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
59
+ __runInitializers(_classThis, _classExtraInitializers);
60
+ }
61
+ /* NOT FOR BROWSER END */
62
+ /** 纯文本部分 */
63
+ get innerText() {
64
+ return this.firstChild.data;
65
+ }
66
+ /** @param wikitext default: `''` */
67
+ constructor(wikitext = '', config, accum) {
68
+ super(wikitext, config, accum);
69
+ }
70
+ /* NOT FOR BROWSER */
71
+ cloneNode() {
72
+ const { constructor, firstChild: { data } } = this;
73
+ return debug_1.Shadow.run(() => {
74
+ const token = new constructor(data, this.getAttribute('config'));
75
+ return token;
76
+ });
77
+ }
78
+ /**
79
+ * @override
80
+ * @param str 新文本
81
+ */
82
+ setText(str) {
83
+ return super.setText(str, 0);
84
+ }
85
+ };
86
+ return NowikiBaseToken = _classThis;
87
+ })();
88
+ exports.NowikiBaseToken = NowikiBaseToken;
89
+ constants_1.classes['NowikiBaseToken'] = __filename;
@@ -0,0 +1,14 @@
1
+ import { NowikiBaseToken } from './base';
2
+ import type { LintError, Config } from '../../base';
3
+ import type { Token } from '../index';
4
+ /** HTML注释,不可见 */
5
+ export declare abstract class CommentToken extends NowikiBaseToken {
6
+ closed: boolean;
7
+ get type(): 'comment';
8
+ /** 内部文本 */
9
+ get innerText(): string;
10
+ set innerText(text: string);
11
+ /** @param closed 是否闭合 */
12
+ constructor(wikitext: string, closed?: boolean, config?: Config, accum?: Token[]);
13
+ cloneNode(): this;
14
+ }
@@ -0,0 +1,124 @@
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.CommentToken = void 0;
38
+ const lint_1 = require("../../util/lint");
39
+ const debug_1 = require("../../util/debug");
40
+ const constants_1 = require("../../util/constants");
41
+ const hidden_1 = require("../../mixin/hidden");
42
+ const index_1 = require("../../index");
43
+ const base_1 = require("./base");
44
+ /** HTML注释,不可见 */
45
+ let CommentToken = (() => {
46
+ let _classDecorators = [(0, hidden_1.hiddenToken)()];
47
+ let _classDescriptor;
48
+ let _classExtraInitializers = [];
49
+ let _classThis;
50
+ let _classSuper = base_1.NowikiBaseToken;
51
+ var CommentToken = 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
+ CommentToken = _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
+ closed;
61
+ get type() {
62
+ return 'comment';
63
+ }
64
+ /* NOT FOR BROWSER */
65
+ /** 内部文本 */
66
+ get innerText() {
67
+ return super.innerText;
68
+ }
69
+ set innerText(text) {
70
+ this.setText(text);
71
+ }
72
+ /* NOT FOR BROWSER END */
73
+ /** @param closed 是否闭合 */
74
+ constructor(wikitext, closed = true, config, accum) {
75
+ super(wikitext, config, accum);
76
+ this.closed = closed;
77
+ }
78
+ /** @private */
79
+ getAttribute(key) {
80
+ return key === 'padding' ? 4 : super.getAttribute(key);
81
+ }
82
+ /** @private */
83
+ lint(start = this.getAbsoluteIndex()) {
84
+ if (this.closed) {
85
+ return [];
86
+ }
87
+ const e = (0, lint_1.generateForSelf)(this, { start }, 'unclosed-comment', index_1.default.msg('unclosed $1', 'HTML comment'));
88
+ e.fix = {
89
+ range: [e.endIndex, e.endIndex],
90
+ text: '-->',
91
+ };
92
+ return [e];
93
+ }
94
+ /** @private */
95
+ toString() {
96
+ /* NOT FOR BROWSER */
97
+ if (!this.closed && this.nextSibling) {
98
+ index_1.default.error('Auto-closing HTML comment', this);
99
+ this.closed = true;
100
+ }
101
+ /* NOT FOR BROWSER END */
102
+ return `<!--${this.innerText}${this.closed ? '-->' : ''}`;
103
+ }
104
+ /** @private */
105
+ print() {
106
+ return super.print({ pre: '&lt;!--', post: this.closed ? '--&gt;' : '' });
107
+ }
108
+ /* NOT FOR BROWSER */
109
+ cloneNode() {
110
+ // @ts-expect-error abstract class
111
+ return debug_1.Shadow.run(() => new CommentToken(this.innerText, this.closed, this.getAttribute('config')));
112
+ }
113
+ /** @private */
114
+ setText(text) {
115
+ if (text.includes('-->')) {
116
+ throw new RangeError('Do not contain "-->" in the comment!');
117
+ }
118
+ return super.setText(text);
119
+ }
120
+ };
121
+ return CommentToken = _classThis;
122
+ })();
123
+ exports.CommentToken = CommentToken;
124
+ constants_1.classes['CommentToken'] = __filename;
@@ -0,0 +1,8 @@
1
+ import { ListBaseToken } from './listBase';
2
+ /** `:` */
3
+ export declare abstract class DdToken extends ListBaseToken {
4
+ get type(): 'dd';
5
+ /** 缩进数 */
6
+ get indent(): number;
7
+ set indent(indent: number);
8
+ }
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DdToken = void 0;
4
+ const constants_1 = require("../../util/constants");
5
+ const listBase_1 = require("./listBase");
6
+ /** `:` */
7
+ class DdToken extends listBase_1.ListBaseToken {
8
+ get type() {
9
+ return 'dd';
10
+ }
11
+ /* NOT FOR BROWSER */
12
+ /** 缩进数 */
13
+ get indent() {
14
+ return this.innerText.length;
15
+ }
16
+ set indent(indent) {
17
+ this.setText(':'.repeat(indent));
18
+ }
19
+ /** @private */
20
+ afterBuild() {
21
+ this.setAttribute('pattern', /^:+$/u);
22
+ super.afterBuild();
23
+ }
24
+ }
25
+ exports.DdToken = DdToken;
26
+ constants_1.classes['DdToken'] = __filename;
@@ -0,0 +1,15 @@
1
+ import { NowikiBaseToken } from './base';
2
+ import type { Config } from '../../base';
3
+ import type { Token } from '../index';
4
+ /** 状态开关 */
5
+ export declare abstract class DoubleUnderscoreToken extends NowikiBaseToken {
6
+ #private;
7
+ readonly name: string;
8
+ get type(): 'double-underscore';
9
+ /**
10
+ * @param word 状态开关名
11
+ * @param sensitive 是否固定大小写
12
+ */
13
+ constructor(word: string, sensitive: boolean, config?: Config, accum?: Token[]);
14
+ cloneNode(): this;
15
+ }
@@ -0,0 +1,97 @@
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.DoubleUnderscoreToken = void 0;
38
+ const debug_1 = require("../../util/debug");
39
+ const constants_1 = require("../../util/constants");
40
+ const hidden_1 = require("../../mixin/hidden");
41
+ const syntax_1 = require("../../mixin/syntax");
42
+ const base_1 = require("./base");
43
+ /** 状态开关 */
44
+ let DoubleUnderscoreToken = (() => {
45
+ let _classDecorators = [(0, syntax_1.syntax)(), (0, hidden_1.hiddenToken)(true)];
46
+ let _classDescriptor;
47
+ let _classExtraInitializers = [];
48
+ let _classThis;
49
+ let _classSuper = base_1.NowikiBaseToken;
50
+ var DoubleUnderscoreToken = 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
+ DoubleUnderscoreToken = _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
+ #sensitive;
60
+ /* NOT FOR BROWSER END */
61
+ get type() {
62
+ return 'double-underscore';
63
+ }
64
+ /**
65
+ * @param word 状态开关名
66
+ * @param sensitive 是否固定大小写
67
+ */
68
+ constructor(word, sensitive, config, accum) {
69
+ super(word, config, accum);
70
+ /* NOT FOR BROWSER */
71
+ this.#sensitive = sensitive;
72
+ this.setAttribute('name', word.toLowerCase());
73
+ this.setAttribute('pattern', new RegExp(`^${word}$`, sensitive ? 'u' : 'iu'));
74
+ }
75
+ /** @private */
76
+ getAttribute(key) {
77
+ return key === 'padding' ? 2 : super.getAttribute(key);
78
+ }
79
+ /** @private */
80
+ toString() {
81
+ return `__${this.innerText}__`;
82
+ }
83
+ /** @private */
84
+ print() {
85
+ return super.print({ pre: '__', post: '__' });
86
+ }
87
+ /* NOT FOR BROWSER */
88
+ cloneNode() {
89
+ const config = this.getAttribute('config');
90
+ // @ts-expect-error abstract class
91
+ return debug_1.Shadow.run(() => new DoubleUnderscoreToken(this.innerText, this.#sensitive, config));
92
+ }
93
+ };
94
+ return DoubleUnderscoreToken = _classThis;
95
+ })();
96
+ exports.DoubleUnderscoreToken = DoubleUnderscoreToken;
97
+ constants_1.classes['DoubleUnderscoreToken'] = __filename;
@@ -0,0 +1,5 @@
1
+ import { NowikiBaseToken } from './base';
2
+ /** `<hr>` */
3
+ export declare abstract class HrToken extends NowikiBaseToken {
4
+ get type(): 'hr';
5
+ }
@@ -0,0 +1,65 @@
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.HrToken = void 0;
38
+ const constants_1 = require("../../util/constants");
39
+ const sol_1 = require("../../mixin/sol");
40
+ const syntax_1 = require("../../mixin/syntax");
41
+ const base_1 = require("./base");
42
+ /** `<hr>` */
43
+ let HrToken = (() => {
44
+ let _classDecorators = [sol_1.sol, (0, syntax_1.syntax)(/^-{4,}$/u)];
45
+ let _classDescriptor;
46
+ let _classExtraInitializers = [];
47
+ let _classThis;
48
+ let _classSuper = base_1.NowikiBaseToken;
49
+ var HrToken = class extends _classSuper {
50
+ static { _classThis = this; }
51
+ static {
52
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
53
+ __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
54
+ HrToken = _classThis = _classDescriptor.value;
55
+ if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
56
+ __runInitializers(_classThis, _classExtraInitializers);
57
+ }
58
+ get type() {
59
+ return 'hr';
60
+ }
61
+ };
62
+ return HrToken = _classThis;
63
+ })();
64
+ exports.HrToken = HrToken;
65
+ constants_1.classes['HrToken'] = __filename;
@@ -0,0 +1,14 @@
1
+ import { NowikiBaseToken } from './base';
2
+ import type { LintError } from '../../base';
3
+ import type { AttributesToken, ExtToken } from '../../internal';
4
+ /** 扩展标签内的纯文字Token */
5
+ export declare abstract class NowikiToken extends NowikiBaseToken {
6
+ readonly name: string;
7
+ abstract get nextSibling(): undefined;
8
+ abstract get previousSibling(): AttributesToken;
9
+ abstract get parentNode(): ExtToken | undefined;
10
+ abstract get nextElementSibling(): undefined;
11
+ abstract get previousElementSibling(): AttributesToken;
12
+ abstract get parentElement(): ExtToken | undefined;
13
+ get type(): 'ext-inner';
14
+ }
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NowikiToken = void 0;
4
+ const lint_1 = require("../../util/lint");
5
+ const constants_1 = require("../../util/constants");
6
+ const index_1 = require("../../index");
7
+ const base_1 = require("./base");
8
+ /** 扩展标签内的纯文字Token */
9
+ class NowikiToken extends base_1.NowikiBaseToken {
10
+ /* NOT FOR BROWSER END */
11
+ get type() {
12
+ return 'ext-inner';
13
+ }
14
+ /** @private */
15
+ lint(start = this.getAbsoluteIndex()) {
16
+ const { name, firstChild: { data } } = this;
17
+ if ((name === 'templatestyles' || name === 'section') && data) {
18
+ const e = (0, lint_1.generateForSelf)(this, { start }, 'void-ext', index_1.default.msg('nothing should be in <$1>', name));
19
+ e.fix = {
20
+ range: [start - 1, e.endIndex + name.length + 3],
21
+ text: '/>',
22
+ };
23
+ return [e];
24
+ }
25
+ // eslint-disable-next-line @typescript-eslint/no-unused-expressions
26
+ /<\s*(?:\/\s*)?(nowiki)\b/giu;
27
+ return super.lint(start, new RegExp(String.raw `<\s*(?:/\s*)${name === 'nowiki' ? '' : '?'}(${name})\b`, 'giu'));
28
+ }
29
+ }
30
+ exports.NowikiToken = NowikiToken;
31
+ constants_1.classes['NowikiToken'] = __filename;
@@ -0,0 +1,16 @@
1
+ import { ListBaseToken } from './listBase';
2
+ import type { AstRange } from '../../lib/range';
3
+ /** 位于行首的`;:*#` */
4
+ export declare abstract class ListToken extends ListBaseToken {
5
+ get type(): 'list';
6
+ /** 是否包含`:` */
7
+ get dd(): boolean;
8
+ /** 是否包含`;` */
9
+ get dt(): boolean;
10
+ /** 是否包含`*` */
11
+ get ul(): boolean;
12
+ /** 是否包含`#` */
13
+ get ol(): boolean;
14
+ /** 获取列表行的范围 */
15
+ getRange(): AstRange;
16
+ }
@@ -0,0 +1,111 @@
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
+ get type() {
58
+ return 'list';
59
+ }
60
+ /* NOT FOR BROWSER */
61
+ /** 是否包含`:` */
62
+ get dd() {
63
+ return this.innerText.includes(':');
64
+ }
65
+ /** 是否包含`;` */
66
+ get dt() {
67
+ return this.innerText.includes(';');
68
+ }
69
+ /** 是否包含`*` */
70
+ get ul() {
71
+ return this.innerText.includes('*');
72
+ }
73
+ /** 是否包含`#` */
74
+ get ol() {
75
+ return this.innerText.includes('#');
76
+ }
77
+ /** 获取列表行的范围 */
78
+ getRange() {
79
+ const range = this.createRange();
80
+ let nDt = this.dt ? this.innerText.split(';').length - 2 : 0;
81
+ range.setStartBefore(this);
82
+ let { nextSibling } = this;
83
+ while (nextSibling && (nextSibling.type !== 'text' || !nextSibling.data.includes('\n'))) {
84
+ if (nextSibling.type === 'dd') {
85
+ nDt -= nextSibling.indent;
86
+ }
87
+ if (nDt < 0) {
88
+ break;
89
+ }
90
+ ({ nextSibling } = nextSibling);
91
+ }
92
+ if (nextSibling) {
93
+ if (nDt < 0) {
94
+ range.setEndBefore(nextSibling);
95
+ }
96
+ else {
97
+ const i = nextSibling.data.indexOf('\n');
98
+ range.setEnd(nextSibling, i);
99
+ }
100
+ }
101
+ else {
102
+ const { parentNode } = this;
103
+ range.setEnd(parentNode, parentNode.length);
104
+ }
105
+ return range;
106
+ }
107
+ };
108
+ return ListToken = _classThis;
109
+ })();
110
+ exports.ListToken = ListToken;
111
+ constants_1.classes['ListToken'] = __filename;
@@ -0,0 +1,5 @@
1
+ import { NowikiBaseToken } from './base';
2
+ /** `;:*#` */
3
+ export declare abstract class ListBaseToken extends NowikiBaseToken {
4
+ abstract get type(): 'dd' | 'list';
5
+ }