wikilint 2.48.1 → 3.0.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 (66) hide show
  1. package/README.md +1 -1
  2. package/data/signatures.json +2 -2
  3. package/dist/base.d.mts +3 -2
  4. package/dist/base.d.ts +3 -2
  5. package/dist/base.js +1 -0
  6. package/dist/base.mjs +2 -1
  7. package/dist/bin/config.js +1 -1
  8. package/dist/index.d.ts +0 -1
  9. package/dist/index.js +17 -11
  10. package/dist/internal.d.ts +1 -0
  11. package/dist/lib/document.d.ts +4 -4
  12. package/dist/lib/lintConfig.js +1 -0
  13. package/dist/lib/lsp.js +7 -4
  14. package/dist/lib/node.d.ts +0 -4
  15. package/dist/lib/node.js +8 -0
  16. package/dist/map.d.ts +2 -1
  17. package/dist/parser/commentAndExt.js +1 -2
  18. package/dist/parser/hrAndDoubleUnderscore.js +3 -2
  19. package/dist/parser/table.js +2 -1
  20. package/dist/src/arg.d.ts +1 -1
  21. package/dist/src/arg.js +1 -1
  22. package/dist/src/attributes.d.ts +4 -3
  23. package/dist/src/converter.d.ts +1 -1
  24. package/dist/src/converter.js +1 -1
  25. package/dist/src/converterRule.d.ts +1 -1
  26. package/dist/src/converterRule.js +1 -1
  27. package/dist/src/extLink.d.ts +1 -1
  28. package/dist/src/extLink.js +1 -1
  29. package/dist/src/index.js +54 -14
  30. package/dist/src/link/category.d.ts +1 -1
  31. package/dist/src/link/category.js +1 -1
  32. package/dist/src/link/index.d.ts +1 -1
  33. package/dist/src/link/index.js +1 -1
  34. package/dist/src/link/redirectTarget.d.ts +1 -1
  35. package/dist/src/link/redirectTarget.js +1 -1
  36. package/dist/src/magicLink.d.ts +4 -3
  37. package/dist/src/magicLink.js +1 -1
  38. package/dist/src/multiLine/gallery.d.ts +4 -4
  39. package/dist/src/multiLine/imagemap.d.ts +5 -3
  40. package/dist/src/multiLine/imagemap.js +1 -1
  41. package/dist/src/nested.d.ts +1 -1
  42. package/dist/src/nested.js +1 -1
  43. package/dist/src/nowiki/list.js +6 -3
  44. package/dist/src/nowiki/listBase.d.ts +24 -0
  45. package/dist/src/nowiki/listBase.js +104 -0
  46. package/dist/src/paramLine.d.ts +1 -1
  47. package/dist/src/paramLine.js +1 -1
  48. package/dist/src/pre.d.ts +5 -3
  49. package/dist/src/redirect.d.ts +1 -1
  50. package/dist/src/redirect.js +1 -1
  51. package/dist/src/singleLine/charinsertLine.d.ts +1 -1
  52. package/dist/src/singleLine/charinsertLine.js +1 -1
  53. package/dist/src/table/index.d.ts +2 -2
  54. package/dist/src/table/index.js +1 -1
  55. package/dist/src/table/tr.d.ts +1 -1
  56. package/dist/src/table/tr.js +1 -1
  57. package/dist/src/tag/index.d.ts +7 -5
  58. package/dist/src/tag/index.js +9 -4
  59. package/dist/src/tagPair/ext.js +1 -1
  60. package/dist/src/transclude.d.ts +1 -1
  61. package/dist/src/transclude.js +1 -1
  62. package/dist/util/debug.js +7 -1
  63. package/i18n/en.json +1 -0
  64. package/i18n/zh-hans.json +1 -0
  65. package/i18n/zh-hant.json +1 -0
  66. package/package.json +6 -6
@@ -7,7 +7,7 @@ import type { Token, AtomToken } from '../../internal';
7
7
  * target of a redirect
8
8
  *
9
9
  * 重定向目标
10
- * @classdesc `{childNodes: [AtomToken, ?NoincludeToken]}`
10
+ * @classdesc `{childNodes: [AtomToken, NoincludeToken?]}`
11
11
  */
