wikiparser-node 1.12.4 → 1.12.5-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 (175) hide show
  1. package/bundle/bundle.min.js +37 -0
  2. package/config/default.json +29 -30
  3. package/config/enwiki.json +15 -829
  4. package/config/llwiki.json +21 -56
  5. package/config/minimum.json +6 -1
  6. package/config/moegirl.json +21 -65
  7. package/config/zhwiki.json +28 -494
  8. package/extensions/dist/base.js +163 -0
  9. package/extensions/dist/codejar.js +52 -0
  10. package/extensions/dist/editor.js +159 -0
  11. package/extensions/dist/highlight.js +30 -0
  12. package/extensions/dist/lint.js +72 -0
  13. package/extensions/editor.css +59 -0
  14. package/extensions/ui.css +162 -0
  15. package/package.json +28 -21
  16. package/config/.schema.json +0 -203
  17. package/dist/addon/table.js +0 -494
  18. package/dist/addon/token.js +0 -392
  19. package/dist/addon/transclude.js +0 -184
  20. package/dist/base.d.ts +0 -81
  21. package/dist/base.js +0 -40
  22. package/dist/index.d.ts +0 -33
  23. package/dist/index.js +0 -275
  24. package/dist/internal.d.ts +0 -47
  25. package/dist/lib/element.d.ts +0 -125
  26. package/dist/lib/element.js +0 -377
  27. package/dist/lib/node.d.ts +0 -173
  28. package/dist/lib/node.js +0 -478
  29. package/dist/lib/range.d.ts +0 -105
  30. package/dist/lib/range.js +0 -406
  31. package/dist/lib/ranges.d.ts +0 -28
  32. package/dist/lib/ranges.js +0 -126
  33. package/dist/lib/rect.d.ts +0 -18
  34. package/dist/lib/rect.js +0 -36
  35. package/dist/lib/text.d.ts +0 -58
  36. package/dist/lib/text.js +0 -414
  37. package/dist/lib/title.d.ts +0 -49
  38. package/dist/lib/title.js +0 -253
  39. package/dist/mixin/attributesParent.d.ts +0 -49
  40. package/dist/mixin/attributesParent.js +0 -80
  41. package/dist/mixin/fixed.d.ts +0 -5
  42. package/dist/mixin/fixed.js +0 -32
  43. package/dist/mixin/flagsParent.d.ts +0 -43
  44. package/dist/mixin/flagsParent.js +0 -64
  45. package/dist/mixin/hidden.d.ts +0 -7
  46. package/dist/mixin/hidden.js +0 -39
  47. package/dist/mixin/magicLinkParent.d.ts +0 -19
  48. package/dist/mixin/magicLinkParent.js +0 -43
  49. package/dist/mixin/singleLine.d.ts +0 -5
  50. package/dist/mixin/singleLine.js +0 -25
  51. package/dist/mixin/sol.d.ts +0 -6
  52. package/dist/mixin/sol.js +0 -45
  53. package/dist/mixin/syntax.d.ts +0 -8
  54. package/dist/mixin/syntax.js +0 -46
  55. package/dist/parser/braces.js +0 -152
  56. package/dist/parser/commentAndExt.js +0 -84
  57. package/dist/parser/converter.js +0 -41
  58. package/dist/parser/externalLinks.js +0 -39
  59. package/dist/parser/hrAndDoubleUnderscore.js +0 -44
  60. package/dist/parser/html.js +0 -40
  61. package/dist/parser/links.js +0 -103
  62. package/dist/parser/list.js +0 -116
  63. package/dist/parser/magicLinks.js +0 -55
  64. package/dist/parser/quotes.js +0 -69
  65. package/dist/parser/redirect.js +0 -28
  66. package/dist/parser/selector.js +0 -393
  67. package/dist/parser/table.js +0 -125
  68. package/dist/src/arg.d.ts +0 -49
  69. package/dist/src/arg.js +0 -219
  70. package/dist/src/atom.d.ts +0 -14
  71. package/dist/src/atom.js +0 -54
  72. package/dist/src/attribute.d.ts +0 -64
  73. package/dist/src/attribute.js +0 -478
  74. package/dist/src/attributes.d.ts +0 -103
  75. package/dist/src/attributes.js +0 -380
  76. package/dist/src/converter.d.ts +0 -28
  77. package/dist/src/converter.js +0 -153
  78. package/dist/src/converterFlags.d.ts +0 -80
  79. package/dist/src/converterFlags.js +0 -241
  80. package/dist/src/converterRule.d.ts +0 -71
  81. package/dist/src/converterRule.js +0 -218
  82. package/dist/src/extLink.d.ts +0 -36
  83. package/dist/src/extLink.js +0 -223
  84. package/dist/src/gallery.d.ts +0 -47
  85. package/dist/src/gallery.js +0 -145
  86. package/dist/src/heading.d.ts +0 -44
  87. package/dist/src/heading.js +0 -222
  88. package/dist/src/hidden.d.ts +0 -9
  89. package/dist/src/hidden.js +0 -82
  90. package/dist/src/html.d.ts +0 -61
  91. package/dist/src/html.js +0 -344
  92. package/dist/src/imageParameter.d.ts +0 -60
  93. package/dist/src/imageParameter.js +0 -262
  94. package/dist/src/imagemap.d.ts +0 -47
  95. package/dist/src/imagemap.js +0 -148
  96. package/dist/src/imagemapLink.d.ts +0 -35
  97. package/dist/src/imagemapLink.js +0 -99
  98. package/dist/src/index.d.ts +0 -136
  99. package/dist/src/index.js +0 -790
  100. package/dist/src/link/base.d.ts +0 -52
  101. package/dist/src/link/base.js +0 -258
  102. package/dist/src/link/category.d.ts +0 -22
  103. package/dist/src/link/category.js +0 -36
  104. package/dist/src/link/file.d.ts +0 -102
  105. package/dist/src/link/file.js +0 -335
  106. package/dist/src/link/galleryImage.d.ts +0 -29
  107. package/dist/src/link/galleryImage.js +0 -133
  108. package/dist/src/link/index.d.ts +0 -39
  109. package/dist/src/link/index.js +0 -100
  110. package/dist/src/link/redirectTarget.d.ts +0 -27
  111. package/dist/src/link/redirectTarget.js +0 -71
  112. package/dist/src/magicLink.d.ts +0 -57
  113. package/dist/src/magicLink.js +0 -261
  114. package/dist/src/nested.d.ts +0 -40
  115. package/dist/src/nested.js +0 -108
  116. package/dist/src/nowiki/base.d.ts +0 -28
  117. package/dist/src/nowiki/base.js +0 -90
  118. package/dist/src/nowiki/comment.d.ts +0 -14
  119. package/dist/src/nowiki/comment.js +0 -123
  120. package/dist/src/nowiki/dd.d.ts +0 -8
  121. package/dist/src/nowiki/dd.js +0 -74
  122. package/dist/src/nowiki/doubleUnderscore.d.ts +0 -15
  123. package/dist/src/nowiki/doubleUnderscore.js +0 -101
  124. package/dist/src/nowiki/hr.d.ts +0 -5
  125. package/dist/src/nowiki/hr.js +0 -72
  126. package/dist/src/nowiki/index.d.ts +0 -14
  127. package/dist/src/nowiki/index.js +0 -30
  128. package/dist/src/nowiki/list.d.ts +0 -5
  129. package/dist/src/nowiki/list.js +0 -67
  130. package/dist/src/nowiki/listBase.d.ts +0 -23
  131. package/dist/src/nowiki/listBase.js +0 -100
  132. package/dist/src/nowiki/noinclude.d.ts +0 -6
  133. package/dist/src/nowiki/noinclude.js +0 -77
  134. package/dist/src/nowiki/quote.d.ts +0 -14
  135. package/dist/src/nowiki/quote.js +0 -149
  136. package/dist/src/onlyinclude.d.ts +0 -13
  137. package/dist/src/onlyinclude.js +0 -60
  138. package/dist/src/paramTag/index.d.ts +0 -28
  139. package/dist/src/paramTag/index.js +0 -80
  140. package/dist/src/paramTag/inputbox.d.ts +0 -8
  141. package/dist/src/paramTag/inputbox.js +0 -24
  142. package/dist/src/parameter.d.ts +0 -60
  143. package/dist/src/parameter.js +0 -267
  144. package/dist/src/pre.d.ts +0 -28
  145. package/dist/src/pre.js +0 -62
  146. package/dist/src/redirect.d.ts +0 -30
  147. package/dist/src/redirect.js +0 -128
  148. package/dist/src/syntax.d.ts +0 -15
  149. package/dist/src/syntax.js +0 -87
  150. package/dist/src/table/base.d.ts +0 -28
  151. package/dist/src/table/base.js +0 -81
  152. package/dist/src/table/index.d.ts +0 -230
  153. package/dist/src/table/index.js +0 -506
  154. package/dist/src/table/td.d.ts +0 -72
  155. package/dist/src/table/td.js +0 -375
  156. package/dist/src/table/tr.d.ts +0 -30
  157. package/dist/src/table/tr.js +0 -61
  158. package/dist/src/table/trBase.d.ts +0 -49
  159. package/dist/src/table/trBase.js +0 -165
  160. package/dist/src/tagPair/ext.d.ts +0 -29
  161. package/dist/src/tagPair/ext.js +0 -217
  162. package/dist/src/tagPair/include.d.ts +0 -33
  163. package/dist/src/tagPair/include.js +0 -132
  164. package/dist/src/tagPair/index.d.ts +0 -23
  165. package/dist/src/tagPair/index.js +0 -130
  166. package/dist/src/transclude.d.ts +0 -159
  167. package/dist/src/transclude.js +0 -598
  168. package/dist/util/constants.js +0 -26
  169. package/dist/util/debug.js +0 -95
  170. package/dist/util/diff.js +0 -83
  171. package/dist/util/html.js +0 -146
  172. package/dist/util/lint.js +0 -32
  173. package/dist/util/string.js +0 -107
  174. package/errors/README +0 -3
  175. package/printed/README +0 -3
