wikiparser-node 1.11.0 → 1.11.1-b

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (172) hide show
  1. package/bundle/bundle.min.js +38 -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 +56 -0
  9. package/extensions/dist/lint.js +72 -0
  10. package/extensions/editor.css +64 -0
  11. package/extensions/ui.css +144 -0
  12. package/package.json +28 -35
  13. package/config/.schema.json +0 -186
  14. package/dist/addon/table.js +0 -486
  15. package/dist/addon/token.js +0 -304
  16. package/dist/addon/transclude.js +0 -184
  17. package/dist/base.d.ts +0 -81
  18. package/dist/base.js +0 -39
  19. package/dist/index.d.ts +0 -33
  20. package/dist/index.js +0 -235
  21. package/dist/internal.d.ts +0 -46
  22. package/dist/lib/element.d.ts +0 -125
  23. package/dist/lib/element.js +0 -375
  24. package/dist/lib/node.d.ts +0 -173
  25. package/dist/lib/node.js +0 -478
  26. package/dist/lib/range.d.ts +0 -105
  27. package/dist/lib/range.js +0 -406
  28. package/dist/lib/ranges.d.ts +0 -28
  29. package/dist/lib/ranges.js +0 -126
  30. package/dist/lib/rect.d.ts +0 -18
  31. package/dist/lib/rect.js +0 -34
  32. package/dist/lib/text.d.ts +0 -58
  33. package/dist/lib/text.js +0 -400
  34. package/dist/lib/title.d.ts +0 -42
  35. package/dist/lib/title.js +0 -208
  36. package/dist/mixin/attributesParent.d.ts +0 -49
  37. package/dist/mixin/attributesParent.js +0 -79
  38. package/dist/mixin/fixed.d.ts +0 -5
  39. package/dist/mixin/fixed.js +0 -32
  40. package/dist/mixin/flagsParent.d.ts +0 -43
  41. package/dist/mixin/flagsParent.js +0 -64
  42. package/dist/mixin/hidden.d.ts +0 -7
  43. package/dist/mixin/hidden.js +0 -37
  44. package/dist/mixin/magicLinkParent.d.ts +0 -19
  45. package/dist/mixin/magicLinkParent.js +0 -43
  46. package/dist/mixin/singleLine.d.ts +0 -5
  47. package/dist/mixin/singleLine.js +0 -25
  48. package/dist/mixin/sol.d.ts +0 -6
  49. package/dist/mixin/sol.js +0 -45
  50. package/dist/mixin/syntax.d.ts +0 -8
  51. package/dist/mixin/syntax.js +0 -46
  52. package/dist/parser/braces.js +0 -150
  53. package/dist/parser/commentAndExt.js +0 -79
  54. package/dist/parser/converter.js +0 -39
  55. package/dist/parser/externalLinks.js +0 -37
  56. package/dist/parser/hrAndDoubleUnderscore.js +0 -42
  57. package/dist/parser/html.js +0 -38
  58. package/dist/parser/links.js +0 -101
  59. package/dist/parser/list.js +0 -114
  60. package/dist/parser/magicLinks.js +0 -52
  61. package/dist/parser/quotes.js +0 -67
  62. package/dist/parser/redirect.js +0 -26
  63. package/dist/parser/selector.js +0 -394
  64. package/dist/parser/table.js +0 -123
  65. package/dist/src/arg.d.ts +0 -51
  66. package/dist/src/arg.js +0 -214
  67. package/dist/src/atom.d.ts +0 -14
  68. package/dist/src/atom.js +0 -52
  69. package/dist/src/attribute.d.ts +0 -64
  70. package/dist/src/attribute.js +0 -480
  71. package/dist/src/attributes.d.ts +0 -101
  72. package/dist/src/attributes.js +0 -381
  73. package/dist/src/converter.d.ts +0 -28
  74. package/dist/src/converter.js +0 -148
  75. package/dist/src/converterFlags.d.ts +0 -80
  76. package/dist/src/converterFlags.js +0 -239
  77. package/dist/src/converterRule.d.ts +0 -71
  78. package/dist/src/converterRule.js +0 -216
  79. package/dist/src/extLink.d.ts +0 -36
  80. package/dist/src/extLink.js +0 -218
  81. package/dist/src/gallery.d.ts +0 -47
  82. package/dist/src/gallery.js +0 -143
  83. package/dist/src/heading.d.ts +0 -40
  84. package/dist/src/heading.js +0 -192
  85. package/dist/src/hidden.d.ts +0 -9
  86. package/dist/src/hidden.js +0 -80
  87. package/dist/src/html.d.ts +0 -61
  88. package/dist/src/html.js +0 -343
  89. package/dist/src/imageParameter.d.ts +0 -60
  90. package/dist/src/imageParameter.js +0 -260
  91. package/dist/src/imagemap.d.ts +0 -47
  92. package/dist/src/imagemap.js +0 -146
  93. package/dist/src/imagemapLink.d.ts +0 -31
  94. package/dist/src/imagemapLink.js +0 -97
  95. package/dist/src/index.d.ts +0 -136
  96. package/dist/src/index.js +0 -834
  97. package/dist/src/link/base.d.ts +0 -52
  98. package/dist/src/link/base.js +0 -256
  99. package/dist/src/link/category.d.ts +0 -22
  100. package/dist/src/link/category.js +0 -34
  101. package/dist/src/link/file.d.ts +0 -102
  102. package/dist/src/link/file.js +0 -333
  103. package/dist/src/link/galleryImage.d.ts +0 -29
  104. package/dist/src/link/galleryImage.js +0 -132
  105. package/dist/src/link/index.d.ts +0 -39
  106. package/dist/src/link/index.js +0 -98
  107. package/dist/src/link/redirectTarget.d.ts +0 -27
  108. package/dist/src/link/redirectTarget.js +0 -69
  109. package/dist/src/magicLink.d.ts +0 -58
  110. package/dist/src/magicLink.js +0 -256
  111. package/dist/src/nested.d.ts +0 -40
  112. package/dist/src/nested.js +0 -106
  113. package/dist/src/nowiki/base.d.ts +0 -28
  114. package/dist/src/nowiki/base.js +0 -89
  115. package/dist/src/nowiki/comment.d.ts +0 -14
  116. package/dist/src/nowiki/comment.js +0 -121
  117. package/dist/src/nowiki/dd.d.ts +0 -8
  118. package/dist/src/nowiki/dd.js +0 -72
  119. package/dist/src/nowiki/doubleUnderscore.d.ts +0 -15
  120. package/dist/src/nowiki/doubleUnderscore.js +0 -97
  121. package/dist/src/nowiki/hr.d.ts +0 -5
  122. package/dist/src/nowiki/hr.js +0 -70
  123. package/dist/src/nowiki/index.d.ts +0 -14
  124. package/dist/src/nowiki/index.js +0 -28
  125. package/dist/src/nowiki/list.d.ts +0 -5
  126. package/dist/src/nowiki/list.js +0 -65
  127. package/dist/src/nowiki/listBase.d.ts +0 -23
  128. package/dist/src/nowiki/listBase.js +0 -99
  129. package/dist/src/nowiki/noinclude.d.ts +0 -6
  130. package/dist/src/nowiki/noinclude.js +0 -75
  131. package/dist/src/nowiki/quote.d.ts +0 -14
  132. package/dist/src/nowiki/quote.js +0 -140
  133. package/dist/src/onlyinclude.d.ts +0 -13
  134. package/dist/src/onlyinclude.js +0 -58
  135. package/dist/src/paramTag/index.d.ts +0 -28
  136. package/dist/src/paramTag/index.js +0 -78
  137. package/dist/src/paramTag/inputbox.d.ts +0 -8
  138. package/dist/src/paramTag/inputbox.js +0 -22
  139. package/dist/src/parameter.d.ts +0 -60
  140. package/dist/src/parameter.js +0 -264
  141. package/dist/src/pre.d.ts +0 -28
  142. package/dist/src/pre.js +0 -60
  143. package/dist/src/redirect.d.ts +0 -30
  144. package/dist/src/redirect.js +0 -126
  145. package/dist/src/syntax.d.ts +0 -17
  146. package/dist/src/syntax.js +0 -87
  147. package/dist/src/table/base.d.ts +0 -28
  148. package/dist/src/table/base.js +0 -81
  149. package/dist/src/table/index.d.ts +0 -230
  150. package/dist/src/table/index.js +0 -506
  151. package/dist/src/table/td.d.ts +0 -72
  152. package/dist/src/table/td.js +0 -370
  153. package/dist/src/table/tr.d.ts +0 -30
  154. package/dist/src/table/tr.js +0 -59
  155. package/dist/src/table/trBase.d.ts +0 -49
  156. package/dist/src/table/trBase.js +0 -164
  157. package/dist/src/tagPair/ext.d.ts +0 -29
  158. package/dist/src/tagPair/ext.js +0 -220
  159. package/dist/src/tagPair/include.d.ts +0 -33
  160. package/dist/src/tagPair/include.js +0 -130
  161. package/dist/src/tagPair/index.d.ts +0 -23
  162. package/dist/src/tagPair/index.js +0 -128
  163. package/dist/src/transclude.d.ts +0 -159
  164. package/dist/src/transclude.js +0 -587
  165. package/dist/util/constants.js +0 -25
  166. package/dist/util/debug.js +0 -95
  167. package/dist/util/diff.js +0 -83
  168. package/dist/util/html.js +0 -143
  169. package/dist/util/lint.js +0 -32
  170. package/dist/util/string.js +0 -87
  171. package/errors/README +0 -3
  172. package/printed/README +0 -3
