wikilint 2.15.0 → 2.16.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.
- package/README.md +2 -1
- package/config/.schema.json +14 -1
- package/config/llwiki.json +1 -0
- package/config/minimum.json +2 -0
- package/config/moegirl.json +1 -0
- package/config/zhwiki.json +24 -23
- package/coverage/badge.svg +1 -0
- package/dist/base.d.mts +164 -0
- package/dist/base.d.ts +68 -0
- package/dist/base.js +70 -63
- package/dist/base.mjs +74 -0
- package/dist/bin/coverage.js +19 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +13 -3
- package/dist/internal.d.ts +41 -41
- package/dist/lib/lsp.d.ts +68 -0
- package/dist/lib/lsp.js +610 -0
- package/dist/lib/node.js +2 -2
- package/dist/lib/rect.d.ts +3 -5
- package/dist/lib/rect.js +13 -10
- package/dist/lib/text.js +6 -7
- package/dist/parser/braces.js +2 -0
- package/dist/parser/commentAndExt.js +1 -0
- package/dist/parser/converter.js +1 -0
- package/dist/parser/externalLinks.js +2 -1
- package/dist/parser/hrAndDoubleUnderscore.js +2 -1
- package/dist/parser/html.js +1 -0
- package/dist/parser/links.js +1 -0
- package/dist/parser/list.js +1 -0
- package/dist/parser/magicLinks.js +2 -1
- package/dist/parser/quotes.js +1 -0
- package/dist/parser/redirect.js +1 -0
- package/dist/parser/table.js +1 -0
- package/dist/src/attribute.d.ts +4 -2
- package/dist/src/attribute.js +3 -4
- package/dist/src/attributes.js +1 -1
- package/dist/src/heading.js +3 -1
- package/dist/src/html.js +3 -4
- package/dist/src/link/redirectTarget.d.ts +2 -3
- package/dist/src/link/redirectTarget.js +1 -2
- package/dist/src/magicLink.js +1 -1
- package/dist/src/nowiki/comment.d.ts +1 -1
- package/dist/src/nowiki/comment.js +1 -1
- package/dist/src/nowiki/quote.js +8 -12
- package/dist/util/debug.js +14 -2
- package/dist/util/diff.js +5 -0
- package/dist/util/html.js +3 -1
- package/dist/util/lint.js +16 -4
- package/dist/util/sharable.js +5 -4
- package/dist/util/sharable.mjs +4 -4
- package/dist/util/string.js +12 -1
- package/package.json +39 -21
package/README.md
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
[](https://www.npmjs.com/package/wikilint)
|
|
2
2
|
[](https://github.com/bhsd-harry/wikiparser-node/actions/workflows/codeql.yml)
|
|
3
3
|
[](https://github.com/bhsd-harry/wikiparser-node/actions/workflows/node.js.yml)
|
|
4
|
-
[](https://app.codacy.com/gh/bhsd-harry/wikiparser-node/dashboard)
|
|
5
|
+

|
|
5
6
|
|
|
6
7
|
# WikiLint
|
|
7
8
|
|
package/config/.schema.json
CHANGED
|
@@ -51,7 +51,20 @@
|
|
|
51
51
|
"items": {
|
|
52
52
|
"type": "string",
|
|
53
53
|
"pattern": "^[^#A-Z]+$"
|
|
54
|
-
}
|
|
54
|
+
},
|
|
55
|
+
"allOf": [
|
|
56
|
+
{
|
|
57
|
+
"contains": {
|
|
58
|
+
"const": "!"
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
"contains": {
|
|
63
|
+
"const": "="
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
],
|
|
67
|
+
"minItems": 2
|
|
55
68
|
},
|
|
56
69
|
"parserFunction": {
|
|
57
70
|
"type": "array",
|
package/config/llwiki.json
CHANGED
package/config/minimum.json
CHANGED
package/config/moegirl.json
CHANGED
package/config/zhwiki.json
CHANGED
|
@@ -759,29 +759,7 @@
|
|
|
759
759
|
],
|
|
760
760
|
"doubleUnderscore": [
|
|
761
761
|
[],
|
|
762
|
-
[
|
|
763
|
-
"EXPECTUNUSEDCATEGORY",
|
|
764
|
-
"DISAMBIG",
|
|
765
|
-
"消除歧义",
|
|
766
|
-
"HIDDENCAT",
|
|
767
|
-
"隐藏分类",
|
|
768
|
-
"隱藏分類",
|
|
769
|
-
"INDEX",
|
|
770
|
-
"索引",
|
|
771
|
-
"NEWSECTIONLINK",
|
|
772
|
-
"新段落链接",
|
|
773
|
-
"NOINDEX",
|
|
774
|
-
"无索引",
|
|
775
|
-
"NONEWSECTIONLINK",
|
|
776
|
-
"无新段落链接",
|
|
777
|
-
"STATICREDIRECT",
|
|
778
|
-
"静态重定向",
|
|
779
|
-
"靜態重新導向",
|
|
780
|
-
"NOGLOBAL",
|
|
781
|
-
"禁用全域用户页",
|
|
782
|
-
"EXPECTED_UNCONNECTED_PAGE",
|
|
783
|
-
"EXPECTUNUSEDTEMPLATE"
|
|
784
|
-
],
|
|
762
|
+
[],
|
|
785
763
|
{
|
|
786
764
|
"forcetoc": "forcetoc",
|
|
787
765
|
"强显目录": "forcetoc",
|
|
@@ -811,6 +789,29 @@
|
|
|
811
789
|
"已存档讨论": "archivedtalk",
|
|
812
790
|
"notalk": "notalk",
|
|
813
791
|
"禁用讨论": "notalk"
|
|
792
|
+
},
|
|
793
|
+
{
|
|
794
|
+
"EXPECTUNUSEDCATEGORY": "EXPECTUNUSEDCATEGORY",
|
|
795
|
+
"DISAMBIG": "DISAMBIG",
|
|
796
|
+
"消除歧义": "DISAMBIG",
|
|
797
|
+
"HIDDENCAT": "HIDDENCAT",
|
|
798
|
+
"隐藏分类": "HIDDENCAT",
|
|
799
|
+
"隱藏分類": "HIDDENCAT",
|
|
800
|
+
"INDEX": "INDEX",
|
|
801
|
+
"索引": "INDEX",
|
|
802
|
+
"NEWSECTIONLINK": "NEWSECTIONLINK",
|
|
803
|
+
"新段落链接": "NEWSECTIONLINK",
|
|
804
|
+
"NOINDEX": "NOINDEX",
|
|
805
|
+
"无索引": "NOINDEX",
|
|
806
|
+
"NONEWSECTIONLINK": "NONEWSECTIONLINK",
|
|
807
|
+
"无新段落链接": "NONEWSECTIONLINK",
|
|
808
|
+
"STATICREDIRECT": "STATICREDIRECT",
|
|
809
|
+
"静态重定向": "STATICREDIRECT",
|
|
810
|
+
"靜態重新導向": "STATICREDIRECT",
|
|
811
|
+
"NOGLOBAL": "NOGLOBAL",
|
|
812
|
+
"禁用全域用户页": "NOGLOBAL",
|
|
813
|
+
"EXPECTED_UNCONNECTED_PAGE": "EXPECTED_UNCONNECTED_PAGE",
|
|
814
|
+
"EXPECTUNUSEDTEMPLATE": "EXPECTUNUSEDTEMPLATE"
|
|
814
815
|
}
|
|
815
816
|
],
|
|
816
817
|
"protocol": "bitcoin:|ftp://|ftps://|geo:|git://|gopher://|http://|https://|irc://|ircs://|magnet:|mailto:|matrix:|mms://|news:|nntp://|redis://|sftp://|sip:|sips:|sms:|ssh://|svn://|tel:|telnet://|urn:|worldwind://|xmpp:",
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="98" height="20" role="img" aria-label="Coverage: 86%"><title>Coverage: 86%</title><linearGradient id="s" x2="0" y2="100%"><stop offset="0" stop-color="#bbb" stop-opacity=".1"/><stop offset="1" stop-opacity=".1"/></linearGradient><clipPath id="r"><rect width="98" height="20" rx="3" fill="#fff"/></clipPath><g clip-path="url(#r)"><rect width="63" height="20" fill="#555"/><rect x="63" width="35" height="20" fill="#4c1"/><rect width="98" height="20" fill="url(#s)"/></g><g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" text-rendering="geometricPrecision" font-size="110"><text aria-hidden="true" x="325" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="530">Coverage</text><text x="325" y="140" transform="scale(.1)" fill="#fff" textLength="530">Coverage</text><text aria-hidden="true" x="795" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="250">86%</text><text x="795" y="140" transform="scale(.1)" fill="#fff" textLength="250">86%</text></g></svg>
|
package/dist/base.d.mts
ADDED
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import type { Range, Position, ColorInformation, ColorPresentation, CompletionItem, FoldingRange, DocumentSymbol, DocumentLink, Location, WorkspaceEdit } from 'vscode-languageserver-types';
|
|
2
|
+
export interface Config {
|
|
3
|
+
ext: string[];
|
|
4
|
+
readonly html: [string[], string[], string[]];
|
|
5
|
+
readonly namespaces: Record<string, string>;
|
|
6
|
+
readonly nsid: Record<string, number>;
|
|
7
|
+
readonly variable: string[];
|
|
8
|
+
readonly parserFunction: [Record<string, string>, Record<string, string> | string[], string[], string[]];
|
|
9
|
+
readonly doubleUnderscore: [string[], string[], Record<string, string>?, Record<string, string>?];
|
|
10
|
+
readonly protocol: string;
|
|
11
|
+
readonly interwiki: string[];
|
|
12
|
+
readonly img: Record<string, string>;
|
|
13
|
+
readonly redirection: string[];
|
|
14
|
+
readonly variants: string[];
|
|
15
|
+
readonly articlePath?: string;
|
|
16
|
+
}
|
|
17
|
+
export type TokenTypes = 'root' | 'plain' | 'redirect' | 'redirect-syntax' | 'redirect-target' | 'onlyinclude' | 'noinclude' | 'include' | 'comment' | 'ext' | 'ext-attrs' | 'ext-attr-dirty' | 'ext-attr' | 'attr-key' | 'attr-value' | 'ext-inner' | 'arg' | 'arg-name' | 'arg-default' | 'hidden' | 'magic-word' | 'magic-word-name' | 'invoke-function' | 'invoke-module' | 'template' | 'template-name' | 'parameter' | 'parameter-key' | 'parameter-value' | 'heading' | 'heading-title' | 'heading-trail' | 'html' | 'html-attrs' | 'html-attr-dirty' | 'html-attr' | 'table' | 'tr' | 'td' | 'table-syntax' | 'table-attrs' | 'table-attr-dirty' | 'table-attr' | 'table-inter' | 'td-inner' | 'hr' | 'double-underscore' | 'link' | 'link-target' | 'link-text' | 'category' | 'file' | 'gallery-image' | 'imagemap-image' | 'image-parameter' | 'quote' | 'ext-link' | 'ext-link-text' | 'ext-link-url' | 'free-ext-link' | 'magic-link' | 'list' | 'dd' | 'list-range' | 'converter' | 'converter-flags' | 'converter-flag' | 'converter-rule' | 'converter-rule-variant' | 'converter-rule-to' | 'converter-rule-from' | 'param-line' | 'imagemap-link';
|
|
18
|
+
export declare const stages: {
|
|
19
|
+
redirect: number;
|
|
20
|
+
onlyinclude: number;
|
|
21
|
+
noinclude: number;
|
|
22
|
+
include: number;
|
|
23
|
+
comment: number;
|
|
24
|
+
ext: number;
|
|
25
|
+
arg: number;
|
|
26
|
+
'magic-word': number;
|
|
27
|
+
template: number;
|
|
28
|
+
heading: number;
|
|
29
|
+
html: number;
|
|
30
|
+
table: number;
|
|
31
|
+
hr: number;
|
|
32
|
+
'double-underscore': number;
|
|
33
|
+
link: number;
|
|
34
|
+
category: number;
|
|
35
|
+
file: number;
|
|
36
|
+
quote: number;
|
|
37
|
+
'ext-link': number;
|
|
38
|
+
'free-ext-link': number;
|
|
39
|
+
'magic-link': number;
|
|
40
|
+
list: number;
|
|
41
|
+
dd: number;
|
|
42
|
+
converter: number;
|
|
43
|
+
};
|
|
44
|
+
export type Stage = keyof typeof stages;
|
|
45
|
+
export declare const rules: readonly ["bold-header", "format-leakage", "fostered-content", "h1", "illegal-attr", "insecure-style", "invalid-gallery", "invalid-imagemap", "invalid-invoke", "invalid-isbn", "lonely-apos", "lonely-bracket", "lonely-http", "nested-link", "no-arg", "no-duplicate", "no-ignored", "obsolete-attr", "obsolete-tag", "parsing-order", "pipe-like", "table-layout", "tag-like", "unbalanced-header", "unclosed-comment", "unclosed-quote", "unclosed-table", "unescaped", "unknown-page", "unmatched-tag", "unterminated-url", "url-encoding", "var-anchor", "void-ext"];
|
|
46
|
+
export declare namespace LintError {
|
|
47
|
+
type Severity = 'error' | 'warning';
|
|
48
|
+
type Rule = typeof rules[number];
|
|
49
|
+
interface Fix {
|
|
50
|
+
readonly range: [number, number];
|
|
51
|
+
text: string;
|
|
52
|
+
desc: string;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
export interface LintError {
|
|
56
|
+
rule: LintError.Rule;
|
|
57
|
+
message: string;
|
|
58
|
+
severity: LintError.Severity;
|
|
59
|
+
startIndex: number;
|
|
60
|
+
endIndex: number;
|
|
61
|
+
startLine: number;
|
|
62
|
+
startCol: number;
|
|
63
|
+
endLine: number;
|
|
64
|
+
endCol: number;
|
|
65
|
+
fix?: LintError.Fix;
|
|
66
|
+
suggestions?: LintError.Fix[];
|
|
67
|
+
}
|
|
68
|
+
/** 类似Node */
|
|
69
|
+
export interface AstNode {
|
|
70
|
+
readonly childNodes: readonly AstNode[];
|
|
71
|
+
/** 节点类型 */
|
|
72
|
+
type: string;
|
|
73
|
+
toString(...args: unknown[]): string;
|
|
74
|
+
/** Linter */
|
|
75
|
+
lint(): LintError[];
|
|
76
|
+
}
|
|
77
|
+
/** 所有节点的基类 */
|
|
78
|
+
interface Token extends AstNode {
|
|
79
|
+
readonly name?: string;
|
|
80
|
+
/**
|
|
81
|
+
* 符合选择器的所有后代节点
|
|
82
|
+
* @param selector 选择器
|
|
83
|
+
*/
|
|
84
|
+
querySelectorAll<T = Token>(selector: string): T[];
|
|
85
|
+
}
|
|
86
|
+
export interface LanguageService {
|
|
87
|
+
/**
|
|
88
|
+
* 提供颜色指示
|
|
89
|
+
* @param rgba 颜色解析函数
|
|
90
|
+
* @param text 源代码
|
|
91
|
+
* @param hsl 是否允许HSL颜色
|
|
92
|
+
*/
|
|
93
|
+
provideDocumentColors(rgba: (s: string) => [number, number, number, number] | [], text: string, hsl?: boolean): Promise<ColorInformation[]>;
|
|
94
|
+
/**
|
|
95
|
+
* 颜色选择器
|
|
96
|
+
* @ignore
|
|
97
|
+
*/
|
|
98
|
+
provideColorPresentations(// eslint-disable-line @typescript-eslint/class-methods-use-this
|
|
99
|
+
{ color: { red, green, blue, alpha }, range }: ColorInformation): ColorPresentation[];
|
|
100
|
+
/**
|
|
101
|
+
* 提供自动补全
|
|
102
|
+
* @param text 源代码
|
|
103
|
+
* @param position 位置
|
|
104
|
+
*/
|
|
105
|
+
provideCompletionItems(text: string, position: Position): Promise<CompletionItem[] | undefined>;
|
|
106
|
+
/**
|
|
107
|
+
* 提供折叠范围
|
|
108
|
+
* @param text 源代码
|
|
109
|
+
*/
|
|
110
|
+
provideFoldingRanges(text: string): Promise<FoldingRange[]>;
|
|
111
|
+
/**
|
|
112
|
+
* 提供章节
|
|
113
|
+
* @param text 源代码
|
|
114
|
+
*/
|
|
115
|
+
provideDocumentSymbols(text: string): Promise<DocumentSymbol[]>;
|
|
116
|
+
/**
|
|
117
|
+
* 提供链接
|
|
118
|
+
* @param text 源代码
|
|
119
|
+
*/
|
|
120
|
+
provideLinks(text: string): Promise<DocumentLink[]>;
|
|
121
|
+
/**
|
|
122
|
+
* 提供引用
|
|
123
|
+
* @param text 源代码
|
|
124
|
+
* @param position 位置
|
|
125
|
+
*/
|
|
126
|
+
provideReferences(text: string, position: Position): Promise<Omit<Location, 'uri'>[] | undefined>;
|
|
127
|
+
/**
|
|
128
|
+
* 提供定义
|
|
129
|
+
* @param text 源代码
|
|
130
|
+
* @param position 位置
|
|
131
|
+
*/
|
|
132
|
+
provideDefinition(text: string, position: Position): Promise<Omit<Location, 'uri'>[] | undefined>;
|
|
133
|
+
/**
|
|
134
|
+
* 提供变量更名准备
|
|
135
|
+
* @param text 源代码
|
|
136
|
+
* @param position 位置
|
|
137
|
+
*/
|
|
138
|
+
resolveRenameLocation(text: string, position: Position): Promise<Range | undefined>;
|
|
139
|
+
/**
|
|
140
|
+
* 变量更名
|
|
141
|
+
* @param text 源代码
|
|
142
|
+
* @param position 位置
|
|
143
|
+
* @param newName 新名称
|
|
144
|
+
*/
|
|
145
|
+
provideRenameEdits(text: string, position: Position, newName: string): Promise<WorkspaceEdit | undefined>;
|
|
146
|
+
}
|
|
147
|
+
export interface Parser {
|
|
148
|
+
config: Config | string;
|
|
149
|
+
i18n: Record<string, string> | string | undefined;
|
|
150
|
+
/** 获取当前的解析设置 */
|
|
151
|
+
getConfig(): Config;
|
|
152
|
+
/**
|
|
153
|
+
* 解析wikitext
|
|
154
|
+
* @param include 是否嵌入
|
|
155
|
+
* @param maxStage 最大解析层级
|
|
156
|
+
*/
|
|
157
|
+
parse(wikitext: string, include?: boolean, maxStage?: number | Stage | Stage[], config?: Config): Token;
|
|
158
|
+
/**
|
|
159
|
+
* 创建语言服务
|
|
160
|
+
* @param uri 文档标识
|
|
161
|
+
*/
|
|
162
|
+
createLanguageService(uri: object): LanguageService;
|
|
163
|
+
}
|
|
164
|
+
export {};
|
package/dist/base.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { Range, Position, ColorInformation, ColorPresentation, CompletionItem, FoldingRange, DocumentSymbol, DocumentLink, Location, WorkspaceEdit } from 'vscode-languageserver-types';
|
|
1
2
|
export interface Config {
|
|
2
3
|
ext: string[];
|
|
3
4
|
readonly html: [string[], string[], string[]];
|
|
@@ -11,6 +12,7 @@ export interface Config {
|
|
|
11
12
|
readonly img: Record<string, string>;
|
|
12
13
|
readonly redirection: string[];
|
|
13
14
|
readonly variants: string[];
|
|
15
|
+
readonly articlePath?: string;
|
|
14
16
|
}
|
|
15
17
|
export type TokenTypes = 'root' | 'plain' | 'redirect' | 'redirect-syntax' | 'redirect-target' | 'onlyinclude' | 'noinclude' | 'include' | 'comment' | 'ext' | 'ext-attrs' | 'ext-attr-dirty' | 'ext-attr' | 'attr-key' | 'attr-value' | 'ext-inner' | 'arg' | 'arg-name' | 'arg-default' | 'hidden' | 'magic-word' | 'magic-word-name' | 'invoke-function' | 'invoke-module' | 'template' | 'template-name' | 'parameter' | 'parameter-key' | 'parameter-value' | 'heading' | 'heading-title' | 'heading-trail' | 'html' | 'html-attrs' | 'html-attr-dirty' | 'html-attr' | 'table' | 'tr' | 'td' | 'table-syntax' | 'table-attrs' | 'table-attr-dirty' | 'table-attr' | 'table-inter' | 'td-inner' | 'hr' | 'double-underscore' | 'link' | 'link-target' | 'link-text' | 'category' | 'file' | 'gallery-image' | 'imagemap-image' | 'image-parameter' | 'quote' | 'ext-link' | 'ext-link-text' | 'ext-link-url' | 'free-ext-link' | 'magic-link' | 'list' | 'dd' | 'list-range' | 'converter' | 'converter-flags' | 'converter-flag' | 'converter-rule' | 'converter-rule-variant' | 'converter-rule-to' | 'converter-rule-from' | 'param-line' | 'imagemap-link';
|
|
16
18
|
export declare const stages: {
|
|
@@ -81,6 +83,67 @@ interface Token extends AstNode {
|
|
|
81
83
|
*/
|
|
82
84
|
querySelectorAll<T = Token>(selector: string): T[];
|
|
83
85
|
}
|
|
86
|
+
export interface LanguageService {
|
|
87
|
+
/**
|
|
88
|
+
* 提供颜色指示
|
|
89
|
+
* @param rgba 颜色解析函数
|
|
90
|
+
* @param text 源代码
|
|
91
|
+
* @param hsl 是否允许HSL颜色
|
|
92
|
+
*/
|
|
93
|
+
provideDocumentColors(rgba: (s: string) => [number, number, number, number] | [], text: string, hsl?: boolean): Promise<ColorInformation[]>;
|
|
94
|
+
/**
|
|
95
|
+
* 颜色选择器
|
|
96
|
+
* @ignore
|
|
97
|
+
*/
|
|
98
|
+
provideColorPresentations(// eslint-disable-line @typescript-eslint/class-methods-use-this
|
|
99
|
+
{ color: { red, green, blue, alpha }, range }: ColorInformation): ColorPresentation[];
|
|
100
|
+
/**
|
|
101
|
+
* 提供自动补全
|
|
102
|
+
* @param text 源代码
|
|
103
|
+
* @param position 位置
|
|
104
|
+
*/
|
|
105
|
+
provideCompletionItems(text: string, position: Position): Promise<CompletionItem[] | undefined>;
|
|
106
|
+
/**
|
|
107
|
+
* 提供折叠范围
|
|
108
|
+
* @param text 源代码
|
|
109
|
+
*/
|
|
110
|
+
provideFoldingRanges(text: string): Promise<FoldingRange[]>;
|
|
111
|
+
/**
|
|
112
|
+
* 提供章节
|
|
113
|
+
* @param text 源代码
|
|
114
|
+
*/
|
|
115
|
+
provideDocumentSymbols(text: string): Promise<DocumentSymbol[]>;
|
|
116
|
+
/**
|
|
117
|
+
* 提供链接
|
|
118
|
+
* @param text 源代码
|
|
119
|
+
*/
|
|
120
|
+
provideLinks(text: string): Promise<DocumentLink[]>;
|
|
121
|
+
/**
|
|
122
|
+
* 提供引用
|
|
123
|
+
* @param text 源代码
|
|
124
|
+
* @param position 位置
|
|
125
|
+
*/
|
|
126
|
+
provideReferences(text: string, position: Position): Promise<Omit<Location, 'uri'>[] | undefined>;
|
|
127
|
+
/**
|
|
128
|
+
* 提供定义
|
|
129
|
+
* @param text 源代码
|
|
130
|
+
* @param position 位置
|
|
131
|
+
*/
|
|
132
|
+
provideDefinition(text: string, position: Position): Promise<Omit<Location, 'uri'>[] | undefined>;
|
|
133
|
+
/**
|
|
134
|
+
* 提供变量更名准备
|
|
135
|
+
* @param text 源代码
|
|
136
|
+
* @param position 位置
|
|
137
|
+
*/
|
|
138
|
+
resolveRenameLocation(text: string, position: Position): Promise<Range | undefined>;
|
|
139
|
+
/**
|
|
140
|
+
* 变量更名
|
|
141
|
+
* @param text 源代码
|
|
142
|
+
* @param position 位置
|
|
143
|
+
* @param newName 新名称
|
|
144
|
+
*/
|
|
145
|
+
provideRenameEdits(text: string, position: Position, newName: string): Promise<WorkspaceEdit | undefined>;
|
|
146
|
+
}
|
|
84
147
|
export interface Parser {
|
|
85
148
|
config: Config | string;
|
|
86
149
|
i18n: Record<string, string> | string | undefined;
|
|
@@ -92,5 +155,10 @@ export interface Parser {
|
|
|
92
155
|
* @param maxStage 最大解析层级
|
|
93
156
|
*/
|
|
94
157
|
parse(wikitext: string, include?: boolean, maxStage?: number | Stage | Stage[], config?: Config): Token;
|
|
158
|
+
/**
|
|
159
|
+
* 创建语言服务
|
|
160
|
+
* @param uri 文档标识
|
|
161
|
+
*/
|
|
162
|
+
createLanguageService(uri: object): LanguageService;
|
|
95
163
|
}
|
|
96
164
|
export {};
|
package/dist/base.js
CHANGED
|
@@ -1,66 +1,73 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.rules = exports.stages = void 0;
|
|
4
|
-
exports.stages = {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
4
|
+
exports.stages = (() => {
|
|
5
|
+
const obj = {
|
|
6
|
+
redirect: 1,
|
|
7
|
+
onlyinclude: 1,
|
|
8
|
+
noinclude: 1,
|
|
9
|
+
include: 1,
|
|
10
|
+
comment: 1,
|
|
11
|
+
ext: 1,
|
|
12
|
+
arg: 2,
|
|
13
|
+
'magic-word': 2,
|
|
14
|
+
template: 2,
|
|
15
|
+
heading: 2,
|
|
16
|
+
html: 3,
|
|
17
|
+
table: 4,
|
|
18
|
+
hr: 5,
|
|
19
|
+
'double-underscore': 5,
|
|
20
|
+
link: 6,
|
|
21
|
+
category: 6,
|
|
22
|
+
file: 6,
|
|
23
|
+
quote: 7,
|
|
24
|
+
'ext-link': 8,
|
|
25
|
+
'free-ext-link': 9,
|
|
26
|
+
'magic-link': 9,
|
|
27
|
+
list: 10,
|
|
28
|
+
dd: 10,
|
|
29
|
+
converter: 11,
|
|
30
|
+
};
|
|
31
|
+
Object.setPrototypeOf(obj, null);
|
|
32
|
+
return obj;
|
|
33
|
+
})();
|
|
34
|
+
exports.rules = (() => {
|
|
35
|
+
const arr = [
|
|
36
|
+
'bold-header',
|
|
37
|
+
'format-leakage',
|
|
38
|
+
'fostered-content',
|
|
39
|
+
'h1',
|
|
40
|
+
'illegal-attr',
|
|
41
|
+
'insecure-style',
|
|
42
|
+
'invalid-gallery',
|
|
43
|
+
'invalid-imagemap',
|
|
44
|
+
'invalid-invoke',
|
|
45
|
+
'invalid-isbn',
|
|
46
|
+
'lonely-apos',
|
|
47
|
+
'lonely-bracket',
|
|
48
|
+
'lonely-http',
|
|
49
|
+
'nested-link',
|
|
50
|
+
'no-arg',
|
|
51
|
+
'no-duplicate',
|
|
52
|
+
'no-ignored',
|
|
53
|
+
'obsolete-attr',
|
|
54
|
+
'obsolete-tag',
|
|
55
|
+
'parsing-order',
|
|
56
|
+
'pipe-like',
|
|
57
|
+
'table-layout',
|
|
58
|
+
'tag-like',
|
|
59
|
+
'unbalanced-header',
|
|
60
|
+
'unclosed-comment',
|
|
61
|
+
'unclosed-quote',
|
|
62
|
+
'unclosed-table',
|
|
63
|
+
'unescaped',
|
|
64
|
+
'unknown-page',
|
|
65
|
+
'unmatched-tag',
|
|
66
|
+
'unterminated-url',
|
|
67
|
+
'url-encoding',
|
|
68
|
+
'var-anchor',
|
|
69
|
+
'void-ext',
|
|
70
|
+
];
|
|
71
|
+
Object.freeze(arr);
|
|
72
|
+
return arr;
|
|
73
|
+
})();
|
package/dist/base.mjs
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
const stages = /* @__PURE__ */ (() => {
|
|
2
|
+
const obj = {
|
|
3
|
+
redirect: 1,
|
|
4
|
+
onlyinclude: 1,
|
|
5
|
+
noinclude: 1,
|
|
6
|
+
include: 1,
|
|
7
|
+
comment: 1,
|
|
8
|
+
ext: 1,
|
|
9
|
+
arg: 2,
|
|
10
|
+
"magic-word": 2,
|
|
11
|
+
template: 2,
|
|
12
|
+
heading: 2,
|
|
13
|
+
html: 3,
|
|
14
|
+
table: 4,
|
|
15
|
+
hr: 5,
|
|
16
|
+
"double-underscore": 5,
|
|
17
|
+
link: 6,
|
|
18
|
+
category: 6,
|
|
19
|
+
file: 6,
|
|
20
|
+
quote: 7,
|
|
21
|
+
"ext-link": 8,
|
|
22
|
+
"free-ext-link": 9,
|
|
23
|
+
"magic-link": 9,
|
|
24
|
+
list: 10,
|
|
25
|
+
dd: 10,
|
|
26
|
+
converter: 11
|
|
27
|
+
};
|
|
28
|
+
Object.setPrototypeOf(obj, null);
|
|
29
|
+
return obj;
|
|
30
|
+
})();
|
|
31
|
+
const rules = /* @__PURE__ */ (() => {
|
|
32
|
+
const arr = [
|
|
33
|
+
"bold-header",
|
|
34
|
+
"format-leakage",
|
|
35
|
+
"fostered-content",
|
|
36
|
+
"h1",
|
|
37
|
+
"illegal-attr",
|
|
38
|
+
"insecure-style",
|
|
39
|
+
"invalid-gallery",
|
|
40
|
+
"invalid-imagemap",
|
|
41
|
+
"invalid-invoke",
|
|
42
|
+
"invalid-isbn",
|
|
43
|
+
"lonely-apos",
|
|
44
|
+
"lonely-bracket",
|
|
45
|
+
"lonely-http",
|
|
46
|
+
"nested-link",
|
|
47
|
+
"no-arg",
|
|
48
|
+
"no-duplicate",
|
|
49
|
+
"no-ignored",
|
|
50
|
+
"obsolete-attr",
|
|
51
|
+
"obsolete-tag",
|
|
52
|
+
"parsing-order",
|
|
53
|
+
"pipe-like",
|
|
54
|
+
"table-layout",
|
|
55
|
+
"tag-like",
|
|
56
|
+
"unbalanced-header",
|
|
57
|
+
"unclosed-comment",
|
|
58
|
+
"unclosed-quote",
|
|
59
|
+
"unclosed-table",
|
|
60
|
+
"unescaped",
|
|
61
|
+
"unknown-page",
|
|
62
|
+
"unmatched-tag",
|
|
63
|
+
"unterminated-url",
|
|
64
|
+
"url-encoding",
|
|
65
|
+
"var-anchor",
|
|
66
|
+
"void-ext"
|
|
67
|
+
];
|
|
68
|
+
Object.freeze(arr);
|
|
69
|
+
return arr;
|
|
70
|
+
})();
|
|
71
|
+
export {
|
|
72
|
+
rules,
|
|
73
|
+
stages
|
|
74
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const fs = require("fs");
|
|
4
|
+
// eslint-disable-next-line n/no-missing-require
|
|
5
|
+
const { total: { statements: { pct } } } = require('../../coverage/coverage-summary.json');
|
|
6
|
+
const colors = ['#4c1', '#dfb317', '#e05d44'];
|
|
7
|
+
let color;
|
|
8
|
+
if (pct >= 80) {
|
|
9
|
+
[color] = colors;
|
|
10
|
+
}
|
|
11
|
+
else if (pct >= 60) {
|
|
12
|
+
[, color] = colors;
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
[, , color] = colors;
|
|
16
|
+
}
|
|
17
|
+
const svg = fs.readFileSync('coverage/badge.svg', 'utf8').replace(/\b\d{2}(?=%)/gu, String(Math.round(pct)))
|
|
18
|
+
.replace(new RegExp(colors.join('|'), 'u'), color);
|
|
19
|
+
fs.writeFileSync('coverage/badge.svg', svg);
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Config, LintError, TokenTypes, Parser as ParserBase, Stage } from './base';
|
|
2
2
|
import type { Title } from './lib/title';
|
|
3
|
+
import type { LanguageService } from './lib/lsp';
|
|
3
4
|
import type { Token } from './internal';
|
|
4
5
|
declare interface Parser extends ParserBase {
|
|
5
6
|
rules: readonly LintError.Rule[];
|
|
@@ -11,6 +12,11 @@ declare interface Parser extends ParserBase {
|
|
|
11
12
|
*/
|
|
12
13
|
normalizeTitle(title: string, defaultNs?: number, include?: boolean, config?: Config): Title;
|
|
13
14
|
parse(wikitext: string, include?: boolean, maxStage?: number | Stage | Stage[], config?: Config): Token;
|
|
15
|
+
/**
|
|
16
|
+
* 创建语言服务
|
|
17
|
+
* @param uri 文档标识
|
|
18
|
+
*/
|
|
19
|
+
createLanguageService(uri: object): LanguageService;
|
|
14
20
|
}
|
|
15
21
|
declare const Parser: Parser;
|
|
16
22
|
// @ts-expect-error mixed export styles
|