wikilint 2.32.0 → 2.34.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/dist/base.d.mts +1 -1
- package/dist/base.d.ts +1 -1
- package/dist/base.js +1 -0
- package/dist/base.mjs +1 -0
- package/dist/bin/cli.js +8 -19
- package/dist/bin/config.js +1 -1
- package/dist/index.js +3 -5
- package/dist/internal.d.ts +3 -0
- package/dist/lib/lintConfig.js +8 -0
- package/dist/lib/lsp.js +20 -3
- package/dist/lib/node.js +3 -11
- package/dist/lib/text.js +18 -18
- package/dist/src/attribute.d.ts +3 -5
- package/dist/src/attribute.js +11 -9
- package/dist/src/attributes.d.ts +0 -1
- package/dist/src/attributes.js +4 -5
- package/dist/src/imageParameter.d.ts +7 -3
- package/dist/src/imageParameter.js +14 -4
- package/dist/src/index.d.ts +8 -0
- package/dist/src/index.js +22 -20
- package/dist/src/link/base.d.ts +1 -1
- package/dist/src/link/base.js +7 -1
- package/dist/src/link/categorytree.d.ts +19 -0
- package/dist/src/link/categorytree.js +95 -0
- package/dist/src/link/file.d.ts +3 -2
- package/dist/src/link/file.js +3 -2
- package/dist/src/link/galleryImage.js +5 -4
- package/dist/src/multiLine/gallery.d.ts +1 -3
- package/dist/src/multiLine/gallery.js +1 -3
- package/dist/src/multiLine/imagemap.js +2 -3
- package/dist/src/multiLine/inputbox.d.ts +3 -3
- package/dist/src/multiLine/inputbox.js +3 -7
- package/dist/src/multiLine/paramTag.d.ts +3 -4
- package/dist/src/multiLine/paramTag.js +5 -47
- package/dist/src/nowiki/index.js +48 -13
- package/dist/src/nowiki/list.d.ts +0 -1
- package/dist/src/nowiki/list.js +1 -0
- package/dist/src/nowiki/noinclude.d.ts +0 -1
- package/dist/src/nowiki/noinclude.js +1 -0
- package/dist/src/paramLine.d.ts +3 -0
- package/dist/src/paramLine.js +43 -2
- package/dist/src/table/base.d.ts +1 -2
- package/dist/src/table/base.js +7 -8
- package/dist/src/table/index.d.ts +1 -1
- package/dist/src/table/index.js +1 -7
- package/dist/src/table/td.d.ts +0 -1
- package/dist/src/table/td.js +1 -0
- package/dist/src/table/tr.d.ts +1 -1
- package/dist/src/tagPair/ext.js +19 -10
- package/dist/src/tagPair/index.d.ts +2 -1
- package/dist/src/tagPair/index.js +10 -6
- package/dist/src/tagPair/translate.d.ts +1 -1
- package/dist/src/tagPair/translate.js +3 -0
- package/dist/util/debug.js +10 -3
- package/dist/util/diff.js +6 -17
- package/dist/util/sharable.d.mts +1 -0
- package/dist/util/sharable.js +62 -1
- package/dist/util/sharable.mjs +62 -0
- package/i18n/en.json +2 -0
- package/i18n/zh-hans.json +2 -0
- package/i18n/zh-hant.json +2 -0
- package/package.json +3 -3
package/dist/src/link/base.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ import type { Title } from '../../lib/title';
|
|
|
11
11
|
export declare abstract class LinkBaseToken extends Token {
|
|
12
12
|
#private;
|
|
13
13
|
readonly name: string;
|
|
14
|
-
abstract get type(): 'link' | 'category' | 'file' | 'gallery-image' | 'imagemap-image' | 'redirect-target';
|
|
14
|
+
abstract get type(): 'link' | 'category' | 'file' | 'gallery-image' | 'imagemap-image' | 'redirect-target' | 'ext-inner';
|
|
15
15
|
readonly childNodes: readonly [AtomToken, ...Token[]];
|
|
16
16
|
abstract get firstChild(): AtomToken;
|
|
17
17
|
abstract get lastChild(): Token;
|
package/dist/src/link/base.js
CHANGED
|
@@ -91,13 +91,19 @@ let LinkBaseToken = (() => {
|
|
|
91
91
|
}
|
|
92
92
|
this.#delimiter = delimiter;
|
|
93
93
|
}
|
|
94
|
+
/** 更新name */
|
|
95
|
+
#setName() {
|
|
96
|
+
if (this.type !== 'ext-inner') {
|
|
97
|
+
this.setAttribute('name', this.#title.title);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
94
100
|
/** @private */
|
|
95
101
|
afterBuild() {
|
|
96
102
|
this.#title = this.getTitle();
|
|
97
103
|
if (this.#delimiter.includes('\0')) {
|
|
98
104
|
this.#delimiter = this.buildFromStr(this.#delimiter, constants_1.BuildMethod.String);
|
|
99
105
|
}
|
|
100
|
-
this
|
|
106
|
+
this.#setName();
|
|
101
107
|
super.afterBuild();
|
|
102
108
|
}
|
|
103
109
|
/** @private */
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { LinkBaseToken } from './base';
|
|
2
|
+
import type { Config, LintError } from '../../base';
|
|
3
|
+
import type { Title } from '../../lib/title';
|
|
4
|
+
import type { Token, AtomToken, AttributesToken, ExtToken } from '../../internal';
|
|
5
|
+
/**
|
|
6
|
+
* `<categorytree>`
|
|
7
|
+
* @classdesc `{childNodes: [AtomToken]}`
|
|
8
|
+
*/
|
|
9
|
+
export declare abstract class CategorytreeToken extends LinkBaseToken {
|
|
10
|
+
readonly childNodes: readonly [AtomToken];
|
|
11
|
+
abstract get lastChild(): AtomToken;
|
|
12
|
+
abstract get nextSibling(): undefined;
|
|
13
|
+
abstract get previousSibling(): AttributesToken | undefined;
|
|
14
|
+
abstract get parentNode(): ExtToken | undefined;
|
|
15
|
+
abstract get link(): Title;
|
|
16
|
+
get type(): 'ext-inner';
|
|
17
|
+
/** @param link 链接标题 */
|
|
18
|
+
constructor(link: string, linkText?: undefined, config?: Config, accum?: Token[]);
|
|
19
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
|
3
|
+
function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
|
|
4
|
+
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
|
5
|
+
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
|
|
6
|
+
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
|
|
7
|
+
var _, done = false;
|
|
8
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
9
|
+
var context = {};
|
|
10
|
+
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
|
|
11
|
+
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
|
|
12
|
+
context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
|
|
13
|
+
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
|
|
14
|
+
if (kind === "accessor") {
|
|
15
|
+
if (result === void 0) continue;
|
|
16
|
+
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
|
|
17
|
+
if (_ = accept(result.get)) descriptor.get = _;
|
|
18
|
+
if (_ = accept(result.set)) descriptor.set = _;
|
|
19
|
+
if (_ = accept(result.init)) initializers.unshift(_);
|
|
20
|
+
}
|
|
21
|
+
else if (_ = accept(result)) {
|
|
22
|
+
if (kind === "field") initializers.unshift(_);
|
|
23
|
+
else descriptor[key] = _;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
27
|
+
done = true;
|
|
28
|
+
};
|
|
29
|
+
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
|
|
30
|
+
var useValue = arguments.length > 2;
|
|
31
|
+
for (var i = 0; i < initializers.length; i++) {
|
|
32
|
+
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
|
33
|
+
}
|
|
34
|
+
return useValue ? value : void 0;
|
|
35
|
+
};
|
|
36
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
37
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
38
|
+
};
|
|
39
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
|
+
exports.CategorytreeToken = void 0;
|
|
41
|
+
const lint_1 = require("../../util/lint");
|
|
42
|
+
const padded_1 = require("../../mixin/padded");
|
|
43
|
+
const index_1 = __importDefault(require("../../index"));
|
|
44
|
+
const base_1 = require("./base");
|
|
45
|
+
/**
|
|
46
|
+
* `<categorytree>`
|
|
47
|
+
* @classdesc `{childNodes: [AtomToken]}`
|
|
48
|
+
*/
|
|
49
|
+
let CategorytreeToken = (() => {
|
|
50
|
+
let _classDecorators = [(0, padded_1.padded)('')];
|
|
51
|
+
let _classDescriptor;
|
|
52
|
+
let _classExtraInitializers = [];
|
|
53
|
+
let _classThis;
|
|
54
|
+
let _classSuper = base_1.LinkBaseToken;
|
|
55
|
+
var CategorytreeToken = class extends _classSuper {
|
|
56
|
+
static { _classThis = this; }
|
|
57
|
+
static {
|
|
58
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
59
|
+
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
60
|
+
CategorytreeToken = _classThis = _classDescriptor.value;
|
|
61
|
+
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
62
|
+
__runInitializers(_classThis, _classExtraInitializers);
|
|
63
|
+
}
|
|
64
|
+
get type() {
|
|
65
|
+
return 'ext-inner';
|
|
66
|
+
}
|
|
67
|
+
/** @param link 链接标题 */
|
|
68
|
+
constructor(link, linkText, config, accum = []) {
|
|
69
|
+
super(link, linkText, config, accum);
|
|
70
|
+
this.setAttribute('bracket', false);
|
|
71
|
+
}
|
|
72
|
+
/** @private */
|
|
73
|
+
getTitle() {
|
|
74
|
+
const target = this.firstChild.toString().trim(), opt = { halfParsed: true }, title = this.normalizeTitle(target, 14, opt);
|
|
75
|
+
return title.valid && title.ns === 14
|
|
76
|
+
? title
|
|
77
|
+
: this.normalizeTitle(`Category:${target}`, 0, opt);
|
|
78
|
+
}
|
|
79
|
+
/** @private */
|
|
80
|
+
lint(start = this.getAbsoluteIndex()) {
|
|
81
|
+
LINT: {
|
|
82
|
+
const rule = 'no-ignored', s = index_1.default.lintConfig.getSeverity(rule, 'categorytree');
|
|
83
|
+
if (s) {
|
|
84
|
+
const { link } = this;
|
|
85
|
+
if (!link.valid || link.ns !== 14) {
|
|
86
|
+
return [(0, lint_1.generateForSelf)(this, { start }, rule, 'invalid-category', s)];
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return super.lint(start, false);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
return CategorytreeToken = _classThis;
|
|
94
|
+
})();
|
|
95
|
+
exports.CategorytreeToken = CategorytreeToken;
|
package/dist/src/link/file.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { LinkBaseToken } from './base';
|
|
2
2
|
import { ImageParameterToken } from '../imageParameter';
|
|
3
|
-
import type { Config, LintError } from '../../base';
|
|
3
|
+
import type { TokenTypes, Config, LintError } from '../../base';
|
|
4
4
|
import type { Token, AtomToken } from '../../internal';
|
|
5
5
|
/**
|
|
6
6
|
* image
|
|
@@ -23,8 +23,9 @@ export declare abstract class FileToken extends LinkBaseToken {
|
|
|
23
23
|
* @param link 文件名
|
|
24
24
|
* @param text 图片参数
|
|
25
25
|
* @param delimiter `|`
|
|
26
|
+
* @param type 节点类型
|
|
26
27
|
*/
|
|
27
|
-
constructor(link: string, text?: string, config?: Config, accum?: Token[], delimiter?: string);
|
|
28
|
+
constructor(link: string, text?: string, config?: Config, accum?: Token[], delimiter?: string, type?: TokenTypes);
|
|
28
29
|
/**
|
|
29
30
|
* Get all image parameter tokens
|
|
30
31
|
*
|
package/dist/src/link/file.js
CHANGED
|
@@ -69,13 +69,14 @@ class FileToken extends base_1.LinkBaseToken {
|
|
|
69
69
|
* @param link 文件名
|
|
70
70
|
* @param text 图片参数
|
|
71
71
|
* @param delimiter `|`
|
|
72
|
+
* @param type 节点类型
|
|
72
73
|
*/
|
|
73
|
-
constructor(link, text, config, accum = [], delimiter = '|') {
|
|
74
|
+
constructor(link, text, config, accum = [], delimiter = '|', type) {
|
|
74
75
|
super(link, undefined, config, accum, delimiter);
|
|
75
76
|
const { extension } = this.getTitle(true, true);
|
|
76
77
|
this.safeAppend(explode(text).map(
|
|
77
78
|
// @ts-expect-error abstract class
|
|
78
|
-
(part) => new imageParameter_1.ImageParameterToken(part, extension, config, accum)));
|
|
79
|
+
(part) => new imageParameter_1.ImageParameterToken(part, extension, type, config, accum)));
|
|
79
80
|
}
|
|
80
81
|
/** @private */
|
|
81
82
|
lint(start = this.getAbsoluteIndex(), re) {
|
|
@@ -84,9 +84,10 @@ let GalleryImageToken = (() => {
|
|
|
84
84
|
}
|
|
85
85
|
accum.splice(length, 1);
|
|
86
86
|
}
|
|
87
|
-
|
|
87
|
+
const privateType = `${type}-image`;
|
|
88
|
+
super(link, token?.firstChild.toString(), config, accum, undefined, privateType);
|
|
88
89
|
this.setAttribute('bracket', false);
|
|
89
|
-
this.privateType =
|
|
90
|
+
this.privateType = privateType;
|
|
90
91
|
}
|
|
91
92
|
/** @private */
|
|
92
93
|
getTitle(temporary) {
|
|
@@ -95,9 +96,9 @@ let GalleryImageToken = (() => {
|
|
|
95
96
|
}
|
|
96
97
|
/** 判定无效的图片 */
|
|
97
98
|
#lint() {
|
|
98
|
-
const
|
|
99
|
+
const title = this.getAttribute('title');
|
|
99
100
|
// eslint-disable-next-line @stylistic/semi
|
|
100
|
-
return ns !== 6;
|
|
101
|
+
return title.ns !== 6;
|
|
101
102
|
}
|
|
102
103
|
/** @private */
|
|
103
104
|
lint(start = this.getAbsoluteIndex(), re) {
|
|
@@ -4,9 +4,7 @@ import { CommentLineToken } from '../nowiki/commentLine';
|
|
|
4
4
|
import type { Config, LintError } from '../../base';
|
|
5
5
|
import type { AstText, Token } from '../../internal';
|
|
6
6
|
/**
|
|
7
|
-
* gallery
|
|
8
|
-
*
|
|
9
|
-
* gallery标签
|
|
7
|
+
* `<gallery>`
|
|
10
8
|
* @classdesc `{childNodes: (GalleryImageToken|CommentLineToken|AstText)[]}`
|
|
11
9
|
*/
|
|
12
10
|
export declare abstract class GalleryToken extends MultiLineToken {
|
|
@@ -10,9 +10,7 @@ const index_2 = require("./index");
|
|
|
10
10
|
const galleryImage_1 = require("../link/galleryImage");
|
|
11
11
|
const commentLine_1 = require("../nowiki/commentLine");
|
|
12
12
|
/**
|
|
13
|
-
* gallery
|
|
14
|
-
*
|
|
15
|
-
* gallery标签
|
|
13
|
+
* `<gallery>`
|
|
16
14
|
* @classdesc `{childNodes: (GalleryImageToken|CommentLineToken|AstText)[]}`
|
|
17
15
|
*/
|
|
18
16
|
class GalleryToken extends index_2.MultiLineToken {
|
|
@@ -35,9 +35,8 @@ class ImagemapToken extends index_2.MultiLineToken {
|
|
|
35
35
|
//
|
|
36
36
|
}
|
|
37
37
|
else if (first) {
|
|
38
|
-
const pipe = line.indexOf('|'), file = pipe === -1 ? line : line.slice(0, pipe),
|
|
39
|
-
if (valid
|
|
40
|
-
&& ns === 6) {
|
|
38
|
+
const pipe = line.indexOf('|'), file = pipe === -1 ? line : line.slice(0, pipe), title = this.normalizeTitle(file, 0, { halfParsed: true, temporary: true, page: '' });
|
|
39
|
+
if (title.valid && title.ns === 6) {
|
|
41
40
|
// @ts-expect-error abstract class
|
|
42
41
|
const token = new galleryImage_1.GalleryImageToken('imagemap', file, pipe === -1 ? undefined : line.slice(pipe + 1), config, accum);
|
|
43
42
|
super.insertAt(token);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import Parser from '../../index';
|
|
2
1
|
import { ParamTagToken } from './paramTag';
|
|
2
|
+
import type { Config } from '../../base';
|
|
3
3
|
import type { Token } from '../../internal';
|
|
4
4
|
/** `<inputbox>` */
|
|
5
5
|
export declare abstract class InputboxToken extends ParamTagToken {
|
|
6
|
-
/** @
|
|
7
|
-
constructor(include: boolean, wikitext
|
|
6
|
+
/** @param name 扩展标签名 */
|
|
7
|
+
constructor(name: string, include: boolean, wikitext: string | undefined, config: Config, accum?: Token[]);
|
|
8
8
|
}
|
|
@@ -1,17 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.InputboxToken = void 0;
|
|
7
4
|
const commentAndExt_1 = require("../../parser/commentAndExt");
|
|
8
5
|
const braces_1 = require("../../parser/braces");
|
|
9
|
-
const index_1 = __importDefault(require("../../index"));
|
|
10
6
|
const paramTag_1 = require("./paramTag");
|
|
11
7
|
/** `<inputbox>` */
|
|
12
8
|
class InputboxToken extends paramTag_1.ParamTagToken {
|
|
13
|
-
/** @
|
|
14
|
-
constructor(include, wikitext, config
|
|
9
|
+
/** @param name 扩展标签名 */
|
|
10
|
+
constructor(name, include, wikitext, config, accum = []) {
|
|
15
11
|
const placeholder = Symbol('InputboxToken'), newConfig = config.excludes.includes('heading')
|
|
16
12
|
? config
|
|
17
13
|
: {
|
|
@@ -22,7 +18,7 @@ class InputboxToken extends paramTag_1.ParamTagToken {
|
|
|
22
18
|
wikitext &&= (0, commentAndExt_1.parseCommentAndExt)(wikitext, newConfig, accum, include);
|
|
23
19
|
wikitext &&= (0, braces_1.parseBraces)(wikitext, newConfig, accum);
|
|
24
20
|
accum.splice(length, 1);
|
|
25
|
-
super(include, wikitext, newConfig, accum, {});
|
|
21
|
+
super(name, include, wikitext, newConfig, accum, {});
|
|
26
22
|
}
|
|
27
23
|
}
|
|
28
24
|
exports.InputboxToken = InputboxToken;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import Parser from '../../index';
|
|
2
1
|
import { MultiLineToken } from './index';
|
|
3
2
|
import { ParamLineToken } from '../paramLine';
|
|
4
|
-
import type {
|
|
3
|
+
import type { Config } from '../../base';
|
|
5
4
|
import type { Token } from '../../internal';
|
|
6
5
|
/**
|
|
7
6
|
* `<dynamicpagelist>`
|
|
@@ -11,6 +10,6 @@ export declare abstract class ParamTagToken extends MultiLineToken {
|
|
|
11
10
|
readonly childNodes: readonly ParamLineToken[];
|
|
12
11
|
abstract get firstChild(): ParamLineToken | undefined;
|
|
13
12
|
abstract get lastChild(): ParamLineToken | undefined;
|
|
14
|
-
/** @
|
|
15
|
-
constructor(include: boolean, wikitext
|
|
13
|
+
/** @param name 扩展标签名 */
|
|
14
|
+
constructor(name: string, include: boolean, wikitext: string | undefined, config: Config, accum?: Token[], acceptable?: WikiParserAcceptable);
|
|
16
15
|
}
|
|
@@ -1,67 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.ParamTagToken = void 0;
|
|
7
|
-
const lint_1 = require("../../util/lint");
|
|
8
|
-
const rect_1 = require("../../lib/rect");
|
|
9
4
|
const commentAndExt_1 = require("../../parser/commentAndExt");
|
|
10
|
-
const index_1 =
|
|
11
|
-
const index_2 = require("./index");
|
|
5
|
+
const index_1 = require("./index");
|
|
12
6
|
const paramLine_1 = require("../paramLine");
|
|
13
7
|
/**
|
|
14
8
|
* `<dynamicpagelist>`
|
|
15
9
|
* @classdesc `{childNodes: ParamLineToken[]}`
|
|
16
10
|
*/
|
|
17
|
-
class ParamTagToken extends
|
|
18
|
-
/** @
|
|
19
|
-
constructor(include, wikitext, config
|
|
11
|
+
class ParamTagToken extends index_1.MultiLineToken {
|
|
12
|
+
/** @param name 扩展标签名 */
|
|
13
|
+
constructor(name, include, wikitext, config, accum = [], acceptable) {
|
|
20
14
|
super(undefined, config, accum, {});
|
|
21
15
|
if (wikitext) {
|
|
22
16
|
this.safeAppend(wikitext.split('\n')
|
|
23
17
|
.map(line => acceptable ? line : (0, commentAndExt_1.parseCommentAndExt)(line, config, accum, include))
|
|
24
18
|
// @ts-expect-error abstract class
|
|
25
|
-
.map((line) => new paramLine_1.ParamLineToken(line, config, accum, {})));
|
|
19
|
+
.map((line) => new paramLine_1.ParamLineToken(name, line, config, accum, {})));
|
|
26
20
|
}
|
|
27
21
|
accum.splice(accum.indexOf(this), 1);
|
|
28
22
|
accum.push(this);
|
|
29
23
|
}
|
|
30
|
-
/** @private */
|
|
31
|
-
lint(start = this.getAbsoluteIndex()) {
|
|
32
|
-
LINT: {
|
|
33
|
-
const rule = 'no-ignored', { lintConfig } = index_1.default, s = lintConfig.getSeverity(rule, this.name);
|
|
34
|
-
if (!s) {
|
|
35
|
-
return [];
|
|
36
|
-
}
|
|
37
|
-
const rect = new rect_1.BoundingRect(this, start), msg = index_1.default.msg('invalid-parameter', this.name), errors = [];
|
|
38
|
-
for (const child of this.childNodes) {
|
|
39
|
-
child.setAttribute('aIndex', start);
|
|
40
|
-
const grandChildren = child.childNodes
|
|
41
|
-
.filter(({ type }) => type !== 'comment' && type !== 'include' && type !== 'noinclude');
|
|
42
|
-
if (grandChildren.some(({ type }) => type === 'ext')) {
|
|
43
|
-
errors.push((0, lint_1.generateForChild)(child, rect, rule, msg, s));
|
|
44
|
-
}
|
|
45
|
-
else {
|
|
46
|
-
const i = grandChildren.findIndex(({ type }) => type !== 'text'), str = grandChildren.slice(0, i === -1 ? undefined : i).map(String).join('');
|
|
47
|
-
if (str && !(i === -1 ? /^[a-z]+(?:\[\])?\s*=/iu : /^[a-z]+(?:\[\])?\s*(?:=|$)/iu).test(str)) {
|
|
48
|
-
const e = (0, lint_1.generateForChild)(child, rect, rule, msg, s);
|
|
49
|
-
if (lintConfig.computeEditInfo) {
|
|
50
|
-
e.suggestions = [(0, lint_1.fixByRemove)(e)];
|
|
51
|
-
}
|
|
52
|
-
errors.push(e);
|
|
53
|
-
}
|
|
54
|
-
else {
|
|
55
|
-
const childErrors = child.lint(start, false);
|
|
56
|
-
if (childErrors.length > 0) {
|
|
57
|
-
Array.prototype.push.apply(errors, childErrors);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
start += child.toString().length + 1;
|
|
62
|
-
}
|
|
63
|
-
return errors;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
24
|
}
|
|
67
25
|
exports.ParamTagToken = ParamTagToken;
|
package/dist/src/nowiki/index.js
CHANGED
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.NowikiToken = void 0;
|
|
7
7
|
const common_1 = require("@bhsd/common");
|
|
8
8
|
const lint_1 = require("../../util/lint");
|
|
9
|
+
const rect_1 = require("../../lib/rect");
|
|
9
10
|
const index_1 = __importDefault(require("../../index"));
|
|
10
11
|
const base_1 = require("./base");
|
|
11
12
|
/* NOT FOR BROWSER ONLY */
|
|
@@ -42,9 +43,9 @@ class NowikiToken extends base_1.NowikiBaseToken {
|
|
|
42
43
|
/** @private */
|
|
43
44
|
lint(start = this.getAbsoluteIndex()) {
|
|
44
45
|
LINT: {
|
|
45
|
-
const { name,
|
|
46
|
+
const { name, innerText,
|
|
46
47
|
/* NOT FOR BROWSER ONLY */
|
|
47
|
-
|
|
48
|
+
previousSibling, } = this, { lintConfig } = index_1.default;
|
|
48
49
|
let rule = 'void-ext', s = lintConfig.getSeverity(rule, name);
|
|
49
50
|
if (s && this.#lint()) {
|
|
50
51
|
const e = (0, lint_1.generateForSelf)(this, { start }, rule, index_1.default.msg('nothing-in', name), s);
|
|
@@ -53,9 +54,42 @@ class NowikiToken extends base_1.NowikiBaseToken {
|
|
|
53
54
|
}
|
|
54
55
|
return [e];
|
|
55
56
|
}
|
|
56
|
-
const errors = super.lint(start, getLintRegex(name));
|
|
57
|
-
/* NOT FOR BROWSER ONLY */
|
|
58
57
|
NPM: {
|
|
58
|
+
rule = 'invalid-json';
|
|
59
|
+
const sSyntax = lintConfig.getSeverity(rule);
|
|
60
|
+
/* NOT FOR BROWSER ONLY */
|
|
61
|
+
const sDuplicate = lintConfig.getSeverity(rule, 'duplicate');
|
|
62
|
+
/* NOT FOR BROWSER ONLY END */
|
|
63
|
+
if (name === 'templatedata' && (sSyntax
|
|
64
|
+
|| sDuplicate)) {
|
|
65
|
+
// browser版本使用`lintJSONNative()`
|
|
66
|
+
return (0, common_1.lintJSON)(innerText).map(({ message, position, line, column,
|
|
67
|
+
/* NOT FOR BROWSER ONLY */
|
|
68
|
+
severity, }) => {
|
|
69
|
+
s =
|
|
70
|
+
/* eslint-disable @stylistic/operator-linebreak */
|
|
71
|
+
severity === 'warning' ?
|
|
72
|
+
sDuplicate :
|
|
73
|
+
/* eslint-enable @stylistic/operator-linebreak */
|
|
74
|
+
sSyntax;
|
|
75
|
+
if (!s) {
|
|
76
|
+
return false;
|
|
77
|
+
}
|
|
78
|
+
const rect = new rect_1.BoundingRect(this, start), startIndex = start + position, startLine = rect.top + line - 1, startCol = (line > 1 ? 0 : rect.left) + column - 1;
|
|
79
|
+
return {
|
|
80
|
+
rule,
|
|
81
|
+
message,
|
|
82
|
+
severity: s,
|
|
83
|
+
startIndex,
|
|
84
|
+
endIndex: startIndex,
|
|
85
|
+
startLine,
|
|
86
|
+
endLine: startLine,
|
|
87
|
+
startCol,
|
|
88
|
+
endCol: startCol,
|
|
89
|
+
};
|
|
90
|
+
}).filter((e) => e !== false);
|
|
91
|
+
}
|
|
92
|
+
/* NOT FOR BROWSER ONLY */
|
|
59
93
|
rule = 'invalid-math';
|
|
60
94
|
s = lintConfig.getSeverity(rule);
|
|
61
95
|
if (s && constants_1.mathTags.has(name)) {
|
|
@@ -84,20 +118,21 @@ class NowikiToken extends base_1.NowikiBaseToken {
|
|
|
84
118
|
const result = texvcjs.check(tex, {
|
|
85
119
|
usemhchem: isChem || Boolean(previousSibling?.hasAttr('chem')),
|
|
86
120
|
});
|
|
87
|
-
if (result.status
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
121
|
+
if (result.status === '+') {
|
|
122
|
+
return [];
|
|
123
|
+
}
|
|
124
|
+
const e = (0, lint_1.generateForSelf)(this, { start }, rule, 'chem-required', s);
|
|
125
|
+
if (result.status !== 'C') {
|
|
126
|
+
const { message, location } = result.error, [endIndex, endLine, endCol] = updateLocation(e, location.end, n);
|
|
127
|
+
[e.startIndex, e.startLine, e.startCol] = updateLocation(e, location.start, n);
|
|
128
|
+
Object.assign(e, { endIndex, endLine, endCol, message });
|
|
95
129
|
}
|
|
130
|
+
return [e];
|
|
96
131
|
}
|
|
97
132
|
}
|
|
98
133
|
}
|
|
99
134
|
/* NOT FOR BROWSER ONLY END */
|
|
100
|
-
return
|
|
135
|
+
return super.lint(start, getLintRegex(name));
|
|
101
136
|
}
|
|
102
137
|
}
|
|
103
138
|
}
|
package/dist/src/nowiki/list.js
CHANGED
|
@@ -17,6 +17,7 @@ class ListToken extends listBase_1.ListBaseToken {
|
|
|
17
17
|
get type() {
|
|
18
18
|
return 'list';
|
|
19
19
|
}
|
|
20
|
+
/** @private */
|
|
20
21
|
lint(start = this.getAbsoluteIndex()) {
|
|
21
22
|
LINT: {
|
|
22
23
|
const rule = 'syntax-like', s = index_1.default.lintConfig.getSeverity(rule, 'redirect'), { innerText } = this;
|
|
@@ -69,6 +69,7 @@ let NoincludeToken = (() => {
|
|
|
69
69
|
toString(skip) {
|
|
70
70
|
return skip ? '' : super.toString();
|
|
71
71
|
}
|
|
72
|
+
/** @private */
|
|
72
73
|
lint(start = this.getAbsoluteIndex()) {
|
|
73
74
|
LINT: {
|
|
74
75
|
const { lintConfig } = index_1.default, rule = 'no-ignored', s = lintConfig.getSeverity(rule, 'include');
|
package/dist/src/paramLine.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Token } from './index';
|
|
2
|
+
import type { Config, LintError } from '../base';
|
|
2
3
|
import type { ParamTagToken } from '../internal';
|
|
3
4
|
/**
|
|
4
5
|
* parameter of certain extension tags
|
|
@@ -10,4 +11,6 @@ export declare abstract class ParamLineToken extends Token {
|
|
|
10
11
|
abstract get nextSibling(): this | undefined;
|
|
11
12
|
abstract get previousSibling(): this | undefined;
|
|
12
13
|
get type(): 'param-line';
|
|
14
|
+
/** @param name 扩展标签名 */
|
|
15
|
+
constructor(name: string, wikitext: string | undefined, config: Config, accum: Token[], acceptable: WikiParserAcceptable);
|
|
13
16
|
}
|
package/dist/src/paramLine.js
CHANGED
|
@@ -1,15 +1,56 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.ParamLineToken = void 0;
|
|
4
|
-
const
|
|
7
|
+
const lint_1 = require("../util/lint");
|
|
8
|
+
const sharable_1 = require("../util/sharable");
|
|
9
|
+
const index_1 = __importDefault(require("../index"));
|
|
10
|
+
const index_2 = require("./index");
|
|
5
11
|
/**
|
|
6
12
|
* parameter of certain extension tags
|
|
7
13
|
*
|
|
8
14
|
* 某些扩展标签的参数
|
|
9
15
|
*/
|
|
10
|
-
class ParamLineToken extends
|
|
16
|
+
class ParamLineToken extends index_2.Token {
|
|
11
17
|
get type() {
|
|
12
18
|
return 'param-line';
|
|
13
19
|
}
|
|
20
|
+
/** @param name 扩展标签名 */
|
|
21
|
+
constructor(name, wikitext, config, accum, acceptable) {
|
|
22
|
+
super(wikitext, config, accum, acceptable);
|
|
23
|
+
this.setAttribute('name', name);
|
|
24
|
+
}
|
|
25
|
+
/** @private */
|
|
26
|
+
lint(start = this.getAbsoluteIndex()) {
|
|
27
|
+
LINT: {
|
|
28
|
+
const rule = 'no-ignored', { lintConfig } = index_1.default, { name, childNodes } = this, s = lintConfig.getSeverity(rule, name);
|
|
29
|
+
if (!s) {
|
|
30
|
+
return [];
|
|
31
|
+
}
|
|
32
|
+
const msg = index_1.default.msg('invalid-parameter', name);
|
|
33
|
+
if (childNodes.some(({ type }) => type === 'ext')) {
|
|
34
|
+
return [(0, lint_1.generateForSelf)(this, { start }, rule, msg, s)];
|
|
35
|
+
}
|
|
36
|
+
const children = childNodes
|
|
37
|
+
.filter(({ type }) => type !== 'comment' && type !== 'include' && type !== 'noinclude'), isInputbox = name === 'inputbox', i = isInputbox ? children.findIndex(({ type }) => type !== 'text') : -1;
|
|
38
|
+
let str = children.slice(0, i === -1 ? undefined : i).map(String).join('').trim();
|
|
39
|
+
if (str) {
|
|
40
|
+
if (isInputbox) {
|
|
41
|
+
str = str.toLowerCase();
|
|
42
|
+
}
|
|
43
|
+
const j = str.indexOf('='), key = str.slice(0, j === -1 ? undefined : j).trim(), params = sharable_1.extParams[name];
|
|
44
|
+
if (j === -1 ? i === -1 || !params.some(p => p.startsWith(key)) : !params.includes(key)) {
|
|
45
|
+
const e = (0, lint_1.generateForSelf)(this, { start }, rule, msg, s);
|
|
46
|
+
if (lintConfig.computeEditInfo) {
|
|
47
|
+
e.suggestions = [(0, lint_1.fixByRemove)(e)];
|
|
48
|
+
}
|
|
49
|
+
return [e];
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return super.lint(start, false);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
14
55
|
}
|
|
15
56
|
exports.ParamLineToken = ParamLineToken;
|
package/dist/src/table/base.d.ts
CHANGED
|
@@ -23,7 +23,6 @@ export declare abstract class TableBaseToken extends Token {
|
|
|
23
23
|
* @param type 节点类型
|
|
24
24
|
* @param attr 表格属性
|
|
25
25
|
*/
|
|
26
|
-
constructor(pattern: RegExp, syntax: string, type: TableTypes, attr?: string, config?: Config, accum?: Token[], acceptable?: WikiParserAcceptable);
|
|
27
|
-
escape(): void;
|
|
26
|
+
constructor(pattern: RegExp, syntax: string | undefined, type: TableTypes, attr?: string, config?: Config, accum?: Token[], acceptable?: WikiParserAcceptable);
|
|
28
27
|
}
|
|
29
28
|
export {};
|
package/dist/src/table/base.js
CHANGED
|
@@ -89,15 +89,14 @@ let TableBaseToken = (() => {
|
|
|
89
89
|
// @ts-expect-error abstract class
|
|
90
90
|
new attributes_1.AttributesToken(attr, 'table-attrs', type, config, accum));
|
|
91
91
|
}
|
|
92
|
+
/** @private */
|
|
92
93
|
escape() {
|
|
93
|
-
LSP: {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
child.escape();
|
|
100
|
-
}
|
|
94
|
+
LSP: for (const child of this.childNodes) {
|
|
95
|
+
if (child instanceof syntax_1.SyntaxToken) {
|
|
96
|
+
escapeTable(child);
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
child.escape();
|
|
101
100
|
}
|
|
102
101
|
}
|
|
103
102
|
}
|
|
@@ -24,7 +24,7 @@ export declare abstract class TableToken extends TrBaseToken {
|
|
|
24
24
|
* @param syntax 表格语法
|
|
25
25
|
* @param attr 表格属性
|
|
26
26
|
*/
|
|
27
|
-
constructor(syntax
|
|
27
|
+
constructor(syntax?: string, attr?: string, config?: Config, accum?: Token[]);
|
|
28
28
|
/**
|
|
29
29
|
* Close the table syntax
|
|
30
30
|
*
|