wikiparser-node 1.16.4 → 1.16.5

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 (150) hide show
  1. package/README.md +1 -1
  2. package/bundle/bundle.es7.js +27 -27
  3. package/bundle/bundle.lsp.js +30 -30
  4. package/bundle/bundle.min.js +29 -29
  5. package/dist/addon/table.js +7 -4
  6. package/dist/addon/token.js +13 -7
  7. package/dist/addon/transclude.js +7 -5
  8. package/dist/base.d.mts +99 -30
  9. package/dist/base.d.ts +99 -30
  10. package/dist/index.d.ts +10 -4
  11. package/dist/index.js +59 -14
  12. package/dist/lib/attributes.js +2 -2
  13. package/dist/lib/element.d.ts +96 -42
  14. package/dist/lib/element.js +97 -45
  15. package/dist/lib/lsp.d.ts +64 -35
  16. package/dist/lib/lsp.js +99 -71
  17. package/dist/lib/node.d.ts +122 -53
  18. package/dist/lib/node.js +172 -75
  19. package/dist/lib/range.d.ts +83 -31
  20. package/dist/lib/range.js +83 -31
  21. package/dist/lib/ranges.d.ts +1 -1
  22. package/dist/lib/ranges.js +3 -2
  23. package/dist/lib/text.d.ts +40 -14
  24. package/dist/lib/text.js +47 -19
  25. package/dist/lib/title.d.ts +50 -16
  26. package/dist/lib/title.js +77 -36
  27. package/dist/mixin/attributesParent.d.ts +37 -21
  28. package/dist/mixin/attributesParent.js +0 -2
  29. package/dist/mixin/flagsParent.d.ts +38 -12
  30. package/dist/mixin/hidden.d.ts +0 -2
  31. package/dist/mixin/hidden.js +0 -2
  32. package/dist/mixin/magicLinkParent.d.ts +11 -5
  33. package/dist/mixin/singleLine.d.ts +0 -2
  34. package/dist/mixin/singleLine.js +3 -3
  35. package/dist/mixin/sol.d.ts +0 -2
  36. package/dist/mixin/sol.js +2 -3
  37. package/dist/mixin/syntax.d.ts +0 -2
  38. package/dist/mixin/syntax.js +0 -2
  39. package/dist/parser/braces.js +4 -2
  40. package/dist/parser/links.js +13 -7
  41. package/dist/parser/list.js +3 -1
  42. package/dist/parser/quotes.js +22 -2
  43. package/dist/parser/redirect.js +4 -1
  44. package/dist/src/arg.d.ts +19 -9
  45. package/dist/src/arg.js +34 -15
  46. package/dist/src/atom.d.ts +5 -1
  47. package/dist/src/atom.js +5 -1
  48. package/dist/src/attribute.d.ts +26 -8
  49. package/dist/src/attribute.js +30 -11
  50. package/dist/src/attributes.d.ts +50 -22
  51. package/dist/src/attributes.js +54 -26
  52. package/dist/src/converter.d.ts +4 -2
  53. package/dist/src/converter.js +12 -9
  54. package/dist/src/converterFlags.d.ts +45 -15
  55. package/dist/src/converterFlags.js +45 -15
  56. package/dist/src/converterRule.d.ts +30 -11
  57. package/dist/src/converterRule.js +46 -16
  58. package/dist/src/extLink.d.ts +6 -2
  59. package/dist/src/extLink.js +14 -11
  60. package/dist/src/gallery.d.ts +13 -9
  61. package/dist/src/gallery.js +35 -21
  62. package/dist/src/heading.d.ts +13 -7
  63. package/dist/src/heading.js +21 -11
  64. package/dist/src/hidden.d.ts +5 -1
  65. package/dist/src/hidden.js +7 -3
  66. package/dist/src/html.d.ts +11 -5
  67. package/dist/src/html.js +16 -7
  68. package/dist/src/imageParameter.d.ts +23 -11
  69. package/dist/src/imageParameter.js +22 -10
  70. package/dist/src/imagemap.d.ts +4 -4
  71. package/dist/src/imagemap.js +9 -5
  72. package/dist/src/imagemapLink.d.ts +3 -1
  73. package/dist/src/imagemapLink.js +3 -1
  74. package/dist/src/index.d.ts +65 -20
  75. package/dist/src/index.js +111 -39
  76. package/dist/src/link/base.d.ts +14 -6
  77. package/dist/src/link/base.js +40 -17
  78. package/dist/src/link/category.d.ts +7 -2
  79. package/dist/src/link/category.js +20 -4
  80. package/dist/src/link/file.d.ts +71 -23
  81. package/dist/src/link/file.js +100 -36
  82. package/dist/src/link/galleryImage.d.ts +8 -4
  83. package/dist/src/link/galleryImage.js +15 -8
  84. package/dist/src/link/index.d.ts +12 -4
  85. package/dist/src/link/index.js +15 -5
  86. package/dist/src/link/redirectTarget.d.ts +3 -2
  87. package/dist/src/link/redirectTarget.js +5 -3
  88. package/dist/src/magicLink.d.ts +24 -11
  89. package/dist/src/magicLink.js +36 -19
  90. package/dist/src/nested.d.ts +5 -3
  91. package/dist/src/nested.js +9 -6
  92. package/dist/src/nowiki/base.d.ts +4 -2
  93. package/dist/src/nowiki/base.js +6 -5
  94. package/dist/src/nowiki/comment.d.ts +6 -2
  95. package/dist/src/nowiki/comment.js +8 -3
  96. package/dist/src/nowiki/dd.d.ts +0 -3
  97. package/dist/src/nowiki/dd.js +0 -8
  98. package/dist/src/nowiki/doubleUnderscore.d.ts +5 -1
  99. package/dist/src/nowiki/doubleUnderscore.js +5 -1
  100. package/dist/src/nowiki/index.d.ts +5 -1
  101. package/dist/src/nowiki/index.js +5 -1
  102. package/dist/src/nowiki/list.d.ts +5 -1
  103. package/dist/src/nowiki/list.js +5 -1
  104. package/dist/src/nowiki/listBase.d.ts +15 -5
  105. package/dist/src/nowiki/listBase.js +40 -9
  106. package/dist/src/nowiki/noinclude.d.ts +5 -1
  107. package/dist/src/nowiki/noinclude.js +5 -1
  108. package/dist/src/nowiki/quote.d.ts +15 -8
  109. package/dist/src/nowiki/quote.js +32 -12
  110. package/dist/src/onlyinclude.d.ts +4 -2
  111. package/dist/src/onlyinclude.js +4 -2
  112. package/dist/src/paramTag/index.d.ts +1 -1
  113. package/dist/src/paramTag/index.js +1 -1
  114. package/dist/src/parameter.d.ts +24 -12
  115. package/dist/src/parameter.js +45 -27
  116. package/dist/src/pre.d.ts +1 -1
  117. package/dist/src/pre.js +1 -1
  118. package/dist/src/redirect.d.ts +2 -0
  119. package/dist/src/redirect.js +2 -0
  120. package/dist/src/syntax.d.ts +5 -1
  121. package/dist/src/syntax.js +5 -1
  122. package/dist/src/table/base.d.ts +5 -1
  123. package/dist/src/table/base.js +10 -3
  124. package/dist/src/table/index.d.ts +134 -66
  125. package/dist/src/table/index.js +149 -81
  126. package/dist/src/table/td.d.ts +18 -10
  127. package/dist/src/table/td.js +23 -15
  128. package/dist/src/table/tr.d.ts +13 -3
  129. package/dist/src/table/tr.js +14 -6
  130. package/dist/src/table/trBase.d.ts +28 -12
  131. package/dist/src/table/trBase.js +28 -18
  132. package/dist/src/tagPair/ext.d.ts +3 -1
  133. package/dist/src/tagPair/ext.js +10 -8
  134. package/dist/src/tagPair/include.d.ts +8 -2
  135. package/dist/src/tagPair/include.js +8 -2
  136. package/dist/src/tagPair/index.d.ts +6 -2
  137. package/dist/src/tagPair/index.js +6 -2
  138. package/dist/src/transclude.d.ts +102 -33
  139. package/dist/src/transclude.js +114 -42
  140. package/dist/util/debug.js +2 -7
  141. package/dist/util/html.js +1 -18
  142. package/dist/util/string.js +7 -1
  143. package/extensions/dist/base.js +25 -8
  144. package/extensions/dist/codejar.js +2 -1
  145. package/extensions/dist/lsp.js +5 -10
  146. package/extensions/es7/base.js +25 -8
  147. package/extensions/ui.css +1 -162
  148. package/i18n/zh-hans.json +1 -1
  149. package/i18n/zh-hant.json +1 -1
  150. package/package.json +3 -3
