wikiparser-node 1.4.0 → 1.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 (122) hide show
  1. package/config/default.json +18 -3
  2. package/config/enwiki.json +1224 -0
  3. package/dist/addon/table.js +4 -2
  4. package/dist/index.js +4 -7
  5. package/dist/lib/element.d.ts +6 -5
  6. package/dist/lib/element.js +25 -33
  7. package/dist/lib/node.d.ts +1 -0
  8. package/dist/lib/node.js +1 -1
  9. package/dist/lib/range.d.ts +1 -0
  10. package/dist/lib/ranges.d.ts +1 -0
  11. package/dist/lib/text.d.ts +1 -0
  12. package/dist/lib/text.js +14 -4
  13. package/dist/lib/title.d.ts +1 -0
  14. package/dist/mixin/attributesParent.d.ts +1 -61
  15. package/dist/mixin/fixed.d.ts +1 -27
  16. package/dist/mixin/hidden.d.ts +1 -14
  17. package/dist/mixin/singleLine.d.ts +1 -10
  18. package/dist/mixin/sol.d.ts +1 -11
  19. package/dist/mixin/syntax.d.ts +1 -14
  20. package/dist/parser/braces.js +3 -0
  21. package/dist/parser/commentAndExt.js +5 -0
  22. package/dist/parser/converter.js +1 -0
  23. package/dist/parser/externalLinks.js +1 -0
  24. package/dist/parser/hrAndDoubleUnderscore.js +3 -0
  25. package/dist/parser/html.js +4 -1
  26. package/dist/parser/links.js +1 -0
  27. package/dist/parser/list.js +2 -0
  28. package/dist/parser/magicLinks.js +1 -0
  29. package/dist/parser/quotes.js +1 -0
  30. package/dist/parser/table.js +4 -0
  31. package/dist/src/arg.d.ts +2 -1
  32. package/dist/src/arg.js +1 -0
  33. package/dist/src/attribute.d.ts +2 -5
  34. package/dist/src/attribute.js +1 -0
  35. package/dist/src/attributes.d.ts +2 -1
  36. package/dist/src/attributes.js +5 -1
  37. package/dist/src/converter.d.ts +3 -10
  38. package/dist/src/converter.js +9 -2
  39. package/dist/src/converterFlags.d.ts +2 -1
  40. package/dist/src/converterFlags.js +1 -0
  41. package/dist/src/converterRule.d.ts +1 -1
  42. package/dist/src/converterRule.js +1 -0
  43. package/dist/src/extLink.d.ts +7 -5
  44. package/dist/src/extLink.js +11 -0
  45. package/dist/src/gallery.d.ts +2 -1
  46. package/dist/src/gallery.js +7 -1
  47. package/dist/src/heading.d.ts +4 -8
  48. package/dist/src/heading.js +1 -0
  49. package/dist/src/hidden.d.ts +0 -2
  50. package/dist/src/html.d.ts +4 -19
  51. package/dist/src/html.js +1 -0
  52. package/dist/src/imageParameter.d.ts +2 -1
  53. package/dist/src/imageParameter.js +1 -0
  54. package/dist/src/imagemap.d.ts +1 -1
  55. package/dist/src/imagemap.js +5 -0
  56. package/dist/src/imagemapLink.d.ts +1 -7
  57. package/dist/src/imagemapLink.js +5 -1
  58. package/dist/src/index.d.ts +4 -0
  59. package/dist/src/index.js +51 -29
  60. package/dist/src/link/base.d.ts +1 -0
  61. package/dist/src/link/category.d.ts +1 -1
  62. package/dist/src/link/category.js +0 -1
  63. package/dist/src/link/file.d.ts +2 -1
  64. package/dist/src/link/file.js +6 -3
  65. package/dist/src/link/galleryImage.d.ts +5 -3
  66. package/dist/src/link/galleryImage.js +0 -1
  67. package/dist/src/link/index.d.ts +2 -1
  68. package/dist/src/link/index.js +0 -1
  69. package/dist/src/magicLink.d.ts +1 -6
  70. package/dist/src/magicLink.js +2 -1
  71. package/dist/src/nested.d.ts +2 -1
  72. package/dist/src/nested.js +5 -1
  73. package/dist/src/nowiki/base.d.ts +1 -5
  74. package/dist/src/nowiki/comment.d.ts +1 -3
  75. package/dist/src/nowiki/comment.js +1 -1
  76. package/dist/src/nowiki/dd.d.ts +1 -1
  77. package/dist/src/nowiki/dd.js +0 -1
  78. package/dist/src/nowiki/doubleUnderscore.d.ts +2 -10
  79. package/dist/src/nowiki/doubleUnderscore.js +1 -1
  80. package/dist/src/nowiki/hr.d.ts +3 -9
  81. package/dist/src/nowiki/hr.js +0 -1
  82. package/dist/src/nowiki/index.d.ts +1 -1
  83. package/dist/src/nowiki/index.js +0 -1
  84. package/dist/src/nowiki/list.d.ts +3 -2
  85. package/dist/src/nowiki/list.js +0 -1
  86. package/dist/src/nowiki/listBase.d.ts +1 -6
  87. package/dist/src/nowiki/listBase.js +0 -1
  88. package/dist/src/nowiki/noinclude.d.ts +1 -3
  89. package/dist/src/nowiki/noinclude.js +0 -1
  90. package/dist/src/nowiki/quote.d.ts +1 -7
  91. package/dist/src/nowiki/quote.js +0 -1
  92. package/dist/src/paramTag/index.d.ts +1 -1
  93. package/dist/src/paramTag/index.js +1 -1
  94. package/dist/src/paramTag/inputbox.d.ts +1 -1
  95. package/dist/src/paramTag/inputbox.js +0 -1
  96. package/dist/src/parameter.d.ts +1 -5
  97. package/dist/src/parameter.js +1 -0
  98. package/dist/src/pre.d.ts +1 -1
  99. package/dist/src/pre.js +3 -0
  100. package/dist/src/syntax.d.ts +0 -5
  101. package/dist/src/table/base.d.ts +3 -13
  102. package/dist/src/table/base.js +3 -1
  103. package/dist/src/table/index.d.ts +1 -1
  104. package/dist/src/table/index.js +0 -1
  105. package/dist/src/table/td.d.ts +2 -5
  106. package/dist/src/table/td.js +6 -3
  107. package/dist/src/table/tr.d.ts +2 -1
  108. package/dist/src/table/tr.js +3 -2
  109. package/dist/src/table/trBase.d.ts +1 -0
  110. package/dist/src/table/trBase.js +1 -0
  111. package/dist/src/tagPair/ext.d.ts +3 -13
  112. package/dist/src/tagPair/ext.js +19 -2
  113. package/dist/src/tagPair/include.d.ts +1 -3
  114. package/dist/src/tagPair/include.js +1 -0
  115. package/dist/src/tagPair/index.d.ts +2 -5
  116. package/dist/src/tagPair/index.js +1 -1
  117. package/dist/src/transclude.d.ts +2 -1
  118. package/dist/src/transclude.js +8 -2
  119. package/dist/util/string.js +3 -1
  120. package/i18n/zh-hans.json +4 -3
  121. package/i18n/zh-hant.json +5 -4
  122. package/package.json +11 -11
