wikilint 2.4.0 → 2.4.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 (99) hide show
  1. package/config/default.json +18 -3
  2. package/config/enwiki.json +411 -0
  3. package/dist/index.js +3 -6
  4. package/dist/lib/element.d.ts +6 -0
  5. package/dist/lib/element.js +25 -0
  6. package/dist/lib/node.d.ts +1 -0
  7. package/dist/lib/text.d.ts +1 -0
  8. package/dist/lib/text.js +13 -4
  9. package/dist/parser/braces.js +3 -0
  10. package/dist/parser/commentAndExt.js +5 -0
  11. package/dist/parser/converter.js +1 -0
  12. package/dist/parser/externalLinks.js +1 -0
  13. package/dist/parser/hrAndDoubleUnderscore.js +3 -0
  14. package/dist/parser/html.js +4 -1
  15. package/dist/parser/links.js +1 -0
  16. package/dist/parser/list.js +2 -0
  17. package/dist/parser/magicLinks.js +1 -0
  18. package/dist/parser/quotes.js +1 -0
  19. package/dist/parser/table.js +4 -0
  20. package/dist/src/arg.d.ts +1 -1
  21. package/dist/src/attribute.d.ts +2 -1
  22. package/dist/src/attributes.d.ts +1 -1
  23. package/dist/src/attributes.js +3 -1
  24. package/dist/src/converter.d.ts +1 -1
  25. package/dist/src/converter.js +8 -2
  26. package/dist/src/converterFlags.d.ts +2 -1
  27. package/dist/src/converterRule.d.ts +1 -1
  28. package/dist/src/extLink.d.ts +5 -1
  29. package/dist/src/extLink.js +10 -0
  30. package/dist/src/gallery.d.ts +2 -1
  31. package/dist/src/gallery.js +3 -0
  32. package/dist/src/heading.d.ts +2 -1
  33. package/dist/src/hidden.d.ts +0 -2
  34. package/dist/src/html.d.ts +2 -1
  35. package/dist/src/imageParameter.d.ts +2 -1
  36. package/dist/src/imagemap.d.ts +1 -1
  37. package/dist/src/imagemap.js +4 -0
  38. package/dist/src/imagemapLink.d.ts +1 -1
  39. package/dist/src/imagemapLink.js +5 -1
  40. package/dist/src/index.d.ts +1 -0
  41. package/dist/src/index.js +12 -12
  42. package/dist/src/link/base.d.ts +1 -0
  43. package/dist/src/link/category.d.ts +1 -1
  44. package/dist/src/link/category.js +0 -1
  45. package/dist/src/link/file.d.ts +2 -1
  46. package/dist/src/link/file.js +3 -2
  47. package/dist/src/link/galleryImage.d.ts +6 -3
  48. package/dist/src/link/galleryImage.js +0 -1
  49. package/dist/src/link/index.d.ts +1 -1
  50. package/dist/src/link/index.js +0 -1
  51. package/dist/src/magicLink.d.ts +1 -1
  52. package/dist/src/magicLink.js +1 -1
  53. package/dist/src/nested.d.ts +1 -1
  54. package/dist/src/nested.js +4 -1
  55. package/dist/src/nowiki/comment.d.ts +1 -3
  56. package/dist/src/nowiki/comment.js +0 -1
  57. package/dist/src/nowiki/dd.d.ts +1 -1
  58. package/dist/src/nowiki/dd.js +0 -1
  59. package/dist/src/nowiki/doubleUnderscore.d.ts +1 -3
  60. package/dist/src/nowiki/doubleUnderscore.js +0 -1
  61. package/dist/src/nowiki/hr.d.ts +1 -1
  62. package/dist/src/nowiki/hr.js +0 -1
  63. package/dist/src/nowiki/index.d.ts +1 -1
  64. package/dist/src/nowiki/index.js +0 -1
  65. package/dist/src/nowiki/list.d.ts +1 -1
  66. package/dist/src/nowiki/list.js +0 -1
  67. package/dist/src/nowiki/listBase.d.ts +1 -1
  68. package/dist/src/nowiki/listBase.js +0 -1
  69. package/dist/src/nowiki/noinclude.d.ts +1 -3
  70. package/dist/src/nowiki/noinclude.js +0 -1
  71. package/dist/src/nowiki/quote.d.ts +1 -1
  72. package/dist/src/nowiki/quote.js +0 -1
  73. package/dist/src/paramTag/index.d.ts +1 -1
  74. package/dist/src/paramTag/index.js +1 -1
  75. package/dist/src/paramTag/inputbox.d.ts +1 -1
  76. package/dist/src/paramTag/inputbox.js +0 -1
  77. package/dist/src/parameter.d.ts +1 -1
  78. package/dist/src/pre.d.ts +1 -1
  79. package/dist/src/pre.js +2 -0
  80. package/dist/src/table/base.js +3 -1
  81. package/dist/src/table/index.d.ts +1 -1
  82. package/dist/src/table/index.js +0 -1
  83. package/dist/src/table/td.d.ts +2 -1
  84. package/dist/src/table/td.js +0 -1
  85. package/dist/src/table/tr.d.ts +1 -1
  86. package/dist/src/table/tr.js +0 -1
  87. package/dist/src/table/trBase.js +1 -0
  88. package/dist/src/tagPair/ext.d.ts +1 -1
  89. package/dist/src/tagPair/ext.js +18 -2
  90. package/dist/src/tagPair/include.d.ts +1 -3
  91. package/dist/src/tagPair/index.d.ts +3 -0
  92. package/dist/src/tagPair/index.js +5 -0
  93. package/dist/src/transclude.d.ts +2 -1
  94. package/dist/src/transclude.js +1 -0
  95. package/dist/util/string.js +3 -1
  96. package/i18n/zh-hans.json +4 -3
  97. package/i18n/zh-hant.json +5 -4
  98. package/package.json +14 -13
  99. package/dist/bin/declaration.js +0 -27
