wikiparser-node 0.10.0 → 0.11.0-m

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 (155) hide show
  1. package/README.md +44 -32
  2. package/config/.schema.json +1 -8
  3. package/config/default.json +1 -2
  4. package/config/llwiki.json +1 -36
  5. package/config/moegirl.json +1 -45
  6. package/config/zhwiki.json +1 -467
  7. package/dist/index.d.ts +110 -0
  8. package/dist/lib/element.d.ts +48 -0
  9. package/dist/lib/node.d.ts +108 -0
  10. package/dist/lib/text.d.ts +30 -0
  11. package/dist/lib/title.d.ts +15 -0
  12. package/dist/mixin/hidden.d.ts +8 -0
  13. package/dist/parser/brackets.d.ts +12 -0
  14. package/dist/parser/commentAndExt.d.ts +8 -0
  15. package/dist/parser/converter.d.ts +7 -0
  16. package/dist/parser/externalLinks.d.ts +7 -0
  17. package/dist/parser/hrAndDoubleUnderscore.d.ts +11 -0
  18. package/dist/parser/html.d.ts +7 -0
  19. package/dist/parser/links.d.ts +7 -0
  20. package/dist/parser/list.d.ts +7 -0
  21. package/dist/parser/magicLinks.d.ts +7 -0
  22. package/dist/parser/quotes.d.ts +7 -0
  23. package/dist/parser/table.d.ts +11 -0
  24. package/dist/src/arg.d.ts +25 -0
  25. package/dist/src/atom/hidden.d.ts +5 -0
  26. package/dist/src/atom/index.d.ts +14 -0
  27. package/dist/src/attribute.d.ts +42 -0
  28. package/dist/src/attributes.d.ts +33 -0
  29. package/dist/src/converter.d.ts +29 -0
  30. package/dist/src/converterFlags.d.ts +27 -0
  31. package/dist/src/converterRule.d.ts +29 -0
  32. package/dist/src/extLink.d.ts +22 -0
  33. package/dist/src/gallery.d.ts +19 -0
  34. package/dist/src/hasNowiki/index.d.ts +14 -0
  35. package/dist/src/hasNowiki/pre.d.ts +13 -0
  36. package/dist/src/heading.d.ts +24 -0
  37. package/dist/src/html.d.ts +33 -0
  38. package/dist/src/imageParameter.d.ts +23 -0
  39. package/dist/src/imagemap.d.ts +26 -0
  40. package/dist/src/imagemapLink.d.ts +16 -0
  41. package/dist/src/index.d.ts +53 -0
  42. package/dist/src/link/category.d.ts +8 -0
  43. package/dist/src/link/file.d.ts +27 -0
  44. package/dist/src/link/galleryImage.d.ts +15 -0
  45. package/dist/src/link/index.d.ts +29 -0
  46. package/dist/src/magicLink.d.ts +14 -0
  47. package/dist/src/nested/choose.d.ts +13 -0
  48. package/dist/src/nested/combobox.d.ts +13 -0
  49. package/dist/src/nested/index.d.ts +20 -0
  50. package/dist/src/nested/references.d.ts +13 -0
  51. package/dist/src/nowiki/comment.d.ts +19 -0
  52. package/dist/src/nowiki/dd.d.ts +8 -0
  53. package/dist/src/nowiki/doubleUnderscore.d.ts +12 -0
  54. package/dist/src/nowiki/hr.d.ts +13 -0
  55. package/dist/src/nowiki/index.d.ts +18 -0
  56. package/dist/src/nowiki/list.d.ts +8 -0
  57. package/dist/src/nowiki/noinclude.d.ts +8 -0
  58. package/dist/src/nowiki/quote.d.ts +20 -0
  59. package/dist/src/onlyinclude.d.ts +17 -0
  60. package/dist/src/paramTag/index.d.ts +24 -0
  61. package/dist/src/paramTag/inputbox.d.ts +8 -0
  62. package/dist/src/parameter.d.ts +28 -0
  63. package/dist/src/syntax.d.ts +15 -0
  64. package/dist/src/table/index.d.ts +16 -0
  65. package/dist/src/table/td.d.ts +39 -0
  66. package/dist/src/table/tr.d.ts +17 -0
  67. package/dist/src/tagPair/ext.d.ts +17 -0
  68. package/dist/src/tagPair/include.d.ts +16 -0
  69. package/dist/src/tagPair/index.d.ts +28 -0
  70. package/dist/src/transclude.d.ts +75 -0
  71. package/dist/util/lint.d.ts +28 -0
  72. package/dist/util/string.d.ts +31 -0
  73. package/i18n/zh-hans.json +1 -1
  74. package/i18n/zh-hant.json +1 -1
  75. package/index.js +5 -257
  76. package/lib/element.js +7 -482
  77. package/lib/node.js +11 -540
  78. package/lib/text.js +3 -96
  79. package/lib/title.js +1 -28
  80. package/mixin/hidden.js +0 -3
  81. package/package.json +11 -5
  82. package/parser/brackets.js +3 -2
  83. package/parser/commentAndExt.js +8 -6
  84. package/parser/converter.js +1 -2
  85. package/parser/externalLinks.js +1 -2
  86. package/parser/hrAndDoubleUnderscore.js +1 -2
  87. package/parser/html.js +1 -2
  88. package/parser/links.js +5 -6
  89. package/parser/list.js +1 -2
  90. package/parser/magicLinks.js +1 -2
  91. package/parser/quotes.js +1 -2
  92. package/parser/table.js +1 -2
  93. package/src/arg.js +4 -118
  94. package/src/atom/hidden.js +0 -2
  95. package/src/atom/index.js +1 -18
  96. package/src/attribute.js +6 -190
  97. package/src/attributes.js +5 -308
  98. package/src/converter.js +3 -109
  99. package/src/converterFlags.js +1 -188
  100. package/src/converterRule.js +2 -184
  101. package/src/extLink.js +2 -122
  102. package/src/gallery.js +2 -56
  103. package/src/hasNowiki/index.js +1 -13
  104. package/src/hasNowiki/pre.js +1 -13
  105. package/src/heading.js +4 -55
  106. package/src/html.js +5 -120
  107. package/src/imageParameter.js +3 -165
  108. package/src/imagemap.js +3 -62
  109. package/src/imagemapLink.js +2 -14
  110. package/src/index.js +9 -530
  111. package/src/link/category.js +1 -32
  112. package/src/link/file.js +3 -158
  113. package/src/link/galleryImage.js +3 -61
  114. package/src/link/index.js +4 -273
  115. package/src/magicLink.js +6 -87
  116. package/src/nested/choose.js +1 -2
  117. package/src/nested/combobox.js +1 -2
  118. package/src/nested/index.js +8 -32
  119. package/src/nested/references.js +1 -2
  120. package/src/nowiki/comment.js +2 -26
  121. package/src/nowiki/dd.js +1 -47
  122. package/src/nowiki/doubleUnderscore.js +1 -31
  123. package/src/nowiki/hr.js +2 -21
  124. package/src/nowiki/index.js +2 -24
  125. package/src/nowiki/list.js +2 -5
  126. package/src/nowiki/noinclude.js +0 -14
  127. package/src/nowiki/quote.js +2 -16
  128. package/src/onlyinclude.js +2 -27
  129. package/src/paramTag/index.js +2 -25
  130. package/src/paramTag/inputbox.js +2 -5
  131. package/src/parameter.js +6 -148
  132. package/src/syntax.js +1 -69
  133. package/src/table/index.js +2 -939
  134. package/src/table/td.js +6 -226
  135. package/src/table/tr.js +3 -248
  136. package/src/tagPair/ext.js +4 -23
  137. package/src/tagPair/include.js +1 -25
  138. package/src/tagPair/index.js +3 -52
  139. package/src/transclude.js +6 -513
  140. package/typings/api.d.ts +9 -0
  141. package/typings/index.d.ts +51 -0
  142. package/typings/node.d.ts +16 -0
  143. package/typings/parser.d.ts +5 -0
  144. package/typings/token.d.ts +28 -0
  145. package/util/lint.js +2 -0
  146. package/util/string.js +0 -51
  147. package/lib/ranges.js +0 -130
  148. package/mixin/attributeParent.js +0 -117
  149. package/mixin/fixedToken.js +0 -40
  150. package/mixin/singleLine.js +0 -31
  151. package/mixin/sol.js +0 -54
  152. package/parser/selector.js +0 -177
  153. package/src/charinsert.js +0 -97
  154. package/tool/index.js +0 -1202
  155. package/util/debug.js +0 -73
