wikilint 2.27.0 → 2.28.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 (90) hide show
  1. package/config/default.json +15 -16
  2. package/config/jawiki.json +15 -16
  3. package/coverage/badge.svg +1 -1
  4. package/dist/base.d.mts +2 -2
  5. package/dist/base.d.ts +2 -2
  6. package/dist/base.js +1 -0
  7. package/dist/base.mjs +1 -0
  8. package/dist/bin/config.js +11 -11
  9. package/dist/index.d.ts +1 -1
  10. package/dist/index.js +2 -3
  11. package/dist/internal.d.ts +5 -5
  12. package/dist/lib/lintConfig.js +7 -5
  13. package/dist/lib/lsp.d.ts +1 -1
  14. package/dist/lib/lsp.js +5 -2
  15. package/dist/lib/node.js +44 -33
  16. package/dist/mixin/attributesParent.js +16 -14
  17. package/dist/mixin/elementLike.js +45 -43
  18. package/dist/mixin/hidden.js +0 -1
  19. package/dist/mixin/nodeLike.js +2 -2
  20. package/dist/mixin/padded.js +9 -7
  21. package/dist/parser/commentAndExt.js +5 -2
  22. package/dist/parser/hrAndDoubleUnderscore.js +8 -7
  23. package/dist/parser/html.js +1 -1
  24. package/dist/src/arg.js +3 -4
  25. package/dist/src/atom.d.ts +1 -1
  26. package/dist/src/atom.js +0 -1
  27. package/dist/src/attribute.d.ts +2 -4
  28. package/dist/src/attribute.js +7 -2
  29. package/dist/src/attributes.d.ts +3 -4
  30. package/dist/src/attributes.js +5 -3
  31. package/dist/src/commented.d.ts +3 -3
  32. package/dist/src/imageParameter.js +53 -13
  33. package/dist/src/index.js +1 -1
  34. package/dist/src/link/file.js +8 -9
  35. package/dist/src/link/index.js +1 -1
  36. package/dist/src/magicLink.js +12 -1
  37. package/dist/src/multiLine/gallery.d.ts +20 -0
  38. package/dist/src/multiLine/gallery.js +95 -0
  39. package/dist/src/multiLine/imagemap.d.ts +21 -0
  40. package/dist/src/multiLine/imagemap.js +111 -0
  41. package/dist/src/multiLine/index.d.ts +14 -0
  42. package/dist/src/multiLine/index.js +27 -0
  43. package/dist/src/{paramTag → multiLine}/inputbox.d.ts +1 -1
  44. package/dist/src/{paramTag → multiLine}/inputbox.js +2 -2
  45. package/dist/src/multiLine/paramTag.d.ts +16 -0
  46. package/dist/src/multiLine/paramTag.js +67 -0
  47. package/dist/src/nowiki/base.d.ts +1 -1
  48. package/dist/src/nowiki/comment.js +1 -0
  49. package/dist/src/nowiki/commentLine.d.ts +10 -0
  50. package/dist/src/nowiki/commentLine.js +12 -0
  51. package/dist/src/nowiki/doubleUnderscore.d.ts +3 -1
  52. package/dist/src/nowiki/doubleUnderscore.js +6 -2
  53. package/dist/src/nowiki/quote.js +1 -1
  54. package/dist/src/paramLine.d.ts +13 -0
  55. package/dist/src/paramLine.js +15 -0
  56. package/dist/src/parameter.d.ts +0 -1
  57. package/dist/src/parameter.js +1 -0
  58. package/dist/src/pre.d.ts +3 -5
  59. package/dist/src/pre.js +2 -2
  60. package/dist/src/syntax.d.ts +1 -1
  61. package/dist/src/table/base.d.ts +6 -1
  62. package/dist/src/table/base.js +73 -23
  63. package/dist/src/table/index.js +43 -39
  64. package/dist/src/table/td.d.ts +1 -1
  65. package/dist/src/table/td.js +6 -4
  66. package/dist/src/table/tr.d.ts +1 -1
  67. package/dist/src/table/trBase.js +3 -1
  68. package/dist/src/{html.d.ts → tag/html.d.ts} +5 -13
  69. package/dist/src/{html.js → tag/html.js} +11 -71
  70. package/dist/src/tag/index.d.ts +31 -0
  71. package/dist/src/tag/index.js +110 -0
  72. package/dist/src/tag/tvar.d.ts +20 -0
  73. package/dist/src/tag/tvar.js +75 -0
  74. package/dist/src/tagPair/ext.js +14 -7
  75. package/dist/src/tagPair/index.d.ts +1 -1
  76. package/dist/src/tagPair/translate.js +9 -9
  77. package/dist/src/transclude.d.ts +3 -5
  78. package/dist/src/transclude.js +3 -1
  79. package/i18n/en.json +2 -0
  80. package/i18n/zh-hans.json +2 -0
  81. package/i18n/zh-hant.json +2 -0
  82. package/package.json +5 -5
  83. package/dist/mixin/multiLine.d.ts +0 -4
  84. package/dist/mixin/multiLine.js +0 -26
  85. package/dist/src/gallery.d.ts +0 -26
  86. package/dist/src/gallery.js +0 -149
  87. package/dist/src/imagemap.d.ts +0 -27
  88. package/dist/src/imagemap.js +0 -164
  89. package/dist/src/paramTag/index.d.ts +0 -21
  90. package/dist/src/paramTag/index.js +0 -121
