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.
- package/dist/base.d.mts +84 -27
- package/dist/base.d.ts +84 -27
- package/dist/bin/cli.js +2 -1
- package/dist/index.d.ts +8 -4
- package/dist/index.js +55 -11
- package/dist/lib/element.d.ts +42 -16
- package/dist/lib/element.js +45 -17
- package/dist/lib/lsp.d.ts +64 -35
- package/dist/lib/lsp.js +208 -159
- package/dist/lib/node.d.ts +50 -18
- package/dist/lib/node.js +66 -27
- package/dist/lib/text.d.ts +8 -2
- package/dist/lib/text.js +10 -3
- package/dist/lib/title.d.ts +19 -10
- package/dist/lib/title.js +28 -22
- package/dist/mixin/attributesParent.d.ts +4 -4
- package/dist/mixin/attributesParent.js +0 -2
- package/dist/mixin/hidden.d.ts +0 -2
- package/dist/mixin/hidden.js +0 -2
- package/dist/parser/braces.js +52 -20
- package/dist/parser/commentAndExt.js +17 -4
- package/dist/parser/links.js +8 -7
- package/dist/parser/list.js +3 -1
- package/dist/parser/quotes.js +2 -1
- package/dist/parser/redirect.js +4 -1
- package/dist/src/arg.d.ts +4 -2
- package/dist/src/arg.js +8 -4
- package/dist/src/atom.d.ts +5 -1
- package/dist/src/atom.js +5 -1
- package/dist/src/attribute.d.ts +9 -3
- package/dist/src/attribute.js +9 -3
- package/dist/src/attributes.d.ts +12 -4
- package/dist/src/attributes.js +12 -4
- package/dist/src/converter.d.ts +3 -1
- package/dist/src/converter.js +8 -5
- package/dist/src/converterFlags.d.ts +13 -3
- package/dist/src/converterFlags.js +13 -3
- package/dist/src/converterRule.d.ts +3 -1
- package/dist/src/converterRule.js +3 -1
- package/dist/src/extLink.d.ts +2 -0
- package/dist/src/extLink.js +2 -0
- package/dist/src/gallery.d.ts +3 -1
- package/dist/src/gallery.js +7 -5
- package/dist/src/heading.d.ts +3 -1
- package/dist/src/heading.js +4 -2
- package/dist/src/hidden.d.ts +5 -1
- package/dist/src/hidden.js +5 -1
- package/dist/src/html.d.ts +6 -2
- package/dist/src/html.js +6 -2
- package/dist/src/imageParameter.d.ts +11 -3
- package/dist/src/imageParameter.js +12 -4
- package/dist/src/imagemap.d.ts +1 -1
- package/dist/src/imagemap.js +5 -4
- package/dist/src/imagemapLink.d.ts +2 -0
- package/dist/src/imagemapLink.js +2 -0
- package/dist/src/index.d.ts +5 -3
- package/dist/src/index.js +28 -18
- package/dist/src/link/base.d.ts +4 -2
- package/dist/src/link/base.js +12 -6
- package/dist/src/link/category.d.ts +2 -0
- package/dist/src/link/category.js +2 -0
- package/dist/src/link/file.d.ts +17 -7
- package/dist/src/link/file.js +28 -14
- package/dist/src/link/galleryImage.d.ts +5 -1
- package/dist/src/link/galleryImage.js +9 -5
- package/dist/src/link/index.d.ts +2 -0
- package/dist/src/link/index.js +2 -0
- package/dist/src/link/redirectTarget.d.ts +2 -1
- package/dist/src/link/redirectTarget.js +4 -2
- package/dist/src/magicLink.d.ts +8 -4
- package/dist/src/magicLink.js +16 -9
- package/dist/src/nested.d.ts +3 -1
- package/dist/src/nested.js +7 -4
- package/dist/src/nowiki/base.d.ts +3 -1
- package/dist/src/nowiki/base.js +3 -1
- package/dist/src/nowiki/comment.d.ts +5 -1
- package/dist/src/nowiki/comment.js +5 -1
- package/dist/src/nowiki/doubleUnderscore.d.ts +5 -1
- package/dist/src/nowiki/doubleUnderscore.js +5 -1
- package/dist/src/nowiki/index.d.ts +5 -1
- package/dist/src/nowiki/index.js +5 -1
- package/dist/src/nowiki/list.d.ts +5 -1
- package/dist/src/nowiki/list.js +5 -1
- package/dist/src/nowiki/noinclude.d.ts +5 -1
- package/dist/src/nowiki/noinclude.js +5 -1
- package/dist/src/nowiki/quote.d.ts +5 -1
- package/dist/src/nowiki/quote.js +5 -1
- package/dist/src/onlyinclude.d.ts +3 -1
- package/dist/src/onlyinclude.js +3 -1
- package/dist/src/paramTag/index.d.ts +1 -1
- package/dist/src/paramTag/index.js +1 -1
- package/dist/src/parameter.d.ts +3 -1
- package/dist/src/parameter.js +3 -1
- package/dist/src/pre.d.ts +1 -1
- package/dist/src/pre.js +1 -1
- package/dist/src/redirect.d.ts +2 -0
- package/dist/src/redirect.js +2 -0
- package/dist/src/syntax.d.ts +5 -1
- package/dist/src/syntax.js +5 -1
- package/dist/src/table/base.js +3 -1
- package/dist/src/table/index.d.ts +20 -15
- package/dist/src/table/index.js +22 -23
- package/dist/src/table/td.d.ts +9 -3
- package/dist/src/table/td.js +9 -3
- package/dist/src/table/tr.d.ts +3 -1
- package/dist/src/table/tr.js +4 -2
- package/dist/src/table/trBase.d.ts +9 -9
- package/dist/src/table/trBase.js +13 -18
- package/dist/src/tagPair/ext.d.ts +3 -1
- package/dist/src/tagPair/ext.js +3 -1
- package/dist/src/tagPair/include.d.ts +2 -0
- package/dist/src/tagPair/include.js +2 -0
- package/dist/src/tagPair/index.d.ts +6 -2
- package/dist/src/tagPair/index.js +6 -2
- package/dist/src/transclude.d.ts +34 -10
- package/dist/src/transclude.js +47 -17
- package/dist/util/debug.js +2 -16
- package/dist/util/string.js +2 -0
- package/i18n/zh-hans.json +1 -1
- package/i18n/zh-hant.json +1 -1
- package/package.json +2 -2
package/dist/base.d.mts
CHANGED
|
@@ -65,19 +65,33 @@ export interface LintError {
|
|
|
65
65
|
fix?: LintError.Fix;
|
|
66
66
|
suggestions?: LintError.Fix[];
|
|
67
67
|
}
|
|
68
|
-
/**
|
|
68
|
+
/**
|
|
69
|
+
* Node-like
|
|
70
|
+
*
|
|
71
|
+
* 类似Node
|
|
72
|
+
*/
|
|
69
73
|
export interface AstNode {
|
|
70
74
|
readonly childNodes: readonly AstNode[];
|
|
71
|
-
/**
|
|
75
|
+
/**
|
|
76
|
+
* node type
|
|
77
|
+
*
|
|
78
|
+
* 节点类型
|
|
79
|
+
*/
|
|
72
80
|
type: string;
|
|
73
81
|
toString(...args: unknown[]): string;
|
|
74
82
|
/** Linter */
|
|
75
83
|
lint(): LintError[];
|
|
76
84
|
}
|
|
77
|
-
/**
|
|
85
|
+
/**
|
|
86
|
+
* base class for all tokens
|
|
87
|
+
*
|
|
88
|
+
* 所有节点的基类
|
|
89
|
+
*/
|
|
78
90
|
interface Token extends AstNode {
|
|
79
91
|
readonly name?: string;
|
|
80
92
|
/**
|
|
93
|
+
* Get all descendants that match the selector
|
|
94
|
+
*
|
|
81
95
|
* 符合选择器的所有后代节点
|
|
82
96
|
* @param selector 选择器
|
|
83
97
|
*/
|
|
@@ -101,108 +115,151 @@ export type CompletionItem = Omit<CompletionItemBase, 'kind'> & {
|
|
|
101
115
|
kind: keyof typeof CompletionItemKind;
|
|
102
116
|
};
|
|
103
117
|
export interface LanguageService {
|
|
104
|
-
/**
|
|
118
|
+
/**
|
|
119
|
+
* Destroy the instance
|
|
120
|
+
*
|
|
121
|
+
* 销毁实例
|
|
122
|
+
*/
|
|
105
123
|
destroy(): void;
|
|
106
124
|
/**
|
|
125
|
+
* Provide color decorators
|
|
126
|
+
*
|
|
107
127
|
* 提供颜色指示
|
|
108
|
-
* @param rgba 颜色解析函数
|
|
109
|
-
* @param text 源代码
|
|
110
|
-
* @param hsl 是否允许HSL颜色
|
|
128
|
+
* @param rgba color parser / 颜色解析函数
|
|
129
|
+
* @param text source Wikitext / 源代码
|
|
130
|
+
* @param hsl whether HSL colors are treated / 是否允许HSL颜色
|
|
111
131
|
*/
|
|
112
132
|
provideDocumentColors(rgba: (s: string) => [number, number, number, number] | [], text: string, hsl?: boolean): Promise<ColorInformation[]>;
|
|
113
133
|
/**
|
|
134
|
+
* Provide color pickers
|
|
135
|
+
*
|
|
114
136
|
* 颜色选择器
|
|
115
|
-
* @param color 颜色信息
|
|
137
|
+
* @param color color information / 颜色信息
|
|
116
138
|
*/
|
|
117
139
|
provideColorPresentations(color: ColorInformation): ColorPresentation[];
|
|
118
140
|
/**
|
|
141
|
+
* Provide auto-completion
|
|
142
|
+
*
|
|
119
143
|
* 提供自动补全
|
|
120
|
-
* @param text 源代码
|
|
144
|
+
* @param text source Wikitext / 源代码
|
|
121
145
|
* @param position 位置
|
|
122
146
|
*/
|
|
123
147
|
provideCompletionItems(text: string, position: Position): Promise<CompletionItem[] | undefined>;
|
|
124
148
|
/**
|
|
149
|
+
* Provide grammar check
|
|
150
|
+
*
|
|
125
151
|
* 提供语法检查
|
|
126
|
-
* @param
|
|
152
|
+
* @param text source Wikitext / 源代码
|
|
153
|
+
* @param warning whether to include warnings / 是否包含警告
|
|
127
154
|
*/
|
|
128
|
-
provideDiagnostics(
|
|
155
|
+
provideDiagnostics(text: string, warning?: boolean): Promise<Diagnostic[]>;
|
|
129
156
|
/**
|
|
157
|
+
* Provide folding ranges
|
|
158
|
+
*
|
|
130
159
|
* 提供折叠范围
|
|
131
|
-
* @param text 源代码
|
|
160
|
+
* @param text source Wikitext / 源代码
|
|
132
161
|
*/
|
|
133
162
|
provideFoldingRanges(text: string): Promise<FoldingRange[]>;
|
|
134
163
|
/**
|
|
164
|
+
* Provide links
|
|
165
|
+
*
|
|
135
166
|
* 提供链接
|
|
136
|
-
* @param text 源代码
|
|
167
|
+
* @param text source Wikitext / 源代码
|
|
137
168
|
*/
|
|
138
169
|
provideLinks(text: string): Promise<DocumentLink[]>;
|
|
139
170
|
/**
|
|
171
|
+
* Provide references
|
|
172
|
+
*
|
|
140
173
|
* 提供引用
|
|
141
|
-
* @param text 源代码
|
|
174
|
+
* @param text source Wikitext / 源代码
|
|
142
175
|
* @param position 位置
|
|
143
176
|
*/
|
|
144
177
|
provideReferences(text: string, position: Position): Promise<Omit<Location, 'uri'>[] | undefined>;
|
|
145
178
|
/**
|
|
179
|
+
* Provide definitions
|
|
180
|
+
*
|
|
146
181
|
* 提供定义
|
|
147
|
-
* @param text 源代码
|
|
182
|
+
* @param text source Wikitext / 源代码
|
|
148
183
|
* @param position 位置
|
|
149
184
|
*/
|
|
150
185
|
provideDefinition(text: string, position: Position): Promise<Omit<Location, 'uri'>[] | undefined>;
|
|
151
186
|
/**
|
|
187
|
+
* Provide locations for renaming
|
|
188
|
+
*
|
|
152
189
|
* 提供变量更名准备
|
|
153
|
-
* @param text 源代码
|
|
190
|
+
* @param text source Wikitext / 源代码
|
|
154
191
|
* @param position 位置
|
|
155
192
|
*/
|
|
156
193
|
resolveRenameLocation(text: string, position: Position): Promise<Range | undefined>;
|
|
157
194
|
/**
|
|
195
|
+
* Provide rename edits
|
|
196
|
+
*
|
|
158
197
|
* 变量更名
|
|
159
|
-
* @param text 源代码
|
|
198
|
+
* @param text source Wikitext / 源代码
|
|
160
199
|
* @param position 位置
|
|
161
|
-
* @param newName 新名称
|
|
200
|
+
* @param newName new name / 新名称
|
|
162
201
|
*/
|
|
163
202
|
provideRenameEdits(text: string, position: Position, newName: string): Promise<WorkspaceEdit | undefined>;
|
|
164
203
|
/**
|
|
204
|
+
* Provide hover information
|
|
205
|
+
*
|
|
165
206
|
* 提供悬停信息
|
|
166
|
-
* @param text 源代码
|
|
207
|
+
* @param text source Wikitext / 源代码
|
|
167
208
|
* @param position 位置
|
|
168
209
|
*/
|
|
169
210
|
provideHover(text: string, position: Position): Promise<Hover | undefined>;
|
|
170
211
|
/**
|
|
212
|
+
* Provide signature help for magic words
|
|
213
|
+
*
|
|
171
214
|
* 提供魔术字帮助
|
|
172
|
-
* @param text 源代码
|
|
215
|
+
* @param text source Wikitext / 源代码
|
|
173
216
|
* @param position 位置
|
|
174
217
|
*/
|
|
175
218
|
provideSignatureHelp(text: string, position: Position): Promise<SignatureHelp | undefined>;
|
|
176
219
|
/**
|
|
220
|
+
* Provide CodeLens
|
|
221
|
+
*
|
|
177
222
|
* 提供 CodeLens
|
|
178
|
-
* @param text 源代码
|
|
223
|
+
* @param text source Wikitext / 源代码
|
|
179
224
|
*/
|
|
180
225
|
provideInlayHints(text: string): Promise<InlayHint[]>;
|
|
181
226
|
/**
|
|
227
|
+
* Provide quick fixes
|
|
228
|
+
*
|
|
182
229
|
* 提供快速修复建议
|
|
183
|
-
* @param diagnostics 语法诊断信息
|
|
230
|
+
* @param diagnostics grammar diagnostics / 语法诊断信息
|
|
184
231
|
*/
|
|
185
232
|
provideCodeAction(diagnostics: Diagnostic[]): CodeAction[];
|
|
186
233
|
/**
|
|
234
|
+
* Provide document sections
|
|
235
|
+
*
|
|
187
236
|
* 提供章节
|
|
188
|
-
* @param text 源代码
|
|
237
|
+
* @param text source Wikitext / 源代码
|
|
189
238
|
*/
|
|
190
239
|
provideDocumentSymbols(text: string): Promise<DocumentSymbol[]>;
|
|
191
240
|
}
|
|
192
241
|
export interface Parser {
|
|
193
242
|
config: Config | string;
|
|
194
243
|
i18n: Record<string, string> | string | undefined;
|
|
195
|
-
/**
|
|
244
|
+
/**
|
|
245
|
+
* Get the current parser configuration
|
|
246
|
+
*
|
|
247
|
+
* 获取当前的解析设置
|
|
248
|
+
*/
|
|
196
249
|
getConfig(): Config;
|
|
197
250
|
/**
|
|
251
|
+
* Parse wikitext
|
|
252
|
+
*
|
|
198
253
|
* 解析wikitext
|
|
199
|
-
* @param include 是否嵌入
|
|
200
|
-
* @param maxStage 最大解析层级
|
|
254
|
+
* @param include whether to be transcluded / 是否嵌入
|
|
255
|
+
* @param maxStage max stage for parsing / 最大解析层级
|
|
201
256
|
*/
|
|
202
257
|
parse(wikitext: string, include?: boolean, maxStage?: number | Stage | Stage[], config?: Config): Token;
|
|
203
258
|
/**
|
|
259
|
+
* Create a language server
|
|
260
|
+
*
|
|
204
261
|
* 创建语言服务
|
|
205
|
-
* @param uri 文档标识
|
|
262
|
+
* @param uri document URI / 文档标识
|
|
206
263
|
*/
|
|
207
264
|
createLanguageService(uri: object): LanguageService;
|
|
208
265
|
}
|
package/dist/base.d.ts
CHANGED
|
@@ -65,19 +65,33 @@ export interface LintError {
|
|
|
65
65
|
fix?: LintError.Fix;
|
|
66
66
|
suggestions?: LintError.Fix[];
|
|
67
67
|
}
|
|
68
|
-
/**
|
|
68
|
+
/**
|
|
69
|
+
* Node-like
|
|
70
|
+
*
|
|
71
|
+
* 类似Node
|
|
72
|
+
*/
|
|
69
73
|
export interface AstNode {
|
|
70
74
|
readonly childNodes: readonly AstNode[];
|
|
71
|
-
/**
|
|
75
|
+
/**
|
|
76
|
+
* node type
|
|
77
|
+
*
|
|
78
|
+
* 节点类型
|
|
79
|
+
*/
|
|
72
80
|
type: string;
|
|
73
81
|
toString(...args: unknown[]): string;
|
|
74
82
|
/** Linter */
|
|
75
83
|
lint(): LintError[];
|
|
76
84
|
}
|
|
77
|
-
/**
|
|
85
|
+
/**
|
|
86
|
+
* base class for all tokens
|
|
87
|
+
*
|
|
88
|
+
* 所有节点的基类
|
|
89
|
+
*/
|
|
78
90
|
interface Token extends AstNode {
|
|
79
91
|
readonly name?: string;
|
|
80
92
|
/**
|
|
93
|
+
* Get all descendants that match the selector
|
|
94
|
+
*
|
|
81
95
|
* 符合选择器的所有后代节点
|
|
82
96
|
* @param selector 选择器
|
|
83
97
|
*/
|
|
@@ -101,108 +115,151 @@ export type CompletionItem = Omit<CompletionItemBase, 'kind'> & {
|
|
|
101
115
|
kind: keyof typeof CompletionItemKind;
|
|
102
116
|
};
|
|
103
117
|
export interface LanguageService {
|
|
104
|
-
/**
|
|
118
|
+
/**
|
|
119
|
+
* Destroy the instance
|
|
120
|
+
*
|
|
121
|
+
* 销毁实例
|
|
122
|
+
*/
|
|
105
123
|
destroy(): void;
|
|
106
124
|
/**
|
|
125
|
+
* Provide color decorators
|
|
126
|
+
*
|
|
107
127
|
* 提供颜色指示
|
|
108
|
-
* @param rgba 颜色解析函数
|
|
109
|
-
* @param text 源代码
|
|
110
|
-
* @param hsl 是否允许HSL颜色
|
|
128
|
+
* @param rgba color parser / 颜色解析函数
|
|
129
|
+
* @param text source Wikitext / 源代码
|
|
130
|
+
* @param hsl whether HSL colors are treated / 是否允许HSL颜色
|
|
111
131
|
*/
|
|
112
132
|
provideDocumentColors(rgba: (s: string) => [number, number, number, number] | [], text: string, hsl?: boolean): Promise<ColorInformation[]>;
|
|
113
133
|
/**
|
|
134
|
+
* Provide color pickers
|
|
135
|
+
*
|
|
114
136
|
* 颜色选择器
|
|
115
|
-
* @param color 颜色信息
|
|
137
|
+
* @param color color information / 颜色信息
|
|
116
138
|
*/
|
|
117
139
|
provideColorPresentations(color: ColorInformation): ColorPresentation[];
|
|
118
140
|
/**
|
|
141
|
+
* Provide auto-completion
|
|
142
|
+
*
|
|
119
143
|
* 提供自动补全
|
|
120
|
-
* @param text 源代码
|
|
144
|
+
* @param text source Wikitext / 源代码
|
|
121
145
|
* @param position 位置
|
|
122
146
|
*/
|
|
123
147
|
provideCompletionItems(text: string, position: Position): Promise<CompletionItem[] | undefined>;
|
|
124
148
|
/**
|
|
149
|
+
* Provide grammar check
|
|
150
|
+
*
|
|
125
151
|
* 提供语法检查
|
|
126
|
-
* @param
|
|
152
|
+
* @param text source Wikitext / 源代码
|
|
153
|
+
* @param warning whether to include warnings / 是否包含警告
|
|
127
154
|
*/
|
|
128
|
-
provideDiagnostics(
|
|
155
|
+
provideDiagnostics(text: string, warning?: boolean): Promise<Diagnostic[]>;
|
|
129
156
|
/**
|
|
157
|
+
* Provide folding ranges
|
|
158
|
+
*
|
|
130
159
|
* 提供折叠范围
|
|
131
|
-
* @param text 源代码
|
|
160
|
+
* @param text source Wikitext / 源代码
|
|
132
161
|
*/
|
|
133
162
|
provideFoldingRanges(text: string): Promise<FoldingRange[]>;
|
|
134
163
|
/**
|
|
164
|
+
* Provide links
|
|
165
|
+
*
|
|
135
166
|
* 提供链接
|
|
136
|
-
* @param text 源代码
|
|
167
|
+
* @param text source Wikitext / 源代码
|
|
137
168
|
*/
|
|
138
169
|
provideLinks(text: string): Promise<DocumentLink[]>;
|
|
139
170
|
/**
|
|
171
|
+
* Provide references
|
|
172
|
+
*
|
|
140
173
|
* 提供引用
|
|
141
|
-
* @param text 源代码
|
|
174
|
+
* @param text source Wikitext / 源代码
|
|
142
175
|
* @param position 位置
|
|
143
176
|
*/
|
|
144
177
|
provideReferences(text: string, position: Position): Promise<Omit<Location, 'uri'>[] | undefined>;
|
|
145
178
|
/**
|
|
179
|
+
* Provide definitions
|
|
180
|
+
*
|
|
146
181
|
* 提供定义
|
|
147
|
-
* @param text 源代码
|
|
182
|
+
* @param text source Wikitext / 源代码
|
|
148
183
|
* @param position 位置
|
|
149
184
|
*/
|
|
150
185
|
provideDefinition(text: string, position: Position): Promise<Omit<Location, 'uri'>[] | undefined>;
|
|
151
186
|
/**
|
|
187
|
+
* Provide locations for renaming
|
|
188
|
+
*
|
|
152
189
|
* 提供变量更名准备
|
|
153
|
-
* @param text 源代码
|
|
190
|
+
* @param text source Wikitext / 源代码
|
|
154
191
|
* @param position 位置
|
|
155
192
|
*/
|
|
156
193
|
resolveRenameLocation(text: string, position: Position): Promise<Range | undefined>;
|
|
157
194
|
/**
|
|
195
|
+
* Provide rename edits
|
|
196
|
+
*
|
|
158
197
|
* 变量更名
|
|
159
|
-
* @param text 源代码
|
|
198
|
+
* @param text source Wikitext / 源代码
|
|
160
199
|
* @param position 位置
|
|
161
|
-
* @param newName 新名称
|
|
200
|
+
* @param newName new name / 新名称
|
|
162
201
|
*/
|
|
163
202
|
provideRenameEdits(text: string, position: Position, newName: string): Promise<WorkspaceEdit | undefined>;
|
|
164
203
|
/**
|
|
204
|
+
* Provide hover information
|
|
205
|
+
*
|
|
165
206
|
* 提供悬停信息
|
|
166
|
-
* @param text 源代码
|
|
207
|
+
* @param text source Wikitext / 源代码
|
|
167
208
|
* @param position 位置
|
|
168
209
|
*/
|
|
169
210
|
provideHover(text: string, position: Position): Promise<Hover | undefined>;
|
|
170
211
|
/**
|
|
212
|
+
* Provide signature help for magic words
|
|
213
|
+
*
|
|
171
214
|
* 提供魔术字帮助
|
|
172
|
-
* @param text 源代码
|
|
215
|
+
* @param text source Wikitext / 源代码
|
|
173
216
|
* @param position 位置
|
|
174
217
|
*/
|
|
175
218
|
provideSignatureHelp(text: string, position: Position): Promise<SignatureHelp | undefined>;
|
|
176
219
|
/**
|
|
220
|
+
* Provide CodeLens
|
|
221
|
+
*
|
|
177
222
|
* 提供 CodeLens
|
|
178
|
-
* @param text 源代码
|
|
223
|
+
* @param text source Wikitext / 源代码
|
|
179
224
|
*/
|
|
180
225
|
provideInlayHints(text: string): Promise<InlayHint[]>;
|
|
181
226
|
/**
|
|
227
|
+
* Provide quick fixes
|
|
228
|
+
*
|
|
182
229
|
* 提供快速修复建议
|
|
183
|
-
* @param diagnostics 语法诊断信息
|
|
230
|
+
* @param diagnostics grammar diagnostics / 语法诊断信息
|
|
184
231
|
*/
|
|
185
232
|
provideCodeAction(diagnostics: Diagnostic[]): CodeAction[];
|
|
186
233
|
/**
|
|
234
|
+
* Provide document sections
|
|
235
|
+
*
|
|
187
236
|
* 提供章节
|
|
188
|
-
* @param text 源代码
|
|
237
|
+
* @param text source Wikitext / 源代码
|
|
189
238
|
*/
|
|
190
239
|
provideDocumentSymbols(text: string): Promise<DocumentSymbol[]>;
|
|
191
240
|
}
|
|
192
241
|
export interface Parser {
|
|
193
242
|
config: Config | string;
|
|
194
243
|
i18n: Record<string, string> | string | undefined;
|
|
195
|
-
/**
|
|
244
|
+
/**
|
|
245
|
+
* Get the current parser configuration
|
|
246
|
+
*
|
|
247
|
+
* 获取当前的解析设置
|
|
248
|
+
*/
|
|
196
249
|
getConfig(): Config;
|
|
197
250
|
/**
|
|
251
|
+
* Parse wikitext
|
|
252
|
+
*
|
|
198
253
|
* 解析wikitext
|
|
199
|
-
* @param include 是否嵌入
|
|
200
|
-
* @param maxStage 最大解析层级
|
|
254
|
+
* @param include whether to be transcluded / 是否嵌入
|
|
255
|
+
* @param maxStage max stage for parsing / 最大解析层级
|
|
201
256
|
*/
|
|
202
257
|
parse(wikitext: string, include?: boolean, maxStage?: number | Stage | Stage[], config?: Config): Token;
|
|
203
258
|
/**
|
|
259
|
+
* Create a language server
|
|
260
|
+
*
|
|
204
261
|
* 创建语言服务
|
|
205
|
-
* @param uri 文档标识
|
|
262
|
+
* @param uri document URI / 文档标识
|
|
206
263
|
*/
|
|
207
264
|
createLanguageService(uri: object): LanguageService;
|
|
208
265
|
}
|
package/dist/bin/cli.js
CHANGED
|
@@ -16,7 +16,8 @@ Available options:
|
|
|
16
16
|
-s, --strict Exit when there is an error or warning
|
|
17
17
|
Override -q or --quiet
|
|
18
18
|
-v, --version Print package version
|
|
19
|
-
`, preset = new Set((0, fs_1.readdirSync)('./config').filter(file => file.endsWith('.json'))
|
|
19
|
+
`, preset = new Set((0, fs_1.readdirSync)('./config').filter(file => file.endsWith('.json'))
|
|
20
|
+
.map(file => file.slice(0, -5))), { argv } = process, files = [];
|
|
20
21
|
let include = false, quiet = false, strict = false, exit = false, fixing = false, nErr = 0, nWarn = 0, nFixableErr = 0, nFixableWarn = 0, option, config, lang;
|
|
21
22
|
/**
|
|
22
23
|
* throw if `-c` or `--config` option is incorrect
|
package/dist/index.d.ts
CHANGED
|
@@ -5,16 +5,20 @@ import type { Token } from './internal';
|
|
|
5
5
|
declare interface Parser extends ParserBase {
|
|
6
6
|
rules: readonly LintError.Rule[];
|
|
7
7
|
/**
|
|
8
|
+
* Normalize page title
|
|
9
|
+
*
|
|
8
10
|
* 规范化页面标题
|
|
9
|
-
* @param title 标题(含或不含命名空间前缀)
|
|
10
|
-
* @param defaultNs 命名空间
|
|
11
|
-
* @param include 是否嵌入
|
|
11
|
+
* @param title title (with or without the namespace prefix) / 标题(含或不含命名空间前缀)
|
|
12
|
+
* @param defaultNs default namespace number / 命名空间
|
|
13
|
+
* @param include whether to be transcluded / 是否嵌入
|
|
12
14
|
*/
|
|
13
15
|
normalizeTitle(title: string, defaultNs?: number, include?: boolean, config?: Config): Title;
|
|
14
16
|
parse(wikitext: string, include?: boolean, maxStage?: number | Stage | Stage[], config?: Config): Token;
|
|
15
17
|
/**
|
|
18
|
+
* Create a language server
|
|
19
|
+
*
|
|
16
20
|
* 创建语言服务
|
|
17
|
-
* @param uri 文档标识
|
|
21
|
+
* @param uri document URI / 文档标识
|
|
18
22
|
*/
|
|
19
23
|
createLanguageService(uri: object): LanguageService;
|
|
20
24
|
}
|
package/dist/index.js
CHANGED
|
@@ -1,24 +1,30 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/* eslint n/exports-style: 0 */
|
|
3
|
-
const fs = require("fs");
|
|
4
|
-
const path = require("path");
|
|
5
3
|
const base_1 = require("./base");
|
|
6
4
|
const debug_1 = require("./util/debug");
|
|
7
5
|
const constants_1 = require("./util/constants");
|
|
8
6
|
const string_1 = require("./util/string");
|
|
7
|
+
/* NOT FOR BROWSER ONLY */
|
|
8
|
+
const fs = require("fs");
|
|
9
|
+
const path = require("path");
|
|
9
10
|
const diff_1 = require("./util/diff");
|
|
11
|
+
/* NOT FOR BROWSER ONLY */
|
|
10
12
|
/**
|
|
11
13
|
* 从根路径require
|
|
12
14
|
* @param file 文件名
|
|
13
15
|
* @param dir 子路径
|
|
14
16
|
*/
|
|
15
|
-
const rootRequire = (file, dir) => require(path.isAbsolute(file)
|
|
17
|
+
const rootRequire = (file, dir) => require(path.isAbsolute(file)
|
|
18
|
+
? /* istanbul ignore next */ file
|
|
19
|
+
: path.join('..', file.includes('/') ? '' : dir, file));
|
|
20
|
+
/* NOT FOR BROWSER ONLY END */
|
|
16
21
|
const Parser = {
|
|
17
22
|
config: 'default',
|
|
18
23
|
i18n: undefined,
|
|
19
24
|
rules: base_1.rules,
|
|
20
25
|
/** @implements */
|
|
21
26
|
getConfig() {
|
|
27
|
+
/* NOT FOR BROWSER ONLY */
|
|
22
28
|
if (typeof this.config === 'string') {
|
|
23
29
|
this.config = rootRequire(this.config, 'config');
|
|
24
30
|
/* istanbul ignore if */
|
|
@@ -27,6 +33,7 @@ const Parser = {
|
|
|
27
33
|
}
|
|
28
34
|
return this.getConfig();
|
|
29
35
|
}
|
|
36
|
+
/* NOT FOR BROWSER ONLY END */
|
|
30
37
|
const { doubleUnderscore } = this.config;
|
|
31
38
|
for (let i = 0; i < 2; i++) {
|
|
32
39
|
if (doubleUnderscore.length > i + 2 && doubleUnderscore[i].length === 0) {
|
|
@@ -40,18 +47,20 @@ const Parser = {
|
|
|
40
47
|
},
|
|
41
48
|
/** @implements */
|
|
42
49
|
msg(msg, arg = '') {
|
|
50
|
+
/* NOT FOR BROWSER ONLY */
|
|
43
51
|
if (typeof this.i18n === 'string') {
|
|
44
52
|
this.i18n = rootRequire(this.i18n, 'i18n');
|
|
45
53
|
return this.msg(msg, arg);
|
|
46
54
|
}
|
|
55
|
+
/* NOT FOR BROWSER ONLY END */
|
|
47
56
|
return msg && (this.i18n?.[msg] ?? msg).replace('$1', this.msg(arg));
|
|
48
57
|
},
|
|
49
58
|
/** @implements */
|
|
50
|
-
normalizeTitle(title, defaultNs = 0, include, config = Parser.getConfig(), halfParsed, decode = false, selfLink = false) {
|
|
59
|
+
normalizeTitle(title, defaultNs = 0, include, config = Parser.getConfig(), temporary = false, halfParsed, decode = false, selfLink = false) {
|
|
51
60
|
const { Title } = require('./lib/title');
|
|
52
61
|
let titleObj;
|
|
53
62
|
if (halfParsed) {
|
|
54
|
-
titleObj = new Title(title, defaultNs, config, decode, selfLink);
|
|
63
|
+
titleObj = new Title(title, defaultNs, config, temporary, decode, selfLink);
|
|
55
64
|
}
|
|
56
65
|
else {
|
|
57
66
|
const { Token } = require('./src/index');
|
|
@@ -59,7 +68,7 @@ const Parser = {
|
|
|
59
68
|
const root = new Token(title, config);
|
|
60
69
|
root.type = 'root';
|
|
61
70
|
root.parseOnce(0, include).parseOnce();
|
|
62
|
-
const t = new Title(root.toString(), defaultNs, config, decode, selfLink);
|
|
71
|
+
const t = new Title(root.toString(), defaultNs, config, temporary, decode, selfLink);
|
|
63
72
|
for (const key of ['main', 'fragment']) {
|
|
64
73
|
const str = t[key];
|
|
65
74
|
if (str?.includes('\0')) {
|
|
@@ -90,6 +99,7 @@ const Parser = {
|
|
|
90
99
|
token.type = 'root';
|
|
91
100
|
try {
|
|
92
101
|
return token.parse(maxStage, include);
|
|
102
|
+
/* NOT FOR BROWSER ONLY */
|
|
93
103
|
}
|
|
94
104
|
catch (e) /* istanbul ignore next */ {
|
|
95
105
|
if (e instanceof Error) {
|
|
@@ -105,16 +115,50 @@ const Parser = {
|
|
|
105
115
|
}
|
|
106
116
|
throw e;
|
|
107
117
|
}
|
|
118
|
+
/* NOT FOR BROWSER ONLY END */
|
|
108
119
|
});
|
|
109
120
|
return root;
|
|
110
121
|
},
|
|
111
122
|
/** @implements */
|
|
123
|
+
async partialParse(wikitext, watch, include, config = Parser.getConfig()) {
|
|
124
|
+
const { Token } = require('./src/index');
|
|
125
|
+
const set = typeof setImmediate === 'function' ? setImmediate : /* istanbul ignore next */ setTimeout, { running } = debug_1.Shadow;
|
|
126
|
+
debug_1.Shadow.running = true;
|
|
127
|
+
const token = new Token((0, string_1.tidy)(wikitext), config);
|
|
128
|
+
token.type = 'root';
|
|
129
|
+
let i = 0;
|
|
130
|
+
await new Promise(resolve => {
|
|
131
|
+
const /** @ignore */ check = () => {
|
|
132
|
+
if (watch() === wikitext) {
|
|
133
|
+
i++;
|
|
134
|
+
set(parseOnce, 0);
|
|
135
|
+
}
|
|
136
|
+
else {
|
|
137
|
+
resolve();
|
|
138
|
+
}
|
|
139
|
+
},
|
|
140
|
+
/** @ignore */ parseOnce = () => {
|
|
141
|
+
if (i === constants_1.MAX_STAGE + 1) {
|
|
142
|
+
token.afterBuild();
|
|
143
|
+
resolve();
|
|
144
|
+
}
|
|
145
|
+
else {
|
|
146
|
+
token[i === constants_1.MAX_STAGE ? 'build' : 'parseOnce'](i, include);
|
|
147
|
+
check();
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
set(parseOnce, 0);
|
|
151
|
+
});
|
|
152
|
+
debug_1.Shadow.running = running;
|
|
153
|
+
return token;
|
|
154
|
+
},
|
|
155
|
+
/** @implements */
|
|
112
156
|
createLanguageService(uri) {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
157
|
+
LSP: { // eslint-disable-line no-unused-labels
|
|
158
|
+
const mod = require('./lib/lsp');
|
|
159
|
+
const { LanguageService, tasks } = mod;
|
|
160
|
+
return tasks.get(uri) ?? new LanguageService(uri);
|
|
161
|
+
}
|
|
118
162
|
},
|
|
119
163
|
};
|
|
120
164
|
const def = {
|