wikilint 2.16.4 → 2.16.6

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 (121) hide show
  1. package/dist/base.d.mts +84 -27
  2. package/dist/base.d.ts +84 -27
  3. package/dist/bin/cli.js +2 -1
  4. package/dist/index.d.ts +8 -4
  5. package/dist/index.js +55 -11
  6. package/dist/lib/element.d.ts +42 -16
  7. package/dist/lib/element.js +45 -17
  8. package/dist/lib/lsp.d.ts +64 -35
  9. package/dist/lib/lsp.js +208 -159
  10. package/dist/lib/node.d.ts +50 -18
  11. package/dist/lib/node.js +66 -27
  12. package/dist/lib/text.d.ts +8 -2
  13. package/dist/lib/text.js +10 -3
  14. package/dist/lib/title.d.ts +19 -10
  15. package/dist/lib/title.js +28 -22
  16. package/dist/mixin/attributesParent.d.ts +4 -4
  17. package/dist/mixin/attributesParent.js +0 -2
  18. package/dist/mixin/hidden.d.ts +0 -2
  19. package/dist/mixin/hidden.js +0 -2
  20. package/dist/parser/braces.js +52 -20
  21. package/dist/parser/commentAndExt.js +17 -4
  22. package/dist/parser/links.js +8 -7
  23. package/dist/parser/list.js +3 -1
  24. package/dist/parser/quotes.js +2 -1
  25. package/dist/parser/redirect.js +4 -1
  26. package/dist/src/arg.d.ts +4 -2
  27. package/dist/src/arg.js +8 -4
  28. package/dist/src/atom.d.ts +5 -1
  29. package/dist/src/atom.js +5 -1
  30. package/dist/src/attribute.d.ts +9 -3
  31. package/dist/src/attribute.js +9 -3
  32. package/dist/src/attributes.d.ts +12 -4
  33. package/dist/src/attributes.js +12 -4
  34. package/dist/src/converter.d.ts +3 -1
  35. package/dist/src/converter.js +8 -5
  36. package/dist/src/converterFlags.d.ts +13 -3
  37. package/dist/src/converterFlags.js +13 -3
  38. package/dist/src/converterRule.d.ts +3 -1
  39. package/dist/src/converterRule.js +3 -1
  40. package/dist/src/extLink.d.ts +2 -0
  41. package/dist/src/extLink.js +2 -0
  42. package/dist/src/gallery.d.ts +3 -1
  43. package/dist/src/gallery.js +7 -5
  44. package/dist/src/heading.d.ts +3 -1
  45. package/dist/src/heading.js +4 -2
  46. package/dist/src/hidden.d.ts +5 -1
  47. package/dist/src/hidden.js +5 -1
  48. package/dist/src/html.d.ts +6 -2
  49. package/dist/src/html.js +6 -2
  50. package/dist/src/imageParameter.d.ts +11 -3
  51. package/dist/src/imageParameter.js +12 -4
  52. package/dist/src/imagemap.d.ts +1 -1
  53. package/dist/src/imagemap.js +5 -4
  54. package/dist/src/imagemapLink.d.ts +2 -0
  55. package/dist/src/imagemapLink.js +2 -0
  56. package/dist/src/index.d.ts +5 -3
  57. package/dist/src/index.js +28 -18
  58. package/dist/src/link/base.d.ts +4 -2
  59. package/dist/src/link/base.js +12 -6
  60. package/dist/src/link/category.d.ts +2 -0
  61. package/dist/src/link/category.js +2 -0
  62. package/dist/src/link/file.d.ts +17 -7
  63. package/dist/src/link/file.js +28 -14
  64. package/dist/src/link/galleryImage.d.ts +5 -1
  65. package/dist/src/link/galleryImage.js +9 -5
  66. package/dist/src/link/index.d.ts +2 -0
  67. package/dist/src/link/index.js +2 -0
  68. package/dist/src/link/redirectTarget.d.ts +2 -1
  69. package/dist/src/link/redirectTarget.js +4 -2
  70. package/dist/src/magicLink.d.ts +8 -4
  71. package/dist/src/magicLink.js +16 -9
  72. package/dist/src/nested.d.ts +3 -1
  73. package/dist/src/nested.js +7 -4
  74. package/dist/src/nowiki/base.d.ts +3 -1
  75. package/dist/src/nowiki/base.js +3 -1
  76. package/dist/src/nowiki/comment.d.ts +5 -1
  77. package/dist/src/nowiki/comment.js +5 -1
  78. package/dist/src/nowiki/doubleUnderscore.d.ts +5 -1
  79. package/dist/src/nowiki/doubleUnderscore.js +5 -1
  80. package/dist/src/nowiki/index.d.ts +5 -1
  81. package/dist/src/nowiki/index.js +5 -1
  82. package/dist/src/nowiki/list.d.ts +5 -1
  83. package/dist/src/nowiki/list.js +5 -1
  84. package/dist/src/nowiki/noinclude.d.ts +5 -1
  85. package/dist/src/nowiki/noinclude.js +5 -1
  86. package/dist/src/nowiki/quote.d.ts +5 -1
  87. package/dist/src/nowiki/quote.js +5 -1
  88. package/dist/src/onlyinclude.d.ts +3 -1
  89. package/dist/src/onlyinclude.js +3 -1
  90. package/dist/src/paramTag/index.d.ts +1 -1
  91. package/dist/src/paramTag/index.js +1 -1
  92. package/dist/src/parameter.d.ts +3 -1
  93. package/dist/src/parameter.js +3 -1
  94. package/dist/src/pre.d.ts +1 -1
  95. package/dist/src/pre.js +1 -1
  96. package/dist/src/redirect.d.ts +2 -0
  97. package/dist/src/redirect.js +2 -0
  98. package/dist/src/syntax.d.ts +5 -1
  99. package/dist/src/syntax.js +5 -1
  100. package/dist/src/table/base.js +3 -1
  101. package/dist/src/table/index.d.ts +20 -15
  102. package/dist/src/table/index.js +22 -23
  103. package/dist/src/table/td.d.ts +9 -3
  104. package/dist/src/table/td.js +9 -3
  105. package/dist/src/table/tr.d.ts +3 -1
  106. package/dist/src/table/tr.js +4 -2
  107. package/dist/src/table/trBase.d.ts +9 -9
  108. package/dist/src/table/trBase.js +13 -18
  109. package/dist/src/tagPair/ext.d.ts +3 -1
  110. package/dist/src/tagPair/ext.js +3 -1
  111. package/dist/src/tagPair/include.d.ts +2 -0
  112. package/dist/src/tagPair/include.js +2 -0
  113. package/dist/src/tagPair/index.d.ts +6 -2
  114. package/dist/src/tagPair/index.js +6 -2
  115. package/dist/src/transclude.d.ts +34 -10
  116. package/dist/src/transclude.js +47 -17
  117. package/dist/util/debug.js +2 -16
  118. package/dist/util/string.js +2 -0
  119. package/i18n/zh-hans.json +1 -1
  120. package/i18n/zh-hant.json +1 -1
  121. package/package.json +2 -2