@@ -1,7 +1,6 @@
1
1
  'use strict';
2
2
 
3
3
  const {generateForChild} = require('../../util/lint'),
4
- singleLine = require('../../mixin/singleLine'),
5
4
  Parser = require('../..'),
6
5
  Token = require('..'),
7
6
  AtomToken = require('../atom');
@@ -15,17 +14,15 @@ class ParamTagToken extends Token {
15
14
 
16
15
  /**
17
16
  * @param {string} wikitext wikitext
18
- * @param {accum} accum
17
+ * @param {import('../../typings/token').accum} accum
19
18
  */
20
19
  constructor(wikitext, config = Parser.getConfig(), accum = []) {
21
20
  super(undefined, config, true, accum, {
22
- SingleLineAtomToken: ':',
23
21
  });
24
22
  if (wikitext) {
25
- const SingleLineAtomToken = singleLine(AtomToken);
23
+ const SingleLineAtomToken = AtomToken;
26
24
  this.append(
27
25
  ...wikitext.split('\n').map(line => new SingleLineAtomToken(line, 'param-line', config, accum, {
28
- AstText: ':',
29
26
  })),
30
27
  );
31
28
  }
@@ -33,7 +30,6 @@ class ParamTagToken extends Token {
33
30
 
34
31
  /**
35
32
  * @override
36
- * @param {string} selector
37
33
  */
38
34
  toString(selector) {
39
35
  return super.toString(selector, '\n');
@@ -49,11 +45,6 @@ class ParamTagToken extends Token {
49
45
  return 1;
50
46
  }
51
47
 
52
- /** @override */
53
- print() {
54
- return super.print({sep: '\n'});
55
- }
56
-
57
48
  /**
58
49
  * @override
59
50
  * @param {number} start 起始位置
@@ -70,20 +61,6 @@ class ParamTagToken extends Token {
70
61
  return generateForChild(child, rect, Parser.msg('invalid parameter of $1', this.name));
71
62
  });
72
63
  }
73
-
74
- /**
75
- * @override
76
- * @this {ParamTagToken & {constructor: typeof ParamTagToken}}
77
- */
78
- cloneNode() {
79
- const cloned = this.cloneChildNodes();
80
- return Parser.run(() => {
81
- const token = new this.constructor(undefined, this.getAttribute('config'));
82
- token.append(...cloned);
83
- return token;
84
- });
85
- }
86
64
  }
87
65
 
88
- Parser.classes.ParamTagToken = __filename;
89
66
  module.exports = ParamTagToken;
@@ -1,7 +1,6 @@
1
1
  'use strict';
2
2
 
3
3
  const parseBrackets = require('../../parser/brackets'),
4
- singleLine = require('../../mixin/singleLine'),
5
4
  Parser = require('../..'),
6
5
  ParamTagToken = require('.'),
7
6
  AtomToken = require('../atom');
@@ -15,7 +14,7 @@ class InputboxToken extends ParamTagToken {
15
14
 
16
15
  /**
17
16
  * @param {string} wikitext wikitext
18
- * @param {accum} accum
17
+ * @param {import('../../typings/token').accum} accum
19
18
  */
20
19
  constructor(wikitext, config = Parser.getConfig(), accum = []) {
21
20
  super(undefined, config, accum);
@@ -23,13 +22,11 @@ class InputboxToken extends ParamTagToken {
23
22
  accum.splice(accum.indexOf(this), 1);
24
23
  accum.push(this);
25
24
  if (wikitext) {
26
- const SingleLineAtomToken = singleLine(AtomToken);
25
+ const SingleLineAtomToken = AtomToken;
27
26
  this.append(...wikitext.split('\n').map(line => new SingleLineAtomToken(line, 'param-line', config, accum, {
28
- AstText: ':', ArgToken: ':', TranscludeToken: ':',
29
27
  })));
30
28
  }
31
29
  }
32
30
  }
33
31
 
34
- Parser.classes.InputboxToken = __filename;
35
32
  module.exports = InputboxToken;
package/src/parameter.js CHANGED
@@ -1,8 +1,7 @@
1
1
  'use strict';
2
2
 
3
- const {noWrap, extUrlChar, extUrlCharFirst} = require('../util/string'),
3
+ const {extUrlChar, extUrlCharFirst} = require('../util/string'),
4
4
  {generateForChild} = require('../util/lint'),
5
- fixedToken = require('../mixin/fixedToken'),
6
5
  Parser = require('..'),
7
6
  Token = require('.');
8
7
 
@@ -10,7 +9,7 @@ const {noWrap, extUrlChar, extUrlCharFirst} = require('../util/string'),
10
9
  * 模板或魔术字参数
11
10
  * @classdesc `{childNodes: [Token, Token]}`
12
11
  */
13
- class ParameterToken extends fixedToken(Token) {
12
+ class ParameterToken extends Token {
14
13
  type = 'parameter';
15
14
 
16
15
  /** 是否是匿名参数 */
@@ -18,37 +17,14 @@ class ParameterToken extends fixedToken(Token) {
18
17
  return this.firstChild.length === 0;
19
18
  }
20
19
 
21
- /** getValue()的getter */
22
- get value() {
23
- return this.getValue();
24
- }
25
-
26
- set value(value) {
27
- this.setValue(value);
28
- }
29
-
30
- /**
31
- * 是否是重复参数
32
- * @this {ParameterToken & {parentNode: TranscludeToken}}
33
- */
34
- get duplicated() {
35
- const TranscludeToken = require('./transclude');
36
- try {
37
- return Boolean(this.parentNode?.getDuplicatedArgs()?.some(([key]) => key === this.name));
38
- } catch {
39
- return false;
40
- }
41
- }
42
-
43
20
  /**
44
21
  * @param {string|number} key 参数名
45
22
  * @param {string} value 参数值
46
- * @param {accum} accum
23
+ * @param {import('../typings/token').accum} accum
47
24
  */
48
25
  constructor(key, value, config = Parser.getConfig(), accum = []) {
49
26
  super(undefined, config, true, accum);
50
27
  const keyToken = new Token(typeof key === 'number' ? undefined : key, config, true, accum, {
51
- 'Stage-11': ':', '!HeadingToken': '',
52
28
  }),
53
29
  token = new Token(value, config, true, accum);
54
30
  keyToken.type = 'parameter-key';
@@ -60,37 +36,22 @@ class ParameterToken extends fixedToken(Token) {
60
36
  afterBuild() {
61
37
  if (!this.anon) {
62
38
  const TranscludeToken = require('./transclude');
63
- const name = this.firstChild.toString('comment, noinclude, include')
39
+ const name = String(this.firstChild).replace(/<!--.*?-->/gsu, '')
64
40
  .replace(/^[ \t\n\0\v]+|(?<=[^ \t\n\0\v])[ \t\n\0\v]+$/gu, ''),
65
41
  {parentNode} = this;
66
42
  this.setAttribute('name', name);
67
43
  if (parentNode instanceof TranscludeToken) {
68
- parentNode.getAttribute('keys').add(name);
69
44
  parentNode.getArgs(name, false, false).add(this);
70
45
  }
71
46
  }
72
- const /** @type {AstListener} */ parameterListener = ({prevTarget}, data) => {
73
- if (!this.anon) { // 匿名参数不管怎么变动还是匿名
74
- const {firstChild, name} = this;
75
- if (prevTarget === firstChild) {
76
- const newKey = firstChild.toString('comment, noinclude, include')
77
- .replace(/^[ \t\n\0\v]+|(?<=[^ \t\n\0\v])[ \t\n\0\v]+$/gu, '');
78
- data.oldKey = name;
79
- data.newKey = newKey;
80
- this.setAttribute('name', newKey);
81
- }
82
- }
83
- };
84
- this.addEventListener(['remove', 'insert', 'replace', 'text'], parameterListener);
85
47
  }
86
48
 
87
49
  /**
88
50
  * @override
89
- * @param {string} selector
90
51
  * @returns {string}
91
52
  */
92
53
  toString(selector) {
93
- return this.anon && !(selector && this.matches(selector))
54
+ return this.anon
94
55
  ? this.lastChild.toString(selector)
95
56
  : super.toString(selector, '=');
96
57
  }
@@ -108,11 +69,6 @@ class ParameterToken extends fixedToken(Token) {
108
69
  return this.anon ? 0 : 1;
109
70
  }
110
71
 
111
- /** @override */
112
- print() {
113
- return super.print({sep: this.anon ? '' : '='});
114
- }
115
-
116
72
  /**
117
73
  * @override
118
74
  * @param {number} start 起始位置
@@ -121,7 +77,7 @@ class ParameterToken extends fixedToken(Token) {
121
77
  const errors = super.lint(start),
122
78
  {firstChild, lastChild} = this,
123
79
  link = new RegExp(`https?://${extUrlCharFirst}${extUrlChar}$`, 'iu')
124
- .exec(firstChild.toString('comment, noinclude, include'))?.[0];
80
+ .exec(String(firstChild).replace(/<!--.*?-->/gsu, ''))?.[0];
125
81
  if (link && new URL(link).search) {
126
82
  const e = generateForChild(firstChild, {start}, 'unescaped query string in an anonymous parameter');
127
83
  errors.push({
@@ -136,104 +92,6 @@ class ParameterToken extends fixedToken(Token) {
136
92
  }
137
93
  return errors;
138
94
  }
139
-
140
- /**
141
- * 获取参数值
142
- * @this {ParameterToken & {parentNode: TranscludeToken}}
143
- */
144
- getValue() {
145
- const TranscludeToken = require('./transclude');
146
- const value = this.lastChild.text();
147
- return this.anon && this.parentNode?.isTemplate() ? value : value.trim();
148
- }
149
-
150
- /** @override */
151
- cloneNode() {
152
- const [key, value] = this.cloneChildNodes(),
153
- config = this.getAttribute('config');
154
- return Parser.run(() => {
155
- const token = new ParameterToken(this.anon ? Number(this.name) : undefined, undefined, config);
156
- token.firstChild.safeReplaceWith(key);
157
- token.lastChild.safeReplaceWith(value);
158
- token.afterBuild();
159
- return token;
160
- });
161
- }
162
-
163
- /**
164
- * @override
165
- * @param {ParameterToken} token 待替换的节点
166
- * @complexity `n`
167
- */
168
- safeReplaceWith(token) {
169
- Parser.warn(`${this.constructor.name}.safeReplaceWith 方法退化到 replaceWith。`);
170
- return this.replaceWith(token);
171
- }
172
-
173
- /**
174
- * 设置参数值
175
- * @this {ParameterToken & {parentNode: TranscludeToken}}
176
- * @param {string} value 参数值
177
- * @throws `SyntaxError` 非法的模板参数
178
- */
179
- setValue(value) {
180
- value = String(value);
181
- const TranscludeToken = require('./transclude');
182
- const templateLike = this.parentNode?.isTemplate(),
183
- wikitext = `{{${templateLike ? ':T|' : 'lc:'}${this.anon ? '' : '1='}${value}}}`,
184
- root = Parser.parse(wikitext, this.getAttribute('include'), 2, this.getAttribute('config')),
185
- {length, firstChild: transclude} = root,
186
- /** @type {Token & {lastChild: ParameterToken}} */
187
- {lastChild: parameter, type, name, length: transcludeLength} = transclude,
188
- targetType = templateLike ? 'template' : 'magic-word',
189
- targetName = templateLike ? 'T' : 'lc';
190
- if (length !== 1 || type !== targetType || name !== targetName || transcludeLength !== 2
191
- || parameter.anon !== this.anon || parameter.name !== '1'
192
- ) {
193
- throw new SyntaxError(`非法的模板参数:${noWrap(value)}`);
194
- }
195
- const {lastChild} = parameter;
196
- parameter.destroy(true);
197
- this.lastChild.safeReplaceWith(lastChild);
198
- }
199
-
200
- /**
201
- * 修改参数名
202
- * @this {ParameterToken & {parentNode: TranscludeToken}}
203
- * @param {string} key 新参数名
204
- * @param {boolean} force 是否无视冲突命名
205
- * @throws `Error` 仅用于模板参数
206
- * @throws `SyntaxError` 非法的模板参数名
207
- * @throws `RangeError` 更名造成重复参数
208
- */
209
- rename(key, force) {
210
- key = String(key);
211
- const TranscludeToken = require('./transclude');
212
- const {parentNode} = this;
213
- // 必须检测是否是TranscludeToken
214
- if (!parentNode?.isTemplate() || !(parentNode instanceof TranscludeToken)) {
215
- throw new Error(`${this.constructor.name}.rename 方法仅用于模板参数!`);
216
- }
217
- const root = Parser.parse(`{{:T|${key}=}}`, this.getAttribute('include'), 2, this.getAttribute('config')),
218
- {length, firstChild: template} = root,
219
- {type, name, lastChild: parameter, length: templateLength} = template;
220
- if (length !== 1 || type !== 'template' || name !== 'T' || templateLength !== 2) {
221
- throw new SyntaxError(`非法的模板参数名:${key}`);
222
- }
223
- const {name: parameterName, firstChild} = parameter;
224
- if (this.name === parameterName) {
225
- Parser.warn('未改变实际参数名', parameterName);
226
- } else if (parentNode.hasArg(parameterName)) {
227
- if (force) {
228
- Parser.warn('参数更名造成重复参数', parameterName);
229
- } else {
230
- throw new RangeError(`参数更名造成重复参数:${parameterName}`);
231
- }
232
- }
233
- parameter.destroy(true);
234
- this.firstChild.safeReplaceWith(firstChild);
235
- }
236
95
  }
237
96
 
238
- Parser.classes.ParameterToken = __filename;
239
97
  module.exports = ParameterToken;
package/src/syntax.js CHANGED
@@ -1,8 +1,6 @@
1
1
  'use strict';
2
2
 
3
3
  const Parser = require('..'),
4
- {undo} = require('../util/debug'),
5
- {text} = require('../util/string'),
6
4
  Token = require('.');
7
5
 
8
6
  /**
@@ -10,82 +8,16 @@ const Parser = require('..'),
10
8
  * @classdesc `{childNodes: ...AstText|Token}`
11
9
  */
12
10
  class SyntaxToken extends Token {
13
- #pattern;
14
-
15
11
  /**
16
12
  * @param {string} wikitext 语法wikitext
17
13
  * @param {RegExp} pattern 语法正则
18
14
  * @param {string} type Token.type
19
- * @param {accum} accum
20
- * @param {acceptable} acceptable 可接受的子节点设置
21
- * @throws `RangeError` 含有g修饰符的语法正则
15
+ * @param {import('../typings/token').accum} accum
22
16
  */
23
17
  constructor(wikitext, pattern, type = 'plain', config = Parser.getConfig(), accum = [], acceptable = undefined) {
24
- if (pattern.global) {
25
- throw new RangeError(`SyntaxToken 的语法正则不能含有 g 修饰符:${pattern}`);
26
- }
27
18
  super(wikitext, config, true, accum, acceptable);
28
19
  this.type = type;
29
- this.#pattern = pattern;
30
- }
31
-
32
- /** @override */
33
- cloneNode() {
34
- const cloned = this.cloneChildNodes(),
35
- config = this.getAttribute('config'),
36
- acceptable = this.getAttribute('acceptable');
37
- return Parser.run(() => {
38
- const token = new SyntaxToken(undefined, this.#pattern, this.type, config, [], acceptable);
39
- token.append(...cloned);
40
- token.afterBuild();
41
- return token;
42
- });
43
- }
44
-
45
- /** @override */
46
- afterBuild() {
47
- const /** @type {AstListener} */ syntaxListener = (e, data) => {
48
- const pattern = this.#pattern;
49
- if (!Parser.running && !pattern.test(this.text())) {
50
- undo(e, data);
51
- Parser.error(`不可修改 ${this.constructor.name} 的语法!`, pattern);
52
- throw new Error(`不可修改 ${this.constructor.name} 的语法!`);
53
- }
54
- };
55
- this.addEventListener(['remove', 'insert', 'replace', 'text'], syntaxListener);
56
- }
57
-
58
- /**
59
- * @override
60
- * @template {string} T
61
- * @param {T} key 属性键
62
- * @returns {TokenAttribute<T>}
63
- */
64
- getAttribute(key) {
65
- return key === 'pattern' ? this.#pattern : super.getAttribute(key);
66
- }
67
-
68
- /**
69
- * @override
70
- * @param {PropertyKey} key 属性键
71
- */
72
- hasAttribute(key) {
73
- return key === 'pattern' || super.hasAttribute(key);
74
- }
75
-
76
- /**
77
- * @override
78
- * @param {...Token} elements 待替换的子节点
79
- * @complexity `n`
80
- */
81
- replaceChildren(...elements) {
82
- if (this.#pattern.test(text(elements))) {
83
- Parser.run(() => {
84
- super.replaceChildren(...elements);
85
- });
86
- }
87
20
  }
88
21
  }
89
22
 
90
- Parser.classes.SyntaxToken = __filename;
91
23
  module.exports = SyntaxToken;