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.
- package/README.md +1 -1
- package/data/signatures.json +2 -2
- package/dist/base.d.mts +3 -2
- package/dist/base.d.ts +3 -2
- package/dist/base.js +1 -0
- package/dist/base.mjs +2 -1
- package/dist/bin/config.js +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +17 -11
- package/dist/internal.d.ts +1 -0
- package/dist/lib/document.d.ts +4 -4
- package/dist/lib/lintConfig.js +1 -0
- package/dist/lib/lsp.js +7 -4
- package/dist/lib/node.d.ts +0 -4
- package/dist/lib/node.js +8 -0
- package/dist/map.d.ts +2 -1
- package/dist/parser/commentAndExt.js +1 -2
- package/dist/parser/hrAndDoubleUnderscore.js +3 -2
- package/dist/parser/table.js +2 -1
- package/dist/src/arg.d.ts +1 -1
- package/dist/src/arg.js +1 -1
- package/dist/src/attributes.d.ts +4 -3
- package/dist/src/converter.d.ts +1 -1
- package/dist/src/converter.js +1 -1
- package/dist/src/converterRule.d.ts +1 -1
- package/dist/src/converterRule.js +1 -1
- package/dist/src/extLink.d.ts +1 -1
- package/dist/src/extLink.js +1 -1
- package/dist/src/index.js +54 -14
- package/dist/src/link/category.d.ts +1 -1
- package/dist/src/link/category.js +1 -1
- package/dist/src/link/index.d.ts +1 -1
- package/dist/src/link/index.js +1 -1
- package/dist/src/link/redirectTarget.d.ts +1 -1
- package/dist/src/link/redirectTarget.js +1 -1
- package/dist/src/magicLink.d.ts +4 -3
- package/dist/src/magicLink.js +1 -1
- package/dist/src/multiLine/gallery.d.ts +4 -4
- package/dist/src/multiLine/imagemap.d.ts +5 -3
- package/dist/src/multiLine/imagemap.js +1 -1
- package/dist/src/nested.d.ts +1 -1
- package/dist/src/nested.js +1 -1
- package/dist/src/nowiki/list.js +6 -3
- package/dist/src/nowiki/listBase.d.ts +24 -0
- package/dist/src/nowiki/listBase.js +104 -0
- package/dist/src/paramLine.d.ts +1 -1
- package/dist/src/paramLine.js +1 -1
- package/dist/src/pre.d.ts +5 -3
- package/dist/src/redirect.d.ts +1 -1
- package/dist/src/redirect.js +1 -1
- package/dist/src/singleLine/charinsertLine.d.ts +1 -1
- package/dist/src/singleLine/charinsertLine.js +1 -1
- package/dist/src/table/index.d.ts +2 -2
- package/dist/src/table/index.js +1 -1
- package/dist/src/table/tr.d.ts +1 -1
- package/dist/src/table/tr.js +1 -1
- package/dist/src/tag/index.d.ts +7 -5
- package/dist/src/tag/index.js +9 -4
- package/dist/src/tagPair/ext.js +1 -1
- package/dist/src/transclude.d.ts +1 -1
- package/dist/src/transclude.js +1 -1
- package/dist/util/debug.js +7 -1
- package/i18n/en.json +1 -0
- package/i18n/zh-hans.json +1 -0
- package/i18n/zh-hant.json +1 -0
- package/package.json +6 -6
package/README.md
CHANGED
package/data/signatures.json
CHANGED
|
@@ -2658,13 +2658,13 @@
|
|
|
2658
2658
|
"aliases": [
|
|
2659
2659
|
"!"
|
|
2660
2660
|
],
|
|
2661
|
-
"description": "Used to include
|
|
2661
|
+
"description": "Used to include an escaped [pipe](https://en.wikipedia.org/wiki/Vertical_bar) (`|`) character as part of template or parser function arguments to prevent interpretation as a parameter separator during expansion.\n\nSee [help](https://www.mediawiki.org/wiki/Help:Extension:ParserFunctions#Escaping_pipe_characters_in_tables) for further explanation."
|
|
2662
2662
|
},
|
|
2663
2663
|
{
|
|
2664
2664
|
"aliases": [
|
|
2665
2665
|
"="
|
|
2666
2666
|
],
|
|
2667
|
-
"description": "Used to include an equal sign.\n\nSee [help](https://www.mediawiki.org/wiki/Help:Extension:ParserFunctions#Raw_equal_signs) for further explanation."
|
|
2667
|
+
"description": "Used to include an escaped equal sign (`=`) character as part of template or parser function arguments to prevent interpretation as a name-value separator during expansion.\n\nSee [help](https://www.mediawiki.org/wiki/Help:Extension:ParserFunctions#Raw_equal_signs) for further explanation."
|
|
2668
2668
|
},
|
|
2669
2669
|
{
|
|
2670
2670
|
"aliases": [
|
package/dist/base.d.mts
CHANGED
|
@@ -15,7 +15,7 @@ export interface Config {
|
|
|
15
15
|
articlePath?: string;
|
|
16
16
|
}
|
|
17
17
|
export type ConfigData = Omit<Config, 'excludes'>;
|
|
18
|
-
export type TokenTypes = 'root' | 'plain' | 'redirect' | 'redirect-syntax' | 'redirect-target' | 'translate' | 'translate-attr' | 'translate-inner' | 'tvar' | 'tvar-name' | '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' | 'converter' | 'converter-flags' | 'converter-flag' | 'converter-rule' | 'converter-rule-variant' | 'converter-rule-to' | 'converter-rule-from' | 'param-line' | 'param-line-key' | 'param-line-value' | 'imagemap-link' | 'charinsert-line';
|
|
18
|
+
export type TokenTypes = 'root' | 'plain' | 'redirect' | 'redirect-syntax' | 'redirect-target' | 'translate' | 'translate-attr' | 'translate-inner' | 'tvar' | 'tvar-name' | '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' | 'converter' | 'converter-flags' | 'converter-flag' | 'converter-rule' | 'converter-rule-variant' | 'converter-rule-to' | 'converter-rule-from' | 'param-line' | 'param-line-key' | 'param-line-value' | 'imagemap-link' | 'charinsert-line' | 'list-range';
|
|
19
19
|
export declare const stages: {
|
|
20
20
|
redirect: number;
|
|
21
21
|
onlyinclude: number;
|
|
@@ -41,8 +41,9 @@ export declare const stages: {
|
|
|
41
41
|
list: number;
|
|
42
42
|
dd: number;
|
|
43
43
|
converter: number;
|
|
44
|
+
'list-range': number;
|
|
44
45
|
};
|
|
45
|
-
|
|
46
|
+
declare type Stage = keyof typeof stages;
|
|
46
47
|
export declare const rules: readonly ["arg-in-ext", "blank-alt", "bold-header", "format-leakage", "fostered-content", "h1", "illegal-attr", "insecure-style", "invalid-gallery", "invalid-imagemap", "invalid-invoke", "invalid-isbn", "invalid-json", "invalid-ref", "invalid-url", "lonely-apos", "lonely-bracket", "lonely-http", "nested-link", "no-arg", "no-duplicate", "no-ignored", "obsolete-attr", "obsolete-tag", "parsing-order", "pipe-like", "required-attr", "syntax-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", "invalid-css", "invalid-math"];
|
|
47
48
|
export declare namespace LintError {
|
|
48
49
|
type Severity = 'error' | 'warning';
|
package/dist/base.d.ts
CHANGED
|
@@ -15,7 +15,7 @@ export interface Config {
|
|
|
15
15
|
articlePath?: string;
|
|
16
16
|
}
|
|
17
17
|
export type ConfigData = Omit<Config, 'excludes'>;
|
|
18
|
-
export type TokenTypes = 'root' | 'plain' | 'redirect' | 'redirect-syntax' | 'redirect-target' | 'translate' | 'translate-attr' | 'translate-inner' | 'tvar' | 'tvar-name' | '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' | 'converter' | 'converter-flags' | 'converter-flag' | 'converter-rule' | 'converter-rule-variant' | 'converter-rule-to' | 'converter-rule-from' | 'param-line' | 'param-line-key' | 'param-line-value' | 'imagemap-link' | 'charinsert-line';
|
|
18
|
+
export type TokenTypes = 'root' | 'plain' | 'redirect' | 'redirect-syntax' | 'redirect-target' | 'translate' | 'translate-attr' | 'translate-inner' | 'tvar' | 'tvar-name' | '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' | 'converter' | 'converter-flags' | 'converter-flag' | 'converter-rule' | 'converter-rule-variant' | 'converter-rule-to' | 'converter-rule-from' | 'param-line' | 'param-line-key' | 'param-line-value' | 'imagemap-link' | 'charinsert-line' | 'list-range';
|
|
19
19
|
export declare const stages: {
|
|
20
20
|
redirect: number;
|
|
21
21
|
onlyinclude: number;
|
|
@@ -41,8 +41,9 @@ export declare const stages: {
|
|
|
41
41
|
list: number;
|
|
42
42
|
dd: number;
|
|
43
43
|
converter: number;
|
|
44
|
+
'list-range': number;
|
|
44
45
|
};
|
|
45
|
-
|
|
46
|
+
declare type Stage = keyof typeof stages;
|
|
46
47
|
export declare const rules: readonly ["arg-in-ext", "blank-alt", "bold-header", "format-leakage", "fostered-content", "h1", "illegal-attr", "insecure-style", "invalid-gallery", "invalid-imagemap", "invalid-invoke", "invalid-isbn", "invalid-json", "invalid-ref", "invalid-url", "lonely-apos", "lonely-bracket", "lonely-http", "nested-link", "no-arg", "no-duplicate", "no-ignored", "obsolete-attr", "obsolete-tag", "parsing-order", "pipe-like", "required-attr", "syntax-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", "invalid-css", "invalid-math"];
|
|
47
48
|
export declare namespace LintError {
|
|
48
49
|
type Severity = 'error' | 'warning';
|
package/dist/base.js
CHANGED
package/dist/base.mjs
CHANGED
package/dist/bin/config.js
CHANGED
|
@@ -41,7 +41,7 @@ const filterGadget = (id) => {
|
|
|
41
41
|
const n = Number(id);
|
|
42
42
|
return n < 2300 || n > 2303; // Gadget, Gadget talk, Gadget definition, Gadget definition talk
|
|
43
43
|
};
|
|
44
|
-
const pkg = 'wikilint', version = '
|
|
44
|
+
const pkg = 'wikilint', version = '3.0.0';
|
|
45
45
|
/**
|
|
46
46
|
* Get the parser configuration for a Wikimedia Foundation project.
|
|
47
47
|
* @param site site nickname
|
package/dist/index.d.ts
CHANGED
|
@@ -52,7 +52,6 @@ declare interface Parser extends ParserBase {
|
|
|
52
52
|
declare const Parser: Parser;
|
|
53
53
|
// @ts-expect-error mixed export styles
|
|
54
54
|
export = Parser;
|
|
55
|
-
export default Parser;
|
|
56
55
|
export type { Config, ConfigData, LintConfig, LintError, TokenTypes, LanguageService, QuickFixData, Title, };
|
|
57
56
|
export type * from './internal';
|
|
58
57
|
declare global { type WikiParserAcceptable = Record<string, any>; }
|
package/dist/index.js
CHANGED
|
@@ -189,13 +189,11 @@ const Parser = {
|
|
|
189
189
|
config = configOrStage;
|
|
190
190
|
page = pageOrConfig;
|
|
191
191
|
}
|
|
192
|
-
maxStage ??= constants_1.MAX_STAGE;
|
|
192
|
+
maxStage ??= constants_1.MAX_STAGE + 1;
|
|
193
193
|
config ??= this.getConfig();
|
|
194
|
-
// eslint-disable-next-line unicorn/prefer-smaller-scope
|
|
195
|
-
let types;
|
|
196
194
|
LSP: if (typeof maxStage !== 'number') {
|
|
197
|
-
types = Array.isArray(maxStage) ? maxStage : [maxStage];
|
|
198
|
-
maxStage = Math.max(...types.map(t => base_1.stages[t] || constants_1.MAX_STAGE));
|
|
195
|
+
const types = Array.isArray(maxStage) ? maxStage : [maxStage];
|
|
196
|
+
maxStage = Math.max(...types.map(t => base_1.stages[t] || constants_1.MAX_STAGE + 1));
|
|
199
197
|
}
|
|
200
198
|
const { Token } = require('./src/index');
|
|
201
199
|
const root = debug_1.Shadow.run(() => {
|
|
@@ -203,20 +201,29 @@ const Parser = {
|
|
|
203
201
|
token.type = 'root';
|
|
204
202
|
token.pageName = page;
|
|
205
203
|
try {
|
|
206
|
-
|
|
204
|
+
token.parse(maxStage, include);
|
|
205
|
+
PRINT: if (maxStage > constants_1.MAX_STAGE) {
|
|
206
|
+
token.buildLists();
|
|
207
|
+
}
|
|
208
|
+
return token;
|
|
207
209
|
/* NOT FOR BROWSER ONLY */
|
|
208
210
|
}
|
|
209
211
|
catch (e) /* c8 ignore start */ {
|
|
210
212
|
if (e instanceof Error) {
|
|
211
|
-
const file = path_1.default.join(__dirname, '..', 'errors', new Date().toISOString()), stage = token.getAttribute('stage');
|
|
213
|
+
const file = path_1.default.join(__dirname, '..', 'errors', new Date().toISOString()), stage = token.getAttribute('stage'), isMax = stage === constants_1.MAX_STAGE;
|
|
212
214
|
for (const k in config) {
|
|
213
215
|
if (k.startsWith('regex') || config[k] instanceof Set) {
|
|
214
216
|
delete config[k];
|
|
215
217
|
}
|
|
216
218
|
}
|
|
217
|
-
fs_1.default.writeFileSync(file,
|
|
219
|
+
fs_1.default.writeFileSync(file, isMax ? wikitext : token.toString());
|
|
218
220
|
fs_1.default.writeFileSync(`${file}.err`, e.stack);
|
|
219
|
-
fs_1.default.writeFileSync(`${file}.json`, JSON.stringify({
|
|
221
|
+
fs_1.default.writeFileSync(`${file}.json`, JSON.stringify({
|
|
222
|
+
stage: isMax ? maxStage : stage,
|
|
223
|
+
include,
|
|
224
|
+
config,
|
|
225
|
+
page,
|
|
226
|
+
}, null, '\t'));
|
|
220
227
|
}
|
|
221
228
|
throw e;
|
|
222
229
|
}
|
|
@@ -240,7 +247,7 @@ const Parser = {
|
|
|
240
247
|
lint(wikitext, includeOrPage, configOrInclude, pageOrConfig) {
|
|
241
248
|
LINT: {
|
|
242
249
|
const [include, config, page] = getParams(includeOrPage, configOrInclude, pageOrConfig);
|
|
243
|
-
return debug_1.Shadow.internal(() => this.parse(wikitext, include,
|
|
250
|
+
return debug_1.Shadow.internal(() => this.parse(wikitext, include, constants_1.MAX_STAGE, config, page).lint(), this);
|
|
244
251
|
}
|
|
245
252
|
},
|
|
246
253
|
/* NOT FOR BROWSER ONLY */
|
|
@@ -278,5 +285,4 @@ for (const key in Parser) {
|
|
|
278
285
|
}
|
|
279
286
|
}
|
|
280
287
|
Object.defineProperties(Parser, def);
|
|
281
|
-
exports.default = Parser;
|
|
282
288
|
module.exports = Parser;
|
package/dist/internal.d.ts
CHANGED
|
@@ -55,3 +55,4 @@ export type { CommentLineToken } from './src/nowiki/commentLine';
|
|
|
55
55
|
export type { TranslateToken } from './src/tagPair/translate';
|
|
56
56
|
export type { TvarToken } from './src/tag/tvar';
|
|
57
57
|
export type { FuncTagToken } from './src/funcTag';
|
|
58
|
+
export type { ListRangeToken } from './src/nowiki/listBase';
|
package/dist/lib/document.d.ts
CHANGED
|
@@ -66,8 +66,8 @@ declare abstract class EmbeddedDocument implements TextDocument {
|
|
|
66
66
|
/** embedded JSON document */
|
|
67
67
|
export declare class EmbeddedJSONDocument extends EmbeddedDocument {
|
|
68
68
|
jsonDoc: JsonLanguageService.JSONDocument;
|
|
69
|
-
|
|
70
|
-
|
|
69
|
+
getLineRange: () => Range;
|
|
70
|
+
getEOLCharacters: () => string;
|
|
71
71
|
/**
|
|
72
72
|
* @param root root token
|
|
73
73
|
* @param token current token
|
|
@@ -77,8 +77,8 @@ export declare class EmbeddedJSONDocument extends EmbeddedDocument {
|
|
|
77
77
|
/** embedded CSS document */
|
|
78
78
|
export declare class EmbeddedCSSDocument extends EmbeddedDocument {
|
|
79
79
|
styleSheet: CssLanguageService.Stylesheet;
|
|
80
|
-
|
|
81
|
-
|
|
80
|
+
getLineRange: () => Range;
|
|
81
|
+
getEOLCharacters: () => string;
|
|
82
82
|
/**
|
|
83
83
|
* @param root root token
|
|
84
84
|
* @param token current token
|
package/dist/lib/lintConfig.js
CHANGED
package/dist/lib/lsp.js
CHANGED
|
@@ -339,6 +339,9 @@ function getStylelintPos(rect, bottom, lineOrCode, columnOrOffset) {
|
|
|
339
339
|
* @param errors LilyPond errors
|
|
340
340
|
*/
|
|
341
341
|
const getLilyPondDiagnostics = (root, token, errors) => {
|
|
342
|
+
if (!errors) {
|
|
343
|
+
return [];
|
|
344
|
+
}
|
|
342
345
|
const { top, left } = root.posFromIndex(token.lastChild.getAbsoluteIndex());
|
|
343
346
|
return errors.map(({ line, col, message }) => {
|
|
344
347
|
const pos = (0, lint_1.getEndPos)(top, left, line, col);
|
|
@@ -952,7 +955,7 @@ class LanguageService {
|
|
|
952
955
|
try {
|
|
953
956
|
// eslint-disable-next-line @typescript-eslint/strict-void-return
|
|
954
957
|
await util_1.default.promisify(child_process_1.execFile)(this.lilypond, ['-dno-print-pages', '-s', '-o', dir, file]);
|
|
955
|
-
scores.set(score,
|
|
958
|
+
scores.set(score, undefined);
|
|
956
959
|
}
|
|
957
960
|
catch (e) {
|
|
958
961
|
const { stderr } = e;
|
|
@@ -1393,7 +1396,7 @@ class LanguageService {
|
|
|
1393
1396
|
contents: {
|
|
1394
1397
|
kind: 'markdown',
|
|
1395
1398
|
value: (info.signatures
|
|
1396
|
-
? `${info.signatures.map(params => `- **{{ ${f}${params.length === 0 ? '**' : `${colon}** `}${params.map(({ label, const: c }) => c ? label : `*${label}*`).join(' **|** ')} **}}
|
|
1399
|
+
? `${info.signatures.map(params => `- **{{ ${f}${params.length === 0 ? '**' : `${colon}** `}${params.map(({ label, const: c }) => c ? label : `*${label}*`).join(' **|** ')} **}}**\n`).join('')}\n`
|
|
1397
1400
|
: '')
|
|
1398
1401
|
+ info.description,
|
|
1399
1402
|
},
|
|
@@ -1537,7 +1540,7 @@ class LanguageService {
|
|
|
1537
1540
|
* @param diagnostics grammar diagnostics / 语法诊断信息
|
|
1538
1541
|
*/
|
|
1539
1542
|
provideCodeAction(diagnostics) {
|
|
1540
|
-
const actionable = diagnostics.filter((diagnostic) => diagnostic.data), fixable = actionable.filter(({ source, data }) => source === 'WikiLint' && data.some(({ fix }) => fix))
|
|
1543
|
+
const actionable = diagnostics.filter((diagnostic) => diagnostic.data), fixable = actionable.filter(({ source, data }) => source === 'WikiLint' && data.some(({ fix }) => fix));
|
|
1541
1544
|
return [
|
|
1542
1545
|
...actionable.flatMap(diagnostic => diagnostic.data.map((data) => ({
|
|
1543
1546
|
title: data.title,
|
|
@@ -1551,7 +1554,7 @@ class LanguageService {
|
|
|
1551
1554
|
...fixable.length === 0
|
|
1552
1555
|
? []
|
|
1553
1556
|
: [
|
|
1554
|
-
...
|
|
1557
|
+
...[...new Set(fixable.map(({ code }) => code))].map((rule) => ({
|
|
1555
1558
|
title: `Fix all: ${rule}`,
|
|
1556
1559
|
kind: 'source.fixAll',
|
|
1557
1560
|
diagnostics: fixable.filter(({ code }) => code === rule),
|
package/dist/lib/node.d.ts
CHANGED
package/dist/lib/node.js
CHANGED
|
@@ -250,6 +250,14 @@ let AstNode = (() => {
|
|
|
250
250
|
getLines() {
|
|
251
251
|
LINT: return (0, common_1.splitLines)(String(this));
|
|
252
252
|
}
|
|
253
|
+
/** @private */
|
|
254
|
+
removeInternal() {
|
|
255
|
+
PRINT: {
|
|
256
|
+
const { parentNode } = this, i = parentNode?.childNodes.indexOf(this);
|
|
257
|
+
parentNode?.removeAt(i);
|
|
258
|
+
return i;
|
|
259
|
+
}
|
|
260
|
+
}
|
|
253
261
|
};
|
|
254
262
|
return AstNode = _classThis;
|
|
255
263
|
})();
|
package/dist/map.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { RedirectToken, RedirectTargetToken, OnlyincludeToken, IncludeToken, CommentToken, ExtToken, AttributesToken, AttributeToken, AtomToken, ArgToken, TranscludeToken, SyntaxToken, ParameterToken, HeadingToken, HtmlToken, TableToken, TrToken, TdToken, DoubleUnderscoreToken, HrToken, LinkToken, CategoryToken, FileToken, ImageParameterToken, QuoteToken, ExtLinkToken, MagicLinkToken, ListToken, DdToken, ConverterToken, ConverterFlagsToken, ConverterRuleToken, TranslateToken, TvarToken, HiddenToken, GalleryImageToken, ParamLineToken, ImagemapLinkToken, CharinsertLineToken } from './internal';
|
|
1
|
+
import type { RedirectToken, RedirectTargetToken, OnlyincludeToken, IncludeToken, CommentToken, ExtToken, AttributesToken, AttributeToken, AtomToken, ArgToken, TranscludeToken, SyntaxToken, ParameterToken, HeadingToken, HtmlToken, TableToken, TrToken, TdToken, DoubleUnderscoreToken, HrToken, LinkToken, CategoryToken, FileToken, ImageParameterToken, QuoteToken, ExtLinkToken, MagicLinkToken, ListToken, DdToken, ConverterToken, ConverterFlagsToken, ConverterRuleToken, TranslateToken, TvarToken, HiddenToken, GalleryImageToken, ParamLineToken, ImagemapLinkToken, CharinsertLineToken, ListRangeToken } from './internal';
|
|
2
2
|
export interface TokenTypeMap {
|
|
3
3
|
redirect: RedirectToken;
|
|
4
4
|
'redirect-syntax': SyntaxToken;
|
|
@@ -64,5 +64,6 @@ export interface TokenTypeMap {
|
|
|
64
64
|
'param-line-value': AtomToken;
|
|
65
65
|
'imagemap-link': ImagemapLinkToken;
|
|
66
66
|
'charinsert-line': CharinsertLineToken;
|
|
67
|
+
'list-range': ListRangeToken;
|
|
67
68
|
}
|
|
68
69
|
export type SelectedTokenTypes = keyof TokenTypeMap;
|
|
@@ -10,8 +10,7 @@ const ext_1 = require("../src/tagPair/ext");
|
|
|
10
10
|
const comment_1 = require("../src/nowiki/comment");
|
|
11
11
|
const onlyincludeLeft = '<onlyinclude>', onlyincludeRight = '</onlyinclude>', { length } = onlyincludeLeft, getExtRegex = [false, true].map(includeOnly => {
|
|
12
12
|
const noincludeRegex = includeOnly ? 'includeonly' : '(?:no|only)include', includeRegex = includeOnly ? 'noinclude' : 'includeonly';
|
|
13
|
-
return (0, common_1.getRegex)(exts => new RegExp(String.raw `<!--.*?(?:-->|$)|<${noincludeRegex}(?:\s[^>]*)?/?>|</${noincludeRegex}\s*>|<(${exts
|
|
14
|
-
})(\s[^>]*?)?(?:/>|>(.*?)</(${'\\1'}\s*)>)|<(${includeRegex})(\s[^>]*?)?(?:/>|>(.*?)(?:</(${includeRegex}\s*)>|$))`, 'gisu'));
|
|
13
|
+
return (0, common_1.getRegex)(exts => new RegExp(String.raw `<!--.*?(?:-->|$)|<${noincludeRegex}(?:\s[^>]*)?/?>|</${noincludeRegex}\s*>|<(${exts})(\s[^>]*?)?(?:/>|>(.*?)</(${'\\1'}\s*)>)|<(${includeRegex})(\s[^>]*?)?(?:/>|>(.*?)(?:</(${includeRegex}\s*)>|$))`, 'gisu'));
|
|
15
14
|
});
|
|
16
15
|
/**
|
|
17
16
|
* 更新`<onlyinclude>`和`</onlyinclude>`的位置
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.parseHrAndDoubleUnderscore = void 0;
|
|
4
4
|
const cm_util_1 = require("@bhsd/cm-util");
|
|
5
|
+
const debug_1 = require("../util/debug");
|
|
5
6
|
const hr_1 = require("../src/nowiki/hr");
|
|
6
7
|
const doubleUnderscore_1 = require("../src/nowiki/doubleUnderscore");
|
|
7
8
|
const heading_1 = require("../src/heading");
|
|
@@ -16,7 +17,7 @@ const parseHrAndDoubleUnderscore = ({ firstChild: { data }, type, name }, config
|
|
|
16
17
|
config.insensitiveDoubleUnderscore ??= new Set(insensitive.filter(cm_util_1.isUnderscore));
|
|
17
18
|
config.sensitiveDoubleUnderscore ??= new Set(sensitive.filter(cm_util_1.isUnderscore));
|
|
18
19
|
config.regexHrAndDoubleUnderscore ??= new RegExp(String.raw `^((?:\0\d+[cno]\x7F)*)(-{4,})|__(${all.filter(cm_util_1.isUnderscore).join('|')})__|_{2}(${all.filter(s => !(0, cm_util_1.isUnderscore)(s)).map(s => s.slice(2, -2)).join('|')})_{2}`, 'gimu');
|
|
19
|
-
if (type !== 'root' && (type !== 'ext-inner' ||
|
|
20
|
+
if (type !== 'root' && (type !== 'ext-inner' || !(0, debug_1.isIsolated)(name))) {
|
|
20
21
|
data = `\0${data}`;
|
|
21
22
|
}
|
|
22
23
|
data = data.replace(config.regexHrAndDoubleUnderscore, (m, p1, p2, p3, p4) => {
|
|
@@ -41,6 +42,6 @@ const parseHrAndDoubleUnderscore = ({ firstChild: { data }, type, name }, config
|
|
|
41
42
|
return text;
|
|
42
43
|
});
|
|
43
44
|
}
|
|
44
|
-
return type === 'root' || type === 'ext-inner' && name
|
|
45
|
+
return type === 'root' || type === 'ext-inner' && (0, debug_1.isIsolated)(name) ? data : data.slice(1);
|
|
45
46
|
};
|
|
46
47
|
exports.parseHrAndDoubleUnderscore = parseHrAndDoubleUnderscore;
|
package/dist/parser/table.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.parseTable = void 0;
|
|
4
|
+
const debug_1 = require("../util/debug");
|
|
4
5
|
const index_1 = require("../src/index");
|
|
5
6
|
const index_2 = require("../src/table/index");
|
|
6
7
|
const tr_1 = require("../src/table/tr");
|
|
@@ -25,7 +26,7 @@ const pop = (top, stack) => top.is('td') ? stack.pop() : top;
|
|
|
25
26
|
*/
|
|
26
27
|
const parseTable = ({ firstChild: { data }, type, name }, config, accum) => {
|
|
27
28
|
const stack = [], lines = data.split('\n');
|
|
28
|
-
let out = type === 'root' || type === 'parameter-value' || type === 'ext-inner' && name
|
|
29
|
+
let out = type === 'root' || type === 'parameter-value' || type === 'ext-inner' && (0, debug_1.isIsolated)(name)
|
|
29
30
|
? ''
|
|
30
31
|
: `\n${lines.shift()}`, top;
|
|
31
32
|
/**
|
package/dist/src/arg.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ import type { Config, LintError } from '../base';
|
|
|
6
6
|
* argument wrapped in `{{{}}}`
|
|
7
7
|
*
|
|
8
8
|
* `{{{}}}`包裹的参数
|
|
9
|
-
* @classdesc `{childNodes: [AtomToken,
|
|
9
|
+
* @classdesc `{childNodes: [AtomToken] | [AtomToken, Token, ...HiddenToken[]]}`
|
|
10
10
|
*/
|
|
11
11
|
export declare abstract class ArgToken extends Token {
|
|
12
12
|
#private;
|
package/dist/src/arg.js
CHANGED
|
@@ -51,7 +51,7 @@ const hidden_1 = require("./hidden");
|
|
|
51
51
|
* argument wrapped in `{{{}}}`
|
|
52
52
|
*
|
|
53
53
|
* `{{{}}}`包裹的参数
|
|
54
|
-
* @classdesc `{childNodes: [AtomToken,
|
|
54
|
+
* @classdesc `{childNodes: [AtomToken] | [AtomToken, Token, ...HiddenToken[]]}`
|
|
55
55
|
*/
|
|
56
56
|
let ArgToken = (() => {
|
|
57
57
|
let _classDecorators = [noEscape_1.noEscape, (0, padded_1.padded)('{{{'), (0, gapped_1.gapped)()];
|
package/dist/src/attributes.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ import type { ExtToken, HtmlToken, SyntaxToken } from '../internal';
|
|
|
7
7
|
import type { AttributeTypes } from './attribute';
|
|
8
8
|
import type { TableTokens } from './table/index';
|
|
9
9
|
declare type AttributesTypes = `${AttributeTypes}s`;
|
|
10
|
+
declare type Child = AtomToken | AttributeToken;
|
|
10
11
|
/**
|
|
11
12
|
* 将属性类型转换为单属性类型
|
|
12
13
|
* @param type 属性类型
|
|
@@ -21,9 +22,9 @@ export declare const toAttributeType: (type: AttributesTypes) => AttributeTypes;
|
|
|
21
22
|
export declare abstract class AttributesToken extends Token {
|
|
22
23
|
#private;
|
|
23
24
|
readonly name: string;
|
|
24
|
-
readonly childNodes: readonly
|
|
25
|
-
abstract get firstChild():
|
|
26
|
-
abstract get lastChild():
|
|
25
|
+
readonly childNodes: readonly Child[];
|
|
26
|
+
abstract get firstChild(): Child | undefined;
|
|
27
|
+
abstract get lastChild(): Child | undefined;
|
|
27
28
|
abstract get parentNode(): ExtToken | HtmlToken | TableTokens | undefined;
|
|
28
29
|
abstract get previousSibling(): SyntaxToken | undefined;
|
|
29
30
|
get type(): AttributesTypes;
|
package/dist/src/converter.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ import type { Config } from '../base';
|
|
|
6
6
|
* language conversion
|
|
7
7
|
*
|
|
8
8
|
* 转换
|
|
9
|
-
* @classdesc `{childNodes: [ConverterFlagsToken, ...ConverterRuleToken[]]}`
|
|
9
|
+
* @classdesc `{childNodes: [ConverterFlagsToken, ConverterRuleToken, ...ConverterRuleToken[]]}`
|
|
10
10
|
*/
|
|
11
11
|
export declare abstract class ConverterToken extends Token {
|
|
12
12
|
readonly childNodes: readonly [ConverterFlagsToken, ConverterRuleToken, ...ConverterRuleToken[]];
|
package/dist/src/converter.js
CHANGED
|
@@ -45,7 +45,7 @@ const converterRule_1 = require("./converterRule");
|
|
|
45
45
|
* language conversion
|
|
46
46
|
*
|
|
47
47
|
* 转换
|
|
48
|
-
* @classdesc `{childNodes: [ConverterFlagsToken, ...ConverterRuleToken[]]}`
|
|
48
|
+
* @classdesc `{childNodes: [ConverterFlagsToken, ConverterRuleToken, ...ConverterRuleToken[]]}`
|
|
49
49
|
*/
|
|
50
50
|
let ConverterToken = (() => {
|
|
51
51
|
let _classDecorators = [noEscape_1.noEscape, (0, padded_1.padded)('-{')];
|
|
@@ -6,7 +6,7 @@ import type { ConverterToken, ConverterFlagsToken } from '../internal';
|
|
|
6
6
|
* language conversion rule
|
|
7
7
|
*
|
|
8
8
|
* 转换规则
|
|
9
|
-
* @classdesc `{childNodes: [Token?, AtomToken
|
|
9
|
+
* @classdesc `{childNodes: [Token] | [Token?, AtomToken, Token]}`
|
|
10
10
|
*/
|
|
11
11
|
export declare abstract class ConverterRuleToken extends Token {
|
|
12
12
|
readonly childNodes: readonly [Token] | readonly [AtomToken, Token] | readonly [Token, AtomToken, Token];
|
|
@@ -60,7 +60,7 @@ const getRuleFromTo = (text, type, config, accum) => {
|
|
|
60
60
|
* language conversion rule
|
|
61
61
|
*
|
|
62
62
|
* 转换规则
|
|
63
|
-
* @classdesc `{childNodes: [Token?, AtomToken
|
|
63
|
+
* @classdesc `{childNodes: [Token] | [Token?, AtomToken, Token]}`
|
|
64
64
|
*/
|
|
65
65
|
let ConverterRuleToken = (() => {
|
|
66
66
|
let _classDecorators = [noEscape_1.noEscape];
|
package/dist/src/extLink.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ import type { Config, LintError } from '../base';
|
|
|
5
5
|
* external link
|
|
6
6
|
*
|
|
7
7
|
* 外链
|
|
8
|
-
* @classdesc `{childNodes: [MagicLinkToken, ?
|
|
8
|
+
* @classdesc `{childNodes: [MagicLinkToken, Token?]}`
|
|
9
9
|
*/
|
|
10
10
|
export declare abstract class ExtLinkToken extends Token {
|
|
11
11
|
#private;
|
package/dist/src/extLink.js
CHANGED
|
@@ -48,7 +48,7 @@ const magicLink_1 = require("./magicLink");
|
|
|
48
48
|
* external link
|
|
49
49
|
*
|
|
50
50
|
* 外链
|
|
51
|
-
* @classdesc `{childNodes: [MagicLinkToken, ?
|
|
51
|
+
* @classdesc `{childNodes: [MagicLinkToken, Token?]}`
|
|
52
52
|
*/
|
|
53
53
|
let ExtLinkToken = (() => {
|
|
54
54
|
let _classDecorators = [(0, padded_1.padded)('[')];
|
package/dist/src/index.js
CHANGED
|
@@ -55,7 +55,7 @@ const debug_1 = require("../util/debug");
|
|
|
55
55
|
const index_1 = __importDefault(require("../index"));
|
|
56
56
|
const element_1 = require("../lib/element");
|
|
57
57
|
const text_1 = require("../lib/text");
|
|
58
|
-
const lintSelectors = ['category', 'html-attr#id,ext-attr#id,table-attr#id'];
|
|
58
|
+
const lintSelectors = ['category', 'html-attr#id,ext-attr#id,table-attr#id', 'ext#indicator'];
|
|
59
59
|
/**
|
|
60
60
|
* base class for all tokens
|
|
61
61
|
*
|
|
@@ -302,7 +302,7 @@ class Token extends element_1.AstElement {
|
|
|
302
302
|
}
|
|
303
303
|
const { parseList } = require('../parser/list');
|
|
304
304
|
const { firstChild, type, name } = this, lines = firstChild.toString().split('\n'), state = { lastPrefix: '' };
|
|
305
|
-
let i = type === 'root' || type === 'ext-inner' && name
|
|
305
|
+
let i = type === 'root' || type === 'ext-inner' && (0, debug_1.isIsolated)(name) ? 0 : 1;
|
|
306
306
|
for (; i < lines.length; i++) {
|
|
307
307
|
lines[i] = parseList(lines[i], state, this.#config, this.#accum);
|
|
308
308
|
}
|
|
@@ -386,18 +386,24 @@ class Token extends element_1.AstElement {
|
|
|
386
386
|
const { lintConfig } = index_1.default, { computeEditInfo, fix: needFix, ignoreDisables, configurationComment } = lintConfig;
|
|
387
387
|
let errors = super.lint(start, re);
|
|
388
388
|
if (this.type === 'root') {
|
|
389
|
-
const
|
|
390
|
-
|
|
389
|
+
const r = 'no-duplicate', s = ['category', 'id', 'indicator'].map(key => lintConfig.getSeverity(r, key)), msgs = ['category', 'id', 'name'], wikitext = this.toString();
|
|
390
|
+
for (let i = 0; i < s.length; i++) {
|
|
391
|
+
const severity = s[i];
|
|
392
|
+
if (!severity) {
|
|
393
|
+
continue;
|
|
394
|
+
}
|
|
395
|
+
const record = new Map(), selector = lintSelectors[i];
|
|
391
396
|
for (const cat of this.querySelectorAll(selector)) {
|
|
392
397
|
let key;
|
|
393
|
-
if (
|
|
398
|
+
if (i === 0) { // category
|
|
394
399
|
key = cat.name;
|
|
395
400
|
}
|
|
396
|
-
else {
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
+
else if (i === 1) { // id
|
|
402
|
+
key = cat.getValue().replace(/\s+/gu, '_');
|
|
403
|
+
}
|
|
404
|
+
else { // indicator
|
|
405
|
+
key = cat.getAttr('name')
|
|
406
|
+
?.replace(/\s+/gu, '_');
|
|
401
407
|
}
|
|
402
408
|
if (key) {
|
|
403
409
|
const thisCat = record.get(key);
|
|
@@ -410,11 +416,10 @@ class Token extends element_1.AstElement {
|
|
|
410
416
|
}
|
|
411
417
|
}
|
|
412
418
|
for (const [key, value] of record) {
|
|
413
|
-
if (value.size > 1 && !key.startsWith('
|
|
414
|
-
const isCat = !key.startsWith('#'), msg = `duplicate-${isCat ? 'category' : 'id'}`, severity = s[isCat ? 0 : 1];
|
|
419
|
+
if (value.size > 1 && (i !== 1 || !key.startsWith('mw-customcollapsible-'))) {
|
|
415
420
|
errors.push(...[...value].map(cat => {
|
|
416
|
-
const e = (0, lint_1.generateForSelf)(cat, { start: cat.getAbsoluteIndex() }, r,
|
|
417
|
-
if (computeEditInfo &&
|
|
421
|
+
const e = (0, lint_1.generateForSelf)(cat, { start: cat.getAbsoluteIndex() }, r, `duplicate-${msgs[i]}`, severity);
|
|
422
|
+
if (computeEditInfo && i === 0) {
|
|
418
423
|
e.suggestions = [(0, lint_1.fixByRemove)(e)];
|
|
419
424
|
}
|
|
420
425
|
return e;
|
|
@@ -496,5 +501,40 @@ class Token extends element_1.AstElement {
|
|
|
496
501
|
}
|
|
497
502
|
});
|
|
498
503
|
}
|
|
504
|
+
/**
|
|
505
|
+
* 构建列表
|
|
506
|
+
* @param recursive 是否递归
|
|
507
|
+
*/
|
|
508
|
+
#buildLists(recursive) {
|
|
509
|
+
PRINT: for (let i = 0; i < this.length; i++) {
|
|
510
|
+
const child = this.childNodes[i];
|
|
511
|
+
if (child.is('list') || child.is('dd')) {
|
|
512
|
+
child.getRange();
|
|
513
|
+
}
|
|
514
|
+
else if (recursive && child.type !== 'text') {
|
|
515
|
+
child.#buildLists(true);
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
/** @private */
|
|
520
|
+
buildLists() {
|
|
521
|
+
PRINT: this.#buildLists(true);
|
|
522
|
+
}
|
|
523
|
+
/** @private */
|
|
524
|
+
concat(elements) {
|
|
525
|
+
PRINT: {
|
|
526
|
+
if (elements.length === 0) {
|
|
527
|
+
return;
|
|
528
|
+
}
|
|
529
|
+
const { childNodes, lastChild } = this, first = elements[0], last = elements.at(-1);
|
|
530
|
+
for (const element of elements) {
|
|
531
|
+
element.setAttribute('parentNode', this);
|
|
532
|
+
}
|
|
533
|
+
lastChild?.setAttribute('nextSibling', first);
|
|
534
|
+
first.setAttribute('previousSibling', lastChild);
|
|
535
|
+
last.setAttribute('nextSibling', undefined);
|
|
536
|
+
this.setAttribute('childNodes', [...childNodes, ...elements]);
|
|
537
|
+
}
|
|
538
|
+
}
|
|
499
539
|
}
|
|
500
540
|
exports.Token = Token;
|
|
@@ -5,7 +5,7 @@ import type { Token, AtomToken } from '../../internal';
|
|
|
5
5
|
* category
|
|
6
6
|
*
|
|
7
7
|
* 分类
|
|
8
|
-
* @classdesc `{childNodes: [AtomToken, ?
|
|
8
|
+
* @classdesc `{childNodes: [AtomToken, Token?]}`
|
|
9
9
|
*/
|
|
10
10
|
export declare abstract class CategoryToken extends LinkBaseToken {
|
|
11
11
|
readonly childNodes: readonly [AtomToken] | readonly [AtomToken, Token];
|
package/dist/src/link/index.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ import type { Token, AtomToken } from '../../internal';
|
|
|
6
6
|
* internal link
|
|
7
7
|
*
|
|
8
8
|
* 内链
|
|
9
|
-
* @classdesc `{childNodes: [AtomToken, ?
|
|
9
|
+
* @classdesc `{childNodes: [AtomToken, Token?]}`
|
|
10
10
|
*/
|
|
11
11
|
export declare abstract class LinkToken extends LinkBaseToken {
|
|
12
12
|
readonly childNodes: readonly [AtomToken] | readonly [AtomToken, Token];
|
package/dist/src/link/index.js
CHANGED