wikilint 2.27.0 → 2.28.0

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 (79) hide show
  1. package/coverage/badge.svg +1 -1
  2. package/dist/base.d.mts +1 -1
  3. package/dist/base.d.ts +1 -1
  4. package/dist/bin/config.js +1 -1
  5. package/dist/index.d.ts +1 -1
  6. package/dist/index.js +2 -3
  7. package/dist/internal.d.ts +5 -5
  8. package/dist/lib/lintConfig.js +5 -5
  9. package/dist/lib/lsp.d.ts +1 -1
  10. package/dist/lib/lsp.js +1 -1
  11. package/dist/lib/node.js +44 -33
  12. package/dist/mixin/attributesParent.js +16 -14
  13. package/dist/mixin/elementLike.js +45 -43
  14. package/dist/mixin/hidden.js +0 -1
  15. package/dist/mixin/nodeLike.js +2 -2
  16. package/dist/mixin/padded.js +9 -7
  17. package/dist/parser/commentAndExt.js +1 -1
  18. package/dist/parser/html.js +1 -1
  19. package/dist/src/arg.js +1 -1
  20. package/dist/src/atom.d.ts +1 -1
  21. package/dist/src/atom.js +0 -1
  22. package/dist/src/attribute.d.ts +2 -4
  23. package/dist/src/attribute.js +6 -2
  24. package/dist/src/attributes.d.ts +3 -4
  25. package/dist/src/attributes.js +5 -3
  26. package/dist/src/commented.d.ts +3 -3
  27. package/dist/src/imageParameter.js +6 -5
  28. package/dist/src/index.js +1 -1
  29. package/dist/src/link/file.js +7 -5
  30. package/dist/src/link/index.js +1 -1
  31. package/dist/src/multiLine/gallery.d.ts +20 -0
  32. package/dist/src/multiLine/gallery.js +95 -0
  33. package/dist/src/multiLine/imagemap.d.ts +21 -0
  34. package/dist/src/multiLine/imagemap.js +111 -0
  35. package/dist/src/multiLine/index.d.ts +14 -0
  36. package/dist/src/multiLine/index.js +27 -0
  37. package/dist/src/{paramTag → multiLine}/inputbox.d.ts +1 -1
  38. package/dist/src/{paramTag → multiLine}/inputbox.js +2 -2
  39. package/dist/src/multiLine/paramTag.d.ts +16 -0
  40. package/dist/src/multiLine/paramTag.js +67 -0
  41. package/dist/src/nowiki/base.d.ts +1 -1
  42. package/dist/src/nowiki/comment.js +1 -0
  43. package/dist/src/nowiki/commentLine.d.ts +10 -0
  44. package/dist/src/nowiki/commentLine.js +12 -0
  45. package/dist/src/nowiki/quote.js +1 -1
  46. package/dist/src/paramLine.d.ts +13 -0
  47. package/dist/src/paramLine.js +15 -0
  48. package/dist/src/parameter.d.ts +0 -1
  49. package/dist/src/parameter.js +1 -0
  50. package/dist/src/pre.d.ts +3 -5
  51. package/dist/src/pre.js +2 -2
  52. package/dist/src/syntax.d.ts +1 -1
  53. package/dist/src/table/base.d.ts +6 -1
  54. package/dist/src/table/base.js +73 -23
  55. package/dist/src/table/index.js +43 -39
  56. package/dist/src/table/td.d.ts +1 -1
  57. package/dist/src/table/td.js +6 -4
  58. package/dist/src/table/tr.d.ts +1 -1
  59. package/dist/src/table/trBase.js +3 -1
  60. package/dist/src/{html.d.ts → tag/html.d.ts} +5 -13
  61. package/dist/src/{html.js → tag/html.js} +11 -71
  62. package/dist/src/tag/index.d.ts +31 -0
  63. package/dist/src/tag/index.js +110 -0
  64. package/dist/src/tag/tvar.d.ts +20 -0
  65. package/dist/src/tag/tvar.js +75 -0
  66. package/dist/src/tagPair/ext.js +4 -4
  67. package/dist/src/tagPair/index.d.ts +1 -1
  68. package/dist/src/tagPair/translate.js +9 -9
  69. package/dist/src/transclude.d.ts +3 -5
  70. package/dist/src/transclude.js +3 -1
  71. package/package.json +2 -2
  72. package/dist/mixin/multiLine.d.ts +0 -4
  73. package/dist/mixin/multiLine.js +0 -26
  74. package/dist/src/gallery.d.ts +0 -26
  75. package/dist/src/gallery.js +0 -149
  76. package/dist/src/imagemap.d.ts +0 -27
  77. package/dist/src/imagemap.js +0 -164
  78. package/dist/src/paramTag/index.d.ts +0 -21
  79. package/dist/src/paramTag/index.js +0 -121