@@ -1,6 +1,10 @@
1
1
  import { Token } from './index';
2
2
  import type { Config } from '../base';
3
- /** 不可见的节点 */
3
+ /**
4
+ * invisible token
5
+ *
6
+ * 不可见的节点
7
+ */
4
8
  export declare class HiddenToken extends Token {
5
9
  get type(): 'hidden';
6
10
  /** @class */
@@ -41,7 +41,11 @@ const index_1 = require("./index");
41
41
  const debug_1 = require("../util/debug");
42
42
  const constants_1 = require("../util/constants");
43
43
  /* NOT FOR BROWSER END */
44
- /** 不可见的节点 */
44
+ /**
45
+ * invisible token
46
+ *
47
+ * 不可见的节点
48
+ */
45
49
  let HiddenToken = (() => {
46
50
  let _classDecorators = [(0, hidden_1.hiddenToken)()];
47
51
  let _classDescriptor;
@@ -68,9 +72,9 @@ let HiddenToken = (() => {
68
72
  });
69
73
  }
70
74
  cloneNode() {
71
- const cloned = this.cloneChildNodes(), config = this.getAttribute('config');
75
+ const cloned = this.cloneChildNodes();
72
76
  return debug_1.Shadow.run(() => {
73
- const token = new HiddenToken(undefined, config, []);
77
+ const token = new HiddenToken(undefined, this.getAttribute('config'), []);
74
78
  token.append(...cloned);
75
79
  return token;
76
80
  });
@@ -5,6 +5,8 @@ import type { AttributesToken } from '../internal';
5
5
  export interface HtmlToken extends AttributesParentBase {
6
6
  }
7
7
  /**
8
+ * HTML tag
9
+ *
8
10
  * HTML标签
9
11
  * @classdesc `{childNodes: [AttributesToken]}`
10
12
  */
@@ -18,9 +20,9 @@ export declare abstract class HtmlToken extends Token {
18
20
  abstract get firstElementChild(): AttributesToken;
19
21
  abstract get lastElementChild(): AttributesToken;
20
22
  get type(): 'html';
21
- /** 是否自封闭 */
23
+ /** whether to be self-closing / 是否自封闭 */
22
24
  get selfClosing(): boolean;
23
- /** 是否是闭合标签 */
25
+ /** whether to be a closing tag / 是否是闭合标签 */
24
26
  get closing(): boolean;
25
27
  /** @throws `Error` 自封闭标签或空标签 */
26
28
  set closing(value: boolean);
@@ -34,22 +36,26 @@ export declare abstract class HtmlToken extends Token {
34
36
  */
35
37
  constructor(name: string, attr: AttributesToken, closing: boolean, selfClosing: boolean, config?: Config, accum?: Token[]);
36
38
  /**
39
+ * Find the matching tag
40
+ *
37
41
  * 搜索匹配的标签
38
42
  * @throws `SyntaxError` 同时闭合和自封闭的标签
39
43
  * @throws `SyntaxError` 无效自封闭标签
40
44
  * @throws `SyntaxError` 未匹配的标签
41
45
  */
42
46
  findMatchingTag(): this | undefined;
43
- /** @override */
44
- json(): AST;
45
47
  cloneNode(): this;
46
48
  /**
49
+ * Change the tag name
50
+ *
47
51
  * 更换标签名
48
- * @param tag 标签名
52
+ * @param tag tag name / 标签名
49
53
  * @throws `RangeError` 非法的HTML标签
50
54
  */
51
55
  replaceTag(tag: string): void;
52
56
  /**
57
+ * Fix the invalid self-closing tag
58
+ *
53
59
  * 修复无效自封闭标签
54
60
  * @throws `Error` 无法修复无效自封闭标签
55
61
  */
package/dist/src/html.js CHANGED
@@ -73,6 +73,8 @@ const magicWords = new Set(['if', 'ifeq', 'ifexpr', 'ifexist', 'iferror', 'switc
73
73
  'var',
74
74
  ]), obsoleteTags = new Set(['strike', 'big', 'center', 'font', 'tt']);
75
75
  /**
76
+ * HTML tag
77
+ *
76
78
  * HTML标签
77
79
  * @classdesc `{childNodes: [AttributesToken]}`
78
80
  */
@@ -98,11 +100,11 @@ let HtmlToken = (() => {
98
100
  get type() {
99
101
  return 'html';
100
102
  }
101
- /** 是否自封闭 */
103
+ /** whether to be self-closing / 是否自封闭 */
102
104
  get selfClosing() {
103
105
  return this.#selfClosing;
104
106
  }
105
- /** 是否是闭合标签 */
107
+ /** whether to be a closing tag / 是否是闭合标签 */
106
108
  get closing() {
107
109
  return this.#closing;
108
110
  }
@@ -253,6 +255,8 @@ let HtmlToken = (() => {
253
255
  return errors;
254
256
  }
255
257
  /**
258
+ * Find the matching tag
259
+ *
256
260
  * 搜索匹配的标签
257
261
  * @throws `SyntaxError` 同时闭合和自封闭的标签
258
262
  * @throws `SyntaxError` 无效自封闭标签
@@ -297,9 +301,9 @@ let HtmlToken = (() => {
297
301
  post: `${this.#selfClosing ? '/' : ''}>`,
298
302
  });
299
303
  }
300
- /** @override */
301
- json() {
302
- const json = super.json();
304
+ /** @private */
305
+ json(_, start = this.getAbsoluteIndex()) {
306
+ const json = super.json(undefined, start);
303
307
  Object.assign(json, { closing: this.closing, selfClosing: this.#selfClosing });
304
308
  return json;
305
309
  }
@@ -310,8 +314,10 @@ let HtmlToken = (() => {
310
314
  return debug_1.Shadow.run(() => new HtmlToken(this.#tag, attr, this.closing, this.selfClosing, config));
311
315
  }
312
316
  /**
317
+ * Change the tag name
318
+ *
313
319
  * 更换标签名
314
- * @param tag 标签名
320
+ * @param tag tag name / 标签名
315
321
  * @throws `RangeError` 非法的HTML标签
316
322
  */
317
323
  replaceTag(tag) {
@@ -323,6 +329,8 @@ let HtmlToken = (() => {
323
329
  this.#tag = tag;
324
330
  }
325
331
  /**
332
+ * Fix the invalid self-closing tag
333
+ *
326
334
  * 修复无效自封闭标签
327
335
  * @throws `Error` 无法修复无效自封闭标签
328
336
  */
@@ -333,7 +341,8 @@ let HtmlToken = (() => {
333
341
  }
334
342
  else if (firstChild.text().trim()) {
335
343
  this.#selfClosing = false;
336
- this.after(index_2.default.parse(`</${this.name}>`, false, 3, this.getAttribute('config')).firstChild);
344
+ this.after(index_2.default.parse(`</${this.name}>`, false, 3, this.getAttribute('config'))
345
+ .firstChild);
337
346
  return;
338
347
  }
339
348
  const { childNodes } = parentNode, i = childNodes.indexOf(this), prevSiblings = childNodes.slice(0, i)
@@ -4,7 +4,11 @@ import type { LintError } from '../base';
4
4
  import type { Title } from '../lib/title';
5
5
  import type { AtomToken, FileToken, AstNodes, AstText } from '../internal';
6
6
  export declare const galleryParams: Set<string>;
7
- /** 图片参数 */
7
+ /**
8
+ * image parameter
9
+ *
10
+ * 图片参数
11
+ */
8
12
  export declare abstract class ImageParameterToken extends Token {
9
13
  #private;
10
14
  readonly name: string;
@@ -15,13 +19,13 @@ export declare abstract class ImageParameterToken extends Token {
15
19
  abstract get nextElementSibling(): this | undefined;
16
20
  abstract get previousElementSibling(): AtomToken | this;
17
21
  get type(): 'image-parameter';
18
- /** 图片链接 */
22
+ /** image link / 图片链接 */
19
23
  get link(): string | Title | undefined;
20
24
  set link(value: string);
21
- /** getValue()的getter */
25
+ /** parameter value / 参数值 */
22
26
  get value(): string | true;
23
27
  set value(value: string | true);
24
- /** 图片大小 */
28
+ /** iamge size / 图片大小 */
25
29
  get size(): {
26
30
  width: string;
27
31
  height: string;
@@ -30,34 +34,42 @@ export declare abstract class ImageParameterToken extends Token {
30
34
  width: string;
31
35
  height: string;
32
36
  } | undefined);
33
- /** 图片宽度 */
37
+ /** image width / 图片宽度 */
34
38
  get width(): string | undefined;
35
39
  set width(width: string | undefined);
36
- /** 图片高度 */
40
+ /** image height / 图片高度 */
37
41
  get height(): string | undefined;
38
42
  set height(height: string | undefined);
39
43
  /** @param str 图片参数 */
40
44
  constructor(str: string, extension: string | undefined, config?: Parser.Config, accum?: Token[]);
41
- /** 获取参数值 */
45
+ /**
46
+ * Get the parameter value
47
+ *
48
+ * 获取参数值
49
+ */
42
50
  getValue(): string | true;
43
51
  cloneNode(): this;
44
52
  /**
45
53
  * @override
46
- * @param token 待插入的子节点
47
- * @param i 插入位置
54
+ * @param token node to be inserted / 待插入的子节点
55
+ * @param i position to be inserted at / 插入位置
48
56
  * @throws `Error` 不接受自定义输入的图片参数
49
57
  */
50
58
  insertAt(token: string, i?: number): AstText;
51
59
  insertAt<T extends AstNodes>(token: T, i?: number): T;
52
60
  /**
61
+ * Set the parameter value
62
+ *
53
63
  * 设置参数值
54
- * @param value 参数值
64
+ * @param value parameter value / 参数值
55
65
  * @throws `Error` 无效参数
56
66
  */
57
67
  setValue(value?: string | boolean): void;
58
68
  /**
69
+ * Get the URL
70
+ *
59
71
  * 获取网址
60
- * @param articlePath 条目路径
72
+ * @param articlePath article path / 条目路径
61
73
  */
62
74
  getUrl(articlePath?: string): string | undefined;
63
75
  }
@@ -31,7 +31,7 @@ function validate(key, val, config, halfParsed, ext) {
31
31
  else if (value.startsWith('[[') && value.endsWith(']]')) {
32
32
  value = value.slice(2, -2);
33
33
  }
34
- const title = index_1.default.normalizeTitle(value, 0, false, config, halfParsed, true, true);
34
+ const title = index_1.default.normalizeTitle(value, 0, false, config, false, halfParsed, true, true);
35
35
  return title.valid && title;
36
36
  }
37
37
  case 'lang':
@@ -46,7 +46,11 @@ function validate(key, val, config, halfParsed, ext) {
46
46
  return Boolean(value) && !isNaN(value);
47
47
  }
48
48
  }
49
- /** 图片参数 */
49
+ /**
50
+ * image parameter
51
+ *
52
+ * 图片参数
53
+ */
50
54
  class ImageParameterToken extends index_2.Token {
51
55
  #syntax = '';
52
56
  #extension;
@@ -54,7 +58,7 @@ class ImageParameterToken extends index_2.Token {
54
58
  get type() {
55
59
  return 'image-parameter';
56
60
  }
57
- /** 图片链接 */
61
+ /** image link / 图片链接 */
58
62
  get link() {
59
63
  return this.name === 'link' ? validate('link', super.text(), this.getAttribute('config')) : undefined;
60
64
  }
@@ -64,14 +68,14 @@ class ImageParameterToken extends index_2.Token {
64
68
  this.setValue(value);
65
69
  }
66
70
  }
67
- /** getValue()的getter */
71
+ /** parameter value / 参数值 */
68
72
  get value() {
69
73
  return this.getValue();
70
74
  }
71
75
  set value(value) {
72
76
  this.setValue(value);
73
77
  }
74
- /** 图片大小 */
78
+ /** iamge size / 图片大小 */
75
79
  get size() {
76
80
  if (this.name === 'width') {
77
81
  const size = this.getValue().trim().replace(/px$/u, '').trim();
@@ -94,7 +98,7 @@ class ImageParameterToken extends index_2.Token {
94
98
  this.setValue(size && size.width + (size.height && 'x') + size.height);
95
99
  }
96
100
  }
97
- /** 图片宽度 */
101
+ /** image width / 图片宽度 */
98
102
  get width() {
99
103
  return this.size?.width;
100
104
  }
@@ -104,7 +108,7 @@ class ImageParameterToken extends index_2.Token {
104
108
  this.setValue((width || '') + (height && 'x') + height);
105
109
  }
106
110
  }
107
- /** 图片高度 */
111
+ /** image height / 图片高度 */
108
112
  get height() {
109
113
  return this.size?.height;
110
114
  }
@@ -194,7 +198,11 @@ class ImageParameterToken extends index_2.Token {
194
198
  #isVoid() {
195
199
  return this.#syntax && !this.#syntax.includes('$1');
196
200
  }
197
- /** 获取参数值 */
201
+ /**
202
+ * Get the parameter value
203
+ *
204
+ * 获取参数值
205
+ */
198
206
  getValue() {
199
207
  return this.name === 'invalid' ? this.text() : this.#isVoid() || super.text();
200
208
  }
@@ -222,8 +230,10 @@ class ImageParameterToken extends index_2.Token {
222
230
  return super.insertAt(token, i);
223
231
  }
224
232
  /**
233
+ * Set the parameter value
234
+ *
225
235
  * 设置参数值
226
- * @param value 参数值
236
+ * @param value parameter value / 参数值
227
237
  * @throws `Error` 无效参数
228
238
  */
229
239
  setValue(value = false) {
@@ -245,8 +255,10 @@ class ImageParameterToken extends index_2.Token {
245
255
  }
246
256
  }
247
257
  /**
258
+ * Get the URL
259
+ *
248
260
  * 获取网址
249
- * @param articlePath 条目路径
261
+ * @param articlePath article path / 条目路径
250
262
  */
251
263
  getUrl(articlePath) {
252
264
  let { link } = this;
@@ -8,7 +8,7 @@ import type { AstText, AttributesToken, ExtToken, AstNodes } from '../internal';
8
8
  declare type Child = GalleryImageToken | NoincludeToken;
9
9
  /**
10
10
  * `<imagemap>`
11
- * @classdesc `{childNodes: ...NoincludeToken, GalleryImageToken, ...(NoincludeToken|ImagemapLinkToken|AstText)}`
11
+ * @classdesc `{childNodes: [...NoincludeToken[], GalleryImageToken, ...(NoincludeToken|ImagemapLinkToken|AstText)[]]}`
12
12
  */
13
13
  export declare abstract class ImagemapToken extends Token {
14
14
  readonly name: 'imagemap';
@@ -31,8 +31,8 @@ export declare abstract class ImagemapToken extends Token {
31
31
  constructor(inner?: string, config?: Parser.Config, accum?: Token[]);
32
32
  /**
33
33
  * @override
34
- * @param token 待插入的节点
35
- * @param i 插入位置
34
+ * @param token node to be inserted / 待插入的节点
35
+ * @param i position to be inserted at / 插入位置
36
36
  * @throws `Error` 当前缺少合法图片
37
37
  * @throws `RangeError` 已有一张合法图片
38
38
  */
@@ -40,7 +40,7 @@ export declare abstract class ImagemapToken extends Token {
40
40
  insertAt<T extends AstNodes>(token: T, i?: number): T;
41
41
  /**
42
42
  * @override
43
- * @param i 移除位置
43
+ * @param i position of the child node /移除位置
44
44
  * @throws `Error` 禁止移除图片
45
45
  */
46
46
  removeAt(i: number): AstNodes;
@@ -14,7 +14,7 @@ const constants_1 = require("../util/constants");
14
14
  const singleLine_1 = require("../mixin/singleLine");
15
15
  /**
16
16
  * `<imagemap>`
17
- * @classdesc `{childNodes: ...NoincludeToken, GalleryImageToken, ...(NoincludeToken|ImagemapLinkToken|AstText)}`
17
+ * @classdesc `{childNodes: [...NoincludeToken[], GalleryImageToken, ...(NoincludeToken|ImagemapLinkToken|AstText)[]]}`
18
18
  */
19
19
  class ImagemapToken extends index_2.Token {
20
20
  /* NOT FOR BROWSER END */
@@ -41,8 +41,12 @@ class ImagemapToken extends index_2.Token {
41
41
  //
42
42
  }
43
43
  else if (first) {
44
- const pipe = line.indexOf('|'), file = pipe === -1 ? line : line.slice(0, pipe), title = this.normalizeTitle(file, 0, true);
45
- if (title.valid && !title.interwiki && title.ns === 6) {
44
+ const pipe = line.indexOf('|'), file = pipe === -1 ? line : line.slice(0, pipe), { valid, ns,
45
+ /* NOT FOR BROWSER */
46
+ interwiki, } = this.normalizeTitle(file, 0, true, true);
47
+ if (valid
48
+ && !interwiki
49
+ && ns === 6) {
46
50
  // @ts-expect-error abstract class
47
51
  const token = new galleryImage_1.GalleryImageToken('imagemap', file, pipe === -1 ? undefined : line.slice(pipe + 1), config, accum);
48
52
  super.insertAt(token);
@@ -61,7 +65,7 @@ class ImagemapToken extends index_2.Token {
61
65
  const i = line.indexOf('['), substr = line.slice(i), mtIn = /^\[\[([^|]+)(?:\|([^\]]+))?\]\][\w\s]*$/u
62
66
  .exec(substr);
63
67
  if (mtIn) {
64
- if (this.normalizeTitle(mtIn[1], 0, true, false, true).valid) {
68
+ if (this.normalizeTitle(mtIn[1], 0, true, true, false, true).valid) {
65
69
  // @ts-expect-error abstract class
66
70
  super.insertAt(new imagemapLink_1.ImagemapLinkToken(line.slice(0, i), mtIn.slice(1), substr.slice(substr.indexOf(']]') + 2), config, accum));
67
71
  continue;
@@ -131,7 +135,7 @@ class ImagemapToken extends index_2.Token {
131
135
  }
132
136
  /**
133
137
  * @override
134
- * @param i 移除位置
138
+ * @param i position of the child node /移除位置
135
139
  * @throws `Error` 禁止移除图片
136
140
  */
137
141
  removeAt(i) {
@@ -6,6 +6,8 @@ import { ExtLinkToken } from './extLink';
6
6
  import type { AstText, ImagemapToken, GalleryImageToken } from '../internal';
7
7
  import type { Title } from '../lib/title';
8
8
  /**
9
+ * link inside the `<imagemap>`
10
+ *
9
11
  * `<imagemap>`内的链接
10
12
  * @classdesc `{childNodes: [AstText, LinkToken|ExtLinkToken, NoincludeToken]}`
11
13
  */
@@ -23,7 +25,7 @@ export declare abstract class ImagemapLinkToken extends Token {
23
25
  abstract get previousElementSibling(): GalleryImageToken | this | NoincludeToken;
24
26
  abstract get nextElementSibling(): this | NoincludeToken | undefined;
25
27
  get type(): 'imagemap-link';
26
- /** 内外链接 */
28
+ /** internal or external link / 内外链接 */
27
29
  get link(): string | Title;
28
30
  set link(link: string);
29
31
  /**
@@ -46,6 +46,8 @@ const fixed_1 = require("../mixin/fixed");
46
46
  const singleLine_1 = require("../mixin/singleLine");
47
47
  /* NOT FOR BROWSER END */
48
48
  /**
49
+ * link inside the `<imagemap>`
50
+ *
49
51
  * `<imagemap>`内的链接
50
52
  * @classdesc `{childNodes: [AstText, LinkToken|ExtLinkToken, NoincludeToken]}`
51
53
  */
@@ -69,7 +71,7 @@ let ImagemapLinkToken = (() => {
69
71
  return 'imagemap-link';
70
72
  }
71
73
  /* NOT FOR BROWSER */
72
- /** 内外链接 */
74
+ /** internal or external link / 内外链接 */
73
75
  get link() {
74
76
  return this.childNodes[1].link;
75
77
  }
@@ -8,8 +8,10 @@ import { Ranges } from '../lib/ranges';
8
8
  import { AstRange } from '../lib/range';
9
9
  import type { Range } from '../lib/ranges';
10
10
  /**
11
+ * base class for all tokens
12
+ *
11
13
  * 所有节点的基类
12
- * @classdesc `{childNodes: ...(AstText|Token)}`
14
+ * @classdesc `{childNodes: (AstText|Token)[]}`
13
15
  */
14
16
  export declare class Token extends AstElement {
15
17
  #private;
@@ -19,33 +21,39 @@ export declare class Token extends AstElement {
19
21
  constructor(wikitext?: string, config?: Parser.Config, accum?: Token[], acceptable?: Acceptable);
20
22
  /**
21
23
  * @override
22
- * @param child 待插入的子节点
23
- * @param i 插入位置
24
+ * @param child node to be inserted / 待插入的子节点
25
+ * @param i position to be inserted at / 插入位置
24
26
  */
25
27
  insertAt(child: string, i?: number): AstText;
26
28
  insertAt<T extends AstNodes>(child: T, i?: number): T;
27
29
  /**
28
30
  * @override
29
- * @param i 移除位置
31
+ * @param i position of the child node / 移除位置
30
32
  */
31
33
  removeAt(i: number): AstNodes;
32
34
  /**
35
+ * Replace with a token of the same type
36
+ *
33
37
  * 替换为同类节点
34
- * @param token 待替换的节点
38
+ * @param token token to be replaced with / 待替换的节点
35
39
  * @throws `Error` 不存在父节点
36
40
  */
37
41
  safeReplaceWith(token: this): void;
38
42
  /**
43
+ * Create an HTML comment
44
+ *
39
45
  * 创建HTML注释
40
- * @param data 注释内容
46
+ * @param data comment content / 注释内容
41
47
  */
42
48
  createComment(data?: string): CommentToken;
43
49
  /**
50
+ * Create a tag
51
+ *
44
52
  * 创建标签
45
- * @param tagName 标签名
53
+ * @param tagName tag name / 标签名
46
54
  * @param options 选项
47
- * @param options.selfClosing 是否自封闭
48
- * @param options.closing 是否是闭合标签
55
+ * @param options.selfClosing whether to be a self-closing tag / 是否自封闭
56
+ * @param options.closing whether to be a closing tag / 是否是闭合标签
49
57
  * @throws `RangeError` 非法的标签名
50
58
  */
51
59
  createElement(tagName: string, options?: {
@@ -53,43 +61,80 @@ export declare class Token extends AstElement {
53
61
  closing?: boolean;
54
62
  }): IncludeToken | ExtToken | HtmlToken;
55
63
  /**
64
+ * Create a text node
65
+ *
56
66
  * 创建纯文本节点
57
- * @param data 文本内容
67
+ * @param data text content / 文本内容
58
68
  */
59
69
  createTextNode(data?: string): AstText;
60
- /** 创建AstRange对象 */
70
+ /**
71
+ * Create an AstRange object
72
+ *
73
+ * 创建AstRange对象
74
+ */
61
75
  createRange(): AstRange;
62
76
  /**
77
+ * Check if a title is an interwiki link
78
+ *
63
79
  * 判断标题是否是跨维基链接
64
80
  * @param title 标题
65
81
  */
66
82
  isInterwiki(title: string): RegExpExecArray | null;
67
- /** 深拷贝节点 */
83
+ /**
84
+ * Deep clone the node
85
+ *
86
+ * 深拷贝节点
87
+ */
68
88
  cloneNode(): this;
69
- /** 获取全部章节 */
89
+ /**
90
+ * Get all sections
91
+ *
92
+ * 获取全部章节
93
+ */
70
94
  sections(): AstRange[] | undefined;
71
95
  /**
96
+ * Get a section
97
+ *
72
98
  * 获取指定章节
73
- * @param n 章节序号
99
+ * @param n rank of the section / 章节序号
74
100
  */
75
101
  section(n: number): AstRange | undefined;
76
102
  /**
103
+ * Get the enclosing HTML tags
104
+ *
77
105
  * 获取指定的外层HTML标签
78
- * @param tag HTML标签名
106
+ * @param tag HTML tag name / HTML标签名
79
107
  * @throws `RangeError` 非法的标签或空标签
80
108
  */
81
109
  findEnclosingHtml(tag?: string): AstRange | undefined;
82
- /** 获取全部分类 */
110
+ /**
111
+ * Get all categories
112
+ *
113
+ * 获取全部分类
114
+ */
83
115
  getCategories(): [string, string | undefined][];
84
116
  /**
117
+ * Expand templates
118
+ *
85
119
  * 展开模板
86
- * @param context 模板调用环境
87
120
  */
88
121
  expand(): Token;
89
- /** 解析部分魔术字 */
122
+ /**
123
+ * Parse some magic words
124
+ *
125
+ * 解析部分魔术字
126
+ */
90
127
  solveConst(): Token;
91
- /** 合并普通节点的普通子节点 */
128
+ /**
129
+ * Merge plain child tokens of a plain token
130
+ *
131
+ * 合并普通节点的普通子节点
132
+ */
92
133
  flatten(): void;
93
- /** 生成HTML */
134
+ /**
135
+ * Generate HTML
136
+ *
137
+ * 生成HTML
138
+ */
94
139
  toHtml(): string;
95
140
  }