wikiparser-node 1.19.0 → 1.20.1

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 (113) hide show
  1. package/README.md +3 -0
  2. package/bundle/bundle-es7.min.js +25 -32
  3. package/bundle/bundle-lsp.min.js +24 -97
  4. package/bundle/bundle.min.js +26 -33
  5. package/config/default.json +49 -3
  6. package/config/minimum.json +5 -1
  7. package/data/ext/math.json +660 -0
  8. package/dist/addon/table.js +24 -5
  9. package/dist/addon/transclude.js +4 -4
  10. package/dist/base.d.mts +1 -1
  11. package/dist/base.d.ts +1 -1
  12. package/dist/bin/config.js +26 -8
  13. package/dist/index.js +10 -1
  14. package/dist/internal.d.ts +2 -0
  15. package/dist/lib/document.d.ts +6 -1
  16. package/dist/lib/document.js +21 -5
  17. package/dist/lib/element.js +15 -21
  18. package/dist/lib/lsp.js +88 -59
  19. package/dist/lib/node.d.ts +4 -4
  20. package/dist/lib/node.js +21 -24
  21. package/dist/lib/text.js +13 -14
  22. package/dist/lib/title.js +2 -1
  23. package/dist/mixin/attributesParent.js +1 -1
  24. package/dist/mixin/fixed.d.ts +1 -2
  25. package/dist/mixin/fixed.js +2 -3
  26. package/dist/mixin/gapped.d.ts +4 -0
  27. package/dist/mixin/gapped.js +24 -0
  28. package/dist/mixin/hidden.js +1 -1
  29. package/dist/mixin/multiLine.d.ts +4 -0
  30. package/dist/mixin/multiLine.js +33 -0
  31. package/dist/mixin/noEscape.js +1 -1
  32. package/dist/mixin/padded.d.ts +5 -0
  33. package/dist/mixin/padded.js +24 -0
  34. package/dist/mixin/singleLine.js +1 -1
  35. package/dist/mixin/sol.js +1 -1
  36. package/dist/mixin/syntax.js +3 -3
  37. package/dist/parser/braces.js +8 -12
  38. package/dist/parser/commentAndExt.js +18 -2
  39. package/dist/parser/magicLinks.js +2 -2
  40. package/dist/parser/quotes.js +0 -4
  41. package/dist/parser/selector.js +5 -2
  42. package/dist/src/arg.js +10 -13
  43. package/dist/src/atom.js +2 -7
  44. package/dist/src/attribute.js +6 -6
  45. package/dist/src/attributes.js +10 -14
  46. package/dist/src/commented.d.ts +26 -0
  47. package/dist/src/commented.js +52 -0
  48. package/dist/src/converter.js +3 -6
  49. package/dist/src/converterFlags.js +266 -223
  50. package/dist/src/converterRule.d.ts +2 -2
  51. package/dist/src/converterRule.js +2 -2
  52. package/dist/src/extLink.d.ts +2 -3
  53. package/dist/src/extLink.js +222 -175
  54. package/dist/src/gallery.d.ts +4 -5
  55. package/dist/src/gallery.js +179 -144
  56. package/dist/src/heading.js +11 -11
  57. package/dist/src/hidden.js +2 -7
  58. package/dist/src/imageParameter.d.ts +2 -2
  59. package/dist/src/imageParameter.js +6 -5
  60. package/dist/src/imagemap.d.ts +2 -2
  61. package/dist/src/imagemap.js +155 -123
  62. package/dist/src/imagemapLink.d.ts +2 -2
  63. package/dist/src/index.js +44 -20
  64. package/dist/src/link/base.d.ts +2 -3
  65. package/dist/src/link/base.js +13 -15
  66. package/dist/src/link/file.d.ts +2 -3
  67. package/dist/src/link/file.js +3 -3
  68. package/dist/src/link/galleryImage.d.ts +2 -3
  69. package/dist/src/link/galleryImage.js +7 -13
  70. package/dist/src/link/redirectTarget.js +1 -1
  71. package/dist/src/magicLink.js +7 -9
  72. package/dist/src/nested.d.ts +2 -2
  73. package/dist/src/nested.js +4 -7
  74. package/dist/src/nowiki/comment.d.ts +1 -1
  75. package/dist/src/nowiki/comment.js +2 -5
  76. package/dist/src/nowiki/doubleUnderscore.d.ts +1 -1
  77. package/dist/src/nowiki/doubleUnderscore.js +2 -5
  78. package/dist/src/nowiki/index.d.ts +2 -2
  79. package/dist/src/nowiki/index.js +2 -1
  80. package/dist/src/nowiki/quote.d.ts +3 -3
  81. package/dist/src/nowiki/quote.js +13 -12
  82. package/dist/src/onlyinclude.js +6 -13
  83. package/dist/src/paramTag/index.d.ts +2 -2
  84. package/dist/src/paramTag/index.js +102 -66
  85. package/dist/src/paramTag/inputbox.d.ts +1 -1
  86. package/dist/src/parameter.d.ts +4 -5
  87. package/dist/src/parameter.js +13 -13
  88. package/dist/src/pre.d.ts +4 -5
  89. package/dist/src/pre.js +8 -17
  90. package/dist/src/syntax.d.ts +1 -1
  91. package/dist/src/syntax.js +2 -7
  92. package/dist/src/table/base.d.ts +2 -2
  93. package/dist/src/table/base.js +8 -8
  94. package/dist/src/table/index.js +1 -1
  95. package/dist/src/table/td.d.ts +3 -3
  96. package/dist/src/table/td.js +9 -9
  97. package/dist/src/table/tr.d.ts +2 -2
  98. package/dist/src/tagPair/ext.js +35 -30
  99. package/dist/src/tagPair/index.d.ts +1 -1
  100. package/dist/src/tagPair/index.js +2 -5
  101. package/dist/src/tagPair/translate.d.ts +38 -0
  102. package/dist/src/tagPair/translate.js +129 -0
  103. package/dist/src/transclude.js +5 -6
  104. package/dist/util/html.js +16 -1
  105. package/dist/util/lint.js +17 -30
  106. package/dist/util/sharable.js +29 -1
  107. package/dist/util/sharable.mjs +31 -3
  108. package/dist/util/string.js +14 -1
  109. package/extensions/dist/base.js +1 -1
  110. package/extensions/dist/lsp.js +13 -2
  111. package/package.json +7 -6
  112. package/extensions/es7/base.js +0 -320
  113. package/extensions/es7/lint.js +0 -97
