wikiparser-node 1.4.1 → 1.4.2-b

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (162) hide show
  1. package/bundle/bundle.min.js +36 -0
  2. package/config/enwiki.json +1 -814
  3. package/config/llwiki.json +1 -35
  4. package/config/moegirl.json +1 -44
  5. package/config/zhwiki.json +1 -466
  6. package/extensions/dist/base.js +64 -0
  7. package/extensions/dist/editor.js +159 -0
  8. package/extensions/dist/highlight.js +59 -0
  9. package/extensions/dist/lint.js +48 -0
  10. package/extensions/editor.css +63 -0
  11. package/extensions/ui.css +141 -0
  12. package/package.json +30 -15
  13. package/config/.schema.json +0 -172
  14. package/dist/addon/table.d.ts +0 -6
  15. package/dist/addon/table.js +0 -560
  16. package/dist/base.d.ts +0 -53
  17. package/dist/index.d.ts +0 -32
  18. package/dist/index.js +0 -208
  19. package/dist/internal.d.ts +0 -44
  20. package/dist/lib/element.d.ts +0 -154
  21. package/dist/lib/element.js +0 -635
  22. package/dist/lib/node.d.ts +0 -146
  23. package/dist/lib/node.js +0 -419
  24. package/dist/lib/range.d.ts +0 -104
  25. package/dist/lib/range.js +0 -385
  26. package/dist/lib/ranges.d.ts +0 -26
  27. package/dist/lib/ranges.js +0 -118
  28. package/dist/lib/text.d.ts +0 -62
  29. package/dist/lib/text.js +0 -265
  30. package/dist/lib/title.d.ts +0 -38
  31. package/dist/lib/title.js +0 -163
  32. package/dist/mixin/attributesParent.d.ts +0 -20
  33. package/dist/mixin/attributesParent.js +0 -89
  34. package/dist/mixin/fixed.d.ts +0 -5
  35. package/dist/mixin/fixed.js +0 -28
  36. package/dist/mixin/flagsParent.d.ts +0 -61
  37. package/dist/mixin/flagsParent.js +0 -70
  38. package/dist/mixin/hidden.d.ts +0 -5
  39. package/dist/mixin/hidden.js +0 -24
  40. package/dist/mixin/magicLinkParent.d.ts +0 -34
  41. package/dist/mixin/magicLinkParent.js +0 -41
  42. package/dist/mixin/singleLine.d.ts +0 -5
  43. package/dist/mixin/singleLine.js +0 -25
  44. package/dist/mixin/sol.d.ts +0 -8
  45. package/dist/mixin/sol.js +0 -43
  46. package/dist/mixin/syntax.d.ts +0 -6
  47. package/dist/mixin/syntax.js +0 -54
  48. package/dist/parser/braces.js +0 -131
  49. package/dist/parser/commentAndExt.js +0 -90
  50. package/dist/parser/converter.js +0 -41
  51. package/dist/parser/externalLinks.js +0 -32
  52. package/dist/parser/hrAndDoubleUnderscore.js +0 -41
  53. package/dist/parser/html.js +0 -39
  54. package/dist/parser/links.js +0 -95
  55. package/dist/parser/list.js +0 -68
  56. package/dist/parser/magicLinks.js +0 -43
  57. package/dist/parser/quotes.js +0 -68
  58. package/dist/parser/selector.js +0 -162
  59. package/dist/parser/table.js +0 -124
  60. package/dist/src/arg.d.ts +0 -58
  61. package/dist/src/arg.js +0 -195
  62. package/dist/src/atom.d.ts +0 -12
  63. package/dist/src/atom.js +0 -27
  64. package/dist/src/attribute.d.ts +0 -67
  65. package/dist/src/attribute.js +0 -423
  66. package/dist/src/attributes.d.ts +0 -109
  67. package/dist/src/attributes.js +0 -347
  68. package/dist/src/converter.d.ts +0 -28
  69. package/dist/src/converter.js +0 -86
  70. package/dist/src/converterFlags.d.ts +0 -87
  71. package/dist/src/converterFlags.js +0 -225
  72. package/dist/src/converterRule.d.ts +0 -77
  73. package/dist/src/converterRule.js +0 -209
  74. package/dist/src/extLink.d.ts +0 -38
  75. package/dist/src/extLink.js +0 -133
  76. package/dist/src/gallery.d.ts +0 -54
  77. package/dist/src/gallery.js +0 -127
  78. package/dist/src/heading.d.ts +0 -47
  79. package/dist/src/heading.js +0 -144
  80. package/dist/src/hidden.d.ts +0 -7
  81. package/dist/src/hidden.js +0 -23
  82. package/dist/src/html.d.ts +0 -62
  83. package/dist/src/html.js +0 -285
  84. package/dist/src/imageParameter.d.ts +0 -65
  85. package/dist/src/imageParameter.js +0 -248
  86. package/dist/src/imagemap.d.ts +0 -56
  87. package/dist/src/imagemap.js +0 -152
  88. package/dist/src/imagemapLink.d.ts +0 -28
  89. package/dist/src/imagemapLink.js +0 -44
  90. package/dist/src/index.d.ts +0 -143
  91. package/dist/src/index.js +0 -791
  92. package/dist/src/link/base.d.ts +0 -52
  93. package/dist/src/link/base.js +0 -209
  94. package/dist/src/link/category.d.ts +0 -13
  95. package/dist/src/link/category.js +0 -28
  96. package/dist/src/link/file.d.ts +0 -96
  97. package/dist/src/link/file.js +0 -262
  98. package/dist/src/link/galleryImage.d.ts +0 -31
  99. package/dist/src/link/galleryImage.js +0 -105
  100. package/dist/src/link/index.d.ts +0 -56
  101. package/dist/src/link/index.js +0 -134
  102. package/dist/src/magicLink.d.ts +0 -51
  103. package/dist/src/magicLink.js +0 -148
  104. package/dist/src/nested.d.ts +0 -43
  105. package/dist/src/nested.js +0 -90
  106. package/dist/src/nowiki/base.d.ts +0 -27
  107. package/dist/src/nowiki/base.js +0 -42
  108. package/dist/src/nowiki/comment.d.ts +0 -27
  109. package/dist/src/nowiki/comment.js +0 -74
  110. package/dist/src/nowiki/dd.d.ts +0 -8
  111. package/dist/src/nowiki/dd.js +0 -24
  112. package/dist/src/nowiki/doubleUnderscore.d.ts +0 -18
  113. package/dist/src/nowiki/doubleUnderscore.js +0 -50
  114. package/dist/src/nowiki/hr.d.ts +0 -8
  115. package/dist/src/nowiki/hr.js +0 -13
  116. package/dist/src/nowiki/index.d.ts +0 -16
  117. package/dist/src/nowiki/index.js +0 -20
  118. package/dist/src/nowiki/list.d.ts +0 -19
  119. package/dist/src/nowiki/list.js +0 -47
  120. package/dist/src/nowiki/listBase.d.ts +0 -5
  121. package/dist/src/nowiki/listBase.js +0 -11
  122. package/dist/src/nowiki/noinclude.d.ts +0 -10
  123. package/dist/src/nowiki/noinclude.js +0 -23
  124. package/dist/src/nowiki/quote.d.ts +0 -14
  125. package/dist/src/nowiki/quote.js +0 -68
  126. package/dist/src/onlyinclude.d.ts +0 -16
  127. package/dist/src/onlyinclude.js +0 -57
  128. package/dist/src/paramTag/index.d.ts +0 -37
  129. package/dist/src/paramTag/index.js +0 -68
  130. package/dist/src/paramTag/inputbox.d.ts +0 -8
  131. package/dist/src/paramTag/inputbox.js +0 -22
  132. package/dist/src/parameter.d.ts +0 -67
  133. package/dist/src/parameter.js +0 -215
  134. package/dist/src/pre.d.ts +0 -28
  135. package/dist/src/pre.js +0 -54
  136. package/dist/src/syntax.d.ts +0 -14
  137. package/dist/src/syntax.js +0 -34
  138. package/dist/src/table/base.d.ts +0 -27
  139. package/dist/src/table/base.js +0 -80
  140. package/dist/src/table/index.d.ts +0 -230
  141. package/dist/src/table/index.js +0 -385
  142. package/dist/src/table/td.d.ts +0 -88
  143. package/dist/src/table/td.js +0 -273
  144. package/dist/src/table/tr.d.ts +0 -32
  145. package/dist/src/table/tr.js +0 -57
  146. package/dist/src/table/trBase.d.ts +0 -53
  147. package/dist/src/table/trBase.js +0 -154
  148. package/dist/src/tagPair/ext.d.ts +0 -29
  149. package/dist/src/tagPair/ext.js +0 -151
  150. package/dist/src/tagPair/include.d.ts +0 -37
  151. package/dist/src/tagPair/include.js +0 -71
  152. package/dist/src/tagPair/index.d.ts +0 -27
  153. package/dist/src/tagPair/index.js +0 -76
  154. package/dist/src/transclude.d.ts +0 -167
  155. package/dist/src/transclude.js +0 -700
  156. package/dist/util/constants.js +0 -113
  157. package/dist/util/debug.js +0 -83
  158. package/dist/util/diff.js +0 -72
  159. package/dist/util/lint.js +0 -30
  160. package/dist/util/string.js +0 -53
  161. package/errors/README +0 -1
  162. package/printed/README +0 -1