12
12
  export declare abstract class RedirectTargetToken extends LinkBaseToken {
13
13
  readonly childNodes: readonly [AtomToken] | readonly [AtomToken, NoincludeToken];
@@ -12,7 +12,7 @@ const noinclude_1 = require("../nowiki/noinclude");
12
12
  * target of a redirect
13
13
  *
14
14
  * 重定向目标
15
- * @classdesc `{childNodes: [AtomToken, ?NoincludeToken]}`
15
+ * @classdesc `{childNodes: [AtomToken, NoincludeToken?]}`
16
16
  */
17
17
  class RedirectTargetToken extends base_1.LinkBaseToken {
18
18
  get type() {
@@ -3,17 +3,18 @@ import { Token } from './index';
3
3
  import type { LintError } from '../base';
4
4
  import type { AstText, CommentToken, IncludeToken, NoincludeToken, TranscludeToken } from '../internal';
5
5
  declare type ExtLinkTypes = 'free-ext-link' | 'ext-link-url' | 'magic-link';
6
+ declare type Child = CommentToken | IncludeToken | NoincludeToken | TranscludeToken;
6
7
  /**
7
8
  * free external link
8
9
  *
9
10
  * 自由外链
10
- * @classdesc `{childNodes: (AstText|CommentToken|IncludeToken|NoincludeToken)[]}`
11
+ * @classdesc `{childNodes: (AstText|CommentToken|IncludeToken|NoincludeToken|TranscludeToken)[]}`
11
12
  */
12
13
  export declare abstract class MagicLinkToken extends Token {
13
14
  #private;
14
- readonly childNodes: readonly (AstText | CommentToken | IncludeToken | NoincludeToken | TranscludeToken)[];
15
+ readonly childNodes: readonly (AstText | Child)[];
15
16
  abstract get firstChild(): AstText | TranscludeToken;
16
- abstract get lastChild(): AstText | CommentToken | IncludeToken | NoincludeToken | TranscludeToken;
17
+ abstract get lastChild(): AstText | Child;
17
18
  get type(): ExtLinkTypes;
18
19
  /**
19
20
  * text of the link
@@ -15,7 +15,7 @@ const spaceRegex = new RegExp(`${space}+`, 'gu');
15
15
  * free external link
16
16
  *
17
17
  * 自由外链
18
- * @classdesc `{childNodes: (AstText|CommentToken|IncludeToken|NoincludeToken)[]}`
18
+ * @classdesc `{childNodes: (AstText|CommentToken|IncludeToken|NoincludeToken|TranscludeToken)[]}`
19
19
  */
20
20
  class MagicLinkToken extends index_2.Token {
21
21
  #type;
@@ -3,7 +3,7 @@ import { GalleryImageToken } from '../link/galleryImage';
3
3
  import { CommentLineToken } from '../nowiki/commentLine';
4
4
  import type { Config, LintError } from '../../base';
5
5
  import type { AstText, Token } from '../../internal';
6
- declare type Child = GalleryImageToken | CommentLineToken | AstText;
6
+ declare type Child = GalleryImageToken | CommentLineToken;
7
7
  /**
8
8
  * `<gallery>`
9
9
  * @classdesc `{childNodes: (GalleryImageToken|CommentLineToken|AstText)[]}`
@@ -11,9 +11,9 @@ declare type Child = GalleryImageToken | CommentLineToken | AstText;
11
11
  export declare abstract class GalleryToken extends MultiLineToken {
12
12
  #private;
13
13
  readonly name: 'gallery';
14
- readonly childNodes: readonly Child[];
15
- abstract get firstChild(): Child | undefined;
16
- abstract get lastChild(): Child | undefined;
14
+ readonly childNodes: readonly (AstText | Child)[];
15
+ abstract get firstChild(): AstText | Child | undefined;
16
+ abstract get lastChild(): AstText | Child | undefined;
17
17
  /** @param inner 标签内部wikitext */
18
18
  constructor(inner?: string, config?: Config, accum?: Token[]);
19
19
  }
@@ -5,17 +5,19 @@ import { GalleryImageToken } from '../link/galleryImage';
5
5
  import { ImagemapLinkToken } from '../singleLine/imagemapLink';
6
6
  import type { LintError } from '../../base';
7
7
  import type { AstText, Token } from '../../internal';
8
+ declare type Child = GalleryImageToken | CommentLineToken | ImagemapLinkToken;
8
9
  /**
9
10
  * `<imagemap>`
10
- * @classdesc `{childNodes: [...CommentLineToken[], GalleryImageToken, ...(CommentLineToken|ImagemapLinkToken|AstText)[]]}`
11
+ * @classdesc `{childNodes: (GalleryImageToken|CommentLineToken|ImagemapLinkToken|AstText)[]]}`
11
12
  */
12
13
  export declare abstract class ImagemapToken extends MultiLineToken {
13
14
  readonly name: 'imagemap';
14
- readonly childNodes: readonly (GalleryImageToken | CommentLineToken | ImagemapLinkToken | AstText)[];
15
+ readonly childNodes: readonly (Child | AstText)[];
15
16
  abstract get firstChild(): GalleryImageToken | CommentLineToken | undefined;
16
- abstract get lastChild(): GalleryImageToken | CommentLineToken | ImagemapLinkToken | AstText | undefined;
17
+ abstract get lastChild(): Child | AstText | undefined;
17
18
  /** 图片 */
18
19
  get image(): GalleryImageToken | undefined;
19
20
  /** @param inner 标签内部wikitext */
20
21
  constructor(inner?: string, config?: Parser.Config, accum?: Token[]);
21
22
  }
23
+ export {};
@@ -14,7 +14,7 @@ const galleryImage_1 = require("../link/galleryImage");
14
14
  const imagemapLink_1 = require("../singleLine/imagemapLink");
15
15
  /**
16
16
  * `<imagemap>`
17
- * @classdesc `{childNodes: [...CommentLineToken[], GalleryImageToken, ...(CommentLineToken|ImagemapLinkToken|AstText)[]]}`
17
+ * @classdesc `{childNodes: (GalleryImageToken|CommentLineToken|ImagemapLinkToken|AstText)[]]}`
18
18
  */
19
19
  class ImagemapToken extends index_2.MultiLineToken {
20
20
  /** 图片 */
@@ -8,7 +8,7 @@ declare type Child = ExtToken | NoincludeToken | CommentToken | IncludeToken | A
8
8
  * extension tag that has a nested structure
9
9
  *
10
10
  * 嵌套式的扩展标签
11
- * @classdesc `{childNodes: (ExtToken|NoincludeToken|CommentToken)[]}`
11
+ * @classdesc `{childNodes: (ExtToken|NoincludeToken|CommentToken|IncludeToken|ArgToken|TranscludeToken)[]}`
12
12
  */
13
13
  export declare abstract class NestedToken extends Token {
14
14
  #private;
@@ -20,7 +20,7 @@ const childTypes = new Set(['comment', 'include', 'arg', 'template', 'magic-word
20
20
  * extension tag that has a nested structure
21
21
  *
22
22
  * 嵌套式的扩展标签
23
- * @classdesc `{childNodes: (ExtToken|NoincludeToken|CommentToken)[]}`
23
+ * @classdesc `{childNodes: (ExtToken|NoincludeToken|CommentToken|IncludeToken|ArgToken|TranscludeToken)[]}`
24
24
  */
25
25
  class NestedToken extends index_2.Token {
26
26
  #tags;
@@ -22,11 +22,14 @@ class ListToken extends listBase_1.ListBaseToken {
22
22
  LINT: {
23
23
  const rule = 'syntax-like', s = index_1.default.lintConfig.getSeverity(rule, 'redirect'), { innerText } = this;
24
24
  if (s && innerText === '#') {
25
- // eslint-disable-next-line prefer-const
26
25
  let { nextSibling } = this;
26
+ PRINT: if (nextSibling?.is('list-range')) {
27
+ nextSibling = nextSibling.firstChild;
28
+ }
27
29
  if (nextSibling?.type === 'text' && linkTypes.has(nextSibling.nextSibling?.type)) {
28
- /^redirect\s*(?::\s*)?$/iu; // eslint-disable-line @typescript-eslint/no-unused-expressions
29
- const re = new RegExp(String.raw `^(?:${this.getAttribute('config').redirection.join('|')})\s*(?::\s*)?$`, 'iu');
30
+ // eslint-disable-next-line @typescript-eslint/no-unused-expressions
31
+ /^redirect[^\S\n]*(?::[^\S\n]*)?$/iu;
32
+ const re = new RegExp(String.raw `^(?:${this.getAttribute('config').redirection.join('|')})[^\S\n]*(?::[^\S\n]*)?$`, 'iu');
30
33
  if (re.test(`#${nextSibling.data}`)) {
31
34
  const e = (0, lint_1.generateForSelf)(nextSibling, { start: start + 1 }, rule, 'redirect-like', s);
32
35
  e.startIndex--;
@@ -1,5 +1,29 @@
1
+ import { AstText } from '../../lib/text';
2
+ import { Token } from '../index';
1
3
  import { NowikiBaseToken } from './base';
4
+ import type { DdToken, ListToken } from '../../internal';
5
+ export interface ListRangeToken extends Token {
6
+ readonly type: 'list-range';
7
+ readonly previousSibling: ListToken | DdToken;
8
+ readonly nextSibling: DdToken | AstText | undefined;
9
+ }
2
10
  /** `;:*#` */
3
11
  export declare abstract class ListBaseToken extends NowikiBaseToken {
4
12
  abstract get type(): 'dd' | 'list';
13
+ /** whether to contain `;` / 是否包含`;` */
14
+ get dt(): boolean;
15
+ /**
16
+ * number of indentation
17
+ *
18
+ * 缩进数
19
+ * @since v1.16.5
20
+ */
21
+ get indent(): number;
22
+ /**
23
+ * Get the range of the list
24
+ *
25
+ * 获取列表行的范围
26
+ * @throws `Error` if the token has no parent node
27
+ */
28
+ getRange(): ListRangeToken;
5
29
  }
@@ -1,8 +1,112 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ListBaseToken = void 0;
4
+ const debug_1 = require("../../util/debug");
5
+ const text_1 = require("../../lib/text");
6
+ const index_1 = require("../index");
4
7
  const base_1 = require("./base");
5
8
  /** `;:*#` */
6
9
  class ListBaseToken extends base_1.NowikiBaseToken {
10
+ /** whether to contain `;` / 是否包含`;` */
11
+ get dt() {
12
+ PRINT: return this.innerText.includes(';');
13
+ }
14
+ /**
15
+ * number of indentation
16
+ *
17
+ * 缩进数
18
+ * @since v1.16.5
19
+ */
20
+ get indent() {
21
+ PRINT: return this.innerText.split(':').length - 1;
22
+ }
23
+ /**
24
+ * Get the range of the list
25
+ *
26
+ * 获取列表行的范围
27
+ * @throws `Error` if the token has no parent node
28
+ */
29
+ getRange() {
30
+ PRINT: {
31
+ const { parentNode } = this;
32
+ if (!parentNode) {
33
+ throw new Error('There is no parent node!');
34
+ }
35
+ let { nextSibling } = this;
36
+ if (nextSibling?.is('list-range')) {
37
+ return nextSibling;
38
+ }
39
+ const { dt, type } = this;
40
+ let nDt = 0;
41
+ while (nextSibling && (nextSibling.type !== 'text' || !nextSibling.data.includes('\n'))) {
42
+ if (type === 'list') {
43
+ if (nextSibling.is('dd')) {
44
+ nDt -= nextSibling.indent;
45
+ if (dt && nDt < 0) {
46
+ break;
47
+ }
48
+ }
49
+ else if (nextSibling.is('list') && nextSibling.dt) {
50
+ nDt++;
51
+ }
52
+ }
53
+ else if (nextSibling.is('dd')) {
54
+ break;
55
+ }
56
+ ({ nextSibling } = nextSibling);
57
+ }
58
+ let start, end, contents;
59
+ if (nextSibling && nextSibling.type !== 'text') {
60
+ const { childNodes } = parentNode;
61
+ start = childNodes.indexOf(this) + 1;
62
+ end = childNodes.indexOf(nextSibling);
63
+ contents = childNodes.slice(start, end);
64
+ }
65
+ else {
66
+ if (type === 'list') {
67
+ while (this.previousSibling?.is('list')) {
68
+ this.setText(this.previousSibling.innerText + this.innerText);
69
+ this.previousSibling.removeInternal();
70
+ }
71
+ for (let i = 0; i < nDt; i++) {
72
+ const token = this.nextSibling;
73
+ this.setText(this.innerText + token.innerText);
74
+ token.removeInternal();
75
+ }
76
+ if (parentNode.is('list-range')) {
77
+ parentNode.previousSibling.setText(parentNode.previousSibling.innerText + this.innerText);
78
+ this.removeInternal();
79
+ return parentNode;
80
+ }
81
+ }
82
+ const { childNodes } = parentNode;
83
+ start = childNodes.indexOf(this) + 1;
84
+ if (nextSibling) {
85
+ const { data } = nextSibling, offset = data.indexOf('\n'), text = new text_1.AstText(data.slice(0, offset));
86
+ end = childNodes.indexOf(nextSibling);
87
+ contents = childNodes.slice(start, end);
88
+ const last = contents.at(-1);
89
+ if (last) {
90
+ last.setAttribute('nextSibling', text);
91
+ text.setAttribute('previousSibling', last);
92
+ }
93
+ contents.push(text);
94
+ nextSibling.setAttribute('data', data.slice(offset));
95
+ }
96
+ else {
97
+ end = childNodes.length;
98
+ contents = childNodes.slice(start);
99
+ }
100
+ }
101
+ const token = debug_1.Shadow.run(() => {
102
+ const t = new index_1.Token(undefined, this.getAttribute('config'));
103
+ t.type = 'list-range';
104
+ return t;
105
+ });
106
+ token.concat(contents); // eslint-disable-line unicorn/no-unused-builtin-method-return
107
+ (0, debug_1.setChildNodes)(parentNode, start, end - start, [token]);
108
+ return token;
109
+ }
110
+ }
7
111
  }
8
112
  exports.ListBaseToken = ListBaseToken;
@@ -6,7 +6,7 @@ import type { ParamTagToken, FuncTagToken } from '../internal';
6
6
  * parameter of certain extension tags
7
7
  *
8
8
  * 某些扩展标签的参数
9
- * @classdesc `{childNodes: [AtomToken] | [AtomToken, AtomToken]}`
9
+ * @classdesc `{childNodes: [AtomToken, AtomToken?]}`
10
10
  */
11
11
  export declare abstract class ParamLineToken extends Token {
12
12
  readonly name: string;
@@ -49,7 +49,7 @@ const skipTypes = new Set(['comment', 'include', 'noinclude']);
49
49
  * parameter of certain extension tags
50
50
  *
51
51
  * 某些扩展标签的参数
52
- * @classdesc `{childNodes: [AtomToken] | [AtomToken, AtomToken]}`
52
+ * @classdesc `{childNodes: [AtomToken, AtomToken?]}`
53
53
  */
54
54
  let ParamLineToken = (() => {
55
55
  let _classDecorators = [(0, gapped_1.gapped)()];
package/dist/src/pre.d.ts CHANGED
@@ -2,15 +2,16 @@ import { Token } from './index';
2
2
  import { NoincludeToken } from './nowiki/noinclude';
3
3
  import type { Config, LintError } from '../base';
4
4
  import type { AstText, AttributesToken, ExtToken, ConverterToken } from '../internal';
5
+ declare type Child = NoincludeToken | ConverterToken;
5
6
  /**
6
7
  * `<pre>`
7
8
  * @classdesc `{childNodes: (AstText|NoincludeToken|ConverterToken)[]}`
8
9
  */
9
10
  export declare abstract class PreToken extends Token {
10
11
  readonly name: 'pre';
11
- readonly childNodes: readonly (NoincludeToken | ConverterToken | AstText)[];
12
- abstract get firstChild(): NoincludeToken | ConverterToken | AstText | undefined;
13
- abstract get lastChild(): NoincludeToken | ConverterToken | AstText | undefined;
12
+ readonly childNodes: readonly (Child | AstText)[];
13
+ abstract get firstChild(): Child | AstText | undefined;
14
+ abstract get lastChild(): Child | AstText | undefined;
14
15
  abstract get nextSibling(): undefined;
15
16
  abstract get previousSibling(): AttributesToken | undefined;
16
17
  abstract get parentNode(): ExtToken | undefined;
@@ -18,3 +19,4 @@ export declare abstract class PreToken extends Token {
18
19
  /** @class */
19
20
  constructor(wikitext?: string, config?: Config, accum?: Token[]);
20
21
  }
22
+ export {};
@@ -6,7 +6,7 @@ import type { Config, LintError } from '../base';
6
6
  * redirect
7
7
  *
8
8
  * 重定向
9
- * @classdesc `{childNodes: [SyntaxToken, LinkToken]}`
9
+ * @classdesc `{childNodes: [SyntaxToken, RedirectTargetToken]}`
10
10
  */
11
11
  export declare abstract class RedirectToken extends Token {
12
12
  #private;
@@ -44,7 +44,7 @@ const redirectTarget_1 = require("./link/redirectTarget");
44
44
  * redirect
45
45
  *
46
46
  * 重定向
47
- * @classdesc `{childNodes: [SyntaxToken, LinkToken]}`
47
+ * @classdesc `{childNodes: [SyntaxToken, RedirectTargetToken]}`
48
48
  */
49
49
  let RedirectToken = (() => {
50
50
  let _classDecorators = [(0, hidden_1.hiddenToken)(false, false), noEscape_1.noEscape];
@@ -6,7 +6,7 @@ import type { Token, CharinsertToken, AstText } from '../../internal';
6
6
  * lines in `<charinsert>`
7
7
  *
8
8
  * `<charinsert>` 的行
9
- * @classdesc `{childNodes: (AstText | ExtToken)[]}`
9
+ * @classdesc `{childNodes: (AstText|ExtToken)[]}`
10
10
  */
11
11
  export declare abstract class CharinsertLineToken extends SingleLineToken {
12
12
  readonly childNodes: readonly (AstText | ExtToken)[];
@@ -13,7 +13,7 @@ const ext_1 = require("../tagPair/ext");
13
13
  * lines in `<charinsert>`
14
14
  *
15
15
  * `<charinsert>` 的行
16
- * @classdesc `{childNodes: (AstText | ExtToken)[]}`
16
+ * @classdesc `{childNodes: (AstText|ExtToken)[]}`
17
17
  */
18
18
  class CharinsertLineToken extends index_2.SingleLineToken {
19
19
  get type() {
@@ -6,13 +6,13 @@ import type { TableCoords } from './trBase';
6
6
  export type TableTokens = TableToken | TrToken | TdToken;
7
7
  /** @extends {Array<TableCoords[]>} */
8
8
  export declare class Layout extends Array<TableCoords[]> {
9
- abstract static from(arr: TableCoords[][]): Layout;
9
+ static from: (arr: TableCoords[][]) => Layout;
10
10
  }
11
11
  /**
12
12
  * table
13
13
  *
14
14
  * 表格
15
- * @classdesc `{childNodes: [SyntaxToken, AttributesToken, ?Token, ...TdToken[], ...TrToken[], ?SyntaxToken]}`
15
+ * @classdesc `{childNodes: [SyntaxToken, AttributesToken, ...TdToken[], ...TrToken[], SyntaxToken?]}`
16
16
  */
17
17
  export declare abstract class TableToken extends TrBaseToken {
18
18
  readonly childNodes: readonly [SyntaxToken, AttributesToken, ...(TdToken | TrToken)[], SyntaxToken] | readonly [SyntaxToken, AttributesToken, ...(TdToken | TrToken)[]];
@@ -53,7 +53,7 @@ exports.Layout = Layout;
53
53
  * table
54
54
  *
55
55
  * 表格
56
- * @classdesc `{childNodes: [SyntaxToken, AttributesToken, ?Token, ...TdToken[], ...TrToken[], ?SyntaxToken]}`
56
+ * @classdesc `{childNodes: [SyntaxToken, AttributesToken, ...TdToken[], ...TrToken[], SyntaxToken?]}`
57
57
  */
58
58
  let TableToken = (() => {
59
59
  let _classSuper = trBase_1.TrBaseToken;
@@ -5,7 +5,7 @@ import type { Token, TdToken, TableToken, SyntaxToken, AttributesToken } from '.
5
5
  * table row that contains the newline at the beginning but not at the end
6
6
  *
7
7
  * 表格行,含开头的换行,不含结尾的换行
8
- * @classdesc `{childNodes: [SyntaxToken, AttributesToken, ?Token, ...TdToken[]]}`
8
+ * @classdesc `{childNodes: [SyntaxToken, AttributesToken, ...TdToken[]]}`
9
9
  */
10
10
  export declare abstract class TrToken extends TrBaseToken {
11
11
  readonly childNodes: readonly [SyntaxToken, AttributesToken, ...TdToken[]];
@@ -6,7 +6,7 @@ const trBase_1 = require("./trBase");
6
6
  * table row that contains the newline at the beginning but not at the end
7
7
  *
8
8
  * 表格行,含开头的换行,不含结尾的换行
9
- * @classdesc `{childNodes: [SyntaxToken, AttributesToken, ?Token, ...TdToken[]]}`
9
+ * @classdesc `{childNodes: [SyntaxToken, AttributesToken, ...TdToken[]]}`
10
10
  */
11
11
  class TrToken extends trBase_1.TrBaseToken {
12
12
  get type() {
@@ -1,17 +1,18 @@
1
1
  import { Token } from '../index';
2
2
  import type { Config } from '../../base';
3
3
  import type { AttributesToken, SyntaxToken } from '../../internal';
4
+ declare type Child = AttributesToken | SyntaxToken;
4
5
  /**
5
6
  * HTML tag
6
7
  *
7
8
  * HTML标签
8
- * @classdesc `{childNodes: [AttributesToken]}`
9
+ * @classdesc `{childNodes: [AttributesToken|SyntaxToken]}`
9
10
  */
10
11
  export declare abstract class TagToken extends Token {
11
12
  #private;
12
- readonly childNodes: readonly [AttributesToken | SyntaxToken];
13
- abstract get firstChild(): AttributesToken | SyntaxToken;
14
- abstract get lastChild(): AttributesToken | SyntaxToken;
13
+ readonly childNodes: readonly [Child];
14
+ abstract get firstChild(): Child;
15
+ abstract get lastChild(): Child;
15
16
  abstract get type(): 'html' | 'tvar';
16
17
  abstract get selfClosing(): boolean | undefined;
17
18
  /** whether to be a closing tag / 是否是闭合标签 */
@@ -21,7 +22,7 @@ export declare abstract class TagToken extends Token {
21
22
  * @param attr 标签属性
22
23
  * @param closing 是否闭合
23
24
  */
24
- constructor(tag: string, attr: AttributesToken | SyntaxToken, closing: boolean, config?: Config, accum?: Token[]);
25
+ constructor(tag: string, attr: Child, closing: boolean, config?: Config, accum?: Token[]);
25
26
  /**
26
27
  * Find the matching tag
27
28
  *
@@ -29,3 +30,4 @@ export declare abstract class TagToken extends Token {
29
30
  */
30
31
  findMatchingTag(): this | undefined;
31
32
  }
33
+ export {};
@@ -8,7 +8,7 @@ const index_1 = require("../index");
8
8
  * HTML tag
9
9
  *
10
10
  * HTML标签
11
- * @classdesc `{childNodes: [AttributesToken]}`
11
+ * @classdesc `{childNodes: [AttributesToken|SyntaxToken]}`
12
12
  */
13
13
  class TagToken extends index_1.Token {
14
14
  #closing;
@@ -47,7 +47,6 @@ class TagToken extends index_1.Token {
47
47
  findMatchingTag() {
48
48
  LINT: return (0, lint_1.cache)(this.#match, () => {
49
49
  const { type, name, closing, selfClosing, } = this;
50
- // eslint-disable-next-line prefer-const
51
50
  let { parentNode } = this, isVoid = false, isFlexible = false;
52
51
  if (type === 'html') {
53
52
  const [, flexibleTags, voidTags] = this.getAttribute('config').html;
@@ -63,9 +62,15 @@ class TagToken extends index_1.Token {
63
62
  }
64
63
  const { childNodes } = parentNode, i = childNodes.indexOf(this), siblings = closing ? childNodes.slice(0, i) : childNodes.slice(i + 1).reverse(), stack = [this], { rev } = debug_1.Shadow;
65
64
  let cur = siblings.pop(), until;
66
- while (cur) {
67
- // eslint-disable-next-line no-empty, @typescript-eslint/no-unnecessary-condition
65
+ while (cur || parentNode.is('list-range') && parentNode.parentNode) {
68
66
  if (!cur) {
67
+ const parent = parentNode.parentNode, ch = parent.childNodes, j = ch.indexOf(parentNode);
68
+ Array.prototype.push.apply(siblings, closing ? ch.slice(0, j) : ch.slice(j + 1).reverse());
69
+ parentNode = parent;
70
+ }
71
+ else if (cur.is('list-range')) {
72
+ const ch = cur.childNodes;
73
+ Array.prototype.push.apply(siblings, closing ? ch : [...ch].reverse());
69
74
  }
70
75
  else if (until) {
71
76
  if (cur === until) {
@@ -223,7 +223,7 @@ let ExtToken = (() => {
223
223
  LINT: {
224
224
  const refName = this.getAttr('name'), text = this.innerText?.trim();
225
225
  let msg = '';
226
- if (this.closest('ext#references')) {
226
+ if (this.closest('ext-inner#references')) {
227
227
  if (!refName) {
228
228
  msg = 'no-named-in-references';
229
229
  }
@@ -8,7 +8,7 @@ export declare const invalidTemplateMsg = "Invalid template name";
8
8
  * template or magic word
9
9
  *
10
10
  * 模板或魔术字
11
- * @classdesc `{childNodes: [AtomToken|SyntaxToken, ...AtomToken[], ...ParameterToken[]]}`
11
+ * @classdesc `{childNodes: [AtomToken|SyntaxToken, ...ParameterToken[]]}`
12
12
  */
13
13
  export declare abstract class TranscludeToken extends Token {
14
14
  #private;
@@ -55,7 +55,7 @@ const sortArgs = /** @ignore */ ({ childNodes }, args) => [...args].sort((a, b)
55
55
  * template or magic word
56
56
  *
57
57
  * 模板或魔术字
58
- * @classdesc `{childNodes: [AtomToken|SyntaxToken, ...AtomToken[], ...ParameterToken[]]}`
58
+ * @classdesc `{childNodes: [AtomToken|SyntaxToken, ...ParameterToken[]]}`
59
59
  */
60
60
  let TranscludeToken = (() => {
61
61
  let _classDecorators = [noEscape_1.noEscape, (0, gapped_1.gapped)()];
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.mixin = exports.emptyArray = exports.getMagicWordInfo = exports.setChildNodes = exports.isLink = exports.isRowEnd = exports.Shadow = void 0;
3
+ exports.mixin = exports.emptyArray = exports.getMagicWordInfo = exports.setChildNodes = exports.isLink = exports.isRowEnd = exports.isIsolated = exports.Shadow = void 0;
4
4
  exports.isToken = isToken;
5
5
  exports.Shadow = {
6
6
  running: false,
@@ -37,6 +37,12 @@ exports.Shadow = {
37
37
  function isToken(type) {
38
38
  return (node) => node.type === type;
39
39
  }
40
+ /**
41
+ * 扩展节点是否提供独立解析环境
42
+ * @param name 扩展节点名称
43
+ */
44
+ const isIsolated = (name) => name === 'poem' || name === 'indicator';
45
+ exports.isIsolated = isIsolated;
40
46
  /**
41
47
  * 是否是行尾
42
48
  * @param token 节点
package/i18n/en.json CHANGED
@@ -17,6 +17,7 @@
17
17
  "duplicate-ext-parameter": "duplicate parameter of <$1>",
18
18
  "duplicate-id": "duplicate HTML id",
19
19
  "duplicate-image-parameter": "duplicate image $1 parameter",
20
+ "duplicate-name": "duplicate name of <indicator>",
20
21
  "duplicate-parameter": "duplicate template parameter",
21
22
  "encode": null,
22
23
  "escape": null,
package/i18n/zh-hans.json CHANGED
@@ -17,6 +17,7 @@
17
17
  "duplicate-ext-parameter": "重复的<$1>参数",
18
18
  "duplicate-id": "重复的HTML id属性",
19
19
  "duplicate-image-parameter": "重复的图像$1参数",
20
+ "duplicate-name": "重复的<indicator> name属性",
20
21
  "duplicate-parameter": "重复的模板参数",
21
22
  "encode": "编码",
22
23
  "escape": "转义",
package/i18n/zh-hant.json CHANGED
@@ -17,6 +17,7 @@
17
17
  "duplicate-ext-parameter": "重複的<$1>參數",
18
18
  "duplicate-id": "重複的HTML id屬性",
19
19
  "duplicate-image-parameter": "重複的圖片$1參數",
20
+ "duplicate-name": "重複的<indicator> name屬性",
20
21
  "duplicate-parameter": "重複的模板參數",
21
22
  "encode": "編碼",
22
23
  "escape": "跳脫",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wikilint",
3
- "version": "2.48.1",
3
+ "version": "3.0.0",
4
4
  "description": "A Node.js linter for MediaWiki markup",
5
5
  "keywords": [
6
6
  "mediawiki",
@@ -103,10 +103,10 @@
103
103
  "@bhsd/stylelint-util": "^1.1.0",
104
104
  "culori": "^4.0.2",
105
105
  "entities": "^8.1.0",
106
- "vscode-languageserver-types": "^3.18.4"
106
+ "vscode-languageserver-types": "^3.18.5"
107
107
  },
108
108
  "devDependencies": {
109
- "@bhsd/code-standard": "^5.0.0",
109
+ "@bhsd/code-standard": "^5.1.0",
110
110
  "@bhsd/nodejs": "^1.2.1",
111
111
  "@bhsd/test-util": "^3.3.0",
112
112
  "ajv": "^8.20.0",
@@ -114,16 +114,16 @@
114
114
  "c8": "^12.0.0",
115
115
  "diff2html-cli": "^5.2.15",
116
116
  "esbuild": "^0.28.2",
117
- "eslint": "^10.13.0",
117
+ "eslint": "^10.14.0",
118
118
  "mathoid-texvcjs": "^0.6.0",
119
119
  "stylelint": "^17.16.0",
120
120
  "typescript": "^6.0.3",
121
121
  "vscode-css-languageservice": "^6.3.10",
122
122
  "vscode-html-languageservice": "^5.6.2",
123
123
  "vscode-json-languageservice": "^5.7.2",
124
- "vscode-languageserver-textdocument": "^1.0.15"
124
+ "vscode-languageserver-textdocument": "^1.0.16"
125
125
  },
126
126
  "engines": {
127
- "node": "^20.19.0 || ^22.13.0 || >=24.11.0"
127
+ "node": "^22.13.0 || >=24.11.0"
128
128
  }
129
129
  }