@@ -1 +1 @@
1
- <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="98" height="20" role="img" aria-label="Coverage: 89%"><title>Coverage: 89%</title><linearGradient id="s" x2="0" y2="100%"><stop offset="0" stop-color="#bbb" stop-opacity=".1"/><stop offset="1" stop-opacity=".1"/></linearGradient><clipPath id="r"><rect width="98" height="20" rx="3" fill="#fff"/></clipPath><g clip-path="url(#r)"><rect width="63" height="20" fill="#555"/><rect x="63" width="35" height="20" fill="#4c1"/><rect width="98" height="20" fill="url(#s)"/></g><g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" text-rendering="geometricPrecision" font-size="110"><text aria-hidden="true" x="325" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="530">Coverage</text><text x="325" y="140" transform="scale(.1)" fill="#fff" textLength="530">Coverage</text><text aria-hidden="true" x="795" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="250">89%</text><text x="795" y="140" transform="scale(.1)" fill="#fff" textLength="250">89%</text></g></svg>
1
+ <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="98" height="20" role="img" aria-label="Coverage: 90%"><title>Coverage: 90%</title><linearGradient id="s" x2="0" y2="100%"><stop offset="0" stop-color="#bbb" stop-opacity=".1"/><stop offset="1" stop-opacity=".1"/></linearGradient><clipPath id="r"><rect width="98" height="20" rx="3" fill="#fff"/></clipPath><g clip-path="url(#r)"><rect width="63" height="20" fill="#555"/><rect x="63" width="35" height="20" fill="#4c1"/><rect width="98" height="20" fill="url(#s)"/></g><g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" text-rendering="geometricPrecision" font-size="110"><text aria-hidden="true" x="325" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="530">Coverage</text><text x="325" y="140" transform="scale(.1)" fill="#fff" textLength="530">Coverage</text><text aria-hidden="true" x="795" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="250">90%</text><text x="795" y="140" transform="scale(.1)" fill="#fff" textLength="250">90%</text></g></svg>
package/dist/base.d.mts CHANGED
@@ -16,7 +16,7 @@ export interface Config {
16
16
  readonly articlePath?: string;
17
17
  }
18
18
  export type ConfigData = Omit<Config, 'excludes'>;
