wikiparser-node 1.0.3 → 1.1.0-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 (153) hide show
  1. package/bundle/bundle.min.js +36 -0
  2. package/config/llwiki.json +1 -35
  3. package/config/moegirl.json +1 -44
  4. package/config/zhwiki.json +1 -466
  5. package/extensions/dist/base.js +70 -0
  6. package/extensions/dist/editor.js +172 -0
  7. package/extensions/dist/highlight.js +39 -0
  8. package/extensions/dist/lint.js +48 -0
  9. package/extensions/editor.css +63 -0
  10. package/extensions/ui.css +119 -0
  11. package/package.json +23 -11
  12. package/config/.schema.json +0 -160
  13. package/dist/addon/table.d.ts +0 -6
  14. package/dist/addon/table.js +0 -531
  15. package/dist/bin/toc.js +0 -18
  16. package/dist/index.d.ts +0 -60
  17. package/dist/index.js +0 -205
  18. package/dist/internal.d.ts +0 -44
  19. package/dist/lib/element.d.ts +0 -155
  20. package/dist/lib/element.js +0 -655
  21. package/dist/lib/node.d.ts +0 -143
  22. package/dist/lib/node.js +0 -419
  23. package/dist/lib/range.d.ts +0 -115
  24. package/dist/lib/range.js +0 -353
  25. package/dist/lib/ranges.d.ts +0 -28
  26. package/dist/lib/ranges.js +0 -120
  27. package/dist/lib/text.d.ts +0 -63
  28. package/dist/lib/text.js +0 -217
  29. package/dist/lib/title.d.ts +0 -26
  30. package/dist/lib/title.js +0 -125
  31. package/dist/mixin/attributesParent.js +0 -94
  32. package/dist/mixin/fixed.js +0 -32
  33. package/dist/mixin/flagsParent.js +0 -70
  34. package/dist/mixin/hidden.js +0 -22
  35. package/dist/mixin/magicLinkParent.js +0 -41
  36. package/dist/mixin/singleLine.js +0 -25
  37. package/dist/mixin/sol.js +0 -43
  38. package/dist/mixin/syntax.js +0 -56
  39. package/dist/parser/braces.js +0 -123
  40. package/dist/parser/commentAndExt.js +0 -65
  41. package/dist/parser/converter.js +0 -40
  42. package/dist/parser/externalLinks.js +0 -28
  43. package/dist/parser/hrAndDoubleUnderscore.js +0 -38
  44. package/dist/parser/html.js +0 -36
  45. package/dist/parser/links.js +0 -94
  46. package/dist/parser/list.js +0 -59
  47. package/dist/parser/magicLinks.js +0 -40
  48. package/dist/parser/quotes.js +0 -67
  49. package/dist/parser/selector.js +0 -163
  50. package/dist/parser/table.js +0 -110
  51. package/dist/src/arg.d.ts +0 -58
  52. package/dist/src/arg.js +0 -190
  53. package/dist/src/atom.d.ts +0 -12
  54. package/dist/src/atom.js +0 -27
  55. package/dist/src/attribute.d.ts +0 -86
  56. package/dist/src/attribute.js +0 -392
  57. package/dist/src/attributes.d.ts +0 -106
  58. package/dist/src/attributes.js +0 -339
  59. package/dist/src/converter.d.ts +0 -51
  60. package/dist/src/converter.js +0 -79
  61. package/dist/src/converterFlags.d.ts +0 -87
  62. package/dist/src/converterFlags.js +0 -223
  63. package/dist/src/converterRule.d.ts +0 -81
  64. package/dist/src/converterRule.js +0 -221
  65. package/dist/src/extLink.d.ts +0 -53
  66. package/dist/src/extLink.js +0 -121
  67. package/dist/src/gallery.d.ts +0 -55
  68. package/dist/src/gallery.js +0 -129
  69. package/dist/src/heading.d.ts +0 -76
  70. package/dist/src/heading.js +0 -127
  71. package/dist/src/hidden.d.ts +0 -21
  72. package/dist/src/hidden.js +0 -23
  73. package/dist/src/html.d.ts +0 -99
  74. package/dist/src/html.js +0 -230
  75. package/dist/src/imageParameter.d.ts +0 -66
  76. package/dist/src/imageParameter.js +0 -246
  77. package/dist/src/imagemap.d.ts +0 -57
  78. package/dist/src/imagemap.js +0 -148
  79. package/dist/src/imagemapLink.d.ts +0 -57
  80. package/dist/src/imagemapLink.js +0 -40
  81. package/dist/src/index.d.ts +0 -145
  82. package/dist/src/index.js +0 -766
  83. package/dist/src/link/base.d.ts +0 -52
  84. package/dist/src/link/base.js +0 -198
  85. package/dist/src/link/category.d.ts +0 -13
  86. package/dist/src/link/category.js +0 -29
  87. package/dist/src/link/file.d.ts +0 -96
  88. package/dist/src/link/file.js +0 -253
  89. package/dist/src/link/galleryImage.d.ts +0 -41
  90. package/dist/src/link/galleryImage.js +0 -98
  91. package/dist/src/link/index.d.ts +0 -53
  92. package/dist/src/link/index.js +0 -123
  93. package/dist/src/magicLink.d.ts +0 -58
  94. package/dist/src/magicLink.js +0 -122
  95. package/dist/src/nested.d.ts +0 -44
  96. package/dist/src/nested.js +0 -87
  97. package/dist/src/nowiki/base.d.ts +0 -46
  98. package/dist/src/nowiki/base.js +0 -42
  99. package/dist/src/nowiki/comment.d.ts +0 -39
  100. package/dist/src/nowiki/comment.js +0 -67
  101. package/dist/src/nowiki/dd.d.ts +0 -8
  102. package/dist/src/nowiki/dd.js +0 -25
  103. package/dist/src/nowiki/doubleUnderscore.d.ts +0 -43
  104. package/dist/src/nowiki/doubleUnderscore.js +0 -51
  105. package/dist/src/nowiki/hr.d.ts +0 -29
  106. package/dist/src/nowiki/hr.js +0 -14
  107. package/dist/src/nowiki/index.d.ts +0 -16
  108. package/dist/src/nowiki/index.js +0 -21
  109. package/dist/src/nowiki/list.d.ts +0 -29
  110. package/dist/src/nowiki/list.js +0 -47
  111. package/dist/src/nowiki/listBase.d.ts +0 -18
  112. package/dist/src/nowiki/listBase.js +0 -12
  113. package/dist/src/nowiki/noinclude.d.ts +0 -25
  114. package/dist/src/nowiki/noinclude.js +0 -25
  115. package/dist/src/nowiki/quote.d.ts +0 -22
  116. package/dist/src/nowiki/quote.js +0 -50
  117. package/dist/src/onlyinclude.d.ts +0 -16
  118. package/dist/src/onlyinclude.js +0 -57
  119. package/dist/src/paramTag/index.d.ts +0 -37
  120. package/dist/src/paramTag/index.js +0 -68
  121. package/dist/src/paramTag/inputbox.d.ts +0 -8
  122. package/dist/src/paramTag/inputbox.js +0 -23
  123. package/dist/src/parameter.d.ts +0 -82
  124. package/dist/src/parameter.js +0 -202
  125. package/dist/src/pre.d.ts +0 -28
  126. package/dist/src/pre.js +0 -51
  127. package/dist/src/syntax.d.ts +0 -25
  128. package/dist/src/syntax.js +0 -30
  129. package/dist/src/table/base.d.ts +0 -52
  130. package/dist/src/table/base.js +0 -78
  131. package/dist/src/table/index.d.ts +0 -229
  132. package/dist/src/table/index.js +0 -364
  133. package/dist/src/table/td.d.ts +0 -102
  134. package/dist/src/table/td.js +0 -261
  135. package/dist/src/table/tr.d.ts +0 -32
  136. package/dist/src/table/tr.js +0 -56
  137. package/dist/src/table/trBase.d.ts +0 -54
  138. package/dist/src/table/trBase.js +0 -151
  139. package/dist/src/tagPair/ext.d.ts +0 -55
  140. package/dist/src/tagPair/ext.js +0 -142
  141. package/dist/src/tagPair/include.d.ts +0 -52
  142. package/dist/src/tagPair/include.js +0 -58
  143. package/dist/src/tagPair/index.d.ts +0 -47
  144. package/dist/src/tagPair/index.js +0 -93
  145. package/dist/src/transclude.d.ts +0 -167
  146. package/dist/src/transclude.js +0 -694
  147. package/dist/util/constants.js +0 -108
  148. package/dist/util/debug.js +0 -63
  149. package/dist/util/diff.js +0 -72
  150. package/dist/util/lint.js +0 -48
  151. package/dist/util/string.js +0 -63
  152. package/errors/README +0 -1
  153. package/printed/README +0 -1