@@ -1,9 +1,44 @@
1
1
  "use strict";
2
+ var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
3
+ function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
4
+ var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
5
+ var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
6
+ var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
7
+ var _, done = false;
8
+ for (var i = decorators.length - 1; i >= 0; i--) {
9
+ var context = {};
10
+ for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
11
+ for (var p in contextIn.access) context.access[p] = contextIn.access[p];
12
+ context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
13
+ var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
14
+ if (kind === "accessor") {
15
+ if (result === void 0) continue;
16
+ if (result === null || typeof result !== "object") throw new TypeError("Object expected");
17
+ if (_ = accept(result.get)) descriptor.get = _;
18
+ if (_ = accept(result.set)) descriptor.set = _;
19
+ if (_ = accept(result.init)) initializers.unshift(_);
20
+ }
21
+ else if (_ = accept(result)) {
22
+ if (kind === "field") initializers.unshift(_);
23
+ else descriptor[key] = _;
24
+ }
25
+ }
26
+ if (target) Object.defineProperty(target, contextIn.name, descriptor);
27
+ done = true;
28
+ };
29
+ var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
30
+ var useValue = arguments.length > 2;
31
+ for (var i = 0; i < initializers.length; i++) {
32
+ value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
33
+ }
34
+ return useValue ? value : void 0;
35
+ };
2
36
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
37
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
38
  };
5
39
  Object.defineProperty(exports, "__esModule", { value: true });
