wikilint 2.39.1 → 2.40.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/config/default.json +10 -1
- package/config/enwiki.json +88 -87
- package/config/jawiki.json +162 -153
- package/config/minimum.json +2 -80
- package/config/zhwiki.json +125 -124
- package/data/signatures.json +1 -1
- package/dist/base.d.mts +6 -6
- package/dist/base.d.ts +6 -6
- package/dist/base.js +1 -0
- package/dist/base.mjs +1 -0
- package/dist/bin/config.js +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +5 -1
- package/dist/lib/lintConfig.js +12 -0
- package/dist/lib/lsp.js +6 -12
- package/dist/lib/node.js +4 -1
- package/dist/lib/text.js +4 -1
- package/dist/lib/title.js +6 -5
- package/dist/parser/commentAndExt.js +2 -1
- package/dist/src/attribute.d.ts +4 -1
- package/dist/src/attribute.js +2 -1
- package/dist/src/attributes.js +27 -3
- package/dist/src/heading.js +8 -3
- package/dist/src/link/base.d.ts +1 -1
- package/dist/src/link/base.js +10 -4
- package/dist/src/link/file.js +2 -2
- package/dist/src/link/galleryImage.js +0 -1
- package/dist/src/magicLink.js +20 -16
- package/dist/src/multiLine/gallery.d.ts +5 -3
- package/dist/src/multiLine/gallery.js +6 -3
- package/dist/src/nowiki/base.d.ts +1 -1
- package/dist/src/parameter.js +3 -1
- package/dist/src/tagPair/ext.js +11 -5
- package/dist/src/tagPair/index.d.ts +1 -1
- package/dist/src/transclude.d.ts +6 -1
- package/dist/src/transclude.js +18 -15
- package/dist/util/constants.js +2 -1
- package/i18n/en.json +1 -0
- package/i18n/zh-hans.json +1 -0
- package/i18n/zh-hant.json +1 -0
- package/package.json +10 -22
package/dist/lib/title.js
CHANGED
|
@@ -87,7 +87,8 @@ class Title {
|
|
|
87
87
|
catch /* c8 ignore next */ { }
|
|
88
88
|
}
|
|
89
89
|
title = (0, string_1.decodeHtml)(title).replace(/[_ ]+/gu, ' ').trim();
|
|
90
|
-
if (subpage
|
|
90
|
+
if (subpage
|
|
91
|
+
|| page && trimmed.startsWith('/')) {
|
|
91
92
|
this.#ns = 0;
|
|
92
93
|
}
|
|
93
94
|
else {
|
|
@@ -139,7 +140,9 @@ class Title {
|
|
|
139
140
|
#getTitle(prefix, redirect = true) {
|
|
140
141
|
let title = (prefix + this.main).replace(/ /gu, '_');
|
|
141
142
|
if (title.startsWith('/')) {
|
|
142
|
-
title =
|
|
143
|
+
title =
|
|
144
|
+
(this.page ?? '') +
|
|
145
|
+
title.replace(/(.)\/$/u, '$1');
|
|
143
146
|
}
|
|
144
147
|
else if (title.startsWith('../') && this.page?.includes('/')) {
|
|
145
148
|
const [level, sub] = resolve(title), dirs = this.page.split('/');
|
|
@@ -183,9 +186,7 @@ class Title {
|
|
|
183
186
|
if (title) {
|
|
184
187
|
return this.#path.replace('$1', encodeURIComponent(title)
|
|
185
188
|
+ (fragment
|
|
186
|
-
? `#${encodeURIComponent(
|
|
187
|
-
// eslint-disable-next-line @stylistic/comma-dangle
|
|
188
|
-
fragment)}`
|
|
189
|
+
? `#${encodeURIComponent(fragment)}`
|
|
189
190
|
: ''));
|
|
190
191
|
}
|
|
191
192
|
return fragment === undefined ? '' : `#${encodeURIComponent(fragment)}`;
|
|
@@ -91,7 +91,8 @@ const parseCommentAndExt = (wikitext, config, accum, includeOnly) => {
|
|
|
91
91
|
ch = 'c';
|
|
92
92
|
const closed = substr.endsWith('-->');
|
|
93
93
|
// @ts-expect-error abstract class
|
|
94
|
-
new comment_1.CommentToken((0, string_1.restore)(substr, accum, 1)
|
|
94
|
+
new comment_1.CommentToken((0, string_1.restore)(substr, accum, 1)
|
|
95
|
+
.slice(4, closed ? -3 : undefined), closed, config, accum);
|
|
95
96
|
}
|
|
96
97
|
else if (include) {
|
|
97
98
|
// @ts-expect-error abstract class
|
package/dist/src/attribute.d.ts
CHANGED
|
@@ -12,7 +12,10 @@ export type AttributeTypes = 'ext-attr' | 'html-attr' | 'table-attr';
|
|
|
12
12
|
export declare abstract class AttributeToken extends Token {
|
|
13
13
|
#private;
|
|
14
14
|
readonly name: string;
|
|
15
|
-
readonly childNodes: readonly [
|
|
15
|
+
readonly childNodes: readonly [
|
|
16
|
+
AtomToken,
|
|
17
|
+
Token
|
|
18
|
+
];
|
|
16
19
|
abstract get firstChild(): AtomToken;
|
|
17
20
|
abstract get lastChild(): Token;
|
|
18
21
|
abstract get parentNode(): AttributesToken | undefined;
|
package/dist/src/attribute.js
CHANGED
|
@@ -77,7 +77,8 @@ class AttributeToken extends index_2.Token {
|
|
|
77
77
|
valueToken.setAttribute('stage', 1);
|
|
78
78
|
}
|
|
79
79
|
else {
|
|
80
|
-
valueToken =
|
|
80
|
+
valueToken =
|
|
81
|
+
new atom_1.AtomToken(value, 'attr-value', config, accum, {});
|
|
81
82
|
}
|
|
82
83
|
super(undefined, config, accum);
|
|
83
84
|
this.#type = type;
|
package/dist/src/attributes.js
CHANGED
|
@@ -32,6 +32,15 @@ const wordRegex = /* #__PURE__ */ (() => {
|
|
|
32
32
|
}
|
|
33
33
|
/* c8 ignore stop */
|
|
34
34
|
})();
|
|
35
|
+
const required = new Map([
|
|
36
|
+
['indicator', ['name']],
|
|
37
|
+
['langconvert', ['from', 'to']],
|
|
38
|
+
['mapframe', ['width', 'height']],
|
|
39
|
+
['maplink', ['width', 'height']],
|
|
40
|
+
['phonos', [['ipa', 'file', 'wikibase']]],
|
|
41
|
+
['section', [['begin', 'end']]],
|
|
42
|
+
['templatestyles', ['src']],
|
|
43
|
+
]);
|
|
35
44
|
/**
|
|
36
45
|
* attributes of extension and HTML tags
|
|
37
46
|
*
|
|
@@ -57,14 +66,15 @@ class AttributesToken extends index_2.Token {
|
|
|
57
66
|
let out = '', mt = regex.exec(attr), lastIndex = 0;
|
|
58
67
|
const insertDirty = /** 插入无效属性 */ () => {
|
|
59
68
|
if (out) {
|
|
60
|
-
super.insertAt(new atom_1.AtomToken(out, toDirty(type), config, accum
|
|
69
|
+
super.insertAt(new atom_1.AtomToken(out, toDirty(type), config, accum));
|
|
61
70
|
out = '';
|
|
62
71
|
}
|
|
63
72
|
};
|
|
64
73
|
while (mt) {
|
|
65
74
|
const { index, 0: full, 1: key, 2: equal, 3: quoteStart, 4: quoted, 5: quoteEnd, 6: unquoted } = mt;
|
|
66
75
|
out += attr.slice(lastIndex, index);
|
|
67
|
-
if (/^(?:[\w:]|\0\d+t\x7F)(?:[\w:.-]|\0\d+t\x7F)*$/u
|
|
76
|
+
if (/^(?:[\w:]|\0\d+t\x7F)(?:[\w:.-]|\0\d+t\x7F)*$/u
|
|
77
|
+
.test((0, string_1.removeComment)(key).trim())) {
|
|
68
78
|
const value = quoted ?? unquoted, quotes = [quoteStart, quoteEnd],
|
|
69
79
|
// @ts-expect-error abstract class
|
|
70
80
|
token = new attribute_1.AttributeToken((0, exports.toAttributeType)(type), name, key, quotes, config, equal, value, accum);
|
|
@@ -136,7 +146,7 @@ class AttributesToken extends index_2.Token {
|
|
|
136
146
|
/** @private */
|
|
137
147
|
lint(start = this.getAbsoluteIndex(), re) {
|
|
138
148
|
LINT: {
|
|
139
|
-
const errors = super.lint(start, re), { parentNode, childNodes } = this, attrs = new Map(), duplicated = new Set(), rect = new rect_1.BoundingRect(this, start), rules = ['no-ignored', 'no-duplicate'], { lintConfig } = index_1.default, { computeEditInfo, fix } = lintConfig, s = ['closingTag', 'invalidAttributes', 'nonWordAttributes']
|
|
149
|
+
const errors = super.lint(start, re), { parentNode, childNodes, type, name: tag } = this, attrs = new Map(), duplicated = new Set(), rect = new rect_1.BoundingRect(this, start), rules = ['no-ignored', 'no-duplicate', 'required-attr'], { lintConfig } = index_1.default, { computeEditInfo, fix } = lintConfig, s = ['closingTag', 'invalidAttributes', 'nonWordAttributes']
|
|
140
150
|
.map(k => lintConfig.getSeverity(rules[0], k));
|
|
141
151
|
if (s[0] && this.#lint()) {
|
|
142
152
|
const e = (0, lint_1.generateForSelf)(this, rect, rules[0], 'attributes-of-closing-tag', s[0]);
|
|
@@ -171,6 +181,20 @@ class AttributesToken extends index_2.Token {
|
|
|
171
181
|
}
|
|
172
182
|
}
|
|
173
183
|
}
|
|
184
|
+
if (type === 'ext-attrs' && required.has(tag)) {
|
|
185
|
+
const severity = lintConfig.getSeverity(rules[2], tag);
|
|
186
|
+
if (severity) {
|
|
187
|
+
for (const key of required.get(tag)) {
|
|
188
|
+
const keys = typeof key === 'string' ? [key] : key, missing = keys.every(k => {
|
|
189
|
+
const value = this.getAttr(k);
|
|
190
|
+
return value === true || !value;
|
|
191
|
+
});
|
|
192
|
+
if (missing) {
|
|
193
|
+
errors.push((0, lint_1.generateForSelf)(this, rect, rules[2], index_1.default.msg('required-attribute', keys.join('/')), severity));
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}
|
|
174
198
|
const severity = lintConfig.getSeverity(rules[1], 'attribute');
|
|
175
199
|
if (severity && duplicated.size > 0) {
|
|
176
200
|
for (const key of duplicated) {
|
package/dist/src/heading.js
CHANGED
|
@@ -38,6 +38,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
38
38
|
};
|
|
39
39
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
40
|
exports.HeadingToken = void 0;
|
|
41
|
+
const common_1 = require("@bhsd/common");
|
|
41
42
|
const lint_1 = require("../util/lint");
|
|
42
43
|
const debug_1 = require("../util/debug");
|
|
43
44
|
const rect_1 = require("../lib/rect");
|
|
@@ -126,10 +127,14 @@ let HeadingToken = (() => {
|
|
|
126
127
|
//
|
|
127
128
|
}
|
|
128
129
|
else if (unbalancedStart) {
|
|
129
|
-
const
|
|
130
|
-
e.suggestions = [{ desc: `h${level}`, range: [e.startIndex, e.startIndex + extra
|
|
130
|
+
const extra = (0, common_1.numLeadingSpaces)(innerStr, /[^=]|$/u), newLevel = level + extra;
|
|
131
|
+
e.suggestions = [{ desc: `h${level}`, range: [e.startIndex, e.startIndex + extra], text: '' }];
|
|
131
132
|
if (newLevel < 7) {
|
|
132
|
-
e.suggestions.push({
|
|
133
|
+
e.suggestions.push({
|
|
134
|
+
desc: `h${newLevel}`,
|
|
135
|
+
range: [e.endIndex, e.endIndex],
|
|
136
|
+
text: '='.repeat(extra),
|
|
137
|
+
});
|
|
133
138
|
}
|
|
134
139
|
}
|
|
135
140
|
else {
|
package/dist/src/link/base.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ import type { Title } from '../../lib/title';
|
|
|
12
12
|
export declare abstract class LinkBaseToken extends Token {
|
|
13
13
|
#private;
|
|
14
14
|
readonly name: string;
|
|
15
|
-
abstract get type(): '
|
|
15
|
+
abstract get type(): 'gallery-image' | 'link' | 'category' | 'file' | 'redirect-target' | 'ext-inner' | 'imagemap-image';
|
|
16
16
|
readonly childNodes: readonly [AtomToken, ...Token[]];
|
|
17
17
|
abstract get firstChild(): AtomToken;
|
|
18
18
|
abstract get lastChild(): Token;
|
package/dist/src/link/base.js
CHANGED
|
@@ -74,7 +74,7 @@ let LinkBaseToken = (() => {
|
|
|
74
74
|
#title;
|
|
75
75
|
/** full link / 完整链接 */
|
|
76
76
|
get link() {
|
|
77
|
-
|
|
77
|
+
LINT: return this.#title;
|
|
78
78
|
}
|
|
79
79
|
/**
|
|
80
80
|
* @param link 链接标题
|
|
@@ -83,7 +83,7 @@ let LinkBaseToken = (() => {
|
|
|
83
83
|
*/
|
|
84
84
|
constructor(link, linkText, config = index_1.default.getConfig(), accum = [], delimiter = '|') {
|
|
85
85
|
super(undefined, config, accum, {});
|
|
86
|
-
this.insertAt(new atom_1.AtomToken(link, 'link-target', config, accum
|
|
86
|
+
this.insertAt(new atom_1.AtomToken(link, 'link-target', config, accum));
|
|
87
87
|
if (linkText !== undefined) {
|
|
88
88
|
const inner = new index_2.Token(linkText, { ...config, excludes: [...config.excludes, 'list'] }, accum);
|
|
89
89
|
inner.type = 'link-text';
|
|
@@ -123,12 +123,18 @@ let LinkBaseToken = (() => {
|
|
|
123
123
|
/** @private */
|
|
124
124
|
toString(skip) {
|
|
125
125
|
const str = super.toString(skip, this.#delimiter);
|
|
126
|
-
|
|
126
|
+
if (this.#bracket) {
|
|
127
|
+
return `[[${str}]]`;
|
|
128
|
+
}
|
|
129
|
+
return str;
|
|
127
130
|
}
|
|
128
131
|
/** @private */
|
|
129
132
|
text() {
|
|
130
133
|
const str = super.text('|');
|
|
131
|
-
|
|
134
|
+
if (this.#bracket) {
|
|
135
|
+
return `[[${str}]]`;
|
|
136
|
+
}
|
|
137
|
+
return str;
|
|
132
138
|
}
|
|
133
139
|
/** @private */
|
|
134
140
|
getAttribute(key) {
|
package/dist/src/link/file.js
CHANGED
|
@@ -74,9 +74,9 @@ class FileToken extends base_1.LinkBaseToken {
|
|
|
74
74
|
constructor(link, text, config, accum = [], delimiter = '|', type) {
|
|
75
75
|
super(link, undefined, config, accum, delimiter);
|
|
76
76
|
const { extension } = this.getTitle(true, true);
|
|
77
|
-
this.safeAppend(explode(text).map(
|
|
77
|
+
this.safeAppend(explode(text).map((part) =>
|
|
78
78
|
// @ts-expect-error abstract class
|
|
79
|
-
|
|
79
|
+
new imageParameter_1.ImageParameterToken(part, extension, type, config, accum)));
|
|
80
80
|
}
|
|
81
81
|
/** @private */
|
|
82
82
|
lint(start = this.getAbsoluteIndex(), re) {
|
package/dist/src/magicLink.js
CHANGED
|
@@ -87,7 +87,7 @@ class MagicLinkToken extends index_2.Token {
|
|
|
87
87
|
let rule = 'invalid-url', severity = lintConfig.getSeverity(rule);
|
|
88
88
|
if (severity && !this.querySelector('magic-word')) {
|
|
89
89
|
try {
|
|
90
|
-
this
|
|
90
|
+
this.#getUrl();
|
|
91
91
|
}
|
|
92
92
|
catch {
|
|
93
93
|
errors.push((0, lint_1.generateForSelf)(this, rect, rule, 'invalid-url', severity));
|
|
@@ -115,6 +115,16 @@ class MagicLinkToken extends index_2.Token {
|
|
|
115
115
|
return errors;
|
|
116
116
|
}
|
|
117
117
|
}
|
|
118
|
+
/** 获取自由外链的 URL */
|
|
119
|
+
#getUrl() {
|
|
120
|
+
LINT: {
|
|
121
|
+
let { link } = this;
|
|
122
|
+
if (link.startsWith('//')) {
|
|
123
|
+
link = `https:${link}`;
|
|
124
|
+
}
|
|
125
|
+
return new URL(link);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
118
128
|
/**
|
|
119
129
|
* Get the URL
|
|
120
130
|
*
|
|
@@ -123,22 +133,16 @@ class MagicLinkToken extends index_2.Token {
|
|
|
123
133
|
*/
|
|
124
134
|
getUrl(articlePath) {
|
|
125
135
|
LSP: {
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
if (type === 'magic-link') {
|
|
129
|
-
if (link.startsWith('ISBN')) {
|
|
130
|
-
return this
|
|
131
|
-
.normalizeTitle(`BookSources/${link.slice(5)}`, -1, { temporary: true })
|
|
132
|
-
.getUrl(articlePath);
|
|
133
|
-
}
|
|
134
|
-
link = link.startsWith('RFC')
|
|
135
|
-
? `https://datatracker.ietf.org/doc/html/rfc${link.slice(4)}`
|
|
136
|
-
: `https://pubmed.ncbi.nlm.nih.gov/${link.slice(5)}`;
|
|
137
|
-
}
|
|
138
|
-
else if (link.startsWith('//')) {
|
|
139
|
-
link = `https:${link}`;
|
|
136
|
+
if (this.type !== 'magic-link') {
|
|
137
|
+
return this.#getUrl();
|
|
140
138
|
}
|
|
141
|
-
|
|
139
|
+
const { link } = this;
|
|
140
|
+
return link.startsWith('ISBN')
|
|
141
|
+
? this.normalizeTitle(`BookSources/${link.slice(5)}`, -1, { temporary: true })
|
|
142
|
+
.getUrl(articlePath)
|
|
143
|
+
: new URL(link.startsWith('RFC')
|
|
144
|
+
? `https://datatracker.ietf.org/doc/html/rfc${link.slice(4)}`
|
|
145
|
+
: `https://pubmed.ncbi.nlm.nih.gov/${link.slice(5)}`);
|
|
142
146
|
}
|
|
143
147
|
}
|
|
144
148
|
}
|
|
@@ -3,6 +3,7 @@ import { GalleryImageToken } from '../link/galleryImage';
|
|
|
3
3
|
import { CommentLineToken } from '../nowiki/commentLine';
|
|
4
4
|
import type { Config, LintError } from '../../base';
|
|
5
5
|
import type { AstText, Token } from '../../internal';
|
|
6
|
+
declare type Child = GalleryImageToken | CommentLineToken | AstText;
|
|
6
7
|
/**
|
|
7
8
|
* `<gallery>`
|
|
8
9
|
* @classdesc `{childNodes: (GalleryImageToken|CommentLineToken|AstText)[]}`
|
|
@@ -10,9 +11,10 @@ import type { AstText, Token } from '../../internal';
|
|
|
10
11
|
export declare abstract class GalleryToken extends MultiLineToken {
|
|
11
12
|
#private;
|
|
12
13
|
readonly name: 'gallery';
|
|
13
|
-
readonly childNodes: readonly
|
|
14
|
-
abstract get firstChild():
|
|
15
|
-
abstract get lastChild():
|
|
14
|
+
readonly childNodes: readonly Child[];
|
|
15
|
+
abstract get firstChild(): Child | undefined;
|
|
16
|
+
abstract get lastChild(): Child | undefined;
|
|
16
17
|
/** @param inner 标签内部wikitext */
|
|
17
18
|
constructor(inner?: string, config?: Config, accum?: Token[]);
|
|
18
19
|
}
|
|
20
|
+
export {};
|
|
@@ -20,8 +20,10 @@ class GalleryToken extends index_2.MultiLineToken {
|
|
|
20
20
|
for (const line of inner?.split('\n') ?? []) {
|
|
21
21
|
const matches = /^([^|]+)(?:\|(.*))?/u.exec(line);
|
|
22
22
|
if (!matches) {
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
super.insertAt((line.trim()
|
|
24
|
+
// @ts-expect-error abstract class
|
|
25
|
+
? new commentLine_1.CommentLineToken(line, config, accum)
|
|
26
|
+
: line));
|
|
25
27
|
continue;
|
|
26
28
|
}
|
|
27
29
|
const [, file, alt] = matches;
|
|
@@ -30,8 +32,9 @@ class GalleryToken extends index_2.MultiLineToken {
|
|
|
30
32
|
super.insertAt(new galleryImage_1.GalleryImageToken('gallery', file, alt, config, accum));
|
|
31
33
|
}
|
|
32
34
|
else {
|
|
35
|
+
super.insertAt(
|
|
33
36
|
// @ts-expect-error abstract class
|
|
34
|
-
|
|
37
|
+
new commentLine_1.CommentLineToken(line, config, accum));
|
|
35
38
|
}
|
|
36
39
|
}
|
|
37
40
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Token } from '../index';
|
|
2
2
|
import type { Config } from '../../base';
|
|
3
3
|
import type { AstText } from '../../internal';
|
|
4
|
-
declare type NowikiTypes = 'ext-inner' | 'comment' | 'dd' | 'double-underscore' | 'hr' | 'list' | '
|
|
4
|
+
declare type NowikiTypes = 'ext-inner' | 'comment' | 'dd' | 'double-underscore' | 'hr' | 'list' | 'quote' | 'noinclude';
|
|
5
5
|
/**
|
|
6
6
|
* text-only token that will not be parsed
|
|
7
7
|
*
|
package/dist/src/parameter.js
CHANGED
|
@@ -38,7 +38,9 @@ class ParameterToken extends index_2.Token {
|
|
|
38
38
|
}
|
|
39
39
|
/** @private */
|
|
40
40
|
trimName(name, set = true) {
|
|
41
|
-
const trimmed = (typeof name === 'string'
|
|
41
|
+
const trimmed = (typeof name === 'string'
|
|
42
|
+
? name :
|
|
43
|
+
name.toString(true))
|
|
42
44
|
.replace(/^[ \t\n\0\v]+|([^ \t\n\0\v])[ \t\n\0\v]+$/gu, '$1');
|
|
43
45
|
this.setAttribute('name', trimmed);
|
|
44
46
|
return trimmed;
|
package/dist/src/tagPair/ext.js
CHANGED
|
@@ -106,11 +106,17 @@ let ExtToken = (() => {
|
|
|
106
106
|
case 'seo':
|
|
107
107
|
case 'langconvert':
|
|
108
108
|
case 'phonos':
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
109
|
+
switch (lcName) {
|
|
110
|
+
case 'poem':
|
|
111
|
+
newConfig.excludes.push('heading');
|
|
112
|
+
break;
|
|
113
|
+
case 'langconvert':
|
|
114
|
+
newConfig.excludes.push('list');
|
|
115
|
+
break;
|
|
116
|
+
case 'tab':
|
|
117
|
+
newConfig.ext = newConfig.ext.filter(e => e !== 'tabs');
|
|
118
|
+
break;
|
|
119
|
+
// No default
|
|
114
120
|
}
|
|
115
121
|
innerToken = new index_2.Token(inner, newConfig, accum);
|
|
116
122
|
break;
|
|
@@ -10,7 +10,7 @@ export declare abstract class TagPairToken extends Token {
|
|
|
10
10
|
#private;
|
|
11
11
|
readonly name: string;
|
|
12
12
|
closed: boolean;
|
|
13
|
-
abstract get type(): 'ext' | '
|
|
13
|
+
abstract get type(): 'ext' | 'translate' | 'include';
|
|
14
14
|
readonly childNodes: readonly [AstNodes, AstNodes];
|
|
15
15
|
abstract get firstChild(): AstNodes;
|
|
16
16
|
abstract get lastChild(): AstNodes;
|
package/dist/src/transclude.d.ts
CHANGED
|
@@ -13,7 +13,12 @@ export declare abstract class TranscludeToken extends Token {
|
|
|
13
13
|
#private;
|
|
14
14
|
readonly modifier: string;
|
|
15
15
|
readonly name: string;
|
|
16
|
-
readonly childNodes: readonly [
|
|
16
|
+
readonly childNodes: readonly [
|
|
17
|
+
SyntaxToken,
|
|
18
|
+
AtomToken,
|
|
19
|
+
AtomToken,
|
|
20
|
+
...ParameterToken[]
|
|
21
|
+
] | readonly [AtomToken | SyntaxToken, ...ParameterToken[]];
|
|
17
22
|
abstract get firstChild(): AtomToken | SyntaxToken;
|
|
18
23
|
abstract get lastChild(): AtomToken | SyntaxToken | ParameterToken;
|
|
19
24
|
get type(): 'template' | 'magic-word';
|
package/dist/src/transclude.js
CHANGED
|
@@ -174,7 +174,9 @@ let TranscludeToken = (() => {
|
|
|
174
174
|
let i = 1;
|
|
175
175
|
for (let j = 0; j < parts.length; j++) {
|
|
176
176
|
const part = parts[j];
|
|
177
|
-
if (!(templateLike
|
|
177
|
+
if (!(templateLike
|
|
178
|
+
|| this.name === 'switch' && j > 0
|
|
179
|
+
|| this.name === 'tag' && j > 1)) {
|
|
178
180
|
part[0] = part.join('=');
|
|
179
181
|
part.length = 1;
|
|
180
182
|
}
|
|
@@ -212,11 +214,15 @@ let TranscludeToken = (() => {
|
|
|
212
214
|
* 是否是模板或模块
|
|
213
215
|
*/
|
|
214
216
|
isTemplate() {
|
|
215
|
-
return this.type === 'template'
|
|
217
|
+
return this.type === 'template'
|
|
218
|
+
|| this.name === 'invoke';
|
|
216
219
|
}
|
|
217
220
|
/** 获取模板或模块名 */
|
|
218
221
|
#getTitle() {
|
|
219
|
-
const isTemplate = this.type === 'template', title = this.normalizeTitle((isTemplate ? '' : 'Module:')
|
|
222
|
+
const isTemplate = this.type === 'template', title = this.normalizeTitle((isTemplate ? '' : 'Module:')
|
|
223
|
+
+ (0, string_1.removeComment)(this.childNodes[isTemplate ?
|
|
224
|
+
0
|
|
225
|
+
: 1].text()), 10, { temporary: true, ...!isTemplate && { page: '' } });
|
|
220
226
|
return title;
|
|
221
227
|
}
|
|
222
228
|
/** @private */
|
|
@@ -244,14 +250,15 @@ let TranscludeToken = (() => {
|
|
|
244
250
|
}
|
|
245
251
|
/** @private */
|
|
246
252
|
text() {
|
|
247
|
-
const { childNodes, length, firstChild, modifier, type, name } = this;
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
253
|
+
const { childNodes, length, firstChild, modifier, type, name, } = this;
|
|
254
|
+
if (type === 'magic-word' && name === 'vardefine') {
|
|
255
|
+
return '';
|
|
256
|
+
}
|
|
257
|
+
return `{{${modifier}${type === 'magic-word'
|
|
258
|
+
? firstChild.text()
|
|
259
|
+
+ (length === 1 ? '' : this.#colon)
|
|
260
|
+
+ (0, string_1.text)(childNodes.slice(1), '|')
|
|
261
|
+
: super.text('|')}}}`;
|
|
255
262
|
}
|
|
256
263
|
/** @private */
|
|
257
264
|
getAttribute(key) {
|
|
@@ -320,10 +327,8 @@ let TranscludeToken = (() => {
|
|
|
320
327
|
}
|
|
321
328
|
}
|
|
322
329
|
#handleAnonArgChange(addedToken, append) {
|
|
323
|
-
/* eslint-disable @stylistic/operator-linebreak */
|
|
324
330
|
this.#anonCount +=
|
|
325
331
|
1;
|
|
326
|
-
/* eslint-enable @stylistic/operator-linebreak */
|
|
327
332
|
let i;
|
|
328
333
|
// eslint-disable-next-line prefer-const
|
|
329
334
|
i = this.#anonCount - 1;
|
|
@@ -361,9 +366,7 @@ let TranscludeToken = (() => {
|
|
|
361
366
|
args = this.#args.get(keyStr);
|
|
362
367
|
}
|
|
363
368
|
else {
|
|
364
|
-
/* eslint-disable @stylistic/function-paren-newline */
|
|
365
369
|
args = new Set();
|
|
366
|
-
/* eslint-enable @stylistic/function-paren-newline */
|
|
367
370
|
this.#args.set(keyStr, args);
|
|
368
371
|
}
|
|
369
372
|
return args;
|
package/dist/util/constants.js
CHANGED
|
@@ -8,8 +8,9 @@ var BuildMethod;
|
|
|
8
8
|
BuildMethod[BuildMethod["Text"] = 1] = "Text";
|
|
9
9
|
})(BuildMethod || (exports.BuildMethod = BuildMethod = {}));
|
|
10
10
|
exports.enMsg = (() => {
|
|
11
|
+
LSP: return require(
|
|
11
12
|
// eslint-disable-next-line n/no-missing-require
|
|
12
|
-
|
|
13
|
+
'../../i18n/en.json');
|
|
13
14
|
})();
|
|
14
15
|
exports.galleryParams = new Set(['alt', 'link', 'lang', 'page', 'caption']);
|
|
15
16
|
exports.extensions = new Set(['tiff', 'tif', 'png', 'gif', 'jpg', 'jpeg', 'webp', 'xcf', 'pdf', 'svg', 'djvu']);
|
package/i18n/en.json
CHANGED
|
@@ -67,6 +67,7 @@
|
|
|
67
67
|
"redirect-like": "redirect-like syntax in a list item",
|
|
68
68
|
"ref-in-link": "<ref> in an internal or external link",
|
|
69
69
|
"remove": null,
|
|
70
|
+
"required-attribute": "required $1 attribute is missing",
|
|
70
71
|
"template-in-link": "template in an internal link target",
|
|
71
72
|
"unbalanced-in-section-header": "unbalanced $1 in a section header",
|
|
72
73
|
"unclosed": "unclosed $1",
|
package/i18n/zh-hans.json
CHANGED
package/i18n/zh-hant.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wikilint",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.40.0",
|
|
4
4
|
"description": "A Node.js linter for MediaWiki markup",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"mediawiki",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"build:define": "bash sed.sh -i \"s/pkg = \\$PKG/pkg = $(npm pkg get name)/; s/version = \\$VERSION/version = $(npm pkg get version)/\" dist/bin/config.js",
|
|
46
46
|
"build": "npm run build:core",
|
|
47
47
|
"diff": "bash diff.sh",
|
|
48
|
-
"diff:stat": "f() { git diff --stat
|
|
48
|
+
"diff:stat": "f() { git diff --stat -w --color=always $1 $2 -- . | grep '\\.ts'; }; f",
|
|
49
49
|
"lint:ts": "tsc --noEmit && eslint --cache .",
|
|
50
50
|
"lint:json": "v8r -s config/.schema.json config/*.json && v8r -s data/.schema.json data/*.json && mocha dist/test/json.js",
|
|
51
51
|
"lint:md": "markdownlint-cli2 '*.md'",
|
|
@@ -74,53 +74,41 @@
|
|
|
74
74
|
]
|
|
75
75
|
},
|
|
76
76
|
"dependencies": {
|
|
77
|
-
"@bhsd/cm-util": "^1.
|
|
78
|
-
"@bhsd/common": "^2.
|
|
77
|
+
"@bhsd/cm-util": "^1.1.0",
|
|
78
|
+
"@bhsd/common": "^2.2.1",
|
|
79
79
|
"@bhsd/stylelint-util": "^1.0.2",
|
|
80
80
|
"binary-search": "^1.3.6",
|
|
81
81
|
"vscode-languageserver-types": "^3.17.5"
|
|
82
82
|
},
|
|
83
83
|
"optionalDependencies": {
|
|
84
|
-
"color-name": "
|
|
84
|
+
"color-name": "~2.0.2",
|
|
85
85
|
"entities": "^8.0.0",
|
|
86
86
|
"mathoid-texvcjs": "^0.6.0",
|
|
87
|
-
"stylelint": "^17.
|
|
87
|
+
"stylelint": "^17.11.0",
|
|
88
88
|
"vscode-css-languageservice": "^6.3.10",
|
|
89
89
|
"vscode-html-languageservice": "^5.6.2",
|
|
90
90
|
"vscode-json-languageservice": "^5.7.2"
|
|
91
91
|
},
|
|
92
92
|
"devDependencies": {
|
|
93
|
-
"@bhsd/code-standard": "^2.2
|
|
93
|
+
"@bhsd/code-standard": "^2.4.2",
|
|
94
94
|
"@bhsd/nodejs": "^1.0.0",
|
|
95
|
-
"@bhsd/test-util": "^1.
|
|
96
|
-
"@eslint-community/eslint-plugin-eslint-comments": "^4.7.1",
|
|
97
|
-
"@stylistic/eslint-plugin": "^5.10.0",
|
|
95
|
+
"@bhsd/test-util": "^1.2.0",
|
|
98
96
|
"@types/color-name": "^2.0.0",
|
|
99
97
|
"@types/color-rgba": "^2.1.3",
|
|
100
98
|
"@types/mocha": "^10.0.10",
|
|
101
99
|
"@types/node": "^24.11.0",
|
|
102
|
-
"@typescript-eslint/
|
|
103
|
-
"@typescript-eslint/parser": "^8.59.0",
|
|
100
|
+
"@typescript-eslint/parser": "^8.59.2",
|
|
104
101
|
"c8": "^11.0.0",
|
|
105
102
|
"color-rgba": "^3.0.0",
|
|
106
103
|
"diff2html-cli": "^5.2.15",
|
|
107
104
|
"esbuild": "^0.28.0",
|
|
108
|
-
"eslint": "^10.
|
|
109
|
-
"eslint-plugin-jsdoc": "^62.9.0",
|
|
110
|
-
"eslint-plugin-jsonc": "^3.1.2",
|
|
111
|
-
"eslint-plugin-n": "^17.24.0",
|
|
112
|
-
"eslint-plugin-promise": "^7.2.1",
|
|
113
|
-
"eslint-plugin-regexp": "^3.1.0",
|
|
114
|
-
"eslint-plugin-unicorn": "^64.0.0",
|
|
105
|
+
"eslint": "^10.3.0",
|
|
115
106
|
"markdownlint-cli2": "^0.22.1",
|
|
116
107
|
"mocha": "^11.7.5",
|
|
117
108
|
"typescript": "^6.0.3",
|
|
118
109
|
"v8r": "^6.0.0",
|
|
119
110
|
"vscode-languageserver-textdocument": "^1.0.12"
|
|
120
111
|
},
|
|
121
|
-
"overrides": {
|
|
122
|
-
"eslint": "^10.2.1"
|
|
123
|
-
},
|
|
124
112
|
"engines": {
|
|
125
113
|
"node": "^20.19.0 || ^22.13.0 || >=24.11.0"
|
|
126
114
|
}
|