19
- export type TokenTypes = 'root' | 'plain' | 'redirect' | 'redirect-syntax' | 'redirect-target' | 'translate' | 'translate-attr' | 'translate-inner' | 'onlyinclude' | 'noinclude' | 'include' | 'comment' | 'ext' | 'ext-attrs' | 'ext-attr-dirty' | 'ext-attr' | 'attr-key' | 'attr-value' | 'ext-inner' | 'arg' | 'arg-name' | 'arg-default' | 'hidden' | 'magic-word' | 'magic-word-name' | 'invoke-function' | 'invoke-module' | 'template' | 'template-name' | 'parameter' | 'parameter-key' | 'parameter-value' | 'heading' | 'heading-title' | 'heading-trail' | 'html' | 'html-attrs' | 'html-attr-dirty' | 'html-attr' | 'table' | 'tr' | 'td' | 'table-syntax' | 'table-attrs' | 'table-attr-dirty' | 'table-attr' | 'table-inter' | 'td-inner' | 'hr' | 'double-underscore' | 'link' | 'link-target' | 'link-text' | 'category' | 'file' | 'gallery-image' | 'imagemap-image' | 'image-parameter' | 'quote' | 'ext-link' | 'ext-link-text' | 'ext-link-url' | 'free-ext-link' | 'magic-link' | 'list' | 'dd' | 'list-range' | 'converter' | 'converter-flags' | 'converter-flag' | 'converter-rule' | 'converter-rule-variant' | 'converter-rule-to' | 'converter-rule-from' | 'param-line' | 'imagemap-link';
19
+ export type TokenTypes = 'root' | 'plain' | 'redirect' | 'redirect-syntax' | 'redirect-target' | 'translate' | 'translate-attr' | 'translate-inner' | 'tvar' | 'tvar-name' | 'onlyinclude' | 'noinclude' | 'include' | 'comment' | 'ext' | 'ext-attrs' | 'ext-attr-dirty' | 'ext-attr' | 'attr-key' | 'attr-value' | 'ext-inner' | 'arg' | 'arg-name' | 'arg-default' | 'hidden' | 'magic-word' | 'magic-word-name' | 'invoke-function' | 'invoke-module' | 'template' | 'template-name' | 'parameter' | 'parameter-key' | 'parameter-value' | 'heading' | 'heading-title' | 'heading-trail' | 'html' | 'html-attrs' | 'html-attr-dirty' | 'html-attr' | 'table' | 'tr' | 'td' | 'table-syntax' | 'table-attrs' | 'table-attr-dirty' | 'table-attr' | 'table-inter' | 'td-inner' | 'hr' | 'double-underscore' | 'link' | 'link-target' | 'link-text' | 'category' | 'file' | 'gallery-image' | 'imagemap-image' | 'image-parameter' | 'quote' | 'ext-link' | 'ext-link-text' | 'ext-link-url' | 'free-ext-link' | 'magic-link' | 'list' | 'dd' | 'list-range' | 'converter' | 'converter-flags' | 'converter-flag' | 'converter-rule' | 'converter-rule-variant' | 'converter-rule-to' | 'converter-rule-from' | 'param-line' | 'imagemap-link';
20
20
  export declare const stages: {
21
21
  redirect: number;
22
22
  onlyinclude: number;
package/dist/base.d.ts CHANGED
@@ -16,7 +16,7 @@ export interface Config {
16
16
  readonly articlePath?: string;
17
17
  }
18
18
  export type ConfigData = Omit<Config, 'excludes'>;
19
- export type TokenTypes = 'root' | 'plain' | 'redirect' | 'redirect-syntax' | 'redirect-target' | 'translate' | 'translate-attr' | 'translate-inner' | 'onlyinclude' | 'noinclude' | 'include' | 'comment' | 'ext' | 'ext-attrs' | 'ext-attr-dirty' | 'ext-attr' | 'attr-key' | 'attr-value' | 'ext-inner' | 'arg' | 'arg-name' | 'arg-default' | 'hidden' | 'magic-word' | 'magic-word-name' | 'invoke-function' | 'invoke-module' | 'template' | 'template-name' | 'parameter' | 'parameter-key' | 'parameter-value' | 'heading' | 'heading-title' | 'heading-trail' | 'html' | 'html-attrs' | 'html-attr-dirty' | 'html-attr' | 'table' | 'tr' | 'td' | 'table-syntax' | 'table-attrs' | 'table-attr-dirty' | 'table-attr' | 'table-inter' | 'td-inner' | 'hr' | 'double-underscore' | 'link' | 'link-target' | 'link-text' | 'category' | 'file' | 'gallery-image' | 'imagemap-image' | 'image-parameter' | 'quote' | 'ext-link' | 'ext-link-text' | 'ext-link-url' | 'free-ext-link' | 'magic-link' | 'list' | 'dd' | 'list-range' | 'converter' | 'converter-flags' | 'converter-flag' | 'converter-rule' | 'converter-rule-variant' | 'converter-rule-to' | 'converter-rule-from' | 'param-line' | 'imagemap-link';
19
+ export type TokenTypes = 'root' | 'plain' | 'redirect' | 'redirect-syntax' | 'redirect-target' | 'translate' | 'translate-attr' | 'translate-inner' | 'tvar' | 'tvar-name' | 'onlyinclude' | 'noinclude' | 'include' | 'comment' | 'ext' | 'ext-attrs' | 'ext-attr-dirty' | 'ext-attr' | 'attr-key' | 'attr-value' | 'ext-inner' | 'arg' | 'arg-name' | 'arg-default' | 'hidden' | 'magic-word' | 'magic-word-name' | 'invoke-function' | 'invoke-module' | 'template' | 'template-name' | 'parameter' | 'parameter-key' | 'parameter-value' | 'heading' | 'heading-title' | 'heading-trail' | 'html' | 'html-attrs' | 'html-attr-dirty' | 'html-attr' | 'table' | 'tr' | 'td' | 'table-syntax' | 'table-attrs' | 'table-attr-dirty' | 'table-attr' | 'table-inter' | 'td-inner' | 'hr' | 'double-underscore' | 'link' | 'link-target' | 'link-text' | 'category' | 'file' | 'gallery-image' | 'imagemap-image' | 'image-parameter' | 'quote' | 'ext-link' | 'ext-link-text' | 'ext-link-url' | 'free-ext-link' | 'magic-link' | 'list' | 'dd' | 'list-range' | 'converter' | 'converter-flags' | 'converter-flag' | 'converter-rule' | 'converter-rule-variant' | 'converter-rule-to' | 'converter-rule-from' | 'param-line' | 'imagemap-link';
20
20
  export declare const stages: {
21
21
  redirect: number;
22
22
  onlyinclude: number;
@@ -77,7 +77,7 @@ const mw = {
77
77
  },
78
78
  },
79
79
  };
