wikiparser-node 0.10.0 → 0.11.0-m
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/README.md +44 -32
- package/config/.schema.json +1 -8
- package/config/default.json +1 -2
- package/config/llwiki.json +1 -36
- package/config/moegirl.json +1 -45
- package/config/zhwiki.json +1 -467
- package/dist/index.d.ts +110 -0
- package/dist/lib/element.d.ts +48 -0
- package/dist/lib/node.d.ts +108 -0
- package/dist/lib/text.d.ts +30 -0
- package/dist/lib/title.d.ts +15 -0
- package/dist/mixin/hidden.d.ts +8 -0
- package/dist/parser/brackets.d.ts +12 -0
- package/dist/parser/commentAndExt.d.ts +8 -0
- package/dist/parser/converter.d.ts +7 -0
- package/dist/parser/externalLinks.d.ts +7 -0
- package/dist/parser/hrAndDoubleUnderscore.d.ts +11 -0
- package/dist/parser/html.d.ts +7 -0
- package/dist/parser/links.d.ts +7 -0
- package/dist/parser/list.d.ts +7 -0
- package/dist/parser/magicLinks.d.ts +7 -0
- package/dist/parser/quotes.d.ts +7 -0
- package/dist/parser/table.d.ts +11 -0
- package/dist/src/arg.d.ts +25 -0
- package/dist/src/atom/hidden.d.ts +5 -0
- package/dist/src/atom/index.d.ts +14 -0
- package/dist/src/attribute.d.ts +42 -0
- package/dist/src/attributes.d.ts +33 -0
- package/dist/src/converter.d.ts +29 -0
- package/dist/src/converterFlags.d.ts +27 -0
- package/dist/src/converterRule.d.ts +29 -0
- package/dist/src/extLink.d.ts +22 -0
- package/dist/src/gallery.d.ts +19 -0
- package/dist/src/hasNowiki/index.d.ts +14 -0
- package/dist/src/hasNowiki/pre.d.ts +13 -0
- package/dist/src/heading.d.ts +24 -0
- package/dist/src/html.d.ts +33 -0
- package/dist/src/imageParameter.d.ts +23 -0
- package/dist/src/imagemap.d.ts +26 -0
- package/dist/src/imagemapLink.d.ts +16 -0
- package/dist/src/index.d.ts +53 -0
- package/dist/src/link/category.d.ts +8 -0
- package/dist/src/link/file.d.ts +27 -0
- package/dist/src/link/galleryImage.d.ts +15 -0
- package/dist/src/link/index.d.ts +29 -0
- package/dist/src/magicLink.d.ts +14 -0
- package/dist/src/nested/choose.d.ts +13 -0
- package/dist/src/nested/combobox.d.ts +13 -0
- package/dist/src/nested/index.d.ts +20 -0
- package/dist/src/nested/references.d.ts +13 -0
- package/dist/src/nowiki/comment.d.ts +19 -0
- package/dist/src/nowiki/dd.d.ts +8 -0
- package/dist/src/nowiki/doubleUnderscore.d.ts +12 -0
- package/dist/src/nowiki/hr.d.ts +13 -0
- package/dist/src/nowiki/index.d.ts +18 -0
- package/dist/src/nowiki/list.d.ts +8 -0
- package/dist/src/nowiki/noinclude.d.ts +8 -0
- package/dist/src/nowiki/quote.d.ts +20 -0
- package/dist/src/onlyinclude.d.ts +17 -0
- package/dist/src/paramTag/index.d.ts +24 -0
- package/dist/src/paramTag/inputbox.d.ts +8 -0
- package/dist/src/parameter.d.ts +28 -0
- package/dist/src/syntax.d.ts +15 -0
- package/dist/src/table/index.d.ts +16 -0
- package/dist/src/table/td.d.ts +39 -0
- package/dist/src/table/tr.d.ts +17 -0
- package/dist/src/tagPair/ext.d.ts +17 -0
- package/dist/src/tagPair/include.d.ts +16 -0
- package/dist/src/tagPair/index.d.ts +28 -0
- package/dist/src/transclude.d.ts +75 -0
- package/dist/util/lint.d.ts +28 -0
- package/dist/util/string.d.ts +31 -0
- package/i18n/zh-hans.json +1 -1
- package/i18n/zh-hant.json +1 -1
- package/index.js +5 -257
- package/lib/element.js +7 -482
- package/lib/node.js +11 -540
- package/lib/text.js +3 -96
- package/lib/title.js +1 -28
- package/mixin/hidden.js +0 -3
- package/package.json +11 -5
- package/parser/brackets.js +3 -2
- package/parser/commentAndExt.js +8 -6
- package/parser/converter.js +1 -2
- package/parser/externalLinks.js +1 -2
- package/parser/hrAndDoubleUnderscore.js +1 -2
- package/parser/html.js +1 -2
- package/parser/links.js +5 -6
- package/parser/list.js +1 -2
- package/parser/magicLinks.js +1 -2
- package/parser/quotes.js +1 -2
- package/parser/table.js +1 -2
- package/src/arg.js +4 -118
- package/src/atom/hidden.js +0 -2
- package/src/atom/index.js +1 -18
- package/src/attribute.js +6 -190
- package/src/attributes.js +5 -308
- package/src/converter.js +3 -109
- package/src/converterFlags.js +1 -188
- package/src/converterRule.js +2 -184
- package/src/extLink.js +2 -122
- package/src/gallery.js +2 -56
- package/src/hasNowiki/index.js +1 -13
- package/src/hasNowiki/pre.js +1 -13
- package/src/heading.js +4 -55
- package/src/html.js +5 -120
- package/src/imageParameter.js +3 -165
- package/src/imagemap.js +3 -62
- package/src/imagemapLink.js +2 -14
- package/src/index.js +9 -530
- package/src/link/category.js +1 -32
- package/src/link/file.js +3 -158
- package/src/link/galleryImage.js +3 -61
- package/src/link/index.js +4 -273
- package/src/magicLink.js +6 -87
- package/src/nested/choose.js +1 -2
- package/src/nested/combobox.js +1 -2
- package/src/nested/index.js +8 -32
- package/src/nested/references.js +1 -2
- package/src/nowiki/comment.js +2 -26
- package/src/nowiki/dd.js +1 -47
- package/src/nowiki/doubleUnderscore.js +1 -31
- package/src/nowiki/hr.js +2 -21
- package/src/nowiki/index.js +2 -24
- package/src/nowiki/list.js +2 -5
- package/src/nowiki/noinclude.js +0 -14
- package/src/nowiki/quote.js +2 -16
- package/src/onlyinclude.js +2 -27
- package/src/paramTag/index.js +2 -25
- package/src/paramTag/inputbox.js +2 -5
- package/src/parameter.js +6 -148
- package/src/syntax.js +1 -69
- package/src/table/index.js +2 -939
- package/src/table/td.js +6 -226
- package/src/table/tr.js +3 -248
- package/src/tagPair/ext.js +4 -23
- package/src/tagPair/include.js +1 -25
- package/src/tagPair/index.js +3 -52
- package/src/transclude.js +6 -513
- package/typings/api.d.ts +9 -0
- package/typings/index.d.ts +51 -0
- package/typings/node.d.ts +16 -0
- package/typings/parser.d.ts +5 -0
- package/typings/token.d.ts +28 -0
- package/util/lint.js +2 -0
- package/util/string.js +0 -51
- package/lib/ranges.js +0 -130
- package/mixin/attributeParent.js +0 -117
- package/mixin/fixedToken.js +0 -40
- package/mixin/singleLine.js +0 -31
- package/mixin/sol.js +0 -54
- package/parser/selector.js +0 -177
- package/src/charinsert.js +0 -97
- package/tool/index.js +0 -1202
- package/util/debug.js +0 -73
package/src/tagPair/index.js
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const Parser = require('../..'),
|
|
4
|
-
fixedToken = require('../../mixin/fixedToken'),
|
|
5
4
|
Token = require('..');
|
|
6
5
|
|
|
7
6
|
/**
|
|
8
7
|
* 成对标签
|
|
9
8
|
* @classdesc `{childNodes: [AstText|AttributesToken, AstText|Token]}`
|
|
10
9
|
*/
|
|
11
|
-
class TagPairToken extends
|
|
10
|
+
class TagPairToken extends Token {
|
|
12
11
|
#selfClosing;
|
|
13
12
|
#closed;
|
|
14
13
|
#tags;
|
|
@@ -18,34 +17,12 @@ class TagPairToken extends fixedToken(Token) {
|
|
|
18
17
|
return this.#closed;
|
|
19
18
|
}
|
|
20
19
|
|
|
21
|
-
set closed(value) {
|
|
22
|
-
this.#closed ||= Boolean(value);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/** getter */
|
|
26
|
-
get selfClosing() {
|
|
27
|
-
return this.#selfClosing;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
set selfClosing(value) {
|
|
31
|
-
value = Boolean(value);
|
|
32
|
-
if (value !== this.#selfClosing && this.lastChild.text()) {
|
|
33
|
-
Parser.warn(`<${this.name}>标签内部的${value ? '文本将被隐藏' : '原有文本将再次可见'}!`);
|
|
34
|
-
}
|
|
35
|
-
this.#selfClosing = value;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/** 内部wikitext */
|
|
39
|
-
get innerText() {
|
|
40
|
-
return this.#selfClosing ? undefined : this.lastChild.text();
|
|
41
|
-
}
|
|
42
|
-
|
|
43
20
|
/**
|
|
44
21
|
* @param {string} name 标签名
|
|
45
22
|
* @param {string|Token} attr 标签属性
|
|
46
23
|
* @param {string|Token} inner 内部wikitext
|
|
47
24
|
* @param {string|undefined} closed 是否封闭;约定`undefined`表示自闭合,`''`表示未闭合
|
|
48
|
-
* @param {accum} accum
|
|
25
|
+
* @param {import('../../typings/token').accum} accum
|
|
49
26
|
*/
|
|
50
27
|
constructor(name, attr, inner, closed, config = Parser.getConfig(), accum = []) {
|
|
51
28
|
super(undefined, config, true);
|
|
@@ -66,17 +43,10 @@ class TagPairToken extends fixedToken(Token) {
|
|
|
66
43
|
|
|
67
44
|
/**
|
|
68
45
|
* @override
|
|
69
|
-
* @param {string} selector
|
|
70
46
|
*/
|
|
71
47
|
toString(selector) {
|
|
72
|
-
const {firstChild, lastChild
|
|
48
|
+
const {firstChild, lastChild} = this,
|
|
73
49
|
[opening, closing] = this.#tags;
|
|
74
|
-
if (selector && this.matches(selector)) {
|
|
75
|
-
return '';
|
|
76
|
-
} else if (!this.#closed && nextSibling) {
|
|
77
|
-
Parser.error(`自动闭合 <${name}>`, lastChild);
|
|
78
|
-
this.#closed = true;
|
|
79
|
-
}
|
|
80
50
|
return this.#selfClosing
|
|
81
51
|
? `<${opening}${String(firstChild)}/>`
|
|
82
52
|
: `<${opening}${String(firstChild)}>${String(lastChild)}${this.#closed ? `</${closing}>` : ''}`;
|
|
@@ -102,25 +72,6 @@ class TagPairToken extends fixedToken(Token) {
|
|
|
102
72
|
getGaps() {
|
|
103
73
|
return 1;
|
|
104
74
|
}
|
|
105
|
-
|
|
106
|
-
/** @override */
|
|
107
|
-
print() {
|
|
108
|
-
const [opening, closing] = this.#tags;
|
|
109
|
-
return super.print(this.#selfClosing
|
|
110
|
-
? {pre: `<${opening}`, post: '/>'}
|
|
111
|
-
: {pre: `<${opening}`, sep: '>', post: this.#closed ? `</${closing}>` : ''});
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
* @override
|
|
116
|
-
* @template {string} T
|
|
117
|
-
* @param {T} key 属性键
|
|
118
|
-
* @returns {TokenAttribute<T>}
|
|
119
|
-
*/
|
|
120
|
-
getAttribute(key) {
|
|
121
|
-
return key === 'tags' ? [...this.#tags] : super.getAttribute(key);
|
|
122
|
-
}
|
|
123
75
|
}
|
|
124
76
|
|
|
125
|
-
Parser.classes.TagPairToken = __filename;
|
|
126
77
|
module.exports = TagPairToken;
|