wikilint 2.18.4 → 2.20.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 +49 -3
- package/config/minimum.json +5 -1
- package/data/ext/math.json +660 -0
- package/dist/base.d.mts +4 -3
- package/dist/base.d.ts +4 -3
- package/dist/bin/cli.js +19 -6
- package/dist/bin/config.js +26 -8
- package/dist/index.d.ts +2 -2
- package/dist/index.js +10 -1
- package/dist/internal.d.ts +2 -0
- package/dist/lib/document.d.ts +5 -0
- package/dist/lib/document.js +31 -1
- package/dist/lib/element.js +15 -4
- package/dist/lib/lsp.js +103 -41
- package/dist/lib/node.js +0 -7
- package/dist/lib/text.js +3 -7
- package/dist/lib/title.js +1 -6
- package/dist/mixin/attributesParent.js +1 -1
- package/dist/mixin/gapped.d.ts +4 -0
- package/dist/mixin/gapped.js +20 -0
- package/dist/mixin/hidden.js +1 -1
- package/dist/mixin/multiLine.d.ts +4 -0
- package/dist/mixin/multiLine.js +26 -0
- package/dist/mixin/padded.d.ts +5 -0
- package/dist/mixin/padded.js +20 -0
- package/dist/parser/braces.js +9 -13
- package/dist/parser/commentAndExt.js +18 -2
- package/dist/parser/magicLinks.js +1 -1
- package/dist/parser/selector.js +5 -2
- package/dist/src/arg.js +131 -84
- package/dist/src/attribute.js +4 -4
- package/dist/src/attributes.js +2 -2
- package/dist/src/commented.d.ts +19 -0
- package/dist/src/commented.js +41 -0
- package/dist/src/converter.js +90 -43
- package/dist/src/converterFlags.js +113 -66
- package/dist/src/converterRule.d.ts +1 -1
- package/dist/src/extLink.d.ts +2 -3
- package/dist/src/extLink.js +97 -54
- package/dist/src/gallery.d.ts +3 -4
- package/dist/src/gallery.js +114 -72
- package/dist/src/heading.js +10 -10
- package/dist/src/imageParameter.d.ts +1 -1
- package/dist/src/imageParameter.js +11 -8
- package/dist/src/imagemap.d.ts +1 -1
- package/dist/src/imagemap.js +126 -86
- package/dist/src/imagemapLink.d.ts +1 -1
- package/dist/src/index.js +18 -15
- package/dist/src/link/base.d.ts +2 -3
- package/dist/src/link/base.js +149 -105
- package/dist/src/link/file.d.ts +2 -3
- package/dist/src/link/file.js +2 -2
- package/dist/src/link/galleryImage.d.ts +2 -3
- package/dist/src/link/galleryImage.js +89 -47
- package/dist/src/nested.d.ts +1 -1
- package/dist/src/nowiki/comment.js +2 -5
- package/dist/src/nowiki/doubleUnderscore.js +2 -5
- package/dist/src/nowiki/index.d.ts +1 -1
- package/dist/src/nowiki/index.js +2 -1
- package/dist/src/onlyinclude.js +63 -15
- package/dist/src/paramTag/index.d.ts +1 -1
- package/dist/src/paramTag/index.js +89 -47
- package/dist/src/paramTag/inputbox.js +9 -4
- package/dist/src/parameter.d.ts +3 -4
- package/dist/src/parameter.js +4 -8
- package/dist/src/pre.d.ts +3 -4
- package/dist/src/pre.js +5 -9
- package/dist/src/syntax.d.ts +1 -1
- package/dist/src/table/base.d.ts +2 -2
- package/dist/src/table/base.js +3 -7
- package/dist/src/table/index.js +1 -1
- package/dist/src/table/td.d.ts +2 -3
- package/dist/src/table/td.js +3 -7
- package/dist/src/table/tr.d.ts +1 -1
- package/dist/src/tagPair/ext.js +38 -33
- package/dist/src/tagPair/index.d.ts +1 -1
- package/dist/src/tagPair/index.js +94 -47
- package/dist/src/tagPair/translate.d.ts +22 -0
- package/dist/src/tagPair/translate.js +48 -0
- package/dist/src/transclude.js +378 -332
- package/dist/util/lint.js +17 -30
- package/dist/util/sharable.js +29 -1
- package/dist/util/sharable.mjs +31 -3
- package/dist/util/string.js +14 -1
- package/package.json +8 -6
|
@@ -40,6 +40,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
40
40
|
exports.CommentToken = void 0;
|
|
41
41
|
const lint_1 = require("../../util/lint");
|
|
42
42
|
const hidden_1 = require("../../mixin/hidden");
|
|
43
|
+
const padded_1 = require("../../mixin/padded");
|
|
43
44
|
const index_1 = __importDefault(require("../../index"));
|
|
44
45
|
const base_1 = require("./base");
|
|
45
46
|
/**
|
|
@@ -48,7 +49,7 @@ const base_1 = require("./base");
|
|
|
48
49
|
* HTML注释,不可见
|
|
49
50
|
*/
|
|
50
51
|
let CommentToken = (() => {
|
|
51
|
-
let _classDecorators = [(0, hidden_1.hiddenToken)(false)];
|
|
52
|
+
let _classDecorators = [(0, hidden_1.hiddenToken)(false), (0, padded_1.padded)('<!--')];
|
|
52
53
|
let _classDescriptor;
|
|
53
54
|
let _classExtraInitializers = [];
|
|
54
55
|
let _classThis;
|
|
@@ -72,10 +73,6 @@ let CommentToken = (() => {
|
|
|
72
73
|
this.closed = closed;
|
|
73
74
|
}
|
|
74
75
|
/** @private */
|
|
75
|
-
getAttribute(key) {
|
|
76
|
-
return key === 'padding' ? 4 : super.getAttribute(key);
|
|
77
|
-
}
|
|
78
|
-
/** @private */
|
|
79
76
|
lint(start = this.getAbsoluteIndex()) {
|
|
80
77
|
if (this.closed) {
|
|
81
78
|
return [];
|
|
@@ -36,6 +36,7 @@ var __runInitializers = (this && this.__runInitializers) || function (thisArg, i
|
|
|
36
36
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
37
37
|
exports.DoubleUnderscoreToken = void 0;
|
|
38
38
|
const hidden_1 = require("../../mixin/hidden");
|
|
39
|
+
const padded_1 = require("../../mixin/padded");
|
|
39
40
|
const base_1 = require("./base");
|
|
40
41
|
/**
|
|
41
42
|
* behavior switch
|
|
@@ -43,7 +44,7 @@ const base_1 = require("./base");
|
|
|
43
44
|
* 状态开关
|
|
44
45
|
*/
|
|
45
46
|
let DoubleUnderscoreToken = (() => {
|
|
46
|
-
let _classDecorators = [(0, hidden_1.hiddenToken)()];
|
|
47
|
+
let _classDecorators = [(0, hidden_1.hiddenToken)(), (0, padded_1.padded)('__')];
|
|
47
48
|
let _classDescriptor;
|
|
48
49
|
let _classExtraInitializers = [];
|
|
49
50
|
let _classThis;
|
|
@@ -70,10 +71,6 @@ let DoubleUnderscoreToken = (() => {
|
|
|
70
71
|
this.setAttribute('name', (sensitive ? sAlias?.[word]?.toLowerCase() : iAlias?.[lc]) ?? lc);
|
|
71
72
|
}
|
|
72
73
|
/** @private */
|
|
73
|
-
getAttribute(key) {
|
|
74
|
-
return key === 'padding' ? 2 : super.getAttribute(key);
|
|
75
|
-
}
|
|
76
|
-
/** @private */
|
|
77
74
|
toString() {
|
|
78
75
|
return `__${this.innerText}__`;
|
|
79
76
|
}
|
|
@@ -9,7 +9,7 @@ import type { AttributesToken, ExtToken } from '../../internal';
|
|
|
9
9
|
export declare abstract class NowikiToken extends NowikiBaseToken {
|
|
10
10
|
readonly name: string;
|
|
11
11
|
abstract get nextSibling(): undefined;
|
|
12
|
-
abstract get previousSibling(): AttributesToken;
|
|
12
|
+
abstract get previousSibling(): AttributesToken | undefined;
|
|
13
13
|
abstract get parentNode(): ExtToken | undefined;
|
|
14
14
|
get type(): 'ext-inner';
|
|
15
15
|
}
|
package/dist/src/nowiki/index.js
CHANGED
|
@@ -9,6 +9,7 @@ const lint_1 = require("../../util/lint");
|
|
|
9
9
|
const index_1 = __importDefault(require("../../index"));
|
|
10
10
|
const base_1 = require("./base");
|
|
11
11
|
const getLintRegex = (0, common_1.getRegex)(name => new RegExp(String.raw `<\s*(?:/\s*)${name === 'nowiki' ? '' : '?'}(${name})\b`, 'giu'));
|
|
12
|
+
const voidExt = new Set(['templatestyles', 'section', 'languages']);
|
|
12
13
|
/**
|
|
13
14
|
* text-only token inside an extension tag
|
|
14
15
|
*
|
|
@@ -21,7 +22,7 @@ class NowikiToken extends base_1.NowikiBaseToken {
|
|
|
21
22
|
/** @private */
|
|
22
23
|
lint(start = this.getAbsoluteIndex()) {
|
|
23
24
|
const { name, firstChild: { data } } = this;
|
|
24
|
-
if ((name
|
|
25
|
+
if (voidExt.has(name) && data) {
|
|
25
26
|
const e = (0, lint_1.generateForSelf)(this, { start }, 'void-ext', index_1.default.msg('nothing should be in <$1>', name));
|
|
26
27
|
e.fix = { range: [start, e.endIndex], text: '', desc: 'empty' };
|
|
27
28
|
return [e];
|
package/dist/src/onlyinclude.js
CHANGED
|
@@ -1,6 +1,41 @@
|
|
|
1
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
|
+
};
|
|
2
36
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
37
|
exports.OnlyincludeToken = void 0;
|
|
38
|
+
const padded_1 = require("../mixin/padded");
|
|
4
39
|
const index_1 = require("./index");
|
|
5
40
|
/**
|
|
6
41
|
* `<onlyinclude>` during transclusion
|
|
@@ -8,20 +43,33 @@ const index_1 = require("./index");
|
|
|
8
43
|
* 嵌入时的`<onlyinclude>`
|
|
9
44
|
* @classdesc `{childNodes: (AstText|Token)[]}`
|
|
10
45
|
*/
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
46
|
+
let OnlyincludeToken = (() => {
|
|
47
|
+
let _classDecorators = [(0, padded_1.padded)('<onlyinclude>')];
|
|
48
|
+
let _classDescriptor;
|
|
49
|
+
let _classExtraInitializers = [];
|
|
50
|
+
let _classThis;
|
|
51
|
+
let _classSuper = index_1.Token;
|
|
52
|
+
var OnlyincludeToken = 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
|
+
OnlyincludeToken = _classThis = _classDescriptor.value;
|
|
58
|
+
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
59
|
+
__runInitializers(_classThis, _classExtraInitializers);
|
|
23
60
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
61
|
+
get type() {
|
|
62
|
+
return 'onlyinclude';
|
|
63
|
+
}
|
|
64
|
+
/** @private */
|
|
65
|
+
toString(skip) {
|
|
66
|
+
return `<onlyinclude>${super.toString(skip)}</onlyinclude>`;
|
|
67
|
+
}
|
|
68
|
+
/** @private */
|
|
69
|
+
isPlain() {
|
|
70
|
+
return true;
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
return OnlyincludeToken = _classThis;
|
|
74
|
+
})();
|
|
27
75
|
exports.OnlyincludeToken = OnlyincludeToken;
|
|
@@ -13,7 +13,7 @@ export declare abstract class ParamTagToken extends Token {
|
|
|
13
13
|
abstract get firstChild(): AtomToken | undefined;
|
|
14
14
|
abstract get lastChild(): AtomToken | undefined;
|
|
15
15
|
abstract get nextSibling(): undefined;
|
|
16
|
-
abstract get previousSibling(): AttributesToken;
|
|
16
|
+
abstract get previousSibling(): AttributesToken | undefined;
|
|
17
17
|
abstract get parentNode(): ExtToken | undefined;
|
|
18
18
|
get type(): 'ext-inner';
|
|
19
19
|
/** @class */
|
|
@@ -1,4 +1,38 @@
|
|
|
1
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
|
+
};
|
|
2
36
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
37
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
38
|
};
|
|
@@ -7,6 +41,7 @@ exports.ParamTagToken = void 0;
|
|
|
7
41
|
const lint_1 = require("../../util/lint");
|
|
8
42
|
const rect_1 = require("../../lib/rect");
|
|
9
43
|
const commentAndExt_1 = require("../../parser/commentAndExt");
|
|
44
|
+
const multiLine_1 = require("../../mixin/multiLine");
|
|
10
45
|
const index_1 = __importDefault(require("../../index"));
|
|
11
46
|
const index_2 = require("../index");
|
|
12
47
|
const atom_1 = require("../atom");
|
|
@@ -14,58 +49,65 @@ const atom_1 = require("../atom");
|
|
|
14
49
|
* `<dynamicpagelist>`
|
|
15
50
|
* @classdesc `{childNodes: AtomToken[]}`
|
|
16
51
|
*/
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
52
|
+
let ParamTagToken = (() => {
|
|
53
|
+
let _classDecorators = [multiLine_1.multiLine];
|
|
54
|
+
let _classDescriptor;
|
|
55
|
+
let _classExtraInitializers = [];
|
|
56
|
+
let _classThis;
|
|
57
|
+
let _classSuper = index_2.Token;
|
|
58
|
+
var ParamTagToken = class extends _classSuper {
|
|
59
|
+
static { _classThis = this; }
|
|
60
|
+
static {
|
|
61
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
62
|
+
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
63
|
+
ParamTagToken = _classThis = _classDescriptor.value;
|
|
64
|
+
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
65
|
+
__runInitializers(_classThis, _classExtraInitializers);
|
|
29
66
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
/** @private */
|
|
42
|
-
getGaps() {
|
|
43
|
-
return 1;
|
|
44
|
-
}
|
|
45
|
-
/** @private */
|
|
46
|
-
lint(start = this.getAbsoluteIndex()) {
|
|
47
|
-
const rect = new rect_1.BoundingRect(this, start), msg = index_1.default.msg('invalid parameter of <$1>', this.name), errors = [];
|
|
48
|
-
for (const child of this.childNodes) {
|
|
49
|
-
child.setAttribute('aIndex', start);
|
|
50
|
-
const grandChildren = child.childNodes
|
|
51
|
-
.filter(({ type }) => type !== 'comment' && type !== 'include' && type !== 'noinclude');
|
|
52
|
-
if (grandChildren.some(({ type }) => type === 'ext')) {
|
|
53
|
-
errors.push((0, lint_1.generateForChild)(child, rect, 'no-ignored', msg));
|
|
67
|
+
get type() {
|
|
68
|
+
return 'ext-inner';
|
|
69
|
+
}
|
|
70
|
+
/** @class */
|
|
71
|
+
constructor(include, wikitext, config = index_1.default.getConfig(), accum = [], acceptable) {
|
|
72
|
+
super(undefined, config, accum, {});
|
|
73
|
+
if (wikitext) {
|
|
74
|
+
const SingleLineAtomToken = atom_1.AtomToken;
|
|
75
|
+
this.append(...wikitext.split('\n')
|
|
76
|
+
.map(line => acceptable ? line : (0, commentAndExt_1.parseCommentAndExt)(line, config, accum, include))
|
|
77
|
+
.map(line => new SingleLineAtomToken(line, 'param-line', config, accum, {})));
|
|
54
78
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
79
|
+
accum.splice(accum.indexOf(this), 1);
|
|
80
|
+
accum.push(this);
|
|
81
|
+
}
|
|
82
|
+
/** @private */
|
|
83
|
+
lint(start = this.getAbsoluteIndex()) {
|
|
84
|
+
const rect = new rect_1.BoundingRect(this, start), msg = index_1.default.msg('invalid parameter of <$1>', this.name), errors = [];
|
|
85
|
+
for (const child of this.childNodes) {
|
|
86
|
+
child.setAttribute('aIndex', start);
|
|
87
|
+
const grandChildren = child.childNodes
|
|
88
|
+
.filter(({ type }) => type !== 'comment' && type !== 'include' && type !== 'noinclude');
|
|
89
|
+
if (grandChildren.some(({ type }) => type === 'ext')) {
|
|
90
|
+
errors.push((0, lint_1.generateForChild)(child, rect, 'no-ignored', msg));
|
|
61
91
|
}
|
|
62
92
|
else {
|
|
63
|
-
|
|
93
|
+
const i = grandChildren.findIndex(({ type }) => type !== 'text'), str = grandChildren.slice(0, i === -1 ? undefined : i).map(String).join('');
|
|
94
|
+
if (str && !(i === -1 ? /^[a-z]+(?:\[\])?\s*=/iu : /^[a-z]+(?:\[\])?\s*(?:=|$)/iu).test(str)) {
|
|
95
|
+
const e = (0, lint_1.generateForChild)(child, rect, 'no-ignored', msg);
|
|
96
|
+
e.suggestions = [{ desc: 'remove', range: [e.startIndex, e.endIndex], text: '' }];
|
|
97
|
+
errors.push(e);
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
const childErrors = child.lint(start, false);
|
|
101
|
+
if (childErrors.length > 0) {
|
|
102
|
+
errors.push(...childErrors);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
64
105
|
}
|
|
106
|
+
start += child.toString().length + 1;
|
|
65
107
|
}
|
|
66
|
-
|
|
108
|
+
return errors;
|
|
67
109
|
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
}
|
|
110
|
+
};
|
|
111
|
+
return ParamTagToken = _classThis;
|
|
112
|
+
})();
|
|
71
113
|
exports.ParamTagToken = ParamTagToken;
|
|
@@ -12,12 +12,17 @@ const index_2 = require("./index");
|
|
|
12
12
|
class InputboxToken extends index_2.ParamTagToken {
|
|
13
13
|
/** @class */
|
|
14
14
|
constructor(include, wikitext, config = index_1.default.getConfig(), accum = []) {
|
|
15
|
-
const placeholder = Symbol('InputboxToken'),
|
|
15
|
+
const placeholder = Symbol('InputboxToken'), newConfig = config.excludes.includes('heading')
|
|
16
|
+
? config
|
|
17
|
+
: {
|
|
18
|
+
...config,
|
|
19
|
+
excludes: [...config.excludes, 'heading'],
|
|
20
|
+
}, { length } = accum;
|
|
16
21
|
accum.push(placeholder);
|
|
17
|
-
wikitext &&= (0, commentAndExt_1.parseCommentAndExt)(wikitext,
|
|
18
|
-
wikitext &&= (0, braces_1.parseBraces)(wikitext,
|
|
22
|
+
wikitext &&= (0, commentAndExt_1.parseCommentAndExt)(wikitext, newConfig, accum, include);
|
|
23
|
+
wikitext &&= (0, braces_1.parseBraces)(wikitext, newConfig, accum);
|
|
19
24
|
accum.splice(length, 1);
|
|
20
|
-
super(include, wikitext,
|
|
25
|
+
super(include, wikitext, newConfig, accum, {});
|
|
21
26
|
}
|
|
22
27
|
}
|
|
23
28
|
exports.InputboxToken = InputboxToken;
|
package/dist/src/parameter.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import Parser from '../index';
|
|
2
1
|
import { Token } from './index';
|
|
3
|
-
import type { LintError } from '../base';
|
|
2
|
+
import type { Config, LintError } from '../base';
|
|
4
3
|
import type { AtomToken, SyntaxToken, TranscludeToken } from '../internal';
|
|
5
4
|
/**
|
|
6
5
|
* template or magic word parameter
|
|
@@ -15,7 +14,7 @@ export declare abstract class ParameterToken extends Token {
|
|
|
15
14
|
abstract get lastChild(): Token;
|
|
16
15
|
abstract get parentNode(): TranscludeToken | undefined;
|
|
17
16
|
abstract get nextSibling(): this | undefined;
|
|
18
|
-
abstract get previousSibling(): AtomToken | SyntaxToken | this;
|
|
17
|
+
abstract get previousSibling(): AtomToken | SyntaxToken | this | undefined;
|
|
19
18
|
get type(): 'parameter';
|
|
20
19
|
/** whether to be anonymous / 是否是匿名参数 */
|
|
21
20
|
get anon(): boolean;
|
|
@@ -23,6 +22,6 @@ export declare abstract class ParameterToken extends Token {
|
|
|
23
22
|
* @param key 参数名
|
|
24
23
|
* @param value 参数值
|
|
25
24
|
*/
|
|
26
|
-
constructor(key?: string | number, value?: string, config?:
|
|
25
|
+
constructor(key?: string | number, value?: string, config?: Config, accum?: Token[]);
|
|
27
26
|
text(): string;
|
|
28
27
|
}
|
package/dist/src/parameter.js
CHANGED
|
@@ -1,13 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.ParameterToken = void 0;
|
|
7
4
|
const string_1 = require("../util/string");
|
|
8
5
|
const lint_1 = require("../util/lint");
|
|
9
|
-
const index_1 =
|
|
10
|
-
const index_2 = require("./index");
|
|
6
|
+
const index_1 = require("./index");
|
|
11
7
|
const linkRegex = new RegExp(`https?://${string_1.extUrlCharFirst}${string_1.extUrlChar}$`, 'iu');
|
|
12
8
|
/**
|
|
13
9
|
* template or magic word parameter
|
|
@@ -15,7 +11,7 @@ const linkRegex = new RegExp(`https?://${string_1.extUrlCharFirst}${string_1.ext
|
|
|
15
11
|
* 模板或魔术字参数
|
|
16
12
|
* @classdesc `{childNodes: [Token, Token]}`
|
|
17
13
|
*/
|
|
18
|
-
class ParameterToken extends
|
|
14
|
+
class ParameterToken extends index_1.Token {
|
|
19
15
|
get type() {
|
|
20
16
|
return 'parameter';
|
|
21
17
|
}
|
|
@@ -27,9 +23,9 @@ class ParameterToken extends index_2.Token {
|
|
|
27
23
|
* @param key 参数名
|
|
28
24
|
* @param value 参数值
|
|
29
25
|
*/
|
|
30
|
-
constructor(key, value, config
|
|
26
|
+
constructor(key, value, config, accum = []) {
|
|
31
27
|
super(undefined, config, accum);
|
|
32
|
-
const keyToken = new
|
|
28
|
+
const keyToken = new index_1.Token(typeof key === 'number' ? undefined : key, config, accum, {}), token = new index_1.Token(value, config, accum);
|
|
33
29
|
keyToken.type = 'parameter-key';
|
|
34
30
|
keyToken.setAttribute('stage', 2);
|
|
35
31
|
token.type = 'parameter-value';
|
package/dist/src/pre.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import Parser from '../index';
|
|
2
1
|
import { Token } from './index';
|
|
3
2
|
import { NoincludeToken } from './nowiki/noinclude';
|
|
4
|
-
import type { LintError } from '../base';
|
|
3
|
+
import type { Config, LintError } from '../base';
|
|
5
4
|
import type { AstText, AttributesToken, ExtToken, ConverterToken } from '../internal';
|
|
6
5
|
declare type Child = NoincludeToken | ConverterToken;
|
|
7
6
|
/**
|
|
@@ -14,10 +13,10 @@ export declare abstract class PreToken extends Token {
|
|
|
14
13
|
abstract get firstChild(): AstText | Child | undefined;
|
|
15
14
|
abstract get lastChild(): AstText | Child | undefined;
|
|
16
15
|
abstract get nextSibling(): undefined;
|
|
17
|
-
abstract get previousSibling(): AttributesToken;
|
|
16
|
+
abstract get previousSibling(): AttributesToken | undefined;
|
|
18
17
|
abstract get parentNode(): ExtToken | undefined;
|
|
19
18
|
get type(): 'ext-inner';
|
|
20
19
|
/** @class */
|
|
21
|
-
constructor(wikitext?: string, config?:
|
|
20
|
+
constructor(wikitext?: string, config?: Config, accum?: Token[]);
|
|
22
21
|
}
|
|
23
22
|
export {};
|
package/dist/src/pre.js
CHANGED
|
@@ -1,23 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.PreToken = void 0;
|
|
7
4
|
const constants_1 = require("../util/constants");
|
|
8
|
-
const index_1 =
|
|
9
|
-
const index_2 = require("./index");
|
|
5
|
+
const index_1 = require("./index");
|
|
10
6
|
const noinclude_1 = require("./nowiki/noinclude");
|
|
11
7
|
/**
|
|
12
8
|
* `<pre>`
|
|
13
9
|
* @classdesc `{childNodes: (AstText|NoincludeToken|ConverterToken)[]}`
|
|
14
10
|
*/
|
|
15
|
-
class PreToken extends
|
|
11
|
+
class PreToken extends index_1.Token {
|
|
16
12
|
get type() {
|
|
17
13
|
return 'ext-inner';
|
|
18
14
|
}
|
|
19
15
|
/** @class */
|
|
20
|
-
constructor(wikitext, config
|
|
16
|
+
constructor(wikitext, config, accum = []) {
|
|
21
17
|
if (wikitext) {
|
|
22
18
|
const opening = /<nowiki>/giu, closing = /<\/nowiki>/giu, { length } = opening.source;
|
|
23
19
|
let i = opening.exec(wikitext);
|
|
@@ -45,8 +41,8 @@ class PreToken extends index_2.Token {
|
|
|
45
41
|
this.setAttribute('stage', constants_1.MAX_STAGE - 1);
|
|
46
42
|
}
|
|
47
43
|
/** @private */
|
|
48
|
-
|
|
49
|
-
return
|
|
44
|
+
isPlain() {
|
|
45
|
+
return true;
|
|
50
46
|
}
|
|
51
47
|
/** @private */
|
|
52
48
|
lint(start = this.getAbsoluteIndex()) {
|
package/dist/src/syntax.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Token } from './index';
|
|
2
2
|
import type { Config, LintError } from '../base';
|
|
3
|
-
declare type SyntaxTypes = 'heading-trail' | 'magic-word-name' | 'table-syntax' | 'redirect-syntax';
|
|
3
|
+
declare type SyntaxTypes = 'heading-trail' | 'magic-word-name' | 'table-syntax' | 'redirect-syntax' | 'translate-attr';
|
|
4
4
|
/**
|
|
5
5
|
* plain token that satisfies specific grammar syntax
|
|
6
6
|
*
|
package/dist/src/table/base.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import Parser from '../../index';
|
|
2
1
|
import { Token } from '../index';
|
|
3
2
|
import { SyntaxToken } from '../syntax';
|
|
4
3
|
import { AttributesToken } from '../attributes';
|
|
4
|
+
import type { Config } from '../../base';
|
|
5
5
|
import type { AttributesParentBase } from '../../mixin/attributesParent';
|
|
6
6
|
declare type TableTypes = 'table' | 'tr' | 'td';
|
|
7
7
|
export interface TableBaseToken extends AttributesParentBase {
|
|
@@ -17,6 +17,6 @@ export declare abstract class TableBaseToken extends Token {
|
|
|
17
17
|
* @param type 节点类型
|
|
18
18
|
* @param attr 表格属性
|
|
19
19
|
*/
|
|
20
|
-
constructor(pattern: RegExp, syntax: string, type: TableTypes, attr?: string, config?:
|
|
20
|
+
constructor(pattern: RegExp, syntax: string, type: TableTypes, attr?: string, config?: Config, accum?: Token[], acceptable?: Acceptable);
|
|
21
21
|
}
|
|
22
22
|
export {};
|
package/dist/src/table/base.js
CHANGED
|
@@ -1,12 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.TableBaseToken = void 0;
|
|
7
4
|
const attributesParent_1 = require("../../mixin/attributesParent");
|
|
8
|
-
const index_1 =
|
|
9
|
-
const index_2 = require("../index");
|
|
5
|
+
const index_1 = require("../index");
|
|
10
6
|
const syntax_1 = require("../syntax");
|
|
11
7
|
const attributes_1 = require("../attributes");
|
|
12
8
|
/**
|
|
@@ -15,14 +11,14 @@ const attributes_1 = require("../attributes");
|
|
|
15
11
|
* 表格行,含开头的换行,不含结尾的换行
|
|
16
12
|
* @classdesc `{childNodes: [SyntaxToken, AttributesToken, ...Token[]]}`
|
|
17
13
|
*/
|
|
18
|
-
class TableBaseToken extends (0, attributesParent_1.attributesParent)(1)(
|
|
14
|
+
class TableBaseToken extends (0, attributesParent_1.attributesParent)(1)(index_1.Token) {
|
|
19
15
|
/**
|
|
20
16
|
* @param pattern 表格语法正则
|
|
21
17
|
* @param syntax 表格语法
|
|
22
18
|
* @param type 节点类型
|
|
23
19
|
* @param attr 表格属性
|
|
24
20
|
*/
|
|
25
|
-
constructor(pattern, syntax, type, attr, config
|
|
21
|
+
constructor(pattern, syntax, type, attr, config, accum = [], acceptable) {
|
|
26
22
|
super(undefined, config, accum, acceptable);
|
|
27
23
|
this.append(new syntax_1.SyntaxToken(syntax, 'table-syntax', config, accum),
|
|
28
24
|
// @ts-expect-error abstract class
|
package/dist/src/table/index.js
CHANGED
|
@@ -95,7 +95,7 @@ class TableToken extends trBase_1.TrBaseToken {
|
|
|
95
95
|
const token = new syntax_1.SyntaxToken(undefined, 'table-syntax', config, accum);
|
|
96
96
|
super.insertAt(token);
|
|
97
97
|
});
|
|
98
|
-
this.lastChild.
|
|
98
|
+
this.lastChild.safeReplaceChildren(inner);
|
|
99
99
|
}
|
|
100
100
|
/**
|
|
101
101
|
* Get the table layout
|
package/dist/src/table/td.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import Parser from '../../index';
|
|
2
1
|
import { Token } from '../index';
|
|
3
2
|
import { TableBaseToken } from './base';
|
|
4
|
-
import type { LintError } from '../../base';
|
|
3
|
+
import type { Config, LintError } from '../../base';
|
|
5
4
|
import type { SyntaxToken, AttributesToken, TrToken, TableToken } from '../../internal';
|
|
6
5
|
export type TdSubtypes = 'td' | 'th' | 'caption';
|
|
7
6
|
export interface TdSpanAttrs {
|
|
@@ -32,7 +31,7 @@ export declare abstract class TdToken extends TableBaseToken {
|
|
|
32
31
|
* @param syntax 单元格语法
|
|
33
32
|
* @param inner 内部wikitext
|
|
34
33
|
*/
|
|
35
|
-
constructor(syntax: string, inner?: string, config?:
|
|
34
|
+
constructor(syntax: string, inner?: string, config?: Config, accum?: Token[]);
|
|
36
35
|
/**
|
|
37
36
|
* Check if the cell is at the beginning of a line
|
|
38
37
|
*
|
package/dist/src/table/td.js
CHANGED
|
@@ -1,14 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.TdToken = void 0;
|
|
7
4
|
const lint_1 = require("../../util/lint");
|
|
8
5
|
const constants_1 = require("../../util/constants");
|
|
9
6
|
const rect_1 = require("../../lib/rect");
|
|
10
|
-
const index_1 =
|
|
11
|
-
const index_2 = require("../index");
|
|
7
|
+
const index_1 = require("../index");
|
|
12
8
|
const base_1 = require("./base");
|
|
13
9
|
/**
|
|
14
10
|
* `<td>`, `<th>` or `<caption>`
|
|
@@ -38,7 +34,7 @@ class TdToken extends base_1.TableBaseToken {
|
|
|
38
34
|
* @param syntax 单元格语法
|
|
39
35
|
* @param inner 内部wikitext
|
|
40
36
|
*/
|
|
41
|
-
constructor(syntax, inner, config
|
|
37
|
+
constructor(syntax, inner, config, accum = []) {
|
|
42
38
|
let innerSyntax = /\||\0\d+!\x7F/u.exec(inner ?? ''), attr = innerSyntax ? inner.slice(0, innerSyntax.index) : '';
|
|
43
39
|
if (/\[\[|-\{/u.test(attr)) {
|
|
44
40
|
innerSyntax = null;
|
|
@@ -48,7 +44,7 @@ class TdToken extends base_1.TableBaseToken {
|
|
|
48
44
|
if (innerSyntax) {
|
|
49
45
|
[this.#innerSyntax] = innerSyntax;
|
|
50
46
|
}
|
|
51
|
-
const innerToken = new
|
|
47
|
+
const innerToken = new index_1.Token(inner?.slice((innerSyntax?.index ?? NaN) + this.#innerSyntax.length), config, accum);
|
|
52
48
|
innerToken.type = 'td-inner';
|
|
53
49
|
innerToken.setAttribute('stage', 4);
|
|
54
50
|
this.insertAt(innerToken);
|
package/dist/src/table/tr.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ export declare abstract class TrToken extends TrBaseToken {
|
|
|
12
12
|
abstract get lastChild(): AttributesToken | TdToken;
|
|
13
13
|
abstract get parentNode(): TableToken | undefined;
|
|
14
14
|
abstract get nextSibling(): this | SyntaxToken | undefined;
|
|
15
|
-
abstract get previousSibling(): Token;
|
|
15
|
+
abstract get previousSibling(): Token | undefined;
|
|
16
16
|
get type(): 'tr';
|
|
17
17
|
/**
|
|
18
18
|
* @param syntax 表格语法
|