@@ -5,69 +5,95 @@ export interface CaretPosition {
5
5
  readonly offsetNode: AstNodes;
6
6
  readonly offset: number;
7
7
  }
8
- /** 类似HTMLElement */
8
+ /**
9
+ * HTMLElement-like
10
+ *
11
+ * 类似HTMLElement
12
+ */
9
13
  export declare abstract class AstElement extends AstNode {
10
14
  #private;
11
15
  readonly name?: string;
12
16
  readonly data: undefined;
13
- /** 子节点总数 */
17
+ /** number of child nodes / 子节点总数 */
14
18
  get length(): number;
15
19
  /**
20
+ * Remove a child node
21
+ *
16
22
  * 移除子节点
17
- * @param i 移除位置
23
+ * @param i position of the child node / 移除位置
18
24
  */
19
25
  removeAt(i: number): AstNodes;
20
26
  /**
27
+ * Insert a child node
28
+ *
21
29
  * 插入子节点
22
- * @param node 待插入的子节点
23
- * @param i 插入位置
30
+ * @param node node to be inserted / 待插入的子节点
31
+ * @param i position to be inserted at / 插入位置
24
32
  */
25
33
  insertAt<T extends AstNodes>(node: T, i?: number): T;
26
34
  /**
27
- * 最近的祖先节点
35
+ * Get the closest ancestor node that matches the selector
36
+ *
37
+ * 最近的符合选择器的祖先节点
28
38
  * @param selector 选择器
29
39
  */
30
40
  closest<T = Token>(selector: string): T | undefined;
31
41
  /**
42
+ * Get the first descendant that matches the selector
43
+ *
32
44
  * 符合选择器的第一个后代节点
33
45
  * @param selector 选择器
34
46
  */
35
47
  querySelector<T = Token>(selector: string): T | undefined;
36
48
  /**
49
+ * Get all descendants that match the selector
50
+ *
37
51
  * 符合选择器的所有后代节点
38
52
  * @param selector 选择器
39
53
  */
40
54
  querySelectorAll<T = Token>(selector: string): T[];
41
55
  /**
56
+ * Insert a batch of child nodes at the end
57
+ *
42
58
  * 在末尾批量插入子节点
43
- * @param elements 插入节点
59
+ * @param elements nodes to be inserted / 插入节点
44
60
  */
45
61
  append(...elements: (AstNodes | string)[]): void;
46
62
  /**
63
+ * Replace all child nodes
64
+ *
47
65
  * 批量替换子节点
48
- * @param elements 新的子节点
66
+ * @param elements nodes to be inserted / 新的子节点
49
67
  */
50
68
  replaceChildren(...elements: (AstNodes | string)[]): void;
51
69
  /**
70
+ * Modify the text child node
71
+ *
52
72
  * 修改文本子节点
53
- * @param str 新文本
54
- * @param i 子节点位置
73
+ * @param str new text / 新文本
74
+ * @param i position of the text child node / 子节点位置
55
75
  */
56
76
  setText(str: string, i?: number): string;
57
77
  /**
78
+ * Get the caret position from the character index
79
+ *
58
80
  * 找到给定位置
59
- * @param index 位置
81
+ * @param index character index / 位置
60
82
  */
61
83
  caretPositionFromIndex(index?: number): CaretPosition | undefined;
62
84
  /**
63
- * 找到给定位置所在的最外层节点
64
- * @param index 位置
85
+ * Get the closest ancestor element from the character index
86
+ *
87
+ * 找到给定位置所在的最内层非文本节点
88
+ * @param index character index / 位置
65
89
  */
66
90
  elementFromIndex(index?: number): Token | undefined;
67
91
  /**
68
- * 找到给定位置所在的最外层节点
69
- * @param x 列数
70
- * @param y 行数
92
+ * Get the closest ancestor element from the position
93
+ *
94
+ * 找到给定位置所在的最内层非文本节点
95
+ * @param x column number / 列数
96
+ * @param y line number / 行数
71
97
  */
72
98
  elementFromPoint(x: number, y: number): Token | undefined;
73
99
  }
