wikiparser-node 1.18.2 → 1.18.4
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 +6 -1
- package/bundle/bundle-es7.min.js +29 -28
- package/bundle/bundle-lsp.min.js +31 -30
- package/bundle/bundle.min.js +30 -29
- package/config/minimum.json +7 -0
- package/dist/addon/token.js +37 -28
- package/dist/addon/transclude.js +1 -3
- package/dist/base.d.mts +4 -0
- package/dist/base.d.ts +4 -0
- package/dist/base.js +1 -0
- package/dist/base.mjs +2 -1
- package/dist/bin/config.js +3 -2
- package/dist/index.d.ts +14 -1
- package/dist/index.js +72 -72
- package/dist/lib/element.d.ts +6 -0
- package/dist/lib/element.js +543 -466
- package/dist/lib/lsp.d.ts +1 -0
- package/dist/lib/lsp.js +20 -15
- package/dist/lib/redirectMap.d.ts +7 -0
- package/dist/lib/redirectMap.js +31 -0
- package/dist/lib/text.d.ts +2 -2
- package/dist/lib/text.js +385 -325
- package/dist/lib/title.d.ts +23 -4
- package/dist/lib/title.js +17 -5
- package/dist/mixin/noEscape.d.ts +4 -0
- package/dist/mixin/noEscape.js +22 -0
- package/dist/mixin/readOnly.d.ts +4 -0
- package/dist/mixin/readOnly.js +26 -0
- package/dist/parser/braces.js +79 -37
- package/dist/parser/commentAndExt.js +5 -16
- package/dist/parser/links.js +1 -1
- package/dist/parser/quotes.js +1 -1
- package/dist/parser/redirect.js +1 -3
- package/dist/src/arg.js +253 -202
- package/dist/src/attribute.d.ts +0 -5
- package/dist/src/attribute.js +4 -8
- package/dist/src/converter.js +213 -162
- package/dist/src/gallery.js +1 -2
- package/dist/src/heading.js +5 -6
- package/dist/src/imageParameter.js +16 -16
- package/dist/src/imagemap.js +3 -2
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.js +722 -694
- package/dist/src/link/base.js +292 -241
- package/dist/src/link/file.js +13 -17
- package/dist/src/link/galleryImage.js +1 -1
- package/dist/src/link/redirectTarget.js +1 -2
- package/dist/src/magicLink.d.ts +0 -6
- package/dist/src/magicLink.js +5 -15
- package/dist/src/nested.js +7 -7
- package/dist/src/nowiki/base.js +2 -1
- package/dist/src/nowiki/index.js +4 -3
- package/dist/src/onlyinclude.js +95 -44
- package/dist/src/parameter.d.ts +0 -6
- package/dist/src/parameter.js +1 -13
- package/dist/src/redirect.js +6 -6
- package/dist/src/syntax.d.ts +4 -1
- package/dist/src/syntax.js +4 -1
- package/dist/src/table/base.d.ts +0 -5
- package/dist/src/table/base.js +2 -9
- package/dist/src/table/index.d.ts +1 -0
- package/dist/src/table/index.js +7 -4
- package/dist/src/table/td.d.ts +1 -0
- package/dist/src/table/td.js +2 -3
- package/dist/src/table/trBase.js +31 -14
- package/dist/src/tagPair/index.js +2 -1
- package/dist/src/transclude.js +713 -657
- package/dist/util/debug.js +10 -3
- package/dist/util/diff.js +1 -1
- package/dist/util/string.js +4 -5
- package/extensions/dist/base.js +8 -6
- package/extensions/dist/lint.js +1 -1
- package/extensions/es7/base.js +8 -6
- package/extensions/es7/lint.js +1 -1
- package/extensions/ui.css +1 -1
- package/package.json +3 -3
package/dist/src/arg.js
CHANGED
|
@@ -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
|
};
|
|
@@ -13,6 +47,7 @@ const hidden_1 = require("./hidden");
|
|
|
13
47
|
/* NOT FOR BROWSER */
|
|
14
48
|
const constants_1 = require("../util/constants");
|
|
15
49
|
const debug_1 = require("../util/debug");
|
|
50
|
+
const noEscape_1 = require("../mixin/noEscape");
|
|
16
51
|
const index_2 = __importDefault(require("../index"));
|
|
17
52
|
/* NOT FOR BROWSER END */
|
|
18
53
|
/**
|
|
@@ -21,218 +56,234 @@ const index_2 = __importDefault(require("../index"));
|
|
|
21
56
|
* `{{{}}}`包裹的参数
|
|
22
57
|
* @classdesc `{childNodes: [AtomToken, ?Token, ...HiddenToken[]]}`
|
|
23
58
|
*/
|
|
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
|
-
|
|
59
|
+
let ArgToken = (() => {
|
|
60
|
+
let _classDecorators = [noEscape_1.noEscape];
|
|
61
|
+
let _classDescriptor;
|
|
62
|
+
let _classExtraInitializers = [];
|
|
63
|
+
let _classThis;
|
|
64
|
+
let _classSuper = index_1.Token;
|
|
65
|
+
var ArgToken = class extends _classSuper {
|
|
66
|
+
static { _classThis = this; }
|
|
67
|
+
static {
|
|
68
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
69
|
+
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
70
|
+
ArgToken = _classThis = _classDescriptor.value;
|
|
71
|
+
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
72
|
+
__runInitializers(_classThis, _classExtraInitializers);
|
|
73
|
+
}
|
|
74
|
+
/* NOT FOR BROWSER END */
|
|
75
|
+
get type() {
|
|
76
|
+
return 'arg';
|
|
77
|
+
}
|
|
78
|
+
/** default value / 预设值 */
|
|
79
|
+
get default() {
|
|
80
|
+
return this.childNodes[1]?.text() ?? false;
|
|
81
|
+
}
|
|
82
|
+
/* NOT FOR BROWSER */
|
|
83
|
+
set default(value) {
|
|
84
|
+
this.setDefault(value);
|
|
85
|
+
}
|
|
86
|
+
/* NOT FOR BROWSER END */
|
|
87
|
+
/** @param parts 以'|'分隔的各部分 */
|
|
88
|
+
constructor(parts, config, accum = []) {
|
|
89
|
+
super(undefined, config, accum, {
|
|
90
|
+
AtomToken: 0, Token: 1, HiddenToken: '2:',
|
|
91
|
+
});
|
|
92
|
+
for (let i = 0; i < parts.length; i++) {
|
|
93
|
+
const part = parts[i];
|
|
94
|
+
if (i === 0) {
|
|
95
|
+
const token = new atom_1.AtomToken(part, 'arg-name', config, accum, {
|
|
96
|
+
'Stage-2': ':', '!HeadingToken': '',
|
|
97
|
+
});
|
|
98
|
+
super.insertAt(token);
|
|
99
|
+
}
|
|
100
|
+
else if (i > 1) {
|
|
101
|
+
const token = new hidden_1.HiddenToken(part, config, accum);
|
|
102
|
+
super.insertAt(token);
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
const token = new index_1.Token(part, config, accum);
|
|
106
|
+
token.type = 'arg-default';
|
|
107
|
+
token.setAttribute('stage', 2);
|
|
108
|
+
super.insertAt(token);
|
|
109
|
+
}
|
|
50
110
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
111
|
+
/* NOT FOR BROWSER */
|
|
112
|
+
this.protectChildren(0);
|
|
113
|
+
}
|
|
114
|
+
/** @private */
|
|
115
|
+
toString(skip) {
|
|
116
|
+
return `{{{${super.toString(skip, '|')}}}}`;
|
|
117
|
+
}
|
|
118
|
+
/** @private */
|
|
119
|
+
text() {
|
|
120
|
+
return `{{{${(0, string_1.text)(this.childNodes.slice(0, 2), '|')}}}}`;
|
|
121
|
+
}
|
|
122
|
+
/** @private */
|
|
123
|
+
getAttribute(key) {
|
|
124
|
+
return key === 'padding' ? 3 : super.getAttribute(key);
|
|
125
|
+
}
|
|
126
|
+
/** @private */
|
|
127
|
+
getGaps() {
|
|
128
|
+
return 1;
|
|
129
|
+
}
|
|
130
|
+
/** 设置name */
|
|
131
|
+
#setName() {
|
|
132
|
+
// eslint-disable-next-line no-unused-labels
|
|
133
|
+
LSP: this.setAttribute('name', this.firstChild.text().trim());
|
|
134
|
+
}
|
|
135
|
+
/** @private */
|
|
136
|
+
afterBuild() {
|
|
137
|
+
// eslint-disable-next-line no-unused-labels
|
|
138
|
+
LSP: this.#setName();
|
|
139
|
+
super.afterBuild();
|
|
140
|
+
/* NOT FOR BROWSER */
|
|
141
|
+
const /** @implements */ argListener = ({ prevTarget }) => {
|
|
142
|
+
if (prevTarget === this.firstChild) {
|
|
143
|
+
this.#setName();
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
this.addEventListener(['remove', 'insert', 'replace', 'text'], argListener);
|
|
147
|
+
}
|
|
148
|
+
/** @private */
|
|
149
|
+
lint(start = this.getAbsoluteIndex(), re) {
|
|
150
|
+
const { childNodes: [argName, argDefault, ...rest] } = this;
|
|
151
|
+
if (!this.getAttribute('include')) {
|
|
152
|
+
const e = (0, lint_1.generateForSelf)(this, { start }, 'no-arg', 'unexpected template argument');
|
|
153
|
+
if (argDefault) {
|
|
154
|
+
e.suggestions = [{ range: [start, e.endIndex], text: argDefault.text(), desc: 'expand' }];
|
|
155
|
+
}
|
|
156
|
+
return [e];
|
|
54
157
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
158
|
+
argName.setAttribute('aIndex', start + 3);
|
|
159
|
+
const errors = argName.lint(start + 3, re);
|
|
160
|
+
if (argDefault) {
|
|
161
|
+
const index = start + 4 + argName.toString().length;
|
|
162
|
+
argDefault.setAttribute('aIndex', index);
|
|
163
|
+
errors.push(...argDefault.lint(index, re));
|
|
164
|
+
}
|
|
165
|
+
if (rest.length > 0) {
|
|
166
|
+
const rect = new rect_1.BoundingRect(this, start);
|
|
167
|
+
errors.push(...rest.map(child => {
|
|
168
|
+
const e = (0, lint_1.generateForChild)(child, rect, 'no-ignored', 'invisible content inside triple braces');
|
|
169
|
+
e.startIndex--;
|
|
170
|
+
e.startCol--;
|
|
171
|
+
e.suggestions = [
|
|
172
|
+
{ desc: 'remove', range: [e.startIndex, e.endIndex], text: '' },
|
|
173
|
+
{ desc: 'escape', range: [e.startIndex, e.startIndex + 1], text: '{{!}}' },
|
|
174
|
+
];
|
|
175
|
+
return e;
|
|
176
|
+
}));
|
|
60
177
|
}
|
|
178
|
+
return errors;
|
|
179
|
+
}
|
|
180
|
+
/** @private */
|
|
181
|
+
print() {
|
|
182
|
+
return super.print({ pre: '{{{', post: '}}}', sep: '|' });
|
|
183
|
+
}
|
|
184
|
+
/** @private */
|
|
185
|
+
json(_, start = this.getAbsoluteIndex()) {
|
|
186
|
+
const json = super.json(undefined, start);
|
|
187
|
+
json['default'] = this.default;
|
|
188
|
+
return json;
|
|
61
189
|
}
|
|
62
190
|
/* NOT FOR BROWSER */
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
const /** @implements */ argListener = ({ prevTarget }) => {
|
|
93
|
-
if (prevTarget === this.firstChild) {
|
|
94
|
-
this.#setName();
|
|
191
|
+
cloneNode() {
|
|
192
|
+
const [name, ...cloned] = this.cloneChildNodes();
|
|
193
|
+
return debug_1.Shadow.run(() => {
|
|
194
|
+
// @ts-expect-error abstract class
|
|
195
|
+
const token = new ArgToken([''], this.getAttribute('config'));
|
|
196
|
+
token.firstChild.safeReplaceWith(name);
|
|
197
|
+
token.append(...cloned);
|
|
198
|
+
return token;
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Remove redundant parts
|
|
203
|
+
*
|
|
204
|
+
* 移除无效部分
|
|
205
|
+
*/
|
|
206
|
+
removeRedundant() {
|
|
207
|
+
debug_1.Shadow.run(() => {
|
|
208
|
+
for (let i = this.length - 1; i > 1; i--) {
|
|
209
|
+
super.removeAt(i);
|
|
210
|
+
}
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* @override
|
|
215
|
+
* @param i position of the child node / 移除位置
|
|
216
|
+
*/
|
|
217
|
+
removeAt(i) {
|
|
218
|
+
if (i === 1) {
|
|
219
|
+
this.removeRedundant();
|
|
95
220
|
}
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
221
|
+
return super.removeAt(i);
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* @override
|
|
225
|
+
* @param token node to be inserted / 待插入的子节点
|
|
226
|
+
* @param i position to be inserted at / 插入位置
|
|
227
|
+
*/
|
|
228
|
+
insertAt(token, i = this.length) {
|
|
229
|
+
i += i < 0 ? this.length : 0;
|
|
230
|
+
if (debug_1.Shadow.running) {
|
|
231
|
+
//
|
|
232
|
+
}
|
|
233
|
+
else if (i > 1) {
|
|
234
|
+
this.constructorError('cannot insert redundant child nodes');
|
|
235
|
+
}
|
|
236
|
+
else if (typeof token === 'string') {
|
|
237
|
+
this.constructorError('cannot insert text nodes');
|
|
238
|
+
}
|
|
239
|
+
super.insertAt(token, i);
|
|
240
|
+
if (i === 1) {
|
|
241
|
+
token.type = 'arg-default';
|
|
106
242
|
}
|
|
107
|
-
return [e];
|
|
108
|
-
}
|
|
109
|
-
argName.setAttribute('aIndex', start + 3);
|
|
110
|
-
const errors = argName.lint(start + 3, re);
|
|
111
|
-
if (argDefault) {
|
|
112
|
-
const index = start + 4 + argName.toString().length;
|
|
113
|
-
argDefault.setAttribute('aIndex', index);
|
|
114
|
-
errors.push(...argDefault.lint(index, re));
|
|
115
|
-
}
|
|
116
|
-
if (rest.length > 0) {
|
|
117
|
-
const rect = new rect_1.BoundingRect(this, start);
|
|
118
|
-
errors.push(...rest.map(child => {
|
|
119
|
-
const e = (0, lint_1.generateForChild)(child, rect, 'no-ignored', 'invisible content inside triple braces');
|
|
120
|
-
e.startIndex--;
|
|
121
|
-
e.startCol--;
|
|
122
|
-
e.suggestions = [
|
|
123
|
-
{ desc: 'remove', range: [e.startIndex, e.endIndex], text: '' },
|
|
124
|
-
{ desc: 'escape', range: [e.startIndex, e.startIndex + 1], text: '{{!}}' },
|
|
125
|
-
];
|
|
126
|
-
return e;
|
|
127
|
-
}));
|
|
128
|
-
}
|
|
129
|
-
return errors;
|
|
130
|
-
}
|
|
131
|
-
/** @private */
|
|
132
|
-
print() {
|
|
133
|
-
return super.print({ pre: '{{{', post: '}}}', sep: '|' });
|
|
134
|
-
}
|
|
135
|
-
/** @private */
|
|
136
|
-
json(_, start = this.getAbsoluteIndex()) {
|
|
137
|
-
const json = super.json(undefined, start);
|
|
138
|
-
json['default'] = this.default;
|
|
139
|
-
return json;
|
|
140
|
-
}
|
|
141
|
-
/* NOT FOR BROWSER */
|
|
142
|
-
cloneNode() {
|
|
143
|
-
const [name, ...cloned] = this.cloneChildNodes();
|
|
144
|
-
return debug_1.Shadow.run(() => {
|
|
145
|
-
// @ts-expect-error abstract class
|
|
146
|
-
const token = new ArgToken([''], this.getAttribute('config'));
|
|
147
|
-
token.firstChild.safeReplaceWith(name);
|
|
148
|
-
token.append(...cloned);
|
|
149
243
|
return token;
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* Set the argument name
|
|
247
|
+
*
|
|
248
|
+
* 设置参数名
|
|
249
|
+
* @param name new argument name / 新参数名
|
|
250
|
+
*/
|
|
251
|
+
setName(name) {
|
|
252
|
+
const { childNodes } = index_2.default
|
|
253
|
+
.parse(name, this.getAttribute('include'), 2, this.getAttribute('config'));
|
|
254
|
+
this.firstChild.replaceChildren(...childNodes);
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* Set the default value
|
|
258
|
+
*
|
|
259
|
+
* 设置预设值
|
|
260
|
+
* @param value default value / 预设值
|
|
261
|
+
*/
|
|
262
|
+
setDefault(value) {
|
|
263
|
+
if (value === false) {
|
|
264
|
+
this.removeAt(1);
|
|
265
|
+
return;
|
|
266
|
+
}
|
|
267
|
+
const root = index_2.default
|
|
268
|
+
.parse(value, this.getAttribute('include'), undefined, this.getAttribute('config')), { childNodes: [, oldDefault] } = this;
|
|
269
|
+
if (oldDefault) {
|
|
270
|
+
oldDefault.replaceChildren(...root.childNodes);
|
|
271
|
+
}
|
|
272
|
+
else {
|
|
273
|
+
root.type = 'arg-default';
|
|
274
|
+
this.insertAt(root);
|
|
161
275
|
}
|
|
162
|
-
});
|
|
163
|
-
}
|
|
164
|
-
/**
|
|
165
|
-
* @override
|
|
166
|
-
* @param i position of the child node / 移除位置
|
|
167
|
-
*/
|
|
168
|
-
removeAt(i) {
|
|
169
|
-
if (i === 1) {
|
|
170
|
-
this.removeRedundant();
|
|
171
|
-
}
|
|
172
|
-
return super.removeAt(i);
|
|
173
|
-
}
|
|
174
|
-
/**
|
|
175
|
-
* @override
|
|
176
|
-
* @param token node to be inserted / 待插入的子节点
|
|
177
|
-
* @param i position to be inserted at / 插入位置
|
|
178
|
-
*/
|
|
179
|
-
insertAt(token, i = this.length) {
|
|
180
|
-
i += i < 0 ? this.length : 0;
|
|
181
|
-
if (debug_1.Shadow.running) {
|
|
182
|
-
//
|
|
183
|
-
}
|
|
184
|
-
else if (i > 1) {
|
|
185
|
-
this.constructorError('cannot insert redundant child nodes');
|
|
186
|
-
}
|
|
187
|
-
else if (typeof token === 'string') {
|
|
188
|
-
this.constructorError('cannot insert text nodes');
|
|
189
|
-
}
|
|
190
|
-
super.insertAt(token, i);
|
|
191
|
-
if (i === 1) {
|
|
192
|
-
token.type = 'arg-default';
|
|
193
|
-
}
|
|
194
|
-
return token;
|
|
195
|
-
}
|
|
196
|
-
/**
|
|
197
|
-
* Set the argument name
|
|
198
|
-
*
|
|
199
|
-
* 设置参数名
|
|
200
|
-
* @param name new argument name / 新参数名
|
|
201
|
-
*/
|
|
202
|
-
setName(name) {
|
|
203
|
-
const { childNodes } = index_2.default
|
|
204
|
-
.parse(name, this.getAttribute('include'), 2, this.getAttribute('config'));
|
|
205
|
-
this.firstChild.replaceChildren(...childNodes);
|
|
206
|
-
}
|
|
207
|
-
/**
|
|
208
|
-
* Set the default value
|
|
209
|
-
*
|
|
210
|
-
* 设置预设值
|
|
211
|
-
* @param value default value / 预设值
|
|
212
|
-
*/
|
|
213
|
-
setDefault(value) {
|
|
214
|
-
if (value === false) {
|
|
215
|
-
this.removeAt(1);
|
|
216
|
-
return;
|
|
217
|
-
}
|
|
218
|
-
const root = index_2.default
|
|
219
|
-
.parse(value, this.getAttribute('include'), undefined, this.getAttribute('config')), { childNodes: [, oldDefault] } = this;
|
|
220
|
-
if (oldDefault) {
|
|
221
|
-
oldDefault.replaceChildren(...root.childNodes);
|
|
222
|
-
}
|
|
223
|
-
else {
|
|
224
|
-
root.type = 'arg-default';
|
|
225
|
-
this.insertAt(root);
|
|
226
276
|
}
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
277
|
+
/** @private */
|
|
278
|
+
toHtmlInternal(opt) {
|
|
279
|
+
if (this.length === 1) {
|
|
280
|
+
const html = this.toString();
|
|
281
|
+
return opt?.nowrap ? html.replaceAll('\n', ' ') : html;
|
|
282
|
+
}
|
|
283
|
+
return this.childNodes[1].toHtmlInternal(opt);
|
|
233
284
|
}
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
}
|
|
285
|
+
};
|
|
286
|
+
return ArgToken = _classThis;
|
|
287
|
+
})();
|
|
237
288
|
exports.ArgToken = ArgToken;
|
|
238
289
|
constants_1.classes['ArgToken'] = __filename;
|
package/dist/src/attribute.d.ts
CHANGED
package/dist/src/attribute.js
CHANGED
|
@@ -163,7 +163,7 @@ let AttributeToken = (() => {
|
|
|
163
163
|
if (this.parentNode) {
|
|
164
164
|
this.#tag = this.parentNode.name;
|
|
165
165
|
}
|
|
166
|
-
this.setAttribute('name', this.firstChild.
|
|
166
|
+
this.setAttribute('name', this.firstChild.text().trim().toLowerCase());
|
|
167
167
|
super.afterBuild();
|
|
168
168
|
}
|
|
169
169
|
/** @private */
|
|
@@ -253,13 +253,9 @@ let AttributeToken = (() => {
|
|
|
253
253
|
return token;
|
|
254
254
|
});
|
|
255
255
|
}
|
|
256
|
-
/**
|
|
257
|
-
* Escape `=`
|
|
258
|
-
*
|
|
259
|
-
* 转义等号
|
|
260
|
-
*/
|
|
261
256
|
escape() {
|
|
262
257
|
this.#equal = '{{=}}';
|
|
258
|
+
this.lastChild.escape();
|
|
263
259
|
}
|
|
264
260
|
/**
|
|
265
261
|
* Close the quote
|
|
@@ -382,9 +378,9 @@ let AttributeToken = (() => {
|
|
|
382
378
|
return undefined;
|
|
383
379
|
}
|
|
384
380
|
const hasQuote = value.includes('"');
|
|
385
|
-
if (this.#quotes[0] && value.includes(this.#quotes[0]) || hasQuote && value.includes(
|
|
381
|
+
if (this.#quotes[0] && value.includes(this.#quotes[0]) || hasQuote && value.includes(`'`)) {
|
|
386
382
|
const quote = this.#quotes[0] || '"';
|
|
387
|
-
throw new RangeError(`Please consider replacing \`${quote}\` with \`${quote === '"' ?
|
|
383
|
+
throw new RangeError(`Please consider replacing \`${quote}\` with \`${quote === '"' ? `'` : '"'}\`!`);
|
|
388
384
|
}
|
|
389
385
|
else if (declaration.length > 0) {
|
|
390
386
|
const { value: { offset, length } } = declaration.at(-1);
|