wikilint 2.16.3 → 2.16.5
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/coverage/badge.svg +1 -1
- package/data/signatures.json +43 -0
- package/dist/base.d.mts +84 -27
- package/dist/base.d.ts +84 -27
- package/dist/bin/cli.js +2 -1
- package/dist/index.d.ts +8 -4
- package/dist/index.js +55 -11
- package/dist/lib/element.d.ts +56 -10
- package/dist/lib/element.js +97 -11
- package/dist/lib/lsp.d.ts +62 -27
- package/dist/lib/lsp.js +395 -304
- package/dist/lib/node.d.ts +51 -19
- package/dist/lib/node.js +80 -34
- package/dist/lib/text.d.ts +8 -2
- package/dist/lib/text.js +10 -3
- package/dist/lib/title.d.ts +23 -9
- package/dist/lib/title.js +56 -21
- package/dist/mixin/attributesParent.d.ts +4 -4
- package/dist/mixin/attributesParent.js +2 -4
- package/dist/mixin/hidden.d.ts +0 -2
- package/dist/mixin/hidden.js +0 -2
- package/dist/parser/braces.js +4 -2
- package/dist/parser/links.js +8 -7
- package/dist/parser/list.js +3 -1
- package/dist/parser/quotes.js +2 -1
- package/dist/parser/redirect.js +4 -1
- package/dist/src/arg.d.ts +4 -2
- package/dist/src/arg.js +8 -4
- package/dist/src/atom.d.ts +5 -1
- package/dist/src/atom.js +5 -1
- package/dist/src/attribute.d.ts +9 -3
- package/dist/src/attribute.js +9 -3
- package/dist/src/attributes.d.ts +12 -4
- package/dist/src/attributes.js +12 -4
- package/dist/src/converter.d.ts +3 -1
- package/dist/src/converter.js +8 -5
- package/dist/src/converterFlags.d.ts +13 -3
- package/dist/src/converterFlags.js +13 -3
- package/dist/src/converterRule.d.ts +3 -1
- package/dist/src/converterRule.js +3 -1
- package/dist/src/extLink.d.ts +2 -0
- package/dist/src/extLink.js +2 -0
- package/dist/src/gallery.d.ts +3 -1
- package/dist/src/gallery.js +7 -5
- package/dist/src/heading.d.ts +3 -1
- package/dist/src/heading.js +10 -8
- package/dist/src/hidden.d.ts +5 -1
- package/dist/src/hidden.js +5 -1
- package/dist/src/html.d.ts +9 -2
- package/dist/src/html.js +201 -146
- package/dist/src/imageParameter.d.ts +11 -3
- package/dist/src/imageParameter.js +12 -4
- package/dist/src/imagemap.d.ts +1 -1
- package/dist/src/imagemap.js +5 -4
- package/dist/src/imagemapLink.d.ts +2 -0
- package/dist/src/imagemapLink.js +2 -0
- package/dist/src/index.d.ts +5 -24
- package/dist/src/index.js +28 -73
- package/dist/src/link/base.d.ts +5 -1
- package/dist/src/link/base.js +17 -7
- package/dist/src/link/category.d.ts +4 -0
- package/dist/src/link/category.js +2 -0
- package/dist/src/link/file.d.ts +17 -7
- package/dist/src/link/file.js +28 -14
- package/dist/src/link/galleryImage.d.ts +5 -1
- package/dist/src/link/galleryImage.js +9 -5
- package/dist/src/link/index.d.ts +4 -0
- package/dist/src/link/index.js +2 -0
- package/dist/src/link/redirectTarget.d.ts +3 -1
- package/dist/src/link/redirectTarget.js +4 -2
- package/dist/src/magicLink.d.ts +12 -3
- package/dist/src/magicLink.js +36 -7
- package/dist/src/nested.d.ts +3 -1
- package/dist/src/nested.js +7 -4
- package/dist/src/nowiki/base.d.ts +3 -1
- package/dist/src/nowiki/base.js +3 -1
- package/dist/src/nowiki/comment.d.ts +5 -1
- package/dist/src/nowiki/comment.js +5 -1
- package/dist/src/nowiki/doubleUnderscore.d.ts +5 -1
- package/dist/src/nowiki/doubleUnderscore.js +5 -1
- package/dist/src/nowiki/index.d.ts +5 -1
- package/dist/src/nowiki/index.js +5 -1
- package/dist/src/nowiki/list.d.ts +5 -1
- package/dist/src/nowiki/list.js +5 -1
- package/dist/src/nowiki/noinclude.d.ts +5 -1
- package/dist/src/nowiki/noinclude.js +5 -1
- package/dist/src/nowiki/quote.d.ts +5 -1
- package/dist/src/nowiki/quote.js +5 -1
- package/dist/src/onlyinclude.d.ts +3 -1
- package/dist/src/onlyinclude.js +3 -1
- package/dist/src/paramTag/index.d.ts +1 -1
- package/dist/src/paramTag/index.js +1 -1
- package/dist/src/parameter.d.ts +3 -1
- package/dist/src/parameter.js +3 -1
- package/dist/src/pre.d.ts +1 -1
- package/dist/src/pre.js +1 -1
- package/dist/src/redirect.d.ts +2 -0
- package/dist/src/redirect.js +2 -0
- package/dist/src/syntax.d.ts +5 -1
- package/dist/src/syntax.js +5 -1
- package/dist/src/table/base.js +3 -1
- package/dist/src/table/index.d.ts +20 -15
- package/dist/src/table/index.js +22 -23
- package/dist/src/table/td.d.ts +9 -3
- package/dist/src/table/td.js +9 -3
- package/dist/src/table/tr.d.ts +3 -1
- package/dist/src/table/tr.js +4 -2
- package/dist/src/table/trBase.d.ts +9 -9
- package/dist/src/table/trBase.js +13 -18
- package/dist/src/tagPair/ext.d.ts +6 -1
- package/dist/src/tagPair/ext.js +151 -98
- package/dist/src/tagPair/include.d.ts +2 -0
- package/dist/src/tagPair/include.js +2 -0
- package/dist/src/tagPair/index.d.ts +6 -2
- package/dist/src/tagPair/index.js +6 -2
- package/dist/src/transclude.d.ts +39 -10
- package/dist/src/transclude.js +69 -18
- package/dist/util/debug.js +2 -16
- package/dist/util/string.js +2 -0
- package/i18n/zh-hans.json +1 -1
- package/i18n/zh-hant.json +1 -1
- package/package.json +3 -2
- package/dist/bin/coverage.js +0 -20
package/dist/src/magicLink.js
CHANGED
|
@@ -9,15 +9,17 @@ const index_2 = require("./index");
|
|
|
9
9
|
const space = String.raw `(?:[${string_1.zs}\t]| |�*160;|&#[xX]0*[aA]0;)`;
|
|
10
10
|
const spaceRegex = new RegExp(`${space}+`, 'gu');
|
|
11
11
|
/**
|
|
12
|
+
* free external link
|
|
13
|
+
*
|
|
12
14
|
* 自由外链
|
|
13
|
-
* @classdesc `{childNodes:
|
|
15
|
+
* @classdesc `{childNodes: (AstText|CommentToken|IncludeToken|NoincludeToken)[]}`
|
|
14
16
|
*/
|
|
15
17
|
class MagicLinkToken extends index_2.Token {
|
|
16
18
|
#type;
|
|
17
19
|
get type() {
|
|
18
20
|
return this.#type;
|
|
19
21
|
}
|
|
20
|
-
/** 链接显示文字 */
|
|
22
|
+
/** text of the link / 链接显示文字 */
|
|
21
23
|
get innerText() {
|
|
22
24
|
const map = new Map([['!', '|'], ['=', '=']]);
|
|
23
25
|
let link = (0, string_1.text)(this.childNodes.map(child => {
|
|
@@ -29,12 +31,13 @@ class MagicLinkToken extends index_2.Token {
|
|
|
29
31
|
}
|
|
30
32
|
return link;
|
|
31
33
|
}
|
|
32
|
-
/**
|
|
34
|
+
/** link / 链接 */
|
|
33
35
|
get link() {
|
|
34
36
|
const { innerText } = this;
|
|
35
37
|
if (this.type === 'magic-link') {
|
|
36
38
|
return innerText.startsWith('ISBN')
|
|
37
|
-
? `ISBN ${innerText.slice(5).replace(/[- ]/gu, '')
|
|
39
|
+
? `ISBN ${innerText.slice(5).replace(/[- ]/gu, '')
|
|
40
|
+
.replace(/x$/u, 'X')}`
|
|
38
41
|
: innerText;
|
|
39
42
|
}
|
|
40
43
|
return (0, string_1.decodeNumber)(innerText);
|
|
@@ -49,8 +52,8 @@ class MagicLinkToken extends index_2.Token {
|
|
|
49
52
|
}
|
|
50
53
|
/** @private */
|
|
51
54
|
lint(start = this.getAbsoluteIndex(), re) {
|
|
52
|
-
const errors = super.lint(start, re), rect = new rect_1.BoundingRect(this, start);
|
|
53
|
-
if (
|
|
55
|
+
const errors = super.lint(start, re), rect = new rect_1.BoundingRect(this, start), { type, childNodes } = this;
|
|
56
|
+
if (type === 'magic-link') {
|
|
54
57
|
const { link } = this;
|
|
55
58
|
if (link.startsWith('ISBN')) {
|
|
56
59
|
// eslint-disable-next-line unicorn/no-useless-spread, @typescript-eslint/no-misused-spread
|
|
@@ -63,7 +66,7 @@ class MagicLinkToken extends index_2.Token {
|
|
|
63
66
|
}
|
|
64
67
|
return errors;
|
|
65
68
|
}
|
|
66
|
-
const pipe =
|
|
69
|
+
const pipe = type === 'ext-link-url', regex = pipe ? /\|/u : /[,;。:!?()]+/u, child = childNodes.find((c) => c.type === 'text' && regex.test(c.data));
|
|
67
70
|
if (child) {
|
|
68
71
|
const { data } = child, e = (0, lint_1.generateForChild)(child, rect, 'unterminated-url', index_1.default.msg('$1 in URL', pipe ? '"|"' : 'full-width punctuation'), 'warning'), { index, 0: s } = regex.exec(data), i = e.startIndex + index;
|
|
69
72
|
e.suggestions = pipe
|
|
@@ -76,5 +79,31 @@ class MagicLinkToken extends index_2.Token {
|
|
|
76
79
|
}
|
|
77
80
|
return errors;
|
|
78
81
|
}
|
|
82
|
+
/**
|
|
83
|
+
* Get the URL
|
|
84
|
+
*
|
|
85
|
+
* 获取网址
|
|
86
|
+
* @param articlePath article path / 条目路径
|
|
87
|
+
*/
|
|
88
|
+
getUrl(articlePath) {
|
|
89
|
+
LSP: { // eslint-disable-line no-unused-labels
|
|
90
|
+
const { type } = this;
|
|
91
|
+
let { link } = this;
|
|
92
|
+
if (type === 'magic-link') {
|
|
93
|
+
if (link.startsWith('ISBN')) {
|
|
94
|
+
return this
|
|
95
|
+
.normalizeTitle(`BookSources/${link.slice(5)}`, -1, true)
|
|
96
|
+
.getUrl(articlePath);
|
|
97
|
+
}
|
|
98
|
+
link = link.startsWith('RFC')
|
|
99
|
+
? `https://tools.ietf.org/html/rfc${link.slice(4)}`
|
|
100
|
+
: `https://pubmed.ncbi.nlm.nih.gov/${link.slice(5)}`;
|
|
101
|
+
}
|
|
102
|
+
else if (link.startsWith('//')) {
|
|
103
|
+
link = `https:${link}`;
|
|
104
|
+
}
|
|
105
|
+
return new URL(link);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
79
108
|
}
|
|
80
109
|
exports.MagicLinkToken = MagicLinkToken;
|
package/dist/src/nested.d.ts
CHANGED
|
@@ -6,8 +6,10 @@ import type { LintError } from '../base';
|
|
|
6
6
|
import type { CommentToken, AttributesToken, IncludeToken, ArgToken, TranscludeToken } from '../internal';
|
|
7
7
|
declare type Child = ExtToken | NoincludeToken | CommentToken | IncludeToken | ArgToken | TranscludeToken;
|
|
8
8
|
/**
|
|
9
|
+
* extension tag that has a nested structure
|
|
10
|
+
*
|
|
9
11
|
* 嵌套式的扩展标签
|
|
10
|
-
* @classdesc `{childNodes:
|
|
12
|
+
* @classdesc `{childNodes: (ExtToken|NoincludeToken|CommentToken)[]}`
|
|
11
13
|
*/
|
|
12
14
|
export declare abstract class NestedToken extends Token {
|
|
13
15
|
#private;
|
package/dist/src/nested.js
CHANGED
|
@@ -11,8 +11,10 @@ const ext_1 = require("./tagPair/ext");
|
|
|
11
11
|
const noinclude_1 = require("./nowiki/noinclude");
|
|
12
12
|
const childTypes = new Set(['comment', 'include', 'arg', 'template', 'magic-word']);
|
|
13
13
|
/**
|
|
14
|
+
* extension tag that has a nested structure
|
|
15
|
+
*
|
|
14
16
|
* 嵌套式的扩展标签
|
|
15
|
-
* @classdesc `{childNodes:
|
|
17
|
+
* @classdesc `{childNodes: (ExtToken|NoincludeToken|CommentToken)[]}`
|
|
16
18
|
*/
|
|
17
19
|
class NestedToken extends index_2.Token {
|
|
18
20
|
#tags;
|
|
@@ -58,10 +60,11 @@ class NestedToken extends index_2.Token {
|
|
|
58
60
|
return [
|
|
59
61
|
...super.lint(start, re),
|
|
60
62
|
...this.childNodes.filter(child => {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
+
const { type, name } = child;
|
|
64
|
+
if (type === 'ext') {
|
|
65
|
+
return !this.#tags.includes(name);
|
|
63
66
|
}
|
|
64
|
-
else if (childTypes.has(
|
|
67
|
+
else if (childTypes.has(type)) {
|
|
65
68
|
return false;
|
|
66
69
|
}
|
|
67
70
|
const str = child.toString().trim();
|
|
@@ -3,6 +3,8 @@ import type { Config } from '../../base';
|
|
|
3
3
|
import type { AstText } from '../../lib/text';
|
|
4
4
|
declare type NowikiTypes = 'ext-inner' | 'comment' | 'dd' | 'double-underscore' | 'hr' | 'list' | 'noinclude' | 'quote';
|
|
5
5
|
/**
|
|
6
|
+
* text-only token that will not be parsed
|
|
7
|
+
*
|
|
6
8
|
* 纯文字Token,不会被解析
|
|
7
9
|
* @classdesc `{childNodes: [AstText]}`
|
|
8
10
|
*/
|
|
@@ -11,7 +13,7 @@ export declare abstract class NowikiBaseToken extends Token {
|
|
|
11
13
|
readonly childNodes: readonly [AstText];
|
|
12
14
|
abstract get firstChild(): AstText;
|
|
13
15
|
abstract get lastChild(): AstText;
|
|
14
|
-
/** 纯文本部分 */
|
|
16
|
+
/** text content / 纯文本部分 */
|
|
15
17
|
get innerText(): string;
|
|
16
18
|
/** @param wikitext default: `''` */
|
|
17
19
|
constructor(wikitext?: string, config?: Config, accum?: Token[]);
|
package/dist/src/nowiki/base.js
CHANGED
|
@@ -3,11 +3,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.NowikiBaseToken = void 0;
|
|
4
4
|
const index_1 = require("../index");
|
|
5
5
|
/**
|
|
6
|
+
* text-only token that will not be parsed
|
|
7
|
+
*
|
|
6
8
|
* 纯文字Token,不会被解析
|
|
7
9
|
* @classdesc `{childNodes: [AstText]}`
|
|
8
10
|
*/
|
|
9
11
|
class NowikiBaseToken extends index_1.Token {
|
|
10
|
-
/** 纯文本部分 */
|
|
12
|
+
/** text content / 纯文本部分 */
|
|
11
13
|
get innerText() {
|
|
12
14
|
return this.firstChild.data;
|
|
13
15
|
}
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { NowikiBaseToken } from './base';
|
|
2
2
|
import type { LintError, Config } from '../../base';
|
|
3
3
|
import type { Token } from '../index';
|
|
4
|
-
/**
|
|
4
|
+
/**
|
|
5
|
+
* invisible HTML comment
|
|
6
|
+
*
|
|
7
|
+
* HTML注释,不可见
|
|
8
|
+
*/
|
|
5
9
|
export declare abstract class CommentToken extends NowikiBaseToken {
|
|
6
10
|
closed: boolean;
|
|
7
11
|
get type(): 'comment';
|
|
@@ -39,7 +39,11 @@ const lint_1 = require("../../util/lint");
|
|
|
39
39
|
const hidden_1 = require("../../mixin/hidden");
|
|
40
40
|
const index_1 = require("../../index");
|
|
41
41
|
const base_1 = require("./base");
|
|
42
|
-
/**
|
|
42
|
+
/**
|
|
43
|
+
* invisible HTML comment
|
|
44
|
+
*
|
|
45
|
+
* HTML注释,不可见
|
|
46
|
+
*/
|
|
43
47
|
let CommentToken = (() => {
|
|
44
48
|
let _classDecorators = [(0, hidden_1.hiddenToken)(false)];
|
|
45
49
|
let _classDescriptor;
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import Parser from '../../index';
|
|
2
2
|
import { NowikiBaseToken } from './base';
|
|
3
3
|
import type { Token } from '../index';
|
|
4
|
-
/**
|
|
4
|
+
/**
|
|
5
|
+
* behavior switch
|
|
6
|
+
*
|
|
7
|
+
* 状态开关
|
|
8
|
+
*/
|
|
5
9
|
export declare abstract class DoubleUnderscoreToken extends NowikiBaseToken {
|
|
6
10
|
get type(): 'double-underscore';
|
|
7
11
|
/**
|
|
@@ -38,7 +38,11 @@ exports.DoubleUnderscoreToken = void 0;
|
|
|
38
38
|
const hidden_1 = require("../../mixin/hidden");
|
|
39
39
|
const index_1 = require("../../index");
|
|
40
40
|
const base_1 = require("./base");
|
|
41
|
-
/**
|
|
41
|
+
/**
|
|
42
|
+
* behavior switch
|
|
43
|
+
*
|
|
44
|
+
* 状态开关
|
|
45
|
+
*/
|
|
42
46
|
let DoubleUnderscoreToken = (() => {
|
|
43
47
|
let _classDecorators = [(0, hidden_1.hiddenToken)()];
|
|
44
48
|
let _classDescriptor;
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { NowikiBaseToken } from './base';
|
|
2
2
|
import type { LintError } from '../../base';
|
|
3
3
|
import type { AttributesToken, ExtToken } from '../../internal';
|
|
4
|
-
/**
|
|
4
|
+
/**
|
|
5
|
+
* text-only token inside an extension tag
|
|
6
|
+
*
|
|
7
|
+
* 扩展标签内的纯文字Token
|
|
8
|
+
*/
|
|
5
9
|
export declare abstract class NowikiToken extends NowikiBaseToken {
|
|
6
10
|
readonly name: string;
|
|
7
11
|
abstract get nextSibling(): undefined;
|
package/dist/src/nowiki/index.js
CHANGED
|
@@ -4,7 +4,11 @@ exports.NowikiToken = void 0;
|
|
|
4
4
|
const lint_1 = require("../../util/lint");
|
|
5
5
|
const index_1 = require("../../index");
|
|
6
6
|
const base_1 = require("./base");
|
|
7
|
-
/**
|
|
7
|
+
/**
|
|
8
|
+
* text-only token inside an extension tag
|
|
9
|
+
*
|
|
10
|
+
* 扩展标签内的纯文字Token
|
|
11
|
+
*/
|
|
8
12
|
class NowikiToken extends base_1.NowikiBaseToken {
|
|
9
13
|
get type() {
|
|
10
14
|
return 'ext-inner';
|
package/dist/src/nowiki/list.js
CHANGED
|
@@ -2,7 +2,11 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ListToken = void 0;
|
|
4
4
|
const listBase_1 = require("./listBase");
|
|
5
|
-
/**
|
|
5
|
+
/**
|
|
6
|
+
* `;:*#` at the start of a line
|
|
7
|
+
*
|
|
8
|
+
* 位于行首的`;:*#`
|
|
9
|
+
*/
|
|
6
10
|
class ListToken extends listBase_1.ListBaseToken {
|
|
7
11
|
get type() {
|
|
8
12
|
return 'list';
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { NowikiBaseToken } from './base';
|
|
2
|
-
/**
|
|
2
|
+
/**
|
|
3
|
+
* `<noinclude>` or `</noinclude>` that allows no modification
|
|
4
|
+
*
|
|
5
|
+
* `<noinclude>`或`</noinclude>`,不可进行任何更改
|
|
6
|
+
*/
|
|
3
7
|
export declare abstract class NoincludeToken extends NowikiBaseToken {
|
|
4
8
|
get type(): 'noinclude';
|
|
5
9
|
}
|
|
@@ -37,7 +37,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
37
37
|
exports.NoincludeToken = void 0;
|
|
38
38
|
const hidden_1 = require("../../mixin/hidden");
|
|
39
39
|
const base_1 = require("./base");
|
|
40
|
-
/**
|
|
40
|
+
/**
|
|
41
|
+
* `<noinclude>` or `</noinclude>` that allows no modification
|
|
42
|
+
*
|
|
43
|
+
* `<noinclude>`或`</noinclude>`,不可进行任何更改
|
|
44
|
+
*/
|
|
41
45
|
let NoincludeToken = (() => {
|
|
42
46
|
let _classDecorators = [(0, hidden_1.hiddenToken)()];
|
|
43
47
|
let _classDescriptor;
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { NowikiBaseToken } from './base';
|
|
2
2
|
import type { LintError } from '../../base';
|
|
3
|
-
/**
|
|
3
|
+
/**
|
|
4
|
+
* `''` and `'''`
|
|
5
|
+
*
|
|
6
|
+
* `''`和`'''`
|
|
7
|
+
*/
|
|
4
8
|
export declare abstract class QuoteToken extends NowikiBaseToken {
|
|
5
9
|
get type(): 'quote';
|
|
6
10
|
/** 是否粗体 */
|
package/dist/src/nowiki/quote.js
CHANGED
|
@@ -5,7 +5,11 @@ const lint_1 = require("../../util/lint");
|
|
|
5
5
|
const rect_1 = require("../../lib/rect");
|
|
6
6
|
const index_1 = require("../../index");
|
|
7
7
|
const base_1 = require("./base");
|
|
8
|
-
/**
|
|
8
|
+
/**
|
|
9
|
+
* `''` and `'''`
|
|
10
|
+
*
|
|
11
|
+
* `''`和`'''`
|
|
12
|
+
*/
|
|
9
13
|
class QuoteToken extends base_1.NowikiBaseToken {
|
|
10
14
|
get type() {
|
|
11
15
|
return 'quote';
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { Token } from './index';
|
|
2
2
|
/**
|
|
3
|
+
* `<onlyinclude>` during transclusion
|
|
4
|
+
*
|
|
3
5
|
* 嵌入时的`<onlyinclude>`
|
|
4
|
-
* @classdesc `{childNodes:
|
|
6
|
+
* @classdesc `{childNodes: (AstText|Token)[]}`
|
|
5
7
|
*/
|
|
6
8
|
export declare class OnlyincludeToken extends Token {
|
|
7
9
|
get type(): 'onlyinclude';
|
package/dist/src/onlyinclude.js
CHANGED
|
@@ -3,8 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.OnlyincludeToken = void 0;
|
|
4
4
|
const index_1 = require("./index");
|
|
5
5
|
/**
|
|
6
|
+
* `<onlyinclude>` during transclusion
|
|
7
|
+
*
|
|
6
8
|
* 嵌入时的`<onlyinclude>`
|
|
7
|
-
* @classdesc `{childNodes:
|
|
9
|
+
* @classdesc `{childNodes: (AstText|Token)[]}`
|
|
8
10
|
*/
|
|
9
11
|
class OnlyincludeToken extends index_1.Token {
|
|
10
12
|
get type() {
|
|
@@ -5,7 +5,7 @@ import type { LintError } from '../../base';
|
|
|
5
5
|
import type { AttributesToken, ExtToken } from '../../internal';
|
|
6
6
|
/**
|
|
7
7
|
* `<dynamicpagelist>`
|
|
8
|
-
* @classdesc `{childNodes:
|
|
8
|
+
* @classdesc `{childNodes: AtomToken[]}`
|
|
9
9
|
*/
|
|
10
10
|
export declare abstract class ParamTagToken extends Token {
|
|
11
11
|
readonly name: string;
|
|
@@ -9,7 +9,7 @@ const index_2 = require("../index");
|
|
|
9
9
|
const atom_1 = require("../atom");
|
|
10
10
|
/**
|
|
11
11
|
* `<dynamicpagelist>`
|
|
12
|
-
* @classdesc `{childNodes:
|
|
12
|
+
* @classdesc `{childNodes: AtomToken[]}`
|
|
13
13
|
*/
|
|
14
14
|
class ParamTagToken extends index_2.Token {
|
|
15
15
|
get type() {
|
package/dist/src/parameter.d.ts
CHANGED
|
@@ -3,6 +3,8 @@ import { Token } from './index';
|
|
|
3
3
|
import type { LintError } from '../base';
|
|
4
4
|
import type { AtomToken, SyntaxToken, TranscludeToken } from '../internal';
|
|
5
5
|
/**
|
|
6
|
+
* template or magic word parameter
|
|
7
|
+
*
|
|
6
8
|
* 模板或魔术字参数
|
|
7
9
|
* @classdesc `{childNodes: [Token, Token]}`
|
|
8
10
|
*/
|
|
@@ -15,7 +17,7 @@ export declare abstract class ParameterToken extends Token {
|
|
|
15
17
|
abstract get nextSibling(): this | undefined;
|
|
16
18
|
abstract get previousSibling(): AtomToken | SyntaxToken | this;
|
|
17
19
|
get type(): 'parameter';
|
|
18
|
-
/** 是否是匿名参数 */
|
|
20
|
+
/** whether to be anonymous / 是否是匿名参数 */
|
|
19
21
|
get anon(): boolean;
|
|
20
22
|
/**
|
|
21
23
|
* @param key 参数名
|
package/dist/src/parameter.js
CHANGED
|
@@ -7,6 +7,8 @@ const index_1 = require("../index");
|
|
|
7
7
|
const index_2 = require("./index");
|
|
8
8
|
const linkRegex = new RegExp(`https?://${string_1.extUrlCharFirst}${string_1.extUrlChar}$`, 'iu');
|
|
9
9
|
/**
|
|
10
|
+
* template or magic word parameter
|
|
11
|
+
*
|
|
10
12
|
* 模板或魔术字参数
|
|
11
13
|
* @classdesc `{childNodes: [Token, Token]}`
|
|
12
14
|
*/
|
|
@@ -14,7 +16,7 @@ class ParameterToken extends index_2.Token {
|
|
|
14
16
|
get type() {
|
|
15
17
|
return 'parameter';
|
|
16
18
|
}
|
|
17
|
-
/** 是否是匿名参数 */
|
|
19
|
+
/** whether to be anonymous / 是否是匿名参数 */
|
|
18
20
|
get anon() {
|
|
19
21
|
return this.firstChild.length === 0;
|
|
20
22
|
}
|
package/dist/src/pre.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ import type { AstText, AttributesToken, ExtToken, ConverterToken } from '../inte
|
|
|
6
6
|
declare type Child = NoincludeToken | ConverterToken;
|
|
7
7
|
/**
|
|
8
8
|
* `<pre>`
|
|
9
|
-
* @classdesc `{childNodes:
|
|
9
|
+
* @classdesc `{childNodes: (AstText|NoincludeToken|ConverterToken)[]}`
|
|
10
10
|
*/
|
|
11
11
|
export declare abstract class PreToken extends Token {
|
|
12
12
|
readonly name: 'pre';
|
package/dist/src/pre.js
CHANGED
|
@@ -7,7 +7,7 @@ const index_2 = require("./index");
|
|
|
7
7
|
const noinclude_1 = require("./nowiki/noinclude");
|
|
8
8
|
/**
|
|
9
9
|
* `<pre>`
|
|
10
|
-
* @classdesc `{childNodes:
|
|
10
|
+
* @classdesc `{childNodes: (AstText|NoincludeToken|ConverterToken)[]}`
|
|
11
11
|
*/
|
|
12
12
|
class PreToken extends index_2.Token {
|
|
13
13
|
get type() {
|
package/dist/src/redirect.d.ts
CHANGED
package/dist/src/redirect.js
CHANGED
package/dist/src/syntax.d.ts
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { Token } from './index';
|
|
2
2
|
import type { Config, LintError } from '../base';
|
|
3
3
|
declare type SyntaxTypes = 'heading-trail' | 'magic-word-name' | 'table-syntax' | 'redirect-syntax';
|
|
4
|
-
/**
|
|
4
|
+
/**
|
|
5
|
+
* plain token that satisfies specific grammar syntax
|
|
6
|
+
*
|
|
7
|
+
* 满足特定语法格式的plain Token
|
|
8
|
+
*/
|
|
5
9
|
export declare class SyntaxToken extends Token {
|
|
6
10
|
#private;
|
|
7
11
|
get type(): SyntaxTypes;
|
package/dist/src/syntax.js
CHANGED
|
@@ -2,7 +2,11 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SyntaxToken = void 0;
|
|
4
4
|
const index_1 = require("./index");
|
|
5
|
-
/**
|
|
5
|
+
/**
|
|
6
|
+
* plain token that satisfies specific grammar syntax
|
|
7
|
+
*
|
|
8
|
+
* 满足特定语法格式的plain Token
|
|
9
|
+
*/
|
|
6
10
|
class SyntaxToken extends index_1.Token {
|
|
7
11
|
#type;
|
|
8
12
|
get type() {
|
package/dist/src/table/base.js
CHANGED
|
@@ -7,8 +7,10 @@ const index_2 = require("../index");
|
|
|
7
7
|
const syntax_1 = require("../syntax");
|
|
8
8
|
const attributes_1 = require("../attributes");
|
|
9
9
|
/**
|
|
10
|
+
* table row that contains the newline at the beginning but not at the end
|
|
11
|
+
*
|
|
10
12
|
* 表格行,含开头的换行,不含结尾的换行
|
|
11
|
-
* @classdesc `{childNodes: [SyntaxToken, AttributesToken, ...Token]}`
|
|
13
|
+
* @classdesc `{childNodes: [SyntaxToken, AttributesToken, ...Token[]]}`
|
|
12
14
|
*/
|
|
13
15
|
class TableBaseToken extends (0, attributesParent_1.attributesParent)(1)(index_2.Token) {
|
|
14
16
|
/**
|
|
@@ -13,14 +13,16 @@ export declare const isRowEnd: ({ type }: Token) => boolean;
|
|
|
13
13
|
export declare class Layout extends Array<TableCoords[]> {
|
|
14
14
|
}
|
|
15
15
|
/**
|
|
16
|
+
* table
|
|
17
|
+
*
|
|
16
18
|
* 表格
|
|
17
|
-
* @classdesc `{childNodes: [SyntaxToken, AttributesToken, ?Token, ...TdToken, ...TrToken, ?SyntaxToken]}`
|
|
19
|
+
* @classdesc `{childNodes: [SyntaxToken, AttributesToken, ?Token, ...TdToken[], ...TrToken[], ?SyntaxToken]}`
|
|
18
20
|
*/
|
|
19
21
|
export declare abstract class TableToken extends TrBaseToken {
|
|
20
22
|
readonly childNodes: readonly [SyntaxToken, AttributesToken, ...(TdToken | TrToken)[], SyntaxToken] | readonly [SyntaxToken, AttributesToken, ...(TdToken | TrToken)[]];
|
|
21
23
|
abstract get lastChild(): AttributesToken | TdToken | TrToken | SyntaxToken;
|
|
22
24
|
get type(): 'table';
|
|
23
|
-
/** 表格是否闭合 */
|
|
25
|
+
/** whether the table is closed / 表格是否闭合 */
|
|
24
26
|
get closed(): boolean;
|
|
25
27
|
/**
|
|
26
28
|
* @param syntax 表格语法
|
|
@@ -28,12 +30,14 @@ export declare abstract class TableToken extends TrBaseToken {
|
|
|
28
30
|
*/
|
|
29
31
|
constructor(syntax: string, attr?: string, config?: Config, accum?: Token[]);
|
|
30
32
|
/**
|
|
33
|
+
* Get the table layout
|
|
34
|
+
*
|
|
31
35
|
* 获取表格布局
|
|
32
|
-
* @param stop 中止条件
|
|
33
|
-
* @param stop.row 中止行
|
|
34
|
-
* @param stop.column 中止列
|
|
35
|
-
* @param stop.x 中止行
|
|
36
|
-
* @param stop.y 中止列
|
|
36
|
+
* @param stop stop condition / 中止条件
|
|
37
|
+
* @param stop.row stop at the row / 中止行
|
|
38
|
+
* @param stop.column stop at the column / 中止列
|
|
39
|
+
* @param stop.x stop at the row / 中止行
|
|
40
|
+
* @param stop.y stop at the column / 中止列
|
|
37
41
|
*/
|
|
38
42
|
getLayout(stop?: {
|
|
39
43
|
row?: number;
|
|
@@ -41,18 +45,19 @@ export declare abstract class TableToken extends TrBaseToken {
|
|
|
41
45
|
x?: number;
|
|
42
46
|
y?: number;
|
|
43
47
|
}): Layout;
|
|
44
|
-
/** 获取所有行 */
|
|
45
|
-
getAllRows(): (TrToken | this)[];
|
|
46
48
|
/**
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
+
* Get all rows
|
|
50
|
+
*
|
|
51
|
+
* 获取所有行
|
|
49
52
|
*/
|
|
50
|
-
|
|
53
|
+
getAllRows(): (TrToken | this)[];
|
|
51
54
|
/**
|
|
55
|
+
* Get the `n`-th row
|
|
56
|
+
*
|
|
52
57
|
* 获取第n行
|
|
53
|
-
* @param n 行号
|
|
54
|
-
* @param force 是否将表格自身视为第一行
|
|
55
|
-
* @param insert 是否用于判断插入新行的位置
|
|
58
|
+
* @param n row number / 行号
|
|
59
|
+
* @param force whether to regard the table itself as the first row / 是否将表格自身视为第一行
|
|
60
|
+
* @param insert whether to be used to insert a new row / 是否用于判断插入新行的位置
|
|
56
61
|
* @throws `RangeError` 不存在该行
|
|
57
62
|
*/
|
|
58
63
|
getNthRow(n: number, force?: boolean, insert?: false): TrToken | this | undefined;
|
package/dist/src/table/index.js
CHANGED
|
@@ -25,14 +25,16 @@ class Layout extends Array {
|
|
|
25
25
|
}
|
|
26
26
|
exports.Layout = Layout;
|
|
27
27
|
/**
|
|
28
|
+
* table
|
|
29
|
+
*
|
|
28
30
|
* 表格
|
|
29
|
-
* @classdesc `{childNodes: [SyntaxToken, AttributesToken, ?Token, ...TdToken, ...TrToken, ?SyntaxToken]}`
|
|
31
|
+
* @classdesc `{childNodes: [SyntaxToken, AttributesToken, ?Token, ...TdToken[], ...TrToken[], ?SyntaxToken]}`
|
|
30
32
|
*/
|
|
31
33
|
class TableToken extends trBase_1.TrBaseToken {
|
|
32
34
|
get type() {
|
|
33
35
|
return 'table';
|
|
34
36
|
}
|
|
35
|
-
/** 表格是否闭合 */
|
|
37
|
+
/** whether the table is closed / 表格是否闭合 */
|
|
36
38
|
get closed() {
|
|
37
39
|
return this.lastChild.type === 'table-syntax';
|
|
38
40
|
}
|
|
@@ -80,20 +82,24 @@ class TableToken extends trBase_1.TrBaseToken {
|
|
|
80
82
|
}
|
|
81
83
|
/** @private */
|
|
82
84
|
close(syntax = '\n|}', halfParsed) {
|
|
83
|
-
const config = this.getAttribute('config'), accum = this.getAttribute('accum'), inner = halfParsed
|
|
85
|
+
const config = this.getAttribute('config'), accum = this.getAttribute('accum'), inner = halfParsed
|
|
86
|
+
? [syntax]
|
|
87
|
+
: index_1.default.parse(syntax, this.getAttribute('include'), 2, config).childNodes;
|
|
84
88
|
debug_1.Shadow.run(() => {
|
|
85
|
-
const token = new syntax_1.SyntaxToken(undefined, closingPattern, 'table-syntax', config, accum
|
|
89
|
+
const token = new syntax_1.SyntaxToken(undefined, closingPattern, 'table-syntax', config, accum);
|
|
86
90
|
super.insertAt(token);
|
|
87
91
|
});
|
|
88
92
|
this.lastChild.replaceChildren(...inner);
|
|
89
93
|
}
|
|
90
94
|
/**
|
|
95
|
+
* Get the table layout
|
|
96
|
+
*
|
|
91
97
|
* 获取表格布局
|
|
92
|
-
* @param stop 中止条件
|
|
93
|
-
* @param stop.row 中止行
|
|
94
|
-
* @param stop.column 中止列
|
|
95
|
-
* @param stop.x 中止行
|
|
96
|
-
* @param stop.y 中止列
|
|
98
|
+
* @param stop stop condition / 中止条件
|
|
99
|
+
* @param stop.row stop at the row / 中止行
|
|
100
|
+
* @param stop.column stop at the column / 中止列
|
|
101
|
+
* @param stop.x stop at the row / 中止行
|
|
102
|
+
* @param stop.y stop at the column / 中止列
|
|
97
103
|
*/
|
|
98
104
|
getLayout(stop) {
|
|
99
105
|
const rows = this.getAllRows(), { length } = rows, layout = new Layout(...emptyArray(length, () => []));
|
|
@@ -125,7 +131,11 @@ class TableToken extends trBase_1.TrBaseToken {
|
|
|
125
131
|
}
|
|
126
132
|
return layout;
|
|
127
133
|
}
|
|
128
|
-
/**
|
|
134
|
+
/**
|
|
135
|
+
* Get all rows
|
|
136
|
+
*
|
|
137
|
+
* 获取所有行
|
|
138
|
+
*/
|
|
129
139
|
getAllRows() {
|
|
130
140
|
return [
|
|
131
141
|
...super.getRowCount() ? [this] : [],
|
|
@@ -133,18 +143,6 @@ class TableToken extends trBase_1.TrBaseToken {
|
|
|
133
143
|
.filter((child) => child.type === 'tr' && child.getRowCount() > 0),
|
|
134
144
|
];
|
|
135
145
|
}
|
|
136
|
-
/**
|
|
137
|
-
* 获取指定坐标的单元格
|
|
138
|
-
* @param coords 表格坐标
|
|
139
|
-
*/
|
|
140
|
-
getNthCell(
|
|
141
|
-
// eslint-disable-next-line @stylistic/comma-dangle
|
|
142
|
-
coords) {
|
|
143
|
-
// eslint-disable-next-line prefer-const, @typescript-eslint/no-unnecessary-type-assertion
|
|
144
|
-
let rawCoords = coords;
|
|
145
|
-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
146
|
-
return rawCoords && this.getNthRow(rawCoords.row, false, false)?.getNthCol(rawCoords.column);
|
|
147
|
-
}
|
|
148
146
|
getNthRow(n, force, insert) {
|
|
149
147
|
const isRow = super.getRowCount();
|
|
150
148
|
if (n === 0
|
|
@@ -156,7 +154,8 @@ class TableToken extends trBase_1.TrBaseToken {
|
|
|
156
154
|
n--;
|
|
157
155
|
}
|
|
158
156
|
for (const child of this.childNodes.slice(2)) {
|
|
159
|
-
|
|
157
|
+
const { type } = child;
|
|
158
|
+
if (type === 'tr' && child.getRowCount()) {
|
|
160
159
|
n--;
|
|
161
160
|
if (n < 0) {
|
|
162
161
|
return child;
|