@@ -5,9 +5,13 @@ const string_1 = require("../util/string");
5
5
  const debug_1 = require("../util/debug");
6
6
  const selector_1 = require("../parser/selector");
7
7
  const node_1 = require("./node");
8
- /** 类似HTMLElement */
8
+ /**
9
+ * HTMLElement-like
10
+ *
11
+ * 类似HTMLElement
12
+ */
9
13
  class AstElement extends node_1.AstNode {
10
- /** 子节点总数 */
14
+ /** number of child nodes / 子节点总数 */
11
15
  get length() {
12
16
  return this.childNodes.length;
13
17
  }
@@ -17,7 +21,7 @@ class AstElement extends node_1.AstNode {
17
21
  }
18
22
  /** @private */
19
23
  normalize() {
20
- const childNodes = [...this.childNodes];
24
+ const childNodes = this.getChildNodes();
21
25
  /**
22
26
  * 移除子节点
23
27
  * @param i 移除位置
@@ -39,23 +43,29 @@ class AstElement extends node_1.AstNode {
39
43
  this.setAttribute('childNodes', childNodes);
40
44
  }
41
45
  /**
46
+ * Remove a child node
47
+ *
42
48
  * 移除子节点
43
- * @param i 移除位置
49
+ * @param i position of the child node / 移除位置
44
50
  */
45
51
  removeAt(i) {
46
52
  return (0, debug_1.setChildNodes)(this, i, 1)[0];
47
53
  }
48
54
  /**
55
+ * Insert a child node
56
+ *
49
57
  * 插入子节点
50
- * @param node 待插入的子节点
51
- * @param i 插入位置
58
+ * @param node node to be inserted / 待插入的子节点
59
+ * @param i position to be inserted at / 插入位置
52
60
  */
53
61
  insertAt(node, i = this.length) {
54
62
  (0, debug_1.setChildNodes)(this, i, 0, [node]);
55
63
  return node;
56
64
  }
57
65
  /**
58
- * 最近的祖先节点
66
+ * Get the closest ancestor node that matches the selector
67
+ *
68
+ * 最近的符合选择器的祖先节点
59
69
  * @param selector 选择器
60
70
  */
61
71
  closest(selector) {
@@ -89,6 +99,8 @@ class AstElement extends node_1.AstNode {
89
99
  return undefined;
90
100
  }
91
101
  /**
102
+ * Get the first descendant that matches the selector
103
+ *
92
104
  * 符合选择器的第一个后代节点
93
105
  * @param selector 选择器
94
106
  */
@@ -114,6 +126,8 @@ class AstElement extends node_1.AstNode {
114
126
  return descendants;
115
127
  }
116
128
  /**
129
+ * Get all descendants that match the selector
130
+ *
117
131
  * 符合选择器的所有后代节点
118
132
  * @param selector 选择器
119
133
  */
@@ -122,8 +136,10 @@ class AstElement extends node_1.AstNode {
122
136
  return this.#getElementsBy(condition);
123
137
  }
124
138
  /**
139
+ * Insert a batch of child nodes at the end
140
+ *
125
141
  * 在末尾批量插入子节点
126
- * @param elements 插入节点
142
+ * @param elements nodes to be inserted / 插入节点
127
143
  */
128
144
  append(...elements) {
129
145
  for (const element of elements) {
@@ -131,8 +147,10 @@ class AstElement extends node_1.AstNode {
131
147
  }
132
148
  }
133
149
  /**
150
+ * Replace all child nodes
151
+ *
134
152
  * 批量替换子节点
135
- * @param elements 新的子节点
153
+ * @param elements nodes to be inserted / 新的子节点
136
154
  */
137
155
  replaceChildren(...elements) {
138
156
  for (let i = this.length - 1; i >= 0; i--) {
@@ -141,9 +159,11 @@ class AstElement extends node_1.AstNode {
141
159
  this.append(...elements);
142
160
  }
143
161
  /**
162
+ * Modify the text child node
163
+ *
144
164
  * 修改文本子节点
145
- * @param str 新文本
146
- * @param i 子节点位置
165
+ * @param str new text / 新文本
166
+ * @param i position of the text child node / 子节点位置
147
167
  */
148
168
  setText(str, i = 0) {
149
169
  i += i < 0 ? this.length : 0;
@@ -157,8 +177,10 @@ class AstElement extends node_1.AstNode {
157
177
  return this.childNodes.map(child => child.toString(skip)).join(separator);
158
178
  }
159
179
  /**
180
+ * Get the caret position from the character index
181
+ *
160
182
  * 找到给定位置
161
- * @param index 位置
183
+ * @param index character index / 位置
162
184
  */
163
185
  caretPositionFromIndex(index) {
164
186
  LSP: { // eslint-disable-line no-unused-labels
@@ -176,6 +198,7 @@ class AstElement extends node_1.AstNode {
176
198
  acc += self.getAttribute('padding');
177
199
  for (let i = 0; acc <= index && i < childNodes.length; i++) {
178
200
  const cur = childNodes[i], { nextSibling } = cur, str = cur.toString(), l = str.length;
201
+ cur.setAttribute('aIndex', acc);
179
202
  acc += l;
180
203
  // 优先选择靠前的非文本兄弟节点,但永不进入假节点
181
204
  if (acc > index
@@ -197,8 +220,10 @@ class AstElement extends node_1.AstNode {
197
220
  }
198
221
  }
199
222
  /**
200
- * 找到给定位置所在的最外层节点
201
- * @param index 位置
223
+ * Get the closest ancestor element from the character index
224
+ *
225
+ * 找到给定位置所在的最内层非文本节点
226
+ * @param index character index / 位置
202
227
  */
203
228
  elementFromIndex(index) {
204
229
  LSP: { // eslint-disable-line no-unused-labels
@@ -207,9 +232,11 @@ class AstElement extends node_1.AstNode {
207
232
  }
208
233
  }
209
234
  /**
210
- * 找到给定位置所在的最外层节点
211
- * @param x 列数
212
- * @param y 行数
235
+ * Get the closest ancestor element from the position
236
+ *
237
+ * 找到给定位置所在的最内层非文本节点
238
+ * @param x column number / 列数
239
+ * @param y line number / 行数
213
240
  */
214
241
  elementFromPoint(x, y) {
215
242
  // eslint-disable-next-line no-unused-labels
@@ -220,6 +247,7 @@ class AstElement extends node_1.AstNode {
220
247
  const errors = [];
221
248
  for (let i = 0, cur = start + this.getAttribute('padding'); i < this.length; i++) {
222
249
  const child = this.childNodes[i];
250
+ child.setAttribute('aIndex', cur);
223
251
  errors.push(...child.lint(cur, re));
224
252
  cur += child.toString().length + this.getGaps(i);
225
253
  }
package/dist/lib/lsp.d.ts CHANGED
@@ -17,90 +17,119 @@ export declare class LanguageService implements LanguageServiceBase {
17
17
  /** @implements */
18
18
  destroy(): void;
19
19
  /**
20
+ * Provide color decorators
21
+ *
20
22
  * 提供颜色指示
21
- * @param rgba 颜色解析函数
22
- * @param text 源代码
23
- * @param hsl 是否允许HSL颜色
23
+ * @param rgba color parser / 颜色解析函数
24
+ * @param text source Wikitext / 源代码
25
+ * @param hsl whether HSL colors are treated / 是否允许HSL颜色
24
26
  */
25
27
  provideDocumentColors(rgba: (s: string) => [number, number, number, number] | [], text: string, hsl?: boolean): Promise<ColorInformation[]>;
26
- /** @implements */
27
- provideColorPresentations(// eslint-disable-line @typescript-eslint/class-methods-use-this
28
- { color: { red, green, blue, alpha }, range }: ColorInformation): ColorPresentation[];
29
28
  /**
29
+ * Provide color pickers
30
+ *
31
+ * 颜色选择器
32
+ * @param color color information / 颜色信息
33
+ */
34
+ provideColorPresentations(color: ColorInformation): ColorPresentation[];
35
+ /**
36
+ * Provide auto-completion
37
+ *
30
38
  * 提供自动补全
31
- * @param text 源代码
39
+ * @param text source Wikitext / 源代码
32
40
  * @param position 位置
33
41
  */
34
42
  provideCompletionItems(text: string, position: Position): Promise<CompletionItem[] | undefined>;
35
43
  /**
36
- * 提供语法诊断
37
- * @param wikitext 源代码
38
- * @param warning 是否提供警告
44
+ * Provide grammar check
45
+ *
46
+ * 提供语法检查
47
+ * @param text source Wikitext / 源代码
48
+ * @param warning whether to include warnings / 是否包含警告
39
49
  */
40
- provideDiagnostics(wikitext: string, warning?: boolean): Promise<Diagnostic[]>;
50
+ provideDiagnostics(text: string, warning?: boolean): Promise<Diagnostic[]>;
41
51
  /**
52
+ * Provide folding ranges
53
+ *
42
54
  * 提供折叠范围
43
- * @param text 源代码
55
+ * @param text source Wikitext / 源代码
44
56
  */
45
57
  provideFoldingRanges(text: string): Promise<FoldingRange[]>;
46
58
  /**
59
+ * Provide links
60
+ *
47
61
  * 提供链接
48
- * @param text 源代码
62
+ * @param text source Wikitext / 源代码
49
63
  */
50
64
  provideLinks(text: string): Promise<DocumentLink[]>;
51
65
  /**
66
+ * Provide references
67
+ *
52
68
  * 提供引用
53
- * @param text 源代码
69
+ * @param text source Wikitext / 源代码
54
70
  * @param position 位置
55
71
  */
56
72
  provideReferences(text: string, position: Position): Promise<Omit<Location, 'uri'>[] | undefined>;
57
73
  /**
74
+ * Provide definitions
75
+ *
58
76
  * 提供定义
59
- * @param text 源代码
60
- * @param pos 位置
61
- * @param pos.line 行号
62
- * @param pos.character 列号
77
+ * @param text source Wikitext / 源代码
78
+ * @param position 位置
63
79
  */
64
- provideDefinition(text: string, { line, character }: Position): Promise<Omit<Location, 'uri'>[] | undefined>;
80
+ provideDefinition(text: string, position: Position): Promise<Omit<Location, 'uri'>[] | undefined>;
65
81
  /**
82
+ * Provide locations for renaming
83
+ *
66
84
  * 提供变量更名准备
67
- * @param text 源代码
68
- * @param pos 位置
69
- * @param pos.line 行号
70
- * @param pos.character 列号
85
+ * @param text source Wikitext / 源代码
86
+ * @param position 位置
71
87
  */
72
- resolveRenameLocation(text: string, { line, character }: Position): Promise<Range | undefined>;
88
+ resolveRenameLocation(text: string, position: Position): Promise<Range | undefined>;
73
89
  /**
90
+ * Provide rename edits
91
+ *
74
92
  * 变量更名
75
- * @param text 源代码
76
- * @param pos 位置
77
- * @param pos.line 行号
78
- * @param pos.character 列号
79
- * @param newName 新名称
93
+ * @param text source Wikitext / 源代码
94
+ * @param position 位置
95
+ * @param newName new name / 新名称
80
96
  */
81
- provideRenameEdits(text: string, { line, character }: Position, newName: string): Promise<WorkspaceEdit | undefined>;
97
+ provideRenameEdits(text: string, position: Position, newName: string): Promise<WorkspaceEdit | undefined>;
82
98
  /**
99
+ * Provide hover information
100
+ *
83
101
  * 提供悬停信息
84
- * @param text 源代码
102
+ * @param text source Wikitext / 源代码
85
103
  * @param position 位置
86
104
  */
87
105
  provideHover(text: string, position: Position): Promise<Hover | undefined>;
88
106
  /**
107
+ * Provide signature help for magic words
108
+ *
89
109
  * 提供魔术字帮助
90
- * @param text 源代码
110
+ * @param text source Wikitext / 源代码
91
111
  * @param position 位置
92
112
  */
93
113
  provideSignatureHelp(text: string, position: Position): Promise<SignatureHelp | undefined>;
94
114
  /**
115
+ * Provide CodeLens
116
+ *
95
117
  * 提供 CodeLens
96
- * @param text 源代码
118
+ * @param text source Wikitext / 源代码
97
119
  */
98
120
  provideInlayHints(text: string): Promise<InlayHint[]>;
99
- /** @implements */
121
+ /**
122
+ * Provide quick fixes
123
+ *
124
+ * 提供快速修复建议
125
+ * @param diagnostics grammar diagnostics / 语法诊断信息
126
+ */
100
127
  provideCodeAction(diagnostics: Diagnostic[]): CodeAction[];
101
128
  /**
129
+ * Provide document sections
130
+ *
102
131
  * 提供章节
103
- * @param text 源代码
132
+ * @param text source Wikitext / 源代码
104
133
  */
105
134
  provideDocumentSymbols(text: string): Promise<DocumentSymbol[]>;
106
135
  }