wikilint 2.16.4 → 2.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 (120) hide show
  1. package/dist/base.d.mts +84 -27
  2. package/dist/base.d.ts +84 -27
  3. package/dist/bin/cli.js +2 -1
  4. package/dist/index.d.ts +8 -4
  5. package/dist/index.js +55 -11
  6. package/dist/lib/element.d.ts +42 -16
  7. package/dist/lib/element.js +44 -17
  8. package/dist/lib/lsp.d.ts +64 -35
  9. package/dist/lib/lsp.js +99 -71
  10. package/dist/lib/node.d.ts +50 -18
  11. package/dist/lib/node.js +66 -27
  12. package/dist/lib/text.d.ts +8 -2
  13. package/dist/lib/text.js +10 -3
  14. package/dist/lib/title.d.ts +19 -10
  15. package/dist/lib/title.js +28 -22
  16. package/dist/mixin/attributesParent.d.ts +4 -4
  17. package/dist/mixin/attributesParent.js +0 -2
  18. package/dist/mixin/hidden.d.ts +0 -2
  19. package/dist/mixin/hidden.js +0 -2
  20. package/dist/parser/braces.js +4 -2
  21. package/dist/parser/links.js +8 -7
  22. package/dist/parser/list.js +3 -1
  23. package/dist/parser/quotes.js +2 -1
  24. package/dist/parser/redirect.js +4 -1
  25. package/dist/src/arg.d.ts +4 -2
  26. package/dist/src/arg.js +8 -4
  27. package/dist/src/atom.d.ts +5 -1
  28. package/dist/src/atom.js +5 -1
  29. package/dist/src/attribute.d.ts +9 -3
  30. package/dist/src/attribute.js +9 -3
  31. package/dist/src/attributes.d.ts +12 -4
  32. package/dist/src/attributes.js +12 -4
  33. package/dist/src/converter.d.ts +3 -1
  34. package/dist/src/converter.js +8 -5
  35. package/dist/src/converterFlags.d.ts +13 -3
  36. package/dist/src/converterFlags.js +13 -3
  37. package/dist/src/converterRule.d.ts +3 -1
  38. package/dist/src/converterRule.js +3 -1
  39. package/dist/src/extLink.d.ts +2 -0
  40. package/dist/src/extLink.js +2 -0
  41. package/dist/src/gallery.d.ts +3 -1
  42. package/dist/src/gallery.js +7 -5
  43. package/dist/src/heading.d.ts +3 -1
  44. package/dist/src/heading.js +4 -2
  45. package/dist/src/hidden.d.ts +5 -1
  46. package/dist/src/hidden.js +5 -1
  47. package/dist/src/html.d.ts +6 -2
  48. package/dist/src/html.js +6 -2
  49. package/dist/src/imageParameter.d.ts +11 -3
  50. package/dist/src/imageParameter.js +12 -4
  51. package/dist/src/imagemap.d.ts +1 -1
  52. package/dist/src/imagemap.js +5 -4
  53. package/dist/src/imagemapLink.d.ts +2 -0
  54. package/dist/src/imagemapLink.js +2 -0
  55. package/dist/src/index.d.ts +5 -3
  56. package/dist/src/index.js +28 -18
  57. package/dist/src/link/base.d.ts +4 -2
  58. package/dist/src/link/base.js +12 -6
  59. package/dist/src/link/category.d.ts +2 -0
  60. package/dist/src/link/category.js +2 -0
  61. package/dist/src/link/file.d.ts +17 -7
  62. package/dist/src/link/file.js +28 -14
  63. package/dist/src/link/galleryImage.d.ts +5 -1
  64. package/dist/src/link/galleryImage.js +9 -5
  65. package/dist/src/link/index.d.ts +2 -0
  66. package/dist/src/link/index.js +2 -0
  67. package/dist/src/link/redirectTarget.d.ts +2 -1
  68. package/dist/src/link/redirectTarget.js +4 -2
  69. package/dist/src/magicLink.d.ts +8 -4
  70. package/dist/src/magicLink.js +16 -9
  71. package/dist/src/nested.d.ts +3 -1
  72. package/dist/src/nested.js +7 -4
  73. package/dist/src/nowiki/base.d.ts +3 -1
  74. package/dist/src/nowiki/base.js +3 -1
  75. package/dist/src/nowiki/comment.d.ts +5 -1
  76. package/dist/src/nowiki/comment.js +5 -1
  77. package/dist/src/nowiki/doubleUnderscore.d.ts +5 -1
  78. package/dist/src/nowiki/doubleUnderscore.js +5 -1
  79. package/dist/src/nowiki/index.d.ts +5 -1
  80. package/dist/src/nowiki/index.js +5 -1
  81. package/dist/src/nowiki/list.d.ts +5 -1
  82. package/dist/src/nowiki/list.js +5 -1
  83. package/dist/src/nowiki/noinclude.d.ts +5 -1
  84. package/dist/src/nowiki/noinclude.js +5 -1
  85. package/dist/src/nowiki/quote.d.ts +5 -1
  86. package/dist/src/nowiki/quote.js +5 -1
  87. package/dist/src/onlyinclude.d.ts +3 -1
  88. package/dist/src/onlyinclude.js +3 -1
  89. package/dist/src/paramTag/index.d.ts +1 -1
  90. package/dist/src/paramTag/index.js +1 -1
  91. package/dist/src/parameter.d.ts +3 -1
  92. package/dist/src/parameter.js +3 -1
  93. package/dist/src/pre.d.ts +1 -1
  94. package/dist/src/pre.js +1 -1
  95. package/dist/src/redirect.d.ts +2 -0
  96. package/dist/src/redirect.js +2 -0
  97. package/dist/src/syntax.d.ts +5 -1
  98. package/dist/src/syntax.js +5 -1
  99. package/dist/src/table/base.js +3 -1
  100. package/dist/src/table/index.d.ts +20 -15
  101. package/dist/src/table/index.js +22 -23
  102. package/dist/src/table/td.d.ts +9 -3
  103. package/dist/src/table/td.js +9 -3
  104. package/dist/src/table/tr.d.ts +3 -1
  105. package/dist/src/table/tr.js +4 -2
  106. package/dist/src/table/trBase.d.ts +9 -9
  107. package/dist/src/table/trBase.js +13 -18
  108. package/dist/src/tagPair/ext.d.ts +3 -1
  109. package/dist/src/tagPair/ext.js +3 -1
  110. package/dist/src/tagPair/include.d.ts +2 -0
  111. package/dist/src/tagPair/include.js +2 -0
  112. package/dist/src/tagPair/index.d.ts +6 -2
  113. package/dist/src/tagPair/index.js +6 -2
  114. package/dist/src/transclude.d.ts +34 -10
  115. package/dist/src/transclude.js +47 -17
  116. package/dist/util/debug.js +2 -16
  117. package/dist/util/string.js +2 -0
  118. package/i18n/zh-hans.json +1 -1
  119. package/i18n/zh-hant.json +1 -1
  120. package/package.json +2 -2