@@ -57,9 +57,11 @@ const parseTable = ({ firstChild: { data }, type, name }, config = Parser.getCon
57
57
  }
58
58
  const [, indent, moreSpaces, tableSyntax, attr] = matchesStart;
59
59
  if (indent) {
60
+ // @ts-expect-error abstract class
60
61
  new dd_1.DdToken(indent, config, accum);
61
62
  }
62
63
  push(`\n${spaces}${indent && `\0${accum.length - 1}d\x7F`}${moreSpaces}\0${accum.length}b\x7F`, top);
64
+ // @ts-expect-error abstract class
63
65
  stack.push(...top ? [top] : [], new index_2.TableToken(tableSyntax, attr, config, accum));
64
66
  continue;
65
67
  }
@@ -88,6 +90,7 @@ const parseTable = ({ firstChild: { data }, type, name }, config = Parser.getCon
88
90
  if (top.type === 'tr') {
89
91
  top = stack.pop();
90
92
  }
93
+ // @ts-expect-error abstract class
91
94
  const tr = new tr_1.TrToken(`\n${spaces}${row}`, attr, config, accum);
92
95
  stack.push(top, tr);
93
96
  top.insertAt(tr);
@@ -101,6 +104,7 @@ const parseTable = ({ firstChild: { data }, type, name }, config = Parser.getCon
101
104
  * @param tr 当前表格行
102
105
  */
103
106
  const createTd = (tr) => {
107
+ // @ts-expect-error abstract class
104
108
  const td = new td_1.TdToken(lastSyntax, attr.slice(lastIndex, mt?.index), config, accum);
105
109
  tr.insertAt(td);
106
110
  return td;
package/dist/src/arg.d.ts CHANGED
@@ -7,7 +7,8 @@ import type { LintError } from '../base';
7
7
  * `{{{}}}`包裹的参数
8
8
  * @classdesc `{childNodes: [AtomToken, ?Token, ...HiddenToken]}`
9
9
  */
10
- export declare class ArgToken extends Token {
10
+ export declare abstract class ArgToken extends Token {
11
+ #private;
11
12
  readonly type = "arg";
12
13
  readonly name: string;
13
14
  readonly childNodes: readonly [AtomToken] | readonly [AtomToken, Token, ...HiddenToken[]];
package/dist/src/arg.js CHANGED
@@ -105,6 +105,7 @@ class ArgToken extends index_1.Token {
105
105
  cloneNode() {
106
106
  const [name, ...cloned] = this.cloneChildNodes();
107
107
  return debug_1.Shadow.run(() => {
108
+ // @ts-expect-error abstract class
108
109
  const token = new ArgToken([''], this.getAttribute('config'));
109
110
  token.firstChild.safeReplaceWith(name);
110
111
  token.append(...cloned);
@@ -2,13 +2,10 @@ import * as Parser from '../index';
2
2
  import { Token } from './index';
3
3
  import { AtomToken } from './atom';
4
4
  import type { LintError } from '../base';
5
- import type { FixedTokenBase } from '../mixin/fixed';
6
5
  import type { AttributesToken } from '../internal';
7
6
  export type AttributeTypes = 'ext-attr' | 'html-attr' | 'table-attr';
8
- export declare class AttributeToken extends Token implements FixedTokenBase {
9
- removeAt(): never;
10
- insertAt(token: string, i?: number | undefined): Parser.AstText;
11
- insertAt<T extends Parser.AstNodes>(token: T, i?: number | undefined): T;
7
+ export declare abstract class AttributeToken extends Token {
8
+ #private;
12
9
  type: AttributeTypes;
13
10
  readonly name: string;
14
11
  readonly tag: string;
@@ -354,6 +354,7 @@ class AttributeToken extends (0, fixed_1.fixedToken)(index_1.Token) {
354
354
  cloneNode() {
355
355
  const [key, value] = this.cloneChildNodes(), config = this.getAttribute('config');
356
356
  return debug_1.Shadow.run(() => {
357
+ // @ts-expect-error abstract class
357
358
  const token = new AttributeToken(this.type, this.tag, '', this.#equal, '', this.#quotes, config);
358
359
  token.firstChild.safeReplaceWith(key);
359
360
  token.lastChild.safeReplaceWith(value);
@@ -10,7 +10,8 @@ declare type AttributesTypes = `${AttributeTypes}s`;
10
10
  * 扩展和HTML标签属性
11
11
  * @classdesc `{childNodes: ...AtomToken|AttributeToken}`
12
12
  */
13
- export declare class AttributesToken extends Token {
13
+ export declare abstract class AttributesToken extends Token {
14
+ #private;
14
15
  type: AttributesTypes;
15
16
  readonly name: string;
16
17
  readonly childNodes: readonly (AtomToken | AttributeToken)[];
@@ -99,7 +99,9 @@ class AttributesToken extends index_1.Token {
99
99
  const { index, 0: full, 1: key, 2: equal, 3: quoteStart, 4: quoted, 5: quoteEnd, 6: unquoted } = mt;
100
100
  out += attr.slice(lastIndex, index);
101
101
  if (/^(?:[\w:]|\0\d+[t!~{}+-]\x7F)(?:[\w:.-]|\0\d+[t!~{}+-]\x7F)*$/u.test((0, string_1.removeComment)(key).trim())) {
102
- const value = quoted ?? unquoted, quotes = [quoteStart, quoteEnd], token = new attribute_1.AttributeToken(toAttributeType(type), name, key, equal, value, quotes, config, accum);
102
+ const value = quoted ?? unquoted, quotes = [quoteStart, quoteEnd],
103
+ // @ts-expect-error abstract class
104
+ token = new attribute_1.AttributeToken(toAttributeType(type), name, key, equal, value, quotes, config, accum);
103
105
  insertDirty();
104
106
  super.insertAt(token);
105
107
  }
@@ -200,6 +202,7 @@ class AttributesToken extends index_1.Token {
200
202
  cloneNode() {
201
203
  const cloned = this.cloneChildNodes();
202
204
  return debug_1.Shadow.run(() => {
205
+ // @ts-expect-error abstract class
203
206
  const token = new AttributesToken(undefined, this.type, this.name, this.getAttribute('config'));
204
207
  token.append(...cloned);
205
208
  token.setAttribute('name', this.name);
@@ -262,6 +265,7 @@ class AttributesToken extends index_1.Token {
262
265
  else if (value === false) {
263
266
  return;
264
267
  }
268
+ // @ts-expect-error abstract class
265
269
  const token = debug_1.Shadow.run(() => new attribute_1.AttributeToken(toAttributeType(this.type), this.name, key, value === true ? '' : '=', value === true ? '' : value, ['"', '"'], this.getAttribute('config')));
266
270
  this.insertAt(token);
267
271
  }
@@ -3,16 +3,9 @@ import { Token } from './index';
3
3
  import { ConverterFlagsToken } from './converterFlags';
4
4
  import { ConverterRuleToken } from './converterRule';
5
5
  import type { FlagsParentBase } from '../mixin/flagsParent';
6
- export declare class ConverterToken extends Token implements FlagsParentBase {
7
- flags: Set<string>;
8
- getAllFlags(): Set<string>;
9
- getEffectiveFlags(): Set<string>;
10
- getUnknownFlags(): Set<string>;
11
- hasFlag(flag: string): boolean;
12
- hasEffectiveFlag(flag: string): boolean;
13
- removeFlag(flag: string): void;
14
- setFlag(flag: string): void;
15
- toggleFlag(flag: string): void;
6
+ export interface ConverterToken extends FlagsParentBase {
7
+ }
8
+ export declare abstract class ConverterToken extends Token {
16
9
  readonly type = "converter";
17
10
  readonly childNodes: readonly [ConverterFlagsToken, ...ConverterRuleToken[]];
18
11
  abstract get children(): [ConverterFlagsToken, ...ConverterRuleToken[]];
@@ -27,13 +27,19 @@ class ConverterToken extends (0, flagsParent_1.flagsParent)(index_1.Token) {
27
27
  */
28
28
  constructor(flags, rules, config = Parser.getConfig(), accum = []) {
29
29
  super(undefined, config, accum);
30
+ // @ts-expect-error abstract class
30
31
  this.append(new converterFlags_1.ConverterFlagsToken(flags, config, accum));
31
- const [firstRule] = rules, hasColon = firstRule.includes(':'), firstRuleToken = new converterRule_1.ConverterRuleToken(firstRule, hasColon, config, accum);
32
+ const [firstRule] = rules, hasColon = firstRule.includes(':'),
33
+ // @ts-expect-error abstract class
34
+ firstRuleToken = new converterRule_1.ConverterRuleToken(firstRule, hasColon, config, accum);
32
35
  if (hasColon && firstRuleToken.length === 1) {
36
+ // @ts-expect-error abstract class
33
37
  this.insertAt(new converterRule_1.ConverterRuleToken(rules.join(';'), false, config, accum));
34
38
  }
35
39
  else {
36
- this.append(firstRuleToken, ...rules.slice(1).map(rule => new converterRule_1.ConverterRuleToken(rule, true, config, accum)));
40
+ this.append(firstRuleToken,
41
+ // @ts-expect-error abstract class
42
+ ...rules.slice(1).map(rule => new converterRule_1.ConverterRuleToken(rule, true, config, accum)));
37
43
  }
38
44
  this.protectChildren(0);
39
45
  }
@@ -67,6 +73,7 @@ class ConverterToken extends (0, flagsParent_1.flagsParent)(index_1.Token) {
67
73
  cloneNode() {
68
74
  const [flags, ...rules] = this.cloneChildNodes();
69
75
  return debug_1.Shadow.run(() => {
76
+ // @ts-expect-error abstract class
70
77
  const token = new ConverterToken([], [''], this.getAttribute('config'));
71
78
  token.firstChild.safeReplaceWith(flags);
72
79
  token.removeAt(1);
@@ -7,7 +7,8 @@ import type { ConverterToken, ConverterRuleToken } from '../internal';
7
7
  * 转换flags
8
8
  * @classdesc `{childNodes: ...AtomToken}`
9
9
  */
10
- export declare class ConverterFlagsToken extends Token {
10
+ export declare abstract class ConverterFlagsToken extends Token {
11
+ #private;
11
12
  readonly type = "converter-flags";
12
13
  readonly childNodes: readonly AtomToken[];
13
14
  abstract get children(): AtomToken[];
@@ -91,6 +91,7 @@ class ConverterFlagsToken extends index_1.Token {
91
91
  cloneNode() {
92
92
  const cloned = this.cloneChildNodes();
93
93
  return debug_1.Shadow.run(() => {
94
+ // @ts-expect-error abstract class
94
95
  const token = new ConverterFlagsToken([], this.getAttribute('config'));
95
96
  token.append(...cloned);
96
97
  token.afterBuild();
@@ -6,7 +6,7 @@ import type { ConverterToken, ConverterFlagsToken } from '../internal';
6
6
  * 转换规则
7
7
  * @classdesc `{childNodes: ...AtomToken}`
8
8
  */
9
- export declare class ConverterRuleToken extends Token {
9
+ export declare abstract class ConverterRuleToken extends Token {
10
10
  readonly type = "converter-rule";
11
11
  readonly childNodes: readonly [AtomToken] | readonly [AtomToken, AtomToken] | readonly [AtomToken, AtomToken, AtomToken];
12
12
  abstract get children(): [AtomToken] | [AtomToken, AtomToken] | [AtomToken, AtomToken, AtomToken];
@@ -110,6 +110,7 @@ class ConverterRuleToken extends index_1.Token {
110
110
  cloneNode() {
111
111
  const cloned = this.cloneChildNodes(), placeholders = ['', 'zh:', '=>zh:'], placeholder = placeholders[cloned.length - 1];
112
112
  return debug_1.Shadow.run(() => {
113
+ // @ts-expect-error abstract class
113
114
  const token = new ConverterRuleToken(placeholder, Boolean(placeholder), this.getAttribute('config'));
114
115
  for (let i = 0; i < cloned.length; i++) {
115
116
  token.childNodes[i].safeReplaceWith(cloned[i]);
@@ -1,12 +1,12 @@
1
1
  import * as Parser from '../index';
2
2
  import { Token } from './index';
3
3
  import { MagicLinkToken } from './magicLink';
4
+ import type { LintError } from '../base';
4
5
  import type { MagicLinkParentBase } from '../mixin/magicLinkParent';
5
- export declare class ExtLinkToken extends Token implements MagicLinkParentBase {
6
- protocol: string | undefined;
7
- link: string;
8
- getUrl(): URL;
9
- setTarget(url: string): void;
6
+ export interface ExtLinkToken extends MagicLinkParentBase {
7
+ }
8
+ export declare abstract class ExtLinkToken extends Token {
9
+ #private;
10
10
  readonly type = "ext-link";
11
11
  readonly childNodes: readonly [MagicLinkToken] | readonly [MagicLinkToken, Token];
12
12
  abstract get children(): [MagicLinkToken] | [MagicLinkToken, Token];
@@ -24,6 +24,8 @@ export declare class ExtLinkToken extends Token implements MagicLinkParentBase {
24
24
  /** @override */
25
25
  text(): string;
26
26
  /** @override */
27
+ lint(start?: number): LintError[];
28
+ /** @override */
27
29
  print(): string;
28
30
  /** @override */
29
31
  cloneNode(): this;
@@ -4,6 +4,7 @@ exports.ExtLinkToken = void 0;
4
4
  const string_1 = require("../util/string");
5
5
  const debug_1 = require("../util/debug");
6
6
  const constants_1 = require("../util/constants");
7
+ const lint_1 = require("../util/lint");
7
8
  const magicLinkParent_1 = require("../mixin/magicLinkParent");
8
9
  const Parser = require("../index");
9
10
  const index_1 = require("./index");
@@ -35,6 +36,7 @@ class ExtLinkToken extends (0, magicLinkParent_1.magicLinkParent)(index_1.Token)
35
36
  super(undefined, config, accum, {
36
37
  MagicLinkToken: 0, Token: 1,
37
38
  });
39
+ // @ts-expect-error abstract class
38
40
  this.insertAt(new magicLink_1.MagicLinkToken(url, true, config, accum));
39
41
  this.#space = space;
40
42
  if (text) {
@@ -74,6 +76,14 @@ class ExtLinkToken extends (0, magicLinkParent_1.magicLinkParent)(index_1.Token)
74
76
  return this.#space.length;
75
77
  }
76
78
  /** @override */
79
+ lint(start = this.getAbsoluteIndex()) {
80
+ const errors = super.lint(start);
81
+ if (this.length === 1 && this.closest('heading-title')) {
82
+ errors.push((0, lint_1.generateForSelf)(this, { start }, 'variable anchor in a section header'));
83
+ }
84
+ return errors;
85
+ }
86
+ /** @override */
77
87
  print() {
78
88
  return super.print(this.length === 1 ? { pre: '[', post: `${this.#space}]` } : { pre: '[', sep: this.#space, post: ']' });
79
89
  }
@@ -82,6 +92,7 @@ class ExtLinkToken extends (0, magicLinkParent_1.magicLinkParent)(index_1.Token)
82
92
  cloneNode() {
83
93
  const [url, text] = this.cloneChildNodes();
84
94
  return debug_1.Shadow.run(() => {
95
+ // @ts-expect-error abstract class
85
96
  const token = new ExtLinkToken(undefined, '', '', this.getAttribute('config'));
86
97
  token.firstChild.safeReplaceWith(url);
87
98
  if (text) {
@@ -8,7 +8,8 @@ import type { AstNodes, AstText, AttributesToken, ExtToken } from '../internal';
8
8
  * gallery标签
9
9
  * @classdesc `{childNodes: ...(GalleryImageToken|NoincludeToken|AstText)}`
10
10
  */
11
- export declare class GalleryToken extends Token {
11
+ export declare abstract class GalleryToken extends Token {
12
+ #private;
12
13
  readonly type = "ext-inner";
13
14
  readonly name: 'gallery';
14
15
  readonly childNodes: readonly (GalleryImageToken | NoincludeToken | AstText)[];
@@ -27,14 +27,17 @@ class GalleryToken extends index_1.Token {
27
27
  for (const line of inner?.split('\n') ?? []) {
28
28
  const matches = /^([^|]+)(?:\|(.*))?/u.exec(line);
29
29
  if (!matches) {
30
+ // @ts-expect-error abstract class
30
31
  super.insertAt((line.trim() ? new noinclude_1.NoincludeToken(line, config) : line));
31
32
  continue;
32
33
  }
33
34
  const [, file, alt] = matches;
34
35
  if (this.#checkFile(file)) {
36
+ // @ts-expect-error abstract class
35
37
  super.insertAt(new galleryImage_1.GalleryImageToken('gallery', file, alt, config, accum));
36
38
  }
37
39
  else {
40
+ // @ts-expect-error abstract class
38
41
  super.insertAt(new noinclude_1.NoincludeToken(line, config));
39
42
  }
40
43
  }
@@ -91,6 +94,7 @@ class GalleryToken extends index_1.Token {
91
94
  cloneNode() {
92
95
  const cloned = this.cloneChildNodes();
93
96
  return debug_1.Shadow.run(() => {
97
+ // @ts-expect-error abstract class
94
98
  const token = new GalleryToken(undefined, this.getAttribute('config'));
95
99
  token.append(...cloned);
96
100
  return token;
@@ -104,7 +108,9 @@ class GalleryToken extends index_1.Token {
104
108
  */
105
109
  insertImage(file, i) {
106
110
  if (this.#checkFile(file)) {
107
- const token = debug_1.Shadow.run(() => new galleryImage_1.GalleryImageToken('gallery', file, undefined, this.getAttribute('config')));
111
+ const token = debug_1.Shadow.run(
112
+ // @ts-expect-error abstract class
113
+ () => new galleryImage_1.GalleryImageToken('gallery', file, undefined, this.getAttribute('config')));
108
114
  token.afterBuild();
109
115
  return this.insertAt(token, i);
110
116
  }
@@ -2,15 +2,11 @@ import * as Parser from '../index';
2
2
  import { Token } from './index';
3
3
  import { SyntaxToken } from './syntax';
4
4
  import type { LintError } from '../base';
5
- import type { FixedTokenBase } from '../mixin/fixed';
6
5
  import type { SolTokenBase } from '../mixin/sol';
7
- export declare class HeadingToken extends Token implements FixedTokenBase, SolTokenBase {
8
- prependNewLine(): string;
9
-
10
-
11
- removeAt(): never;
12
- insertAt(token: string, i?: number | undefined): Parser.AstText;
13
- insertAt<T_1 extends Parser.AstNodes>(token: T_1, i?: number | undefined): T_1;
6
+ export interface HeadingToken extends SolTokenBase {
7
+ }
8
+ export declare abstract class HeadingToken extends Token {
9
+ #private;
14
10
  readonly type = "heading";
15
11
  readonly childNodes: readonly [Token, SyntaxToken];
16
12
  abstract get children(): [Token, SyntaxToken];
@@ -121,6 +121,7 @@ class HeadingToken extends (0, sol_1.sol)((0, fixed_1.fixedToken)(index_1.Token)
121
121
  cloneNode() {
122
122
  const [title, trail] = this.cloneChildNodes();
123
123
  return debug_1.Shadow.run(() => {
124
+ // @ts-expect-error abstract class
124
125
  const token = new HeadingToken(this.level, [], this.getAttribute('config'));
125
126
  token.firstChild.safeReplaceWith(title);
126
127
  token.lastChild.safeReplaceWith(trail);
@@ -1,7 +1,5 @@
1
1
  import { Token } from './index';
2
2
  export declare class HiddenToken extends Token {
3
- text(): string;
4
- lint(): import("..").LintError[];
5
3
  readonly type = "hidden";
6
4
  /** @override */
7
5
  cloneNode(): this;
@@ -2,26 +2,11 @@ import * as Parser from '../index';
2
2
  import { Token } from './index';
3
3
  import type { LintError } from '../base';
4
4
  import type { AttributesParentBase } from '../mixin/attributesParent';
5
- import type { FixedTokenBase } from '../mixin/fixed';
6
5
  import type { AttributesToken } from '../internal';
7
- export declare class HtmlToken extends Token implements AttributesParentBase, FixedTokenBase {
8
- attributes: Record<string, string | true>;
9
- className: string;
10
- classList: Set<string>;
11
- id: string;
12
- hasAttr(key: string): boolean;
13
- getAttr(key: string): string | true | undefined;
14
- getAttrNames(): Set<string>;
15
- getAttrs(): Record<string, string | true>;
16
- setAttr(key: string, value: string | boolean): void;
17
- setAttr(prop: Record<string, string | boolean>): void;
18
- removeAttr(key: string): void;
19
- toggleAttr(key: string, force?: boolean | undefined): void;
20
-
21
-
22
- removeAt(): never;
23
- insertAt(token: string, i?: number | undefined): Parser.AstText;
24
- insertAt<T_2 extends Parser.AstNodes>(token: T_2, i?: number | undefined): T_2;
6
+ export interface HtmlToken extends AttributesParentBase {
7
+ }
8
+ export declare abstract class HtmlToken extends Token {
9
+ #private;
25
10
  readonly type = "html";
26
11
  readonly name: string;
27
12
  readonly childNodes: readonly [AttributesToken];
package/dist/src/html.js CHANGED
@@ -240,6 +240,7 @@ class HtmlToken extends (0, attributesParent_1.attributesParent)((0, fixed_1.fix
240
240
  /** @override */
241
241
  cloneNode() {
242
242
  const [attr] = this.cloneChildNodes(), config = this.getAttribute('config');
243
+ // @ts-expect-error abstract class
243
244
  return debug_1.Shadow.run(() => new HtmlToken(this.#tag, attr, this.closing, this.selfClosing, config));
244
245
  }
245
246
  /**
@@ -5,7 +5,8 @@ import type { Title } from '../lib/title';
5
5
  import type { AstNodes, AstText, AtomToken, FileToken } from '../internal';
6
6
  export declare const galleryParams: Set<string>;
7
7
  /** 图片参数 */
8
- export declare class ImageParameterToken extends Token {
8
+ export declare abstract class ImageParameterToken extends Token {
9
+ #private;
9
10
  readonly type = "image-parameter";
10
11
  readonly name: string;
11
12
  abstract get parentNode(): FileToken | undefined;
@@ -197,6 +197,7 @@ class ImageParameterToken extends index_1.Token {
197
197
  cloneNode() {
198
198
  const cloned = this.cloneChildNodes(), config = this.getAttribute('config');
199
199
  return debug_1.Shadow.run(() => {
200
+ // @ts-expect-error abstract class
200
201
  const token = new ImageParameterToken(this.#syntax.replace('$1', ''), config);
201
202
  token.replaceChildren(...cloned);
202
203
  token.setAttribute('name', this.name);
@@ -9,7 +9,7 @@ import type { AstNodes, AstText, AttributesToken, ExtToken } from '../internal';
9
9
  * `<imagemap>`
10
10
  * @classdesc `{childNodes: ...NoincludeToken, GalleryImageToken, ...(NoincludeToken|ImagemapLinkToken|AstText)}`
11
11
  */
12
- export declare class ImagemapToken extends Token {
12
+ export declare abstract class ImagemapToken extends Token {
13
13
  readonly type = "ext-inner";
14
14
  readonly name: 'imagemap';
15
15
  readonly childNodes: readonly (GalleryImageToken | NoincludeToken | ImagemapLinkToken | AstText)[];
@@ -46,6 +46,7 @@ class ImagemapToken extends index_1.Token {
46
46
  if (title.valid
47
47
  && !title.interwiki
48
48
  && title.ns === 6) {
49
+ // @ts-expect-error abstract class
49
50
  const token = new galleryImage_1.GalleryImageToken('imagemap', file, options.length > 0 ? options.join('|') : undefined, config, accum);
50
51
  super.insertAt(token);
51
52
  first = false;
@@ -65,6 +66,7 @@ class ImagemapToken extends index_1.Token {
65
66
  .exec(substr);
66
67
  if (mtIn) {
67
68
  if (this.normalizeTitle(mtIn[1], 0, true, false, true).valid) {
69
+ // @ts-expect-error abstract class
68
70
  super.insertAt(new imagemapLink_1.ImagemapLinkToken(line.slice(0, i), mtIn.slice(1), substr.slice(substr.indexOf(']]') + 2), config, accum));
69
71
  continue;
70
72
  }
@@ -74,11 +76,13 @@ class ImagemapToken extends index_1.Token {
74
76
  const mtEx = /^\[([^\]\s]+)(?:(\s+(?=\S))([^\]]*))?\][\w\s]*$/u
75
77
  .exec(substr);
76
78
  if (mtEx) {
79
+ // @ts-expect-error abstract class
77
80
  super.insertAt(new imagemapLink_1.ImagemapLinkToken(line.slice(0, i), mtEx.slice(1), substr.slice(substr.indexOf(']') + 1), config, accum));
78
81
  continue;
79
82
  }
80
83
  }
81
84
  }
85
+ // @ts-expect-error abstract class
82
86
  super.insertAt(new SingleLineNoincludeToken(line, config, accum));
83
87
  }
84
88
  }
@@ -137,6 +141,7 @@ class ImagemapToken extends index_1.Token {
137
141
  cloneNode() {
138
142
  const cloned = this.cloneChildNodes();
139
143
  return debug_1.Shadow.run(() => {
144
+ // @ts-expect-error abstract class
140
145
  const token = new ImagemapToken(undefined, this.getAttribute('config'));
141
146
  token.append(...cloned);
142
147
  return token;
@@ -4,14 +4,8 @@ import { NoincludeToken } from './nowiki/noinclude';
4
4
  import { LinkToken } from './link/index';
5
5
  import { ExtLinkToken } from './extLink';
6
6
  import type { Title } from '../lib/title';
7
- import type { FixedTokenBase } from '../mixin/fixed';
8
7
  import type { AstText, ImagemapToken } from '../internal';
9
- export declare class ImagemapLinkToken extends Token implements FixedTokenBase {
10
- removeAt(): never;
11
- insertAt(token: string, i?: number | undefined): Parser.AstText;
12
- insertAt<T extends Parser.AstNodes>(token: T, i?: number | undefined): T;
13
-
14
-
8
+ export declare abstract class ImagemapLinkToken extends Token {
15
9
  readonly type = "imagemap-link";
16
10
  readonly childNodes: readonly [AstText, LinkToken | ExtLinkToken, NoincludeToken];
17
11
  abstract get children(): [LinkToken | ExtLinkToken, NoincludeToken];
@@ -32,8 +32,12 @@ class ImagemapLinkToken extends (0, fixed_1.fixedToken)((0, singleLine_1.singleL
32
32
  constructor(pre, linkStuff, post, config = Parser.getConfig(), accum = []) {
33
33
  super(undefined, config, accum);
34
34
  this.append(pre, linkStuff.length === 2
35
+ // @ts-expect-error abstract class
35
36
  ? new index_2.LinkToken(...linkStuff, config, accum)
36
- : new extLink_1.ExtLinkToken(...linkStuff, config, accum), new noinclude_1.NoincludeToken(post, config, accum));
37
+ // @ts-expect-error abstract class
38
+ : new extLink_1.ExtLinkToken(...linkStuff, config, accum),
39
+ // @ts-expect-error abstract class
40
+ new noinclude_1.NoincludeToken(post, config, accum));
37
41
  }
38
42
  }
39
43
  exports.ImagemapLinkToken = ImagemapLinkToken;
@@ -3,6 +3,7 @@ import { AstRange } from '../lib/range';
3
3
  import * as Parser from '../index';
4
4
  import { AstElement } from '../lib/element';
5
5
  import { AstText } from '../lib/text';
6
+ import type { LintError } from '../base';
6
7
  import type { Range } from '../lib/ranges';
7
8
  import type { Title } from '../lib/title';
8
9
  import type { AstNodes, IncludeToken, HtmlToken, ExtToken, TranscludeToken, CommentToken, FileToken, LinkToken, ExtLinkToken, MagicLinkToken, ImageParameterToken, ImagemapLinkToken } from '../internal';
@@ -14,6 +15,7 @@ declare type TagToken = IncludeToken | ExtToken | HtmlToken;
14
15
  * @classdesc `{childNodes: ...(AstText|Token)}`
15
16
  */
16
17
  export declare class Token extends AstElement {
18
+ #private;
17
19
  type: TokenTypes;
18
20
  /** 所有图片,包括图库 */
19
21
  get images(): FileToken[];
@@ -39,6 +41,8 @@ export declare class Token extends AstElement {
39
41
  * @param selfLink 是否允许selfLink
40
42
  */
41
43
  normalizeTitle(title: string, defaultNs?: number, halfParsed?: boolean, decode?: boolean, selfLink?: boolean): Title;
44
+ /** @override */
45
+ lint(start?: number): LintError[];
42
46
  /**
43
47
  * @override
44
48
  * @param i 移除位置