wikilint 2.0.0 → 2.1.2
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 -0
- package/dist/base.d.ts +39 -0
- package/dist/index.d.ts +4 -26
- package/dist/index.js +9 -5
- package/dist/lib/element.d.ts +2 -2
- package/dist/lib/element.js +1 -1
- package/dist/lib/node.d.ts +4 -2
- package/dist/lib/node.js +2 -2
- package/dist/lib/text.d.ts +2 -2
- package/dist/lib/text.js +4 -3
- package/dist/lib/title.d.ts +0 -1
- package/dist/lib/title.js +11 -11
- package/dist/parser/commentAndExt.js +5 -1
- package/dist/src/arg.d.ts +1 -1
- package/dist/src/atom.d.ts +1 -1
- package/dist/src/attribute.d.ts +1 -1
- package/dist/src/attributes.d.ts +1 -1
- package/dist/src/converterFlags.d.ts +1 -1
- package/dist/src/converterRule.js +7 -12
- package/dist/src/gallery.d.ts +1 -1
- package/dist/src/heading.d.ts +1 -2
- package/dist/src/heading.js +4 -3
- package/dist/src/html.d.ts +1 -1
- package/dist/src/html.js +10 -9
- package/dist/src/imageParameter.d.ts +1 -1
- package/dist/src/imagemap.d.ts +1 -1
- package/dist/src/link/base.d.ts +2 -1
- package/dist/src/link/base.js +11 -3
- package/dist/src/link/file.d.ts +1 -1
- package/dist/src/link/galleryImage.d.ts +4 -1
- package/dist/src/link/galleryImage.js +14 -3
- package/dist/src/magicLink.d.ts +1 -1
- package/dist/src/nested.d.ts +1 -1
- package/dist/src/nowiki/comment.d.ts +1 -1
- package/dist/src/nowiki/index.d.ts +1 -1
- package/dist/src/nowiki/quote.d.ts +1 -1
- package/dist/src/nowiki/quote.js +2 -2
- package/dist/src/paramTag/index.d.ts +1 -1
- package/dist/src/parameter.d.ts +1 -1
- package/dist/src/table/index.d.ts +1 -1
- package/dist/src/table/td.d.ts +1 -1
- package/dist/src/table/td.js +2 -2
- package/dist/src/table/trBase.d.ts +1 -1
- package/dist/src/tagPair/ext.d.ts +1 -1
- package/dist/src/transclude.d.ts +1 -1
- package/dist/util/debug.js +1 -2
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
[](https://github.com/bhsd-harry/wikiparser-node/actions/workflows/node.js.yml)
|
|
4
4
|
|
|
5
5
|
# wikilint
|
|
6
|
+
|
|
6
7
|
This is a minimal version of [wikiparser-node](https://www.npmjs.com/package/wikiparser-node) customized for [eslint-plugin-wikitext](https://www.npmjs.com/package/eslint-plugin-wikitext).
|
|
7
8
|
|
|
8
9
|
You can also directly lint Wikitext articles in the command line using this package:
|
package/dist/base.d.ts
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export interface Config {
|
|
2
|
+
ext: string[];
|
|
3
|
+
html: [string[], string[], string[]];
|
|
4
|
+
namespaces: Record<string, string>;
|
|
5
|
+
nsid: Record<string, number>;
|
|
6
|
+
parserFunction: [Record<string, string>, string[], string[], string[]];
|
|
7
|
+
doubleUnderscore: [string[], string[]];
|
|
8
|
+
protocol: string;
|
|
9
|
+
img: Record<string, string>;
|
|
10
|
+
variants: string[];
|
|
11
|
+
excludes?: string[];
|
|
12
|
+
}
|
|
13
|
+
export interface LintError {
|
|
14
|
+
message: string;
|
|
15
|
+
severity: 'error' | 'warning';
|
|
16
|
+
startIndex: number;
|
|
17
|
+
endIndex: number;
|
|
18
|
+
startLine: number;
|
|
19
|
+
startCol: number;
|
|
20
|
+
endLine: number;
|
|
21
|
+
endCol: number;
|
|
22
|
+
}
|
|
23
|
+
/** 类似Node */
|
|
24
|
+
export interface AstNode {
|
|
25
|
+
type: string;
|
|
26
|
+
childNodes: AstNode[];
|
|
27
|
+
/** Linter */
|
|
28
|
+
lint(): LintError[];
|
|
29
|
+
}
|
|
30
|
+
export interface Parser {
|
|
31
|
+
config: string | Config;
|
|
32
|
+
i18n: string | Record<string, string> | undefined;
|
|
33
|
+
/**
|
|
34
|
+
* 解析wikitext
|
|
35
|
+
* @param include 是否嵌入
|
|
36
|
+
* @param maxStage 最大解析层级
|
|
37
|
+
*/
|
|
38
|
+
parse(wikitext: string, include?: boolean, maxStage?: number, config?: Config): AstNode;
|
|
39
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,30 +1,7 @@
|
|
|
1
1
|
import type { Title } from './lib/title';
|
|
2
2
|
import type { Token } from './internal';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
html: [string[], string[], string[]];
|
|
6
|
-
namespaces: Record<string, string>;
|
|
7
|
-
nsid: Record<string, number>;
|
|
8
|
-
parserFunction: [Record<string, string>, string[], string[], string[]];
|
|
9
|
-
doubleUnderscore: [string[], string[]];
|
|
10
|
-
protocol: string;
|
|
11
|
-
img: Record<string, string>;
|
|
12
|
-
variants: string[];
|
|
13
|
-
excludes?: string[];
|
|
14
|
-
}
|
|
15
|
-
export interface LintError {
|
|
16
|
-
message: string;
|
|
17
|
-
severity: 'error' | 'warning';
|
|
18
|
-
startIndex: number;
|
|
19
|
-
endIndex: number;
|
|
20
|
-
startLine: number;
|
|
21
|
-
startCol: number;
|
|
22
|
-
endLine: number;
|
|
23
|
-
endCol: number;
|
|
24
|
-
}
|
|
25
|
-
declare interface Parser {
|
|
26
|
-
config: string | Config;
|
|
27
|
-
i18n: string | Record<string, string> | undefined;
|
|
3
|
+
import type { Config, LintError, Parser as ParserBase } from './base';
|
|
4
|
+
declare interface Parser extends ParserBase {
|
|
28
5
|
/**
|
|
29
6
|
* 规范化页面标题
|
|
30
7
|
* @param title 标题(含或不含命名空间前缀)
|
|
@@ -36,7 +13,7 @@ declare interface Parser {
|
|
|
36
13
|
*/
|
|
37
14
|
normalizeTitle(title: string, defaultNs?: number, include?: boolean, config?: Config, halfParsed?: boolean, decode?: boolean, selfLink?: boolean): Title;
|
|
38
15
|
/**
|
|
39
|
-
*
|
|
16
|
+
* @override
|
|
40
17
|
* @param include 是否嵌入
|
|
41
18
|
* @param maxStage 最大解析层级
|
|
42
19
|
*/
|
|
@@ -44,4 +21,5 @@ declare interface Parser {
|
|
|
44
21
|
}
|
|
45
22
|
declare const Parser: Parser;
|
|
46
23
|
export = Parser;
|
|
24
|
+
export type { Config, LintError };
|
|
47
25
|
export type * from './internal';
|
package/dist/index.js
CHANGED
|
@@ -10,6 +10,11 @@ const constants_1 = require("./util/constants");
|
|
|
10
10
|
* @param dir 子路径
|
|
11
11
|
*/
|
|
12
12
|
const rootRequire = (file, dir) => require(file.startsWith('/') ? file : `../${file.includes('/') ? '' : dir}${file}`);
|
|
13
|
+
/**
|
|
14
|
+
* 清理解析专用的不可见字符
|
|
15
|
+
* @param text 源文本
|
|
16
|
+
*/
|
|
17
|
+
const tidy = (text) => text.replace(/[\0\x7F]/gu, '');
|
|
13
18
|
// eslint-disable-next-line @typescript-eslint/no-redeclare
|
|
14
19
|
const Parser = {
|
|
15
20
|
config: 'default',
|
|
@@ -46,11 +51,10 @@ const Parser = {
|
|
|
46
51
|
/** @implements */
|
|
47
52
|
parse(wikitext, include, maxStage = constants_1.MAX_STAGE, config = Parser.getConfig()) {
|
|
48
53
|
const { Token } = require('./src/index');
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
token = new Token(wikitext.replace(/[\0\x7F]/gu, ''), config);
|
|
54
|
+
const root = debug_1.Shadow.run(() => {
|
|
55
|
+
const token = new Token(tidy(wikitext), config);
|
|
52
56
|
try {
|
|
53
|
-
token.parse(maxStage, include);
|
|
57
|
+
return token.parse(maxStage, include);
|
|
54
58
|
}
|
|
55
59
|
catch (e) {
|
|
56
60
|
if (e instanceof Error) {
|
|
@@ -64,7 +68,7 @@ const Parser = {
|
|
|
64
68
|
throw e;
|
|
65
69
|
}
|
|
66
70
|
});
|
|
67
|
-
return
|
|
71
|
+
return root;
|
|
68
72
|
},
|
|
69
73
|
};
|
|
70
74
|
const def = {}, enumerable = new Set([
|
package/dist/lib/element.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AstNode } from './node';
|
|
2
|
-
import type { LintError } from '../
|
|
2
|
+
import type { LintError } from '../base';
|
|
3
3
|
import type { AstNodes, Token } from '../internal';
|
|
4
4
|
/** 类似HTMLElement */
|
|
5
5
|
export declare abstract class AstElement extends AstNode {
|
|
@@ -49,7 +49,7 @@ export declare abstract class AstElement extends AstNode {
|
|
|
49
49
|
*/
|
|
50
50
|
setText(str: string, i?: number): string;
|
|
51
51
|
/**
|
|
52
|
-
*
|
|
52
|
+
* @override
|
|
53
53
|
* @param start
|
|
54
54
|
*/
|
|
55
55
|
lint(start?: number): LintError[];
|
package/dist/lib/element.js
CHANGED
package/dist/lib/node.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import type { LintError, AstNode as AstNodeBase } from '../base';
|
|
1
2
|
import type { AstText, Token } from '../internal';
|
|
2
3
|
export type AstNodes = AstText | Token;
|
|
3
|
-
export type TokenTypes = 'root' | 'plain' | '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' | 'list' | 'dd' | 'converter' | 'converter-flags' | 'converter-flag' | 'converter-rule' | 'converter-rule-
|
|
4
|
+
export type TokenTypes = 'root' | 'plain' | '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' | 'list' | 'dd' | 'converter' | 'converter-flags' | 'converter-flag' | 'converter-rule' | 'converter-rule-variant' | 'converter-rule-to' | 'converter-rule-from' | 'param-line' | 'imagemap-link';
|
|
4
5
|
export interface Dimension {
|
|
5
6
|
height: number;
|
|
6
7
|
width: number;
|
|
@@ -14,11 +15,12 @@ export interface CaretPosition {
|
|
|
14
15
|
offset: number;
|
|
15
16
|
}
|
|
16
17
|
/** 类似Node */
|
|
17
|
-
export declare abstract class AstNode {
|
|
18
|
+
export declare abstract class AstNode implements AstNodeBase {
|
|
18
19
|
#private;
|
|
19
20
|
type: TokenTypes | 'text';
|
|
20
21
|
data?: string | undefined;
|
|
21
22
|
readonly childNodes: AstNodes[];
|
|
23
|
+
abstract lint(): LintError[];
|
|
22
24
|
/** 首位子节点 */
|
|
23
25
|
get firstChild(): AstNodes | undefined;
|
|
24
26
|
/** 末位子节点 */
|
package/dist/lib/node.js
CHANGED
|
@@ -19,12 +19,12 @@ class AstNode {
|
|
|
19
19
|
}
|
|
20
20
|
/** 后一个兄弟节点 */
|
|
21
21
|
get nextSibling() {
|
|
22
|
-
const childNodes = this
|
|
22
|
+
const childNodes = this.parentNode?.childNodes;
|
|
23
23
|
return childNodes && childNodes[childNodes.indexOf(this) + 1];
|
|
24
24
|
}
|
|
25
25
|
/** 前一个兄弟节点 */
|
|
26
26
|
get previousSibling() {
|
|
27
|
-
const childNodes = this
|
|
27
|
+
const childNodes = this.parentNode?.childNodes;
|
|
28
28
|
return childNodes && childNodes[childNodes.indexOf(this) - 1];
|
|
29
29
|
}
|
|
30
30
|
/** 行数 */
|
package/dist/lib/text.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AstNode } from './node';
|
|
2
|
-
import type { LintError } from '../
|
|
2
|
+
import type { LintError } from '../base';
|
|
3
3
|
/** 文本节点 */
|
|
4
4
|
export declare class AstText extends AstNode {
|
|
5
5
|
#private;
|
|
@@ -11,7 +11,7 @@ export declare class AstText extends AstNode {
|
|
|
11
11
|
/** 可见部分 */
|
|
12
12
|
text(): string;
|
|
13
13
|
/**
|
|
14
|
-
*
|
|
14
|
+
* @override
|
|
15
15
|
* @param start
|
|
16
16
|
*/
|
|
17
17
|
lint(start?: number): LintError[];
|
package/dist/lib/text.js
CHANGED
|
@@ -48,7 +48,7 @@ class AstText extends node_1.AstNode {
|
|
|
48
48
|
return this.data;
|
|
49
49
|
}
|
|
50
50
|
/**
|
|
51
|
-
*
|
|
51
|
+
* @override
|
|
52
52
|
* @param start
|
|
53
53
|
*/
|
|
54
54
|
lint(start = this.getAbsoluteIndex()) {
|
|
@@ -60,8 +60,9 @@ class AstText extends node_1.AstNode {
|
|
|
60
60
|
return errors
|
|
61
61
|
.map(({ 0: error, 1: prefix, 2: tag, index }) => {
|
|
62
62
|
if (prefix) {
|
|
63
|
-
|
|
64
|
-
|
|
63
|
+
const { length } = prefix;
|
|
64
|
+
index += length;
|
|
65
|
+
error = error.slice(length);
|
|
65
66
|
}
|
|
66
67
|
const startIndex = start + index, lines = data.slice(0, index).split('\n'), startLine = lines.length + top - 1, line = lines.at(-1), startCol = lines.length === 1 ? left + line.length : line.length, { 0: char, length } = error, endIndex = startIndex + length, rootStr = String(root), nextChar = rootStr[endIndex], previousChar = rootStr[startIndex - 1], severity = length > 1 && (char !== '<' || /[\s/>]/u.test(nextChar ?? ''))
|
|
67
68
|
|| char === '{' && (nextChar === char || previousChar === '-')
|
package/dist/lib/title.d.ts
CHANGED
package/dist/lib/title.js
CHANGED
|
@@ -8,6 +8,7 @@ class Title {
|
|
|
8
8
|
valid;
|
|
9
9
|
ns;
|
|
10
10
|
fragment;
|
|
11
|
+
/** @private */
|
|
11
12
|
encoded = false;
|
|
12
13
|
/**
|
|
13
14
|
* @param title 标题(含或不含命名空间前缀)
|
|
@@ -16,8 +17,7 @@ class Title {
|
|
|
16
17
|
* @param selfLink 是否允许selfLink
|
|
17
18
|
*/
|
|
18
19
|
constructor(title, defaultNs = 0, config = Parser.getConfig(), decode = false, selfLink = false) {
|
|
19
|
-
const {
|
|
20
|
-
let namespace = namespaces[defaultNs] ?? '';
|
|
20
|
+
const { nsid, } = config;
|
|
21
21
|
title = (0, string_1.decodeHtml)(title);
|
|
22
22
|
if (decode && title.includes('%')) {
|
|
23
23
|
try {
|
|
@@ -28,29 +28,29 @@ class Title {
|
|
|
28
28
|
catch { }
|
|
29
29
|
}
|
|
30
30
|
title = title.replaceAll('_', ' ').trim();
|
|
31
|
+
let ns = defaultNs;
|
|
31
32
|
if (title.startsWith(':')) {
|
|
32
|
-
|
|
33
|
+
ns = 0;
|
|
33
34
|
title = title.slice(1).trim();
|
|
34
35
|
}
|
|
35
36
|
const m = title.split(':');
|
|
36
37
|
if (m.length > 1) {
|
|
37
|
-
const
|
|
38
|
+
const id = nsid[m[0].trim().toLowerCase()];
|
|
38
39
|
if (id !== undefined) {
|
|
39
|
-
|
|
40
|
+
ns = id;
|
|
40
41
|
title = m.slice(1).join(':').trim();
|
|
41
42
|
}
|
|
42
43
|
}
|
|
43
|
-
this.ns =
|
|
44
|
+
this.ns = ns;
|
|
44
45
|
const i = title.indexOf('#');
|
|
45
|
-
let fragment;
|
|
46
46
|
if (i !== -1) {
|
|
47
|
-
|
|
47
|
+
// eslint-disable-next-line prefer-const
|
|
48
|
+
let fragment = title.slice(i + 1).trimEnd();
|
|
49
|
+
this.fragment = fragment;
|
|
48
50
|
title = title.slice(0, i).trim();
|
|
49
51
|
}
|
|
50
52
|
this.valid = Boolean(title
|
|
51
|
-
|| selfLink && fragment !== undefined)
|
|
52
|
-
&& !/\0\d+[eh!+-]\x7F|[<>[\]{}|]|%[\da-f]{2}/iu.test(title);
|
|
53
|
-
this.fragment = fragment;
|
|
53
|
+
|| selfLink && this.fragment !== undefined) && !/\0\d+[eh!+-]\x7F|[<>[\]{}|]|%[\da-f]{2}/iu.test(title);
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
56
|
exports.Title = Title;
|
|
@@ -34,7 +34,11 @@ const parseCommentAndExt = (wikitext, config = Parser.getConfig(), accum = [], i
|
|
|
34
34
|
i = wikitext.indexOf(onlyincludeLeft);
|
|
35
35
|
j = wikitext.indexOf(onlyincludeRight, i + length);
|
|
36
36
|
}
|
|
37
|
-
|
|
37
|
+
if (wikitext) {
|
|
38
|
+
new noinclude_1.NoincludeToken(wikitext, config, accum);
|
|
39
|
+
str += `\0${accum.length - 1}c\x7F`;
|
|
40
|
+
}
|
|
41
|
+
return str;
|
|
38
42
|
}
|
|
39
43
|
}
|
|
40
44
|
const ext = config.ext.join('|'), includeRegex = includeOnly ? 'includeonly' : '(?:no|only)include', noincludeRegex = includeOnly ? 'noinclude' : 'includeonly', regex = new RegExp('<!--.*?(?:-->|$)|' // comment
|
package/dist/src/arg.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import * as Parser from '../index';
|
|
|
2
2
|
import { Token } from './index';
|
|
3
3
|
import { AtomToken } from './atom';
|
|
4
4
|
import { HiddenToken } from './hidden';
|
|
5
|
-
import type { LintError } from '../
|
|
5
|
+
import type { LintError } from '../base';
|
|
6
6
|
/**
|
|
7
7
|
* `{{{}}}`包裹的参数
|
|
8
8
|
* @classdesc `{childNodes: [AtomToken, ?Token, ...HiddenToken]}`
|
package/dist/src/atom.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as Parser from '../index';
|
|
2
2
|
import { Token } from './index';
|
|
3
|
-
declare type AtomTypes = 'arg-name' | 'attr-key' | 'attr-value' | 'ext-attr-dirty' | 'html-attr-dirty' | 'table-attr-dirty' | 'converter-flag' | 'converter-rule-variant' | 'converter-rule-to' | 'converter-rule-from' | '
|
|
3
|
+
declare type AtomTypes = 'arg-name' | 'attr-key' | 'attr-value' | 'ext-attr-dirty' | 'html-attr-dirty' | 'table-attr-dirty' | 'converter-flag' | 'converter-rule-variant' | 'converter-rule-to' | 'converter-rule-from' | 'invoke-function' | 'invoke-module' | 'template-name' | 'link-target' | 'param-line';
|
|
4
4
|
/** 不会被继续解析的plain Token */
|
|
5
5
|
export declare class AtomToken extends Token {
|
|
6
6
|
type: AtomTypes;
|
package/dist/src/attribute.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as Parser from '../index';
|
|
2
2
|
import { Token } from './index';
|
|
3
3
|
import { AtomToken } from './atom';
|
|
4
|
-
import type { LintError } from '../
|
|
4
|
+
import type { LintError } from '../base';
|
|
5
5
|
import type { AttributesToken } from '../internal';
|
|
6
6
|
export type AttributeTypes = 'ext-attr' | 'html-attr' | 'table-attr';
|
|
7
7
|
/**
|
package/dist/src/attributes.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import * as Parser from '../index';
|
|
|
2
2
|
import { Token } from './index';
|
|
3
3
|
import { AtomToken } from './atom';
|
|
4
4
|
import { AttributeToken } from './attribute';
|
|
5
|
-
import type { LintError } from '../
|
|
5
|
+
import type { LintError } from '../base';
|
|
6
6
|
import type { ExtToken, HtmlToken, TdToken, TrToken, TableToken } from '../internal';
|
|
7
7
|
declare type AttributesTypes = 'ext-attrs' | 'html-attrs' | 'table-attrs';
|
|
8
8
|
/**
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as Parser from '../index';
|
|
2
2
|
import { Token } from './index';
|
|
3
3
|
import { AtomToken } from './atom';
|
|
4
|
-
import type { LintError } from '../
|
|
4
|
+
import type { LintError } from '../base';
|
|
5
5
|
import type { ConverterToken, ConverterRuleToken } from '../internal';
|
|
6
6
|
/**
|
|
7
7
|
* 转换flags
|
|
@@ -16,21 +16,16 @@ class ConverterRuleToken extends index_1.Token {
|
|
|
16
16
|
*/
|
|
17
17
|
constructor(rule, hasColon = true, config = Parser.getConfig(), accum = []) {
|
|
18
18
|
super(undefined, config, accum);
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
super.insertAt(new atom_1.AtomToken(rule.slice(0, j), 'converter-rule-from', config, accum), 0);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
else {
|
|
29
|
-
super.insertAt(new atom_1.AtomToken(rule, 'converter-rule-noconvert', config, accum));
|
|
19
|
+
const i = rule.indexOf(':'), j = rule.slice(0, i).indexOf('=>'), v = j === -1 ? rule.slice(0, i) : rule.slice(j + 2, i);
|
|
20
|
+
if (hasColon && config.variants.includes(v.trim())) {
|
|
21
|
+
super.insertAt(new atom_1.AtomToken(v, 'converter-rule-variant', config, accum));
|
|
22
|
+
super.insertAt(new atom_1.AtomToken(rule.slice(i + 1), 'converter-rule-to', config, accum));
|
|
23
|
+
if (j !== -1) {
|
|
24
|
+
super.insertAt(new atom_1.AtomToken(rule.slice(0, j), 'converter-rule-from', config, accum), 0);
|
|
30
25
|
}
|
|
31
26
|
}
|
|
32
27
|
else {
|
|
33
|
-
super.insertAt(new atom_1.AtomToken(rule, 'converter-rule-
|
|
28
|
+
super.insertAt(new atom_1.AtomToken(rule, 'converter-rule-to', config, accum));
|
|
34
29
|
}
|
|
35
30
|
}
|
|
36
31
|
/** @private */
|
package/dist/src/gallery.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import * as Parser from '../index';
|
|
|
2
2
|
import { Token } from './index';
|
|
3
3
|
import { GalleryImageToken } from './link/galleryImage';
|
|
4
4
|
import { HiddenToken } from './hidden';
|
|
5
|
-
import type { LintError } from '../
|
|
5
|
+
import type { LintError } from '../base';
|
|
6
6
|
import type { AstText, AttributesToken, ExtToken } from '../internal';
|
|
7
7
|
/**
|
|
8
8
|
* gallery标签
|
package/dist/src/heading.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as Parser from '../index';
|
|
2
2
|
import { Token } from './index';
|
|
3
3
|
import { SyntaxToken } from './syntax';
|
|
4
|
-
import type { LintError } from '../
|
|
4
|
+
import type { LintError } from '../base';
|
|
5
5
|
/**
|
|
6
6
|
* 章节标题
|
|
7
7
|
* @classdesc `{childNodes: [Token, SyntaxToken]}`
|
|
@@ -9,7 +9,6 @@ import type { LintError } from '../index';
|
|
|
9
9
|
export declare class HeadingToken extends Token {
|
|
10
10
|
#private;
|
|
11
11
|
readonly type = "heading";
|
|
12
|
-
name: string;
|
|
13
12
|
childNodes: [Token, SyntaxToken];
|
|
14
13
|
abstract get firstChild(): Token;
|
|
15
14
|
abstract get lastChild(): SyntaxToken;
|
package/dist/src/heading.js
CHANGED
|
@@ -11,13 +11,14 @@ const syntax_1 = require("./syntax");
|
|
|
11
11
|
*/
|
|
12
12
|
class HeadingToken extends index_1.Token {
|
|
13
13
|
type = 'heading';
|
|
14
|
+
#level;
|
|
14
15
|
/** 标题格式的等号 */
|
|
15
16
|
get #equals() {
|
|
16
17
|
return '='.repeat(this.level);
|
|
17
18
|
}
|
|
18
19
|
/** 标题层级 */
|
|
19
20
|
get level() {
|
|
20
|
-
return
|
|
21
|
+
return this.#level;
|
|
21
22
|
}
|
|
22
23
|
/**
|
|
23
24
|
* @param level 标题层级
|
|
@@ -25,7 +26,7 @@ class HeadingToken extends index_1.Token {
|
|
|
25
26
|
*/
|
|
26
27
|
constructor(level, input, config = Parser.getConfig(), accum = []) {
|
|
27
28
|
super(undefined, config, accum);
|
|
28
|
-
this
|
|
29
|
+
this.#level = level;
|
|
29
30
|
const token = new index_1.Token(input[0], config, accum);
|
|
30
31
|
token.type = 'heading-title';
|
|
31
32
|
token.setAttribute('stage', 2);
|
|
@@ -56,7 +57,7 @@ class HeadingToken extends index_1.Token {
|
|
|
56
57
|
lint(start = this.getAbsoluteIndex()) {
|
|
57
58
|
const errors = super.lint(start), innerStr = String(this.firstChild);
|
|
58
59
|
let refError;
|
|
59
|
-
if (this.
|
|
60
|
+
if (this.level === 1) {
|
|
60
61
|
refError = (0, lint_1.generateForSelf)(this, { start }, '<h1>');
|
|
61
62
|
errors.push(refError);
|
|
62
63
|
}
|
package/dist/src/html.d.ts
CHANGED
package/dist/src/html.js
CHANGED
|
@@ -35,23 +35,24 @@ class HtmlToken extends index_1.Token {
|
|
|
35
35
|
}
|
|
36
36
|
/** @private */
|
|
37
37
|
toString(omit) {
|
|
38
|
-
return `<${this
|
|
38
|
+
return `<${this.closing ? '/' : ''}${this.#tag}${super.toString()}${this.#selfClosing ? '/' : ''}>`;
|
|
39
39
|
}
|
|
40
40
|
/** @override */
|
|
41
41
|
text() {
|
|
42
|
-
|
|
42
|
+
const { closing } = this;
|
|
43
|
+
return `<${closing ? '/' : ''}${this.#tag}${closing ? '' : super.text()}${this.#selfClosing ? '/' : ''}>`;
|
|
43
44
|
}
|
|
44
45
|
/** @private */
|
|
45
46
|
getAttribute(key) {
|
|
46
47
|
return key === 'padding'
|
|
47
|
-
? this.#tag.length + (this
|
|
48
|
+
? this.#tag.length + (this.closing ? 2 : 1)
|
|
48
49
|
: super.getAttribute(key);
|
|
49
50
|
}
|
|
50
51
|
/** @override */
|
|
51
52
|
lint(start = this.getAbsoluteIndex()) {
|
|
52
53
|
const errors = super.lint(start);
|
|
53
54
|
let refError;
|
|
54
|
-
if (this.name === 'h1' && !this
|
|
55
|
+
if (this.name === 'h1' && !this.closing) {
|
|
55
56
|
refError = (0, lint_1.generateForSelf)(this, { start }, '<h1>');
|
|
56
57
|
errors.push(refError);
|
|
57
58
|
}
|
|
@@ -91,8 +92,8 @@ class HtmlToken extends index_1.Token {
|
|
|
91
92
|
* @throws `SyntaxError` 未闭合的标签
|
|
92
93
|
*/
|
|
93
94
|
findMatchingTag() {
|
|
94
|
-
const { html } = this.getAttribute('config'), { name: tagName, parentNode } = this, string = (0, string_1.noWrap)(String(this));
|
|
95
|
-
if (
|
|
95
|
+
const { html } = this.getAttribute('config'), { name: tagName, parentNode, closing } = this, string = (0, string_1.noWrap)(String(this));
|
|
96
|
+
if (closing && (this.#selfClosing || html[2].includes(tagName))) {
|
|
96
97
|
throw new SyntaxError(`tag that is both closing and self-closing: ${string}`);
|
|
97
98
|
}
|
|
98
99
|
else if (html[2].includes(tagName) || this.#selfClosing && html[1].includes(tagName)) { // 自封闭标签
|
|
@@ -104,10 +105,10 @@ class HtmlToken extends index_1.Token {
|
|
|
104
105
|
else if (!parentNode) {
|
|
105
106
|
return undefined;
|
|
106
107
|
}
|
|
107
|
-
const { childNodes } = parentNode, i = childNodes.indexOf(this), siblings =
|
|
108
|
+
const { childNodes } = parentNode, i = childNodes.indexOf(this), siblings = closing
|
|
108
109
|
? childNodes.slice(0, i).reverse().filter(({ type, name }) => type === 'html' && name === tagName)
|
|
109
110
|
: childNodes.slice(i + 1).filter(({ type, name }) => type === 'html' && name === tagName);
|
|
110
|
-
let imbalance =
|
|
111
|
+
let imbalance = closing ? -1 : 1;
|
|
111
112
|
for (const token of siblings) {
|
|
112
113
|
if (token.#closing) {
|
|
113
114
|
imbalance--;
|
|
@@ -119,7 +120,7 @@ class HtmlToken extends index_1.Token {
|
|
|
119
120
|
return token;
|
|
120
121
|
}
|
|
121
122
|
}
|
|
122
|
-
throw new SyntaxError(`${
|
|
123
|
+
throw new SyntaxError(`${closing ? 'unmatched closing' : 'unclosed'} tag: ${string}`);
|
|
123
124
|
}
|
|
124
125
|
}
|
|
125
126
|
exports.HtmlToken = HtmlToken;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as Parser from '../index';
|
|
2
2
|
import { Token } from './index';
|
|
3
|
-
import type { LintError } from '../
|
|
3
|
+
import type { LintError } from '../base';
|
|
4
4
|
import type { Title } from '../lib/title';
|
|
5
5
|
import type { AtomToken, FileToken } from '../internal';
|
|
6
6
|
export declare const galleryParams: Set<string>;
|
package/dist/src/imagemap.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { Token } from './index';
|
|
|
3
3
|
import { NoincludeToken } from './nowiki/noinclude';
|
|
4
4
|
import { GalleryImageToken } from './link/galleryImage';
|
|
5
5
|
import { ImagemapLinkToken } from './imagemapLink';
|
|
6
|
-
import type { LintError } from '../
|
|
6
|
+
import type { LintError } from '../base';
|
|
7
7
|
import type { AstText, AttributesToken, ExtToken } from '../internal';
|
|
8
8
|
/**
|
|
9
9
|
* `<imagemap>`
|
package/dist/src/link/base.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import * as Parser from '../../index';
|
|
2
2
|
import { Token } from '../index';
|
|
3
3
|
import { AtomToken } from '../atom';
|
|
4
|
-
import type { LintError } from '../../
|
|
4
|
+
import type { LintError } from '../../base';
|
|
5
|
+
import type { Title } from '../../lib/title';
|
|
5
6
|
/**
|
|
6
7
|
* 内链
|
|
7
8
|
* @classdesc `{childNodes: [AtomToken, ...Token]}`
|
package/dist/src/link/base.js
CHANGED
|
@@ -13,6 +13,7 @@ const atom_1 = require("../atom");
|
|
|
13
13
|
class LinkBaseToken extends index_1.Token {
|
|
14
14
|
#bracket = true;
|
|
15
15
|
#delimiter;
|
|
16
|
+
#title;
|
|
16
17
|
/**
|
|
17
18
|
* @param link 链接标题
|
|
18
19
|
* @param linkText 链接显示文字
|
|
@@ -31,6 +32,7 @@ class LinkBaseToken extends index_1.Token {
|
|
|
31
32
|
}
|
|
32
33
|
/** @private */
|
|
33
34
|
afterBuild() {
|
|
35
|
+
this.#title = this.getTitle();
|
|
34
36
|
if (this.#delimiter.includes('\0')) {
|
|
35
37
|
this.#delimiter = this.buildFromStr(this.#delimiter, 'string');
|
|
36
38
|
}
|
|
@@ -40,6 +42,9 @@ class LinkBaseToken extends index_1.Token {
|
|
|
40
42
|
if (key === 'bracket') {
|
|
41
43
|
this.#bracket = Boolean(value);
|
|
42
44
|
}
|
|
45
|
+
else if (key === 'title') {
|
|
46
|
+
this.#title = value;
|
|
47
|
+
}
|
|
43
48
|
else {
|
|
44
49
|
super.setAttribute(key, value);
|
|
45
50
|
}
|
|
@@ -58,6 +63,9 @@ class LinkBaseToken extends index_1.Token {
|
|
|
58
63
|
}
|
|
59
64
|
/** @private */
|
|
60
65
|
getAttribute(key) {
|
|
66
|
+
if (key === 'title') {
|
|
67
|
+
return this.#title;
|
|
68
|
+
}
|
|
61
69
|
return key === 'padding' ? 2 : super.getAttribute(key);
|
|
62
70
|
}
|
|
63
71
|
/** @private */
|
|
@@ -66,7 +74,7 @@ class LinkBaseToken extends index_1.Token {
|
|
|
66
74
|
}
|
|
67
75
|
/** @override */
|
|
68
76
|
lint(start = this.getAbsoluteIndex()) {
|
|
69
|
-
const errors = super.lint(start), { childNodes: [target, linkText], type: linkType } = this, { encoded, fragment } = this.#
|
|
77
|
+
const errors = super.lint(start), { childNodes: [target, linkText], type: linkType } = this, { encoded, fragment } = this.#title;
|
|
70
78
|
let rect;
|
|
71
79
|
if (linkType === 'link' && target.childNodes.some(({ type }) => type === 'template')) {
|
|
72
80
|
rect = { start, ...this.getRootNode().posFromIndex(start) };
|
|
@@ -86,8 +94,8 @@ class LinkBaseToken extends index_1.Token {
|
|
|
86
94
|
}
|
|
87
95
|
return errors;
|
|
88
96
|
}
|
|
89
|
-
/**
|
|
90
|
-
|
|
97
|
+
/** @private */
|
|
98
|
+
getTitle() {
|
|
91
99
|
return this.normalizeTitle(this.firstChild.text(), 0, false, true, true);
|
|
92
100
|
}
|
|
93
101
|
}
|
package/dist/src/link/file.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as Parser from '../../index';
|
|
2
2
|
import { LinkBaseToken } from './base';
|
|
3
3
|
import { ImageParameterToken } from '../imageParameter';
|
|
4
|
-
import type { LintError } from '../../
|
|
4
|
+
import type { LintError } from '../../base';
|
|
5
5
|
import type { Token, AtomToken } from '../../internal';
|
|
6
6
|
/**
|
|
7
7
|
* 图片
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import * as Parser from '../../index';
|
|
2
2
|
import { Token } from '../index';
|
|
3
3
|
import { FileToken } from './file';
|
|
4
|
-
import type {
|
|
4
|
+
import type { Title } from '../../lib/title';
|
|
5
|
+
import type { LintError } from '../../base';
|
|
5
6
|
/** 图库图片 */
|
|
6
7
|
export declare class GalleryImageToken extends FileToken {
|
|
7
8
|
#private;
|
|
@@ -12,6 +13,8 @@ export declare class GalleryImageToken extends FileToken {
|
|
|
12
13
|
* @param text 图片参数
|
|
13
14
|
*/
|
|
14
15
|
constructor(type: 'gallery' | 'imagemap', link: string, text?: string, config?: Parser.Config, accum?: Token[]);
|
|
16
|
+
/** private */
|
|
17
|
+
getTitle(): Title;
|
|
15
18
|
/** @override */
|
|
16
19
|
lint(start?: number): LintError[];
|
|
17
20
|
}
|
|
@@ -28,8 +28,8 @@ class GalleryImageToken extends file_1.FileToken {
|
|
|
28
28
|
this.setAttribute('bracket', false);
|
|
29
29
|
this.type = `${type}-image`;
|
|
30
30
|
}
|
|
31
|
-
/**
|
|
32
|
-
|
|
31
|
+
/** private */
|
|
32
|
+
getTitle() {
|
|
33
33
|
const imagemap = this.type === 'imagemap-image';
|
|
34
34
|
return this.normalizeTitle(String(this.firstChild), imagemap ? 0 : 6, true, !imagemap);
|
|
35
35
|
}
|
|
@@ -39,11 +39,22 @@ class GalleryImageToken extends file_1.FileToken {
|
|
|
39
39
|
}
|
|
40
40
|
/** @override */
|
|
41
41
|
lint(start = this.getAbsoluteIndex()) {
|
|
42
|
-
const errors = super.lint(start), { ns, } = this
|
|
42
|
+
const errors = super.lint(start), { ns, } = this.getAttribute('title');
|
|
43
43
|
if (ns !== 6) {
|
|
44
44
|
errors.push((0, lint_1.generateForSelf)(this, { start }, 'invalid gallery image'));
|
|
45
45
|
}
|
|
46
46
|
return errors;
|
|
47
47
|
}
|
|
48
|
+
/**
|
|
49
|
+
* 设置`#title`
|
|
50
|
+
* @param title Title对象
|
|
51
|
+
*/
|
|
52
|
+
#setName(title) {
|
|
53
|
+
this.setAttribute('title', title);
|
|
54
|
+
}
|
|
55
|
+
/** @private */
|
|
56
|
+
afterBuild() {
|
|
57
|
+
this.#setName(this.getTitle());
|
|
58
|
+
}
|
|
48
59
|
}
|
|
49
60
|
exports.GalleryImageToken = GalleryImageToken;
|
package/dist/src/magicLink.d.ts
CHANGED
package/dist/src/nested.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { Token } from './index';
|
|
|
3
3
|
import { ExtToken } from './tagPair/ext';
|
|
4
4
|
import { NoincludeToken } from './nowiki/noinclude';
|
|
5
5
|
import { CommentToken } from './nowiki/comment';
|
|
6
|
-
import type { LintError } from '../
|
|
6
|
+
import type { LintError } from '../base';
|
|
7
7
|
import type { AttributesToken } from './attributes';
|
|
8
8
|
/**
|
|
9
9
|
* 嵌套式的扩展标签
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as Parser from '../../index';
|
|
2
2
|
import { NowikiBaseToken } from './base';
|
|
3
|
-
import type { LintError } from '../../
|
|
3
|
+
import type { LintError } from '../../base';
|
|
4
4
|
import type { Token } from '../index';
|
|
5
5
|
declare const CommentToken_base: ((abstract new (...args: any[]) => {
|
|
6
6
|
text(): string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { NowikiBaseToken } from './base';
|
|
2
|
-
import type { LintError } from '../../
|
|
2
|
+
import type { LintError } from '../../base';
|
|
3
3
|
import type { AttributesToken, ExtToken } from '../../internal';
|
|
4
4
|
/** 扩展标签内的纯文字Token */
|
|
5
5
|
export declare class NowikiToken extends NowikiBaseToken {
|
package/dist/src/nowiki/quote.js
CHANGED
|
@@ -14,7 +14,7 @@ class QuoteToken extends base_1.NowikiBaseToken {
|
|
|
14
14
|
let refError;
|
|
15
15
|
if (previousSibling?.type === 'text' && previousSibling.data.endsWith(`'`)) {
|
|
16
16
|
refError = (0, lint_1.generateForSelf)(this, { start }, message);
|
|
17
|
-
const { startIndex: endIndex, startLine: endLine, startCol: endCol } = refError, [{ length }] =
|
|
17
|
+
const { startIndex: endIndex, startLine: endLine, startCol: endCol } = refError, [{ length }] = /(?<!')'+$/u.exec(previousSibling.data), startIndex = start - length;
|
|
18
18
|
errors.push({
|
|
19
19
|
...refError,
|
|
20
20
|
startIndex,
|
|
@@ -26,7 +26,7 @@ class QuoteToken extends base_1.NowikiBaseToken {
|
|
|
26
26
|
}
|
|
27
27
|
if (nextSibling?.type === 'text' && nextSibling.data.startsWith(`'`)) {
|
|
28
28
|
refError ??= (0, lint_1.generateForSelf)(this, { start }, message);
|
|
29
|
-
const { endIndex: startIndex, endLine: startLine, endCol: startCol } = refError, [{ length }] =
|
|
29
|
+
const { endIndex: startIndex, endLine: startLine, endCol: startCol } = refError, [{ length }] = /^'+/u.exec(nextSibling.data), endIndex = startIndex + length;
|
|
30
30
|
errors.push({
|
|
31
31
|
...refError,
|
|
32
32
|
startIndex,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as Parser from '../../index';
|
|
2
2
|
import { Token } from '../index';
|
|
3
3
|
import { AtomToken } from '../atom';
|
|
4
|
-
import type { LintError } from '../../
|
|
4
|
+
import type { LintError } from '../../base';
|
|
5
5
|
import type { AttributesToken, ExtToken } from '../../internal';
|
|
6
6
|
/**
|
|
7
7
|
* `<dynamicpagelist>`
|
package/dist/src/parameter.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as Parser from '../../index';
|
|
2
2
|
import { TrBaseToken } from './trBase';
|
|
3
3
|
import { SyntaxToken } from '../syntax';
|
|
4
|
-
import type { LintError } from '../../
|
|
4
|
+
import type { LintError } from '../../base';
|
|
5
5
|
import type { AttributesToken, TdToken, TrToken, Token } from '../../internal';
|
|
6
6
|
/**
|
|
7
7
|
* 表格
|
package/dist/src/table/td.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as Parser from '../../index';
|
|
2
2
|
import { Token } from '../index';
|
|
3
3
|
import { TableBaseToken } from './base';
|
|
4
|
-
import type { LintError } from '../../
|
|
4
|
+
import type { LintError } from '../../base';
|
|
5
5
|
import type { SyntaxToken, AttributesToken, TrToken, TableToken } from '../../internal';
|
|
6
6
|
export type TdSubtypes = 'td' | 'th' | 'caption';
|
|
7
7
|
export type TdAttrs = Record<string, string | true> & {
|
package/dist/src/table/td.js
CHANGED
|
@@ -22,9 +22,9 @@ class TdToken extends base_1.TableBaseToken {
|
|
|
22
22
|
* @param inner 内部wikitext
|
|
23
23
|
*/
|
|
24
24
|
constructor(syntax, inner, config = Parser.getConfig(), accum = []) {
|
|
25
|
-
let innerSyntax =
|
|
25
|
+
let innerSyntax = /\||\0\d+!\x7F/u.exec(inner ?? ''), attr = innerSyntax ? inner.slice(0, innerSyntax.index) : '';
|
|
26
26
|
if (/\[\[|-\{/u.test(attr)) {
|
|
27
|
-
innerSyntax =
|
|
27
|
+
innerSyntax = null;
|
|
28
28
|
attr = '';
|
|
29
29
|
}
|
|
30
30
|
super(/^(?:\n[^\S\n]*(?:[|!]|\|\+|\{\{\s*!\s*\}\}\+?)|(?:\||\{\{\s*!\s*\}\}){2}|!!|\{\{\s*!!\s*\}\})$/u, syntax, attr, config, accum);
|
|
@@ -2,7 +2,7 @@ import * as Parser from '../../index';
|
|
|
2
2
|
import { Token } from '../index';
|
|
3
3
|
import { TagPairToken } from './index';
|
|
4
4
|
import { AttributesToken } from '../attributes';
|
|
5
|
-
import type { LintError } from '../../
|
|
5
|
+
import type { LintError } from '../../base';
|
|
6
6
|
/**
|
|
7
7
|
* 扩展标签
|
|
8
8
|
* @classdesc `{childNodes: [AttributesToken, Token]}`
|
package/dist/src/transclude.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { Token } from './index';
|
|
|
3
3
|
import { ParameterToken } from './parameter';
|
|
4
4
|
import { AtomToken } from './atom';
|
|
5
5
|
import { SyntaxToken } from './syntax';
|
|
6
|
-
import type { LintError } from '../
|
|
6
|
+
import type { LintError } from '../base';
|
|
7
7
|
/**
|
|
8
8
|
* 模板或魔术字
|
|
9
9
|
* @classdesc `{childNodes: [AtomToken|SyntaxToken, ...AtomToken, ...ParameterToken]}`
|
package/dist/util/debug.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Shadow = void 0;
|
|
4
|
-
// eslint-disable-next-line @typescript-eslint/no-redeclare
|
|
5
4
|
exports.Shadow = {
|
|
6
|
-
/** @
|
|
5
|
+
/** @private */
|
|
7
6
|
run(callback) {
|
|
8
7
|
const result = callback();
|
|
9
8
|
return result;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wikilint",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.1.2",
|
|
4
4
|
"description": "A Node.js linter for MediaWiki markup",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"mediawiki",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"url": "git+https://github.com/bhsd-harry/wikiparser-node.git"
|
|
31
31
|
},
|
|
32
32
|
"scripts": {
|
|
33
|
-
"prepublishOnly": "npm run build; rm dist/internal.js
|
|
33
|
+
"prepublishOnly": "npm run build; rm dist/internal.js dist/base.js dist/[bmpu]*/*.d.ts; rm -r dist/test; grep -rl --include='*.d.ts' '@private' dist/ | xargs gsed -i '/@private/,+1d'",
|
|
34
34
|
"build": "rm -rf dist/; tsc; grep -rl --include='*.d.ts' '@private' dist/ | xargs gsed -i '/@private/,+1d'",
|
|
35
35
|
"diff": "git diff --ignore-all-space --color-moved",
|
|
36
36
|
"lint:ts": "tsc --noEmit && eslint --cache .",
|