@@ -1,121 +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.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)(false)];
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 = { range: [e.endIndex, e.endIndex], text: '-->' };
89
- return [e];
90
- }
91
- /** @private */
92
- toString(skip) {
93
- /* NOT FOR BROWSER */
94
- if (!this.closed && this.nextSibling) {
95
- index_1.default.error('Auto-closing HTML comment', this);
96
- this.closed = true;
97
- }
98
- /* NOT FOR BROWSER END */
99
- return skip ? '' : `<!--${this.innerText}${this.closed ? '-->' : ''}`;
100
- }
101
- /** @private */
102
- print() {
103
- return super.print({ pre: '&lt;!--', post: this.closed ? '--&gt;' : '' });
104
- }
105
- /* NOT FOR BROWSER */
106
- cloneNode() {
107
- // @ts-expect-error abstract class
108
- return debug_1.Shadow.run(() => new CommentToken(this.innerText, this.closed, this.getAttribute('config')));
109
- }
110
- /** @private */
111
- setText(text) {
112
- if (text.includes('-->')) {
113
- throw new RangeError('Do not contain "-->" in the comment!');
114
- }
115
- return super.setText(text);
116
- }
117
- };
118
- return CommentToken = _classThis;
119
- })();
120
- exports.CommentToken = CommentToken;
121
- constants_1.classes['CommentToken'] = __filename;
@@ -1,8 +0,0 @@
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
- }
@@ -1,72 +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.DdToken = void 0;
38
- const constants_1 = require("../../util/constants");
39
- const syntax_1 = require("../../mixin/syntax");
40
- const listBase_1 = require("./listBase");
41
- /** `:` */
42
- let DdToken = (() => {
43
- let _classDecorators = [(0, syntax_1.syntax)(/^:+$/u)];
44
- let _classDescriptor;
45
- let _classExtraInitializers = [];
46
- let _classThis;
47
- let _classSuper = listBase_1.ListBaseToken;
48
- var DdToken = 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
- DdToken = _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 'dd';
59
- }
60
- /* NOT FOR BROWSER */
61
- /** 缩进数 */
62
- get indent() {
63
- return this.innerText.length;
64
- }
65
- set indent(indent) {
66
- this.setText(':'.repeat(indent));
67
- }
68
- };
69
- return DdToken = _classThis;
70
- })();
71
- exports.DdToken = DdToken;
72
- constants_1.classes['DdToken'] = __filename;
@@ -1,15 +0,0 @@
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
- }
@@ -1,97 +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.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)()];
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;
@@ -1,5 +0,0 @@
1
- import { NowikiBaseToken } from './base';
2
- /** `<hr>` */
3
- export declare abstract class HrToken extends NowikiBaseToken {
4
- get type(): 'hr';
5
- }
@@ -1,70 +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.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 = [(0, 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
- /* NOT FOR BROWSER */
62
- /** @private */
63
- toHtmlInternal() {
64
- return '<hr>';
65
- }
66
- };
67
- return HrToken = _classThis;
68
- })();
69
- exports.HrToken = HrToken;
70
- constants_1.classes['HrToken'] = __filename;
@@ -1,14 +0,0 @@
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
- }
@@ -1,28 +0,0 @@
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 = { range: [start, e.endIndex], text: '' };
20
- return [e];
21
- }
22
- // eslint-disable-next-line @typescript-eslint/no-unused-expressions
23
- /<\s*(?:\/\s*)?(nowiki)\b/giu;
24
- return super.lint(start, new RegExp(String.raw `<\s*(?:/\s*)${name === 'nowiki' ? '' : '?'}(${name})\b`, 'giu'));
25
- }
26
- }
27
- exports.NowikiToken = NowikiToken;
28
- constants_1.classes['NowikiToken'] = __filename;
@@ -1,5 +0,0 @@
1
- import { ListBaseToken } from './listBase';
2
- /** 位于行首的`;:*#` */
3
- export declare abstract class ListToken extends ListBaseToken {
4
- get type(): 'list';
5
- }
@@ -1,65 +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 syntax_1 = require("../../mixin/syntax");
41
- const listBase_1 = require("./listBase");
42
- /** 位于行首的`;:*#` */
43
- let ListToken = (() => {
44
- let _classDecorators = [(0, sol_1.sol)(true), (0, syntax_1.syntax)(/^[;:*#]+$/u)];
45
- let _classDescriptor;
46
- let _classExtraInitializers = [];
47
- let _classThis;
48
- let _classSuper = listBase_1.ListBaseToken;
49
- var ListToken = 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
- ListToken = _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 'list';
60
- }
61
- };
62
- return ListToken = _classThis;
63
- })();
64
- exports.ListToken = ListToken;
65
- constants_1.classes['ListToken'] = __filename;
@@ -1,23 +0,0 @@
1
- import { NowikiBaseToken } from './base';
2
- import { Token } from '../index';
3
- import type { DdToken, ListToken, AstText } from '../../internal';
4
- export interface ListRangeToken extends Token {
5
- readonly type: 'list-range';
6
- readonly previousSibling: ListToken | DdToken;
7
- readonly nextSibling: DdToken | AstText | undefined;
8
- readonly previousElementSibling: ListToken | DdToken;
9
- }
10
- /** `;:*#` */
11
- export declare abstract class ListBaseToken extends NowikiBaseToken {
12
- abstract get type(): 'dd' | 'list';
13
- /** 是否包含`:` */
14
- get dd(): boolean;
15
- /** 是否包含`;` */
16
- get dt(): boolean;
17
- /** 是否包含`*` */
18
- get ul(): boolean;
19
- /** 是否包含`#` */
20
- get ol(): boolean;
21
- /** 获取列表行的范围 */
22
- getRange(): ListRangeToken;
23
- }
@@ -1,99 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ListBaseToken = void 0;
4
- const constants_1 = require("../../util/constants");
5
- const debug_1 = require("../../util/debug");
6
- const base_1 = require("./base");
7
- const index_1 = require("../index");
8
- /* NOT FOR BROWSER END */
9
- /** `;:*#` */
10
- class ListBaseToken extends base_1.NowikiBaseToken {
11
- /* NOT FOR BROWSER */
12
- /** 是否包含`:` */
13
- get dd() {
14
- return this.innerText.includes(':');
15
- }
16
- /** 是否包含`;` */
17
- get dt() {
18
- return this.innerText.includes(';');
19
- }
20
- /** 是否包含`*` */
21
- get ul() {
22
- return this.innerText.includes('*');
23
- }
24
- /** 是否包含`#` */
25
- get ol() {
26
- return this.innerText.includes('#');
27
- }
28
- /** 获取列表行的范围 */
29
- getRange() {
30
- let { nextSibling } = this;
31
- if (nextSibling?.type === 'list-range') {
32
- return nextSibling;
33
- }
34
- const { dt, type } = this;
35
- let nDt = 0;
36
- while (nextSibling && (nextSibling.type !== 'text' || !nextSibling.data.includes('\n'))) {
37
- if (type === 'list') {
38
- if (nextSibling.is('dd')) {
39
- nDt -= nextSibling.indent;
40
- if (dt && nDt < 0) {
41
- break;
42
- }
43
- }
44
- else if (nextSibling.is('list') && nextSibling.dt) {
45
- nDt++;
46
- }
47
- }
48
- else if (nextSibling.type === 'dd') {
49
- break;
50
- }
51
- ({ nextSibling } = nextSibling);
52
- }
53
- const range = this.createRange();
54
- if (nextSibling && nextSibling.type !== 'text') {
55
- range.setStartAfter(this);
56
- range.setEndBefore(nextSibling);
57
- }
58
- else {
59
- const { parentNode } = this;
60
- if (type === 'list') {
61
- while (this.previousSibling?.is('list')) {
62
- this.setText(this.previousSibling.innerText + this.innerText);
63
- this.previousSibling.remove();
64
- }
65
- for (let i = 0; i < nDt; i++) {
66
- const token = this.nextSibling;
67
- this.setText(this.innerText + token.innerText);
68
- token.remove();
69
- }
70
- if (parentNode?.is('list-range')) {
71
- parentNode.previousSibling.setText(parentNode.previousSibling.innerText + this.innerText);
72
- this.remove();
73
- return parentNode;
74
- }
75
- }
76
- range.setStartAfter(this);
77
- if (nextSibling) {
78
- range.setEnd(nextSibling, nextSibling.data.indexOf('\n'));
79
- }
80
- else {
81
- range.setEnd(parentNode, parentNode.length);
82
- }
83
- }
84
- const token = debug_1.Shadow.run(() => {
85
- const t = new index_1.Token(undefined, this.getAttribute('config'));
86
- t.type = 'list-range';
87
- return t;
88
- });
89
- token.append(...range.extractContents());
90
- range.insertNode(token);
91
- return token;
92
- }
93
- /** @private */
94
- toHtmlInternal() {
95
- return '';
96
- }
97
- }
98
- exports.ListBaseToken = ListBaseToken;
99
- constants_1.classes['ListBase'] = __filename;
@@ -1,6 +0,0 @@
1
- import { NowikiBaseToken } from './base';
2
- /** `<noinclude>`和`</noinclude>`,不可进行任何更改 */
3
- export declare abstract class NoincludeToken extends NowikiBaseToken {
4
- get type(): 'noinclude';
5
- setText(str: string): string;
6
- }