80
- const pkg = "wikilint", version = "2.27.0";
80
+ const pkg = "wikilint", version = "2.28.0";
81
81
  let mwConfig;
82
82
  /**
83
83
  * Get the parser configuration for a Wikimedia Foundation project.
package/dist/index.d.ts CHANGED
@@ -49,6 +49,6 @@ declare const Parser: Parser;
49
49
  // @ts-expect-error mixed export styles
50
50
  export = Parser;
51
51
  export default Parser;
52
- export type { Config, ConfigData, LintConfig, LintError, TokenTypes, LanguageService, QuickFixData, };
52
+ export type { Config, ConfigData, LintConfig, LintError, TokenTypes, LanguageService, QuickFixData, Title, };
53
53
  export type * from './internal';
54
54
  declare global { type WikiParserAcceptable = Record<string, any>; }
package/dist/index.js CHANGED
@@ -117,9 +117,8 @@ const Parser = {
117
117
  },
118
118
  /** @implements */
119
119
  msg(msg, arg = '') {
120
- LINT: { // eslint-disable-line no-unused-labels
121
- return msg && (this.i18n[msg] ?? msg).replace('$1', this.msg(arg));
122
- }
120
+ LINT: return msg // eslint-disable-line no-unused-labels
121
+ && (this.i18n[msg] ?? msg).replace('$1', this.msg(arg));
123
122
  },
124
123
  /** @implements */
