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/converter.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
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
37
|
exports.ConverterToken = void 0;
|
|
4
38
|
const string_1 = require("../util/string");
|
|
@@ -9,6 +43,7 @@ const converterRule_1 = require("./converterRule");
|
|
|
9
43
|
const html_1 = require("../util/html");
|
|
10
44
|
const debug_1 = require("../util/debug");
|
|
11
45
|
const constants_1 = require("../util/constants");
|
|
46
|
+
const noEscape_1 = require("../mixin/noEscape");
|
|
12
47
|
/* NOT FOR BROWSER END */
|
|
13
48
|
/**
|
|
14
49
|
* language conversion
|
|
@@ -16,173 +51,189 @@ const constants_1 = require("../util/constants");
|
|
|
16
51
|
* 转换
|
|
17
52
|
* @classdesc `{childNodes: [ConverterFlagsToken, ...ConverterRuleToken[]]}`
|
|
18
53
|
*/
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
set flags(value) {
|
|
34
|
-
this.firstChild.flags = value;
|
|
35
|
-
}
|
|
36
|
-
/* NOT FOR BROWSER END */
|
|
37
|
-
/**
|
|
38
|
-
* @param flags 转换类型标记
|
|
39
|
-
* @param rules 转换规则
|
|
40
|
-
*/
|
|
41
|
-
constructor(flags, rules, config, accum = []) {
|
|
42
|
-
super(undefined, config, accum);
|
|
43
|
-
// @ts-expect-error abstract class
|
|
44
|
-
this.append(new converterFlags_1.ConverterFlagsToken(flags, config, accum));
|
|
45
|
-
const [firstRule] = rules, hasColon = firstRule.includes(':'),
|
|
46
|
-
// @ts-expect-error abstract class
|
|
47
|
-
firstRuleToken = new converterRule_1.ConverterRuleToken(firstRule, hasColon, config, accum);
|
|
48
|
-
if (hasColon && firstRuleToken.length === 1
|
|
49
|
-
|| !hasColon && rules.length === 2 && !(0, string_1.removeComment)(rules[1]).trim()) {
|
|
50
|
-
this.insertAt(
|
|
51
|
-
// @ts-expect-error abstract class
|
|
52
|
-
new converterRule_1.ConverterRuleToken(rules.join(';'), false, config, accum));
|
|
54
|
+
let ConverterToken = (() => {
|
|
55
|
+
let _classDecorators = [noEscape_1.noEscape];
|
|
56
|
+
let _classDescriptor;
|
|
57
|
+
let _classExtraInitializers = [];
|
|
58
|
+
let _classThis;
|
|
59
|
+
let _classSuper = index_1.Token;
|
|
60
|
+
var ConverterToken = class extends _classSuper {
|
|
61
|
+
static { _classThis = this; }
|
|
62
|
+
static {
|
|
63
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
64
|
+
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
65
|
+
ConverterToken = _classThis = _classDescriptor.value;
|
|
66
|
+
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
67
|
+
__runInitializers(_classThis, _classExtraInitializers);
|
|
53
68
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
.map(rule => new converterRule_1.ConverterRuleToken(rule, true, config, accum)));
|
|
69
|
+
/* NOT FOR BROWSER END */
|
|
70
|
+
get type() {
|
|
71
|
+
return 'converter';
|
|
58
72
|
}
|
|
59
73
|
/* NOT FOR BROWSER */
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
return i || this.firstChild.length > 0 ? 1 : 0;
|
|
79
|
-
}
|
|
80
|
-
/** @private */
|
|
81
|
-
print() {
|
|
82
|
-
const { childNodes: [flags, ...rules] } = this;
|
|
83
|
-
return `<span class="wpb-converter">-{${flags.print()}${flags.length > 0 ? '|' : ''}${(0, string_1.print)(rules, { sep: ';' })}}-</span>`;
|
|
84
|
-
}
|
|
85
|
-
/* NOT FOR BROWSER */
|
|
86
|
-
cloneNode() {
|
|
87
|
-
const [flags, ...rules] = this.cloneChildNodes();
|
|
88
|
-
return debug_1.Shadow.run(() => {
|
|
74
|
+
/** whether to prevent language conversion / 是否不转换 */
|
|
75
|
+
get noConvert() {
|
|
76
|
+
return this.hasFlag('R') || this.length === 2 && this.lastChild.length === 1;
|
|
77
|
+
}
|
|
78
|
+
/** all language conversion flags / 所有转换类型标记 */
|
|
79
|
+
get flags() {
|
|
80
|
+
return this.firstChild.flags;
|
|
81
|
+
}
|
|
82
|
+
set flags(value) {
|
|
83
|
+
this.firstChild.flags = value;
|
|
84
|
+
}
|
|
85
|
+
/* NOT FOR BROWSER END */
|
|
86
|
+
/**
|
|
87
|
+
* @param flags 转换类型标记
|
|
88
|
+
* @param rules 转换规则
|
|
89
|
+
*/
|
|
90
|
+
constructor(flags, rules, config, accum = []) {
|
|
91
|
+
super(undefined, config, accum);
|
|
89
92
|
// @ts-expect-error abstract class
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
93
|
+
this.insertAt(new converterFlags_1.ConverterFlagsToken(flags, config, accum));
|
|
94
|
+
const [firstRule] = rules, hasColon = firstRule.includes(':'),
|
|
95
|
+
// @ts-expect-error abstract class
|
|
96
|
+
firstRuleToken = new converterRule_1.ConverterRuleToken(firstRule, hasColon, config, accum);
|
|
97
|
+
if (hasColon && firstRuleToken.length === 1
|
|
98
|
+
|| !hasColon && rules.length === 2 && !(0, string_1.removeComment)(rules[1]).trim()) {
|
|
99
|
+
this.insertAt(
|
|
100
|
+
// @ts-expect-error abstract class
|
|
101
|
+
new converterRule_1.ConverterRuleToken(rules.join(';'), false, config, accum));
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
this.append(firstRuleToken, ...rules.slice(1)
|
|
105
|
+
// @ts-expect-error abstract class
|
|
106
|
+
.map(rule => new converterRule_1.ConverterRuleToken(rule, true, config, accum)));
|
|
107
|
+
}
|
|
108
|
+
/* NOT FOR BROWSER */
|
|
109
|
+
this.protectChildren(0);
|
|
102
110
|
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
111
|
+
/** @private */
|
|
112
|
+
toString(skip) {
|
|
113
|
+
const { childNodes: [flags, ...rules] } = this;
|
|
114
|
+
return `-{${flags.toString(skip)}${flags.length > 0 ? '|' : ''}${rules.map(rule => rule.toString(skip)).join(';')}}-`;
|
|
106
115
|
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
116
|
+
/** @private */
|
|
117
|
+
text() {
|
|
118
|
+
const { childNodes: [flags, ...rules] } = this;
|
|
119
|
+
return `-{${flags.text()}|${(0, string_1.text)(rules, ';')}}-`;
|
|
120
|
+
}
|
|
121
|
+
/** @private */
|
|
122
|
+
getAttribute(key) {
|
|
123
|
+
return key === 'padding' ? 2 : super.getAttribute(key);
|
|
124
|
+
}
|
|
125
|
+
/** @private */
|
|
126
|
+
getGaps(i) {
|
|
127
|
+
return i || this.firstChild.length > 0 ? 1 : 0;
|
|
128
|
+
}
|
|
129
|
+
/** @private */
|
|
130
|
+
print() {
|
|
131
|
+
const { childNodes: [flags, ...rules] } = this;
|
|
132
|
+
return `<span class="wpb-converter">-{${flags.print()}${flags.length > 0 ? '|' : ''}${(0, string_1.print)(rules, { sep: ';' })}}-</span>`;
|
|
133
|
+
}
|
|
134
|
+
/* NOT FOR BROWSER */
|
|
135
|
+
cloneNode() {
|
|
136
|
+
const [flags, ...rules] = this.cloneChildNodes();
|
|
137
|
+
return debug_1.Shadow.run(() => {
|
|
138
|
+
// @ts-expect-error abstract class
|
|
139
|
+
const token = new ConverterToken([], [''], this.getAttribute('config'));
|
|
140
|
+
token.firstChild.safeReplaceWith(flags);
|
|
141
|
+
token.removeAt(1);
|
|
142
|
+
token.append(...rules);
|
|
143
|
+
return token;
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
/** @private */
|
|
147
|
+
toHtmlInternal(opt) {
|
|
148
|
+
const flags = this.getEffectiveFlags(), nocc = opt?.nocc, { childNodes: [, ...rules] } = this;
|
|
149
|
+
if (nocc || flags.has('R') || this.getVariantFlags().size > 0) {
|
|
150
|
+
return (nocc ? '-{' : '') + (0, html_1.html)(rules, ';', opt) + (nocc ? '}-' : '');
|
|
151
|
+
}
|
|
152
|
+
else if (flags.has('S')) {
|
|
153
|
+
return rules.find(({ variant }) => variant)?.lastChild.toHtmlInternal(opt).trim()
|
|
154
|
+
?? rules[0].lastChild.toHtmlInternal(opt);
|
|
155
|
+
}
|
|
156
|
+
return '';
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Get all language conversion flags
|
|
160
|
+
*
|
|
161
|
+
* 获取所有转换类型标记
|
|
162
|
+
*/
|
|
163
|
+
getAllFlags() {
|
|
164
|
+
return this.firstChild.getAllFlags();
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Get effective language conversion flags
|
|
168
|
+
*
|
|
169
|
+
* 获取有效的转换类型标记
|
|
170
|
+
*/
|
|
171
|
+
getEffectiveFlags() {
|
|
172
|
+
return this.firstChild.getEffectiveFlags();
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Get unknown language conversion flags
|
|
176
|
+
*
|
|
177
|
+
* 获取未知的转换类型标记
|
|
178
|
+
*/
|
|
179
|
+
getUnknownFlags() {
|
|
180
|
+
return this.firstChild.getUnknownFlags();
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Get language coversion flags that specify a language variant
|
|
184
|
+
*
|
|
185
|
+
* 获取指定语言变体的转换标记
|
|
186
|
+
*/
|
|
187
|
+
getVariantFlags() {
|
|
188
|
+
return this.firstChild.getVariantFlags();
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Check if a language conversion flag is present
|
|
192
|
+
*
|
|
193
|
+
* 是否具有某转换类型标记
|
|
194
|
+
* @param flag language conversion flag / 转换类型标记
|
|
195
|
+
*/
|
|
196
|
+
hasFlag(flag) {
|
|
197
|
+
return this.firstChild.hasFlag(flag);
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Check if an effective language conversion flag is present
|
|
201
|
+
*
|
|
202
|
+
* 是否具有某有效的转换类型标记
|
|
203
|
+
* @param flag language conversion flag / 转换类型标记
|
|
204
|
+
*/
|
|
205
|
+
hasEffectiveFlag(flag) {
|
|
206
|
+
return this.firstChild.hasEffectiveFlag(flag);
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Remove a language conversion flag
|
|
210
|
+
*
|
|
211
|
+
* 移除某转换类型标记
|
|
212
|
+
* @param flag language conversion flag / 转换类型标记
|
|
213
|
+
*/
|
|
214
|
+
removeFlag(flag) {
|
|
215
|
+
this.firstChild.removeFlag(flag);
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Set a language conversion flag
|
|
219
|
+
*
|
|
220
|
+
* 设置转换类型标记
|
|
221
|
+
* @param flag language conversion flag / 转换类型标记
|
|
222
|
+
*/
|
|
223
|
+
setFlag(flag) {
|
|
224
|
+
this.firstChild.setFlag(flag);
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* Toggle a language conversion flag
|
|
228
|
+
*
|
|
229
|
+
* 开关转换类型标记
|
|
230
|
+
* @param flag language conversion flag / 转换类型标记
|
|
231
|
+
*/
|
|
232
|
+
toggleFlag(flag) {
|
|
233
|
+
this.firstChild.toggleFlag(flag);
|
|
234
|
+
}
|
|
235
|
+
};
|
|
236
|
+
return ConverterToken = _classThis;
|
|
237
|
+
})();
|
|
187
238
|
exports.ConverterToken = ConverterToken;
|
|
188
239
|
constants_1.classes['ConverterToken'] = __filename;
|
package/dist/src/gallery.js
CHANGED
|
@@ -67,7 +67,7 @@ class GalleryToken extends index_2.Token {
|
|
|
67
67
|
* @param file 文件名
|
|
68
68
|
*/
|
|
69
69
|
#checkFile(file) {
|
|
70
|
-
return this.normalizeTitle(file, 6, true, true, true).valid;
|
|
70
|
+
return this.normalizeTitle(file, 6, { halfParsed: true, temporary: true, decode: true }).valid;
|
|
71
71
|
}
|
|
72
72
|
/** @private */
|
|
73
73
|
toString(skip) {
|
|
@@ -155,7 +155,6 @@ class GalleryToken extends index_2.Token {
|
|
|
155
155
|
const token = debug_1.Shadow.run(() =>
|
|
156
156
|
// @ts-expect-error abstract class
|
|
157
157
|
new galleryImage_1.GalleryImageToken('gallery', file, undefined, this.getAttribute('config')));
|
|
158
|
-
token.afterBuild();
|
|
159
158
|
return this.insertAt(token, i);
|
|
160
159
|
}
|
|
161
160
|
throw new SyntaxError(`Invalid file name: ${file}`);
|
package/dist/src/heading.js
CHANGED
|
@@ -49,6 +49,7 @@ const constants_1 = require("../util/constants");
|
|
|
49
49
|
const string_1 = require("../util/string");
|
|
50
50
|
const fixed_1 = require("../mixin/fixed");
|
|
51
51
|
const sol_1 = require("../mixin/sol");
|
|
52
|
+
const noEscape_1 = require("../mixin/noEscape");
|
|
52
53
|
/* NOT FOR BROWSER END */
|
|
53
54
|
/**
|
|
54
55
|
* section heading
|
|
@@ -57,7 +58,7 @@ const sol_1 = require("../mixin/sol");
|
|
|
57
58
|
* @classdesc `{childNodes: [Token, SyntaxToken]}`
|
|
58
59
|
*/
|
|
59
60
|
let HeadingToken = (() => {
|
|
60
|
-
let _classDecorators = [fixed_1.fixedToken, (0, sol_1.sol)()];
|
|
61
|
+
let _classDecorators = [fixed_1.fixedToken, (0, sol_1.sol)(), noEscape_1.noEscape];
|
|
61
62
|
let _classDescriptor;
|
|
62
63
|
let _classExtraInitializers = [];
|
|
63
64
|
let _classThis;
|
|
@@ -112,9 +113,7 @@ let HeadingToken = (() => {
|
|
|
112
113
|
const token = new index_2.Token(input[0], config, accum);
|
|
113
114
|
token.type = 'heading-title';
|
|
114
115
|
token.setAttribute('stage', 2);
|
|
115
|
-
const trail = new syntax_1.SyntaxToken(input[1], /^\s*$/u, 'heading-trail', config, accum, {
|
|
116
|
-
'Stage-1': ':', '!ExtToken': '',
|
|
117
|
-
});
|
|
116
|
+
const trail = new syntax_1.SyntaxToken(input[1], /^\s*$/u, 'heading-trail', config, accum, { 'Stage-1': ':', '!ExtToken': '' });
|
|
118
117
|
this.append(token, trail);
|
|
119
118
|
}
|
|
120
119
|
/** 标题格式的等号 */
|
|
@@ -181,7 +180,7 @@ let HeadingToken = (() => {
|
|
|
181
180
|
left: rect.left + level,
|
|
182
181
|
}, 'format-leakage', index_1.default.msg('unbalanced $1 in a section header', 'bold apostrophes')), end = start + level + innerStr.length;
|
|
183
182
|
if (rootStr.slice(e.endIndex, end).trim()) {
|
|
184
|
-
e.suggestions = [{ desc: 'close', range: [end, end], text:
|
|
183
|
+
e.suggestions = [{ desc: 'close', range: [end, end], text: `'''` }];
|
|
185
184
|
}
|
|
186
185
|
else {
|
|
187
186
|
e.fix = { desc: 'remove', range: [e.startIndex, e.endIndex], text: '' };
|
|
@@ -191,7 +190,7 @@ let HeadingToken = (() => {
|
|
|
191
190
|
if (italicQuotes.length % 2) {
|
|
192
191
|
const e = (0, lint_1.generateForChild)(italicQuotes[italicQuotes.length - 1], { start: start + level }, 'format-leakage', index_1.default.msg('unbalanced $1 in a section header', 'italic apostrophes')), end = start + level + innerStr.length;
|
|
193
192
|
e.fix = rootStr.slice(e.endIndex, end).trim()
|
|
194
|
-
? { desc: 'close', range: [end, end], text:
|
|
193
|
+
? { desc: 'close', range: [end, end], text: `''` }
|
|
195
194
|
: { desc: 'remove', range: [e.startIndex, e.endIndex], text: '' };
|
|
196
195
|
errors.push(e);
|
|
197
196
|
}
|
|
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.ImageParameterToken = exports.galleryParams = void 0;
|
|
7
|
+
const common_1 = require("@bhsd/common");
|
|
7
8
|
const string_1 = require("../util/string");
|
|
8
9
|
const lint_1 = require("../util/lint");
|
|
9
10
|
const index_1 = __importDefault(require("../index"));
|
|
@@ -12,6 +13,16 @@ const index_2 = require("./index");
|
|
|
12
13
|
const debug_1 = require("../util/debug");
|
|
13
14
|
const constants_1 = require("../util/constants");
|
|
14
15
|
/* NOT FOR BROWSER END */
|
|
16
|
+
/^(?:ftp:\/\/|\/\/|\0\d+m\x7F)/iu; // eslint-disable-line @typescript-eslint/no-unused-expressions
|
|
17
|
+
const getUrlLikeRegex = (0, common_1.getRegex)(protocol => new RegExp(String.raw `^(?:${protocol}|//|\0\d+m\x7F)`, 'iu'));
|
|
18
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-expressions, es-x/no-regexp-unicode-property-escapes
|
|
19
|
+
/^(?:(?:ftp:\/\/|\/\/)(?:\[[\da-f:.]+\]|[^[\]<>"\t\n\p{Zs}])|\0\d+m\x7F)[^[\]<>"\0\t\n\p{Zs}]*$/iu;
|
|
20
|
+
const getUrlRegex = (0, common_1.getRegex)(protocol => new RegExp(String.raw `^(?:(?:${protocol}|//)${string_1.extUrlCharFirst}|\0\d+m\x7F)${string_1.extUrlChar}$`, 'iu'));
|
|
21
|
+
/* eslint-disable @typescript-eslint/no-unused-expressions */
|
|
22
|
+
/^(\s*)link=(.*)(?=$|\n)(\s*)$/u;
|
|
23
|
+
/^(\s*(?!\s))(.*)px(\s*)$/u;
|
|
24
|
+
/* eslint-enable @typescript-eslint/no-unused-expressions */
|
|
25
|
+
const getSyntaxRegex = (0, common_1.getRegex)(syntax => new RegExp(String.raw `^(\s*(?!\s))${syntax.replace('$1', '(.*)')}${syntax.endsWith('$1') ? '(?=$|\n)' : ''}(\s*)$`, 'u'));
|
|
15
26
|
exports.galleryParams = new Set(['alt', 'link', 'lang', 'page', 'caption']);
|
|
16
27
|
function validate(key, val, config, halfParsed, ext) {
|
|
17
28
|
val = val.trim();
|
|
@@ -23,18 +34,13 @@ function validate(key, val, config, halfParsed, ext) {
|
|
|
23
34
|
if (!value) {
|
|
24
35
|
return val;
|
|
25
36
|
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-expressions, es-x/no-regexp-unicode-property-escapes
|
|
29
|
-
/^(?:(?:ftp:\/\/|\/\/)(?:\[[\da-f:.]+\]|[^[\]<>"\t\n\p{Zs}])|\0\d+m\x7F)[^[\]<>"\0\t\n\p{Zs}]*$/iu;
|
|
30
|
-
const re2 = new RegExp(String.raw `^(?:(?:${config.protocol}|//)${string_1.extUrlCharFirst}|\0\d+m\x7F)${string_1.extUrlChar}$`, 'iu');
|
|
31
|
-
if (re1.test(value)) {
|
|
32
|
-
return re2.test(value) && val;
|
|
37
|
+
else if (getUrlLikeRegex(config.protocol).test(value)) {
|
|
38
|
+
return getUrlRegex(config.protocol).test(value) && val;
|
|
33
39
|
}
|
|
34
40
|
else if (value.startsWith('[[') && value.endsWith(']]')) {
|
|
35
41
|
value = value.slice(2, -2);
|
|
36
42
|
}
|
|
37
|
-
const title = index_1.default.normalizeTitle(value, 0, false, config,
|
|
43
|
+
const title = index_1.default.normalizeTitle(value, 0, false, config, { halfParsed, decode: true, selfLink: true });
|
|
38
44
|
return title.valid && title;
|
|
39
45
|
}
|
|
40
46
|
case 'lang':
|
|
@@ -124,14 +130,8 @@ class ImageParameterToken extends index_2.Token {
|
|
|
124
130
|
/** @param str 图片参数 */
|
|
125
131
|
constructor(str, extension, config, accum) {
|
|
126
132
|
let mt;
|
|
127
|
-
const regexes = Object.entries(config.img)
|
|
128
|
-
|
|
129
|
-
/^(\s*)link=(.*)(?=$|\n)(\s*)$/u;
|
|
130
|
-
/^(\s*(?!\s))(.*)px(\s*)$/u;
|
|
131
|
-
/* eslint-enable @typescript-eslint/no-unused-expressions */
|
|
132
|
-
const re = new RegExp(String.raw `^(\s*(?!\s))${syntax.replace('$1', '(.*)')}${syntax.endsWith('$1') ? '(?=$|\n)' : ''}(\s*)$`, 'u');
|
|
133
|
-
return [syntax, param, re];
|
|
134
|
-
}), param = regexes.find(([, key, regex]) => {
|
|
133
|
+
const regexes = Object.entries(config.img)
|
|
134
|
+
.map(([syntax, param]) => [syntax, param, getSyntaxRegex(syntax)]), param = regexes.find(([, key, regex]) => {
|
|
135
135
|
mt = regex.exec(str);
|
|
136
136
|
return mt
|
|
137
137
|
&& (mt.length !== 4
|
package/dist/src/imagemap.js
CHANGED
|
@@ -46,7 +46,7 @@ class ImagemapToken extends index_2.Token {
|
|
|
46
46
|
else if (first) {
|
|
47
47
|
const pipe = line.indexOf('|'), file = pipe === -1 ? line : line.slice(0, pipe), { valid, ns,
|
|
48
48
|
/* NOT FOR BROWSER */
|
|
49
|
-
interwiki, } = this.normalizeTitle(file, 0, true, true);
|
|
49
|
+
interwiki, } = this.normalizeTitle(file, 0, { halfParsed: true, temporary: true });
|
|
50
50
|
if (valid
|
|
51
51
|
&& !interwiki
|
|
52
52
|
&& ns === 6) {
|
|
@@ -68,7 +68,8 @@ class ImagemapToken extends index_2.Token {
|
|
|
68
68
|
const i = line.indexOf('['), substr = line.slice(i), mtIn = /^\[\[([^|]+)(?:\|([^\]]+))?\]\][\w\s]*$/u
|
|
69
69
|
.exec(substr);
|
|
70
70
|
if (mtIn) {
|
|
71
|
-
if (this.normalizeTitle(mtIn[1], 0, true, true,
|
|
71
|
+
if (this.normalizeTitle(mtIn[1], 0, { halfParsed: true, temporary: true, selfLink: true })
|
|
72
|
+
.valid) {
|
|
72
73
|
// @ts-expect-error abstract class
|
|
73
74
|
super.insertAt(new imagemapLink_1.ImagemapLinkToken(line.slice(0, i), mtIn.slice(1), substr.slice(substr.indexOf(']]') + 2), config, accum));
|
|
74
75
|
continue;
|
package/dist/src/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import Parser from '../index';
|
|
|
2
2
|
import { AstElement } from '../lib/element';
|
|
3
3
|
import { AstText } from '../lib/text';
|
|
4
4
|
import type { LintError, TokenTypes } from '../base';
|
|
5
|
-
import type { Title } from '../lib/title';
|
|
5
|
+
import type { Title, TitleOptions } from '../lib/title';
|
|
6
6
|
import type { AstNodes, IncludeToken, HtmlToken, ExtToken, CommentToken } from '../internal';
|
|
7
7
|
import { Ranges } from '../lib/ranges';
|
|
8
8
|
import { AstRange } from '../lib/range';
|