@@ -1,39 +0,0 @@
1
- import * as Parser from '../../index';
2
- import { NowikiBaseToken } from './base';
3
- import type { LintError } from '../../index';
4
- import type { Token } from '../index';
5
- declare const CommentToken_base: ((abstract new (...args: any[]) => {
6
- text(): string;
7
- length: number;
8
- toString(omit?: Set<string> | undefined, separator?: string | undefined): string;
9
- insertAt(token: unknown, i?: number | undefined): unknown;
10
- afterBuild(): void;
11
- getAttribute<T extends string>(key: T): TokenAttributeGetter<T>;
12
- setAttribute<T_1 extends string>(key: T_1, value: TokenAttributeSetter<T_1>): void;
13
- addEventListener(events: string | string[], listener: AstListener): void;
14
- replaceChildren(...elements: (string | Parser.AstNodes)[]): void;
15
- }) & {
16
- readonly hidden: true;
17
- }) & typeof NowikiBaseToken;
18
- /** HTML注释,不可见 */
19
- export declare class CommentToken extends CommentToken_base {
20
- readonly type = "comment";
21
- closed: boolean;
22
- /** 内部wikitext */
23
- get innerText(): string;
24
- set innerText(text: string);
25
- /** @param closed 是否闭合 */
26
- constructor(wikitext: string, closed?: boolean, config?: Parser.Config, accum?: Token[]);
27
- /** @override */
28
- lint(start?: number): LintError[];
29
- /** @override */
30
- print(): string;
31
- /** @override */
32
- cloneNode(): this;
33
- /**
34
- * @override
35
- * @throws `RangeError` 不允许包含`-->`
36
- */
37
- setText(text: string): string;
38
- }
39
- export {};
@@ -1,67 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CommentToken = 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 hidden_1 = require("../../mixin/hidden");
8
- const Parser = require("../../index");
9
- const base_1 = require("./base");
10
- /** HTML注释,不可见 */
11
- // @ts-expect-error not implementing all abstract methods
12
- class CommentToken extends (0, hidden_1.hidden)(base_1.NowikiBaseToken) {
13
- type = 'comment';
14
- closed;
15
- /* NOT FOR BROWSER */
16
- /** 内部wikitext */
17
- get innerText() {
18
- return super.innerText;
19
- }
20
- set innerText(text) {
21
- this.setText(text);
22
- }
23
- /* NOT FOR BROWSER END */
24
- /** @param closed 是否闭合 */
25
- constructor(wikitext, closed = true, config = Parser.getConfig(), accum = []) {
26
- super(wikitext, config, accum);
27
- this.closed = closed;
28
- Object.defineProperty(this, 'closed', { enumerable: false });
29
- }
30
- /** @private */
31
- getAttribute(key) {
32
- return key === 'padding' ? 4 : super.getAttribute(key);
33
- }
34
- /** @override */
35
- lint(start = this.getAbsoluteIndex()) {
36
- return this.closed ? [] : [(0, lint_1.generateForSelf)(this, { start }, 'unclosed HTML comment')];
37
- }
38
- /** @private */
39
- toString(omit) {
40
- if (!this.closed && this.nextSibling) {
41
- Parser.error('自动闭合HTML注释', this);
42
- this.closed = true;
43
- }
44
- return omit && this.matchesTypes(omit) ? '' : `<!--${this.innerText}${this.closed ? '-->' : ''}`;
45
- }
46
- /** @override */
47
- print() {
48
- return super.print({ pre: '&lt;!--', post: this.closed ? '--&gt;' : '' });
49
- }
50
- /* NOT FOR BROWSER */
51
- /** @override */
52
- cloneNode() {
53
- return debug_1.Shadow.run(() => new CommentToken(this.innerText, this.closed, this.getAttribute('config')));
54
- }
55
- /**
56
- * @override
57
- * @throws `RangeError` 不允许包含`-->`
58
- */
59
- setText(text) {
60
- if (text.includes('-->')) {
61
- throw new RangeError('不允许包含 "-->"!');
62
- }
63
- return super.setText(text);
64
- }
65
- }
66
- exports.CommentToken = CommentToken;
67
- constants_1.classes['CommentToken'] = __filename;
@@ -1,8 +0,0 @@
1
- import { ListBaseToken } from './listBase';
2
- /** `:` */
3
- export declare class DdToken extends ListBaseToken {
4
- readonly type = "dd";
5
- /** 缩进数 */
6
- get indent(): number;
7
- set indent(indent: number);
8
- }
@@ -1,25 +0,0 @@
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
- // @ts-expect-error not implementing all abstract methods
8
- class DdToken extends listBase_1.ListBaseToken {
9
- type = 'dd';
10
- /* NOT FOR BROWSER */
11
- /** 缩进数 */
12
- get indent() {
13
- return this.innerText.split(':').length - 1;
14
- }
15
- set indent(indent) {
16
- this.setText(':'.repeat(indent));
17
- }
18
- /** @private */
19
- afterBuild() {
20
- this.setAttribute('pattern', /^:+$/u);
21
- super.afterBuild();
22
- }
23
- }
24
- exports.DdToken = DdToken;
25
- constants_1.classes['DdToken'] = __filename;
@@ -1,43 +0,0 @@
1
- import * as Parser from '../../index';
2
- import { NowikiBaseToken } from './base';
3
- import type { Token } from '../index';
4
- declare const DoubleUnderscoreToken_base: (abstract new (...args: any[]) => {
5
- "__#4@#pattern": RegExp;
6
- afterBuild(): void;
7
- getAttribute<T extends string>(key: T): TokenAttributeGetter<T>;
8
- setAttribute<T_1 extends string>(key: T_1, value: TokenAttributeSetter<T_1>): void;
9
- replaceChildren(...elements: (string | Parser.AstNodes)[]): void;
10
- length: number;
11
- toString(omit?: Set<string> | undefined, separator?: string | undefined): string;
12
- text(separator?: string | undefined): string;
13
- insertAt(token: unknown, i?: number | undefined): unknown;
14
- addEventListener(events: string | string[], listener: AstListener): void;
15
- }) & ((abstract new (...args: any[]) => {
16
- text(): string;
17
- length: number;
18
- toString(omit?: Set<string> | undefined, separator?: string | undefined): string;
19
- insertAt(token: unknown, i?: number | undefined): unknown;
20
- afterBuild(): void;
21
- getAttribute<T_2 extends string>(key: T_2): TokenAttributeGetter<T_2>;
22
- setAttribute<T_3 extends string>(key: T_3, value: TokenAttributeSetter<T_3>): void;
23
- addEventListener(events: string | string[], listener: AstListener): void;
24
- replaceChildren(...elements: (string | Parser.AstNodes)[]): void;
25
- }) & {
26
- readonly hidden: true;
27
- }) & typeof NowikiBaseToken;
28
- /** 状态开关 */
29
- export declare class DoubleUnderscoreToken extends DoubleUnderscoreToken_base {
30
- #private;
31
- readonly type = "double-underscore";
32
- name: string;
33
- /**
34
- * @param word 状态开关名
35
- * @param fixed 是否固定大小写
36
- */
37
- constructor(word: string, fixed: boolean, config?: Parser.Config, accum?: Token[]);
38
- /** @override */
39
- print(): string;
40
- /** @override */
41
- cloneNode(): this;
42
- }
43
- export {};
@@ -1,51 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DoubleUnderscoreToken = void 0;
4
- const debug_1 = require("../../util/debug");
5
- const constants_1 = require("../../util/constants");
6
- const hidden_1 = require("../../mixin/hidden");
7
- const syntax_1 = require("../../mixin/syntax");
8
- const Parser = require("../../index");
9
- const base_1 = require("./base");
10
- /** 状态开关 */
11
- // @ts-expect-error not implementing all abstract methods
12
- class DoubleUnderscoreToken extends (0, syntax_1.syntax)((0, hidden_1.hidden)(base_1.NowikiBaseToken)) {
13
- type = 'double-underscore';
14
- /* NOT FOR BROWSER */
15
- #fixed;
16
- /* NOT FOR BROWSER END */
17
- /**
18
- * @param word 状态开关名
19
- * @param fixed 是否固定大小写
20
- */
21
- constructor(word, fixed, config = Parser.getConfig(), accum = []) {
22
- super(word, config, accum);
23
- this.#fixed = fixed;
24
- this.setAttribute('name', word.toLowerCase());
25
- this.setAttribute('pattern', new RegExp(`^${word}$`, fixed ? 'u' : 'iu'));
26
- }
27
- /** @private */
28
- getAttribute(key) {
29
- return key === 'padding' ? 2 : super.getAttribute(key);
30
- }
31
- /** @private */
32
- toString(omit) {
33
- return omit && this.matchesTypes(omit) ? '' : `__${this.innerText}__`;
34
- }
35
- /** @override */
36
- print() {
37
- return super.print({ pre: '__', post: '__' });
38
- }
39
- /* NOT FOR BROWSER */
40
- /** @override */
41
- cloneNode() {
42
- const config = this.getAttribute('config');
43
- return debug_1.Shadow.run(() => {
44
- const token = new DoubleUnderscoreToken(this.innerText, this.#fixed, config);
45
- token.afterBuild();
46
- return token;
47
- });
48
- }
49
- }
50
- exports.DoubleUnderscoreToken = DoubleUnderscoreToken;
51
- constants_1.classes['DoubleUnderscoreToken'] = __filename;
@@ -1,29 +0,0 @@
1
- import { NowikiBaseToken } from './base';
2
- declare const HrToken_base: (abstract new (...args: any[]) => {
3
- "__#4@#pattern": RegExp;
4
- afterBuild(): void;
5
- getAttribute<T extends string>(key: T): TokenAttributeGetter<T>;
6
- setAttribute<T_1 extends string>(key: T_1, value: TokenAttributeSetter<T_1>): void;
7
- replaceChildren(...elements: (string | import("../..").AstNodes)[]): void;
8
- length: number;
9
- toString(omit?: Set<string> | undefined, separator?: string | undefined): string;
10
- text(separator?: string | undefined): string;
11
- insertAt(token: unknown, i?: number | undefined): unknown;
12
- addEventListener(events: string | string[], listener: AstListener): void;
13
- }) & (abstract new (...args: any[]) => {
14
- prependNewLine(): string;
15
- toString(omit?: Set<string> | undefined): string;
16
- getAttribute<S extends string>(key: S): TokenAttributeGetter<S>;
17
- text(): string;
18
- length: number;
19
- insertAt(token: unknown, i?: number | undefined): unknown;
20
- afterBuild(): void;
21
- setAttribute<T_2 extends string>(key: T_2, value: TokenAttributeSetter<T_2>): void;
22
- addEventListener(events: string | string[], listener: AstListener): void;
23
- replaceChildren(...elements: (string | import("../..").AstNodes)[]): void;
24
- }) & typeof NowikiBaseToken;
25
- /** `<hr>` */
26
- export declare class HrToken extends HrToken_base {
27
- readonly type = "hr";
28
- }
29
- export {};
@@ -1,14 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.HrToken = void 0;
4
- const constants_1 = require("../../util/constants");
5
- const sol_1 = require("../../mixin/sol");
6
- const syntax_1 = require("../../mixin/syntax");
7
- const base_1 = require("./base");
8
- /** `<hr>` */
9
- // @ts-expect-error not implementing all abstract methods
10
- class HrToken extends (0, syntax_1.syntax)((0, sol_1.sol)(base_1.NowikiBaseToken), /^-{4,}$/u) {
11
- type = 'hr';
12
- }
13
- exports.HrToken = HrToken;
14
- constants_1.classes['HrToken'] = __filename;
@@ -1,16 +0,0 @@
1
- import { NowikiBaseToken } from './base';
2
- import type { LintError } from '../../index';
3
- import type { AttributesToken, ExtToken } from '../../internal';
4
- /** 扩展标签内的纯文字Token */
5
- export declare class NowikiToken extends NowikiBaseToken {
6
- readonly type = "ext-inner";
7
- name: string;
8
- abstract get nextSibling(): undefined;
9
- abstract get nextElementSibling(): undefined;
10
- abstract get previousSibling(): AttributesToken;
11
- abstract get previousElementSibling(): AttributesToken;
12
- abstract get parentNode(): ExtToken | undefined;
13
- abstract get parentElement(): ExtToken | undefined;
14
- /** @override */
15
- lint(start?: number): LintError[];
16
- }
@@ -1,21 +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 Parser = require("../../index");
7
- const base_1 = require("./base");
8
- /** 扩展标签内的纯文字Token */
9
- // @ts-expect-error not implementing all abstract methods
10
- class NowikiToken extends base_1.NowikiBaseToken {
11
- type = 'ext-inner';
12
- /** @override */
13
- lint(start = this.getAbsoluteIndex()) {
14
- const { name, firstChild: { data } } = this;
15
- return (name === 'templatestyles' || name === 'section') && data
16
- ? [(0, lint_1.generateForSelf)(this, { start }, Parser.msg('nothing should be in <$1>', name))]
17
- : super.lint(start);
18
- }
19
- }
20
- exports.NowikiToken = NowikiToken;
21
- constants_1.classes['NowikiToken'] = __filename;
@@ -1,29 +0,0 @@
1
- import { ListBaseToken } from './listBase';
2
- import type { AstRange } from '../../lib/range';
3
- declare const ListToken_base: (abstract new (...args: any[]) => {
4
- prependNewLine(): string;
5
- toString(omit?: Set<string> | undefined): string;
6
- getAttribute<S extends string>(key: S): TokenAttributeGetter<S>;
7
- text(): string;
8
- length: number;
9
- insertAt(token: unknown, i?: number | undefined): unknown;
10
- afterBuild(): void;
11
- setAttribute<T extends string>(key: T, value: TokenAttributeSetter<T>): void;
12
- addEventListener(events: string | string[], listener: AstListener): void;
13
- replaceChildren(...elements: (string | import("../..").AstNodes)[]): void;
14
- }) & typeof ListBaseToken;
15
- /** 位于行首的`;:*#` */
16
- export declare class ListToken extends ListToken_base {
17
- readonly type = "list";
18
- /** 是否包含`:` */
19
- get dd(): boolean;
20
- /** 是否包含`;` */
21
- get dt(): boolean;
22
- /** 是否包含`*` */
23
- get ul(): boolean;
24
- /** 是否包含`#` */
25
- get ol(): boolean;
26
- /** 获取列表行的范围 */
27
- getRange(): AstRange;
28
- }
29
- export {};
@@ -1,47 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ListToken = void 0;
4
- const constants_1 = require("../../util/constants");
5
- const sol_1 = require("../../mixin/sol");
6
- const listBase_1 = require("./listBase");
7
- /** 位于行首的`;:*#` */
8
- // @ts-expect-error not implementing all abstract methods
9
- class ListToken extends (0, sol_1.sol)(listBase_1.ListBaseToken) {
10
- type = 'list';
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
- const range = this.createRange();
31
- range.setStartBefore(this);
32
- let { nextSibling } = this;
33
- while (nextSibling && (nextSibling.type !== 'text' || !nextSibling.data.includes('\n'))) {
34
- ({ nextSibling } = nextSibling);
35
- }
36
- if (nextSibling) {
37
- const i = nextSibling.data.indexOf('\n');
38
- range.setEnd(nextSibling, i);
39
- }
40
- else {
41
- range.setEndAfter(this.parentNode);
42
- }
43
- return range;
44
- }
45
- }
46
- exports.ListToken = ListToken;
47
- constants_1.classes['ListToken'] = __filename;
@@ -1,18 +0,0 @@
1
- import { NowikiBaseToken } from './base';
2
- declare const ListBaseToken_base: (abstract new (...args: any[]) => {
3
- "__#4@#pattern": RegExp;
4
- afterBuild(): void;
5
- getAttribute<T extends string>(key: T): TokenAttributeGetter<T>;
6
- setAttribute<T_1 extends string>(key: T_1, value: TokenAttributeSetter<T_1>): void;
7
- replaceChildren(...elements: (string | import("../..").AstNodes)[]): void;
8
- length: number;
9
- toString(omit?: Set<string> | undefined, separator?: string | undefined): string;
10
- text(separator?: string | undefined): string;
11
- insertAt(token: unknown, i?: number | undefined): unknown;
12
- addEventListener(events: string | string[], listener: AstListener): void;
13
- }) & typeof NowikiBaseToken;
14
- /** `;:*#` */
15
- export declare class ListBaseToken extends ListBaseToken_base {
16
- type: 'dd' | 'list';
17
- }
18
- export {};
@@ -1,12 +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 syntax_1 = require("../../mixin/syntax");
6
- const base_1 = require("./base");
7
- /** `;:*#` */
8
- // @ts-expect-error not implementing all abstract methods
9
- class ListBaseToken extends (0, syntax_1.syntax)(base_1.NowikiBaseToken, /^[;:*#]+$/u) {
10
- }
11
- exports.ListBaseToken = ListBaseToken;
12
- constants_1.classes['ListBase'] = __filename;
@@ -1,25 +0,0 @@
1
- import { NowikiBaseToken } from './base';
2
- declare const NoincludeToken_base: ((abstract new (...args: any[]) => {
3
- text(): string;
4
- length: number;
5
- toString(omit?: Set<string> | undefined, separator?: string | undefined): string;
6
- insertAt(token: unknown, i?: number | undefined): unknown;
7
- afterBuild(): void;
8
- getAttribute<T extends string>(key: T): TokenAttributeGetter<T>;
9
- setAttribute<T_1 extends string>(key: T_1, value: TokenAttributeSetter<T_1>): void;
10
- addEventListener(events: string | string[], listener: AstListener): void;
11
- replaceChildren(...elements: (string | import("../..").AstNodes)[]): void;
12
- }) & {
13
- readonly hidden: true;
14
- }) & typeof NowikiBaseToken;
15
- /** `<noinclude>`和`</noinclude>`,不可进行任何更改 */
16
- export declare class NoincludeToken extends NoincludeToken_base {
17
- readonly type = "noinclude";
18
- /**
19
- * @override
20
- * @param str 新文本
21
- * @throws `Error` 不可更改
22
- */
23
- setText(str: string): string;
24
- }
25
- export {};
@@ -1,25 +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
- // @ts-expect-error not implementing all abstract methods
9
- class NoincludeToken extends (0, hidden_1.hidden)(base_1.NowikiBaseToken) {
10
- type = 'noinclude';
11
- /* NOT FOR BROWSER */
12
- /**
13
- * @override
14
- * @param str 新文本
15
- * @throws `Error` 不可更改
16
- */
17
- setText(str) {
18
- if (/^<\/?(?:(?:no|only)include|includeonly)(?:\s[^>]*)?\/?>$/iu.test(this.innerText)) {
19
- throw new Error(`${this.constructor.name} 不可更改文字内容!`);
20
- }
21
- return super.setText(str);
22
- }
23
- }
24
- exports.NoincludeToken = NoincludeToken;
25
- constants_1.classes['NoincludeToken'] = __filename;
@@ -1,22 +0,0 @@
1
- import * as Parser from '../../index';
2
- import { NowikiBaseToken } from './base';
3
- import type { LintError } from '../../index';
4
- declare const QuoteToken_base: (abstract new (...args: any[]) => {
5
- "__#4@#pattern": RegExp;
6
- afterBuild(): void;
7
- getAttribute<T extends string>(key: T): TokenAttributeGetter<T>;
8
- setAttribute<T_1 extends string>(key: T_1, value: TokenAttributeSetter<T_1>): void;
9
- replaceChildren(...elements: (string | Parser.AstNodes)[]): void;
10
- length: number;
11
- toString(omit?: Set<string> | undefined, separator?: string | undefined): string;
12
- text(separator?: string | undefined): string;
13
- insertAt(token: unknown, i?: number | undefined): unknown;
14
- addEventListener(events: string | string[], listener: AstListener): void;
15
- }) & typeof NowikiBaseToken;
16
- /** `''`和`'''` */
17
- export declare class QuoteToken extends QuoteToken_base {
18
- readonly type = "quote";
19
- /** @override */
20
- lint(start?: number): LintError[];
21
- }
22
- export {};
@@ -1,50 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.QuoteToken = void 0;
4
- const lint_1 = require("../../util/lint");
5
- const constants_1 = require("../../util/constants");
6
- const syntax_1 = require("../../mixin/syntax");
7
- const Parser = require("../../index");
8
- const base_1 = require("./base");
9
- /** `''`和`'''` */
10
- // @ts-expect-error not implementing all abstract methods
11
- class QuoteToken extends (0, syntax_1.syntax)(base_1.NowikiBaseToken, /^(?:'{5}|'''?)$/u) {
12
- type = 'quote';
13
- /** @override */
14
- lint(start = this.getAbsoluteIndex()) {
15
- const { previousSibling, nextSibling } = this, message = Parser.msg('lonely "$1"', `'`), errors = [];
16
- let refError;
17
- let wikitext;
18
- if (previousSibling?.type === 'text' && previousSibling.data.endsWith(`'`)) {
19
- refError = (0, lint_1.generateForSelf)(this, { start }, message);
20
- wikitext = String(this.getRootNode());
21
- const { startIndex: endIndex, startLine: endLine, startCol: endCol } = refError, [{ length }] = previousSibling.data.match(/(?<!')'+$/u), startIndex = start - length;
22
- errors.push({
23
- ...refError,
24
- startIndex,
25
- endIndex,
26
- startCol: endCol - length,
27
- endLine,
28
- endCol,
29
- excerpt: wikitext.slice(startIndex, startIndex + 50),
30
- });
31
- }
32
- if (nextSibling?.type === 'text' && nextSibling.data.startsWith(`'`)) {
33
- refError ??= (0, lint_1.generateForSelf)(this, { start }, message);
34
- wikitext ??= String(this.getRootNode());
35
- const { endIndex: startIndex, endLine: startLine, endCol: startCol } = refError, [{ length }] = nextSibling.data.match(/^'+/u), endIndex = startIndex + length;
36
- errors.push({
37
- ...refError,
38
- startIndex,
39
- endIndex,
40
- startLine,
41
- startCol,
42
- endCol: startCol + length,
43
- excerpt: wikitext.slice(Math.max(0, endIndex - 50), endIndex),
44
- });
45
- }
46
- return errors;
47
- }
48
- }
49
- exports.QuoteToken = QuoteToken;
50
- 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 Parser = require("../index");
7
- const index_1 = require("./index");
8
- /**
9
- * 嵌入时的`<onlyinclude>`
10
- * @classdesc `{childNodes: ...AstText|Token}`
11
- */
12
- class OnlyincludeToken extends index_1.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(...Parser.parse(text, true, undefined, this.getAttribute('config')).childNodes);
25
- }
26
- /* NOT FOR BROWSER END */
27
- /** @private */
28
- toString(omit) {
29
- return omit && this.matchesTypes(omit) ? '' : `<onlyinclude>${super.toString(omit)}</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;