@@ -1,125 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.parseTable = void 0;
4
- const index_1 = require("../src/index");
5
- const index_2 = require("../src/table/index");
6
- const tr_1 = require("../src/table/tr");
7
- const td_1 = require("../src/table/td");
8
- const dd_1 = require("../src/nowiki/dd");
9
- /* NOT FOR BROWSER */
10
- const constants_1 = require("../util/constants");
11
- /* NOT FOR BROWSER END */
12
- /**
13
- * 判断是否为表格行或表格
14
- * @param token 表格节点
15
- */
16
- const isTr = (token) => token.lastChild.constructor !== index_1.Token;
17
- /**
18
- * 解析表格,注意`tr`和`td`包含开头的换行
19
- * @param {Token & {firstChild: AstText}} root 根节点
20
- * @param config
21
- * @param accum
22
- */
23
- const parseTable = ({ firstChild: { data }, type, name }, config, accum) => {
24
- const stack = [], lines = data.split('\n');
25
- let out = type === 'root' || type === 'parameter-value' || type === 'ext-inner' && name === 'poem'
26
- ? ''
27
- : `\n${lines.shift()}`, top;
28
- /**
29
- * 向表格中插入纯文本
30
- * @param str 待插入的文本
31
- * @param topToken 当前解析的表格或表格行
32
- */
33
- const push = (str, topToken) => {
34
- if (!topToken) {
35
- out += str;
36
- return;
37
- }
38
- const { lastChild } = topToken;
39
- if (isTr(topToken)) {
40
- const token = new index_1.Token(str, config, accum);
41
- token.type = 'table-inter';
42
- token.setAttribute('stage', 3);
43
- topToken.insertAt(token);
44
- }
45
- else {
46
- lastChild.setText(lastChild.toString() + str);
47
- }
48
- },
49
- /** 取出最近的表格行 */
50
- pop = () => top.type === 'td' ? stack.pop() : top;
51
- for (const outLine of lines) {
52
- top = stack.pop();
53
- const [spaces] = /^(?:\s|\0\d+[cno]\x7F)*/u.exec(outLine), line = outLine.slice(spaces.length), matchesStart = /^(:*)((?:\s|\0\d+[cn]\x7F)*)(\{\||\{(?:\0\d+[cn]\x7F)*\0\d+!\x7F|\0\d+\{\x7F)(.*)$/u
54
- .exec(line);
55
- if (matchesStart) {
56
- while (top && top.type !== 'td') {
57
- top = stack.pop();
58
- }
59
- const [, indent, moreSpaces, tableSyntax, attr] = matchesStart;
60
- if (indent) {
61
- // @ts-expect-error abstract class
62
- new dd_1.DdToken(indent, config, accum);
63
- }
64
- push(`\n${spaces}${indent && `\0${accum.length - 1}d\x7F`}${moreSpaces}\0${accum.length}b\x7F`, top);
65
- // @ts-expect-error abstract class
66
- stack.push(...top ? [top] : [], new index_2.TableToken(tableSyntax, attr, config, accum));
67
- continue;
68
- }
69
- else if (!top) {
70
- out += `\n${outLine}`;
71
- continue;
72
- }
73
- const matches = // eslint-disable-line @stylistic/operator-linebreak
74
- /^(?:(\|\}|\0\d+!\x7F\}|\0\d+\}\x7F)|(\|-+|\0\d+!\x7F-+|\0\d+-\x7F-*)(?!-)|(!|(?:\||\0\d+!\x7F)\+?))(.*)$/u
75
- .exec(line);
76
- if (!matches) {
77
- push(`\n${outLine}`, top);
78
- stack.push(top);
79
- continue;
80
- }
81
- const [, closing, row, cell, attr] = matches;
82
- if (closing) {
83
- while (top.type !== 'table') {
84
- top = stack.pop();
85
- }
86
- top.close(`\n${spaces}${closing}`, true);
87
- push(attr, stack[stack.length - 1]);
88
- }
89
- else if (row) {
90
- top = pop();
91
- if (top.type === 'tr') {
92
- top = stack.pop();
93
- }
94
- // @ts-expect-error abstract class
95
- const tr = new tr_1.TrToken(`\n${spaces}${row}`, attr, config, accum);
96
- stack.push(top, tr);
97
- top.insertAt(tr);
98
- }
99
- else {
100
- top = pop();
101
- const regex = cell === '!' ? /!!|(?:\||\0\d+!\x7F){2}|\0\d+\+\x7F/gu : /(?:\||\0\d+!\x7F){2}|\0\d+\+\x7F/gu;
102
- let mt = regex.exec(attr), lastIndex = 0, lastSyntax = `\n${spaces}${cell}`;
103
- /**
104
- * 创建表格单元格
105
- * @param tr 当前表格行
106
- */
107
- const newTd = (tr) => {
108
- // @ts-expect-error abstract class
109
- const td = new td_1.TdToken(lastSyntax, attr.slice(lastIndex, mt?.index), config, accum);
110
- tr.insertAt(td);
111
- return td;
112
- };
113
- while (mt) {
114
- newTd(top);
115
- ({ lastIndex } = regex);
116
- [lastSyntax] = mt;
117
- mt = regex.exec(attr);
118
- }
119
- stack.push(top, newTd(top));
120
- }
121
- }
122
- return out.slice(1);
123
- };
124
- exports.parseTable = parseTable;
125
- constants_1.parsers['parseTable'] = __filename;
package/dist/src/arg.d.ts DELETED
@@ -1,49 +0,0 @@
1
- import Parser from '../index';
2
- import { Token } from './index';
3
- import { AtomToken } from './atom';
4
- import { HiddenToken } from './hidden';
5
- import type { LintError } from '../base';
6
- /**
7
- * `{{{}}}`包裹的参数
8
- * @classdesc `{childNodes: [AtomToken, ?Token, ...HiddenToken]}`
9
- */
10
- export declare abstract class ArgToken extends Token {
11
- #private;
12
- readonly name: string;
13
- readonly childNodes: readonly [AtomToken] | readonly [AtomToken, Token, ...HiddenToken[]];
14
- abstract get firstChild(): AtomToken;
15
- abstract get lastChild(): Token;
16
- abstract get children(): [AtomToken] | [AtomToken, Token, ...HiddenToken[]];
17
- abstract get firstElementChild(): AtomToken;
18
- abstract get lastElementChild(): Token;
19
- get type(): 'arg';
20
- /** 预设值 */
21
- get default(): string | false;
22
- set default(value: string | false);
23
- /** @param parts 以'|'分隔的各部分 */
24
- constructor(parts: readonly string[], config?: Parser.Config, accum?: Token[]);
25
- cloneNode(): this;
26
- /** 移除无效部分 */
27
- removeRedundant(): void;
28
- /**
29
- * @override
30
- * @param i 移除位置
31
- */
32
- removeAt(i: number): Token;
33
- /**
34
- * @override
35
- * @param token 待插入的子节点
36
- * @param i 插入位置
37
- */
38
- insertAt<T extends Token>(token: T, i?: number): T;
39
- /**
40
- * 设置参数名
41
- * @param name 新参数名
42
- */
43
- setName(name: string): void;
44
- /**
45
- * 设置预设值
46
- * @param value 预设值
47
- */
48
- setDefault(value: string | false): void;
49
- }
package/dist/src/arg.js DELETED
@@ -1,219 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ArgToken = void 0;
4
- const string_1 = require("../util/string");
5
- const lint_1 = require("../util/lint");
6
- const rect_1 = require("../lib/rect");
7
- const index_1 = require("../index");
8
- const index_2 = require("./index");
9
- const atom_1 = require("./atom");
10
- const hidden_1 = require("./hidden");
11
- /* NOT FOR BROWSER */
12
- const constants_1 = require("../util/constants");
13
- const debug_1 = require("../util/debug");
14
- const html_1 = require("../util/html");
15
- /* NOT FOR BROWSER END */
16
- /**
17
- * `{{{}}}`包裹的参数
18
- * @classdesc `{childNodes: [AtomToken, ?Token, ...HiddenToken]}`
19
- */
20
- class ArgToken extends index_2.Token {
21
- /* NOT FOR BROWSER END */
22
- get type() {
23
- return 'arg';
24
- }
25
- /** 预设值 */
26
- get default() {
27
- return this.childNodes[1]?.text() ?? false;
28
- }
29
- /* NOT FOR BROWSER */
30
- set default(value) {
31
- this.setDefault(value);
32
- }
33
- /* NOT FOR BROWSER END */
34
- /** @param parts 以'|'分隔的各部分 */
35
- constructor(parts, config = index_1.default.getConfig(), accum = []) {
36
- super(undefined, config, accum, {
37
- AtomToken: 0, Token: 1, HiddenToken: '2:',
38
- });
39
- for (const [i, part] of parts.entries()) {
40
- if (i === 0) {
41
- const token = new atom_1.AtomToken(part, 'arg-name', config, accum, {
42
- 'Stage-2': ':', '!HeadingToken': '',
43
- });
44
- super.insertAt(token);
45
- }
46
- else if (i > 1) {
47
- const token = new hidden_1.HiddenToken(part, config, accum);
48
- super.insertAt(token);
49
- }
50
- else {
51
- const token = new index_2.Token(part, config, accum);
52
- token.type = 'arg-default';
53
- token.setAttribute('stage', 2);
54
- super.insertAt(token);
55
- }
56
- }
57
- /* NOT FOR BROWSER */
58
- this.protectChildren(0);
59
- }
60
- /** @private */
61
- toString(skip) {
62
- return `{{{${super.toString(skip, '|')}}}}`;
63
- }
64
- /** @private */
65
- text() {
66
- return `{{{${(0, string_1.text)(this.childNodes.slice(0, 2), '|')}}}}`;
67
- }
68
- /** @private */
69
- getAttribute(key) {
70
- return key === 'padding' ? 3 : super.getAttribute(key);
71
- }
72
- /** @private */
73
- getGaps() {
74
- return 1;
75
- }
76
- /** @private */
77
- lint(start = this.getAbsoluteIndex(), re) {
78
- const { childNodes: [argName, argDefault, ...rest] } = this;
79
- if (!this.getAttribute('include')) {
80
- const e = (0, lint_1.generateForSelf)(this, { start }, 'no-arg', 'unexpected template argument');
81
- if (argDefault) {
82
- e.fix = { range: [start, e.endIndex], text: argDefault.text() };
83
- }
84
- return [e];
85
- }
86
- const errors = argName.lint(start + 3, re);
87
- if (argDefault) {
88
- errors.push(...argDefault.lint(start + 4 + argName.toString().length, re));
89
- }
90
- if (rest.length > 0) {
91
- const rect = new rect_1.BoundingRect(this, start);
92
- errors.push(...rest.map(child => {
93
- const e = (0, lint_1.generateForChild)(child, rect, 'no-ignored', 'invisible content inside triple braces');
94
- e.startIndex--;
95
- e.startCol--;
96
- e.suggestions = [
97
- {
98
- desc: 'remove',
99
- range: [e.startIndex, e.endIndex],
100
- text: '',
101
- },
102
- {
103
- desc: 'escape',
104
- range: [e.startIndex, e.startIndex + 1],
105
- text: '{{!}}',
106
- },
107
- ];
108
- return e;
109
- }));
110
- }
111
- return errors;
112
- }
113
- /** @private */
114
- print() {
115
- return super.print({ pre: '{{{', post: '}}}', sep: '|' });
116
- }
117
- /* NOT FOR BROWSER */
118
- cloneNode() {
119
- const [name, ...cloned] = this.cloneChildNodes();
120
- return debug_1.Shadow.run(() => {
121
- // @ts-expect-error abstract class
122
- const token = new ArgToken([''], this.getAttribute('config'));
123
- token.firstChild.safeReplaceWith(name);
124
- token.append(...cloned);
125
- return token;
126
- });
127
- }
128
- /** 设置name */
129
- #setName() {
130
- this.setAttribute('name', this.firstChild.toString(true).trim());
131
- }
132
- /** @private */
133
- afterBuild() {
134
- this.#setName();
135
- super.afterBuild();
136
- const /** @implements */ argListener = ({ prevTarget }) => {
137
- if (prevTarget === this.firstChild) {
138
- this.#setName();
139
- }
140
- };
141
- this.addEventListener(['remove', 'insert', 'replace', 'text'], argListener);
142
- }
143
- /** 移除无效部分 */
144
- removeRedundant() {
145
- debug_1.Shadow.run(() => {
146
- for (let i = this.length - 1; i > 1; i--) {
147
- super.removeAt(i);
148
- }
149
- });
150
- }
151
- /**
152
- * @override
153
- * @param i 移除位置
154
- */
155
- removeAt(i) {
156
- if (i === 1) {
157
- this.removeRedundant();
158
- }
159
- return super.removeAt(i);
160
- }
161
- /**
162
- * @override
163
- * @param token 待插入的子节点
164
- * @param i 插入位置
165
- */
166
- insertAt(token, i = this.length) {
167
- i += i < 0 ? this.length : 0;
168
- if (debug_1.Shadow.running) {
169
- //
170
- }
171
- else if (i > 1) {
172
- this.constructorError('cannot insert redundant child nodes');
173
- }
174
- else if (typeof token === 'string') {
175
- this.constructorError('cannot insert text nodes');
176
- }
177
- super.insertAt(token, i);
178
- if (i === 1) {
179
- token.type = 'arg-default';
180
- }
181
- return token;
182
- }
183
- /**
184
- * 设置参数名
185
- * @param name 新参数名
186
- */
187
- setName(name) {
188
- const { childNodes } = index_1.default.parse(name, this.getAttribute('include'), 2, this.getAttribute('config'));
189
- this.firstChild.replaceChildren(...childNodes);
190
- }
191
- /**
192
- * 设置预设值
193
- * @param value 预设值
194
- */
195
- setDefault(value) {
196
- if (value === false) {
197
- this.removeAt(1);
198
- return;
199
- }
200
- const root = index_1.default.parse(value, this.getAttribute('include'), undefined, this.getAttribute('config')), { childNodes: [, oldDefault] } = this;
201
- if (oldDefault) {
202
- oldDefault.replaceChildren(...root.childNodes);
203
- }
204
- else {
205
- root.type = 'arg-default';
206
- this.insertAt(root);
207
- }
208
- }
209
- /** @private */
210
- toHtmlInternal(nowrap, nocc) {
211
- if (this.length === 1) {
212
- const html = (0, html_1.font)(this, this.toString());
213
- return nowrap ? html.replaceAll('\n', ' ') : html;
214
- }
215
- return (0, html_1.font)(this, this.childNodes[1].toHtmlInternal(nowrap, nocc));
216
- }
217
- }
218
- exports.ArgToken = ArgToken;
219
- constants_1.classes['ArgToken'] = __filename;
@@ -1,14 +0,0 @@
1
- import { Token } from './index';
2
- import type { Config } from '../base';
3
- declare const atomTypes: readonly ["arg-name", "attr-key", "attr-value", "ext-attr-dirty", "html-attr-dirty", "table-attr-dirty", "converter-flag", "converter-rule-variant", "converter-rule-to", "converter-rule-from", "invoke-function", "invoke-module", "template-name", "link-target", "param-line"];
4
- declare type AtomTypes = typeof atomTypes[number];
5
- /** 不会被继续解析的plain Token */
6
- export declare class AtomToken extends Token {
7
- #private;
8
- get type(): AtomTypes;
9
- set type(value: AtomTypes);
10
- /** @class */
11
- constructor(wikitext: string | undefined, type: AtomTypes, config?: Config, accum?: Token[], acceptable?: Acceptable);
12
- cloneNode(): this;
13
- }
14
- export {};
package/dist/src/atom.js DELETED
@@ -1,54 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AtomToken = void 0;
4
- const index_1 = require("./index");
5
- /* NOT FOR BROWSER */
6
- const debug_1 = require("../util/debug");
7
- const constants_1 = require("../util/constants");
8
- /* NOT FOR BROWSER END */
9
- const atomTypes = [
10
- 'arg-name',
11
- 'attr-key',
12
- 'attr-value',
13
- 'ext-attr-dirty',
14
- 'html-attr-dirty',
15
- 'table-attr-dirty',
16
- 'converter-flag',
17
- 'converter-rule-variant',
18
- 'converter-rule-to',
19
- 'converter-rule-from',
20
- 'invoke-function',
21
- 'invoke-module',
22
- 'template-name',
23
- 'link-target',
24
- 'param-line',
25
- ];
26
- /** 不会被继续解析的plain Token */
27
- class AtomToken extends index_1.Token {
28
- #type;
29
- get type() {
30
- return this.#type;
31
- }
32
- set type(value) {
33
- if (!atomTypes.includes(value)) {
34
- throw new RangeError(`"${value}" is not a valid type for AtomToken!`);
35
- }
36
- this.#type = value;
37
- }
38
- /** @class */
39
- constructor(wikitext, type, config, accum, acceptable) {
40
- super(wikitext, config, accum, acceptable);
41
- this.#type = type;
42
- }
43
- /* NOT FOR BROWSER */
44
- cloneNode() {
45
- const cloned = this.cloneChildNodes(), config = this.getAttribute('config'), acceptable = this.getAcceptable();
46
- return debug_1.Shadow.run(() => {
47
- const token = new AtomToken(undefined, this.type, config, [], acceptable);
48
- token.append(...cloned);
49
- return token;
50
- });
51
- }
52
- }
53
- exports.AtomToken = AtomToken;
54
- constants_1.classes['AtomToken'] = __filename;
@@ -1,64 +0,0 @@
1
- import Parser from '../index';
2
- import { Token } from './index';
3
- import { AtomToken } from './atom';
4
- import type { LintError } from '../base';
5
- import type { AttributesToken } from '../internal';
6
- export type AttributeTypes = 'ext-attr' | 'html-attr' | 'table-attr';
7
- /**
8
- * 扩展和HTML标签属性
9
- * @classdesc `{childNodes: [AtomToken, Token|AtomToken]}`
10
- */
11
- export declare abstract class AttributeToken extends Token {
12
- #private;
13
- readonly name: string;
14
- readonly childNodes: readonly [AtomToken, Token];
15
- abstract get firstChild(): AtomToken;
16
- abstract get lastChild(): Token;
17
- abstract get parentNode(): AttributesToken | undefined;
18
- abstract get nextSibling(): AtomToken | this | undefined;
19
- abstract get previousSibling(): AtomToken | this | undefined;
20
- abstract get children(): [AtomToken, Token];
21
- abstract get firstElementChild(): AtomToken;
22
- abstract get lastElementChild(): Token;
23
- abstract get parentElement(): AttributesToken | undefined;
24
- abstract get nextElementSibling(): AtomToken | this | undefined;
25
- abstract get previousElementSibling(): AtomToken | this | undefined;
26
- get type(): AttributeTypes;
27
- /** 标签名 */
28
- get tag(): string;
29
- /** 引号是否匹配 */
30
- get balanced(): boolean;
31
- set balanced(value: boolean);
32
- /** getValue()的getter */
33
- get value(): string | true;
34
- set value(value: string | true);
35
- /**
36
- * @param type 标签类型
37
- * @param tag 标签名
38
- * @param key 属性名
39
- * @param equal 等号
40
- * @param value 属性值
41
- * @param quotes 引号
42
- */
43
- constructor(type: AttributeTypes, tag: string, key: string, equal?: string, value?: string, quotes?: readonly [string?, string?], config?: Parser.Config, accum?: Token[]);
44
- /** 获取属性值 */
45
- getValue(): string | true;
46
- cloneNode(): this;
47
- /** 转义等号 */
48
- escape(): void;
49
- /** 闭合引号 */
50
- close(): void;
51
- /**
52
- * 设置属性值
53
- * @param value 参数值
54
- * @throws `RangeError` 扩展标签属性不能包含 ">"
55
- * @throws `RangeError` 同时包含单引号和双引号
56
- */
57
- setValue(value: string | boolean): void;
58
- /**
59
- * 修改属性名
60
- * @param key 新属性名
61
- * @throws `Error` title和alt属性不能更名
62
- */
63
- rename(key: string): void;
64
- }