@@ -1,42 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.NowikiBaseToken = void 0;
4
- const debug_1 = require("../../util/debug");
5
- const constants_1 = require("../../util/constants");
6
- const fixed_1 = require("../../mixin/fixed");
7
- const Parser = require("../../index");
8
- const index_1 = require("../index");
9
- /**
10
- * 纯文字Token,不会被解析
11
- * @classdesc `{childNodes: [AstText]}`
12
- */
13
- class NowikiBaseToken extends (0, fixed_1.fixedToken)(index_1.Token) {
14
- /** 纯文本部分 */
15
- get innerText() {
16
- return this.firstChild.data;
17
- }
18
- /** @param wikitext default: `''` */
19
- constructor(wikitext = '', config = Parser.getConfig(), accum = []) {
20
- super(wikitext, config, accum);
21
- }
22
- /* NOT FOR BROWSER */
23
- /** @override */
24
- cloneNode() {
25
- const { constructor, firstChild: { data }, type } = this;
26
- return debug_1.Shadow.run(() => {
27
- const token = new constructor(data, this.getAttribute('config'));
28
- token.type = type;
29
- token.afterBuild();
30
- return token;
31
- });
32
- }
33
- /**
34
- * @override
35
- * @param str 新文本
36
- */
37
- setText(str) {
38
- return super.setText(str, 0);
39
- }
40
- }
41
- exports.NowikiBaseToken = NowikiBaseToken;
42
- constants_1.classes['NowikiBaseToken'] = __filename;
@@ -1,27 +0,0 @@
1
- import * as Parser from '../../index';
2
- import { NowikiBaseToken } from './base';
3
- import type { LintError } from '../../base';
4
- import type { Token } from '../index';
5
- export declare abstract class CommentToken extends NowikiBaseToken {
6
- readonly type = "comment";
7
- closed: boolean;
8
- /** 内部文本 */
9
- get innerText(): string;
10
- set innerText(text: string);
11
- /** @param closed 是否闭合 */
12
- constructor(wikitext: string, closed?: boolean, config?: Parser.Config, accum?: Token[]);
13
- /** @override */
14
- lint(start?: number): LintError[];
15
- /** @override */
16
- print(): string;
17
- /** @override */
18
- json(): object;
19
- /** @override */
20
- cloneNode(): this;
21
- /**
22
- * @override
23
- * @throws `RangeError` 不允许包含`-->`
24
- */
25
- setText(text: string): string;
26
- }
27
- export {};
@@ -1,74 +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
- class CommentToken extends (0, hidden_1.hiddenToken)(base_1.NowikiBaseToken) {
12
- type = 'comment';
13
- closed;
14
- /* NOT FOR BROWSER */
15
- /** 内部文本 */
16
- get innerText() {
17
- return super.innerText;
18
- }
19
- set innerText(text) {
20
- this.setText(text);
21
- }
22
- /* NOT FOR BROWSER END */
23
- /** @param closed 是否闭合 */
24
- constructor(wikitext, closed = true, config = Parser.getConfig(), accum = []) {
25
- super(wikitext, config, accum);
26
- this.closed = closed;
27
- Object.defineProperty(this, 'closed', { enumerable: false });
28
- }
29
- /** @private */
30
- getAttribute(key) {
31
- return key === 'padding' ? 4 : super.getAttribute(key);
32
- }
33
- /** @override */
34
- lint(start = this.getAbsoluteIndex()) {
35
- return this.closed ? [] : [(0, lint_1.generateForSelf)(this, { start }, Parser.msg('unclosed $1', 'HTML comment'))];
36
- }
37
- /** @private */
38
- toString(omit) {
39
- if (!this.closed && this.nextSibling) {
40
- Parser.error('自动闭合HTML注释', this);
41
- this.closed = true;
42
- }
43
- return omit && this.matchesTypes(omit) ? '' : `<!--${this.innerText}${this.closed ? '-->' : ''}`;
44
- }
45
- /** @override */
46
- print() {
47
- return super.print({ pre: '&lt;!--', post: this.closed ? '--&gt;' : '' });
48
- }
49
- /* NOT FOR BROWSER */
50
- /** @override */
51
- json() {
52
- return {
53
- ...super.json(),
54
- closed: this.closed,
55
- };
56
- }
57
- /** @override */
58
- cloneNode() {
59
- // @ts-expect-error abstract class
60
- return debug_1.Shadow.run(() => new CommentToken(this.innerText, this.closed, this.getAttribute('config')));
61
- }
62
- /**
63
- * @override
64
- * @throws `RangeError` 不允许包含`-->`
65
- */
66
- setText(text) {
67
- if (text.includes('-->')) {
68
- throw new RangeError('不允许包含 "-->"!');
69
- }
70
- return super.setText(text);
71
- }
72
- }
73
- exports.CommentToken = CommentToken;
74
- constants_1.classes['CommentToken'] = __filename;
@@ -1,8 +0,0 @@
1
- import { ListBaseToken } from './listBase';
2
- /** `:` */
3
- export declare abstract class DdToken extends ListBaseToken {
4
- readonly type = "dd";
5
- /** 缩进数 */
6
- get indent(): number;
7
- set indent(indent: number);
8
- }
@@ -1,24 +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
- class DdToken extends listBase_1.ListBaseToken {
8
- type = 'dd';
9
- /* NOT FOR BROWSER */
10
- /** 缩进数 */
11
- get indent() {
12
- return this.innerText.length;
13
- }
14
- set indent(indent) {
15
- this.setText(':'.repeat(indent));
16
- }
17
- /** @private */
18
- afterBuild() {
19
- this.setAttribute('pattern', /^:+$/u);
20
- super.afterBuild();
21
- }
22
- }
23
- exports.DdToken = DdToken;
24
- constants_1.classes['DdToken'] = __filename;
@@ -1,18 +0,0 @@
1
- import * as Parser from '../../index';
2
- import { NowikiBaseToken } from './base';
3
- import type { Token } from '../index';
4
- export declare abstract class DoubleUnderscoreToken extends NowikiBaseToken {
5
- #private;
6
- readonly type = "double-underscore";
7
- readonly name: string;
8
- /**
9
- * @param word 状态开关名
10
- * @param sensitive 是否固定大小写
11
- */
12
- constructor(word: string, sensitive: boolean, config?: Parser.Config, accum?: Token[]);
13
- /** @override */
14
- print(): string;
15
- /** @override */
16
- cloneNode(): this;
17
- }
18
- export {};
@@ -1,50 +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
- class DoubleUnderscoreToken extends (0, syntax_1.syntax)((0, hidden_1.hiddenToken)(base_1.NowikiBaseToken)) {
12
- type = 'double-underscore';
13
- #sensitive;
14
- /* NOT FOR BROWSER END */
15
- /**
16
- * @param word 状态开关名
17
- * @param sensitive 是否固定大小写
18
- */
19
- constructor(word, sensitive, config = Parser.getConfig(), accum = []) {
20
- super(word, config, accum);
21
- this.#sensitive = sensitive;
22
- this.setAttribute('name', word.toLowerCase());
23
- this.setAttribute('pattern', new RegExp(`^${word}$`, sensitive ? 'u' : 'iu'));
24
- }
25
- /** @private */
26
- getAttribute(key) {
27
- return key === 'padding' ? 2 : super.getAttribute(key);
28
- }
29
- /** @private */
30
- toString(omit) {
31
- return omit && this.matchesTypes(omit) ? '' : `__${this.innerText}__`;
32
- }
33
- /** @override */
34
- print() {
35
- return super.print({ pre: '__', post: '__' });
36
- }
37
- /* NOT FOR BROWSER */
38
- /** @override */
39
- cloneNode() {
40
- const config = this.getAttribute('config');
41
- return debug_1.Shadow.run(() => {
42
- // @ts-expect-error abstract class
43
- const token = new DoubleUnderscoreToken(this.innerText, this.#sensitive, config);
44
- token.afterBuild();
45
- return token;
46
- });
47
- }
48
- }
49
- exports.DoubleUnderscoreToken = DoubleUnderscoreToken;
50
- constants_1.classes['DoubleUnderscoreToken'] = __filename;
@@ -1,8 +0,0 @@
1
- import { NowikiBaseToken } from './base';
2
- import type { SolTokenBase } from '../../mixin/sol';
3
- export interface HrToken extends SolTokenBase {
4
- }
5
- export declare abstract class HrToken extends NowikiBaseToken {
6
- readonly type = "hr";
7
- }
8
- export {};
@@ -1,13 +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
- class HrToken extends (0, syntax_1.syntax)((0, sol_1.sol)(base_1.NowikiBaseToken), /^-{4,}$/u) {
10
- type = 'hr';
11
- }
12
- exports.HrToken = HrToken;
13
- constants_1.classes['HrToken'] = __filename;
@@ -1,16 +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 type = "ext-inner";
7
- readonly 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,20 +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
- class NowikiToken extends base_1.NowikiBaseToken {
10
- type = 'ext-inner';
11
- /** @override */
12
- lint(start = this.getAbsoluteIndex()) {
13
- const { name, firstChild: { data } } = this;
14
- return (name === 'templatestyles' || name === 'section') && data
15
- ? [(0, lint_1.generateForSelf)(this, { start }, Parser.msg('nothing should be in <$1>', name))]
16
- : super.lint(start);
17
- }
18
- }
19
- exports.NowikiToken = NowikiToken;
20
- constants_1.classes['NowikiToken'] = __filename;
@@ -1,19 +0,0 @@
1
- import { ListBaseToken } from './listBase';
2
- import type { AstRange } from '../../lib/range';
3
- import type { SolTokenBase } from '../../mixin/sol';
4
- export interface ListToken extends SolTokenBase {
5
- }
6
- export declare abstract class ListToken extends ListBaseToken {
7
- readonly type = "list";
8
- /** 是否包含`:` */
9
- get dd(): boolean;
10
- /** 是否包含`;` */
11
- get dt(): boolean;
12
- /** 是否包含`*` */
13
- get ul(): boolean;
14
- /** 是否包含`#` */
15
- get ol(): boolean;
16
- /** 获取列表行的范围 */
17
- getRange(): AstRange;
18
- }
19
- 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
- class ListToken extends (0, sol_1.sol)(listBase_1.ListBaseToken) {
9
- type = 'list';
10
- /* NOT FOR BROWSER */
11
- /** 是否包含`:` */
12
- get dd() {
13
- return this.innerText.includes(':');
14
- }
15
- /** 是否包含`;` */
16
- get dt() {
17
- return this.innerText.includes(';');
18
- }
19
- /** 是否包含`*` */
20
- get ul() {
21
- return this.innerText.includes('*');
22
- }
23
- /** 是否包含`#` */
24
- get ol() {
25
- return this.innerText.includes('#');
26
- }
27
- /** 获取列表行的范围 */
28
- getRange() {
29
- const range = this.createRange();
30
- range.setStartBefore(this);
31
- let { nextSibling } = this;
32
- while (nextSibling && (nextSibling.type !== 'text' || !nextSibling.data.includes('\n'))) {
33
- ({ nextSibling } = nextSibling);
34
- }
35
- if (nextSibling) {
36
- const i = nextSibling.data.indexOf('\n');
37
- range.setEnd(nextSibling, i);
38
- }
39
- else {
40
- const { parentNode } = this;
41
- range.setEnd(parentNode, parentNode.length);
42
- }
43
- return range;
44
- }
45
- }
46
- exports.ListToken = ListToken;
47
- constants_1.classes['ListToken'] = __filename;
@@ -1,5 +0,0 @@
1
- import { NowikiBaseToken } from './base';
2
- export declare abstract class ListBaseToken extends NowikiBaseToken {
3
- type: 'dd' | 'list';
4
- }
5
- export {};
@@ -1,11 +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
- class ListBaseToken extends (0, syntax_1.syntax)(base_1.NowikiBaseToken, /^[;:*#]+$/u) {
9
- }
10
- exports.ListBaseToken = ListBaseToken;
11
- constants_1.classes['ListBase'] = __filename;
@@ -1,10 +0,0 @@
1
- import { NowikiBaseToken } from './base';
2
- export declare abstract class NoincludeToken extends NowikiBaseToken {
3
- readonly type = "noinclude";
4
- /**
5
- * @override
6
- * @param str 新文本
7
- */
8
- setText(str: string): string;
9
- }
10
- export {};
@@ -1,23 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.NoincludeToken = void 0;
4
- const constants_1 = require("../../util/constants");
5
- const hidden_1 = require("../../mixin/hidden");
6
- const base_1 = require("./base");
7
- /** `<noinclude>`和`</noinclude>`,不可进行任何更改 */
8
- class NoincludeToken extends (0, hidden_1.hiddenToken)(base_1.NowikiBaseToken) {
9
- type = 'noinclude';
10
- /* NOT FOR BROWSER */
11
- /**
12
- * @override
13
- * @param str 新文本
14
- */
15
- setText(str) {
16
- if (/^<\/?(?:(?:no|only)include|includeonly)(?:\s[^>]*)?\/?>$/iu.test(this.innerText)) {
17
- this.constructorError('不可更改文字内容');
18
- }
19
- return super.setText(str);
20
- }
21
- }
22
- exports.NoincludeToken = NoincludeToken;
23
- constants_1.classes['NoincludeToken'] = __filename;
@@ -1,14 +0,0 @@
1
- import { NowikiBaseToken } from './base';
2
- import type { LintError } from '../../base';
3
- export declare abstract class QuoteToken extends NowikiBaseToken {
4
- readonly type = "quote";
5
- /** 是否粗体 */
6
- get bold(): boolean;
7
- /** 是否斜体 */
8
- get italic(): boolean;
9
- /** @override */
10
- lint(start?: number): LintError[];
11
- /** @override */
12
- json(): object;
13
- }
14
- export {};
@@ -1,68 +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
- class QuoteToken extends (0, syntax_1.syntax)(base_1.NowikiBaseToken, /^(?:'{5}|'''?)$/u) {
11
- type = 'quote';
12
- /** 是否粗体 */
13
- get bold() {
14
- return this.innerText.length !== 2;
15
- }
16
- /** 是否斜体 */
17
- get italic() {
18
- return this.innerText.length !== 3;
19
- }
20
- /** @override */
21
- lint(start = this.getAbsoluteIndex()) {
22
- const { previousSibling, nextSibling, bold } = this, message = Parser.msg('lonely "$1"', `'`), errors = [];
23
- let refError;
24
- if (previousSibling?.type === 'text' && previousSibling.data.endsWith(`'`)) {
25
- refError = (0, lint_1.generateForSelf)(this, { start }, message);
26
- const { startIndex: endIndex, startLine: endLine, startCol: endCol } = refError, [, { length }] = /(?:^|[^'])('+)$/u.exec(previousSibling.data), startIndex = start - length;
27
- errors.push({
28
- ...refError,
29
- startIndex,
30
- endIndex,
31
- startCol: endCol - length,
32
- endLine,
33
- endCol,
34
- });
35
- }
36
- if (nextSibling?.type === 'text' && nextSibling.data.startsWith(`'`)) {
37
- refError ??= (0, lint_1.generateForSelf)(this, { start }, message);
38
- const { endIndex: startIndex, endLine: startLine, endCol: startCol } = refError, [{ length }] = /^'+/u.exec(nextSibling.data), endIndex = startIndex + length;
39
- errors.push({
40
- ...refError,
41
- startIndex,
42
- endIndex,
43
- startLine,
44
- startCol,
45
- endCol: startCol + length,
46
- });
47
- }
48
- if (bold && this.closest('heading-title')) {
49
- refError ??= (0, lint_1.generateForSelf)(this, { start }, message);
50
- errors.push({
51
- ...refError,
52
- message: Parser.msg('bold in section header'),
53
- severity: 'warning',
54
- });
55
- }
56
- return errors;
57
- }
58
- /** @override */
59
- json() {
60
- return {
61
- ...super.json(),
62
- bold: this.bold,
63
- italic: this.italic,
64
- };
65
- }
66
- }
67
- exports.QuoteToken = QuoteToken;
68
- 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;
@@ -1,37 +0,0 @@
1
- import * as Parser from '../../index';
2
- import { Token } from '../index';
3
- import { AtomToken } from '../atom';
4
- import type { LintError } from '../../base';
5
- import type { AttributesToken, ExtToken } from '../../internal';
6
- /**
7
- * `<dynamicpagelist>`
8
- * @classdesc `{childNodes: ...AtomToken}`
9
- */
10
- export declare abstract class ParamTagToken extends Token {
11
- readonly type = "ext-inner";
12
- readonly name: string;
13
- readonly childNodes: readonly AtomToken[];
14
- abstract get children(): AtomToken[];
15
- abstract get firstChild(): AtomToken | undefined;
16
- abstract get firstElementChild(): AtomToken | undefined;
17
- abstract get lastChild(): AtomToken | undefined;
18
- abstract get lastElementChild(): AtomToken | undefined;
19
- abstract get nextSibling(): undefined;
20
- abstract get nextElementSibling(): undefined;
21
- abstract get previousSibling(): AttributesToken;
22
- abstract get previousElementSibling(): AttributesToken;
23
- abstract get parentNode(): ExtToken | undefined;
24
- abstract get parentElement(): ExtToken | undefined;
25
- /** @class */
26
- constructor(wikitext?: string, config?: Parser.Config, accum?: Token[], acceptable?: Acceptable);
27
- /** @override */
28
- text(): string;
29
- /** @override */
30
- lint(start?: number): LintError[];
31
- /** @override */
32
- print(): string;
33
- /** @override */
34
- cloneNode(this: this & {
35
- constructor: new (...args: any[]) => unknown;
36
- }): this;
37
- }