@@ -6,7 +6,6 @@ const hidden_1 = require("../../mixin/hidden");
6
6
  const Parser = require("../../index");
7
7
  const base_1 = require("./base");
8
8
  /** HTML注释,不可见 */
9
- // @ts-expect-error not implementing all abstract methods
10
9
  class CommentToken extends (0, hidden_1.hiddenToken)(base_1.NowikiBaseToken) {
11
10
  type = 'comment';
12
11
  closed;
@@ -1,5 +1,5 @@
1
1
  import { ListBaseToken } from './listBase';
2
2
  /** `:` */
3
- export declare class DdToken extends ListBaseToken {
3
+ export declare abstract class DdToken extends ListBaseToken {
4
4
  readonly type = "dd";
5
5
  }
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.DdToken = void 0;
4
4
  const listBase_1 = require("./listBase");
5
5
  /** `:` */
6
- // @ts-expect-error not implementing all abstract methods
7
6
  class DdToken extends listBase_1.ListBaseToken {
8
7
  type = 'dd';
9
8
  }
@@ -1,9 +1,7 @@
1
1
  import * as Parser from '../../index';
2
2
  import { NowikiBaseToken } from './base';
3
3
  import type { Token } from '../index';
4
- export declare class DoubleUnderscoreToken extends NowikiBaseToken {
5
- text(): string;
6
- lint(): Parser.LintError[];
4
+ export declare abstract class DoubleUnderscoreToken extends NowikiBaseToken {
7
5
  readonly type = "double-underscore";
8
6
  /**
9
7
  * @param word 状态开关名
@@ -5,7 +5,6 @@ const hidden_1 = require("../../mixin/hidden");
5
5
  const Parser = require("../../index");
6
6
  const base_1 = require("./base");
7
7
  /** 状态开关 */
8
- // @ts-expect-error not implementing all abstract methods
9
8
  class DoubleUnderscoreToken extends (0, hidden_1.hiddenToken)(base_1.NowikiBaseToken) {
10
9
  type = 'double-underscore';
11
10
  /**
@@ -1,5 +1,5 @@
1
1
  import { NowikiBaseToken } from './base';
2
2
  /** `<hr>` */
3
- export declare class HrToken extends NowikiBaseToken {
3
+ export declare abstract class HrToken extends NowikiBaseToken {
4
4
  readonly type = "hr";
5
5
  }
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.HrToken = void 0;
4
4
  const base_1 = require("./base");
5
5
  /** `<hr>` */
6
- // @ts-expect-error not implementing all abstract methods
7
6
  class HrToken extends base_1.NowikiBaseToken {
8
7
  type = 'hr';
9
8
  }
@@ -2,7 +2,7 @@ import { NowikiBaseToken } from './base';
2
2
  import type { LintError } from '../../base';
3
3
  import type { AttributesToken, ExtToken } from '../../internal';
4
4
  /** 扩展标签内的纯文字Token */
5
- export declare class NowikiToken extends NowikiBaseToken {
5
+ export declare abstract class NowikiToken extends NowikiBaseToken {
6
6
  readonly type = "ext-inner";
7
7
  readonly name: string;
8
8
  abstract get nextSibling(): undefined;
@@ -5,7 +5,6 @@ const lint_1 = require("../../util/lint");
5
5
  const Parser = require("../../index");
6
6
  const base_1 = require("./base");
7
7
  /** 扩展标签内的纯文字Token */
8
- // @ts-expect-error not implementing all abstract methods
9
8
  class NowikiToken extends base_1.NowikiBaseToken {
10
9
  type = 'ext-inner';
11
10
  /** @override */
@@ -1,5 +1,5 @@
1
1
  import { ListBaseToken } from './listBase';
2
2
  /** 位于行首的`;:*#` */
3
- export declare class ListToken extends ListBaseToken {
3
+ export declare abstract class ListToken extends ListBaseToken {
4
4
  readonly type = "list";
5
5
  }
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ListToken = void 0;
4
4
  const listBase_1 = require("./listBase");
5
5
  /** 位于行首的`;:*#` */
6
- // @ts-expect-error not implementing all abstract methods
7
6
  class ListToken extends listBase_1.ListBaseToken {
8
7
  type = 'list';
9
8
  }
@@ -1,5 +1,5 @@
1
1
  import { NowikiBaseToken } from './base';
2
2
  /** `;:*#` */
3
- export declare class ListBaseToken extends NowikiBaseToken {
3
+ export declare abstract class ListBaseToken extends NowikiBaseToken {
4
4
  type: 'dd' | 'list';
5
5
  }
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ListBaseToken = void 0;
4
4
  const base_1 = require("./base");
5
5
  /** `;:*#` */
6
- // @ts-expect-error not implementing all abstract methods
7
6
  class ListBaseToken extends base_1.NowikiBaseToken {
8
7
  }
9
8
  exports.ListBaseToken = ListBaseToken;
@@ -1,7 +1,5 @@
1
1
  import { NowikiBaseToken } from './base';
2
- export declare class NoincludeToken extends NowikiBaseToken {
3
- text(): string;
4
- lint(): import("../..").LintError[];
2
+ export declare abstract class NoincludeToken extends NowikiBaseToken {
5
3
  readonly type = "noinclude";
6
4
  }
7
5
  export {};
@@ -4,7 +4,6 @@ exports.NoincludeToken = void 0;
4
4
  const hidden_1 = require("../../mixin/hidden");
5
5
  const base_1 = require("./base");
6
6
  /** `<noinclude>`和`</noinclude>`,不可进行任何更改 */
7
- // @ts-expect-error not implementing all abstract methods
8
7
  class NoincludeToken extends (0, hidden_1.hiddenToken)(base_1.NowikiBaseToken) {
9
8
  type = 'noinclude';
10
9
  }
@@ -1,7 +1,7 @@
1
1
  import { NowikiBaseToken } from './base';
2
2
  import type { LintError } from '../../base';
3
3
  /** `''`和`'''` */
4
- export declare class QuoteToken extends NowikiBaseToken {
4
+ export declare abstract class QuoteToken extends NowikiBaseToken {
5
5
  readonly type = "quote";
6
6
  /** 是否粗体 */
7
7
  get bold(): boolean;
@@ -5,7 +5,6 @@ const lint_1 = require("../../util/lint");
5
5
  const Parser = require("../../index");
6
6
  const base_1 = require("./base");
7
7
  /** `''`和`'''` */
8
- // @ts-expect-error not implementing all abstract methods
9
8
  class QuoteToken extends base_1.NowikiBaseToken {
10
9
  type = 'quote';
11
10
  /** 是否粗体 */
@@ -7,7 +7,7 @@ import type { AttributesToken, ExtToken } from '../../internal';
7
7
  * `<dynamicpagelist>`
8
8
  * @classdesc `{childNodes: ...AtomToken}`
9
9
  */
10
- export declare class ParamTagToken extends Token {
10
+ export declare abstract class ParamTagToken extends Token {
11
11
  readonly type = "ext-inner";
12
12
  readonly name: string;
13
13
  readonly childNodes: readonly AtomToken[];
@@ -39,7 +39,7 @@ class ParamTagToken extends index_1.Token {
39
39
  return str && !(i >= 0 ? /^[a-z]+(?:\[\])?\s*(?:=|$)/iu : /^[a-z]+(?:\[\])?\s*=/iu).test(str);
40
40
  }).map(child => {
41
41
  rect ??= { start, ...this.getRootNode().posFromIndex(start) };
42
- return (0, lint_1.generateForChild)(child, rect, Parser.msg('invalid parameter of $1', this.name));
42
+ return (0, lint_1.generateForChild)(child, rect, Parser.msg('invalid parameter of <$1>', this.name));
43
43
  });
44
44
  }
45
45
  }
@@ -2,7 +2,7 @@ import * as Parser from '../../index';
2
2
  import { ParamTagToken } from './index';
3
3
  import type { Token } from '../index';
4
4
  /** `<inputbox>` */
5
- export declare class InputboxToken extends ParamTagToken {
5
+ export declare abstract class InputboxToken extends ParamTagToken {
6
6
  /** @class */
7
7
  constructor(wikitext?: string, config?: Parser.Config, accum?: Token[]);
8
8
  }
@@ -5,7 +5,6 @@ const braces_1 = require("../../parser/braces");
5
5
  const Parser = require("../../index");
6
6
  const index_1 = require("./index");
7
7
  /** `<inputbox>` */
8
- // @ts-expect-error not implementing all abstract methods
9
8
  class InputboxToken extends index_1.ParamTagToken {
10
9
  /** @class */
11
10
  constructor(wikitext, config = Parser.getConfig(), accum = []) {
@@ -6,7 +6,7 @@ import type { AtomToken, SyntaxToken, TranscludeToken } from '../internal';
6
6
  * 模板或魔术字参数
7
7
  * @classdesc `{childNodes: [Token, Token]}`
8
8
  */
9
- export declare class ParameterToken extends Token {
9
+ export declare abstract class ParameterToken extends Token {
10
10
  readonly type = "parameter";
11
11
  readonly name: string;
12
12
  readonly childNodes: readonly [Token, Token];
package/dist/src/pre.d.ts CHANGED
@@ -6,7 +6,7 @@ import type { AstText, AttributesToken, ExtToken, ConverterToken } from '../inte
6
6
  * `<pre>`
7
7
  * @classdesc `{childNodes: [...AstText|NoincludeToken|ConverterToken]}`
8
8
  */
9
- export declare class PreToken extends Token {
9
+ export declare abstract class PreToken extends Token {
10
10
  readonly type = "ext-inner";
11
11
  readonly name: 'pre';
12
12
  readonly childNodes: readonly (AstText | NoincludeToken | ConverterToken)[];
package/dist/src/pre.js CHANGED
@@ -17,7 +17,9 @@ class PreToken extends index_1.Token {
17
17
  const opening = '<nowiki>', closing = '</nowiki>', { length } = opening;
18
18
  let i = wikitext.indexOf(opening), j = wikitext.indexOf(closing, i + length), str = '';
19
19
  while (i !== -1 && j !== -1) {
20
+ // @ts-expect-error abstract class
20
21
  new noinclude_1.NoincludeToken(opening, config, accum);
22
+ // @ts-expect-error abstract class
21
23
  new noinclude_1.NoincludeToken(closing, config, accum);
22
24
  str += `${wikitext.slice(0, i)}\0${accum.length - 1}c\x7F${wikitext.slice(i + length, j)}\0${accum.length}c\x7F`;
23
25
  wikitext = wikitext.slice(j + length + 1);
@@ -17,7 +17,9 @@ class TableBaseToken extends index_1.Token {
17
17
  */
18
18
  constructor(pattern, syntax, attr, config = Parser.getConfig(), accum = [], acceptable = {}) {
19
19
  super(undefined, config, accum, acceptable);
20
- this.append(new syntax_1.SyntaxToken(syntax, pattern, 'table-syntax', config, accum, {}), new attributes_1.AttributesToken(attr, 'table-attrs', this.type, config, accum));
20
+ this.append(new syntax_1.SyntaxToken(syntax, pattern, 'table-syntax', config, accum, {}),
21
+ // @ts-expect-error abstract class
22
+ new attributes_1.AttributesToken(attr, 'table-attrs', this.type, config, accum));
21
23
  }
22
24
  }
23
25
  exports.TableBaseToken = TableBaseToken;
@@ -7,7 +7,7 @@ import type { AttributesToken, TdToken, TrToken, Token } from '../../internal';
7
7
  * 表格
8
8
  * @classdesc `{childNodes: [SyntaxToken, AttributesToken, ?Token, ...TdToken, ...TrToken, ?SyntaxToken]}`
9
9
  */
10
- export declare class TableToken extends TrBaseToken {
10
+ export declare abstract class TableToken extends TrBaseToken {
11
11
  readonly type = "table";
12
12
  readonly childNodes: readonly [SyntaxToken, AttributesToken, ...(TdToken | TrToken)[], SyntaxToken] | readonly [SyntaxToken, AttributesToken, ...(TdToken | TrToken)[]];
13
13
  abstract get lastChild(): AttributesToken | TdToken | TrToken | SyntaxToken;
@@ -11,7 +11,6 @@ const closingPattern = /^\n[^\S\n]*(?:\|\}|\{\{\s*!\s*\}\}\}|\{\{\s*!\)\s*\}\})$
11
11
  * 表格
12
12
  * @classdesc `{childNodes: [SyntaxToken, AttributesToken, ?Token, ...TdToken, ...TrToken, ?SyntaxToken]}`
13
13
  */
14
- // @ts-expect-error not implementing all abstract methods
15
14
  class TableToken extends trBase_1.TrBaseToken {
16
15
  type = 'table';
17
16
  /** 表格是否闭合 */
@@ -13,7 +13,8 @@ export type TdAttrs = Record<string, string | true> & TdSpanAttrs;
13
13
  * `<td>`、`<th>`和`<caption>`
14
14
  * @classdesc `{childNodes: [SyntaxToken, AttributesToken, Token]}`
15
15
  */
16
- export declare class TdToken extends TableBaseToken {
16
+ export declare abstract class TdToken extends TableBaseToken {
17
+ #private;
17
18
  readonly type = "td";
18
19
  readonly childNodes: readonly [SyntaxToken, AttributesToken, Token];
19
20
  abstract get parentNode(): TrToken | TableToken | undefined;
@@ -10,7 +10,6 @@ const base_1 = require("./base");
10
10
  * `<td>`、`<th>`和`<caption>`
11
11
  * @classdesc `{childNodes: [SyntaxToken, AttributesToken, Token]}`
12
12
  */
13
- // @ts-expect-error not implementing all abstract methods
14
13
  class TdToken extends base_1.TableBaseToken {
15
14
  type = 'td';
16
15
  #innerSyntax = '';
@@ -5,7 +5,7 @@ import type { Token, TdToken, TableToken, SyntaxToken, AttributesToken } from '.
5
5
  * 表格行,含开头的换行,不含结尾的换行
6
6
  * @classdesc `{childNodes: [SyntaxToken, AttributesToken, ?Token, ...TdToken]}`
7
7
  */
8
- export declare class TrToken extends TrBaseToken {
8
+ export declare abstract class TrToken extends TrBaseToken {
9
9
  readonly type = "tr";
10
10
  readonly childNodes: readonly [SyntaxToken, AttributesToken, ...TdToken[]];
11
11
  abstract get lastChild(): AttributesToken | TdToken;
@@ -7,7 +7,6 @@ const trBase_1 = require("./trBase");
7
7
  * 表格行,含开头的换行,不含结尾的换行
8
8
  * @classdesc `{childNodes: [SyntaxToken, AttributesToken, ?Token, ...TdToken]}`
9
9
  */
10
- // @ts-expect-error not implementing all abstract methods
11
10
  class TrToken extends trBase_1.TrBaseToken {
12
11
  type = 'tr';
13
12
  /**
@@ -29,6 +29,7 @@ class TrBaseToken extends base_1.TableBaseToken {
29
29
  const error = (0, lint_1.generateForChild)(inter, { start }, 'content to be moved out from the table');
30
30
  errors.push({
31
31
  ...error,
32
+ severity: first.type === 'template' ? 'warning' : 'error',
32
33
  startIndex: error.startIndex + 1,
33
34
  startLine: error.startLine + 1,
34
35
  startCol: 0,
@@ -7,7 +7,7 @@ import type { LintError } from '../../base';
7
7
  * 扩展标签
8
8
  * @classdesc `{childNodes: [AttributesToken, Token]}`
9
9
  */
10
- export declare class ExtToken extends TagPairToken {
10
+ export declare abstract class ExtToken extends TagPairToken {
11
11
  readonly type = "ext";
12
12
  closed: true;
13
13
  readonly childNodes: readonly [AttributesToken, Token];
@@ -29,7 +29,9 @@ class ExtToken extends index_2.TagPairToken {
29
29
  * @param closed 是否封闭
30
30
  */
31
31
  constructor(name, attr, inner, closed, config = Parser.getConfig(), accum = []) {
32
- const lcName = name.toLowerCase(), attrToken = new attributes_1.AttributesToken(!attr || attr.trimStart() !== attr ? attr : ` ${attr}`, 'ext-attrs', lcName, config, accum), newConfig = { ...config, ext: del(config.ext, lcName), excludes: [...config.excludes ?? []] };
32
+ const lcName = name.toLowerCase(),
33
+ // @ts-expect-error abstract class
34
+ attrToken = new attributes_1.AttributesToken(!attr || attr.trimStart() !== attr ? attr : ` ${attr}`, 'ext-attrs', lcName, config, accum), newConfig = { ...config, ext: del(config.ext, lcName), excludes: [...config.excludes ?? []] };
33
35
  let innerToken;
34
36
  switch (lcName) {
35
37
  case 'tab':
@@ -50,42 +52,50 @@ class ExtToken extends index_2.TagPairToken {
50
52
  break;
51
53
  case 'pre': {
52
54
  const { PreToken } = require('../pre');
55
+ // @ts-expect-error abstract class
53
56
  innerToken = new PreToken(inner, newConfig, accum);
54
57
  break;
55
58
  }
56
59
  case 'dynamicpagelist': {
57
60
  const { ParamTagToken } = require('../paramTag/index');
61
+ // @ts-expect-error abstract class
58
62
  innerToken = new ParamTagToken(inner, newConfig, accum);
59
63
  break;
60
64
  }
61
65
  case 'inputbox': {
62
66
  newConfig.excludes.push('heading');
63
67
  const { InputboxToken } = require('../paramTag/inputbox');
68
+ // @ts-expect-error abstract class
64
69
  innerToken = new InputboxToken(inner, newConfig, accum);
65
70
  break;
66
71
  }
67
72
  case 'references': {
68
73
  const { NestedToken } = require('../nested');
74
+ // @ts-expect-error abstract class
69
75
  innerToken = new NestedToken(inner, /<!--.*?(?:-->|$)|<(ref)(\s[^>]*)?>(.*?)<\/(ref\s*)>/gisu, ['ref'], newConfig, accum);
70
76
  break;
71
77
  }
72
78
  case 'choose': {
73
79
  const { NestedToken } = require('../nested');
80
+ // @ts-expect-error abstract class
74
81
  innerToken = new NestedToken(inner, /<(option|choicetemplate)(\s[^>]*)?>(.*?)<\/(\1)>/gsu, ['option', 'choicetemplate'], newConfig, accum);
75
82
  break;
76
83
  }
77
84
  case 'combobox': {
78
85
  const { NestedToken } = require('../nested');
86
+ // @ts-expect-error abstract class
79
87
  innerToken = new NestedToken(inner, /<(combooption)(\s[^>]*)?>(.*?)<\/(combooption\s*)>/gisu, ['combooption'], newConfig, accum);
80
88
  break;
81
89
  }
82
90
  case 'gallery': {
83
91
  const { GalleryToken } = require('../gallery');
92
+ // @ts-expect-error abstract class
84
93
  innerToken = new GalleryToken(inner, newConfig, accum);
85
94
  break;
86
95
  }
87
96
  case 'imagemap': {
88
97
  const { ImagemapToken } = require('../imagemap');
98
+ // @ts-expect-error abstract class
89
99
  innerToken = new ImagemapToken(inner, newConfig, accum);
90
100
  break;
91
101
  }
@@ -99,6 +109,7 @@ class ExtToken extends index_2.TagPairToken {
99
109
  // ```
100
110
  default: {
101
111
  const { NowikiToken } = require('../nowiki/index');
112
+ // @ts-expect-error abstract class
102
113
  innerToken = new NowikiToken(inner, newConfig);
103
114
  }
104
115
  }
@@ -109,10 +120,15 @@ class ExtToken extends index_2.TagPairToken {
109
120
  /** @override */
110
121
  lint(start = this.getAbsoluteIndex()) {
111
122
  const errors = super.lint(start);
123
+ let rect;
112
124
  if (this.name !== 'nowiki' && this.closest('html-attrs, table-attrs')) {
113
- const rect = { start, ...this.getRootNode().posFromIndex(start) };
125
+ rect = { start, ...this.getRootNode().posFromIndex(start) };
114
126
  errors.push((0, lint_1.generateForSelf)(this, rect, 'extension tag in HTML tag attributes'));
115
127
  }
128
+ if (this.name === 'ref' && this.closest('heading-title')) {
129
+ rect ??= { start, ...this.getRootNode().posFromIndex(start) };
130
+ errors.push((0, lint_1.generateForSelf)(this, rect, 'variable anchor in a section header'));
131
+ }
116
132
  return errors;
117
133
  }
118
134
  }
@@ -2,9 +2,7 @@ import * as Parser from '../../index';
2
2
  import { TagPairToken } from './index';
3
3
  import type { LintError } from '../../base';
4
4
  import type { AstText, Token } from '../../internal';
5
- export declare class IncludeToken extends TagPairToken {
6
- text(): string;
7
- lint(): Parser.LintError[];
5
+ export declare abstract class IncludeToken extends TagPairToken {
8
6
  readonly type = "include";
9
7
  readonly childNodes: readonly [AstText, AstText];
10
8
  abstract get firstChild(): AstText;
@@ -3,6 +3,7 @@ import { Token } from '../index';
3
3
  import type { AstNodes } from '../../lib/node';
4
4
  /** 成对标签 */
5
5
  export declare abstract class TagPairToken extends Token {
6
+ #private;
6
7
  type: 'ext' | 'include';
7
8
  readonly name: string;
8
9
  closed: boolean;
@@ -10,6 +11,8 @@ export declare abstract class TagPairToken extends Token {
10
11
  readonly childNodes: readonly [AstNodes, AstNodes];
11
12
  abstract get firstChild(): AstNodes;
12
13
  abstract get lastChild(): AstNodes;
14
+ /** 内部wikitext */
15
+ get innerText(): string | undefined;
13
16
  /**
14
17
  * @param name 标签名
15
18
  * @param attr 标签属性
@@ -8,6 +8,11 @@ class TagPairToken extends index_1.Token {
8
8
  #tags;
9
9
  closed;
10
10
  selfClosing;
11
+ /* NOT FOR BROWSER END */
12
+ /** 内部wikitext */
13
+ get innerText() {
14
+ return this.selfClosing ? undefined : this.lastChild.text();
15
+ }
11
16
  /**
12
17
  * @param name 标签名
13
18
  * @param attr 标签属性
@@ -8,7 +8,8 @@ import type { LintError } from '../base';
8
8
  * 模板或魔术字
9
9
  * @classdesc `{childNodes: [AtomToken|SyntaxToken, ...AtomToken, ...ParameterToken]}`
10
10
  */
11
- export declare class TranscludeToken extends Token {
11
+ export declare abstract class TranscludeToken extends Token {
12
+ #private;
12
13
  type: 'template' | 'magic-word';
13
14
  readonly modifier: string;
14
15
  readonly childNodes: readonly [AtomToken | SyntaxToken, ...ParameterToken[]] | readonly [SyntaxToken, AtomToken, AtomToken, ...ParameterToken[]];
@@ -89,6 +89,7 @@ class TranscludeToken extends index_1.Token {
89
89
  part.unshift(i);
90
90
  i++;
91
91
  }
92
+ // @ts-expect-error abstract class
92
93
  this.insertAt(new parameter_1.ParameterToken(...part, config, accum));
93
94
  }
94
95
  }
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.noWrap = exports.decodeHtml = exports.text = exports.escapeRegExp = exports.removeComment = exports.extUrlChar = exports.extUrlCharFirst = void 0;
3
+ exports.noWrap = exports.decodeHtml = exports.text = exports.escapeRegExp = exports.removeComment = exports.tidy = exports.extUrlChar = exports.extUrlCharFirst = void 0;
4
4
  exports.extUrlCharFirst = '(?:\\[[\\da-f:.]+\\]|[^[\\]<>"\0-\x1F\x7F\\p{Zs}\uFFFD])';
5
5
  exports.extUrlChar = '(?:[^[\\]<>"\0-\x1F\x7F\\p{Zs}\uFFFD]|\0\\d+[c!~]\x7F)*';
6
6
  /**
@@ -9,6 +9,8 @@ exports.extUrlChar = '(?:[^[\\]<>"\0-\x1F\x7F\\p{Zs}\uFFFD]|\0\\d+[c!~]\x7F)*';
9
9
  * @param replace 替换字符串或函数
10
10
  */
11
11
  const factory = (regex, replace) => (str) => str.replace(regex, replace);
12
+ /** 清理解析专用的不可见字符 */
13
+ exports.tidy = factory(/[\0\x7F]/gu, '');
12
14
  /** remove half-parsed comment-like tokens */
13
15
  exports.removeComment = factory(/\0\d+c\x7F/gu, '');
14
16
  /** escape special chars for RegExp constructor */
package/i18n/zh-hans.json CHANGED
@@ -10,6 +10,7 @@
10
10
  "containing invalid attribute": "包含无效属性",
11
11
  "content to be moved out from the table": "将被移出表格的内容",
12
12
  "duplicated $1 attribute": "重复的$1属性",
13
+ "duplicated category": "重复的分类",
13
14
  "duplicated image $1 parameter": "重复的图片$1参数",
14
15
  "duplicated parameter": "重复参数",
15
16
  "extension tag in HTML tag attributes": "HTML标签属性中的扩展标签",
@@ -27,13 +28,12 @@
27
28
  "invalid gallery image": "无效的图库图片",
28
29
  "invalid gallery image parameter": "无效的图库图片参数",
29
30
  "invalid link in <imagemap>": "无效的<imagemap>链接",
30
- "invalid parameter of $1": "$1的无效参数",
31
+ "invalid parameter of <$1>": "<$1>的无效参数",
31
32
  "invalid self-closing tag": "无效自封闭标签",
32
- "invisible content inside triple brackets": "三重括号内的不可见部分",
33
+ "invisible content inside triple braces": "三重括号内的不可见部分",
33
34
  "italic": "斜体单引号",
34
35
  "lonely \"$1\"": "孤立的\"$1\"",
35
36
  "missing module function": "缺少模块函数",
36
- "missing module name": "缺少模块名称",
37
37
  "nonzero tabindex": "不为0的tabindex",
38
38
  "nothing should be in <$1>": "<$1>标签内不应有任何内容",
39
39
  "obsolete attribute": "过时的属性",
@@ -51,5 +51,6 @@
51
51
  "unmatched closing tag": "未匹配的闭合标签",
52
52
  "unnecessary URL encoding in an internal link": "内链中不必要的URL编码",
53
53
  "useless fragment": "多余的fragment",
54
+ "variable anchor in a section header": "段落标题中可变的锚点",
54
55
  "vertical-alignment": "垂直对齐"
55
56
  }
package/i18n/zh-hant.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "<imagemap> without an image": "缺少圖片的<imagemap>",
3
3
  "$1 in URL": "URL中的$1",
4
- "additional \"|\" in a table cell": "表哥單元格中多餘的\"|\"",
4
+ "additional \"|\" in a table cell": "表格單元格中多餘的\"|\"",
5
5
  "additional \"|\" in the link text": "連結文本中多餘的\"|\"",
6
6
  "attributes of a closing tag": "位於閉合標籤的屬性",
7
7
  "bold apostrophes": "粗體撇號",
@@ -10,6 +10,7 @@
10
10
  "containing invalid attribute": "包含無效屬性",
11
11
  "content to be moved out from the table": "將被移出表格的內容",
12
12
  "duplicated $1 attribute": "重複的$1屬性",
13
+ "duplicated category": "重複的分類",
13
14
  "duplicated image $1 parameter": "重複的圖片$1參數",
14
15
  "duplicated parameter": "重複參數",
15
16
  "extension tag in HTML tag attributes": "HTML標籤屬性中的擴展標籤",
@@ -27,13 +28,12 @@
27
28
  "invalid gallery image": "無效的圖庫圖片",
28
29
  "invalid gallery image parameter": "無效的圖庫圖片參數",
29
30
  "invalid link in <imagemap>": "無效的<imagemap>連結",
30
- "invalid parameter of $1": "$1的無效參數",
31
+ "invalid parameter of <$1>": "<$1>的無效參數",
31
32
  "invalid self-closing tag": "無效自封閉標籤",
32
- "invisible content inside triple brackets": "三重括號內的不可見部分",
33
+ "invisible content inside triple braces": "三重括號內的不可見部分",
33
34
  "italic apostrophes": "斜體撇號",
34
35
  "lonely \"$1\"": "孤立的\"$1\"",
35
36
  "missing module function": "缺少模組函式",
36
- "missing module name": "缺少模組名稱",
37
37
  "nonzero tabindex": "不為0的tabindex",
38
38
  "nothing should be in <$1>": "<$1>標籤內不應有任何內容",
39
39
  "obsolete attribute": "過時的屬性",
@@ -51,5 +51,6 @@
51
51
  "unmatched closing tag": "未匹配的閉合標籤",
52
52
  "unnecessary URL encoding in an internal link": "內部連結中不必要的URL編碼",
53
53
  "useless fragment": "多餘的fragment",
54
+ "variable anchor in a section header": "段落標題中可變的錨點",
54
55
  "vertical-alignment": "垂直對齊"
55
56
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wikilint",
3
- "version": "2.4.0",
3
+ "version": "2.4.1",
4
4
  "description": "A Node.js linter for MediaWiki markup",
5
5
  "keywords": [
6
6
  "mediawiki",
@@ -18,9 +18,10 @@
18
18
  "/errors/README",
19
19
  "/config/",
20
20
  "/i18n/",
21
- "/bin/cli",
21
+ "/bin/cli.js",
22
22
  "/dist/",
23
- "!/dist/test/"
23
+ "!/dist/test/",
24
+ "!/dist/bin/declaration.js"
24
25
  ],
25
26
  "bin": {
26
27
  "wikilint": "./bin/cli.js"
@@ -31,7 +32,7 @@
31
32
  "url": "git+https://github.com/bhsd-harry/wikiparser-node.git"
32
33
  },
33
34
  "scripts": {
34
- "declaration": "grep -rl --include='*.d.ts' '@private' dist/ | xargs gsed -i -E '/^\\s+\\/\\*\\* @private/,+1d'; grep -rl --include='*.d.ts' '#private' dist/ | xargs gsed -i '/#private/d'; node ./dist/bin/declaration.js",
35
+ "declaration": "grep -rl --include='*.d.ts' '@private' dist/ | xargs bash sed.sh -i -E '/^\\s+\\/\\*\\* @private/,+1d'; node ./dist/bin/declaration.js",
35
36
  "prepublishOnly": "npm run build && rm dist/internal.js dist/base.js dist/[bmpu]*/*.d.ts",
36
37
  "build": "bash build.sh",
37
38
  "diff": "git diff --ignore-all-space --color-moved",
@@ -45,22 +46,22 @@
45
46
  },
46
47
  "devDependencies": {
47
48
  "@cypress/request": "^3.0.1",
48
- "@stylistic/eslint-plugin": "^1.5.3",
49
- "@types/node": "^20.9.0",
49
+ "@stylistic/eslint-plugin": "^1.5.4",
50
+ "@types/node": "^20.11.6",
50
51
  "@types/request": "^2.48.12",
51
- "@typescript-eslint/eslint-plugin": "^6.12.0",
52
- "@typescript-eslint/parser": "^6.12.0",
52
+ "@typescript-eslint/eslint-plugin": "^6.19.1",
53
+ "@typescript-eslint/parser": "^6.19.1",
53
54
  "ajv-cli": "^5.0.0",
54
55
  "eslint": "^8.56.0",
55
- "eslint-plugin-es-x": "^7.3.0",
56
+ "eslint-plugin-es-x": "^7.5.0",
56
57
  "eslint-plugin-eslint-comments": "^3.2.0",
57
- "eslint-plugin-jsdoc": "^47.0.2",
58
+ "eslint-plugin-jsdoc": "^48.0.2",
58
59
  "eslint-plugin-json-es": "^1.5.7",
59
- "eslint-plugin-n": "^16.3.1",
60
+ "eslint-plugin-n": "^16.6.2",
60
61
  "eslint-plugin-promise": "^6.1.1",
61
- "eslint-plugin-regexp": "^2.1.1",
62
+ "eslint-plugin-regexp": "^2.2.0",
62
63
  "eslint-plugin-unicorn": "^50.0.1",
63
- "typescript": "^5.1.6"
64
+ "typescript": "^5.3.3"
64
65
  },
65
66
  "engines": {
66
67
  "node": "^20.9.0"