wikiparser-node 1.26.0 → 1.28.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/bundle/bundle-es8.min.js +25 -25
- package/bundle/bundle-lsp.min.js +30 -30
- package/bundle/bundle.min.js +24 -25
- package/coverage/badge.svg +1 -1
- package/data/.schema.json +2 -1
- package/data/signatures.json +82 -16
- package/dist/addon/token.js +1 -1
- package/dist/base.d.mts +3 -3
- package/dist/base.d.ts +3 -3
- package/dist/bin/config.js +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -3
- package/dist/internal.d.ts +5 -5
- package/dist/lib/document.js +6 -0
- package/dist/lib/lintConfig.js +19 -12
- package/dist/lib/lsp.d.ts +1 -1
- package/dist/lib/lsp.js +1 -1
- package/dist/lib/node.js +51 -40
- package/dist/lib/text.js +3 -3
- package/dist/mixin/attributesParent.js +59 -57
- package/dist/mixin/elementLike.js +77 -75
- package/dist/mixin/hidden.js +3 -3
- package/dist/mixin/nodeLike.js +2 -2
- package/dist/mixin/padded.js +9 -7
- package/dist/mixin/singleLine.d.ts +1 -1
- package/dist/mixin/singleLine.js +10 -11
- package/dist/parser/commentAndExt.js +1 -1
- package/dist/parser/html.js +1 -1
- package/dist/parser/selector.js +2 -1
- package/dist/src/arg.js +2 -2
- package/dist/src/atom.d.ts +1 -1
- package/dist/src/atom.js +0 -1
- package/dist/src/attribute.d.ts +5 -7
- package/dist/src/attribute.js +32 -23
- package/dist/src/attributes.d.ts +7 -8
- package/dist/src/attributes.js +5 -3
- package/dist/src/commented.d.ts +3 -3
- package/dist/src/converterRule.js +1 -1
- package/dist/src/heading.js +1 -1
- package/dist/src/imageParameter.d.ts +0 -8
- package/dist/src/imageParameter.js +12 -8
- package/dist/src/imagemapLink.js +1 -1
- package/dist/src/index.d.ts +0 -5
- package/dist/src/index.js +3 -6
- package/dist/src/link/base.js +1 -2
- package/dist/src/link/category.js +1 -2
- package/dist/src/link/file.js +17 -9
- package/dist/src/link/galleryImage.d.ts +0 -3
- package/dist/src/link/galleryImage.js +3 -2
- package/dist/src/link/index.js +1 -1
- package/dist/src/magicLink.d.ts +0 -7
- package/dist/src/multiLine/gallery.d.ts +49 -0
- package/dist/src/{gallery.js → multiLine/gallery.js} +24 -37
- package/dist/src/multiLine/imagemap.d.ts +25 -0
- package/dist/src/{imagemap.js → multiLine/imagemap.js} +20 -36
- package/dist/src/multiLine/index.d.ts +17 -0
- package/dist/src/multiLine/index.js +36 -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 +20 -0
- package/dist/src/{paramTag/index.js → multiLine/paramTag.js} +10 -24
- package/dist/src/nowiki/base.d.ts +1 -1
- package/dist/src/nowiki/comment.js +3 -1
- package/dist/src/nowiki/commentLine.d.ts +11 -0
- package/dist/src/nowiki/commentLine.js +67 -0
- package/dist/src/nowiki/listBase.js +1 -2
- package/dist/src/nowiki/noinclude.d.ts +6 -0
- package/dist/src/nowiki/noinclude.js +19 -4
- package/dist/src/nowiki/quote.js +2 -2
- package/dist/src/paramLine.d.ts +17 -0
- package/dist/src/paramLine.js +83 -0
- package/dist/src/parameter.d.ts +0 -1
- package/dist/src/parameter.js +2 -1
- package/dist/src/pre.d.ts +6 -8
- package/dist/src/pre.js +3 -2
- package/dist/src/syntax.d.ts +1 -1
- package/dist/src/table/base.d.ts +6 -1
- package/dist/src/table/base.js +96 -46
- package/dist/src/table/index.js +71 -67
- package/dist/src/table/td.d.ts +2 -2
- package/dist/src/table/td.js +8 -7
- package/dist/src/table/tr.d.ts +2 -2
- package/dist/src/table/trBase.d.ts +0 -5
- package/dist/src/table/trBase.js +4 -5
- package/dist/src/{html.d.ts → tag/html.d.ts} +6 -22
- package/dist/src/{html.js → tag/html.js} +43 -131
- package/dist/src/tag/index.d.ts +44 -0
- package/dist/src/tag/index.js +214 -0
- package/dist/src/tag/tvar.d.ts +38 -0
- package/dist/src/tag/tvar.js +169 -0
- package/dist/src/tagPair/ext.js +4 -4
- package/dist/src/tagPair/include.js +1 -1
- package/dist/src/tagPair/index.d.ts +1 -1
- package/dist/src/tagPair/index.js +1 -0
- package/dist/src/tagPair/translate.js +10 -10
- package/dist/src/transclude.d.ts +8 -9
- package/dist/src/transclude.js +8 -5
- package/dist/util/constants.js +1 -1
- package/dist/util/html.js +2 -1
- package/extensions/dist/base.js +1 -1
- package/extensions/ui.css +1 -1
- package/i18n/en.json +14 -13
- package/i18n/zh-hans.json +19 -18
- package/i18n/zh-hant.json +31 -30
- package/package.json +2 -2
- package/dist/mixin/multiLine.d.ts +0 -4
- package/dist/mixin/multiLine.js +0 -33
- package/dist/src/gallery.d.ts +0 -66
- package/dist/src/imagemap.d.ts +0 -49
- package/dist/src/paramTag/index.d.ts +0 -28
package/dist/lib/node.js
CHANGED
|
@@ -221,8 +221,10 @@ let AstNode = (() => {
|
|
|
221
221
|
this.#previousSibling = value;
|
|
222
222
|
break;
|
|
223
223
|
case 'aIndex':
|
|
224
|
-
|
|
225
|
-
|
|
224
|
+
LINT: { // eslint-disable-line no-unused-labels
|
|
225
|
+
if (index_1.default.viewOnly) {
|
|
226
|
+
this.#aIndex = [debug_1.Shadow.rev, value];
|
|
227
|
+
}
|
|
226
228
|
}
|
|
227
229
|
break;
|
|
228
230
|
default:
|
|
@@ -285,18 +287,22 @@ let AstNode = (() => {
|
|
|
285
287
|
* @param index character index / 字符位置
|
|
286
288
|
*/
|
|
287
289
|
posFromIndex(index) {
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
290
|
+
LINT: { // eslint-disable-line no-unused-labels
|
|
291
|
+
const { length } = String(this);
|
|
292
|
+
index += index < 0 ? length : 0;
|
|
293
|
+
if (index >= 0 && index <= length) {
|
|
294
|
+
const lines = this.getLines(), top = lines.findIndex(([, , end]) => index <= end);
|
|
295
|
+
return { top, left: index - lines[top][1] };
|
|
296
|
+
}
|
|
297
|
+
return undefined;
|
|
293
298
|
}
|
|
294
|
-
return undefined;
|
|
295
299
|
}
|
|
296
300
|
/** @private */
|
|
297
301
|
getDimension() {
|
|
298
|
-
|
|
299
|
-
|
|
302
|
+
LINT: { // eslint-disable-line no-unused-labels
|
|
303
|
+
const lines = this.getLines(), last = lines[lines.length - 1];
|
|
304
|
+
return { height: lines.length, width: last[2] - last[1] };
|
|
305
|
+
}
|
|
300
306
|
}
|
|
301
307
|
/** @private */
|
|
302
308
|
getGaps(_) {
|
|
@@ -309,28 +315,30 @@ let AstNode = (() => {
|
|
|
309
315
|
* @param j rank of the child node / 子节点序号
|
|
310
316
|
*/
|
|
311
317
|
getRelativeIndex(j) {
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
/* NOT FOR BROWSER */
|
|
319
|
-
this.verifyChild(j, 1);
|
|
320
|
-
/* NOT FOR BROWSER END */
|
|
321
|
-
return (0, lint_1.cache)(this.#rIndex[j], () => {
|
|
322
|
-
const { childNodes } = this, n = j + (j < 0 ? childNodes.length : 0);
|
|
323
|
-
let acc = this.getAttribute('padding');
|
|
324
|
-
for (let i = 0; i < n; i++) {
|
|
325
|
-
if (index_1.default.viewOnly) {
|
|
326
|
-
this.#rIndex[i] = [debug_1.Shadow.rev, acc];
|
|
327
|
-
}
|
|
328
|
-
acc += childNodes[i].toString().length + this.getGaps(i);
|
|
318
|
+
LINT: { // eslint-disable-line no-unused-labels
|
|
319
|
+
if (j === undefined) {
|
|
320
|
+
const { parentNode } = this;
|
|
321
|
+
return parentNode
|
|
322
|
+
? parentNode.getRelativeIndex(parentNode.childNodes.indexOf(this))
|
|
323
|
+
: 0;
|
|
329
324
|
}
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
325
|
+
/* NOT FOR BROWSER */
|
|
326
|
+
this.verifyChild(j, 1);
|
|
327
|
+
/* NOT FOR BROWSER END */
|
|
328
|
+
return (0, lint_1.cache)(this.#rIndex[j], () => {
|
|
329
|
+
const { childNodes } = this, n = j + (j < 0 ? childNodes.length : 0);
|
|
330
|
+
let acc = this.getAttribute('padding');
|
|
331
|
+
for (let i = 0; i < n; i++) {
|
|
332
|
+
if (index_1.default.viewOnly) {
|
|
333
|
+
this.#rIndex[i] = [debug_1.Shadow.rev, acc];
|
|
334
|
+
}
|
|
335
|
+
acc += childNodes[i].toString().length + this.getGaps(i);
|
|
336
|
+
}
|
|
337
|
+
return acc;
|
|
338
|
+
}, value => {
|
|
339
|
+
this.#rIndex[j] = value;
|
|
340
|
+
});
|
|
341
|
+
}
|
|
334
342
|
}
|
|
335
343
|
/**
|
|
336
344
|
* Get the absolute character index of the current node
|
|
@@ -338,7 +346,8 @@ let AstNode = (() => {
|
|
|
338
346
|
* 获取当前节点的绝对位置
|
|
339
347
|
*/
|
|
340
348
|
getAbsoluteIndex() {
|
|
341
|
-
return (0, lint_1.cache)(
|
|
349
|
+
LINT: return (0, lint_1.cache)(// eslint-disable-line no-unused-labels
|
|
350
|
+
this.#aIndex, () => {
|
|
342
351
|
const { parentNode } = this;
|
|
343
352
|
return parentNode ? parentNode.getAbsoluteIndex() + this.getRelativeIndex() : 0;
|
|
344
353
|
}, value => {
|
|
@@ -374,14 +383,16 @@ let AstNode = (() => {
|
|
|
374
383
|
* @since v1.16.3
|
|
375
384
|
*/
|
|
376
385
|
getLines() {
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
const
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
386
|
+
LINT: { // eslint-disable-line no-unused-labels
|
|
387
|
+
const results = [];
|
|
388
|
+
let start = 0;
|
|
389
|
+
for (const line of String(this).split('\n')) {
|
|
390
|
+
const end = start + line.length;
|
|
391
|
+
results.push([line, start, end]);
|
|
392
|
+
start = end + 1;
|
|
393
|
+
}
|
|
394
|
+
return results;
|
|
395
|
+
}
|
|
385
396
|
}
|
|
386
397
|
/* PRINT ONLY */
|
|
387
398
|
/** @private */
|
package/dist/lib/text.js
CHANGED
|
@@ -221,9 +221,9 @@ let AstText = (() => {
|
|
|
221
221
|
return [];
|
|
222
222
|
}
|
|
223
223
|
errorRegex.lastIndex = 0;
|
|
224
|
-
const errors = [], nextType = nextSibling?.type, nextName = nextSibling?.name, previousType = previousSibling?.type, root = this.getRootNode(), rootStr = root.toString(), { ext, html, variants } = root.getAttribute('config'), { top, left } = root.posFromIndex(start), { lintConfig } = index_1.default, tagLike = lintConfig.rules['tag-like'], specified = typeof tagLike === '
|
|
225
|
-
? new Set()
|
|
226
|
-
: new Set(
|
|
224
|
+
const errors = [], nextType = nextSibling?.type, nextName = nextSibling?.name, previousType = previousSibling?.type, root = this.getRootNode(), rootStr = root.toString(), { ext, html, variants } = root.getAttribute('config'), { top, left } = root.posFromIndex(start), { lintConfig } = index_1.default, tagLike = lintConfig.rules['tag-like'], specified = typeof tagLike === 'object' && tagLike[1]
|
|
225
|
+
? new Set(Object.keys(tagLike[1]).filter(tag => tag !== 'invalid' && tag !== 'disallowed'))
|
|
226
|
+
: new Set(), tags = new Set([
|
|
227
227
|
'onlyinclude',
|
|
228
228
|
'noinclude',
|
|
229
229
|
'includeonly',
|
|
@@ -9,64 +9,66 @@ const constants_1 = require("../util/constants");
|
|
|
9
9
|
* @param i AttributesToken子节点的位置
|
|
10
10
|
*/
|
|
11
11
|
const attributesParent = (i = 0) => (constructor) => {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
12
|
+
LINT: { // eslint-disable-line no-unused-labels
|
|
13
|
+
/* eslint-disable jsdoc/require-jsdoc */
|
|
14
|
+
class AttributesParent extends constructor {
|
|
15
|
+
/* NOT FOR BROWSER */
|
|
16
|
+
get attributes() {
|
|
17
|
+
return this.#getAttributesChild().attributes;
|
|
18
|
+
}
|
|
19
|
+
set attributes(attributes) {
|
|
20
|
+
this.#getAttributesChild().attributes = attributes;
|
|
21
|
+
}
|
|
22
|
+
get className() {
|
|
23
|
+
return this.#getAttributesChild().className;
|
|
24
|
+
}
|
|
25
|
+
set className(className) {
|
|
26
|
+
this.#getAttributesChild().className = className;
|
|
27
|
+
}
|
|
28
|
+
get classList() {
|
|
29
|
+
return this.#getAttributesChild().classList;
|
|
30
|
+
}
|
|
31
|
+
get id() {
|
|
32
|
+
return this.#getAttributesChild().id;
|
|
33
|
+
}
|
|
34
|
+
set id(id) {
|
|
35
|
+
this.#getAttributesChild().id = id;
|
|
36
|
+
}
|
|
37
|
+
/* NOT FOR BROWSER END */
|
|
38
|
+
/** AttributesToken子节点 */
|
|
39
|
+
#getAttributesChild() {
|
|
40
|
+
return this.childNodes[i];
|
|
41
|
+
}
|
|
42
|
+
hasAttr(key) {
|
|
43
|
+
LSP: return this.#getAttributesChild().hasAttr(key); // eslint-disable-line no-unused-labels
|
|
44
|
+
}
|
|
45
|
+
getAttr(key) {
|
|
46
|
+
return this.#getAttributesChild().getAttr(key);
|
|
47
|
+
}
|
|
48
|
+
/* NOT FOR BROWSER */
|
|
49
|
+
getAttrNames() {
|
|
50
|
+
return this.#getAttributesChild().getAttrNames();
|
|
51
|
+
}
|
|
52
|
+
getAttrs() {
|
|
53
|
+
return this.#getAttributesChild().getAttrs();
|
|
54
|
+
}
|
|
55
|
+
setAttr(keyOrProp, value) {
|
|
56
|
+
this.#getAttributesChild().setAttr(keyOrProp, value);
|
|
57
|
+
}
|
|
58
|
+
removeAttr(key) {
|
|
59
|
+
this.#getAttributesChild().removeAttr(key);
|
|
60
|
+
}
|
|
61
|
+
toggleAttr(key, force) {
|
|
62
|
+
this.#getAttributesChild().toggleAttr(key, force);
|
|
63
|
+
}
|
|
64
|
+
css(key, value) {
|
|
65
|
+
return this.#getAttributesChild().css(key, value);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
/* eslint-enable jsdoc/require-jsdoc */
|
|
69
|
+
(0, debug_1.mixin)(AttributesParent, constructor);
|
|
70
|
+
return AttributesParent;
|
|
66
71
|
}
|
|
67
|
-
/* eslint-enable jsdoc/require-jsdoc */
|
|
68
|
-
(0, debug_1.mixin)(AttributesParent, constructor);
|
|
69
|
-
return AttributesParent;
|
|
70
72
|
};
|
|
71
73
|
exports.attributesParent = attributesParent;
|
|
72
74
|
constants_1.mixins['attributesParent'] = __filename;
|
|
@@ -8,89 +8,91 @@ const constants_1 = require("../util/constants");
|
|
|
8
8
|
const element_1 = require("../lib/element");
|
|
9
9
|
/** @ignore */
|
|
10
10
|
const elementLike = (constructor) => {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
get firstElementChild() {
|
|
18
|
-
return this.childNodes.find((child) => child.type !== 'text');
|
|
19
|
-
}
|
|
20
|
-
get lastElementChild() {
|
|
21
|
-
return this.childNodes.findLast((child) => child.type !== 'text');
|
|
22
|
-
}
|
|
23
|
-
get childElementCount() {
|
|
24
|
-
return this.children.length;
|
|
25
|
-
}
|
|
26
|
-
/* NOT FOR BROWSER END */
|
|
27
|
-
#getCondition(selector) {
|
|
28
|
-
return (0, selector_1.getCondition)(selector,
|
|
29
|
-
// eslint-disable-next-line unicorn/no-negated-condition, @stylistic/operator-linebreak
|
|
30
|
-
!(this instanceof element_1.AstElement) ?
|
|
31
|
-
undefined : // eslint-disable-line @stylistic/operator-linebreak
|
|
32
|
-
this);
|
|
33
|
-
}
|
|
34
|
-
getElementBy(condition) {
|
|
35
|
-
for (const child of this.childNodes) {
|
|
36
|
-
if (child.type === 'text') {
|
|
37
|
-
continue;
|
|
38
|
-
}
|
|
39
|
-
else if (condition(child)) {
|
|
40
|
-
return child;
|
|
41
|
-
}
|
|
42
|
-
const descendant = child.getElementBy(condition);
|
|
43
|
-
if (descendant) {
|
|
44
|
-
return descendant;
|
|
45
|
-
}
|
|
11
|
+
LINT: { // eslint-disable-line no-unused-labels
|
|
12
|
+
/* eslint-disable jsdoc/require-jsdoc */
|
|
13
|
+
class ElementLike extends constructor {
|
|
14
|
+
/* NOT FOR BROWSER */
|
|
15
|
+
get children() {
|
|
16
|
+
return this.childNodes.filter((child) => child.type !== 'text');
|
|
46
17
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
18
|
+
get firstElementChild() {
|
|
19
|
+
return this.childNodes.find((child) => child.type !== 'text');
|
|
20
|
+
}
|
|
21
|
+
get lastElementChild() {
|
|
22
|
+
return this.childNodes.findLast((child) => child.type !== 'text');
|
|
23
|
+
}
|
|
24
|
+
get childElementCount() {
|
|
25
|
+
return this.children.length;
|
|
26
|
+
}
|
|
27
|
+
/* NOT FOR BROWSER END */
|
|
28
|
+
#getCondition(selector) {
|
|
29
|
+
return (0, selector_1.getCondition)(selector,
|
|
30
|
+
// eslint-disable-next-line unicorn/no-negated-condition, @stylistic/operator-linebreak
|
|
31
|
+
!(this instanceof element_1.AstElement) ?
|
|
32
|
+
undefined : // eslint-disable-line @stylistic/operator-linebreak
|
|
33
|
+
this);
|
|
34
|
+
}
|
|
35
|
+
getElementBy(condition) {
|
|
36
|
+
for (const child of this.childNodes) {
|
|
37
|
+
if (child.type === 'text') {
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
40
|
+
else if (condition(child)) {
|
|
41
|
+
return child;
|
|
42
|
+
}
|
|
43
|
+
const descendant = child.getElementBy(condition);
|
|
44
|
+
if (descendant) {
|
|
45
|
+
return descendant;
|
|
46
|
+
}
|
|
59
47
|
}
|
|
60
|
-
|
|
48
|
+
return undefined;
|
|
61
49
|
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
}
|
|
67
|
-
escape() {
|
|
68
|
-
LSP: { // eslint-disable-line no-unused-labels
|
|
50
|
+
querySelector(selector) {
|
|
51
|
+
return this.getElementBy(this.#getCondition(selector));
|
|
52
|
+
}
|
|
53
|
+
getElementsBy(condition, descendants = []) {
|
|
69
54
|
for (const child of this.childNodes) {
|
|
70
|
-
child.
|
|
55
|
+
if (child.type === 'text') {
|
|
56
|
+
continue;
|
|
57
|
+
}
|
|
58
|
+
else if (condition(child)) {
|
|
59
|
+
descendants.push(child);
|
|
60
|
+
}
|
|
61
|
+
child.getElementsBy(condition, descendants);
|
|
71
62
|
}
|
|
72
|
-
|
|
73
|
-
|
|
63
|
+
return descendants;
|
|
64
|
+
}
|
|
65
|
+
querySelectorAll(selector) {
|
|
66
|
+
return this.getElementsBy(this.#getCondition(selector));
|
|
67
|
+
}
|
|
68
|
+
escape() {
|
|
69
|
+
LSP: { // eslint-disable-line no-unused-labels
|
|
70
|
+
for (const child of this.childNodes) {
|
|
71
|
+
child.escape();
|
|
72
|
+
}
|
|
73
|
+
/* NOT FOR BROWSER */
|
|
74
|
+
this.detach?.();
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
/* NOT FOR BROWSER */
|
|
78
|
+
getElementByTypes(types) {
|
|
79
|
+
const typeSet = new Set(types.split(',').map(str => str.trim()));
|
|
80
|
+
return this.getElementBy((({ type }) => typeSet.has(type)));
|
|
81
|
+
}
|
|
82
|
+
getElementById(id) {
|
|
83
|
+
return this.getElementBy((token => 'id' in token && token.id === id));
|
|
84
|
+
}
|
|
85
|
+
getElementsByClassName(className) {
|
|
86
|
+
return this.getElementsBy((token => 'classList' in token && token.classList.has(className)));
|
|
87
|
+
}
|
|
88
|
+
getElementsByTagName(tag) {
|
|
89
|
+
return this.getElementsBy((({ type, name }) => name === tag && (type === 'html' || type === 'ext')));
|
|
74
90
|
}
|
|
75
91
|
}
|
|
76
|
-
/*
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
return this.getElementBy((({ type }) => typeSet.has(type)));
|
|
80
|
-
}
|
|
81
|
-
getElementById(id) {
|
|
82
|
-
return this.getElementBy((token => 'id' in token && token.id === id));
|
|
83
|
-
}
|
|
84
|
-
getElementsByClassName(className) {
|
|
85
|
-
return this.getElementsBy((token => 'classList' in token && token.classList.has(className)));
|
|
86
|
-
}
|
|
87
|
-
getElementsByTagName(tag) {
|
|
88
|
-
return this.getElementsBy((({ type, name }) => name === tag && (type === 'html' || type === 'ext')));
|
|
89
|
-
}
|
|
92
|
+
/* eslint-enable jsdoc/require-jsdoc */
|
|
93
|
+
(0, debug_1.mixin)(ElementLike, constructor);
|
|
94
|
+
return ElementLike;
|
|
90
95
|
}
|
|
91
|
-
/* eslint-enable jsdoc/require-jsdoc */
|
|
92
|
-
(0, debug_1.mixin)(ElementLike, constructor);
|
|
93
|
-
return ElementLike;
|
|
94
96
|
};
|
|
95
97
|
exports.elementLike = elementLike;
|
|
96
98
|
constants_1.mixins['elementLike'] = __filename;
|
package/dist/mixin/hidden.js
CHANGED
|
@@ -58,7 +58,6 @@ const hiddenToken = (linter = true, html = true) => (constructor) => {
|
|
|
58
58
|
__esDecorate(this, null, _toHtmlInternal_decorators, { kind: "method", name: "toHtmlInternal", static: false, private: false, access: { has: obj => "toHtmlInternal" in obj, get: obj => obj.toHtmlInternal }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
59
59
|
if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
60
60
|
}
|
|
61
|
-
/** 没有可见部分 */
|
|
62
61
|
text() {
|
|
63
62
|
return '';
|
|
64
63
|
}
|
|
@@ -67,8 +66,9 @@ const hiddenToken = (linter = true, html = true) => (constructor) => {
|
|
|
67
66
|
LINT: return linter ? [] : super.lint(start); // eslint-disable-line no-unused-labels
|
|
68
67
|
}
|
|
69
68
|
/* NOT FOR BROWSER */
|
|
70
|
-
dispatchEvent() {
|
|
71
|
-
|
|
69
|
+
dispatchEvent(e, data) {
|
|
70
|
+
e.stopPropagation();
|
|
71
|
+
super.dispatchEvent(e, data);
|
|
72
72
|
}
|
|
73
73
|
toHtmlInternal(opt) {
|
|
74
74
|
return html ? '' : super.toHtmlInternal(opt);
|
package/dist/mixin/nodeLike.js
CHANGED
|
@@ -15,10 +15,10 @@ const nodeLike = (constructor) => {
|
|
|
15
15
|
return this.childNodes[this.childNodes.length - 1];
|
|
16
16
|
}
|
|
17
17
|
get offsetHeight() {
|
|
18
|
-
return this.getDimension().height;
|
|
18
|
+
LINT: return this.getDimension().height; // eslint-disable-line no-unused-labels
|
|
19
19
|
}
|
|
20
20
|
get offsetWidth() {
|
|
21
|
-
return this.getDimension().width;
|
|
21
|
+
LINT: return this.getDimension().width; // eslint-disable-line no-unused-labels
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
24
|
/* eslint-enable jsdoc/require-jsdoc */
|
package/dist/mixin/padded.js
CHANGED
|
@@ -11,15 +11,17 @@ const constants_1 = require("../util/constants");
|
|
|
11
11
|
* @param padding.length
|
|
12
12
|
*/
|
|
13
13
|
const padded = ({ length }) => (constructor) => {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
LINT: { // eslint-disable-line no-unused-labels
|
|
15
|
+
/* eslint-disable jsdoc/require-jsdoc */
|
|
16
|
+
class PaddedToken extends constructor {
|
|
17
|
+
getAttribute(key) {
|
|
18
|
+
return key === 'padding' ? length : super.getAttribute(key);
|
|
19
|
+
}
|
|
18
20
|
}
|
|
21
|
+
/* eslint-enable jsdoc/require-jsdoc */
|
|
22
|
+
(0, debug_1.mixin)(PaddedToken, constructor);
|
|
23
|
+
return PaddedToken;
|
|
19
24
|
}
|
|
20
|
-
/* eslint-enable jsdoc/require-jsdoc */
|
|
21
|
-
(0, debug_1.mixin)(PaddedToken, constructor);
|
|
22
|
-
return PaddedToken;
|
|
23
25
|
};
|
|
24
26
|
exports.padded = padded;
|
|
25
27
|
constants_1.mixins['padded'] = __filename;
|
package/dist/mixin/singleLine.js
CHANGED
|
@@ -5,22 +5,21 @@ const debug_1 = require("../util/debug");
|
|
|
5
5
|
const constants_1 = require("../util/constants");
|
|
6
6
|
/**
|
|
7
7
|
* 不可包含换行符的类
|
|
8
|
-
* @
|
|
8
|
+
* @ignore
|
|
9
9
|
*/
|
|
10
|
-
const singleLine = (
|
|
10
|
+
const singleLine = (constructor) => {
|
|
11
11
|
/* eslint-disable jsdoc/require-jsdoc */
|
|
12
12
|
class SingleLineToken extends constructor {
|
|
13
13
|
toString(skip) {
|
|
14
|
-
if (
|
|
15
|
-
return
|
|
14
|
+
if (this.parentNode?.name === 'inputbox') {
|
|
15
|
+
return this.childNodes.map(child => {
|
|
16
|
+
const str = child.toString(skip), { type } = child;
|
|
17
|
+
return type === 'comment' || type === 'include' || type === 'ext'
|
|
18
|
+
? str
|
|
19
|
+
: str.replaceAll('\n', ' ');
|
|
20
|
+
}).join('');
|
|
16
21
|
}
|
|
17
|
-
|
|
18
|
-
return this.childNodes.map(child => {
|
|
19
|
-
const str = child.toString(skip), { type } = child;
|
|
20
|
-
return type === 'comment' || type === 'include' || type === 'ext'
|
|
21
|
-
? str
|
|
22
|
-
: str.replaceAll('\n', ' ');
|
|
23
|
-
}).join('');
|
|
22
|
+
return super.toString(skip).replaceAll('\n', ' ');
|
|
24
23
|
}
|
|
25
24
|
text() {
|
|
26
25
|
return super.text().replaceAll('\n', ' ');
|
|
@@ -98,7 +98,7 @@ const parseCommentAndExt = (wikitext, config, accum, includeOnly) => {
|
|
|
98
98
|
}
|
|
99
99
|
else {
|
|
100
100
|
// @ts-expect-error abstract class
|
|
101
|
-
new noinclude_1.NoincludeToken(substr, config, accum);
|
|
101
|
+
new noinclude_1.NoincludeToken(substr, config, accum, true);
|
|
102
102
|
}
|
|
103
103
|
return `\0${l}${ch}\x7F`;
|
|
104
104
|
});
|
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
|
/* NOT FOR BROWSER */
|
|
7
7
|
const constants_1 = require("../util/constants");
|
|
8
8
|
/* NOT FOR BROWSER END */
|
package/dist/parser/selector.js
CHANGED
|
@@ -168,6 +168,7 @@ const matches = (token, step, scope, has) => {
|
|
|
168
168
|
case ':optional':
|
|
169
169
|
return isProtected(token) === false;
|
|
170
170
|
case ':scope':
|
|
171
|
+
/* istanbul ignore if */
|
|
171
172
|
if (!scope) {
|
|
172
173
|
throw new SyntaxError('The :scope pseudo-selector must be used with an element node.');
|
|
173
174
|
}
|
|
@@ -376,7 +377,7 @@ const checkToken = (selector, scope, has) => (token) => {
|
|
|
376
377
|
* @throws `SyntaxError` 非法的选择器
|
|
377
378
|
*/
|
|
378
379
|
const needUniversal = () => {
|
|
379
|
-
/* istanbul ignore
|
|
380
|
+
/* istanbul ignore next */
|
|
380
381
|
if (step.length === 0 && (condition.length > 1 || !has)) {
|
|
381
382
|
throw new SyntaxError(`Invalid selector!\n${selector}\nYou may need the universal selector '*'.`);
|
|
382
383
|
}
|
package/dist/src/arg.js
CHANGED
|
@@ -129,7 +129,7 @@ let ArgToken = (() => {
|
|
|
129
129
|
text() {
|
|
130
130
|
return `{{{${(0, string_1.text)(this.childNodes.slice(0, 2), '|')}}}}`;
|
|
131
131
|
}
|
|
132
|
-
/**
|
|
132
|
+
/** 更新name */
|
|
133
133
|
#setName() {
|
|
134
134
|
// eslint-disable-next-line no-unused-labels
|
|
135
135
|
LSP: this.setAttribute('name', this.firstChild.text().trim());
|
|
@@ -193,8 +193,8 @@ let ArgToken = (() => {
|
|
|
193
193
|
}
|
|
194
194
|
/** @private */
|
|
195
195
|
json(_, start = this.getAbsoluteIndex()) {
|
|
196
|
-
const json = super.json(undefined, start);
|
|
197
196
|
LSP: { // eslint-disable-line no-unused-labels
|
|
197
|
+
const json = super.json(undefined, start);
|
|
198
198
|
json['default'] = this.default;
|
|
199
199
|
return json;
|
|
200
200
|
}
|
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
|