125
124
  normalizeTitle(title, defaultNs = 0, include, config = Parser.getConfig(), opt) {
@@ -17,7 +17,7 @@ export type { SyntaxToken } from './src/syntax';
17
17
  export type { ParameterToken } from './src/parameter';
18
18
  export type { TranscludeToken } from './src/transclude';
19
19
  export type { HeadingToken } from './src/heading';
20
- export type { HtmlToken } from './src/html';
20
+ export type { HtmlToken } from './src/tag/html';
21
21
  export type { TdToken } from './src/table/td';
22
22
  export type { TrToken } from './src/table/tr';
23
23
  export type { TableToken } from './src/table/index';
@@ -38,11 +38,11 @@ export type { ConverterRuleToken } from './src/converterRule';
38
38
  export type { ConverterToken } from './src/converter';
39
39
  export type { NowikiToken } from './src/nowiki/index';
40
40
  export type { PreToken } from './src/pre';
41
- export type { ParamTagToken } from './src/paramTag/index';
42
- export type { InputboxToken } from './src/paramTag/inputbox';
41
+ export type { ParamTagToken } from './src/multiLine/paramTag';
42
+ export type { InputboxToken } from './src/multiLine/inputbox';
43
43
  export type { NestedToken } from './src/nested';
44
- export type { GalleryToken } from './src/gallery';
44
+ export type { GalleryToken } from './src/multiLine/gallery';
45
45
  export type { ImagemapLinkToken } from './src/imagemapLink';
46
- export type { ImagemapToken } from './src/imagemap';
46
+ export type { ImagemapToken } from './src/multiLine/imagemap';
47
47
  export type { CommentedToken } from './src/commented';
48
48
  export type { TranslateToken } from './src/tagPair/translate';
@@ -172,11 +172,11 @@ const defaultLintRuleConfig = {
172
172
  'unmatched-tag': [
173
173
  1,
174
174
  {
175
- // both: 1,
176
- // closing: 1,
177
- // conditional: 1,
178
- // opening: 1,
179
- // selfClosing: 1,
175
+ both: 2,
176
+ // closing: 1,
177
+ // conditional: 1,
178
+ // opening: 1,
179
+ selfClosing: 2,
180
180
  },
181
181
  ],
182
182
  'unterminated-url': [
package/dist/lib/lsp.d.ts CHANGED
@@ -167,8 +167,8 @@ export declare class LanguageService implements LanguageServiceBase {
167
167
  * 设置目标维基百科
168
168
  * @param wiki Wikipedia URL / 维基百科网址
169
169
  * @param user URI for wiki userpage or email address of the user / 维基用户页面地址或用户的电子邮件地址
170
- * @throws `RangeError` 不是有效的维基百科网址
171
170
  * @since v1.18.1
171
+ * @throws `RangeError` 不是有效的维基百科网址
172
172
  */
173
173
  setTargetWikipedia(wiki: string, user: string): Promise<void>;
174
174
  }
package/dist/lib/lsp.js CHANGED
@@ -1526,8 +1526,8 @@ class LanguageService {
1526
1526
  * 设置目标维基百科
1527
1527
  * @param wiki Wikipedia URL / 维基百科网址
1528
1528
  * @param user URI for wiki userpage or email address of the user / 维基用户页面地址或用户的电子邮件地址
1529
- * @throws `RangeError` 不是有效的维基百科网址
1530
1529
  * @since v1.18.1
1530
+ * @throws `RangeError` 不是有效的维基百科网址
1531
1531
  */
1532
1532
  async setTargetWikipedia(wiki, user) {
1533
1533
  const [site, host] = index_1.default.getWMFSite(wiki);
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;
@@ -93,7 +93,7 @@ const parseCommentAndExt = (wikitext, config, accum, includeOnly) => {
93
93
  }
94
94
  else {
95
95
  // @ts-expect-error abstract class
96
- new noinclude_1.NoincludeToken(substr, config, accum);
96
+ new noinclude_1.NoincludeToken(substr, config, accum, true);
97
97
  }
98
98
  return `\0${l}${ch}\x7F`;
99
99
  });
@@ -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());
@@ -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 标签类型
@@ -83,6 +83,10 @@ class AttributeToken extends index_2.Token {
83
83
  this.#tag = tag;
84
84
  this.setAttribute('name', (0, string_1.trimLc)((0, string_1.removeComment)(key)));
85
85
  }
86
+ /** 更新name */
87
+ #setName() {
88
+ this.setAttribute('name', (0, string_1.trimLc)(this.firstChild.text()));
89
+ }
86
90
  /** @private */
87
91
  afterBuild() {
88
92
  if (this.#equal.includes('\0')) {
@@ -91,7 +95,7 @@ class AttributeToken extends index_2.Token {
91
95
  if (this.parentNode) {
92
96
  this.#tag = this.parentNode.name;
93
97
  }
94
- this.setAttribute('name', (0, string_1.trimLc)(this.firstChild.text()));
98
+ this.#setName();
95
99
  super.afterBuild();
96
100
  }
97
101
  /** @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;