6
40
  exports.GalleryToken = void 0;
41
+ const multiLine_1 = require("../mixin/multiLine");
7
42
  const index_1 = __importDefault(require("../index"));
8
43
  const index_2 = require("./index");
9
44
  const galleryImage_1 = require("./link/galleryImage");
@@ -18,157 +53,157 @@ const html_1 = require("../util/html");
18
53
  * gallery标签
19
54
  * @classdesc `{childNodes: (GalleryImageToken|NoincludeToken|AstText)[]}`
20
55
  */
21
- class GalleryToken extends index_2.Token {
22
- /* NOT FOR BROWSER END */
23
- get type() {
24
- return 'ext-inner';
25
- }
26
- /* PRINT ONLY */
27
- /** image widths / 图片宽度 */
28
- get widths() {
29
- return this.#getSize('widths');
30
- }
31
- /** image heights / 图片高度 */
32
- get heights() {
33
- return this.#getSize('heights');
34
- }
35
- /* PRINT ONLY END */
36
- /* NOT FOR BROWSER */
37
- /** all images / 所有图片 */
38
- get images() {
39
- return this.childNodes.filter((0, debug_1.isToken)('gallery-image'));
40
- }
41
- /* NOT FOR BROWSER END */
42
- /** @param inner 标签内部wikitext */
43
- constructor(inner, config = index_1.default.getConfig(), accum = []) {
44
- super(undefined, config, accum, {
45
- AstText: ':', GalleryImageToken: ':', NoincludeToken: ':',
46
- });
47
- for (const line of inner?.split('\n') ?? []) {
48
- const matches = /^([^|]+)(?:\|(.*))?/u.exec(line);
49
- if (!matches) {
50
- // @ts-expect-error abstract class
51
- super.insertAt((line.trim() ? new noinclude_1.NoincludeToken(line, config, accum) : line));
52
- continue;
56
+ let GalleryToken = (() => {
57
+ let _classDecorators = [multiLine_1.multiLine];
58
+ let _classDescriptor;
59
+ let _classExtraInitializers = [];
60
+ let _classThis;
61
+ let _classSuper = index_2.Token;
62
+ var GalleryToken = class extends _classSuper {
63
+ static { _classThis = this; }
64
+ static {
65
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
66
+ __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
67
+ GalleryToken = _classThis = _classDescriptor.value;
68
+ if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
69
+ __runInitializers(_classThis, _classExtraInitializers);
70
+ }
71
+ /* NOT FOR BROWSER END */
72
+ get type() {
73
+ return 'ext-inner';
74
+ }
75
+ /* PRINT ONLY */
76
+ /** image widths / 图片宽度 */
77
+ get widths() {
78
+ return this.#getSize('widths');
79
+ }
80
+ /** image heights / 图片高度 */
81
+ get heights() {
82
+ return this.#getSize('heights');
83
+ }
84
+ /* PRINT ONLY END */
85
+ /* NOT FOR BROWSER */
86
+ /** all images / 所有图片 */
87
+ get images() {
88
+ return this.childNodes.filter((0, debug_1.isToken)('gallery-image'));
89
+ }
90
+ /* NOT FOR BROWSER END */
91
+ /** @param inner 标签内部wikitext */
92
+ constructor(inner, config, accum = []) {
93
+ super(undefined, config, accum, {
94
+ AstText: ':', GalleryImageToken: ':', NoincludeToken: ':',
95
+ });
96
+ for (const line of inner?.split('\n') ?? []) {
97
+ const matches = /^([^|]+)(?:\|(.*))?/u.exec(line);
98
+ if (!matches) {
99
+ // @ts-expect-error abstract class
100
+ super.insertAt((line.trim() ? new noinclude_1.NoincludeToken(line, config, accum) : line));
101
+ continue;
102
+ }
103
+ const [, file, alt] = matches;
104
+ if (this.#checkFile(file)) {
105
+ // @ts-expect-error abstract class
106
+ super.insertAt(new galleryImage_1.GalleryImageToken('gallery', file, alt, config, accum));
107
+ }
108
+ else {
109
+ // @ts-expect-error abstract class
110
+ super.insertAt(new noinclude_1.NoincludeToken(line, config, accum));
111
+ }
53
112
  }
54
- const [, file, alt] = matches;
55
- if (this.#checkFile(file)) {
56
- // @ts-expect-error abstract class
57
- super.insertAt(new galleryImage_1.GalleryImageToken('gallery', file, alt, config, accum));
113
+ }
114
+ /**
115
+ * 检查文件名是否有效
116
+ * @param file 文件名
117
+ */
118
+ #checkFile(file) {
119
+ return this.normalizeTitle(file, 6, { halfParsed: true, temporary: true, decode: true }).valid;
120
+ }
121
+ /** @private */
122
+ lint(start = this.getAbsoluteIndex(), re) {
123
+ const { top, left } = this.getRootNode().posFromIndex(start), errors = [];
124
+ for (let i = 0; i < this.length; i++) {
125
+ const child = this.childNodes[i], str = child.toString(), { length } = str, trimmed = str.trim(), { type } = child, startLine = top + i, startCol = i ? 0 : left;
126
+ child.setAttribute('aIndex', start);
127
+ if (type === 'noinclude' && trimmed && !/^<!--.*-->$/u.test(trimmed)) {
128
+ const endIndex = start + length;
129
+ errors.push({
130
+ rule: 'no-ignored',
131
+ message: index_1.default.msg('invalid content in <$1>', 'gallery'),
132
+ severity: trimmed.endsWith('-->') || /^(?:\||<!--)/u.test(trimmed)
133
+ ? 'warning'
134
+ : 'error',
135
+ startIndex: start,
136
+ endIndex,
137
+ startLine,
138
+ endLine: startLine,
139
+ startCol,
140
+ endCol: startCol + length,
141
+ suggestions: [
142
+ { desc: 'remove', range: [start, endIndex], text: '' },
143
+ { desc: 'comment', range: [start, endIndex], text: `<!--${str}-->` },
144
+ ],
145
+ });
146
+ }
147
+ else if (type !== 'noinclude' && type !== 'text') {
148
+ const childErrors = child.lint(start, re);
149
+ if (childErrors.length > 0) {
150
+ errors.push(...childErrors);
151
+ }
152
+ }
153
+ start += length + 1;
58
154
  }
59
- else {
155
+ return errors;
156
+ }
157
+ /* PRINT ONLY */
158
+ /**
159
+ * 获取图片的宽度或高度
160
+ * @param key `widths` 或 `heights`
161
+ */
162
+ #getSize(key) {
163
+ const widths = this.parentNode?.getAttr(key), mt = typeof widths === 'string' && /^(\d+)\s*(?:px)?$/u.exec(widths)?.[1];
164
+ return mt && Number(mt) || 120;
165
+ }
166
+ /** @private */
167
+ json(_, start = this.getAbsoluteIndex()) {
168
+ const json = super.json(undefined, start);
169
+ Object.assign(json, { widths: this.widths, heights: this.heights });
170
+ return json;
171
+ }
172
+ /* PRINT ONLY END */
173
+ /* NOT FOR BROWSER */
174
+ cloneNode() {
175
+ // @ts-expect-error abstract class
176
+ return (0, html_1.cloneNode)(this, () => new GalleryToken(undefined, this.getAttribute('config')));
177
+ }
178
+ /**
179
+ * Insert an image
180
+ *
181
+ * 插入图片
182
+ * @param file image file name / 图片文件名
183
+ * @param i position to be inserted at / 插入位置
184
+ * @throws `SyntaxError` 非法的文件名
185
+ */
186
+ insertImage(file, i) {
187
+ if (this.#checkFile(file)) {
188
+ const token = debug_1.Shadow.run(() =>
60
189
  // @ts-expect-error abstract class
61
- super.insertAt(new noinclude_1.NoincludeToken(line, config, accum));
190
+ new galleryImage_1.GalleryImageToken('gallery', file, undefined, this.getAttribute('config')));
191
+ return this.insertAt(token, i);
62
192
  }
193
+ throw new SyntaxError(`Invalid file name: ${file}`);
63
194
  }
64
- }
65
- /**
66
- * 检查文件名是否有效
67
- * @param file 文件名
68
- */
69
- #checkFile(file) {
70
- return this.normalizeTitle(file, 6, { halfParsed: true, temporary: true, decode: true }).valid;
71
- }
72
- /** @private */
73
- toString(skip) {
74
- return super.toString(skip, '\n');
75
- }
76
- /** @private */
77
- text() {
78
- return super.text('\n').replace(/\n\s*\n/gu, '\n');
79
- }
80
- /** @private */
81
- getGaps() {
82
- return 1;
83
- }
84
- /** @private */
85
- lint(start = this.getAbsoluteIndex(), re) {
86
- const { top, left } = this.getRootNode().posFromIndex(start), errors = [];
87
- for (let i = 0; i < this.length; i++) {
88
- const child = this.childNodes[i], str = child.toString(), { length } = str, trimmed = str.trim(), { type } = child, startLine = top + i, startCol = i ? 0 : left;
89
- child.setAttribute('aIndex', start);
90
- if (type === 'noinclude' && trimmed && !/^<!--.*-->$/u.test(trimmed)) {
91
- const endIndex = start + length;
92
- errors.push({
93
- rule: 'no-ignored',
94
- message: index_1.default.msg('invalid content in <$1>', 'gallery'),
95
- severity: trimmed.startsWith('|') ? 'warning' : 'error',
96
- startIndex: start,
97
- endIndex,
98
- startLine,
99
- endLine: startLine,
100
- startCol,
101
- endCol: startCol + length,
102
- suggestions: [
103
- { desc: 'remove', range: [start, endIndex], text: '' },
104
- { desc: 'comment', range: [start, endIndex], text: `<!--${str}-->` },
105
- ],
106
- });
195
+ insertAt(token, i = this.length) {
196
+ if (!debug_1.Shadow.running && (typeof token === 'string' && token.trim() || token instanceof noinclude_1.NoincludeToken)) {
197
+ throw new RangeError('Please do not insert invisible content into <gallery>!');
107
198
  }
108
- else if (type !== 'noinclude' && type !== 'text') {
109
- errors.push(...child.lint(start, re));
110
- }
111
- start += length + 1;
199
+ return super.insertAt(token, i);
112
200
  }
113
- return errors;
114
- }
115
- /* PRINT ONLY */
116
- /**
117
- * 获取图片的宽度或高度
118
- * @param key `widths` 或 `heights`
119
- */
120
- #getSize(key) {
121
- const widths = this.parentNode?.getAttr(key), mt = typeof widths === 'string' && /^(\d+)\s*(?:px)?$/u.exec(widths)?.[1];
122
- return mt && Number(mt) || 120;
123
- }
124
- /** @private */
125
- print() {
126
- return super.print({ sep: '\n' });
127
- }
128
- /** @private */
129
- json(_, start = this.getAbsoluteIndex()) {
130
- const json = super.json(undefined, start);
131
- Object.assign(json, { widths: this.widths, heights: this.heights });
132
- return json;
133
- }
134
- /* PRINT ONLY END */
135
- /* NOT FOR BROWSER */
136
- cloneNode() {
137
- const cloned = this.cloneChildNodes();
138
- return debug_1.Shadow.run(() => {
139
- // @ts-expect-error abstract class
140
- const token = new GalleryToken(undefined, this.getAttribute('config'));
141
- token.append(...cloned);
142
- return token;
143
- });
144
- }
145
- /**
146
- * Insert an image
147
- *
148
- * 插入图片
149
- * @param file image file name / 图片文件名
150
- * @param i position to be inserted at / 插入位置
151
- * @throws `SyntaxError` 非法的文件名
152
- */
153
- insertImage(file, i) {
154
- if (this.#checkFile(file)) {
155
- const token = debug_1.Shadow.run(() =>
156
- // @ts-expect-error abstract class
157
- new galleryImage_1.GalleryImageToken('gallery', file, undefined, this.getAttribute('config')));
158
- return this.insertAt(token, i);
159
- }
160
- throw new SyntaxError(`Invalid file name: ${file}`);
161
- }
162
- insertAt(token, i = this.length) {
163
- if (!debug_1.Shadow.running && (typeof token === 'string' && token.trim() || token instanceof noinclude_1.NoincludeToken)) {
164
- throw new RangeError('Please do not insert invisible content into <gallery>!');
201
+ /** @private */
202
+ toHtmlInternal() {
203
+ return (0, html_1.html)(this.childNodes.filter((0, debug_1.isToken)('gallery-image')), '\n');
165
204
  }
166
- return super.insertAt(token, i);
167
- }
168
- /** @private */
169
- toHtmlInternal() {
170
- return (0, html_1.html)(this.childNodes.filter((0, debug_1.isToken)('gallery-image')), '\n');
171
- }
172
- }
205
+ };
206
+ return GalleryToken = _classThis;
207
+ })();
173
208
  exports.GalleryToken = GalleryToken;
174
209
  constants_1.classes['GalleryToken'] = __filename;
@@ -96,7 +96,7 @@ let HeadingToken = (() => {
96
96
  }
97
97
  const { childNodes } = index_1.default
98
98
  .parse(text, this.getAttribute('include'), undefined, this.getAttribute('config'));
99
- this.firstChild.replaceChildren(...childNodes);
99
+ this.firstChild.safeReplaceChildren(childNodes);
100
100
  }
101
101
  /** id attribute / id属性 */
102
102
  get id() {
@@ -154,18 +154,18 @@ let HeadingToken = (() => {
154
154
  //
155
155
  }
156
156
  else if (unbalancedStart) {
157
- const [extra] = /^=+/u.exec(innerStr);
158
- e.suggestions = [
159
- { desc: `h${level}`, range: [e.startIndex, e.startIndex + extra.length], text: '' },
160
- { desc: `h${level + extra.length}`, range: [e.endIndex, e.endIndex], text: extra },
161
- ];
157
+ const [extra] = /^=+/u.exec(innerStr), newLevel = level + extra.length;
158
+ e.suggestions = [{ desc: `h${level}`, range: [e.startIndex, e.startIndex + extra.length], text: '' }];
159
+ if (newLevel < 7) {
160
+ e.suggestions.push({ desc: `h${newLevel}`, range: [e.endIndex, e.endIndex], text: extra });
161
+ }
162
162
  }
163
163
  else {
164
- const extra = /[^=](=+)$/u.exec(innerStr)[1];
165
- e.suggestions = [
166
- { desc: `h${level}`, range: [e.endIndex - extra.length, e.endIndex], text: '' },
167
- { desc: `h${level + extra.length}`, range: [e.startIndex, e.startIndex], text: extra },
168
- ];
164
+ const extra = /[^=](=+)$/u.exec(innerStr)[1], newLevel = level + extra.length;
165
+ e.suggestions = [{ desc: `h${level}`, range: [e.endIndex - extra.length, e.endIndex], text: '' }];
166
+ if (newLevel < 7) {
167
+ e.suggestions.push({ desc: `h${newLevel}`, range: [e.startIndex, e.startIndex], text: extra });
168
+ }
169
169
  }
170
170
  errors.push(e);
171
171
  }
@@ -38,8 +38,8 @@ exports.HiddenToken = void 0;
38
38
  const hidden_1 = require("../mixin/hidden");
39
39
  const index_1 = require("./index");
40
40
  /* NOT FOR BROWSER */
41
- const debug_1 = require("../util/debug");
42
41
  const constants_1 = require("../util/constants");
42
+ const html_1 = require("../util/html");
43
43
  /* NOT FOR BROWSER END */
44
44
  /**
45
45
  * invisible token
@@ -72,12 +72,7 @@ let HiddenToken = (() => {
72
72
  });
73
73
  }
74
74
  cloneNode() {
75
- const cloned = this.cloneChildNodes();
76
- return debug_1.Shadow.run(() => {
77
- const token = new HiddenToken(undefined, this.getAttribute('config'), []);
78
- token.append(...cloned);
79
- return token;
80
- });
75
+ return (0, html_1.cloneNode)(this, () => new HiddenToken(undefined, this.getAttribute('config'), []));
81
76
  }
82
77
  };
83
78
  return HiddenToken = _classThis;
@@ -13,10 +13,10 @@ export declare abstract class ImageParameterToken extends Token {
13
13
  readonly name: string;
14
14
  abstract get parentNode(): FileToken | undefined;
15
15
  abstract get nextSibling(): this | undefined;
16
- abstract get previousSibling(): AtomToken | this;
16
+ abstract get previousSibling(): AtomToken | this | undefined;
17
17
  abstract get parentElement(): FileToken | undefined;
18
18
  abstract get nextElementSibling(): this | undefined;
19
- abstract get previousElementSibling(): AtomToken | this;
19
+ abstract get previousElementSibling(): AtomToken | this | undefined;
20
20
  get type(): 'image-parameter';
21
21
  /** image link / 图片链接 */
22
22
  get link(): string | Title | undefined;
@@ -179,10 +179,11 @@ class ImageParameterToken extends index_2.Token {
179
179
  return this.#syntax ? this.#syntax.replace('$1', super.text()).trim() : super.text().trim();
180
180
  }
181
181
  /** @private */
182
+ isPlain() {
183
+ return this.name === 'caption';
184
+ }
185
+ /** @private */
182
186
  getAttribute(key) {
183
- if (key === 'plain') {
184
- return (this.name === 'caption');
185
- }
186
187
  return key === 'padding'
187
188
  ? Math.max(0, this.#syntax.indexOf('$1'))
188
189
  : super.getAttribute(key);
@@ -227,7 +228,7 @@ class ImageParameterToken extends index_2.Token {
227
228
  return debug_1.Shadow.run(() => {
228
229
  // @ts-expect-error abstract class
229
230
  const token = new ImageParameterToken(this.#syntax.replace('$1', '1'), this.#extension, config);
230
- token.replaceChildren(...cloned);
231
+ token.safeReplaceChildren(cloned);
231
232
  return token;
232
233
  });
233
234
  }
@@ -259,7 +260,7 @@ class ImageParameterToken extends index_2.Token {
259
260
  }
260
261
  else if (value !== true) {
261
262
  const include = this.getAttribute('include'), config = this.getAttribute('config'), { childNodes } = index_1.default.parse(value, include, name === 'caption' ? undefined : 5, config);
262
- this.replaceChildren(...childNodes);
263
+ this.safeReplaceChildren(childNodes);
263
264
  }
264
265
  }
265
266
  /**
@@ -16,13 +16,13 @@ export declare abstract class ImagemapToken extends Token {
16
16
  abstract get firstChild(): Child | undefined;
17
17
  abstract get lastChild(): Child | ImagemapLinkToken | AstText | undefined;
18
18
  abstract get nextSibling(): undefined;
19
- abstract get previousSibling(): AttributesToken;
19
+ abstract get previousSibling(): AttributesToken | undefined;
20
20
  abstract get parentNode(): ExtToken | undefined;
21
21
  abstract get children(): (Child | ImagemapLinkToken)[];
22
22
  abstract get firstElementChild(): Child | undefined;
23
23
  abstract get lastElementChild(): Child | ImagemapLinkToken | undefined;
24
24
  abstract get nextElementSibling(): undefined;
25
- abstract get previousElementSibling(): AttributesToken;
25
+ abstract get previousElementSibling(): AttributesToken | undefined;
26
26
  abstract get parentElement(): ExtToken | undefined;
27
27
  get type(): 'ext-inner';
28
28
  /** 图片 */