wikiparser-node 1.42.0 → 1.43.0

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.
@@ -26,10 +26,10 @@ const format = (token) => {
26
26
  transclude_1.TranscludeToken.prototype.newAnonArg =
27
27
  /** @implements */
28
28
  function (val, newline) {
29
- const { childNodes } = index_1.default.parseWithRef(val, this), token = debug_1.Shadow.run(
29
+ const token = debug_1.Shadow.run(
30
30
  // @ts-expect-error abstract class
31
31
  () => new parameter_1.ParameterToken(undefined, undefined, this.getAttribute('config')));
32
- token.lastChild.concat(childNodes); // eslint-disable-line unicorn/prefer-spread
32
+ token.lastChild.concat(index_1.default.parseWithRef(val, this).childNodes); // eslint-disable-line unicorn/prefer-spread
33
33
  if (newline) {
34
34
  format(this);
35
35
  }
@@ -47,11 +47,12 @@ transclude_1.TranscludeToken.prototype.setValue =
47
47
  arg.setValue(value);
48
48
  return;
49
49
  }
50
- const k = index_1.default.parseWithRef(key, this), v = index_1.default.parseWithRef(value, this), token = debug_1.Shadow.run(
50
+ const token = debug_1.Shadow.run(
51
51
  // @ts-expect-error abstract class
52
52
  () => new parameter_1.ParameterToken(undefined, undefined, this.getAttribute('config')));
53
- token.firstChild.safeAppend([...k.childNodes]);
54
- token.lastChild.concat(v.childNodes); // eslint-disable-line unicorn/prefer-spread
53
+ token.firstChild.safeAppend(index_1.default.parseWithRef(key, this).childNodes);
54
+ // eslint-disable-next-line unicorn/prefer-spread
55
+ token.lastChild.concat(index_1.default.parseWithRef(value, this).childNodes);
55
56
  if (newline) {
56
57
  format(this);
57
58
  }
@@ -65,41 +66,30 @@ transclude_1.TranscludeToken.prototype.replaceTemplate =
65
66
  if (type === 'magic-word') {
66
67
  throw new Error('TranscludeToken.replaceTemplate method is only for templates!');
67
68
  }
68
- const { childNodes } = index_1.default.parseWithRef(title, this, 2);
69
- firstChild.safeReplaceChildren(childNodes);
69
+ firstChild.safeReplaceChildren(index_1.default.parseWithRef(title, this, 2).childNodes);
70
70
  };
71
71
  transclude_1.TranscludeToken.prototype.replaceModule =
72
72
  /** @implements */
73
73
  function (title) {
74
- const { type, name, length, childNodes: [, mod] } = this;
74
+ const { type, name, childNodes: [, mod] } = this;
75
75
  /* c8 ignore next 3 */
76
76
  if (type !== 'magic-word' || name !== 'invoke') {
77
77
  throw new Error('TranscludeToken.replaceModule method is only for modules!');
78
78
  }
79
- if (length === 1) {
80
- index_2.Token.prototype.insertAt.call(this, debug_1.Shadow.run(() => new atom_1.AtomToken(undefined, 'invoke-module', this.getAttribute('config'), [], { 'Stage-1': ':', '!ExtToken': '' })));
81
- return;
82
- }
83
- const { childNodes } = index_1.default.parseWithRef(title, this, 2);
84
- mod.safeReplaceChildren(childNodes);
79
+ mod.safeReplaceChildren(index_1.default.parseWithRef(title, this, 2).childNodes);
85
80
  };
86
81
  transclude_1.TranscludeToken.prototype.replaceFunction =
87
82
  /** @implements */
88
83
  function (func) {
89
- const { type, name, length, childNodes: [, , fun] } = this;
84
+ const { type, name, length } = this;
90
85
  /* c8 ignore next 6 */
91
86
  if (type !== 'magic-word' || name !== 'invoke') {
92
87
  throw new Error('TranscludeToken.replaceModule method is only for modules!');
93
88
  }
94
- if (length < 2) {
95
- throw new Error('No module name specified!');
96
- }
97
- if (length === 2) {
98
- index_2.Token.prototype.insertAt.call(this, debug_1.Shadow.run(() => new atom_1.AtomToken(undefined, 'invoke-function', this.getAttribute('config'), [], { 'Stage-1': ':', '!ExtToken': '' })));
99
- return;
89
+ else if (length === 2) {
90
+ index_2.Token.prototype.insertAt.call(this, debug_1.Shadow.run(() => new atom_1.AtomToken(undefined, 'invoke-function', this.getAttribute('config'), [], { 'Stage-2': ':', '!ExtToken': '', '!HeadingToken': '' })));
100
91
  }
101
- const { childNodes } = index_1.default.parseWithRef(func, this, 2);
102
- fun.safeReplaceChildren(childNodes);
92
+ this.childNodes[2].safeReplaceChildren(index_1.default.parseWithRef(func, this, 2).childNodes);
103
93
  };
104
94
  transclude_1.TranscludeToken.prototype.fixDuplication =
105
95
  /** @implements */
@@ -168,11 +158,11 @@ transclude_1.TranscludeToken.prototype.fixDuplication =
168
158
  }
169
159
  }
170
160
  if (remaining > 1) {
171
- index_1.default.error(`${this.type === 'template'
161
+ index_1.default.error(`${JSON.stringify(this.type === 'template'
172
162
  ? this.name
173
- : this.normalizeTitle(`Module:${this.childNodes[1].text()}`, 828, { temporary: true, page: '' }).title} still has ${remaining} duplicated ${key} parameters:\n${[...this.getArgs(key)].map(arg => {
163
+ : this.normalizeTitle(`Module:${this.childNodes[1].text()}`, 828, { temporary: true, page: '' }).title)} still has ${remaining} duplicated ${JSON.stringify(key)} parameters:\n${[...this.getArgs(key)].map(arg => {
174
164
  const { top, left } = arg.getBoundingClientRect();
175
- return `Line ${String(top)} Column ${String(left)}`;
165
+ return `Line ${top} Column ${left}`;
176
166
  }).join('\n')}`);
177
167
  duplicatedKeys.push(key);
178
168
  }
@@ -40,7 +40,7 @@ const filterGadget = (id) => {
40
40
  const n = Number(id);
41
41
  return n < 2300 || n > 2303; // Gadget, Gadget talk, Gadget definition, Gadget definition talk
42
42
  };
43
- const pkg = "wikiparser-node", version = "1.42.0";
43
+ const pkg = "wikiparser-node", version = "1.43.0";
44
44
  /**
45
45
  * Get the parser configuration for a Wikimedia Foundation project.
46
46
  * @param site site nickname
@@ -78,7 +78,7 @@ declare global {
78
78
  dones: Set<string>,
79
79
  key: string,
80
80
  ) => void;
81
- type HideOptGroup = (optgroup: HTMLOptGroupElement) => void;
81
+ type HideOptGroup = (optgroup?: HTMLOptGroupElement) => void;
82
82
  type AddOption = (
83
83
  optgroup: HTMLOptGroupElement | undefined,
84
84
  select: HTMLSelectElement,
@@ -9,19 +9,19 @@ const common_1 = require("@bhsd/common");
9
9
  const constants_1 = require("../util/constants");
10
10
  /* NOT FOR BROWSER */
11
11
  const constants_2 = require("../util/constants");
12
- let texcvjs;
12
+ let texvcjs;
13
13
  const loadTexvcjs = () => {
14
14
  NPM: {
15
- if (texcvjs === undefined) {
15
+ if (texvcjs === undefined) {
16
16
  try {
17
- texcvjs = require('mathoid-texvcjs');
17
+ texvcjs = require('mathoid-texvcjs');
18
18
  }
19
19
  catch /* c8 ignore start */ {
20
- texcvjs = null;
20
+ texvcjs = null;
21
21
  }
22
22
  /* c8 ignore stop */
23
23
  }
24
- return texcvjs;
24
+ return texvcjs;
25
25
  }
26
26
  };
27
27
  exports.loadTexvcjs = loadTexvcjs;
@@ -47,13 +47,13 @@ class Range {
47
47
  .exec(str);
48
48
  /* c8 ignore next 3 */
49
49
  if (!mt) {
50
- throw new RangeError(`The argument \`${str}\` should be either in the form of "an+b" as in CSS selectors or Python slices!`);
50
+ throw new RangeError(`The argument ${JSON.stringify(str)} should be either in the form of "an+b" as in CSS selectors or Python slices!`);
51
51
  }
52
52
  const [, sgnA = '+', a = 1, sgnB = '+'] = mt, b = Number(mt[4] ?? 0);
53
53
  this.step = Number(a);
54
54
  /* c8 ignore next 3 */
55
55
  if (this.step === 0) {
56
- throw new RangeError(`In the argument \`${str}\`, the coefficient of "n" must not be 0!`);
56
+ throw new RangeError(`In the argument ${JSON.stringify(str)}, the coefficient of "n" must not be 0!`);
57
57
  }
58
58
  else if (sgnA === '+') { // `an+b` or `an-b`
59
59
  this.start = sgnB === '+' || b === 0 ? b : this.step - 1 - (b - 1) % this.step;
@@ -186,7 +186,7 @@ const expand = (wikitext, page, callPage, config, include, context, now = index_
186
186
  clean(accum, args);
187
187
  return implicitNewLine(constants_1.functionHooks.get(name)(target, context || undefined), prev);
188
188
  }
189
- else if (magicWords_1.expandedMagicWords.has(name)) {
189
+ try {
190
190
  const result = (0, magicWords_1.expandMagicWord)(name, args.map(({ anon, name: key, value }) => anon ? value : `${key}=${value}`), callPage, config, now, accum);
191
191
  if (result === false) {
192
192
  return m;
@@ -194,7 +194,9 @@ const expand = (wikitext, page, callPage, config, include, context, now = index_
194
194
  clean(accum, args);
195
195
  return implicitNewLine(result, prev);
196
196
  }
197
- return m;
197
+ catch {
198
+ return m;
199
+ }
198
200
  });
199
201
  plain.setText(expanded);
200
202
  if (plain.type === 'parameter-key') {
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.expandMagicWord = exports.expandedMagicWords = void 0;
6
+ exports.expandMagicWord = void 0;
7
7
  /* eslint-disable jsdoc/require-jsdoc */
8
8
  const path_1 = require("path");
9
9
  const string_1 = require("../util/string");
@@ -11,132 +11,6 @@ const constants_1 = require("../util/constants");
11
11
  const html_1 = require("../util/html");
12
12
  const index_1 = __importDefault(require("../index"));
13
13
  const index_2 = require("../src/index");
14
- const magicWords = [
15
- 'currentmonth',
16
- 'currentmonth1',
17
- 'currentmonthname',
18
- 'currentmonthnamegen',
19
- 'currentmonthabbrev',
20
- 'currentday',
21
- 'currentday2',
22
- 'currentdayname',
23
- 'currentyear',
24
- 'currenttime',
25
- 'currenthour',
26
- 'currentweek',
27
- 'currentdow',
28
- 'currenttimestamp',
29
- 'localmonth',
30
- 'localmonth1',
31
- 'localmonthname',
32
- 'localmonthnamegen',
33
- 'localmonthabbrev',
34
- 'localday',
35
- 'localday2',
36
- 'localdayname',
37
- 'localyear',
38
- 'localtime',
39
- 'localhour',
40
- 'localweek',
41
- 'localdow',
42
- 'localtimestamp',
43
- 'articlepath',
44
- 'server',
45
- 'servername',
46
- 'directionmark',
47
- 'contentlanguage',
48
- 'pagelanguage',
49
- 'userlanguage',
50
- 'revisionsize',
51
- 'numberofarticles',
52
- 'numberoffiles',
53
- 'numberofusers',
54
- 'numberofactiveusers',
55
- 'numberofpages',
56
- 'numberofadmins',
57
- 'numberofedits',
58
- 'numberingroup',
59
- 'pagesincategory',
60
- 'pagesize',
61
- 'ns',
62
- 'nse',
63
- 'urlencode',
64
- 'lcfirst',
65
- 'ucfirst',
66
- 'lc',
67
- 'uc',
68
- 'localurl',
69
- 'localurle',
70
- 'fullurl',
71
- 'fullurle',
72
- 'canonicalurl',
73
- 'canonicalurle',
74
- 'gender',
75
- 'formal',
76
- 'displaytitle',
77
- 'defaultsort',
78
- 'revisionuser',
79
- 'translation',
80
- 'revisionid',
81
- 'revisionday',
82
- 'revisionday2',
83
- 'revisionmonth',
84
- 'revisionmonth1',
85
- 'revisionyear',
86
- 'revisiontimestamp',
87
- 'namespace',
88
- 'namespacee',
89
- 'namespacenumber',
90
- 'talkspace',
91
- 'talkspacee',
92
- 'subjectspace',
93
- 'subjectspacee',
94
- 'pagename',
95
- 'pagenamee',
96
- 'fullpagename',
97
- 'fullpagenamee',
98
- 'subpagename',
99
- 'subpagenamee',
100
- 'rootpagename',
101
- 'rootpagenamee',
102
- 'basepagename',
103
- 'basepagenamee',
104
- 'talkpagename',
105
- 'talkpagenamee',
106
- 'subjectpagename',
107
- 'subjectpagenamee',
108
- 'language',
109
- 'dir',
110
- 'padleft',
111
- 'padright',
112
- 'anchorencode',
113
- 'special',
114
- 'speciale',
115
- 'pageid',
116
- 'contentmodel',
117
- 'tag',
118
- 'rel2abs',
119
- 'titleparts',
120
- 'len',
121
- 'pos',
122
- 'rpos',
123
- 'sub',
124
- 'count',
125
- 'replace',
126
- 'explode',
127
- 'urldecode',
128
- 'if',
129
- 'ifeq',
130
- 'ifexist',
131
- 'iferror',
132
- 'switch',
133
- 'plural',
134
- 'expr',
135
- '!',
136
- '=',
137
- 'filepath',
138
- ];
139
- exports.expandedMagicWords = new Set(magicWords);
140
14
  function urlFunction(config, args, local) {
141
15
  const [value, query] = args, fallback = (local ? '' : []);
142
16
  if (value.includes('\0')) {
@@ -297,7 +171,15 @@ const parseUrl = ({ server = '', articlePath = '' }) => {
297
171
  }, isError = (s) => /<(?:strong|span|p|div)\s+(?:[^\s>]+\s+)*?class="\s*(?:[^"\s>]+\s+)*?error(?:\s[^">]*)?"/u.test(s), splitArg = (arg) => {
298
172
  const i = arg.indexOf('=');
299
173
  return i !== -1 && [arg.slice(0, i).trim(), arg.slice(i + 1).trim()];
300
- }, isKnown = (s) => !/\0\d+[tm]\x7F/u.test(s);
174
+ }, isKnown = (s) => !/\0\d+[tm]\x7F/u.test(s), expr = (s) => {
175
+ try {
176
+ const { evaluateExpr } = require('mediawiki-expr');
177
+ return evaluateExpr(s);
178
+ }
179
+ catch {
180
+ throw new Error('Magic words "#expr" and "#ifexpr" require NPM package mediawiki-expr');
181
+ }
182
+ };
301
183
  /**
302
184
  * 展开魔术字
303
185
  * @param name 魔术字名称
@@ -682,11 +564,12 @@ const expandMagicWord = (name, args, page = '', config = index_1.default.getConf
682
564
  ? ''
683
565
  : isKnown(arg0) && isKnown(args[1]) && (args[cmp(arg0, args[1], true) ? 2 : 3] ?? '');
684
566
  case 'if':
685
- case 'iferror':
686
567
  if (args.length === 1) {
687
568
  return '';
688
569
  }
689
- return (name === 'if' ? strip : isError)((0, string_1.decodeHtml)(arg0)) ? args[1] : isKnown(arg0) && (args[2] ?? '');
570
+ return strip((0, string_1.decodeHtml)(arg0)) ? args[1] : isKnown(arg0) && (args[2] ?? '');
571
+ case 'iferror':
572
+ return isError((0, string_1.decodeHtml)(arg0)) ? args[1] ?? '' : isKnown(arg0) && (args[2] ?? arg0);
690
573
  case 'ifexist': {
691
574
  if (args.length === 1) {
692
575
  return '';
@@ -751,7 +634,17 @@ const expandMagicWord = (name, args, page = '', config = index_1.default.getConf
751
634
  return args[n === 1 || n === -1 ? 1 : 2] ?? '';
752
635
  }
753
636
  case 'expr':
754
- return !Number.isNaN(Number(arg0)) && arg0;
637
+ return arg0 && isKnown(arg0) && String(expr(arg0));
638
+ case 'ifexpr': {
639
+ if (!isKnown(arg0)) {
640
+ return false;
641
+ }
642
+ const evaluated = arg0 && expr(arg0);
643
+ if (evaluated && typeof evaluated === 'string') {
644
+ return evaluated;
645
+ }
646
+ return evaluated ? args[1] ?? '' : args[2] ?? '';
647
+ }
755
648
  case '!':
756
649
  return '|';
757
650
  case '=':
package/dist/src/arg.js CHANGED
@@ -265,8 +265,7 @@ let ArgToken = (() => {
265
265
  * @param name new argument name / 新参数名
266
266
  */
267
267
  setName(name) {
268
- const { childNodes } = index_1.default.parseWithRef(name, this, 2);
269
- this.firstChild.safeReplaceChildren(childNodes);
268
+ this.firstChild.safeReplaceChildren(index_1.default.parseWithRef(name, this, 2).childNodes);
270
269
  }
271
270
  /**
272
271
  * Set the default value
package/dist/src/atom.js CHANGED
@@ -79,7 +79,7 @@ let AtomToken = (() => {
79
79
  /* NOT FOR BROWSER */
80
80
  /* c8 ignore next 3 */
81
81
  if (!atomTypes.includes(value)) {
82
- throw new RangeError(`"${value}" is not a valid type for AtomToken!`);
82
+ throw new RangeError(`${JSON.stringify(value)} is not a valid type for AtomToken!`);
83
83
  }
84
84
  /* NOT FOR BROWSER END */
85
85
  this.#type = value;
@@ -259,8 +259,7 @@ let ConverterRuleToken = (() => {
259
259
  * @param to target of language conversion / 转换目标
260
260
  */
261
261
  setTo(to) {
262
- const { childNodes } = index_1.default.parseWithRef(to, this);
263
- this.lastChild.safeReplaceChildren(childNodes);
262
+ this.lastChild.safeReplaceChildren(index_1.default.parseWithRef(to, this).childNodes);
264
263
  }
265
264
  /**
266
265
  * Set the language variant
@@ -288,11 +287,10 @@ let ConverterRuleToken = (() => {
288
287
  if (!variant) {
289
288
  throw new Error('Please specify the language variant first!');
290
289
  }
291
- const { childNodes } = index_1.default.parseWithRef(from, this);
292
- if (!unidirectional) {
290
+ else if (!unidirectional) {
293
291
  super.insertAt(debug_1.Shadow.run(() => getRuleFromTo(undefined, 'from', this.getAttribute('config'))), 0);
294
292
  }
295
- this.firstChild.safeReplaceChildren(childNodes);
293
+ this.firstChild.safeReplaceChildren(index_1.default.parseWithRef(from, this).childNodes);
296
294
  }
297
295
  /**
298
296
  * Make the language conversion unidirectional
@@ -104,8 +104,7 @@ let HeadingToken = (() => {
104
104
  if (text.length > 1 && text.startsWith('=') && text.endsWith('=')) {
105
105
  throw new Error('Please use HeadingToken.setLevel method to change the level of the heading!');
106
106
  }
107
- const { childNodes } = index_1.default.parseWithRef(text, this);
108
- this.firstChild.safeReplaceChildren(childNodes);
107
+ this.firstChild.safeReplaceChildren(index_1.default.parseWithRef(text, this).childNodes);
109
108
  }
110
109
  /**
111
110
  * id attribute
@@ -421,8 +421,7 @@ let ImageParameterToken = (() => {
421
421
  this.typeError('setValue', type);
422
422
  }
423
423
  else if (value !== true) {
424
- const { childNodes } = index_1.default.parseWithRef(value, this, name === 'caption' ? undefined : 5);
425
- this.safeReplaceChildren(childNodes);
424
+ this.safeReplaceChildren(index_1.default.parseWithRef(value, this, name === 'caption' ? undefined : 5).childNodes);
426
425
  }
427
426
  }
428
427
  /**
package/dist/src/index.js CHANGED
@@ -183,7 +183,7 @@ let Token = (() => {
183
183
  ];
184
184
  /* c8 ignore next 3 */
185
185
  if (!plainTypes.includes(value)) {
186
- throw new RangeError(`"${value}" is not a valid type for ${this.constructor.name}!`);
186
+ throw new RangeError(`${JSON.stringify(value)} is not a valid type for ${this.constructor.name}!`);
187
187
  }
188
188
  /* NOT FOR BROWSER END */
189
189
  this.#type = value;
@@ -108,7 +108,7 @@ let LinkBaseToken = (() => {
108
108
  const { prefix, main, fragment } = this.#title, link = `${interwiki}:${prefix}${main}${fragment === undefined ? '' : `#${fragment}`}`;
109
109
  /* c8 ignore next 3 */
110
110
  if (interwiki && !this.isInterwiki(link)) {
111
- throw new RangeError(`${interwiki} is not a valid interwiki prefix!`);
111
+ throw new RangeError(`${JSON.stringify(interwiki)} is not a valid interwiki prefix!`);
112
112
  }
113
113
  this.setTarget(link);
114
114
  }
@@ -360,7 +360,7 @@ let FileToken = (() => {
360
360
  #getTypedArgs(keys, type) {
361
361
  const args = this.getAllArgs().filter(({ name }) => keys.has(name));
362
362
  if (args.length > 1) {
363
- index_1.default.warn(`The image ${this.name} has ${args.length} ${type} parameters. Only the last ${args[0].name} will take effect!`);
363
+ index_1.default.warn(`The image ${JSON.stringify(this.name)} has ${args.length} ${type} parameters. Only the last ${args[0].name} will take effect!`);
364
364
  }
365
365
  return args;
366
366
  }
@@ -485,8 +485,7 @@ let FileToken = (() => {
485
485
  // @ts-expect-error abstract class
486
486
  new imageParameter_1.ImageParameterToken(syntax.replace('$1', key === 'width' ? '1' : ''), this.extension, this.type, config));
487
487
  if (free) {
488
- const { childNodes } = index_1.default.parseWithRef(value, this);
489
- parameter.safeReplaceChildren(childNodes);
488
+ parameter.safeReplaceChildren(index_1.default.parseWithRef(value, this).childNodes);
490
489
  }
491
490
  this.insertAt(parameter);
492
491
  }
@@ -281,8 +281,7 @@ let MagicLinkToken = (() => {
281
281
  * @param url URL containing the protocol / 含协议的网址
282
282
  */
283
283
  setTarget(url) {
284
- const { childNodes } = index_1.default.parseWithRef(url, this, 2);
285
- this.safeReplaceChildren(childNodes);
284
+ this.safeReplaceChildren(index_1.default.parseWithRef(url, this, 2).childNodes);
286
285
  }
287
286
  /**
288
287
  * Check if it is a parameter of a template or magic word
@@ -85,8 +85,7 @@ let OnlyincludeToken = (() => {
85
85
  if (text.includes('</onlyinclude>')) {
86
86
  throw new RangeError('"</onlyinclude>" is not allowed in the text!');
87
87
  }
88
- const { childNodes } = index_2.default.parseWithRef(text, this, undefined, true);
89
- this.safeReplaceChildren(childNodes);
88
+ this.safeReplaceChildren(index_2.default.parseWithRef(text, this, undefined, true).childNodes);
90
89
  }
91
90
  /* NOT FOR BROWSER END */
92
91
  /** @private */
@@ -249,9 +249,8 @@ let ParameterToken = (() => {
249
249
  * @param value parameter value / 参数值
250
250
  */
251
251
  setValue(value) {
252
- const { childNodes } = index_1.default.parseWithRef(value, this);
253
252
  this.lastChild
254
- .safeReplaceChildren(childNodes);
253
+ .safeReplaceChildren(index_1.default.parseWithRef(value, this).childNodes);
255
254
  }
256
255
  /**
257
256
  * Rename the parameter
@@ -168,8 +168,7 @@ let TableToken = (() => {
168
168
  }
169
169
  /* NOT FOR BROWSER */
170
170
  if (!halfParsed) {
171
- const { childNodes } = index_1.default.parseWithRef(syntax, this, 2);
172
- this.lastChild.safeReplaceChildren(childNodes);
171
+ this.lastChild.safeReplaceChildren(index_1.default.parseWithRef(syntax, this, 2).childNodes);
173
172
  }
174
173
  }
175
174
  /**
@@ -158,8 +158,7 @@ let TdToken = (() => {
158
158
  return this.lastChild.text().trim();
159
159
  }
160
160
  set innerText(text) {
161
- const { childNodes } = index_1.default.parseWithRef(text, this, undefined, true);
162
- this.lastChild.safeReplaceChildren(childNodes);
161
+ this.lastChild.safeReplaceChildren(index_1.default.parseWithRef(text, this, undefined, true).childNodes);
163
162
  }
164
163
  /* NOT FOR BROWSER END */
165
164
  /**
@@ -369,7 +368,7 @@ let TdToken = (() => {
369
368
  if (notEOL) {
370
369
  html = html.replace(/(?<=[\S\n])[^\S\n]*$/u, '');
371
370
  }
372
- return `${lf}<${subtype}${attr.toHtmlInternal()}>${subtype === 'caption' ? (0, string_1.newline)(html) : html + (notEOL ? '' : lf)}</${subtype}>`;
371
+ return `${lf}<${subtype}${attr.toHtmlInternal()}>${subtype === 'caption' ? (0, string_1.newline)(html) : html}${notEOL ? '' : lf}</${subtype}>`;
373
372
  }
374
373
  };
375
374
  return TdToken = _classThis;
@@ -384,11 +383,10 @@ exports.TdToken = TdToken;
384
383
  * @param attr 单元格属性
385
384
  */
386
385
  const createTd = (inner, ref, subtype = 'td', attr = {}) => {
387
- const innerToken = typeof inner === 'string' ? index_1.default.parseWithRef(inner, ref) : inner,
388
386
  // @ts-expect-error abstract class
389
- token = debug_1.Shadow.run(() => new TdToken('\n|', undefined, ref.getAttribute('config')));
387
+ const token = debug_1.Shadow.run(() => new TdToken('\n|', undefined, ref.getAttribute('config')));
390
388
  token.setSyntax(subtype);
391
- token.lastChild.safeReplaceWith(innerToken);
389
+ token.lastChild.safeReplaceWith(typeof inner === 'string' ? index_1.default.parseWithRef(inner, ref) : inner);
392
390
  token.setAttr(attr);
393
391
  return token;
394
392
  };
@@ -525,7 +525,7 @@ let TranscludeToken = (() => {
525
525
  * @throws `Error` 不是可接受的魔术字
526
526
  */
527
527
  getPossibleValues() {
528
- const { type, name, childNodes } = this;
528
+ const { type, name, childNodes, length: l } = this;
529
529
  if (type === 'template') {
530
530
  throw new Error('TranscludeToken.getPossibleValues method is only for specific magic words!');
531
531
  }
@@ -534,12 +534,14 @@ let TranscludeToken = (() => {
534
534
  case 'if':
535
535
  case 'ifexist':
536
536
  case 'ifexpr':
537
- case 'iferror':
538
537
  start = 2;
539
538
  break;
540
539
  case 'ifeq':
541
540
  start = 3;
542
541
  break;
542
+ case 'iferror':
543
+ start = l > 3 ? 2 : 1;
544
+ break;
543
545
  case 'switch': {
544
546
  const parameters = childNodes.slice(2), last = parameters[parameters.length - 1];
545
547
  queue = [
@@ -1,6 +1,6 @@
1
1
  (() => {
2
2
  var _a;
3
- const version = '1.42.0', src = (_a = document.currentScript) === null || _a === void 0 ? void 0 : _a.src, file = /\/extensions\/dist\/base\.(?:min\.)?js$/u, CDN = src && file.test(src)
3
+ const version = '1.43.0', src = (_a = document.currentScript) === null || _a === void 0 ? void 0 : _a.src, file = /\/extensions\/dist\/base\.(?:min\.)?js$/u, CDN = src && file.test(src)
4
4
  ? src.replace(file, '')
5
5
  : `https://fastly.jsdelivr.net/npm/wikiparser-node@${version}`;
6
6
  const workerJS = () => {