package/dist/lib/text.js CHANGED
@@ -57,7 +57,11 @@ try {
57
57
  catch /* istanbul ignore next */ {
58
58
  wordRegex = /\w/u;
59
59
  }
60
- /** 文本节点 */
60
+ /**
61
+ * text node
62
+ *
63
+ * 文本节点
64
+ */
61
65
  class AstText extends node_1.AstNode {
62
66
  data = '';
63
67
  get type() {
@@ -134,7 +138,8 @@ class AstText extends node_1.AstNode {
134
138
  const { 0: char, length } = error, magicLink = char === 'r' || char === 'p' || char === 'i';
135
139
  if (char === '<' && !tags.has(tag.toLowerCase())
136
140
  || char === '[' && type === 'ext-link-text' && (/&(?:rbrack|#93|#x5[Dd];);/u.test(data.slice(index + 1))
137
- || nextSibling?.is('ext') && nextName === 'nowiki' && nextSibling.innerText?.includes(']'))
141
+ || nextSibling?.is('ext') && nextName === 'nowiki'
142
+ && nextSibling.innerText?.includes(']'))
138
143
  || magicLink && (!parentNode.getAttribute('plain') || noLinkTypes.has(type))) {
139
144
  continue;
140
145
  }
@@ -221,8 +226,10 @@ class AstText extends node_1.AstNode {
221
226
  this.setAttribute('data', text);
222
227
  }
223
228
  /**
229
+ * Replace the text
230
+ *
224
231
  * 替换字符串
225
- * @param text 替换的字符串
232
+ * @param text new text / 替换的字符串
226
233
  */
227
234
  replaceData(text) {
228
235
  this.#setData(text);
@@ -1,21 +1,24 @@
1
1
  import type { Config } from '../base';
2
- /** MediaWiki页面标题对象 */
2
+ /**
3
+ * title object of a MediaWiki page
4
+ *
5
+ * MediaWiki页面标题对象
6
+ */
3
7
  export declare class Title {
4
8
  #private;
5
- interwiki: string;
6
9
  readonly valid: boolean;
7
- /** 命名空间 */
10
+ /** namespace number / 命名空间 */
8
11
  get ns(): number;
9
12
  /** 片段标识符 */
10
13
  get fragment(): string | undefined;
11
- /** 不含命名空间的标题主体部分 */
14
+ /** main part without the namespace / 不含命名空间的标题主体部分 */
12
15
  get main(): string;
13
16
  set main(title: string);
14
- /** 命名空间前缀 */
17
+ /** namespace prefix / 命名空间前缀 */
15
18
  get prefix(): string;
16
- /** 完整标题 */
19
+ /** full title / 完整标题 */
17
20
  get title(): string;
18
- /** 扩展名 */
21
+ /** file extension / 扩展名 */
19
22
  get extension(): string | undefined;
20
23
  /**
21
24
  * @see MediaWikiTitleCodec::splitTitleString
@@ -25,12 +28,18 @@ export declare class Title {
25
28
  * @param decode 是否需要解码
26
29
  * @param selfLink 是否允许selfLink
27
30
  */
28
- constructor(title: string, defaultNs: number, config: Config, decode: boolean, selfLink: boolean);
29
- /** 检测是否是重定向 */
31
+ constructor(title: string, defaultNs: number, config: Config, temporary: boolean, decode: boolean, selfLink: boolean);
32
+ /**
33
+ * Check if the title is a redirect
34
+ *
35
+ * 检测是否是重定向
36
+ */
30
37
  getRedirection(): [boolean, string];
31
38
  /**
39
+ * Get the URL of the title
40
+ *
32
41
  * 生成URL
33
- * @param articlePath 条目路径
42
+ * @param articlePath article path / 条目路径
34
43
  */
35
44
  getUrl(articlePath?: string): string;
36
45
  }
package/dist/lib/title.js CHANGED
@@ -2,18 +2,21 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Title = void 0;
4
4
  const string_1 = require("../util/string");
5
- /** MediaWiki页面标题对象 */
5
+ /**
6
+ * title object of a MediaWiki page
7
+ *
8
+ * MediaWiki页面标题对象
9
+ */
6
10
  class Title {
7
11
  #main;
8
12
  #namespaces;
9
13
  #path;
10
14
  #ns;
11
15
  #fragment;
12
- interwiki = '';
13
16
  valid;
14
17
  /** @private */
15
18
  encoded = false;
16
- /** 命名空间 */
19
+ /** namespace number / 命名空间 */
17
20
  get ns() {
18
21
  return this.#ns;
19
22
  }
@@ -21,7 +24,7 @@ class Title {
21
24
  get fragment() {
22
25
  return this.#fragment;
23
26
  }
24
- /** 不含命名空间的标题主体部分 */
27
+ /** main part without the namespace / 不含命名空间的标题主体部分 */
25
28
  get main() {
26
29
  return this.#main;
27
30
  }
@@ -29,16 +32,16 @@ class Title {
29
32
  title = title.replace(/_/gu, ' ').trim();
30
33
  this.#main = title && title[0].toUpperCase() + title.slice(1);
31
34
  }
32
- /** 命名空间前缀 */
35
+ /** namespace prefix / 命名空间前缀 */
33
36
  get prefix() {
34
37
  const namespace = this.#namespaces[this.ns];
35
38
  return namespace + (namespace && ':');
36
39
  }
37
- /** 完整标题 */
40
+ /** full title / 完整标题 */
38
41
  get title() {
39
42
  return this.getRedirection()[1];
40
43
  }
41
- /** 扩展名 */
44
+ /** file extension / 扩展名 */
42
45
  get extension() {
43
46
  const { main } = this, i = main.lastIndexOf('.');
44
47
  return i === -1 ? undefined : main.slice(i + 1).toLowerCase();
@@ -51,7 +54,7 @@ class Title {
51
54
  * @param decode 是否需要解码
52
55
  * @param selfLink 是否允许selfLink
53
56
  */
54
- constructor(title, defaultNs, config, decode, selfLink) {
57
+ constructor(title, defaultNs, config, temporary, decode, selfLink) {
55
58
  const subpage = title.trim().startsWith('../');
56
59
  if (decode && title.includes('%')) {
57
60
  try {
@@ -93,29 +96,30 @@ class Title {
93
96
  this.#fragment = fragment.replace(/ /gu, '_');
94
97
  title = title.slice(0, i).trim();
95
98
  }
96
- this.valid = Boolean(title || this.interwiki || selfLink && this.ns === 0 && this.#fragment !== undefined)
99
+ this.valid = Boolean(title
100
+ || selfLink && this.ns === 0 && this.#fragment !== undefined)
97
101
  && (0, string_1.decodeHtml)(title) === title
98
102
  && !/^:|\0\d+[eh!+-]\x7F|[<>[\]{}|\n]|%[\da-f]{2}|(?:^|\/)\.{1,2}(?:$|\/)/iu.test(subpage ? /^(?:\.\.\/)+(.*)/u.exec(title)[1] : title);
99
103
  this.main = title;
100
- Object.defineProperties(this, {
101
- encoded: { enumerable: false, writable: false },
102
- });
103
104
  this.#namespaces = config.namespaces;
104
105
  this.#path = config.articlePath || '/wiki/$1';
105
106
  if (!this.#path.includes('$1')) {
106
107
  this.#path += `${this.#path.endsWith('/') ? '' : '/'}$1`;
107
108
  }
109
+ if (!temporary) {
110
+ Object.defineProperties(this, {
111
+ encoded: { enumerable: false, writable: false },
112
+ });
113
+ }
108
114
  }
109
- /** @private */
110
- toString(display) {
111
- return (display ? this.title.replace(/_/gu, ' ') : this.title)
112
- + (this.#fragment === undefined
113
- ? ''
114
- : `#${this.#fragment}`);
115
- }
116
- /** 检测是否是重定向 */
115
+ /**
116
+ * Check if the title is a redirect
117
+ *
118
+ * 检测是否是重定向
119
+ */
117
120
  getRedirection() {
118
- const prefix = this.interwiki + (this.interwiki && ':') + this.prefix;
121
+ // eslint-disable-next-line @typescript-eslint/prefer-destructuring
122
+ const prefix = this.prefix;
119
123
  // eslint-disable-next-line prefer-const
120
124
  let title = (prefix + this.main).replace(/ /gu, '_');
121
125
  return [false, title];
@@ -125,8 +129,10 @@ class Title {
125
129
  this.#fragment = fragment;
126
130
  }
127
131
  /**
132
+ * Get the URL of the title
133
+ *
128
134
  * 生成URL
129
- * @param articlePath 条目路径
135
+ * @param articlePath article path / 条目路径
130
136
  */
131
137
  getUrl(articlePath) {
132
138
  LSP: { // eslint-disable-line no-unused-labels
@@ -1,13 +1,13 @@
1
1
  export interface AttributesParentBase {
2
2
  /**
3
- * 获取AttributesToken子节点的属性
4
- * @param key 属性键
3
+ * Get the attribute
4
+ *
5
+ * 获取指定属性
6
+ * @param key attribute name / 属性键
5
7
  */
6
8
  getAttr(key: string): string | true | undefined;
7
9
  }
8
10
  /**
9
11
  * 子节点含有AttributesToken的类
10
12
  * @param i AttributesToken子节点的位置
11
- * @param constructor 基类
12
- * @param _ context
13
13
  */
@@ -5,8 +5,6 @@ const debug_1 = require("../util/debug");
5
5
  /**
6
6
  * 子节点含有AttributesToken的类
7
7
  * @param i AttributesToken子节点的位置
8
- * @param constructor 基类
9
- * @param _ context
10
8
  */
11
9
  const attributesParent = (i = 0) => (constructor, _) => {
12
10
  /** 子节点含有AttributesToken的类 */
@@ -2,6 +2,4 @@
2
2
  * 解析后不可见的类
3
3
  * @param linter 是否覆写 lint 方法
4
4
  * @param html 是否覆写 toHtml 方法
5
- * @param constructor 基类
6
- * @param _ context
7
5
  */
@@ -6,8 +6,6 @@ const debug_1 = require("../util/debug");
6
6
  * 解析后不可见的类
7
7
  * @param linter 是否覆写 lint 方法
8
8
  * @param html 是否覆写 toHtml 方法
9
- * @param constructor 基类
10
- * @param _ context
11
9
  */
12
10
  const hiddenToken = (linter = true, html = true) => (constructor, _) => {
13
11
  /** 解析后不可见的类 */
@@ -30,7 +30,8 @@ const parseBraces = (wikitext, config, accum) => {
30
30
  let moreBraces = lastBraces + wikitext.length !== -1;
31
31
  let regex = new RegExp(source + (moreBraces ? openBraces : ''), 'gmu'), mt = regex.exec(wikitext), lastIndex;
32
32
  while (mt
33
- || lastIndex !== undefined && lastIndex <= wikitext.length && stack[stack.length - 1]?.[0]?.startsWith('=')) {
33
+ || lastIndex !== undefined && lastIndex <= wikitext.length
34
+ && stack[stack.length - 1]?.[0]?.startsWith('=')) {
34
35
  if (mt?.[1]) {
35
36
  const [, { length }] = mt;
36
37
  mt[0] = mt[0].slice(length);
@@ -80,7 +81,8 @@ const parseBraces = (wikitext, config, accum) => {
80
81
  const argParts = parts.map(part => part.join('=')), str = argParts.length > 1 && (0, string_1.removeComment)(argParts[1]).trim();
81
82
  // @ts-expect-error abstract class
82
83
  new arg_1.ArgToken(argParts, config, accum);
83
- if (str && str.endsWith(':') && subst.includes(str.slice(0, -1).toLowerCase())) {
84
+ if (str && str.endsWith(':')
85
+ && subst.includes(str.slice(0, -1).toLowerCase())) {
84
86
  ch = 's';
85
87
  }
86
88
  }
@@ -14,8 +14,9 @@ const regexImg = /^((?:(?!\0\d+!\x7F)[^\n[\]{}|])+)(\||\0\d+!\x7F)([\s\S]*)$/u;
14
14
  * @param wikitext
15
15
  * @param config
16
16
  * @param accum
17
+ * @param tidy 是否整理链接
17
18
  */
18
- const parseLinks = (wikitext, config, accum) => {
19
+ const parseLinks = (wikitext, config, accum, tidy) => {
19
20
  config.regexLinks ??= new RegExp(String.raw `^\s*(?:${config.protocol}|//)`, 'iu');
20
21
  const regex = true // eslint-disable-line no-constant-condition, @typescript-eslint/no-unnecessary-condition
21
22
  ? /^((?:(?!\0\d+!\x7F)[^\n[\]{}|])+)(?:(\||\0\d+!\x7F)([\s\S]*?[^\]]))?\]\]([\s\S]*)$/u
@@ -47,13 +48,13 @@ const parseLinks = (wikitext, config, accum) => {
47
48
  s += `[[${x}`;
48
49
  continue;
49
50
  }
50
- const title = index_1.default.normalizeTitle(link, 0, false, config, true, true, true), { ns, valid, interwiki } = title;
51
+ const { ns, valid, } = index_1.default.normalizeTitle(link, 0, false, config, true, true, true, true);
51
52
  if (!valid) {
52
53
  s += `[[${x}`;
53
54
  continue;
54
55
  }
55
56
  else if (mightBeImg) {
56
- if (interwiki || ns !== 6) {
57
+ if (ns !== 6) {
57
58
  s += `[[${x}`;
58
59
  continue;
59
60
  }
@@ -74,20 +75,20 @@ const parseLinks = (wikitext, config, accum) => {
74
75
  break;
75
76
  }
76
77
  }
77
- text = (0, exports.parseLinks)(text, config, accum);
78
+ text = (0, exports.parseLinks)(text, config, accum, tidy);
78
79
  if (!found) {
79
80
  s += `[[${link}${delimiter}${text}`;
80
81
  continue;
81
82
  }
82
83
  }
83
- text &&= (0, quotes_1.parseQuotes)(text, config, accum);
84
+ text &&= (0, quotes_1.parseQuotes)(text, config, accum, tidy);
84
85
  let SomeLinkToken = index_2.LinkToken;
85
86
  if (!force) {
86
- if (!interwiki && ns === 6) {
87
+ if (ns === 6) {
87
88
  text &&= (0, externalLinks_1.parseExternalLinks)(text, config, accum, true);
88
89
  SomeLinkToken = file_1.FileToken;
89
90
  }
90
- else if (!interwiki && ns === 14) {
91
+ else if (ns === 14) {
91
92
  SomeLinkToken = category_1.CategoryToken;
92
93
  }
93
94
  }
@@ -31,7 +31,9 @@ const parseList = (wikitext, state, config, accum) => {
31
31
  }
32
32
  }
33
33
  state.lastPrefix = prefix2;
34
- let text = comment + parts.map((_, i) => `\0${accum.length + i}d\x7F`).join('') + wikitext.slice(total.length);
34
+ let text = comment
35
+ + parts.map((_, i) => `\0${accum.length + i}d\x7F`).join('')
36
+ + wikitext.slice(total.length);
35
37
  for (const part of parts) {
36
38
  // @ts-expect-error abstract class
37
39
  new list_1.ListToken(part, config, accum);
@@ -8,8 +8,9 @@ const quote_1 = require("../src/nowiki/quote");
8
8
  * @param wikitext
9
9
  * @param config
10
10
  * @param accum
11
+ * @param tidy 是否整理
11
12
  */
12
- const parseQuotes = (wikitext, config, accum) => {
13
+ const parseQuotes = (wikitext, config, accum, tidy) => {
13
14
  const arr = wikitext.split(/('{2,})/u), { length } = arr;
14
15
  if (length === 1) {
15
16
  return wikitext;
@@ -13,7 +13,10 @@ const redirect_1 = require("../src/redirect");
13
13
  const parseRedirect = (text, config, accum) => {
14
14
  config.regexRedirect ??= new RegExp(String.raw `^(\s*)((?:${config.redirection.join('|')})\s*(?::\s*)?)\[\[([^\n|\]]+)(\|.*?)?\]\](\s*)`, 'iu');
15
15
  const mt = config.regexRedirect.exec(text);
16
- if (mt && index_1.default.normalizeTitle(mt[3], 0, false, config, true, true).valid) {
16
+ if (mt
17
+ && index_1.default
18
+ .normalizeTitle(mt[3], 0, false, config, true, true, true)
19
+ .valid) {
17
20
  text = `\0${accum.length}o\x7F${text.slice(mt[0].length)}`;
18
21
  // @ts-expect-error abstract class
19
22
  new redirect_1.RedirectToken(...mt.slice(1), config, accum);
package/dist/src/arg.d.ts CHANGED
@@ -4,8 +4,10 @@ import { AtomToken } from './atom';
4
4
  import { HiddenToken } from './hidden';
5
5
  import type { LintError } from '../base';
6
6
  /**
7
+ * argument wrapped in `{{{}}}`
8
+ *
7
9
  * `{{{}}}`包裹的参数
8
- * @classdesc `{childNodes: [AtomToken, ?Token, ...HiddenToken]}`
10
+ * @classdesc `{childNodes: [AtomToken, ?Token, ...HiddenToken[]]}`
9
11
  */
10
12
  export declare abstract class ArgToken extends Token {
11
13
  #private;
@@ -14,7 +16,7 @@ export declare abstract class ArgToken extends Token {
14
16
  abstract get firstChild(): AtomToken;
15
17
  abstract get lastChild(): Token;
16
18
  get type(): 'arg';
17
- /** 预设值 */
19
+ /** default value / 预设值 */
18
20
  get default(): string | false;
19
21
  /** @param parts 以'|'分隔的各部分 */
20
22
  constructor(parts: readonly string[], config?: Parser.Config, accum?: Token[]);
package/dist/src/arg.js CHANGED
@@ -9,14 +9,16 @@ const index_2 = require("./index");
9
9
  const atom_1 = require("./atom");
10
10
  const hidden_1 = require("./hidden");
11
11
  /**
12
+ * argument wrapped in `{{{}}}`
13
+ *
12
14
  * `{{{}}}`包裹的参数
13
- * @classdesc `{childNodes: [AtomToken, ?Token, ...HiddenToken]}`
15
+ * @classdesc `{childNodes: [AtomToken, ?Token, ...HiddenToken[]]}`
14
16
  */
15
17
  class ArgToken extends index_2.Token {
16
18
  get type() {
17
19
  return 'arg';
18
20
  }
19
- /** 预设值 */
21
+ /** default value / 预设值 */
20
22
  get default() {
21
23
  return this.childNodes[1]?.text() ?? false;
22
24
  }
@@ -58,11 +60,13 @@ class ArgToken extends index_2.Token {
58
60
  }
59
61
  /** 设置name */
60
62
  #setName() {
61
- this.setAttribute('name', this.firstChild.toString(true).trim());
63
+ // eslint-disable-next-line no-unused-labels
64
+ LSP: this.setAttribute('name', this.firstChild.toString(true).trim());
62
65
  }
63
66
  /** @private */
64
67
  afterBuild() {
65
- this.#setName();
68
+ // eslint-disable-next-line no-unused-labels
69
+ LSP: this.#setName();
66
70
  super.afterBuild();
67
71
  }
68
72
  /** @private */
@@ -2,7 +2,11 @@ import { Token } from './index';
2
2
  import type { Config } from '../base';
3
3
  declare const atomTypes: readonly ["arg-name", "attr-key", "attr-value", "ext-attr-dirty", "html-attr-dirty", "table-attr-dirty", "converter-flag", "converter-rule-variant", "converter-rule-to", "converter-rule-from", "invoke-function", "invoke-module", "template-name", "link-target", "param-line"];
4
4
  declare type AtomTypes = typeof atomTypes[number];
5
- /** 不会被继续解析的plain Token */
5
+ /**
6
+ * plain Token that will not be parsed further
7
+ *
8
+ * 不会被继续解析的plain Token
9
+ */
6
10
  export declare class AtomToken extends Token {
7
11
  #private;
8
12
  get type(): AtomTypes;
package/dist/src/atom.js CHANGED
@@ -20,7 +20,11 @@ const atomTypes = [
20
20
  'link-target',
21
21
  'param-line',
22
22
  ];
23
- /** 不会被继续解析的plain Token */
23
+ /**
24
+ * plain Token that will not be parsed further
25
+ *
26
+ * 不会被继续解析的plain Token
27
+ */
24
28
  class AtomToken extends index_1.Token {
25
29
  #type;
26
30
  get type() {
@@ -6,6 +6,8 @@ import type { AttributesToken } from '../internal';
6
6
  declare type Child = AtomToken | AttributeToken | undefined;
7
7
  export type AttributeTypes = 'ext-attr' | 'html-attr' | 'table-attr';
8
8
  /**
9
+ * attribute of extension and HTML tags
10
+ *
9
11
  * 扩展和HTML标签属性
10
12
  * @classdesc `{childNodes: [AtomToken, Token|AtomToken]}`
11
13
  */
@@ -19,9 +21,9 @@ export declare abstract class AttributeToken extends Token {
19
21
  abstract get nextSibling(): Child;
20
22
  abstract get previousSibling(): Child;
21
23
  get type(): AttributeTypes;
22
- /** 标签名 */
24
+ /** tag name / 标签名 */
23
25
  get tag(): string;
24
- /** 引号是否匹配 */
26
+ /** whether the quotes are balanced / 引号是否匹配 */
25
27
  get balanced(): boolean;
26
28
  /**
27
29
  * @param type 标签类型
@@ -32,7 +34,11 @@ export declare abstract class AttributeToken extends Token {
32
34
  * @param quotes 引号
33
35
  */
34
36
  constructor(type: AttributeTypes, tag: string, key: string, equal?: string, value?: string, quotes?: readonly [string?, string?], config?: Parser.Config, accum?: Token[]);
35
- /** 获取属性值 */
37
+ /**
38
+ * Get the attribute value
39
+ *
40
+ * 获取属性值
41
+ */
36
42
  getValue(): string | true;
37
43
  }
38
44
  export {};
@@ -11,6 +11,8 @@ const index_2 = require("./index");
11
11
  const atom_1 = require("./atom");
12
12
  const insecureStyle = /expression|(?:accelerator|-o-link(?:-source)?|-o-replace)\s*:|(?:url|image(?:-set)?)\s*\(|attr\s*\([^)]+[\s,]url/u;
13
13
  /**
14
+ * attribute of extension and HTML tags
15
+ *
14
16
  * 扩展和HTML标签属性
15
17
  * @classdesc `{childNodes: [AtomToken, Token|AtomToken]}`
16
18
  */
@@ -22,11 +24,11 @@ class AttributeToken extends index_2.Token {
22
24
  get type() {
23
25
  return this.#type;
24
26
  }
25
- /** 标签名 */
27
+ /** tag name / 标签名 */
26
28
  get tag() {
27
29
  return this.#tag;
28
30
  }
29
- /** 引号是否匹配 */
31
+ /** whether the quotes are balanced / 引号是否匹配 */
30
32
  get balanced() {
31
33
  return !this.#equal || this.#quotes[0] === this.#quotes[1];
32
34
  }
@@ -129,7 +131,11 @@ class AttributeToken extends index_2.Token {
129
131
  }
130
132
  return errors;
131
133
  }
132
- /** 获取属性值 */
134
+ /**
135
+ * Get the attribute value
136
+ *
137
+ * 获取属性值
138
+ */
133
139
  getValue() {
134
140
  return this.#equal ? this.lastChild.text().trim() : this.type === 'ext-attr' || '';
135
141
  }
@@ -9,8 +9,10 @@ import type { TableTokens } from './table/index';
9
9
  declare type AttributesTypes = `${AttributeTypes}s`;
10
10
  declare type Child = AtomToken | AttributeToken;
11
11
  /**
12
+ * attributes of extension and HTML tags
13
+ *
12
14
  * 扩展和HTML标签属性
13
- * @classdesc `{childNodes: ...AtomToken|AttributeToken}`
15
+ * @classdesc `{childNodes: (AtomToken|AttributeToken)[]}`
14
16
  */
15
17
  export declare abstract class AttributesToken extends Token {
16
18
  #private;
@@ -28,18 +30,24 @@ export declare abstract class AttributesToken extends Token {
28
30
  */
29
31
  constructor(attr: string | undefined, type: AttributesTypes, name: string, config?: Parser.Config, accum?: Token[]);
30
32
  /**
33
+ * Get all AttributeTokens with the specified attribute name
34
+ *
31
35
  * 所有指定属性名的AttributeToken
32
- * @param key 属性名
36
+ * @param key attribute name / 属性名
33
37
  */
34
38
  getAttrTokens(key?: string): AttributeToken[];
35
39
  /**
40
+ * Get the last AttributeToken with the specified attribute name
41
+ *
36
42
  * 指定属性名的最后一个AttributeToken
37
- * @param key 属性名
43
+ * @param key attribute name / 属性名
38
44
  */
39
45
  getAttrToken(key: string): AttributeToken | undefined;
40
46
  /**
47
+ * Get the attribute
48
+ *
41
49
  * 获取指定属性
42
- * @param key 属性键
50
+ * @param key attribute name / 属性键
43
51
  */
44
52
  getAttr(key: string): string | true | undefined;
45
53
  }
@@ -27,8 +27,10 @@ catch /* istanbul ignore next */ {
27
27
  wordRegex = /[^\W_]/u;
28
28
  }
29
29
  /**
30
+ * attributes of extension and HTML tags
31
+ *
30
32
  * 扩展和HTML标签属性
31
- * @classdesc `{childNodes: ...AtomToken|AttributeToken}`
33
+ * @classdesc `{childNodes: (AtomToken|AttributeToken)[]}`
32
34
  */
33
35
  class AttributesToken extends index_2.Token {
34
36
  #type;
@@ -82,23 +84,29 @@ class AttributesToken extends index_2.Token {
82
84
  super.afterBuild();
83
85
  }
84
86
  /**
87
+ * Get all AttributeTokens with the specified attribute name
88
+ *
85
89
  * 所有指定属性名的AttributeToken
86
- * @param key 属性名
90
+ * @param key attribute name / 属性名
87
91
  */
88
92
  getAttrTokens(key) {
89
93
  return this.childNodes.filter((child) => child instanceof attribute_1.AttributeToken && (!key || child.name === key.toLowerCase().trim()));
90
94
  }
91
95
  /**
96
+ * Get the last AttributeToken with the specified attribute name
97
+ *
92
98
  * 指定属性名的最后一个AttributeToken
93
- * @param key 属性名
99
+ * @param key attribute name / 属性名
94
100
  */
95
101
  getAttrToken(key) {
96
102
  const tokens = this.getAttrTokens(key);
97
103
  return tokens[tokens.length - 1];
98
104
  }
99
105
  /**
106
+ * Get the attribute
107
+ *
100
108
  * 获取指定属性
101
- * @param key 属性键
109
+ * @param key attribute name / 属性键
102
110
  */
103
111
  getAttr(key) {
104
112
  return this.getAttrToken(key)?.getValue();
@@ -3,8 +3,10 @@ import { Token } from './index';
3
3
  import { ConverterFlagsToken } from './converterFlags';
4
4
  import { ConverterRuleToken } from './converterRule';
5
5
  /**
6
+ * language conversion
7
+ *
6
8
  * 转换
7
- * @classdesc `{childNodes: [ConverterFlagsToken, ...ConverterRuleToken]}`
9
+ * @classdesc `{childNodes: [ConverterFlagsToken, ...ConverterRuleToken[]]}`
8
10
  */
9
11
  export declare abstract class ConverterToken extends Token {
10
12
  readonly childNodes: readonly [ConverterFlagsToken, ConverterRuleToken, ...ConverterRuleToken[]];
@@ -7,8 +7,10 @@ const index_2 = require("./index");
7
7
  const converterFlags_1 = require("./converterFlags");
8
8
  const converterRule_1 = require("./converterRule");
9
9
  /**
10
+ * language conversion
11
+ *
10
12
  * 转换
11
- * @classdesc `{childNodes: [ConverterFlagsToken, ...ConverterRuleToken]}`
13
+ * @classdesc `{childNodes: [ConverterFlagsToken, ...ConverterRuleToken[]]}`
12
14
  */
13
15
  class ConverterToken extends index_2.Token {
14
16
  get type() {
@@ -27,13 +29,14 @@ class ConverterToken extends index_2.Token {
27
29
  firstRuleToken = new converterRule_1.ConverterRuleToken(firstRule, hasColon, config, accum);
28
30
  if (hasColon && firstRuleToken.length === 1
29
31
  || !hasColon && rules.length === 2 && !(0, string_1.removeComment)(rules[1]).trim()) {
32
+ this.insertAt(
30
33
  // @ts-expect-error abstract class
31
- this.insertAt(new converterRule_1.ConverterRuleToken(rules.join(';'), false, config, accum));
34
+ new converterRule_1.ConverterRuleToken(rules.join(';'), false, config, accum));
32
35
  }
33
36
  else {
34
- this.append(firstRuleToken,
35
- // @ts-expect-error abstract class
36
- ...rules.slice(1).map(rule => new converterRule_1.ConverterRuleToken(rule, true, config, accum)));
37
+ this.append(firstRuleToken, ...rules.slice(1)
38
+ // @ts-expect-error abstract class
39
+ .map(rule => new converterRule_1.ConverterRuleToken(rule, true, config, accum)));
37
40
  }
38
41
  }
39
42
  /** @private */