package/dist/lib/node.js CHANGED
@@ -108,7 +108,9 @@ let AstNode = (() => {
108
108
  this.#previousSibling = value;
109
109
  break;
110
110
  case 'aIndex':
111
- this.#aIndex = [debug_1.Shadow.rev, value];
111
+ LINT: { // eslint-disable-line no-unused-labels
112
+ this.#aIndex = [debug_1.Shadow.rev, value];
113
+ }
112
114
  break;
113
115
  default:
114
116
  this[key] = value; // eslint-disable-line @typescript-eslint/no-explicit-any
@@ -154,18 +156,22 @@ let AstNode = (() => {
154
156
  * @param index character index / 字符位置
155
157
  */
156
158
  posFromIndex(index) {
157
- const { length } = String(this);
158
- index += index < 0 ? length : 0;
159
- if (index >= 0 && index <= length) {
160
- const lines = this.getLines(), top = lines.findIndex(([, , end]) => index <= end);
161
- return { top, left: index - lines[top][1] };
159
+ LINT: { // eslint-disable-line no-unused-labels
160
+ const { length } = String(this);
161
+ index += index < 0 ? length : 0;
162
+ if (index >= 0 && index <= length) {
163
+ const lines = this.getLines(), top = lines.findIndex(([, , end]) => index <= end);
164
+ return { top, left: index - lines[top][1] };
165
+ }
166
+ return undefined;
162
167
  }
163
- return undefined;
164
168
  }
165
169
  /** @private */
166
170
  getDimension() {
167
- const lines = this.getLines(), last = lines[lines.length - 1];
168
- return { height: lines.length, width: last[2] - last[1] };
171
+ LINT: { // eslint-disable-line no-unused-labels
172
+ const lines = this.getLines(), last = lines[lines.length - 1];
173
+ return { height: lines.length, width: last[2] - last[1] };
174
+ }
169
175
  }
170
176
  /** @private */
171
177
  getGaps(_) {
@@ -178,23 +184,25 @@ let AstNode = (() => {
178
184
  * @param j rank of the child node / 子节点序号
179
185
  */
180
186
  getRelativeIndex(j) {
181
- if (j === undefined) {
182
- const { parentNode } = this;
183
- return parentNode
184
- ? parentNode.getRelativeIndex(parentNode.childNodes.indexOf(this))
185
- : 0;
186
- }
187
- return (0, lint_1.cache)(this.#rIndex[j], () => {
188
- const { childNodes } = this, n = j + (j < 0 ? childNodes.length : 0);
189
- let acc = this.getAttribute('padding');
190
- for (let i = 0; i < n; i++) {
191
- this.#rIndex[i] = [debug_1.Shadow.rev, acc];
192
- acc += childNodes[i].toString().length + this.getGaps(i);
187
+ LINT: { // eslint-disable-line no-unused-labels
188
+ if (j === undefined) {
189
+ const { parentNode } = this;
190
+ return parentNode
191
+ ? parentNode.getRelativeIndex(parentNode.childNodes.indexOf(this))
192
+ : 0;
193
193
  }
194
- return acc;
195
- }, value => {
196
- this.#rIndex[j] = value;
197
- });
194
+ return (0, lint_1.cache)(this.#rIndex[j], () => {
195
+ const { childNodes } = this, n = j + (j < 0 ? childNodes.length : 0);
196
+ let acc = this.getAttribute('padding');
197
+ for (let i = 0; i < n; i++) {
198
+ this.#rIndex[i] = [debug_1.Shadow.rev, acc];
199
+ acc += childNodes[i].toString().length + this.getGaps(i);
200
+ }
201
+ return acc;
202
+ }, value => {
203
+ this.#rIndex[j] = value;
204
+ });
205
+ }
198
206
  }
199
207
  /**
200
208
  * Get the absolute character index of the current node
@@ -202,7 +210,8 @@ let AstNode = (() => {
202
210
  * 获取当前节点的绝对位置
203
211
  */
204
212
  getAbsoluteIndex() {
205
- return (0, lint_1.cache)(this.#aIndex, () => {
213
+ LINT: return (0, lint_1.cache)(// eslint-disable-line no-unused-labels
214
+ this.#aIndex, () => {
206
215
  const { parentNode } = this;
207
216
  return parentNode ? parentNode.getAbsoluteIndex() + this.getRelativeIndex() : 0;
208
217
  }, value => {
@@ -238,14 +247,16 @@ let AstNode = (() => {
238
247
  * @since v1.16.3
239
248
  */
240
249
  getLines() {
241
- const results = [];
242
- let start = 0;
243
- for (const line of String(this).split('\n')) {
244
- const end = start + line.length;
245
- results.push([line, start, end]);
246
- start = end + 1;
250
+ LINT: { // eslint-disable-line no-unused-labels
251
+ const results = [];
252
+ let start = 0;
253
+ for (const line of String(this).split('\n')) {
254
+ const end = start + line.length;
255
+ results.push([line, start, end]);
256
+ start = end + 1;
257
+ }
258
+ return results;
247
259
  }
248
- return results;
249
260
  }
250
261
  };
251
262
  return AstNode = _classThis;
@@ -7,21 +7,23 @@ const debug_1 = require("../util/debug");
7
7
  * @param i AttributesToken子节点的位置
8
8
  */
9
9
  const attributesParent = (i = 0) => (constructor) => {
10
- /* eslint-disable jsdoc/require-jsdoc */
11
- class AttributesParent extends constructor {
12
- /** AttributesToken子节点 */
13
- #getAttributesChild() {
14
- return this.childNodes[i];
15
- }
16
- hasAttr(key) {
17
- LSP: return this.#getAttributesChild().hasAttr(key); // eslint-disable-line no-unused-labels
18
- }
19
- getAttr(key) {
20
- return this.#getAttributesChild().getAttr(key);
10
+ LINT: { // eslint-disable-line no-unused-labels
11
+ /* eslint-disable jsdoc/require-jsdoc */
12
+ class AttributesParent extends constructor {
13
+ /** AttributesToken子节点 */
14
+ #getAttributesChild() {
15
+ return this.childNodes[i];
16
+ }
17
+ hasAttr(key) {
18
+ LSP: return this.#getAttributesChild().hasAttr(key); // eslint-disable-line no-unused-labels
19
+ }
20
+ getAttr(key) {
21
+ return this.#getAttributesChild().getAttr(key);
22
+ }
21
23
  }
24
+ /* eslint-enable jsdoc/require-jsdoc */
25
+ (0, debug_1.mixin)(AttributesParent, constructor);
26
+ return AttributesParent;
22
27
  }
23
- /* eslint-enable jsdoc/require-jsdoc */
24
- (0, debug_1.mixin)(AttributesParent, constructor);
25
- return AttributesParent;
26
28
  };
27
29
  exports.attributesParent = attributesParent;
@@ -5,56 +5,58 @@ const debug_1 = require("../util/debug");
5
5
  const selector_1 = require("../parser/selector");
6
6
  /** @ignore */
7
7
  const elementLike = (constructor) => {
8
- /* eslint-disable jsdoc/require-jsdoc */
9
- class ElementLike extends constructor {
10
- #getCondition(selector) {
11
- return (0, selector_1.getCondition)(selector,
12
- // @ts-expect-error only AstElement
13
- this);
14
- }
15
- getElementBy(condition) {
16
- for (const child of this.childNodes) {
17
- if (child.type === 'text') {
18
- continue;
19
- }
20
- else if (condition(child)) {
21
- return child;
22
- }
23
- const descendant = child.getElementBy(condition);
24
- if (descendant) {
25
- return descendant;
26
- }
8
+ LINT: { // eslint-disable-line no-unused-labels
9
+ /* eslint-disable jsdoc/require-jsdoc */
10
+ class ElementLike extends constructor {
11
+ #getCondition(selector) {
12
+ return (0, selector_1.getCondition)(selector,
13
+ // @ts-expect-error only AstElement
14
+ this);
27
15
  }
28
- return undefined;
29
- }
30
- querySelector(selector) {
31
- return this.getElementBy(this.#getCondition(selector));
32
- }
33
- getElementsBy(condition, descendants = []) {
34
- for (const child of this.childNodes) {
35
- if (child.type === 'text') {
36
- continue;
37
- }
38
- else if (condition(child)) {
39
- descendants.push(child);
16
+ getElementBy(condition) {
17
+ for (const child of this.childNodes) {
18
+ if (child.type === 'text') {
19
+ continue;
20
+ }
21
+ else if (condition(child)) {
22
+ return child;
23
+ }
24
+ const descendant = child.getElementBy(condition);
25
+ if (descendant) {
26
+ return descendant;
27
+ }
40
28
  }
41
- child.getElementsBy(condition, descendants);
29
+ return undefined;
42
30
  }
43
- return descendants;
44
- }
45
- querySelectorAll(selector) {
46
- return this.getElementsBy(this.#getCondition(selector));
47
- }
48
- escape() {
49
- LSP: { // eslint-disable-line no-unused-labels
31
+ querySelector(selector) {
32
+ return this.getElementBy(this.#getCondition(selector));
33
+ }
34
+ getElementsBy(condition, descendants = []) {
50
35
  for (const child of this.childNodes) {
51
- child.escape();
36
+ if (child.type === 'text') {
37
+ continue;
38
+ }
39
+ else if (condition(child)) {
40
+ descendants.push(child);
41
+ }
42
+ child.getElementsBy(condition, descendants);
43
+ }
44
+ return descendants;
45
+ }
46
+ querySelectorAll(selector) {
47
+ return this.getElementsBy(this.#getCondition(selector));
48
+ }
49
+ escape() {
50
+ LSP: { // eslint-disable-line no-unused-labels
51
+ for (const child of this.childNodes) {
52
+ child.escape();
53
+ }
52
54
  }
53
55
  }
54
56
  }
57
+ /* eslint-enable jsdoc/require-jsdoc */
58
+ (0, debug_1.mixin)(ElementLike, constructor);
59
+ return ElementLike;
55
60
  }
56
- /* eslint-enable jsdoc/require-jsdoc */
57
- (0, debug_1.mixin)(ElementLike, constructor);
58
- return ElementLike;
59
61
  };
60
62
  exports.elementLike = elementLike;
@@ -10,7 +10,6 @@ const debug_1 = require("../util/debug");
10
10
  const hiddenToken = (linter = true, html = true) => (constructor) => {
11
11
  /* eslint-disable jsdoc/require-jsdoc */
12
12
  class AnyHiddenToken extends constructor {
13
- /** 没有可见部分 */
14
13
  text() {
15
14
  return '';
16
15
  }
@@ -13,10 +13,10 @@ const nodeLike = (constructor) => {
13
13
  return this.childNodes[this.childNodes.length - 1];
14
14
  }
15
15
  get offsetHeight() {
16
- return this.getDimension().height;
16
+ LINT: return this.getDimension().height; // eslint-disable-line no-unused-labels
17
17
  }
18
18
  get offsetWidth() {
19
- return this.getDimension().width;
19
+ LINT: return this.getDimension().width; // eslint-disable-line no-unused-labels
20
20
  }
21
21
  }
22
22
  /* eslint-enable jsdoc/require-jsdoc */
@@ -8,14 +8,16 @@ const debug_1 = require("../util/debug");
8
8
  * @param padding.length
9
9
  */
10
10
  const padded = ({ length }) => (constructor) => {
11
- /* eslint-disable jsdoc/require-jsdoc */
12
- class PaddedToken extends constructor {
13
- getAttribute(key) {
14
- return key === 'padding' ? length : super.getAttribute(key);
11
+ LINT: { // eslint-disable-line no-unused-labels
12
+ /* eslint-disable jsdoc/require-jsdoc */
13
+ class PaddedToken extends constructor {
14
+ getAttribute(key) {
15
+ return key === 'padding' ? length : super.getAttribute(key);
16
+ }
15
17
  }
18
+ /* eslint-enable jsdoc/require-jsdoc */
19
+ (0, debug_1.mixin)(PaddedToken, constructor);
20
+ return PaddedToken;
16
21
  }
17
- /* eslint-enable jsdoc/require-jsdoc */
18
- (0, debug_1.mixin)(PaddedToken, constructor);
19
- return PaddedToken;
20
22
  };
21
23
  exports.padded = padded;
@@ -59,8 +59,11 @@ const parseCommentAndExt = (wikitext, config, accum, includeOnly) => {
59
59
  return str;
60
60
  }
61
61
  }
62
- const { ext } = config, newExt = ext.filter(e => e !== 'translate' && e !== 'tvar'), newConfig = { ...config, ext: newExt };
62
+ const { ext } = config;
63
+ let newExt = ext, newConfig = config;
63
64
  if (ext.includes('translate')) {
65
+ newExt = ext.filter(e => e !== 'translate' && e !== 'tvar');
66
+ newConfig = { ...config, ext: newExt };
64
67
  const stack = [];
65
68
  wikitext = wikitext.replace(/<nowiki>[\s\S]*?<\/nowiki>/giu, m => {
66
69
  stack.push(m);
@@ -93,7 +96,7 @@ const parseCommentAndExt = (wikitext, config, accum, includeOnly) => {
93
96
  }
94
97
  else {
95
98
  // @ts-expect-error abstract class
96
- new noinclude_1.NoincludeToken(substr, config, accum);
99
+ new noinclude_1.NoincludeToken(substr, config, accum, true);
97
100
  }
98
101
  return `\0${l}${ch}\x7F`;
99
102
  });
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.parseHrAndDoubleUnderscore = void 0;
4
+ const cm_util_1 = require("@bhsd/cm-util");
4
5
  const hr_1 = require("../src/nowiki/hr");
5
6
  const doubleUnderscore_1 = require("../src/nowiki/doubleUnderscore");
6
7
  const heading_1 = require("../src/heading");
@@ -11,10 +12,10 @@ const heading_1 = require("../src/heading");
11
12
  * @param accum
12
13
  */
13
14
  const parseHrAndDoubleUnderscore = ({ firstChild: { data }, type, name }, config, accum) => {
14
- const { doubleUnderscore: [insensitive, sensitive, aliases] } = config;
15
- config.insensitiveDoubleUnderscore ??= new Set(insensitive);
16
- config.sensitiveDoubleUnderscore ??= new Set(sensitive);
17
- config.regexHrAndDoubleUnderscore ??= new RegExp(`__(${[...insensitive, ...sensitive].join('|')})__`, 'giu');
15
+ const { doubleUnderscore: [insensitive, sensitive, aliases] } = config, all = [...insensitive, ...sensitive];
16
+ config.insensitiveDoubleUnderscore ??= new Set(insensitive.filter(cm_util_1.isUnderscore));
17
+ config.sensitiveDoubleUnderscore ??= new Set(sensitive.filter(cm_util_1.isUnderscore));
18
+ config.regexHrAndDoubleUnderscore ??= new RegExp(`__(${all.filter(cm_util_1.isUnderscore).join('|')})__|_{2}(${all.filter(s => !(0, cm_util_1.isUnderscore)(s)).map(s => s.slice(2, -2)).join('|')})_{2}`, 'giu');
18
19
  if (type !== 'root' && (type !== 'ext-inner' || name !== 'poem')) {
19
20
  data = `\0${data}`;
20
21
  }
@@ -22,11 +23,11 @@ const parseHrAndDoubleUnderscore = ({ firstChild: { data }, type, name }, config
22
23
  // @ts-expect-error abstract class
23
24
  new hr_1.HrToken(m, config, accum);
24
25
  return `${lead}\0${accum.length - 1}r\x7F`;
25
- }).replace(config.regexHrAndDoubleUnderscore, (m, p1) => {
26
- const caseSensitive = config.sensitiveDoubleUnderscore.has(p1), lc = p1.toLowerCase(), caseInsensitive = config.insensitiveDoubleUnderscore.has(lc);
26
+ }).replace(config.regexHrAndDoubleUnderscore, (m, p1, p2) => {
27
+ const key = p1 ?? p2, caseSensitive = config.sensitiveDoubleUnderscore.has(key), lc = key.toLowerCase(), caseInsensitive = config.insensitiveDoubleUnderscore.has(lc);
27
28
  if (caseSensitive || caseInsensitive) {
28
29
  // @ts-expect-error abstract class
29
- new doubleUnderscore_1.DoubleUnderscoreToken(p1, caseSensitive, config, accum);
30
+ new doubleUnderscore_1.DoubleUnderscoreToken(key, caseSensitive, Boolean(p2), config, accum);
30
31
  return `\0${accum.length - 1}${caseInsensitive && (aliases?.[lc] ?? /* istanbul ignore next */ lc) === 'toc' ? 'u' : 'n'}\x7F`;
31
32
  }
32
33
  return m;
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.parseHtml = void 0;
4
4
  const attributes_1 = require("../src/attributes");
5
- const html_1 = require("../src/html");
5
+ const html_1 = require("../src/tag/html");
6
6
  const regex = /^(\/?)([a-z][^\s/>]*)((?:\s|\/(?!>))[^>]*?)?(\/?>)([^<]*)$/iu;
7
7
  /**
8
8
  * 解析HTML标签
package/dist/src/arg.js CHANGED
@@ -101,7 +101,7 @@ let ArgToken = (() => {
101
101
  text() {
102
102
  return `{{{${(0, string_1.text)(this.childNodes.slice(0, 2), '|')}}}}`;
103
103
  }
104
- /** 设置name */
104
+ /** 更新name */
105
105
  #setName() {
106
106
  // eslint-disable-next-line no-unused-labels
107
107
  LSP: this.setAttribute('name', this.firstChild.text().trim());
@@ -126,9 +126,8 @@ let ArgToken = (() => {
126
126
  errors.push(...childErrors);
127
127
  }
128
128
  }
129
- const rules = ['no-ignored', 'no-arg'], { lintConfig } = index_1.default, { computeEditInfo } = lintConfig, s = rules.map(rule => lintConfig.getSeverity(rule, 'arg'));
129
+ const rules = ['no-ignored', 'no-arg'], { lintConfig } = index_1.default, { computeEditInfo } = lintConfig, rect = new rect_1.BoundingRect(this, start), s = rules.map(rule => lintConfig.getSeverity(rule, 'arg'));
130
130
  if (s[0] && rest.length > 0) {
131
- const rect = new rect_1.BoundingRect(this, start);
132
131
  errors.push(...rest.map(child => {
133
132
  const e = (0, lint_1.generateForChild)(child, rect, rules[0], 'invisible-triple-braces', s[0]);
134
133
  e.startIndex--;
@@ -143,7 +142,7 @@ let ArgToken = (() => {
143
142
  }));
144
143
  }
145
144
  if (s[1] && !this.getAttribute('include')) {
146
- const e = (0, lint_1.generateForSelf)(this, { start }, rules[1], 'unexpected-argument', s[1]);
145
+ const e = (0, lint_1.generateForSelf)(this, rect, rules[1], 'unexpected-argument', s[1]);
147
146
  if (computeEditInfo && argDefault) {
148
147
  e.suggestions = [(0, lint_1.fixBy)(e, 'expand', argDefault.text())];
149
148
  }
@@ -1,6 +1,6 @@
1
1
  import { Token } from './index';
2
2
  import type { Config } from '../base';
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"];
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"];
4
4
  declare type AtomTypes = typeof atomTypes[number];
5
5
  /**
6
6
  * plain Token that will not be parsed further
package/dist/src/atom.js CHANGED
@@ -18,7 +18,6 @@ const atomTypes = [
18
18
  'invoke-module',
19
19
  'template-name',
20
20
  'link-target',
21
- 'param-line',
22
21
  ];
23
22
  /**
24
23
  * plain Token that will not be parsed further
@@ -3,7 +3,6 @@ import { Token } from './index';
3
3
  import { AtomToken } from './atom';
4
4
  import type { LintError } from '../base';
5
5
  import type { AttributesToken } from '../internal';
6
- declare type Child = AtomToken | AttributeToken | undefined;
7
6
  export type AttributeTypes = 'ext-attr' | 'html-attr' | 'table-attr';
8
7
  /**
9
8
  * attribute of extension and HTML tags
@@ -18,8 +17,8 @@ export declare abstract class AttributeToken extends Token {
18
17
  abstract get firstChild(): AtomToken;
19
18
  abstract get lastChild(): Token;
20
19
  abstract get parentNode(): AttributesToken | undefined;
21
- abstract get nextSibling(): Child;
22
- abstract get previousSibling(): Child;
20
+ abstract get nextSibling(): AtomToken | this | undefined;
21
+ abstract get previousSibling(): AtomToken | this | undefined;
23
22
  get type(): AttributeTypes;
24
23
  /** tag name / 标签名 */
25
24
  get tag(): string;
@@ -42,4 +41,3 @@ export declare abstract class AttributeToken extends Token {
42
41
  getValue(): string | true;
43
42
  escape(): void;
44
43
  }
45
- export {};
@@ -44,7 +44,7 @@ class AttributeToken extends index_2.Token {
44
44
  }
45
45
  /** whether the quotes are balanced / 引号是否匹配 */
46
46
  get balanced() {
47
- return !this.#equal || this.#quotes[0] === this.#quotes[1];
47
+ LINT: return !this.#equal || this.#quotes[0] === this.#quotes[1]; // eslint-disable-line no-unused-labels
48
48
  }
49
49
  /**
50
50
  * @param type 标签类型
@@ -63,6 +63,7 @@ class AttributeToken extends index_2.Token {
63
63
  valueToken.setAttribute('stage', constants_1.MAX_STAGE - 1);
64
64
  }
65
65
  else if (tag === 'gallery' && key === 'caption'
66
+ || tag === 'ref' && key === 'details'
66
67
  || tag === 'choose' && (key === 'before' || key === 'after')) {
67
68
  const newConfig = {
68
69
  ...config,
@@ -83,6 +84,10 @@ class AttributeToken extends index_2.Token {
83
84
  this.#tag = tag;
84
85
  this.setAttribute('name', (0, string_1.trimLc)((0, string_1.removeComment)(key)));
85
86
  }
87
+ /** 更新name */
88
+ #setName() {
89
+ this.setAttribute('name', (0, string_1.trimLc)(this.firstChild.text()));
90
+ }
86
91
  /** @private */
87
92
  afterBuild() {
88
93
  if (this.#equal.includes('\0')) {
@@ -91,7 +96,7 @@ class AttributeToken extends index_2.Token {
91
96
  if (this.parentNode) {
92
97
  this.#tag = this.parentNode.name;
93
98
  }
94
- this.setAttribute('name', (0, string_1.trimLc)(this.firstChild.text()));
99
+ this.#setName();
95
100
  super.afterBuild();
96
101
  }
97
102
  /** @private */
@@ -6,7 +6,6 @@ import type { ExtToken, HtmlToken, SyntaxToken } from '../internal';
6
6
  import type { AttributeTypes } from './attribute';
7
7
  import type { TableTokens } from './table/index';
8
8
  declare type AttributesTypes = `${AttributeTypes}s`;
9
- declare type Child = AtomToken | AttributeToken;
10
9
  /**
11
10
  * attributes of extension and HTML tags
12
11
  *
@@ -16,9 +15,9 @@ declare type Child = AtomToken | AttributeToken;
16
15
  export declare abstract class AttributesToken extends Token {
17
16
  #private;
18
17
  readonly name: string;
19
- readonly childNodes: readonly Child[];
20
- abstract get firstChild(): Child | undefined;
21
- abstract get lastChild(): Child | undefined;
18
+ readonly childNodes: readonly (AtomToken | AttributeToken)[];
19
+ abstract get firstChild(): AtomToken | AttributeToken | undefined;
20
+ abstract get lastChild(): AtomToken | AttributeToken | undefined;
22
21
  abstract get parentNode(): ExtToken | HtmlToken | TableTokens | undefined;
23
22
  abstract get previousSibling(): SyntaxToken | undefined;
24
23
  get type(): AttributesTypes;
@@ -112,8 +112,10 @@ class AttributesToken extends index_2.Token {
112
112
  * @param key attribute name / 属性名
113
113
  */
114
114
  getAttrToken(key) {
115
- const tokens = this.getAttrTokens(key);
116
- return tokens[tokens.length - 1];
115
+ LINT: { // eslint-disable-line no-unused-labels
116
+ const tokens = this.getAttrTokens(key);
117
+ return tokens[tokens.length - 1];
118
+ }
117
119
  }
118
120
  /**
119
121
  * Get the attribute
@@ -122,7 +124,7 @@ class AttributesToken extends index_2.Token {
122
124
  * @param key attribute name / 属性键
123
125
  */
124
126
  getAttr(key) {
125
- return this.getAttrToken(key)?.getValue();
127
+ LINT: return this.getAttrToken(key)?.getValue(); // eslint-disable-line no-unused-labels
126
128
  }
127
129
  /** 是否位于闭合标签内 */
128
130
  #lint() {
@@ -7,9 +7,9 @@ import type { AstText, AttributesToken, ExtToken } from '../internal';
7
7
  * @classdesc `{childNodes: (AstText|CommentToken)[]}`
8
8
  */
9
9
  export declare abstract class CommentedToken extends Token {
10
- readonly childNodes: readonly (AstText | CommentToken)[];
11
- abstract get firstChild(): AstText | CommentToken | undefined;
12
- abstract get lastChild(): AstText | CommentToken | undefined;
10
+ readonly childNodes: readonly (CommentToken | AstText)[];
11
+ abstract get firstChild(): CommentToken | AstText | undefined;
12
+ abstract get lastChild(): CommentToken | AstText | undefined;
13
13
  abstract get nextSibling(): undefined;
14
14
  abstract get previousSibling(): AttributesToken | undefined;
15
15
  abstract get parentNode(): ExtToken | undefined;