wikilint 2.27.0 → 2.28.1
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 +15 -16
- package/config/jawiki.json +15 -16
- package/coverage/badge.svg +1 -1
- package/dist/base.d.mts +2 -2
- package/dist/base.d.ts +2 -2
- package/dist/base.js +1 -0
- package/dist/base.mjs +1 -0
- package/dist/bin/config.js +11 -11
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -3
- package/dist/internal.d.ts +5 -5
- package/dist/lib/lintConfig.js +7 -5
- package/dist/lib/lsp.d.ts +1 -1
- package/dist/lib/lsp.js +5 -2
- package/dist/lib/node.js +44 -33
- package/dist/mixin/attributesParent.js +16 -14
- package/dist/mixin/elementLike.js +45 -43
- package/dist/mixin/hidden.js +0 -1
- package/dist/mixin/nodeLike.js +2 -2
- package/dist/mixin/padded.js +9 -7
- package/dist/parser/commentAndExt.js +5 -2
- package/dist/parser/hrAndDoubleUnderscore.js +8 -7
- package/dist/parser/html.js +1 -1
- package/dist/src/arg.js +3 -4
- package/dist/src/atom.d.ts +1 -1
- package/dist/src/atom.js +0 -1
- package/dist/src/attribute.d.ts +2 -4
- package/dist/src/attribute.js +7 -2
- package/dist/src/attributes.d.ts +3 -4
- package/dist/src/attributes.js +5 -3
- package/dist/src/commented.d.ts +3 -3
- package/dist/src/imageParameter.js +53 -13
- package/dist/src/index.js +1 -1
- package/dist/src/link/file.js +8 -9
- package/dist/src/link/index.js +1 -1
- package/dist/src/magicLink.js +12 -1
- package/dist/src/multiLine/gallery.d.ts +20 -0
- package/dist/src/multiLine/gallery.js +95 -0
- package/dist/src/multiLine/imagemap.d.ts +21 -0
- package/dist/src/multiLine/imagemap.js +111 -0
- package/dist/src/multiLine/index.d.ts +14 -0
- package/dist/src/multiLine/index.js +27 -0
- package/dist/src/{paramTag → multiLine}/inputbox.d.ts +1 -1
- package/dist/src/{paramTag → multiLine}/inputbox.js +2 -2
- package/dist/src/multiLine/paramTag.d.ts +16 -0
- package/dist/src/multiLine/paramTag.js +67 -0
- package/dist/src/nowiki/base.d.ts +1 -1
- package/dist/src/nowiki/comment.js +1 -0
- package/dist/src/nowiki/commentLine.d.ts +10 -0
- package/dist/src/nowiki/commentLine.js +12 -0
- package/dist/src/nowiki/doubleUnderscore.d.ts +3 -1
- package/dist/src/nowiki/doubleUnderscore.js +6 -2
- package/dist/src/nowiki/quote.js +1 -1
- package/dist/src/paramLine.d.ts +13 -0
- package/dist/src/paramLine.js +15 -0
- package/dist/src/parameter.d.ts +0 -1
- package/dist/src/parameter.js +1 -0
- package/dist/src/pre.d.ts +3 -5
- package/dist/src/pre.js +2 -2
- package/dist/src/syntax.d.ts +1 -1
- package/dist/src/table/base.d.ts +6 -1
- package/dist/src/table/base.js +73 -23
- package/dist/src/table/index.js +43 -39
- package/dist/src/table/td.d.ts +1 -1
- package/dist/src/table/td.js +6 -4
- package/dist/src/table/tr.d.ts +1 -1
- package/dist/src/table/trBase.js +3 -1
- package/dist/src/{html.d.ts → tag/html.d.ts} +5 -13
- package/dist/src/{html.js → tag/html.js} +11 -71
- package/dist/src/tag/index.d.ts +31 -0
- package/dist/src/tag/index.js +110 -0
- package/dist/src/tag/tvar.d.ts +20 -0
- package/dist/src/tag/tvar.js +75 -0
- package/dist/src/tagPair/ext.js +14 -7
- package/dist/src/tagPair/index.d.ts +1 -1
- package/dist/src/tagPair/translate.js +9 -9
- package/dist/src/transclude.d.ts +3 -5
- package/dist/src/transclude.js +3 -1
- package/i18n/en.json +2 -0
- package/i18n/zh-hans.json +2 -0
- package/i18n/zh-hant.json +2 -0
- package/package.json +5 -5
- package/dist/mixin/multiLine.d.ts +0 -4
- package/dist/mixin/multiLine.js +0 -26
- package/dist/src/gallery.d.ts +0 -26
- package/dist/src/gallery.js +0 -149
- package/dist/src/imagemap.d.ts +0 -27
- package/dist/src/imagemap.js +0 -164
- package/dist/src/paramTag/index.d.ts +0 -21
- package/dist/src/paramTag/index.js +0 -121
package/dist/lib/node.js
CHANGED
|
@@ -108,7 +108,9 @@ let AstNode = (() => {
|
|
|
108
108
|
this.#previousSibling = value;
|
|
109
109
|
break;
|
|
110
110
|
case 'aIndex':
|
|
111
|
-
|
|
111
|
+
LINT: { // eslint-disable-line no-unused-labels
|
|
112
|
+
this.#aIndex = [debug_1.Shadow.rev, value];
|
|
113
|
+
}
|
|
112
114
|
break;
|
|
113
115
|
default:
|
|
114
116
|
this[key] = value; // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
@@ -154,18 +156,22 @@ let AstNode = (() => {
|
|
|
154
156
|
* @param index character index / 字符位置
|
|
155
157
|
*/
|
|
156
158
|
posFromIndex(index) {
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
159
|
+
LINT: { // eslint-disable-line no-unused-labels
|
|
160
|
+
const { length } = String(this);
|
|
161
|
+
index += index < 0 ? length : 0;
|
|
162
|
+
if (index >= 0 && index <= length) {
|
|
163
|
+
const lines = this.getLines(), top = lines.findIndex(([, , end]) => index <= end);
|
|
164
|
+
return { top, left: index - lines[top][1] };
|
|
165
|
+
}
|
|
166
|
+
return undefined;
|
|
162
167
|
}
|
|
163
|
-
return undefined;
|
|
164
168
|
}
|
|
165
169
|
/** @private */
|
|
166
170
|
getDimension() {
|
|
167
|
-
|
|
168
|
-
|
|
171
|
+
LINT: { // eslint-disable-line no-unused-labels
|
|
172
|
+
const lines = this.getLines(), last = lines[lines.length - 1];
|
|
173
|
+
return { height: lines.length, width: last[2] - last[1] };
|
|
174
|
+
}
|
|
169
175
|
}
|
|
170
176
|
/** @private */
|
|
171
177
|
getGaps(_) {
|
|
@@ -178,23 +184,25 @@ let AstNode = (() => {
|
|
|
178
184
|
* @param j rank of the child node / 子节点序号
|
|
179
185
|
*/
|
|
180
186
|
getRelativeIndex(j) {
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
return (0, lint_1.cache)(this.#rIndex[j], () => {
|
|
188
|
-
const { childNodes } = this, n = j + (j < 0 ? childNodes.length : 0);
|
|
189
|
-
let acc = this.getAttribute('padding');
|
|
190
|
-
for (let i = 0; i < n; i++) {
|
|
191
|
-
this.#rIndex[i] = [debug_1.Shadow.rev, acc];
|
|
192
|
-
acc += childNodes[i].toString().length + this.getGaps(i);
|
|
187
|
+
LINT: { // eslint-disable-line no-unused-labels
|
|
188
|
+
if (j === undefined) {
|
|
189
|
+
const { parentNode } = this;
|
|
190
|
+
return parentNode
|
|
191
|
+
? parentNode.getRelativeIndex(parentNode.childNodes.indexOf(this))
|
|
192
|
+
: 0;
|
|
193
193
|
}
|
|
194
|
-
return
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
194
|
+
return (0, lint_1.cache)(this.#rIndex[j], () => {
|
|
195
|
+
const { childNodes } = this, n = j + (j < 0 ? childNodes.length : 0);
|
|
196
|
+
let acc = this.getAttribute('padding');
|
|
197
|
+
for (let i = 0; i < n; i++) {
|
|
198
|
+
this.#rIndex[i] = [debug_1.Shadow.rev, acc];
|
|
199
|
+
acc += childNodes[i].toString().length + this.getGaps(i);
|
|
200
|
+
}
|
|
201
|
+
return acc;
|
|
202
|
+
}, value => {
|
|
203
|
+
this.#rIndex[j] = value;
|
|
204
|
+
});
|
|
205
|
+
}
|
|
198
206
|
}
|
|
199
207
|
/**
|
|
200
208
|
* Get the absolute character index of the current node
|
|
@@ -202,7 +210,8 @@ let AstNode = (() => {
|
|
|
202
210
|
* 获取当前节点的绝对位置
|
|
203
211
|
*/
|
|
204
212
|
getAbsoluteIndex() {
|
|
205
|
-
return (0, lint_1.cache)(
|
|
213
|
+
LINT: return (0, lint_1.cache)(// eslint-disable-line no-unused-labels
|
|
214
|
+
this.#aIndex, () => {
|
|
206
215
|
const { parentNode } = this;
|
|
207
216
|
return parentNode ? parentNode.getAbsoluteIndex() + this.getRelativeIndex() : 0;
|
|
208
217
|
}, value => {
|
|
@@ -238,14 +247,16 @@ let AstNode = (() => {
|
|
|
238
247
|
* @since v1.16.3
|
|
239
248
|
*/
|
|
240
249
|
getLines() {
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
const
|
|
245
|
-
|
|
246
|
-
|
|
250
|
+
LINT: { // eslint-disable-line no-unused-labels
|
|
251
|
+
const results = [];
|
|
252
|
+
let start = 0;
|
|
253
|
+
for (const line of String(this).split('\n')) {
|
|
254
|
+
const end = start + line.length;
|
|
255
|
+
results.push([line, start, end]);
|
|
256
|
+
start = end + 1;
|
|
257
|
+
}
|
|
258
|
+
return results;
|
|
247
259
|
}
|
|
248
|
-
return results;
|
|
249
260
|
}
|
|
250
261
|
};
|
|
251
262
|
return AstNode = _classThis;
|
|
@@ -7,21 +7,23 @@ const debug_1 = require("../util/debug");
|
|
|
7
7
|
* @param i AttributesToken子节点的位置
|
|
8
8
|
*/
|
|
9
9
|
const attributesParent = (i = 0) => (constructor) => {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
10
|
+
LINT: { // eslint-disable-line no-unused-labels
|
|
11
|
+
/* eslint-disable jsdoc/require-jsdoc */
|
|
12
|
+
class AttributesParent extends constructor {
|
|
13
|
+
/** AttributesToken子节点 */
|
|
14
|
+
#getAttributesChild() {
|
|
15
|
+
return this.childNodes[i];
|
|
16
|
+
}
|
|
17
|
+
hasAttr(key) {
|
|
18
|
+
LSP: return this.#getAttributesChild().hasAttr(key); // eslint-disable-line no-unused-labels
|
|
19
|
+
}
|
|
20
|
+
getAttr(key) {
|
|
21
|
+
return this.#getAttributesChild().getAttr(key);
|
|
22
|
+
}
|
|
21
23
|
}
|
|
24
|
+
/* eslint-enable jsdoc/require-jsdoc */
|
|
25
|
+
(0, debug_1.mixin)(AttributesParent, constructor);
|
|
26
|
+
return AttributesParent;
|
|
22
27
|
}
|
|
23
|
-
/* eslint-enable jsdoc/require-jsdoc */
|
|
24
|
-
(0, debug_1.mixin)(AttributesParent, constructor);
|
|
25
|
-
return AttributesParent;
|
|
26
28
|
};
|
|
27
29
|
exports.attributesParent = attributesParent;
|
|
@@ -5,56 +5,58 @@ const debug_1 = require("../util/debug");
|
|
|
5
5
|
const selector_1 = require("../parser/selector");
|
|
6
6
|
/** @ignore */
|
|
7
7
|
const elementLike = (constructor) => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
getElementBy(condition) {
|
|
16
|
-
for (const child of this.childNodes) {
|
|
17
|
-
if (child.type === 'text') {
|
|
18
|
-
continue;
|
|
19
|
-
}
|
|
20
|
-
else if (condition(child)) {
|
|
21
|
-
return child;
|
|
22
|
-
}
|
|
23
|
-
const descendant = child.getElementBy(condition);
|
|
24
|
-
if (descendant) {
|
|
25
|
-
return descendant;
|
|
26
|
-
}
|
|
8
|
+
LINT: { // eslint-disable-line no-unused-labels
|
|
9
|
+
/* eslint-disable jsdoc/require-jsdoc */
|
|
10
|
+
class ElementLike extends constructor {
|
|
11
|
+
#getCondition(selector) {
|
|
12
|
+
return (0, selector_1.getCondition)(selector,
|
|
13
|
+
// @ts-expect-error only AstElement
|
|
14
|
+
this);
|
|
27
15
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
16
|
+
getElementBy(condition) {
|
|
17
|
+
for (const child of this.childNodes) {
|
|
18
|
+
if (child.type === 'text') {
|
|
19
|
+
continue;
|
|
20
|
+
}
|
|
21
|
+
else if (condition(child)) {
|
|
22
|
+
return child;
|
|
23
|
+
}
|
|
24
|
+
const descendant = child.getElementBy(condition);
|
|
25
|
+
if (descendant) {
|
|
26
|
+
return descendant;
|
|
27
|
+
}
|
|
40
28
|
}
|
|
41
|
-
|
|
29
|
+
return undefined;
|
|
42
30
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}
|
|
48
|
-
escape() {
|
|
49
|
-
LSP: { // eslint-disable-line no-unused-labels
|
|
31
|
+
querySelector(selector) {
|
|
32
|
+
return this.getElementBy(this.#getCondition(selector));
|
|
33
|
+
}
|
|
34
|
+
getElementsBy(condition, descendants = []) {
|
|
50
35
|
for (const child of this.childNodes) {
|
|
51
|
-
child.
|
|
36
|
+
if (child.type === 'text') {
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
else if (condition(child)) {
|
|
40
|
+
descendants.push(child);
|
|
41
|
+
}
|
|
42
|
+
child.getElementsBy(condition, descendants);
|
|
43
|
+
}
|
|
44
|
+
return descendants;
|
|
45
|
+
}
|
|
46
|
+
querySelectorAll(selector) {
|
|
47
|
+
return this.getElementsBy(this.#getCondition(selector));
|
|
48
|
+
}
|
|
49
|
+
escape() {
|
|
50
|
+
LSP: { // eslint-disable-line no-unused-labels
|
|
51
|
+
for (const child of this.childNodes) {
|
|
52
|
+
child.escape();
|
|
53
|
+
}
|
|
52
54
|
}
|
|
53
55
|
}
|
|
54
56
|
}
|
|
57
|
+
/* eslint-enable jsdoc/require-jsdoc */
|
|
58
|
+
(0, debug_1.mixin)(ElementLike, constructor);
|
|
59
|
+
return ElementLike;
|
|
55
60
|
}
|
|
56
|
-
/* eslint-enable jsdoc/require-jsdoc */
|
|
57
|
-
(0, debug_1.mixin)(ElementLike, constructor);
|
|
58
|
-
return ElementLike;
|
|
59
61
|
};
|
|
60
62
|
exports.elementLike = elementLike;
|
package/dist/mixin/hidden.js
CHANGED
package/dist/mixin/nodeLike.js
CHANGED
|
@@ -13,10 +13,10 @@ const nodeLike = (constructor) => {
|
|
|
13
13
|
return this.childNodes[this.childNodes.length - 1];
|
|
14
14
|
}
|
|
15
15
|
get offsetHeight() {
|
|
16
|
-
return this.getDimension().height;
|
|
16
|
+
LINT: return this.getDimension().height; // eslint-disable-line no-unused-labels
|
|
17
17
|
}
|
|
18
18
|
get offsetWidth() {
|
|
19
|
-
return this.getDimension().width;
|
|
19
|
+
LINT: return this.getDimension().width; // eslint-disable-line no-unused-labels
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
22
|
/* eslint-enable jsdoc/require-jsdoc */
|
package/dist/mixin/padded.js
CHANGED
|
@@ -8,14 +8,16 @@ const debug_1 = require("../util/debug");
|
|
|
8
8
|
* @param padding.length
|
|
9
9
|
*/
|
|
10
10
|
const padded = ({ length }) => (constructor) => {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
LINT: { // eslint-disable-line no-unused-labels
|
|
12
|
+
/* eslint-disable jsdoc/require-jsdoc */
|
|
13
|
+
class PaddedToken extends constructor {
|
|
14
|
+
getAttribute(key) {
|
|
15
|
+
return key === 'padding' ? length : super.getAttribute(key);
|
|
16
|
+
}
|
|
15
17
|
}
|
|
18
|
+
/* eslint-enable jsdoc/require-jsdoc */
|
|
19
|
+
(0, debug_1.mixin)(PaddedToken, constructor);
|
|
20
|
+
return PaddedToken;
|
|
16
21
|
}
|
|
17
|
-
/* eslint-enable jsdoc/require-jsdoc */
|
|
18
|
-
(0, debug_1.mixin)(PaddedToken, constructor);
|
|
19
|
-
return PaddedToken;
|
|
20
22
|
};
|
|
21
23
|
exports.padded = padded;
|
|
@@ -59,8 +59,11 @@ const parseCommentAndExt = (wikitext, config, accum, includeOnly) => {
|
|
|
59
59
|
return str;
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
|
-
const { ext } = config
|
|
62
|
+
const { ext } = config;
|
|
63
|
+
let newExt = ext, newConfig = config;
|
|
63
64
|
if (ext.includes('translate')) {
|
|
65
|
+
newExt = ext.filter(e => e !== 'translate' && e !== 'tvar');
|
|
66
|
+
newConfig = { ...config, ext: newExt };
|
|
64
67
|
const stack = [];
|
|
65
68
|
wikitext = wikitext.replace(/<nowiki>[\s\S]*?<\/nowiki>/giu, m => {
|
|
66
69
|
stack.push(m);
|
|
@@ -93,7 +96,7 @@ const parseCommentAndExt = (wikitext, config, accum, includeOnly) => {
|
|
|
93
96
|
}
|
|
94
97
|
else {
|
|
95
98
|
// @ts-expect-error abstract class
|
|
96
|
-
new noinclude_1.NoincludeToken(substr, config, accum);
|
|
99
|
+
new noinclude_1.NoincludeToken(substr, config, accum, true);
|
|
97
100
|
}
|
|
98
101
|
return `\0${l}${ch}\x7F`;
|
|
99
102
|
});
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.parseHrAndDoubleUnderscore = void 0;
|
|
4
|
+
const cm_util_1 = require("@bhsd/cm-util");
|
|
4
5
|
const hr_1 = require("../src/nowiki/hr");
|
|
5
6
|
const doubleUnderscore_1 = require("../src/nowiki/doubleUnderscore");
|
|
6
7
|
const heading_1 = require("../src/heading");
|
|
@@ -11,10 +12,10 @@ const heading_1 = require("../src/heading");
|
|
|
11
12
|
* @param accum
|
|
12
13
|
*/
|
|
13
14
|
const parseHrAndDoubleUnderscore = ({ firstChild: { data }, type, name }, config, accum) => {
|
|
14
|
-
const { doubleUnderscore: [insensitive, sensitive, aliases] } = config;
|
|
15
|
-
config.insensitiveDoubleUnderscore ??= new Set(insensitive);
|
|
16
|
-
config.sensitiveDoubleUnderscore ??= new Set(sensitive);
|
|
17
|
-
config.regexHrAndDoubleUnderscore ??= new RegExp(`__(${
|
|
15
|
+
const { doubleUnderscore: [insensitive, sensitive, aliases] } = config, all = [...insensitive, ...sensitive];
|
|
16
|
+
config.insensitiveDoubleUnderscore ??= new Set(insensitive.filter(cm_util_1.isUnderscore));
|
|
17
|
+
config.sensitiveDoubleUnderscore ??= new Set(sensitive.filter(cm_util_1.isUnderscore));
|
|
18
|
+
config.regexHrAndDoubleUnderscore ??= new RegExp(`__(${all.filter(cm_util_1.isUnderscore).join('|')})__|_{2}(${all.filter(s => !(0, cm_util_1.isUnderscore)(s)).map(s => s.slice(2, -2)).join('|')})_{2}`, 'giu');
|
|
18
19
|
if (type !== 'root' && (type !== 'ext-inner' || name !== 'poem')) {
|
|
19
20
|
data = `\0${data}`;
|
|
20
21
|
}
|
|
@@ -22,11 +23,11 @@ const parseHrAndDoubleUnderscore = ({ firstChild: { data }, type, name }, config
|
|
|
22
23
|
// @ts-expect-error abstract class
|
|
23
24
|
new hr_1.HrToken(m, config, accum);
|
|
24
25
|
return `${lead}\0${accum.length - 1}r\x7F`;
|
|
25
|
-
}).replace(config.regexHrAndDoubleUnderscore, (m, p1) => {
|
|
26
|
-
const caseSensitive = config.sensitiveDoubleUnderscore.has(
|
|
26
|
+
}).replace(config.regexHrAndDoubleUnderscore, (m, p1, p2) => {
|
|
27
|
+
const key = p1 ?? p2, caseSensitive = config.sensitiveDoubleUnderscore.has(key), lc = key.toLowerCase(), caseInsensitive = config.insensitiveDoubleUnderscore.has(lc);
|
|
27
28
|
if (caseSensitive || caseInsensitive) {
|
|
28
29
|
// @ts-expect-error abstract class
|
|
29
|
-
new doubleUnderscore_1.DoubleUnderscoreToken(
|
|
30
|
+
new doubleUnderscore_1.DoubleUnderscoreToken(key, caseSensitive, Boolean(p2), config, accum);
|
|
30
31
|
return `\0${accum.length - 1}${caseInsensitive && (aliases?.[lc] ?? /* istanbul ignore next */ lc) === 'toc' ? 'u' : 'n'}\x7F`;
|
|
31
32
|
}
|
|
32
33
|
return m;
|
package/dist/parser/html.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.parseHtml = void 0;
|
|
4
4
|
const attributes_1 = require("../src/attributes");
|
|
5
|
-
const html_1 = require("../src/html");
|
|
5
|
+
const html_1 = require("../src/tag/html");
|
|
6
6
|
const regex = /^(\/?)([a-z][^\s/>]*)((?:\s|\/(?!>))[^>]*?)?(\/?>)([^<]*)$/iu;
|
|
7
7
|
/**
|
|
8
8
|
* 解析HTML标签
|
package/dist/src/arg.js
CHANGED
|
@@ -101,7 +101,7 @@ let ArgToken = (() => {
|
|
|
101
101
|
text() {
|
|
102
102
|
return `{{{${(0, string_1.text)(this.childNodes.slice(0, 2), '|')}}}}`;
|
|
103
103
|
}
|
|
104
|
-
/**
|
|
104
|
+
/** 更新name */
|
|
105
105
|
#setName() {
|
|
106
106
|
// eslint-disable-next-line no-unused-labels
|
|
107
107
|
LSP: this.setAttribute('name', this.firstChild.text().trim());
|
|
@@ -126,9 +126,8 @@ let ArgToken = (() => {
|
|
|
126
126
|
errors.push(...childErrors);
|
|
127
127
|
}
|
|
128
128
|
}
|
|
129
|
-
const rules = ['no-ignored', 'no-arg'], { lintConfig } = index_1.default, { computeEditInfo } = lintConfig, s = rules.map(rule => lintConfig.getSeverity(rule, 'arg'));
|
|
129
|
+
const rules = ['no-ignored', 'no-arg'], { lintConfig } = index_1.default, { computeEditInfo } = lintConfig, rect = new rect_1.BoundingRect(this, start), s = rules.map(rule => lintConfig.getSeverity(rule, 'arg'));
|
|
130
130
|
if (s[0] && rest.length > 0) {
|
|
131
|
-
const rect = new rect_1.BoundingRect(this, start);
|
|
132
131
|
errors.push(...rest.map(child => {
|
|
133
132
|
const e = (0, lint_1.generateForChild)(child, rect, rules[0], 'invisible-triple-braces', s[0]);
|
|
134
133
|
e.startIndex--;
|
|
@@ -143,7 +142,7 @@ let ArgToken = (() => {
|
|
|
143
142
|
}));
|
|
144
143
|
}
|
|
145
144
|
if (s[1] && !this.getAttribute('include')) {
|
|
146
|
-
const e = (0, lint_1.generateForSelf)(this,
|
|
145
|
+
const e = (0, lint_1.generateForSelf)(this, rect, rules[1], 'unexpected-argument', s[1]);
|
|
147
146
|
if (computeEditInfo && argDefault) {
|
|
148
147
|
e.suggestions = [(0, lint_1.fixBy)(e, 'expand', argDefault.text())];
|
|
149
148
|
}
|
package/dist/src/atom.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Token } from './index';
|
|
2
2
|
import type { Config } from '../base';
|
|
3
|
-
declare const atomTypes: readonly ["arg-name", "attr-key", "attr-value", "ext-attr-dirty", "html-attr-dirty", "table-attr-dirty", "converter-flag", "converter-rule-variant", "converter-rule-to", "converter-rule-from", "invoke-function", "invoke-module", "template-name", "link-target"
|
|
3
|
+
declare const atomTypes: readonly ["arg-name", "attr-key", "attr-value", "ext-attr-dirty", "html-attr-dirty", "table-attr-dirty", "converter-flag", "converter-rule-variant", "converter-rule-to", "converter-rule-from", "invoke-function", "invoke-module", "template-name", "link-target"];
|
|
4
4
|
declare type AtomTypes = typeof atomTypes[number];
|
|
5
5
|
/**
|
|
6
6
|
* plain Token that will not be parsed further
|
package/dist/src/atom.js
CHANGED
package/dist/src/attribute.d.ts
CHANGED
|
@@ -3,7 +3,6 @@ import { Token } from './index';
|
|
|
3
3
|
import { AtomToken } from './atom';
|
|
4
4
|
import type { LintError } from '../base';
|
|
5
5
|
import type { AttributesToken } from '../internal';
|
|
6
|
-
declare type Child = AtomToken | AttributeToken | undefined;
|
|
7
6
|
export type AttributeTypes = 'ext-attr' | 'html-attr' | 'table-attr';
|
|
8
7
|
/**
|
|
9
8
|
* attribute of extension and HTML tags
|
|
@@ -18,8 +17,8 @@ export declare abstract class AttributeToken extends Token {
|
|
|
18
17
|
abstract get firstChild(): AtomToken;
|
|
19
18
|
abstract get lastChild(): Token;
|
|
20
19
|
abstract get parentNode(): AttributesToken | undefined;
|
|
21
|
-
abstract get nextSibling():
|
|
22
|
-
abstract get previousSibling():
|
|
20
|
+
abstract get nextSibling(): AtomToken | this | undefined;
|
|
21
|
+
abstract get previousSibling(): AtomToken | this | undefined;
|
|
23
22
|
get type(): AttributeTypes;
|
|
24
23
|
/** tag name / 标签名 */
|
|
25
24
|
get tag(): string;
|
|
@@ -42,4 +41,3 @@ export declare abstract class AttributeToken extends Token {
|
|
|
42
41
|
getValue(): string | true;
|
|
43
42
|
escape(): void;
|
|
44
43
|
}
|
|
45
|
-
export {};
|
package/dist/src/attribute.js
CHANGED
|
@@ -44,7 +44,7 @@ class AttributeToken extends index_2.Token {
|
|
|
44
44
|
}
|
|
45
45
|
/** whether the quotes are balanced / 引号是否匹配 */
|
|
46
46
|
get balanced() {
|
|
47
|
-
return !this.#equal || this.#quotes[0] === this.#quotes[1];
|
|
47
|
+
LINT: return !this.#equal || this.#quotes[0] === this.#quotes[1]; // eslint-disable-line no-unused-labels
|
|
48
48
|
}
|
|
49
49
|
/**
|
|
50
50
|
* @param type 标签类型
|
|
@@ -63,6 +63,7 @@ class AttributeToken extends index_2.Token {
|
|
|
63
63
|
valueToken.setAttribute('stage', constants_1.MAX_STAGE - 1);
|
|
64
64
|
}
|
|
65
65
|
else if (tag === 'gallery' && key === 'caption'
|
|
66
|
+
|| tag === 'ref' && key === 'details'
|
|
66
67
|
|| tag === 'choose' && (key === 'before' || key === 'after')) {
|
|
67
68
|
const newConfig = {
|
|
68
69
|
...config,
|
|
@@ -83,6 +84,10 @@ class AttributeToken extends index_2.Token {
|
|
|
83
84
|
this.#tag = tag;
|
|
84
85
|
this.setAttribute('name', (0, string_1.trimLc)((0, string_1.removeComment)(key)));
|
|
85
86
|
}
|
|
87
|
+
/** 更新name */
|
|
88
|
+
#setName() {
|
|
89
|
+
this.setAttribute('name', (0, string_1.trimLc)(this.firstChild.text()));
|
|
90
|
+
}
|
|
86
91
|
/** @private */
|
|
87
92
|
afterBuild() {
|
|
88
93
|
if (this.#equal.includes('\0')) {
|
|
@@ -91,7 +96,7 @@ class AttributeToken extends index_2.Token {
|
|
|
91
96
|
if (this.parentNode) {
|
|
92
97
|
this.#tag = this.parentNode.name;
|
|
93
98
|
}
|
|
94
|
-
this
|
|
99
|
+
this.#setName();
|
|
95
100
|
super.afterBuild();
|
|
96
101
|
}
|
|
97
102
|
/** @private */
|
package/dist/src/attributes.d.ts
CHANGED
|
@@ -6,7 +6,6 @@ import type { ExtToken, HtmlToken, SyntaxToken } from '../internal';
|
|
|
6
6
|
import type { AttributeTypes } from './attribute';
|
|
7
7
|
import type { TableTokens } from './table/index';
|
|
8
8
|
declare type AttributesTypes = `${AttributeTypes}s`;
|
|
9
|
-
declare type Child = AtomToken | AttributeToken;
|
|
10
9
|
/**
|
|
11
10
|
* attributes of extension and HTML tags
|
|
12
11
|
*
|
|
@@ -16,9 +15,9 @@ declare type Child = AtomToken | AttributeToken;
|
|
|
16
15
|
export declare abstract class AttributesToken extends Token {
|
|
17
16
|
#private;
|
|
18
17
|
readonly name: string;
|
|
19
|
-
readonly childNodes: readonly
|
|
20
|
-
abstract get firstChild():
|
|
21
|
-
abstract get lastChild():
|
|
18
|
+
readonly childNodes: readonly (AtomToken | AttributeToken)[];
|
|
19
|
+
abstract get firstChild(): AtomToken | AttributeToken | undefined;
|
|
20
|
+
abstract get lastChild(): AtomToken | AttributeToken | undefined;
|
|
22
21
|
abstract get parentNode(): ExtToken | HtmlToken | TableTokens | undefined;
|
|
23
22
|
abstract get previousSibling(): SyntaxToken | undefined;
|
|
24
23
|
get type(): AttributesTypes;
|
package/dist/src/attributes.js
CHANGED
|
@@ -112,8 +112,10 @@ class AttributesToken extends index_2.Token {
|
|
|
112
112
|
* @param key attribute name / 属性名
|
|
113
113
|
*/
|
|
114
114
|
getAttrToken(key) {
|
|
115
|
-
|
|
116
|
-
|
|
115
|
+
LINT: { // eslint-disable-line no-unused-labels
|
|
116
|
+
const tokens = this.getAttrTokens(key);
|
|
117
|
+
return tokens[tokens.length - 1];
|
|
118
|
+
}
|
|
117
119
|
}
|
|
118
120
|
/**
|
|
119
121
|
* Get the attribute
|
|
@@ -122,7 +124,7 @@ class AttributesToken extends index_2.Token {
|
|
|
122
124
|
* @param key attribute name / 属性键
|
|
123
125
|
*/
|
|
124
126
|
getAttr(key) {
|
|
125
|
-
return this.getAttrToken(key)?.getValue();
|
|
127
|
+
LINT: return this.getAttrToken(key)?.getValue(); // eslint-disable-line no-unused-labels
|
|
126
128
|
}
|
|
127
129
|
/** 是否位于闭合标签内 */
|
|
128
130
|
#lint() {
|
package/dist/src/commented.d.ts
CHANGED
|
@@ -7,9 +7,9 @@ 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 childNodes: readonly (
|
|
11
|
-
abstract get firstChild():
|
|
12
|
-
abstract get lastChild():
|
|
10
|
+
readonly childNodes: readonly (CommentToken | AstText)[];
|
|
11
|
+
abstract get firstChild(): CommentToken | AstText | undefined;
|
|
12
|
+
abstract get lastChild(): CommentToken | AstText | undefined;
|
|
13
13
|
abstract get nextSibling(): undefined;
|
|
14
14
|
abstract get previousSibling(): AttributesToken | undefined;
|
|
15
15
|
abstract get parentNode(): ExtToken | undefined;
|