wikilint 2.44.0 → 2.46.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 +1 -2
- package/config/enwiki.json +1 -1
- package/config/jawiki.json +1 -1
- package/config/minimum.json +1 -1
- package/config/zhwiki.json +1 -1
- package/data/ext/templatedata.json +13 -5
- package/data/signatures.json +38 -32
- package/dist/base.d.mts +10 -2
- package/dist/base.d.ts +10 -2
- package/dist/bin/config.js +1 -1
- package/dist/index.js +1 -1
- package/dist/internal.d.ts +6 -1
- package/dist/lib/element.js +5 -5
- package/dist/lib/lintConfig.js +7 -0
- package/dist/lib/lsp.d.ts +11 -3
- package/dist/lib/lsp.js +91 -59
- package/dist/lib/node.js +2 -2
- package/dist/lib/text.js +2 -2
- package/dist/map.d.ts +4 -1
- package/dist/mixin/elementLike.js +29 -31
- package/dist/mixin/hidden.js +0 -1
- package/dist/mixin/paramLineParent.d.ts +29 -0
- package/dist/mixin/paramLineParent.js +51 -0
- package/dist/src/arg.js +17 -35
- package/dist/src/atom.d.ts +1 -1
- package/dist/src/atom.js +2 -0
- package/dist/src/attribute.js +10 -5
- package/dist/src/attributes.js +18 -15
- package/dist/src/commented.d.ts +1 -0
- package/dist/src/commented.js +1 -3
- package/dist/src/converterFlags.js +18 -21
- package/dist/src/converterRule.js +2 -2
- package/dist/src/funcTag.d.ts +23 -0
- package/dist/src/funcTag.js +85 -0
- package/dist/src/heading.js +8 -3
- package/dist/src/hidden.d.ts +3 -2
- package/dist/src/hidden.js +29 -5
- package/dist/src/imageParameter.js +16 -4
- package/dist/src/index.js +2 -2
- package/dist/src/link/base.js +14 -2
- package/dist/src/link/categorytree.d.ts +2 -0
- package/dist/src/link/categorytree.js +8 -5
- package/dist/src/link/file.js +21 -14
- package/dist/src/multiLine/charinsert.d.ts +16 -0
- package/dist/src/multiLine/charinsert.js +84 -0
- package/dist/src/multiLine/gallery.js +4 -4
- package/dist/src/multiLine/imagemap.d.ts +1 -1
- package/dist/src/multiLine/imagemap.js +13 -12
- package/dist/src/multiLine/index.d.ts +3 -0
- package/dist/src/multiLine/index.js +79 -18
- package/dist/src/multiLine/inputbox.d.ts +1 -0
- package/dist/src/multiLine/paramTag.d.ts +3 -0
- package/dist/src/multiLine/paramTag.js +60 -13
- package/dist/src/nested.js +23 -25
- package/dist/src/nowiki/quote.js +6 -5
- package/dist/src/paramLine.d.ts +23 -3
- package/dist/src/paramLine.js +129 -31
- package/dist/src/parameter.d.ts +6 -0
- package/dist/src/parameter.js +15 -1
- package/dist/src/singleLine/charinsertLine.d.ts +21 -0
- package/dist/src/singleLine/charinsertLine.js +69 -0
- package/dist/src/{imagemapLink.d.ts → singleLine/imagemapLink.d.ts} +8 -7
- package/dist/src/singleLine/imagemapLink.js +95 -0
- package/dist/src/singleLine/index.d.ts +10 -0
- package/dist/src/singleLine/index.js +16 -0
- package/dist/src/table/td.js +5 -4
- package/dist/src/tag/html.js +26 -8
- package/dist/src/tag/index.js +30 -17
- package/dist/src/tagPair/ext.js +23 -2
- package/dist/src/tagPair/index.js +1 -10
- package/dist/src/transclude.js +15 -15
- package/dist/util/sharable.js +22 -0
- package/dist/util/sharable.mjs +22 -0
- package/dist/util/string.js +27 -2
- package/i18n/en.json +4 -0
- package/i18n/zh-hans.json +4 -0
- package/i18n/zh-hant.json +4 -0
- package/package.json +17 -25
- package/dist/src/imagemapLink.js +0 -34
- /package/dist/{util → vendor}/search.js +0 -0
package/dist/src/atom.js
CHANGED
package/dist/src/attribute.js
CHANGED
|
@@ -14,7 +14,7 @@ const index_2 = require("./index");
|
|
|
14
14
|
const atom_1 = require("./atom");
|
|
15
15
|
/* NOT FOR BROWSER ONLY */
|
|
16
16
|
const document_1 = require("../lib/document");
|
|
17
|
-
const insecureStyle = /expression|(?:accelerator|-o-link(?:-source)?|-o-replace)\s*:|(?:url|src|image(?:-set)?)\s*\(|attr\s*\([^)]+[\s,]url/u, evil = /(?:^|\s|\*\/)(?:java|vb)script(?:\W|$)/iu, complexTypes = new Set(['ext', 'arg', 'magic-word', 'template']), urlAttrs = new Set([
|
|
17
|
+
const insecureStyle = /expression|(?:accelerator|-o-link(?:-source)?|-o-replace)\s*:|(?:url|src|image(?:-set)?)\s*\(|attr\s*\([^)]+[\s,]url/u, evil = /(?:^|\s|\*\/)(?:java|vb)script(?:\W|$)/iu, complexTypes = new Set(['ext', 'arg', 'magic-word', 'template']), itemAttrs = new Set(['itemtype', 'itemid', 'itemref']), urlAttrs = new Set([
|
|
18
18
|
'about',
|
|
19
19
|
'property',
|
|
20
20
|
'resource',
|
|
@@ -88,9 +88,13 @@ class AttributeToken extends index_2.Token {
|
|
|
88
88
|
this.#tag = tag;
|
|
89
89
|
this.setAttribute('name', (0, string_1.trimLc)((0, string_1.removeComment)(key)));
|
|
90
90
|
}
|
|
91
|
+
/** 获取name */
|
|
92
|
+
#getName() {
|
|
93
|
+
return (0, string_1.trimLc)(this.firstChild.text());
|
|
94
|
+
}
|
|
91
95
|
/** 更新name */
|
|
92
96
|
#setName() {
|
|
93
|
-
this.setAttribute('name',
|
|
97
|
+
this.setAttribute('name', this.#getName());
|
|
94
98
|
}
|
|
95
99
|
/** @private */
|
|
96
100
|
afterBuild() {
|
|
@@ -110,7 +114,9 @@ class AttributeToken extends index_2.Token {
|
|
|
110
114
|
}
|
|
111
115
|
/** @private */
|
|
112
116
|
text() {
|
|
113
|
-
|
|
117
|
+
// eslint-disable-next-line @typescript-eslint/no-useless-default-assignment
|
|
118
|
+
const { lastChild, name = this.#getName() } = this;
|
|
119
|
+
return this.#equal ? `${name}${this.#equal.trim()}"${lastChild.text()}"` : name;
|
|
114
120
|
}
|
|
115
121
|
/** @private */
|
|
116
122
|
getGaps() {
|
|
@@ -138,8 +144,7 @@ class AttributeToken extends index_2.Token {
|
|
|
138
144
|
// 或非通用HTML属性
|
|
139
145
|
|| !/^(?:xmlns:[\w:.-]+|data-(?!ooui|mw|parsoid)[^:_]*)$/u.test(name)
|
|
140
146
|
&& (tag === 'meta' || tag === 'link' || !sharable_1.commonHtmlAttrs.has(name)))
|
|
141
|
-
|| (name
|
|
142
|
-
&& !parentNode?.hasAttr('itemscope')) {
|
|
147
|
+
|| itemAttrs.has(name) && !parentNode?.hasAttr('itemscope')) {
|
|
143
148
|
LINT: {
|
|
144
149
|
const s = lintConfig.getSeverity(rule, 'unknown');
|
|
145
150
|
if (s) {
|
package/dist/src/attributes.js
CHANGED
|
@@ -124,10 +124,8 @@ class AttributesToken extends index_2.Token {
|
|
|
124
124
|
* @param key attribute name / 属性名
|
|
125
125
|
*/
|
|
126
126
|
getAttrToken(key) {
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
return tokens[tokens.length - 1];
|
|
130
|
-
}
|
|
127
|
+
const tokens = this.getAttrTokens(key);
|
|
128
|
+
return tokens[tokens.length - 1];
|
|
131
129
|
}
|
|
132
130
|
/**
|
|
133
131
|
* Get the attribute
|
|
@@ -136,7 +134,7 @@ class AttributesToken extends index_2.Token {
|
|
|
136
134
|
* @param key attribute name / 属性键
|
|
137
135
|
*/
|
|
138
136
|
getAttr(key) {
|
|
139
|
-
|
|
137
|
+
return this.getAttrToken(key)?.getValue();
|
|
140
138
|
}
|
|
141
139
|
/** 是否位于闭合标签内 */
|
|
142
140
|
#lint() {
|
|
@@ -161,7 +159,7 @@ class AttributesToken extends index_2.Token {
|
|
|
161
159
|
/** @private */
|
|
162
160
|
lint(start = this.getAbsoluteIndex(), re) {
|
|
163
161
|
LINT: {
|
|
164
|
-
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', 'required-attr', 'invalid-ref', 'no-duplicate'], { lintConfig } = index_1.default, { computeEditInfo, fix } = lintConfig, s = ['closingTag', 'invalidAttributes', 'nonWordAttributes']
|
|
162
|
+
const errors = super.lint(start, re), { parentNode, childNodes, length: l, type, name: tag } = this, attrs = new Map(), duplicated = new Set(), rect = new rect_1.BoundingRect(this, start), rules = ['no-ignored', 'required-attr', 'invalid-ref', 'no-duplicate'], { lintConfig } = index_1.default, { computeEditInfo, fix } = lintConfig, s = ['closingTag', 'invalidAttributes', 'nonWordAttributes']
|
|
165
163
|
.map(k => lintConfig.getSeverity(rules[0], k));
|
|
166
164
|
if (s[0] && this.#lint()) {
|
|
167
165
|
const e = (0, lint_1.generateForSelf)(this, rect, rules[0], 'attributes-of-closing-tag', s[0]);
|
|
@@ -174,7 +172,8 @@ class AttributesToken extends index_2.Token {
|
|
|
174
172
|
}
|
|
175
173
|
errors.push(e);
|
|
176
174
|
}
|
|
177
|
-
for (
|
|
175
|
+
for (let i = l - 1; i >= 0; i--) {
|
|
176
|
+
const attr = childNodes[i];
|
|
178
177
|
if (attr instanceof attribute_1.AttributeToken) {
|
|
179
178
|
const { name } = attr;
|
|
180
179
|
if (attrs.has(name)) {
|
|
@@ -219,20 +218,24 @@ class AttributesToken extends index_2.Token {
|
|
|
219
218
|
const severity = lintConfig.getSeverity(rules[3], 'attribute');
|
|
220
219
|
if (severity && duplicated.size > 0) {
|
|
221
220
|
for (const key of duplicated) {
|
|
222
|
-
const pairs = attrs.get(key).map(attr => [attr, attr.getValue()]);
|
|
223
|
-
|
|
224
|
-
const e = (0, lint_1.generateForChild)(attr, rect, rules[3], index_1.default.msg('duplicate-attribute', key), severity);
|
|
221
|
+
const pairs = attrs.get(key).map(attr => [attr, attr.getValue()]), { length } = pairs, duplication = Array.from({ length }), values = new Set();
|
|
222
|
+
for (let i = 0; i < length; i++) {
|
|
223
|
+
const [attr, value] = pairs[i], e = (0, lint_1.generateForChild)(attr, rect, rules[3], index_1.default.msg('duplicate-attribute', key), severity);
|
|
225
224
|
if (computeEditInfo || fix) {
|
|
226
225
|
const remove = (0, lint_1.fixByRemove)(e);
|
|
227
|
-
if (!value ||
|
|
226
|
+
if (!value || values.has(value)) {
|
|
228
227
|
e.fix = remove;
|
|
229
228
|
}
|
|
230
|
-
else
|
|
231
|
-
|
|
229
|
+
else {
|
|
230
|
+
values.add(value);
|
|
231
|
+
if (computeEditInfo) {
|
|
232
|
+
e.suggestions = [remove];
|
|
233
|
+
}
|
|
232
234
|
}
|
|
233
235
|
}
|
|
234
|
-
|
|
235
|
-
}
|
|
236
|
+
duplication[length - i - 1] = e;
|
|
237
|
+
}
|
|
238
|
+
Array.prototype.push.apply(errors, duplication);
|
|
236
239
|
}
|
|
237
240
|
}
|
|
238
241
|
return errors;
|
package/dist/src/commented.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ import type { AstText, AttributesToken, ExtToken } from '../internal';
|
|
|
7
7
|
* @classdesc `{childNodes: (AstText|CommentToken)[]}`
|
|
8
8
|
*/
|
|
9
9
|
export declare abstract class CommentedToken extends Token {
|
|
10
|
+
readonly name: 'hiero';
|
|
10
11
|
readonly childNodes: readonly (CommentToken | AstText)[];
|
|
11
12
|
abstract get firstChild(): CommentToken | AstText | undefined;
|
|
12
13
|
abstract get lastChild(): CommentToken | AstText | undefined;
|
package/dist/src/commented.js
CHANGED
|
@@ -13,9 +13,7 @@ class CommentedToken extends index_1.Token {
|
|
|
13
13
|
}
|
|
14
14
|
/** @class */
|
|
15
15
|
constructor(wikitext, config, accum = []) {
|
|
16
|
-
super(undefined, config, accum, {
|
|
17
|
-
AstText: ':', CommentToken: ':',
|
|
18
|
-
});
|
|
16
|
+
super(undefined, config, accum, {});
|
|
19
17
|
if (wikitext) {
|
|
20
18
|
let i = wikitext.indexOf('<!--'), j = i !== -1 && wikitext.indexOf('-->', i + 4), lastIndex = 0;
|
|
21
19
|
while (j !== false && j !== -1) {
|
|
@@ -77,9 +77,13 @@ let ConverterFlagsToken = (() => {
|
|
|
77
77
|
super(undefined, config, accum, {});
|
|
78
78
|
this.safeAppend(flags.map(flag => new atom_1.AtomToken(flag, 'converter-flag', config, accum)));
|
|
79
79
|
}
|
|
80
|
+
/** 获取全部转换类型标记 */
|
|
81
|
+
#getFlags() {
|
|
82
|
+
return this.childNodes.map(child => child.text().trim());
|
|
83
|
+
}
|
|
80
84
|
/** @private */
|
|
81
85
|
afterBuild() {
|
|
82
|
-
this.#flags = this
|
|
86
|
+
this.#flags = this.#getFlags();
|
|
83
87
|
super.afterBuild();
|
|
84
88
|
}
|
|
85
89
|
/** @private */
|
|
@@ -88,7 +92,7 @@ let ConverterFlagsToken = (() => {
|
|
|
88
92
|
}
|
|
89
93
|
/** @private */
|
|
90
94
|
text() {
|
|
91
|
-
return
|
|
95
|
+
return (this.#flags ?? this.#getFlags()).join(';');
|
|
92
96
|
}
|
|
93
97
|
/**
|
|
94
98
|
* Get unknown language conversion flags
|
|
@@ -96,11 +100,7 @@ let ConverterFlagsToken = (() => {
|
|
|
96
100
|
* 获取未知的转换类型标记
|
|
97
101
|
*/
|
|
98
102
|
getUnknownFlags() {
|
|
99
|
-
return new Set(this.#flags.filter(flag => /\{{3}[^{}]+\}{3}/u.test(flag)));
|
|
100
|
-
}
|
|
101
|
-
/** 从解析设置中获取语言变体 */
|
|
102
|
-
#getVariants() {
|
|
103
|
-
return new Set((0, string_1.toLowerCase)(this.getAttribute('config').variants));
|
|
103
|
+
LINT: return new Set(this.#flags.filter(flag => /\{{3}[^{}]+\}{3}/u.test(flag)));
|
|
104
104
|
}
|
|
105
105
|
/**
|
|
106
106
|
* Get language coversion flags that specify a language variant
|
|
@@ -108,16 +108,10 @@ let ConverterFlagsToken = (() => {
|
|
|
108
108
|
* 获取指定语言变体的转换标记
|
|
109
109
|
*/
|
|
110
110
|
getVariantFlags() {
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
// eslint-disable-next-line @typescript-eslint/class-methods-use-this
|
|
116
|
-
isInvalidFlag(flag, variant, unknown) {
|
|
117
|
-
return Boolean(flag)
|
|
118
|
-
&& !variant.has(flag.toLowerCase())
|
|
119
|
-
&& !unknown.has(flag)
|
|
120
|
-
&& (variant.size > 0 || !definedFlags.has(flag));
|
|
111
|
+
LINT: {
|
|
112
|
+
const variants = new Set((0, string_1.toLowerCase)(this.getAttribute('config').variants));
|
|
113
|
+
return new Set((0, string_1.toLowerCase)(this.#flags).filter(flag => variants.has(flag)));
|
|
114
|
+
}
|
|
121
115
|
}
|
|
122
116
|
/** @private */
|
|
123
117
|
lint(start = this.getAbsoluteIndex(), re) {
|
|
@@ -129,10 +123,13 @@ let ConverterFlagsToken = (() => {
|
|
|
129
123
|
}
|
|
130
124
|
const rule = 'no-ignored', s = lintConfig.getSeverity(rule, 'conversionFlag');
|
|
131
125
|
if (s) {
|
|
132
|
-
const rect = new rect_1.BoundingRect(this, start);
|
|
133
|
-
for (let i =
|
|
134
|
-
const child =
|
|
135
|
-
if (
|
|
126
|
+
const rect = new rect_1.BoundingRect(this, start), { childNodes, length } = this;
|
|
127
|
+
for (let i = length - 1; i >= 0; i--) {
|
|
128
|
+
const child = childNodes[i], flag = child.text().trim();
|
|
129
|
+
if (flag
|
|
130
|
+
&& !variantFlags.has(flag.toLowerCase())
|
|
131
|
+
&& !unknownFlags.has(flag)
|
|
132
|
+
&& (variantFlags.size > 0 || !definedFlags.has(flag))) {
|
|
136
133
|
const e = (0, lint_1.generateForChild)(child, rect, rule, 'invalid-conversion-flag', s);
|
|
137
134
|
if (computeEditInfo || fix) {
|
|
138
135
|
if (variantFlags.size === 0 && definedFlags.has(flag.toUpperCase())) {
|
|
@@ -109,8 +109,8 @@ let ConverterRuleToken = (() => {
|
|
|
109
109
|
text() {
|
|
110
110
|
const { childNodes, firstChild, lastChild } = this;
|
|
111
111
|
return childNodes.length === 3
|
|
112
|
-
? `${firstChild.text()}=>${childNodes[1].text()}:${lastChild.text()}`
|
|
113
|
-
:
|
|
112
|
+
? `${firstChild.text().trim()}=>${childNodes[1].text().trim()}:${lastChild.text().trim()}`
|
|
113
|
+
: childNodes.map(child => child.text().trim()).join(':');
|
|
114
114
|
}
|
|
115
115
|
/** @private */
|
|
116
116
|
getGaps(i) {
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Token } from './index';
|
|
2
|
+
import { ParamLineToken } from './paramLine';
|
|
3
|
+
import type { Config } from '../base';
|
|
4
|
+
import type { AttributesToken, ExtToken } from '../internal';
|
|
5
|
+
import type { ParamLineParentBase } from '../mixin/paramLineParent';
|
|
6
|
+
export interface FuncTagToken extends ParamLineParentBase {
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* `<seo>`
|
|
10
|
+
* @classdesc `{childNodes: ParamLineToken[]}`
|
|
11
|
+
*/
|
|
12
|
+
export declare abstract class FuncTagToken extends Token {
|
|
13
|
+
readonly name: 'seo';
|
|
14
|
+
readonly childNodes: readonly ParamLineToken[];
|
|
15
|
+
abstract get firstChild(): ParamLineToken | undefined;
|
|
16
|
+
abstract get lastChild(): ParamLineToken | undefined;
|
|
17
|
+
abstract get nextSibling(): undefined;
|
|
18
|
+
abstract get previousSibling(): AttributesToken | undefined;
|
|
19
|
+
abstract get parentNode(): ExtToken | undefined;
|
|
20
|
+
get type(): 'ext-inner';
|
|
21
|
+
/** @class */
|
|
22
|
+
constructor(wikitext: string | undefined, config: Config, accum: Token[]);
|
|
23
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
|
3
|
+
function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
|
|
4
|
+
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
|
5
|
+
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
|
|
6
|
+
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
|
|
7
|
+
var _, done = false;
|
|
8
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
9
|
+
var context = {};
|
|
10
|
+
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
|
|
11
|
+
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
|
|
12
|
+
context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
|
|
13
|
+
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
|
|
14
|
+
if (kind === "accessor") {
|
|
15
|
+
if (result === void 0) continue;
|
|
16
|
+
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
|
|
17
|
+
if (_ = accept(result.get)) descriptor.get = _;
|
|
18
|
+
if (_ = accept(result.set)) descriptor.set = _;
|
|
19
|
+
if (_ = accept(result.init)) initializers.unshift(_);
|
|
20
|
+
}
|
|
21
|
+
else if (_ = accept(result)) {
|
|
22
|
+
if (kind === "field") initializers.unshift(_);
|
|
23
|
+
else descriptor[key] = _;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
27
|
+
done = true;
|
|
28
|
+
};
|
|
29
|
+
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
|
|
30
|
+
var useValue = arguments.length > 2;
|
|
31
|
+
for (var i = 0; i < initializers.length; i++) {
|
|
32
|
+
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
|
33
|
+
}
|
|
34
|
+
return useValue ? value : void 0;
|
|
35
|
+
};
|
|
36
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
37
|
+
exports.FuncTagToken = void 0;
|
|
38
|
+
const paramLineParent_1 = require("../mixin/paramLineParent");
|
|
39
|
+
const index_1 = require("./index");
|
|
40
|
+
const paramLine_1 = require("./paramLine");
|
|
41
|
+
const gapped_1 = require("../mixin/gapped");
|
|
42
|
+
/**
|
|
43
|
+
* `<seo>`
|
|
44
|
+
* @classdesc `{childNodes: ParamLineToken[]}`
|
|
45
|
+
*/
|
|
46
|
+
let FuncTagToken = (() => {
|
|
47
|
+
let _classDecorators = [(0, gapped_1.gapped)(), paramLineParent_1.paramLineParent];
|
|
48
|
+
let _classDescriptor;
|
|
49
|
+
let _classExtraInitializers = [];
|
|
50
|
+
let _classThis;
|
|
51
|
+
let _classSuper = index_1.Token;
|
|
52
|
+
var FuncTagToken = class extends _classSuper {
|
|
53
|
+
static { _classThis = this; }
|
|
54
|
+
static {
|
|
55
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
56
|
+
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
57
|
+
FuncTagToken = _classThis = _classDescriptor.value;
|
|
58
|
+
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
59
|
+
__runInitializers(_classThis, _classExtraInitializers);
|
|
60
|
+
}
|
|
61
|
+
get type() {
|
|
62
|
+
return 'ext-inner';
|
|
63
|
+
}
|
|
64
|
+
/** @class */
|
|
65
|
+
constructor(wikitext, config, accum) {
|
|
66
|
+
super(undefined, config, accum, {});
|
|
67
|
+
if (wikitext) {
|
|
68
|
+
for (const parameter of wikitext.split('|')) {
|
|
69
|
+
// @ts-expect-error abstract class
|
|
70
|
+
this.insertAt(new paramLine_1.ParamLineToken('seo', parameter, config, accum));
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
/** @private */
|
|
75
|
+
toString(skip) {
|
|
76
|
+
return super.toString(skip, '|');
|
|
77
|
+
}
|
|
78
|
+
/** @private */
|
|
79
|
+
text() {
|
|
80
|
+
return this.childNodes.map(child => child.text()).filter(Boolean).join('|');
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
return FuncTagToken = _classThis;
|
|
84
|
+
})();
|
|
85
|
+
exports.FuncTagToken = FuncTagToken;
|
package/dist/src/heading.js
CHANGED
|
@@ -100,7 +100,7 @@ let HeadingToken = (() => {
|
|
|
100
100
|
/** @private */
|
|
101
101
|
text() {
|
|
102
102
|
const equals = this.#getEquals();
|
|
103
|
-
return equals + this.firstChild.text() + equals;
|
|
103
|
+
return equals + this.firstChild.text().trim() + equals;
|
|
104
104
|
}
|
|
105
105
|
/** @private */
|
|
106
106
|
getAttribute(key) {
|
|
@@ -110,10 +110,15 @@ let HeadingToken = (() => {
|
|
|
110
110
|
getGaps() {
|
|
111
111
|
return this.level;
|
|
112
112
|
}
|
|
113
|
+
/** 是否包含未成对的`=` */
|
|
114
|
+
#lint() {
|
|
115
|
+
const innerStr = this.firstChild.toString(), unbalancedStart = innerStr.startsWith('=');
|
|
116
|
+
return unbalancedStart ? 1 : innerStr.endsWith('=');
|
|
117
|
+
}
|
|
113
118
|
/** @private */
|
|
114
119
|
lint(start = this.getAbsoluteIndex(), re) {
|
|
115
120
|
LINT: {
|
|
116
|
-
const errors = super.lint(start, re), { firstChild, level } = this, innerStr = firstChild.toString(),
|
|
121
|
+
const errors = super.lint(start, re), { firstChild, level } = this, innerStr = firstChild.toString(), unbalanced = this.#lint(), rect = new rect_1.BoundingRect(this, start), s = this.inHtmlAttrs(), rules = ['h1', 'unbalanced-header', 'format-leakage'], { lintConfig } = index_1.default, { computeEditInfo, fix } = lintConfig, severities = rules.map(rule => lintConfig.getSeverity(rule, 'apostrophe'));
|
|
117
122
|
if (severities[0] && this.level === 1) {
|
|
118
123
|
const e = (0, lint_1.generateForChild)(firstChild, rect, rules[0], '<h1>', severities[0]);
|
|
119
124
|
if (computeEditInfo && !unbalanced) {
|
|
@@ -126,7 +131,7 @@ let HeadingToken = (() => {
|
|
|
126
131
|
if (!computeEditInfo || innerStr === '=') {
|
|
127
132
|
//
|
|
128
133
|
}
|
|
129
|
-
else if (
|
|
134
|
+
else if (unbalanced === 1) {
|
|
130
135
|
const extra = (0, common_1.numLeadingSpaces)(innerStr, /[^=]|$/u), newLevel = level + extra;
|
|
131
136
|
e.suggestions = [{ desc: `h${level}`, range: [e.startIndex, e.startIndex + extra], text: '' }];
|
|
132
137
|
if (newLevel < 7) {
|
package/dist/src/hidden.d.ts
CHANGED
package/dist/src/hidden.js
CHANGED
|
@@ -33,22 +33,27 @@ var __runInitializers = (this && this.__runInitializers) || function (thisArg, i
|
|
|
33
33
|
}
|
|
34
34
|
return useValue ? value : void 0;
|
|
35
35
|
};
|
|
36
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
37
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
38
|
+
};
|
|
36
39
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
37
40
|
exports.HiddenToken = void 0;
|
|
41
|
+
const lint_1 = require("../util/lint");
|
|
38
42
|
const hidden_1 = require("../mixin/hidden");
|
|
39
43
|
const noEscape_1 = require("../mixin/noEscape");
|
|
40
|
-
const index_1 = require("
|
|
44
|
+
const index_1 = __importDefault(require("../index"));
|
|
45
|
+
const index_2 = require("./index");
|
|
41
46
|
/**
|
|
42
|
-
* invisible token
|
|
47
|
+
* invisible token in triple braces
|
|
43
48
|
*
|
|
44
|
-
*
|
|
49
|
+
* 三重括号内不可见的节点
|
|
45
50
|
*/
|
|
46
51
|
let HiddenToken = (() => {
|
|
47
|
-
let _classDecorators = [(0, hidden_1.hiddenToken)(), noEscape_1.noEscape];
|
|
52
|
+
let _classDecorators = [(0, hidden_1.hiddenToken)(false), noEscape_1.noEscape];
|
|
48
53
|
let _classDescriptor;
|
|
49
54
|
let _classExtraInitializers = [];
|
|
50
55
|
let _classThis;
|
|
51
|
-
let _classSuper =
|
|
56
|
+
let _classSuper = index_2.Token;
|
|
52
57
|
var HiddenToken = class extends _classSuper {
|
|
53
58
|
static { _classThis = this; }
|
|
54
59
|
static {
|
|
@@ -61,6 +66,25 @@ let HiddenToken = (() => {
|
|
|
61
66
|
get type() {
|
|
62
67
|
return 'hidden';
|
|
63
68
|
}
|
|
69
|
+
/** @private */
|
|
70
|
+
lint(start = this.getAbsoluteIndex()) {
|
|
71
|
+
LINT: {
|
|
72
|
+
const rule = 'no-ignored', { lintConfig } = index_1.default, s = lintConfig.getSeverity(rule, 'arg');
|
|
73
|
+
if (s) {
|
|
74
|
+
const e = (0, lint_1.generateForSelf)(this, { start }, rule, 'invisible-triple-braces', s);
|
|
75
|
+
e.startIndex--;
|
|
76
|
+
e.startCol--;
|
|
77
|
+
if (lintConfig.computeEditInfo) {
|
|
78
|
+
e.suggestions = [
|
|
79
|
+
(0, lint_1.fixByRemove)(e),
|
|
80
|
+
(0, lint_1.fixByEscape)(e.startIndex, '{{!}}'),
|
|
81
|
+
];
|
|
82
|
+
}
|
|
83
|
+
return [e];
|
|
84
|
+
}
|
|
85
|
+
return [];
|
|
86
|
+
}
|
|
87
|
+
}
|
|
64
88
|
};
|
|
65
89
|
return HiddenToken = _classThis;
|
|
66
90
|
})();
|
|
@@ -62,6 +62,7 @@ const getUrl = (link) => {
|
|
|
62
62
|
}
|
|
63
63
|
return new URL(link).href;
|
|
64
64
|
};
|
|
65
|
+
const pdfExtensions = new Set(['djvu', 'djv', 'pdf']);
|
|
65
66
|
function validate(key, val, config, extOrType, halfParsed, accum) {
|
|
66
67
|
val = (0, string_1.removeComment)(val).trim();
|
|
67
68
|
let value = val.replace(key === 'link' ? /\0\d+[tq]\x7F/gu : /\0\d+t\x7F/gu, '').trim();
|
|
@@ -91,7 +92,7 @@ function validate(key, val, config, extOrType, halfParsed, accum) {
|
|
|
91
92
|
case 'manualthumb':
|
|
92
93
|
return true;
|
|
93
94
|
case 'page':
|
|
94
|
-
return (extOrType
|
|
95
|
+
return pdfExtensions.has(extOrType) && Number(value) > 0;
|
|
95
96
|
default:
|
|
96
97
|
return Boolean(value) && !isNaN(value);
|
|
97
98
|
}
|
|
@@ -201,7 +202,15 @@ let ImageParameterToken = (() => {
|
|
|
201
202
|
}
|
|
202
203
|
/** @private */
|
|
203
204
|
text() {
|
|
204
|
-
|
|
205
|
+
const { name } = this;
|
|
206
|
+
if (name === 'invalid') {
|
|
207
|
+
return '';
|
|
208
|
+
}
|
|
209
|
+
let str = super.text();
|
|
210
|
+
if (name !== 'caption') {
|
|
211
|
+
str = str.trim();
|
|
212
|
+
}
|
|
213
|
+
return this.#syntax ? this.#syntax.replace('$1', str).trim() : str;
|
|
205
214
|
}
|
|
206
215
|
/** @private */
|
|
207
216
|
isPlain() {
|
|
@@ -290,9 +299,12 @@ let ImageParameterToken = (() => {
|
|
|
290
299
|
LINT: {
|
|
291
300
|
const { name, childNodes } = this;
|
|
292
301
|
if (name === 'link') {
|
|
293
|
-
return (0, string_1.text)(childNodes.map(child => child.is('ext') && child.name === 'nowiki' ? child.innerText ?? '' : child));
|
|
302
|
+
return (0, string_1.text)(childNodes.map(child => child.is('ext') && child.name === 'nowiki' ? child.innerText ?? '' : child)).trim();
|
|
303
|
+
}
|
|
304
|
+
else if (name === 'invalid') {
|
|
305
|
+
return '';
|
|
294
306
|
}
|
|
295
|
-
return name === '
|
|
307
|
+
return name === 'caption' ? super.text() : this.#isVoid() || super.text().trim();
|
|
296
308
|
}
|
|
297
309
|
}
|
|
298
310
|
};
|
package/dist/src/index.js
CHANGED
|
@@ -372,12 +372,12 @@ class Token extends element_1.AstElement {
|
|
|
372
372
|
}
|
|
373
373
|
/** @private */
|
|
374
374
|
inTableAttrs() {
|
|
375
|
-
return this.isInside('table-attrs')
|
|
375
|
+
LINT: return this.isInside('table-attrs')
|
|
376
376
|
&& (this.closest('table-attrs,arg,parameter')?.is('table-attrs') ? 2 : 1);
|
|
377
377
|
}
|
|
378
378
|
/** @private */
|
|
379
379
|
inHtmlAttrs() {
|
|
380
|
-
return this.isInside('html-attrs') ? 2 : this.inTableAttrs();
|
|
380
|
+
LINT: return this.isInside('html-attrs') ? 2 : this.inTableAttrs();
|
|
381
381
|
}
|
|
382
382
|
/** @private */
|
|
383
383
|
lint(start = this.getAbsoluteIndex(), re) {
|
package/dist/src/link/base.js
CHANGED
|
@@ -41,6 +41,7 @@ exports.LinkBaseToken = void 0;
|
|
|
41
41
|
const lint_1 = require("../../util/lint");
|
|
42
42
|
const constants_1 = require("../../util/constants");
|
|
43
43
|
const debug_1 = require("../../util/debug");
|
|
44
|
+
const string_1 = require("../../util/string");
|
|
44
45
|
const rect_1 = require("../../lib/rect");
|
|
45
46
|
const padded_1 = require("../../mixin/padded");
|
|
46
47
|
const noEscape_1 = require("../../mixin/noEscape");
|
|
@@ -74,7 +75,7 @@ let LinkBaseToken = (() => {
|
|
|
74
75
|
#title;
|
|
75
76
|
/** full link / 完整链接 */
|
|
76
77
|
get link() {
|
|
77
|
-
|
|
78
|
+
return this.#title;
|
|
78
79
|
}
|
|
79
80
|
/**
|
|
80
81
|
* @param link 链接标题
|
|
@@ -130,7 +131,18 @@ let LinkBaseToken = (() => {
|
|
|
130
131
|
}
|
|
131
132
|
/** @private */
|
|
132
133
|
text() {
|
|
133
|
-
const
|
|
134
|
+
const { length, firstChild, childNodes, type, } = this, target = firstChild.text();
|
|
135
|
+
let str;
|
|
136
|
+
if (length === 1) {
|
|
137
|
+
str =
|
|
138
|
+
type === 'link' ?
|
|
139
|
+
(0, string_1.trimStart)(target) :
|
|
140
|
+
target.trim();
|
|
141
|
+
}
|
|
142
|
+
else {
|
|
143
|
+
str = `${target.trim()}|${(0, string_1.text)(childNodes.slice(1)
|
|
144
|
+
.filter(({ type: t, name }) => t !== 'image-parameter' || name !== 'invalid'), '|')}`;
|
|
145
|
+
}
|
|
134
146
|
if (this.#bracket) {
|
|
135
147
|
return `[[${str}]]`;
|
|
136
148
|
}
|
|
@@ -7,6 +7,8 @@ import type { Token, AtomToken, AttributesToken, ExtToken } from '../../internal
|
|
|
7
7
|
* @classdesc `{childNodes: [AtomToken]}`
|
|
8
8
|
*/
|
|
9
9
|
export declare abstract class CategorytreeToken extends LinkBaseToken {
|
|
10
|
+
#private;
|
|
11
|
+
readonly name: 'categorytree';
|
|
10
12
|
readonly childNodes: readonly [AtomToken];
|
|
11
13
|
abstract get lastChild(): AtomToken;
|
|
12
14
|
abstract get nextSibling(): undefined;
|
|
@@ -80,15 +80,18 @@ let CategorytreeToken = (() => {
|
|
|
80
80
|
lint(start = this.getAbsoluteIndex()) {
|
|
81
81
|
LINT: {
|
|
82
82
|
const rule = 'no-ignored', s = index_1.default.lintConfig.getSeverity(rule, 'categorytree');
|
|
83
|
-
if (s) {
|
|
84
|
-
|
|
85
|
-
if (!link.valid || link.ns !== 14) {
|
|
86
|
-
return [(0, lint_1.generateForSelf)(this, { start }, rule, 'invalid-category', s)];
|
|
87
|
-
}
|
|
83
|
+
if (s && this.#lint()) {
|
|
84
|
+
return [(0, lint_1.generateForSelf)(this, { start }, rule, 'invalid-category', s)];
|
|
88
85
|
}
|
|
89
86
|
return super.lint(start, false);
|
|
90
87
|
}
|
|
91
88
|
}
|
|
89
|
+
/** 无效的分类名 */
|
|
90
|
+
#lint() {
|
|
91
|
+
const { link } = this;
|
|
92
|
+
return !link.valid
|
|
93
|
+
|| link.ns !== 14;
|
|
94
|
+
}
|
|
92
95
|
};
|
|
93
96
|
return CategorytreeToken = _classThis;
|
|
94
97
|
})();
|
package/dist/src/link/file.js
CHANGED
|
@@ -86,7 +86,7 @@ class FileToken extends base_1.LinkBaseToken {
|
|
|
86
86
|
if (s
|
|
87
87
|
&& constants_1.extensions.has(extension)
|
|
88
88
|
&& this.isInside('ext-link-text')
|
|
89
|
-
&& this.getValue('link')
|
|
89
|
+
&& this.getValue('link') !== '') {
|
|
90
90
|
const e = (0, lint_1.generateForSelf)(this, rect, rule, 'link-in-extlink', s);
|
|
91
91
|
if (computeEditInfo || fix) {
|
|
92
92
|
const link = this.getArg('link');
|
|
@@ -111,8 +111,9 @@ class FileToken extends base_1.LinkBaseToken {
|
|
|
111
111
|
}
|
|
112
112
|
s = lintConfig.getSeverity(rule, 'parameter');
|
|
113
113
|
if (s && unscaled) {
|
|
114
|
-
|
|
115
|
-
|
|
114
|
+
const widths = args.filter(({ name }) => name === 'width');
|
|
115
|
+
for (let i = widths.length - 1; i >= 0; i--) {
|
|
116
|
+
const e = (0, lint_1.generateForChild)(widths[i], rect, rule, 'invalid-image-parameter', s);
|
|
116
117
|
if (computeEditInfo || fix) {
|
|
117
118
|
e.fix = (0, lint_1.fixByRemove)(e, -1);
|
|
118
119
|
}
|
|
@@ -146,18 +147,24 @@ class FileToken extends base_1.LinkBaseToken {
|
|
|
146
147
|
* @param p1 替换$1
|
|
147
148
|
* @param severity 错误等级
|
|
148
149
|
*/
|
|
149
|
-
const generate = (tokens, msg, p1, severity = true) =>
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
150
|
+
const generate = (tokens, msg, p1, severity = true) => {
|
|
151
|
+
const { length } = tokens, duplication = Array.from({ length });
|
|
152
|
+
for (let i = length - 1; i >= 0; i--) {
|
|
153
|
+
const arg = tokens[i];
|
|
154
|
+
s = severities[Number(typeof severity === 'function' ? severity(arg) : severity)];
|
|
155
|
+
if (!s) {
|
|
156
|
+
duplication[i] = false;
|
|
157
|
+
continue;
|
|
158
|
+
}
|
|
159
|
+
/** `conflicting-image-parameter`或`duplicate-image-parameter` */
|
|
160
|
+
const e = (0, lint_1.generateForChild)(arg, rect, rule, index_1.default.msg(`${msg}-image-parameter`, p1), s);
|
|
161
|
+
if (computeEditInfo) {
|
|
162
|
+
e.suggestions = [(0, lint_1.fixByRemove)(e, -1)];
|
|
163
|
+
}
|
|
164
|
+
duplication[i] = e;
|
|
158
165
|
}
|
|
159
|
-
return e;
|
|
160
|
-
}
|
|
166
|
+
return duplication.filter((e) => e !== false);
|
|
167
|
+
};
|
|
161
168
|
for (const key of keys) {
|
|
162
169
|
if (key === 'invalid' || key === 'width' && unscaled) {
|
|
163
170
|
continue;
|