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
@@ -7,8 +7,10 @@ const trBase_1 = require("./trBase");
7
7
  const constants_1 = require("../../util/constants");
8
8
  /* NOT FOR BROWSER END */
9
9
  /**
10
+ * table row that contains the newline at the beginning but not at the end
11
+ *
10
12
  * 表格行,含开头的换行,不含结尾的换行
11
- * @classdesc `{childNodes: [SyntaxToken, AttributesToken, ?Token, ...TdToken]}`
13
+ * @classdesc `{childNodes: [SyntaxToken, AttributesToken, ?Token, ...TdToken[]]}`
12
14
  */
13
15
  class TrToken extends trBase_1.TrBaseToken {
14
16
  /* NOT FOR BROWSER END */
@@ -20,9 +22,7 @@ class TrToken extends trBase_1.TrBaseToken {
20
22
  * @param attr 表格属性
21
23
  */
22
24
  constructor(syntax, attr, config, accum) {
23
- super(/^\n[^\S\n]*(?:\|-+|\{\{\s*!\s*\}\}-+|\{\{\s*!-\s*\}\}-*)$/u, syntax, 'tr', attr, config, accum, {
24
- Token: 2, SyntaxToken: 0, AttributesToken: 1, TdToken: '2:',
25
- });
25
+ super(/^\n[^\S\n]*(?:\|-+|\{\{\s*!\s*\}\}-+|\{\{\s*!-\s*\}\}-*)$/u, syntax, 'tr', attr, config, accum, { Token: 2, SyntaxToken: 0, AttributesToken: 1, TdToken: '2:' });
26
26
  }
27
27
  /* NOT FOR BROWSER */
28
28
  /** @private */
@@ -47,11 +47,19 @@ class TrToken extends trBase_1.TrBaseToken {
47
47
  }
48
48
  return undefined;
49
49
  }
50
- /** 获取下一行 */
50
+ /**
51
+ * Get the next row
52
+ *
53
+ * 获取下一行
54
+ */
51
55
  getNextRow() {
52
56
  return this.#getSiblingRow((childNodes, index) => childNodes.slice(index + 1));
53
57
  }
54
- /** 获取前一行 */
58
+ /**
59
+ * Get the previous row
60
+ *
61
+ * 获取前一行
62
+ */
55
63
  getPreviousRow() {
56
64
  return this.#getSiblingRow((childNodes, index) => childNodes.slice(0, index).reverse());
57
65
  }
@@ -11,39 +11,55 @@ export interface TableCoords {
11
11
  readonly y?: undefined;
12
12
  readonly start?: boolean;
13
13
  }
14
- /** 表格行或表格 */
14
+ /**
15
+ * table row or table
16
+ *
17
+ * 表格行或表格
18
+ */
15
19
  export declare abstract class TrBaseToken extends TableBaseToken {
16
20
  #private;
17
21
  abstract get type(): 'table' | 'tr';
18
- /** 获取行数 */
22
+ /**
23
+ * Get the number of rows
24
+ *
25
+ * 获取行数
26
+ */
19
27
  getRowCount(): number;
20
28
  /**
29
+ * Get the `n`-th column
30
+ *
21
31
  * 获取第n列
22
- * @param n 列号
23
- * @param insert 是否用于判断插入新列的位置
32
+ * @param n column number / 列号
33
+ * @param insert whether to be used to insert a new column / 是否用于判断插入新列的位置
24
34
  * @throws `RangeError` 不存在对应单元格
25
35
  */
26
36
  getNthCol(n: number, insert?: false): TdToken | undefined;
27
37
  getNthCol(n: number, insert: true): TdToken | TrToken | SyntaxToken | undefined;
28
38
  /**
29
39
  * @override
30
- * @param i 移除位置
40
+ * @param i position of the child node / 移除位置
31
41
  */
32
42
  removeAt(i: number): AstNodes;
33
43
  /**
34
44
  * @override
35
- * @param token 待插入的子节点
36
- * @param i 插入位置
45
+ * @param token node to be inserted / 待插入的子节点
46
+ * @param i position to be inserted at / 插入位置
37
47
  */
38
48
  insertAt<T extends Token>(token: T, i?: number): T;
39
- /** 获取列数 */
49
+ /**
50
+ * Get the number of columns
51
+ *
52
+ * 获取列数
53
+ */
40
54
  getColCount(): number;
41
55
  /**
56
+ * Insert a new cell
57
+ *
42
58
  * 插入新的单元格
43
- * @param inner 单元格内部wikitext
44
- * @param {TableCoords} coord 单元格坐标
45
- * @param subtype 单元格类型
46
- * @param attr 单元格属性
59
+ * @param inner inner wikitext of the cell / 单元格内部wikitext
60
+ * @param {TableCoords} coord table coordinates of the cell / 单元格坐标
61
+ * @param subtype cell type / 单元格类型
62
+ * @param attr cell attribute / 单元格属性
47
63
  */
48
64
  insertTableCell(inner: string | Token, { column }: TableCoords, subtype?: TdSubtypes, attr?: TdAttrs): TdToken;
49
65
  }
@@ -9,7 +9,11 @@ const debug_1 = require("../../util/debug");
9
9
  const constants_1 = require("../../util/constants");
10
10
  const html_1 = require("../../util/html");
11
11
  const index_1 = require("../index");
12
- /** 表格行或表格 */
12
+ /**
13
+ * table row or table
14
+ *
15
+ * 表格行或表格
16
+ */
13
17
  class TrBaseToken extends base_1.TableBaseToken {
14
18
  /** @private */
15
19
  lint(start = this.getAbsoluteIndex(), re) {
@@ -39,19 +43,23 @@ class TrBaseToken extends base_1.TableBaseToken {
39
43
  errors.push(error);
40
44
  return errors;
41
45
  }
42
- /** 获取行数 */
46
+ /**
47
+ * Get the number of rows
48
+ *
49
+ * 获取行数
50
+ */
43
51
  getRowCount() {
44
- return Number(this.childNodes.some(child => child instanceof td_1.TdToken && child.isIndependent() && !child.firstChild.text().endsWith('+')));
52
+ return Number(this.childNodes.some(child => child instanceof td_1.TdToken
53
+ && child.isIndependent()
54
+ && !child.firstChild.text().endsWith('+')));
45
55
  }
46
56
  getNthCol(n, insert) {
47
- /* NOT FOR BROWSER */
48
57
  const nCols = this.getColCount();
49
58
  n += n < 0 ? nCols : 0;
50
59
  /* istanbul ignore if */
51
60
  if (n < 0 || n > nCols || n === nCols && !insert) {
52
61
  throw new RangeError(`There is no cell at position ${n}!`);
53
62
  }
54
- /* NOT FOR BROWSER END */
55
63
  let last = 0;
56
64
  for (const child of this.childNodes.slice(2)) {
57
65
  if (child instanceof td_1.TdToken) {
@@ -62,16 +70,13 @@ class TrBaseToken extends base_1.TableBaseToken {
62
70
  if (n < 0) {
63
71
  return child;
64
72
  }
65
- /* NOT FOR BROWSER */
66
73
  }
67
74
  else if (child.is('tr') || child.is('table-syntax')) {
68
75
  return child;
69
- /* NOT FOR BROWSER END */
70
76
  }
71
77
  }
72
78
  return undefined;
73
79
  }
74
- /* NOT FOR BROWSER */
75
80
  /** 修复简单的表格语法错误 */
76
81
  #correct() {
77
82
  const { childNodes: [, , child] } = this;
@@ -97,7 +102,7 @@ class TrBaseToken extends base_1.TableBaseToken {
97
102
  }
98
103
  /**
99
104
  * @override
100
- * @param i 移除位置
105
+ * @param i position of the child node / 移除位置
101
106
  */
102
107
  removeAt(i) {
103
108
  i += i < 0 ? this.length : 0;
@@ -112,8 +117,8 @@ class TrBaseToken extends base_1.TableBaseToken {
112
117
  }
113
118
  /**
114
119
  * @override
115
- * @param token 待插入的子节点
116
- * @param i 插入位置
120
+ * @param token node to be inserted / 待插入的子节点
121
+ * @param i position to be inserted at / 插入位置
117
122
  */
118
123
  insertAt(token, i = this.length) {
119
124
  if (!debug_1.Shadow.running && token.type !== 'td') {
@@ -132,7 +137,11 @@ class TrBaseToken extends base_1.TableBaseToken {
132
137
  }
133
138
  return super.insertAt(token, i);
134
139
  }
135
- /** 获取列数 */
140
+ /**
141
+ * Get the number of columns
142
+ *
143
+ * 获取列数
144
+ */
136
145
  getColCount() {
137
146
  let count = 0, last = 0;
138
147
  for (const child of this.childNodes) {
@@ -144,15 +153,16 @@ class TrBaseToken extends base_1.TableBaseToken {
144
153
  return count;
145
154
  }
146
155
  /**
156
+ * Insert a new cell
157
+ *
147
158
  * 插入新的单元格
148
- * @param inner 单元格内部wikitext
149
- * @param {TableCoords} coord 单元格坐标
150
- * @param subtype 单元格类型
151
- * @param attr 单元格属性
159
+ * @param inner inner wikitext of the cell / 单元格内部wikitext
160
+ * @param {TableCoords} coord table coordinates of the cell / 单元格坐标
161
+ * @param subtype cell type / 单元格类型
162
+ * @param attr cell attribute / 单元格属性
152
163
  */
153
164
  insertTableCell(inner, { column }, subtype = 'td', attr = {}) {
154
- const token = (0, td_1.createTd)(inner, subtype, attr, this.getAttribute('include'), this.getAttribute('config'));
155
- return this.insertBefore(token, this.getNthCol(column, true));
165
+ return this.insertBefore((0, td_1.createTd)(inner, subtype, attr, this.getAttribute('include'), this.getAttribute('config')), this.getNthCol(column, true));
156
166
  }
157
167
  /** @private */
158
168
  toHtmlInternal(opt) {
@@ -7,6 +7,8 @@ import type { AttributesParentBase } from '../../mixin/attributesParent';
7
7
  export interface ExtToken extends AttributesParentBase {
8
8
  }
9
9
  /**
10
+ * extension tag
11
+ *
10
12
  * 扩展标签
11
13
  * @classdesc `{childNodes: [AttributesToken, Token]}`
12
14
  */
@@ -20,10 +22,10 @@ export declare abstract class ExtToken extends TagPairToken {
20
22
  get type(): 'ext';
21
23
  /**
22
24
  * @param name 标签名
23
- * @param include 是否嵌入
24
25
  * @param attr 标签属性
25
26
  * @param inner 内部wikitext
26
27
  * @param closed 是否封闭
28
+ * @param include 是否嵌入
27
29
  */
28
30
  constructor(name: string, attr?: string, inner?: string, closed?: string, config?: Parser.Config, include?: boolean, accum?: Token[]);
29
31
  cloneNode(): this;
@@ -52,7 +52,6 @@ const index_5 = require("../nowiki/index");
52
52
  const debug_1 = require("../../util/debug");
53
53
  const constants_1 = require("../../util/constants");
54
54
  const string_1 = require("../../util/string");
55
- const html_1 = require("../../util/html");
56
55
  /**
57
56
  * 从数组中删除指定元素
58
57
  * @param arr 数组
@@ -64,6 +63,8 @@ const del = (arr, ele) => {
64
63
  return [...set];
65
64
  };
66
65
  /**
66
+ * extension tag
67
+ *
67
68
  * 扩展标签
68
69
  * @classdesc `{childNodes: [AttributesToken, Token]}`
69
70
  */
@@ -88,10 +89,10 @@ let ExtToken = (() => {
88
89
  }
89
90
  /**
90
91
  * @param name 标签名
91
- * @param include 是否嵌入
92
92
  * @param attr 标签属性
93
93
  * @param inner 内部wikitext
94
94
  * @param closed 是否封闭
95
+ * @param include 是否嵌入
95
96
  */
96
97
  constructor(name, attr, inner, closed, config = index_1.default.getConfig(), include = false, accum = []) {
97
98
  const lcName = name.toLowerCase(),
@@ -200,13 +201,14 @@ let ExtToken = (() => {
200
201
  const { name, firstChild, lastChild } = this;
201
202
  switch (name) {
202
203
  case 'nowiki':
203
- return (0, html_1.font)(this, (0, string_1.newline)(lastChild.toHtmlInternal()));
204
+ return (0, string_1.newline)(lastChild.toHtmlInternal());
204
205
  case 'pre':
205
- return (0, html_1.font)(this, `<pre${firstChild.toHtmlInternal()}>${(0, string_1.newline)(lastChild.toHtmlInternal({ ...opt, nowrap: false }))}</pre>`);
206
+ return `<pre${firstChild.toHtmlInternal()}>${(0, string_1.newline)(lastChild.toHtmlInternal({ ...opt, nowrap: false }))}</pre>`;
206
207
  case 'poem':
207
208
  firstChild.classList.add('poem');
208
- return (0, html_1.font)(this, `<div${firstChild.toHtmlInternal()}>${lastChild.toHtmlInternal({ ...opt, nowrap: false }).replace(/(?<!^|<hr>)\n(?!$)/gu, '<br>\n')
209
- .replace(/^ +/gmu, p => '&nbsp;'.repeat(p.length))}</div>`);
209
+ return `<div${firstChild.toHtmlInternal()}>${lastChild.toHtmlInternal({ ...opt, nowrap: false })
210
+ .replace(/(?<!^|<hr>)\n(?!$)/gu, '<br>\n')
211
+ .replace(/^ +/gmu, p => '&nbsp;'.repeat(p.length))}</div>`;
210
212
  case 'gallery': {
211
213
  const caption = firstChild.getAttrToken('caption'), perrow = parseInt(String(firstChild.getAttr('perrow'))), mode = firstChild.getAttr('mode'), nolines = typeof mode === 'string' && mode.toLowerCase() === 'nolines', padding = nolines ? 9 : 43;
212
214
  firstChild.classList.add('gallery');
@@ -217,9 +219,9 @@ let ExtToken = (() => {
217
219
  const style = firstChild.getAttr('style');
218
220
  firstChild.setAttr('style', `max-width: ${(lastChild.widths + padding) * perrow}px;${typeof style === 'string' ? style : ''}`);
219
221
  }
220
- return (0, html_1.font)(this, `<ul${firstChild.toHtmlInternal()}>\n${caption
222
+ return `<ul${firstChild.toHtmlInternal()}>\n${caption
221
223
  ? `\t<li class="gallerycaption">${caption.lastChild.toHtmlInternal({ nowrap: true })}</li>\n`
222
- : ''}${lastChild.toHtmlInternal()}\n</ul>`);
224
+ : ''}${lastChild.toHtmlInternal()}\n</ul>`;
223
225
  }
224
226
  default:
225
227
  return '';
@@ -2,6 +2,8 @@ import { TagPairToken } from './index';
2
2
  import type { LintError, Config } from '../../base';
3
3
  import type { AstText, Token } from '../../internal';
4
4
  /**
5
+ * `<includeonly>`, `<noinclude>` or `<onlyinclude>`
6
+ *
5
7
  * `<includeonly>`或`<noinclude>`或`<onlyinclude>`
6
8
  * @classdesc `{childNodes: [AstText, AstText]}`
7
9
  */
@@ -25,9 +27,13 @@ export declare abstract class IncludeToken extends TagPairToken {
25
27
  cloneNode(): this;
26
28
  /**
27
29
  * @override
28
- * @param str 新文本
30
+ * @param str new text / 新文本
29
31
  */
30
32
  setText(str: string): string;
31
- /** 清除标签属性 */
33
+ /**
34
+ * Remove tag attributes
35
+ *
36
+ * 清除标签属性
37
+ */
32
38
  removeAttr(): void;
33
39
  }
@@ -45,6 +45,8 @@ const debug_1 = require("../../util/debug");
45
45
  const constants_1 = require("../../util/constants");
46
46
  /* NOT FOR BROWSER END */
47
47
  /**
48
+ * `<includeonly>`, `<noinclude>` or `<onlyinclude>`
49
+ *
48
50
  * `<includeonly>`或`<noinclude>`或`<onlyinclude>`
49
51
  * @classdesc `{childNodes: [AstText, AstText]}`
50
52
  */
@@ -117,12 +119,16 @@ let IncludeToken = (() => {
117
119
  }
118
120
  /**
119
121
  * @override
120
- * @param str 新文本
122
+ * @param str new text / 新文本
121
123
  */
122
124
  setText(str) {
123
125
  return super.setText(str, 1);
124
126
  }
125
- /** 清除标签属性 */
127
+ /**
128
+ * Remove tag attributes
129
+ *
130
+ * 清除标签属性
131
+ */
126
132
  removeAttr() {
127
133
  super.setText('');
128
134
  }
@@ -1,7 +1,11 @@
1
1
  import { Token } from '../index';
2
2
  import type { Config } from '../../base';
3
3
  import type { AstNodes } from '../../lib/node';
4
- /** 成对标签 */
4
+ /**
5
+ * Paired tags
6
+ *
7
+ * 成对标签
8
+ */
5
9
  export declare abstract class TagPairToken extends Token {
6
10
  #private;
7
11
  readonly name: string;
@@ -11,7 +15,7 @@ export declare abstract class TagPairToken extends Token {
11
15
  readonly childNodes: readonly [AstNodes, AstNodes];
12
16
  abstract get firstChild(): AstNodes;
13
17
  abstract get lastChild(): AstNodes;
14
- /** 内部wikitext */
18
+ /** inner wikitext / 内部wikitext */
15
19
  get innerText(): string | undefined;
16
20
  /**
17
21
  * @param name 标签名
@@ -41,7 +41,11 @@ const constants_1 = require("../../util/constants");
41
41
  const fixed_1 = require("../../mixin/fixed");
42
42
  const index_2 = require("../../index");
43
43
  /* NOT FOR BROWSER END */
44
- /** 成对标签 */
44
+ /**
45
+ * Paired tags
46
+ *
47
+ * 成对标签
48
+ */
45
49
  let TagPairToken = (() => {
46
50
  let _classDecorators = [fixed_1.fixedToken];
47
51
  let _classDescriptor;
@@ -61,7 +65,7 @@ let TagPairToken = (() => {
61
65
  closed;
62
66
  selfClosing;
63
67
  /* NOT FOR BROWSER END */
64
- /** 内部wikitext */
68
+ /** inner wikitext / 内部wikitext */
65
69
  get innerText() {
66
70
  return this.selfClosing ? undefined : this.lastChild.text();
67
71
  }
@@ -6,8 +6,10 @@ import { SyntaxToken } from './syntax';
6
6
  import type { LintError } from '../base';
7
7
  declare type Child = AtomToken | SyntaxToken;
8
8
  /**
9
+ * template or magic word
10
+ *
9
11
  * 模板或魔术字
10
- * @classdesc `{childNodes: [AtomToken|SyntaxToken, ...AtomToken, ...ParameterToken]}`
12
+ * @classdesc `{childNodes: [AtomToken|SyntaxToken, ...AtomToken[], ...ParameterToken[]]}`
11
13
  */
12
14
  export declare abstract class TranscludeToken extends Token {
13
15
  #private;
@@ -20,7 +22,7 @@ export declare abstract class TranscludeToken extends Token {
20
22
  abstract get firstElementChild(): Child;
21
23
  abstract get lastElementChild(): Child | ParameterToken;
22
24
  get type(): 'template' | 'magic-word';
23
- /** 是否存在重复参数 */
25
+ /** whether to contain duplicated parameters / 是否存在重复参数 */
24
26
  get duplication(): boolean;
25
27
  set duplication(duplication: boolean);
26
28
  /**
@@ -30,134 +32,201 @@ export declare abstract class TranscludeToken extends Token {
30
32
  */
31
33
  constructor(title: string, parts: ([string] | [string | number, string])[], config?: Parser.Config, accum?: Token[]);
32
34
  /**
35
+ * Set the transclusion modifier
36
+ *
33
37
  * 设置引用修饰符
34
- * @param modifier 引用修饰符
38
+ * @param modifier transclusion modifier / 引用修饰符
35
39
  */
36
40
  setModifier(modifier: string): boolean;
37
- /** 是否是模板或模块 */
41
+ /**
42
+ * Check if it is a template or a module
43
+ *
44
+ * 是否是模板或模块
45
+ */
38
46
  isTemplate(): boolean;
39
47
  /**
48
+ * Get the module name and module function name
49
+ *
40
50
  * 获取模块名和模块函数名
41
51
  * @throws `Error` 仅用于模块
42
52
  */
43
53
  getModule(): [string, string | undefined];
44
54
  /**
45
55
  * @override
46
- * @param token 待插入的子节点
47
- * @param i 插入位置
56
+ * @param token node to be inserted / 待插入的子节点
57
+ * @param i position to be inserted at / 插入位置
48
58
  */
49
59
  insertAt<T extends ParameterToken>(token: T, i?: number): T;
50
- /** 获取所有参数 */
60
+ /**
61
+ * Get all parameters
62
+ *
63
+ * 获取所有参数
64
+ */
51
65
  getAllArgs(): ParameterToken[];
52
- /** 获取所有匿名参数 */
66
+ /**
67
+ * Get all anonymous parameters
68
+ *
69
+ * 获取所有匿名参数
70
+ */
53
71
  getAnonArgs(): ParameterToken[];
54
72
  /**
73
+ * Get parameters with the specified name
74
+ *
55
75
  * 获取指定参数
56
- * @param key 参数名
57
- * @param exact 是否匹配匿名性
58
- * @param copy 是否返回一个备份
76
+ * @param key parameter name / 参数名
77
+ * @param exact whether to match anonymosity / 是否匹配匿名性
78
+ * @param copy whether to return a copy / 是否返回一个备份
59
79
  */
60
80
  getArgs(key: string | number, exact?: boolean, copy?: boolean): Set<ParameterToken>;
61
81
  /**
82
+ * Get duplicated parameters
83
+ *
62
84
  * 获取重名参数
63
85
  * @throws `Error` 仅用于模板
64
86
  */
65
87
  getDuplicatedArgs(): [string, ParameterToken[]][];
66
88
  /**
89
+ * Get possible values of some magic words
90
+ *
67
91
  * 对特定魔术字获取可能的取值
68
92
  * @throws `Error` 不是可接受的魔术字
69
93
  */
70
94
  getPossibleValues(): Token[];
71
95
  cloneNode(): this;
72
- /** 替换引用 */
96
+ /**
97
+ * Convert to substitution
98
+ *
99
+ * 替换引用
100
+ */
73
101
  subst(): void;
74
- /** 安全的替换引用 */
102
+ /**
103
+ * Convert to safe substitution
104
+ *
105
+ * 安全的替换引用
106
+ */
75
107
  safesubst(): void;
76
108
  /**
77
109
  * @override
78
- * @param i 移除位置
110
+ * @param i position of the child node / 移除位置
79
111
  */
80
112
  removeAt(i: number): ParameterToken;
81
113
  /**
114
+ * Check if there is a parameter with the specified name
115
+ *
82
116
  * 是否具有某参数
83
- * @param key 参数名
84
- * @param exact 是否匹配匿名性
117
+ * @param key parameter name / 参数名
118
+ * @param exact whether to match anonymosity / 是否匹配匿名性
85
119
  */
86
120
  hasArg(key: string | number, exact?: boolean): boolean;
87
121
  /**
122
+ * Get the effective parameter with the specified name
123
+ *
88
124
  * 获取生效的指定参数
89
- * @param key 参数名
90
- * @param exact 是否匹配匿名性
125
+ * @param key parameter name / 参数名
126
+ * @param exact whether to match anonymosity / 是否匹配匿名性
91
127
  */
92
128
  getArg(key: string | number, exact?: boolean): ParameterToken | undefined;
93
129
  /**
130
+ * Remove parameters with the specified name
131
+ *
94
132
  * 移除指定参数
95
- * @param key 参数名
96
- * @param exact 是否匹配匿名性
133
+ * @param key parameter name / 参数名
134
+ * @param exact whether to match anonymosity / 是否匹配匿名性
97
135
  */
98
136
  removeArg(key: string | number, exact?: boolean): void;
99
- /** 获取所有参数名 */
137
+ /**
138
+ * Get all parameter names
139
+ *
140
+ * 获取所有参数名
141
+ */
100
142
  getKeys(): string[];
101
143
  /**
144
+ * Get parameter values
145
+ *
102
146
  * 获取参数值
103
- * @param key 参数名
147
+ * @param key parameter name / 参数名
104
148
  */
105
149
  getValues(key: string | number): string[];
106
150
  /**
151
+ * Get the effective parameter value
152
+ *
107
153
  * 获取生效的参数值
108
- * @param key 参数名
154
+ * @param key parameter name / 参数名
109
155
  */
110
156
  getValue(): Record<string, string>;
111
157
  getValue(key: string | number): string | undefined;
112
158
  /**
159
+ * Insert an anonymous parameter
160
+ *
113
161
  * 插入匿名参数
114
- * @param val 参数值
162
+ * @param val parameter value / 参数值
115
163
  */
116
164
  newAnonArg(val: string): ParameterToken;
117
165
  /**
166
+ * Set the parameter value
167
+ *
118
168
  * 设置参数值
119
- * @param key 参数名
120
- * @param value 参数值
169
+ * @param key parameter name / 参数名
170
+ * @param value parameter value / 参数值
121
171
  * @throws `Error` 仅用于模板
122
172
  */
123
173
  setValue(key: string, value: string): void;
124
174
  /**
175
+ * Convert all anonymous parameters to named ones
176
+ *
125
177
  * 将匿名参数改写为命名参数
126
178
  * @throws `Error` 仅用于模板
127
179
  */
128
180
  anonToNamed(): void;
129
181
  /**
182
+ * Replace the template name
183
+ *
130
184
  * 替换模板名
131
- * @param title 模板名
185
+ * @param title template name / 模板名
132
186
  * @throws `Error` 仅用于模板
133
187
  */
134
188
  replaceTemplate(title: string): void;
135
189
  /**
190
+ * Replace the module name
191
+ *
136
192
  * 替换模块名
137
- * @param title 模块名
193
+ * @param title module name / 模块名
138
194
  * @throws `Error` 仅用于模块
139
195
  */
140
196
  replaceModule(title: string): void;
141
197
  /**
198
+ * Replace the module function
199
+ *
142
200
  * 替换模块函数
143
- * @param func 模块函数名
201
+ * @param func module function name / 模块函数名
144
202
  * @throws `Error` 仅用于模块
145
203
  * @throws `Error` 尚未指定模块名称
146
204
  */
147
205
  replaceFunction(func: string): void;
148
206
  /**
207
+ * Count duplicated parameters
208
+ *
149
209
  * 重复参数计数
150
210
  * @throws `Error` 仅用于模板
151
211
  */
152
212
  hasDuplicatedArgs(): number;
153
213
  /**
154
- * 修复重名参数:
155
- * `aggressive = false`时只移除空参数和全同参数,优先保留匿名参数,否则将所有匿名参数更改为命名。
156
- * `aggressive = true`时还会尝试处理连续的以数字编号的参数。
157
- * @param aggressive 是否使用有更大风险的修复手段
214
+ * Fix duplicated parameters
215
+ * @description
216
+ * - Only empty parameters and identical parameters are removed with `aggressive = false`.
217
+ * Anonymous parameters have a higher precedence, otherwise all anonymous parameters are converted to named ones.
218
+ * - Additionally, consecutive numbered parameters are treated with `aggressive = true`.
219
+ *
220
+ * 修复重名参数
221
+ * @description
222
+ * - `aggressive = false`时只移除空参数和全同参数,优先保留匿名参数,否则将所有匿名参数更改为命名。
223
+ * - `aggressive = true`时还会尝试处理连续的以数字编号的参数。
224
+ * @param aggressive whether to use a more risky approach / 是否使用有更大风险的修复手段
158
225
  */
159
226
  fixDuplication(aggressive?: boolean): string[];
160
227
  /**
228
+ * Escape tables inside the template
229
+ *
161
230
  * 转义模板内的表格
162
231
  * @throws `Error` 转义失败
163
232
  */