wikiparser-node 1.13.0-b → 1.13.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/.schema.json +203 -0
- package/config/default.json +32 -31
- package/config/enwiki.json +829 -15
- package/config/llwiki.json +56 -21
- package/config/moegirl.json +65 -21
- package/config/zhwiki.json +498 -32
- package/dist/addon/table.js +494 -0
- package/dist/addon/token.js +392 -0
- package/dist/addon/transclude.js +184 -0
- package/dist/base.d.ts +109 -0
- package/dist/base.js +67 -0
- package/dist/index.d.ts +33 -0
- package/dist/index.js +279 -0
- package/dist/internal.d.ts +47 -0
- package/dist/lib/element.d.ts +125 -0
- package/dist/lib/element.js +364 -0
- package/dist/lib/node.d.ts +173 -0
- package/dist/lib/node.js +478 -0
- package/dist/lib/range.d.ts +105 -0
- package/dist/lib/range.js +406 -0
- package/dist/lib/ranges.d.ts +28 -0
- package/dist/lib/ranges.js +126 -0
- package/dist/lib/rect.d.ts +18 -0
- package/dist/lib/rect.js +36 -0
- package/dist/lib/text.d.ts +58 -0
- package/dist/lib/text.js +414 -0
- package/dist/lib/title.d.ts +49 -0
- package/dist/lib/title.js +251 -0
- package/dist/mixin/attributesParent.d.ts +49 -0
- package/dist/mixin/attributesParent.js +80 -0
- package/dist/mixin/fixed.d.ts +5 -0
- package/dist/mixin/fixed.js +32 -0
- package/dist/mixin/flagsParent.d.ts +43 -0
- package/dist/mixin/flagsParent.js +64 -0
- package/dist/mixin/hidden.d.ts +7 -0
- package/dist/mixin/hidden.js +39 -0
- package/dist/mixin/magicLinkParent.d.ts +19 -0
- package/dist/mixin/magicLinkParent.js +43 -0
- package/dist/mixin/singleLine.d.ts +5 -0
- package/dist/mixin/singleLine.js +25 -0
- package/dist/mixin/sol.d.ts +6 -0
- package/dist/mixin/sol.js +45 -0
- package/dist/mixin/syntax.d.ts +8 -0
- package/dist/mixin/syntax.js +46 -0
- package/dist/parser/braces.js +152 -0
- package/dist/parser/commentAndExt.js +84 -0
- package/dist/parser/converter.js +41 -0
- package/dist/parser/externalLinks.js +39 -0
- package/dist/parser/hrAndDoubleUnderscore.js +44 -0
- package/dist/parser/html.js +40 -0
- package/dist/parser/links.js +103 -0
- package/dist/parser/list.js +116 -0
- package/dist/parser/magicLinks.js +55 -0
- package/dist/parser/quotes.js +69 -0
- package/dist/parser/redirect.js +28 -0
- package/dist/parser/selector.js +443 -0
- package/dist/parser/table.js +125 -0
- package/dist/src/arg.d.ts +49 -0
- package/dist/src/arg.js +220 -0
- package/dist/src/atom.d.ts +14 -0
- package/dist/src/atom.js +54 -0
- package/dist/src/attribute.d.ts +64 -0
- package/dist/src/attribute.js +482 -0
- package/dist/src/attributes.d.ts +103 -0
- package/dist/src/attributes.js +383 -0
- package/dist/src/converter.d.ts +28 -0
- package/dist/src/converter.js +153 -0
- package/dist/src/converterFlags.d.ts +80 -0
- package/dist/src/converterFlags.js +241 -0
- package/dist/src/converterRule.d.ts +71 -0
- package/dist/src/converterRule.js +218 -0
- package/dist/src/extLink.d.ts +36 -0
- package/dist/src/extLink.js +223 -0
- package/dist/src/gallery.d.ts +51 -0
- package/dist/src/gallery.js +166 -0
- package/dist/src/heading.d.ts +44 -0
- package/dist/src/heading.js +222 -0
- package/dist/src/hidden.d.ts +9 -0
- package/dist/src/hidden.js +82 -0
- package/dist/src/html.d.ts +61 -0
- package/dist/src/html.js +344 -0
- package/dist/src/imageParameter.d.ts +60 -0
- package/dist/src/imageParameter.js +262 -0
- package/dist/src/imagemap.d.ts +47 -0
- package/dist/src/imagemap.js +148 -0
- package/dist/src/imagemapLink.d.ts +35 -0
- package/dist/src/imagemapLink.js +99 -0
- package/dist/src/index.d.ts +136 -0
- package/dist/src/index.js +790 -0
- package/dist/src/link/base.d.ts +52 -0
- package/dist/src/link/base.js +258 -0
- package/dist/src/link/category.d.ts +22 -0
- package/dist/src/link/category.js +36 -0
- package/dist/src/link/file.d.ts +102 -0
- package/dist/src/link/file.js +345 -0
- package/dist/src/link/galleryImage.d.ts +29 -0
- package/dist/src/link/galleryImage.js +133 -0
- package/dist/src/link/index.d.ts +39 -0
- package/dist/src/link/index.js +100 -0
- package/dist/src/link/redirectTarget.d.ts +27 -0
- package/dist/src/link/redirectTarget.js +71 -0
- package/dist/src/magicLink.d.ts +57 -0
- package/dist/src/magicLink.js +261 -0
- package/dist/src/nested.d.ts +40 -0
- package/dist/src/nested.js +108 -0
- package/dist/src/nowiki/base.d.ts +28 -0
- package/dist/src/nowiki/base.js +90 -0
- package/dist/src/nowiki/comment.d.ts +14 -0
- package/dist/src/nowiki/comment.js +123 -0
- package/dist/src/nowiki/dd.d.ts +8 -0
- package/dist/src/nowiki/dd.js +74 -0
- package/dist/src/nowiki/doubleUnderscore.d.ts +15 -0
- package/dist/src/nowiki/doubleUnderscore.js +101 -0
- package/dist/src/nowiki/hr.d.ts +5 -0
- package/dist/src/nowiki/hr.js +72 -0
- package/dist/src/nowiki/index.d.ts +14 -0
- package/dist/src/nowiki/index.js +30 -0
- package/dist/src/nowiki/list.d.ts +5 -0
- package/dist/src/nowiki/list.js +67 -0
- package/dist/src/nowiki/listBase.d.ts +23 -0
- package/dist/src/nowiki/listBase.js +100 -0
- package/dist/src/nowiki/noinclude.d.ts +6 -0
- package/dist/src/nowiki/noinclude.js +77 -0
- package/dist/src/nowiki/quote.d.ts +14 -0
- package/dist/src/nowiki/quote.js +149 -0
- package/dist/src/onlyinclude.d.ts +13 -0
- package/dist/src/onlyinclude.js +60 -0
- package/dist/src/paramTag/index.d.ts +28 -0
- package/dist/src/paramTag/index.js +80 -0
- package/dist/src/paramTag/inputbox.d.ts +8 -0
- package/dist/src/paramTag/inputbox.js +24 -0
- package/dist/src/parameter.d.ts +60 -0
- package/dist/src/parameter.js +267 -0
- package/dist/src/pre.d.ts +28 -0
- package/dist/src/pre.js +62 -0
- package/dist/src/redirect.d.ts +30 -0
- package/dist/src/redirect.js +128 -0
- package/dist/src/syntax.d.ts +15 -0
- package/dist/src/syntax.js +87 -0
- package/dist/src/table/base.d.ts +28 -0
- package/dist/src/table/base.js +81 -0
- package/dist/src/table/index.d.ts +230 -0
- package/dist/src/table/index.js +506 -0
- package/dist/src/table/td.d.ts +72 -0
- package/dist/src/table/td.js +375 -0
- package/dist/src/table/tr.d.ts +30 -0
- package/dist/src/table/tr.js +61 -0
- package/dist/src/table/trBase.d.ts +49 -0
- package/dist/src/table/trBase.js +165 -0
- package/dist/src/tagPair/ext.d.ts +29 -0
- package/dist/src/tagPair/ext.js +229 -0
- package/dist/src/tagPair/include.d.ts +33 -0
- package/dist/src/tagPair/include.js +132 -0
- package/dist/src/tagPair/index.d.ts +23 -0
- package/dist/src/tagPair/index.js +130 -0
- package/dist/src/transclude.d.ts +159 -0
- package/dist/src/transclude.js +598 -0
- package/dist/util/constants.js +26 -0
- package/dist/util/debug.js +95 -0
- package/dist/util/diff.js +83 -0
- package/dist/util/html.js +146 -0
- package/dist/util/lint.js +32 -0
- package/dist/util/string.js +107 -0
- package/errors/README +3 -0
- package/package.json +21 -28
- package/printed/README +3 -0
- package/bundle/bundle.min.js +0 -37
- package/extensions/dist/base.js +0 -163
- package/extensions/dist/codejar.js +0 -53
- package/extensions/dist/editor.js +0 -159
- package/extensions/dist/highlight.js +0 -30
- package/extensions/dist/lint.js +0 -72
- package/extensions/editor.css +0 -59
- package/extensions/ui.css +0 -162
package/dist/src/arg.js
ADDED
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ArgToken = void 0;
|
|
4
|
+
const string_1 = require("../util/string");
|
|
5
|
+
const lint_1 = require("../util/lint");
|
|
6
|
+
const rect_1 = require("../lib/rect");
|
|
7
|
+
const index_1 = require("../index");
|
|
8
|
+
const index_2 = require("./index");
|
|
9
|
+
const atom_1 = require("./atom");
|
|
10
|
+
const hidden_1 = require("./hidden");
|
|
11
|
+
/* NOT FOR BROWSER */
|
|
12
|
+
const constants_1 = require("../util/constants");
|
|
13
|
+
const debug_1 = require("../util/debug");
|
|
14
|
+
const html_1 = require("../util/html");
|
|
15
|
+
/* NOT FOR BROWSER END */
|
|
16
|
+
/**
|
|
17
|
+
* `{{{}}}`包裹的参数
|
|
18
|
+
* @classdesc `{childNodes: [AtomToken, ?Token, ...HiddenToken]}`
|
|
19
|
+
*/
|
|
20
|
+
class ArgToken extends index_2.Token {
|
|
21
|
+
/* NOT FOR BROWSER END */
|
|
22
|
+
get type() {
|
|
23
|
+
return 'arg';
|
|
24
|
+
}
|
|
25
|
+
/** 预设值 */
|
|
26
|
+
get default() {
|
|
27
|
+
return this.childNodes[1]?.text() ?? false;
|
|
28
|
+
}
|
|
29
|
+
/* NOT FOR BROWSER */
|
|
30
|
+
set default(value) {
|
|
31
|
+
this.setDefault(value);
|
|
32
|
+
}
|
|
33
|
+
/* NOT FOR BROWSER END */
|
|
34
|
+
/** @param parts 以'|'分隔的各部分 */
|
|
35
|
+
constructor(parts, config = index_1.default.getConfig(), accum = []) {
|
|
36
|
+
super(undefined, config, accum, {
|
|
37
|
+
AtomToken: 0, Token: 1, HiddenToken: '2:',
|
|
38
|
+
});
|
|
39
|
+
for (const [i, part] of parts.entries()) {
|
|
40
|
+
if (i === 0) {
|
|
41
|
+
const token = new atom_1.AtomToken(part, 'arg-name', config, accum, {
|
|
42
|
+
'Stage-2': ':', '!HeadingToken': '',
|
|
43
|
+
});
|
|
44
|
+
super.insertAt(token);
|
|
45
|
+
}
|
|
46
|
+
else if (i > 1) {
|
|
47
|
+
const token = new hidden_1.HiddenToken(part, config, accum);
|
|
48
|
+
super.insertAt(token);
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
const token = new index_2.Token(part, config, accum);
|
|
52
|
+
token.type = 'arg-default';
|
|
53
|
+
token.setAttribute('stage', 2);
|
|
54
|
+
super.insertAt(token);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
/* NOT FOR BROWSER */
|
|
58
|
+
this.protectChildren(0);
|
|
59
|
+
}
|
|
60
|
+
/** @private */
|
|
61
|
+
toString(skip) {
|
|
62
|
+
return `{{{${super.toString(skip, '|')}}}}`;
|
|
63
|
+
}
|
|
64
|
+
/** @private */
|
|
65
|
+
text() {
|
|
66
|
+
return `{{{${(0, string_1.text)(this.childNodes.slice(0, 2), '|')}}}}`;
|
|
67
|
+
}
|
|
68
|
+
/** @private */
|
|
69
|
+
getAttribute(key) {
|
|
70
|
+
return key === 'padding' ? 3 : super.getAttribute(key);
|
|
71
|
+
}
|
|
72
|
+
/** @private */
|
|
73
|
+
getGaps() {
|
|
74
|
+
return 1;
|
|
75
|
+
}
|
|
76
|
+
/** 设置name */
|
|
77
|
+
#setName() {
|
|
78
|
+
this.setAttribute('name', this.firstChild.toString(true).trim());
|
|
79
|
+
}
|
|
80
|
+
/** @private */
|
|
81
|
+
afterBuild() {
|
|
82
|
+
this.#setName();
|
|
83
|
+
super.afterBuild();
|
|
84
|
+
/* NOT FOR BROWSER */
|
|
85
|
+
const /** @implements */ argListener = ({ prevTarget }) => {
|
|
86
|
+
if (prevTarget === this.firstChild) {
|
|
87
|
+
this.#setName();
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
this.addEventListener(['remove', 'insert', 'replace', 'text'], argListener);
|
|
91
|
+
}
|
|
92
|
+
/** @private */
|
|
93
|
+
lint(start = this.getAbsoluteIndex(), re) {
|
|
94
|
+
const { childNodes: [argName, argDefault, ...rest] } = this;
|
|
95
|
+
if (!this.getAttribute('include')) {
|
|
96
|
+
const e = (0, lint_1.generateForSelf)(this, { start }, 'no-arg', 'unexpected template argument');
|
|
97
|
+
if (argDefault) {
|
|
98
|
+
e.fix = { range: [start, e.endIndex], text: argDefault.text() };
|
|
99
|
+
}
|
|
100
|
+
return [e];
|
|
101
|
+
}
|
|
102
|
+
const errors = argName.lint(start + 3, re);
|
|
103
|
+
if (argDefault) {
|
|
104
|
+
errors.push(...argDefault.lint(start + 4 + argName.toString().length, re));
|
|
105
|
+
}
|
|
106
|
+
if (rest.length > 0) {
|
|
107
|
+
const rect = new rect_1.BoundingRect(this, start);
|
|
108
|
+
errors.push(...rest.map(child => {
|
|
109
|
+
const e = (0, lint_1.generateForChild)(child, rect, 'no-ignored', 'invisible content inside triple braces');
|
|
110
|
+
e.startIndex--;
|
|
111
|
+
e.startCol--;
|
|
112
|
+
e.suggestions = [
|
|
113
|
+
{
|
|
114
|
+
desc: 'remove',
|
|
115
|
+
range: [e.startIndex, e.endIndex],
|
|
116
|
+
text: '',
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
desc: 'escape',
|
|
120
|
+
range: [e.startIndex, e.startIndex + 1],
|
|
121
|
+
text: '{{!}}',
|
|
122
|
+
},
|
|
123
|
+
];
|
|
124
|
+
return e;
|
|
125
|
+
}));
|
|
126
|
+
}
|
|
127
|
+
return errors;
|
|
128
|
+
}
|
|
129
|
+
/** @private */
|
|
130
|
+
print() {
|
|
131
|
+
return super.print({ pre: '{{{', post: '}}}', sep: '|' });
|
|
132
|
+
}
|
|
133
|
+
/* NOT FOR BROWSER */
|
|
134
|
+
cloneNode() {
|
|
135
|
+
const [name, ...cloned] = this.cloneChildNodes();
|
|
136
|
+
return debug_1.Shadow.run(() => {
|
|
137
|
+
// @ts-expect-error abstract class
|
|
138
|
+
const token = new ArgToken([''], this.getAttribute('config'));
|
|
139
|
+
token.firstChild.safeReplaceWith(name);
|
|
140
|
+
token.append(...cloned);
|
|
141
|
+
return token;
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
/** 移除无效部分 */
|
|
145
|
+
removeRedundant() {
|
|
146
|
+
debug_1.Shadow.run(() => {
|
|
147
|
+
for (let i = this.length - 1; i > 1; i--) {
|
|
148
|
+
super.removeAt(i);
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* @override
|
|
154
|
+
* @param i 移除位置
|
|
155
|
+
*/
|
|
156
|
+
removeAt(i) {
|
|
157
|
+
if (i === 1) {
|
|
158
|
+
this.removeRedundant();
|
|
159
|
+
}
|
|
160
|
+
return super.removeAt(i);
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* @override
|
|
164
|
+
* @param token 待插入的子节点
|
|
165
|
+
* @param i 插入位置
|
|
166
|
+
*/
|
|
167
|
+
insertAt(token, i = this.length) {
|
|
168
|
+
i += i < 0 ? this.length : 0;
|
|
169
|
+
if (debug_1.Shadow.running) {
|
|
170
|
+
//
|
|
171
|
+
}
|
|
172
|
+
else if (i > 1) {
|
|
173
|
+
this.constructorError('cannot insert redundant child nodes');
|
|
174
|
+
}
|
|
175
|
+
else if (typeof token === 'string') {
|
|
176
|
+
this.constructorError('cannot insert text nodes');
|
|
177
|
+
}
|
|
178
|
+
super.insertAt(token, i);
|
|
179
|
+
if (i === 1) {
|
|
180
|
+
token.type = 'arg-default';
|
|
181
|
+
}
|
|
182
|
+
return token;
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* 设置参数名
|
|
186
|
+
* @param name 新参数名
|
|
187
|
+
*/
|
|
188
|
+
setName(name) {
|
|
189
|
+
const { childNodes } = index_1.default.parse(name, this.getAttribute('include'), 2, this.getAttribute('config'));
|
|
190
|
+
this.firstChild.replaceChildren(...childNodes);
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* 设置预设值
|
|
194
|
+
* @param value 预设值
|
|
195
|
+
*/
|
|
196
|
+
setDefault(value) {
|
|
197
|
+
if (value === false) {
|
|
198
|
+
this.removeAt(1);
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
201
|
+
const root = index_1.default.parse(value, this.getAttribute('include'), undefined, this.getAttribute('config')), { childNodes: [, oldDefault] } = this;
|
|
202
|
+
if (oldDefault) {
|
|
203
|
+
oldDefault.replaceChildren(...root.childNodes);
|
|
204
|
+
}
|
|
205
|
+
else {
|
|
206
|
+
root.type = 'arg-default';
|
|
207
|
+
this.insertAt(root);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
/** @private */
|
|
211
|
+
toHtmlInternal(nowrap, nocc) {
|
|
212
|
+
if (this.length === 1) {
|
|
213
|
+
const html = (0, html_1.font)(this, this.toString());
|
|
214
|
+
return nowrap ? html.replaceAll('\n', ' ') : html;
|
|
215
|
+
}
|
|
216
|
+
return (0, html_1.font)(this, this.childNodes[1].toHtmlInternal(nowrap, nocc));
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
exports.ArgToken = ArgToken;
|
|
220
|
+
constants_1.classes['ArgToken'] = __filename;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Token } from './index';
|
|
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", "param-line"];
|
|
4
|
+
declare type AtomTypes = typeof atomTypes[number];
|
|
5
|
+
/** 不会被继续解析的plain Token */
|
|
6
|
+
export declare class AtomToken extends Token {
|
|
7
|
+
#private;
|
|
8
|
+
get type(): AtomTypes;
|
|
9
|
+
set type(value: AtomTypes);
|
|
10
|
+
/** @class */
|
|
11
|
+
constructor(wikitext: string | undefined, type: AtomTypes, config?: Config, accum?: Token[], acceptable?: Acceptable);
|
|
12
|
+
cloneNode(): this;
|
|
13
|
+
}
|
|
14
|
+
export {};
|
package/dist/src/atom.js
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AtomToken = void 0;
|
|
4
|
+
const index_1 = require("./index");
|
|
5
|
+
/* NOT FOR BROWSER */
|
|
6
|
+
const debug_1 = require("../util/debug");
|
|
7
|
+
const constants_1 = require("../util/constants");
|
|
8
|
+
/* NOT FOR BROWSER END */
|
|
9
|
+
const atomTypes = [
|
|
10
|
+
'arg-name',
|
|
11
|
+
'attr-key',
|
|
12
|
+
'attr-value',
|
|
13
|
+
'ext-attr-dirty',
|
|
14
|
+
'html-attr-dirty',
|
|
15
|
+
'table-attr-dirty',
|
|
16
|
+
'converter-flag',
|
|
17
|
+
'converter-rule-variant',
|
|
18
|
+
'converter-rule-to',
|
|
19
|
+
'converter-rule-from',
|
|
20
|
+
'invoke-function',
|
|
21
|
+
'invoke-module',
|
|
22
|
+
'template-name',
|
|
23
|
+
'link-target',
|
|
24
|
+
'param-line',
|
|
25
|
+
];
|
|
26
|
+
/** 不会被继续解析的plain Token */
|
|
27
|
+
class AtomToken extends index_1.Token {
|
|
28
|
+
#type;
|
|
29
|
+
get type() {
|
|
30
|
+
return this.#type;
|
|
31
|
+
}
|
|
32
|
+
set type(value) {
|
|
33
|
+
if (!atomTypes.includes(value)) {
|
|
34
|
+
throw new RangeError(`"${value}" is not a valid type for AtomToken!`);
|
|
35
|
+
}
|
|
36
|
+
this.#type = value;
|
|
37
|
+
}
|
|
38
|
+
/** @class */
|
|
39
|
+
constructor(wikitext, type, config, accum, acceptable) {
|
|
40
|
+
super(wikitext, config, accum, acceptable);
|
|
41
|
+
this.#type = type;
|
|
42
|
+
}
|
|
43
|
+
/* NOT FOR BROWSER */
|
|
44
|
+
cloneNode() {
|
|
45
|
+
const cloned = this.cloneChildNodes(), config = this.getAttribute('config'), acceptable = this.getAcceptable();
|
|
46
|
+
return debug_1.Shadow.run(() => {
|
|
47
|
+
const token = new AtomToken(undefined, this.type, config, [], acceptable);
|
|
48
|
+
token.append(...cloned);
|
|
49
|
+
return token;
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
exports.AtomToken = AtomToken;
|
|
54
|
+
constants_1.classes['AtomToken'] = __filename;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import Parser from '../index';
|
|
2
|
+
import { Token } from './index';
|
|
3
|
+
import { AtomToken } from './atom';
|
|
4
|
+
import type { LintError } from '../base';
|
|
5
|
+
import type { AttributesToken } from '../internal';
|
|
6
|
+
export type AttributeTypes = 'ext-attr' | 'html-attr' | 'table-attr';
|
|
7
|
+
/**
|
|
8
|
+
* 扩展和HTML标签属性
|
|
9
|
+
* @classdesc `{childNodes: [AtomToken, Token|AtomToken]}`
|
|
10
|
+
*/
|
|
11
|
+
export declare abstract class AttributeToken extends Token {
|
|
12
|
+
#private;
|
|
13
|
+
readonly name: string;
|
|
14
|
+
readonly childNodes: readonly [AtomToken, Token];
|
|
15
|
+
abstract get firstChild(): AtomToken;
|
|
16
|
+
abstract get lastChild(): Token;
|
|
17
|
+
abstract get parentNode(): AttributesToken | undefined;
|
|
18
|
+
abstract get nextSibling(): AtomToken | this | undefined;
|
|
19
|
+
abstract get previousSibling(): AtomToken | this | undefined;
|
|
20
|
+
abstract get children(): [AtomToken, Token];
|
|
21
|
+
abstract get firstElementChild(): AtomToken;
|
|
22
|
+
abstract get lastElementChild(): Token;
|
|
23
|
+
abstract get parentElement(): AttributesToken | undefined;
|
|
24
|
+
abstract get nextElementSibling(): AtomToken | this | undefined;
|
|
25
|
+
abstract get previousElementSibling(): AtomToken | this | undefined;
|
|
26
|
+
get type(): AttributeTypes;
|
|
27
|
+
/** 标签名 */
|
|
28
|
+
get tag(): string;
|
|
29
|
+
/** 引号是否匹配 */
|
|
30
|
+
get balanced(): boolean;
|
|
31
|
+
set balanced(value: boolean);
|
|
32
|
+
/** getValue()的getter */
|
|
33
|
+
get value(): string | true;
|
|
34
|
+
set value(value: string | true);
|
|
35
|
+
/**
|
|
36
|
+
* @param type 标签类型
|
|
37
|
+
* @param tag 标签名
|
|
38
|
+
* @param key 属性名
|
|
39
|
+
* @param equal 等号
|
|
40
|
+
* @param value 属性值
|
|
41
|
+
* @param quotes 引号
|
|
42
|
+
*/
|
|
43
|
+
constructor(type: AttributeTypes, tag: string, key: string, equal?: string, value?: string, quotes?: readonly [string?, string?], config?: Parser.Config, accum?: Token[]);
|
|
44
|
+
/** 获取属性值 */
|
|
45
|
+
getValue(): string | true;
|
|
46
|
+
cloneNode(): this;
|
|
47
|
+
/** 转义等号 */
|
|
48
|
+
escape(): void;
|
|
49
|
+
/** 闭合引号 */
|
|
50
|
+
close(): void;
|
|
51
|
+
/**
|
|
52
|
+
* 设置属性值
|
|
53
|
+
* @param value 参数值
|
|
54
|
+
* @throws `RangeError` 扩展标签属性不能包含 ">"
|
|
55
|
+
* @throws `RangeError` 同时包含单引号和双引号
|
|
56
|
+
*/
|
|
57
|
+
setValue(value: string | boolean): void;
|
|
58
|
+
/**
|
|
59
|
+
* 修改属性名
|
|
60
|
+
* @param key 新属性名
|
|
61
|
+
* @throws `Error` title和alt属性不能更名
|
|
62
|
+
*/
|
|
63
|
+
rename(key: string): void;
|
|
64
|
+
}
|