wikiparser-node 1.19.0 → 1.20.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/README.md +3 -0
- package/bundle/bundle-es7.min.js +24 -31
- package/bundle/bundle-lsp.min.js +25 -98
- package/bundle/bundle.min.js +25 -32
- package/config/default.json +49 -3
- package/config/minimum.json +5 -1
- package/data/ext/math.json +660 -0
- package/dist/addon/table.js +24 -5
- package/dist/addon/transclude.js +4 -4
- package/dist/base.d.mts +1 -1
- package/dist/base.d.ts +1 -1
- package/dist/bin/config.js +26 -8
- package/dist/index.js +10 -1
- package/dist/internal.d.ts +2 -0
- package/dist/lib/document.d.ts +1 -0
- package/dist/lib/document.js +10 -1
- package/dist/lib/element.js +15 -21
- package/dist/lib/lsp.js +88 -58
- package/dist/lib/node.js +21 -24
- package/dist/lib/text.js +3 -4
- package/dist/lib/title.js +2 -1
- package/dist/mixin/attributesParent.js +1 -1
- package/dist/mixin/fixed.d.ts +1 -2
- package/dist/mixin/fixed.js +2 -3
- package/dist/mixin/gapped.d.ts +4 -0
- package/dist/mixin/gapped.js +24 -0
- package/dist/mixin/hidden.js +1 -1
- package/dist/mixin/multiLine.d.ts +4 -0
- package/dist/mixin/multiLine.js +33 -0
- package/dist/mixin/noEscape.js +1 -1
- package/dist/mixin/padded.d.ts +5 -0
- package/dist/mixin/padded.js +24 -0
- package/dist/mixin/singleLine.js +1 -1
- package/dist/mixin/sol.js +1 -1
- package/dist/mixin/syntax.js +3 -3
- package/dist/parser/braces.js +8 -12
- package/dist/parser/commentAndExt.js +18 -2
- package/dist/parser/magicLinks.js +2 -2
- package/dist/parser/selector.js +5 -2
- package/dist/src/arg.js +10 -13
- package/dist/src/atom.js +2 -7
- package/dist/src/attribute.js +6 -6
- package/dist/src/attributes.js +8 -12
- package/dist/src/commented.d.ts +26 -0
- package/dist/src/commented.js +52 -0
- package/dist/src/converter.js +3 -6
- package/dist/src/converterFlags.js +266 -223
- package/dist/src/converterRule.d.ts +2 -2
- package/dist/src/converterRule.js +2 -2
- package/dist/src/extLink.d.ts +2 -3
- package/dist/src/extLink.js +222 -175
- package/dist/src/gallery.d.ts +4 -5
- package/dist/src/gallery.js +177 -144
- package/dist/src/heading.js +11 -11
- package/dist/src/hidden.js +2 -7
- package/dist/src/imageParameter.d.ts +2 -2
- package/dist/src/imageParameter.js +6 -5
- package/dist/src/imagemap.d.ts +2 -2
- package/dist/src/imagemap.js +155 -123
- package/dist/src/imagemapLink.d.ts +2 -2
- package/dist/src/index.js +44 -20
- package/dist/src/link/base.d.ts +2 -3
- package/dist/src/link/base.js +13 -15
- package/dist/src/link/file.d.ts +2 -3
- package/dist/src/link/file.js +3 -3
- package/dist/src/link/galleryImage.d.ts +2 -3
- package/dist/src/link/galleryImage.js +7 -13
- package/dist/src/magicLink.js +7 -9
- package/dist/src/nested.d.ts +2 -2
- package/dist/src/nested.js +4 -7
- package/dist/src/nowiki/comment.js +2 -5
- package/dist/src/nowiki/doubleUnderscore.js +2 -5
- package/dist/src/nowiki/index.d.ts +2 -2
- package/dist/src/nowiki/index.js +2 -1
- package/dist/src/onlyinclude.js +6 -13
- package/dist/src/paramTag/index.d.ts +2 -2
- package/dist/src/paramTag/index.js +102 -66
- package/dist/src/parameter.d.ts +4 -5
- package/dist/src/parameter.js +13 -13
- package/dist/src/pre.d.ts +4 -5
- package/dist/src/pre.js +8 -17
- package/dist/src/syntax.d.ts +1 -1
- package/dist/src/syntax.js +2 -7
- package/dist/src/table/base.d.ts +2 -2
- package/dist/src/table/base.js +8 -8
- package/dist/src/table/index.js +1 -1
- package/dist/src/table/td.d.ts +3 -3
- package/dist/src/table/td.js +9 -9
- package/dist/src/table/tr.d.ts +2 -2
- package/dist/src/tagPair/ext.js +35 -30
- package/dist/src/tagPair/index.d.ts +1 -1
- package/dist/src/tagPair/index.js +2 -5
- package/dist/src/tagPair/translate.d.ts +38 -0
- package/dist/src/tagPair/translate.js +129 -0
- package/dist/src/transclude.js +5 -6
- package/dist/util/html.js +16 -1
- package/dist/util/lint.js +17 -30
- package/dist/util/sharable.js +29 -1
- package/dist/util/sharable.mjs +31 -3
- package/dist/util/string.js +14 -1
- package/extensions/dist/base.js +1 -1
- package/extensions/dist/lsp.js +13 -2
- package/package.json +4 -3
- package/extensions/es7/base.js +0 -320
- package/extensions/es7/lint.js +0 -97
package/dist/src/extLink.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
|
};
|
|
@@ -6,12 +40,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
40
|
exports.ExtLinkToken = void 0;
|
|
7
41
|
const constants_1 = require("../util/constants");
|
|
8
42
|
const lint_1 = require("../util/lint");
|
|
9
|
-
const
|
|
10
|
-
const
|
|
43
|
+
const padded_1 = require("../mixin/padded");
|
|
44
|
+
const index_1 = require("./index");
|
|
11
45
|
const magicLink_1 = require("./magicLink");
|
|
12
46
|
/* NOT FOR BROWSER */
|
|
13
47
|
const string_1 = require("../util/string");
|
|
14
48
|
const debug_1 = require("../util/debug");
|
|
49
|
+
const index_2 = __importDefault(require("../index"));
|
|
15
50
|
/* NOT FOR BROWSER END */
|
|
16
51
|
/**
|
|
17
52
|
* external link
|
|
@@ -19,192 +54,204 @@ const debug_1 = require("../util/debug");
|
|
|
19
54
|
* 外链
|
|
20
55
|
* @classdesc `{childNodes: [MagicLinkToken, ?Token]}`
|
|
21
56
|
*/
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
this.setLinkText(text);
|
|
37
|
-
}
|
|
38
|
-
/** URL protocol / 协议 */
|
|
39
|
-
get protocol() {
|
|
40
|
-
return this.firstChild.protocol;
|
|
41
|
-
}
|
|
42
|
-
set protocol(value) {
|
|
43
|
-
this.firstChild.protocol = value;
|
|
44
|
-
}
|
|
45
|
-
/** link / 链接 */
|
|
46
|
-
get link() {
|
|
47
|
-
return this.firstChild.link;
|
|
48
|
-
}
|
|
49
|
-
set link(url) {
|
|
50
|
-
this.firstChild.link = url;
|
|
51
|
-
}
|
|
52
|
-
/* NOT FOR BROWSER END */
|
|
53
|
-
/**
|
|
54
|
-
* @param url 网址
|
|
55
|
-
* @param space 空白字符
|
|
56
|
-
* @param text 链接文字
|
|
57
|
-
*/
|
|
58
|
-
constructor(url, space = '', text = '', config = index_1.default.getConfig(), accum = []) {
|
|
59
|
-
super(undefined, config, accum, {
|
|
60
|
-
MagicLinkToken: 0, Token: 1,
|
|
61
|
-
});
|
|
62
|
-
const link = url && /^\0\d+f\x7F$/u.test(url)
|
|
63
|
-
? accum[Number(url.slice(1, -2))]
|
|
64
|
-
// @ts-expect-error abstract class
|
|
65
|
-
: new magicLink_1.MagicLinkToken(url, 'ext-link-url', config, accum);
|
|
66
|
-
this.insertAt(link);
|
|
67
|
-
this.#space = space;
|
|
68
|
-
if (text) {
|
|
69
|
-
const inner = new index_2.Token(text, config, accum, {
|
|
70
|
-
'Stage-7': ':', ConverterToken: ':',
|
|
71
|
-
});
|
|
72
|
-
inner.type = 'ext-link-text';
|
|
73
|
-
inner.setAttribute('stage', constants_1.MAX_STAGE - 1);
|
|
74
|
-
this.insertAt(inner);
|
|
57
|
+
let ExtLinkToken = (() => {
|
|
58
|
+
let _classDecorators = [(0, padded_1.padded)('[')];
|
|
59
|
+
let _classDescriptor;
|
|
60
|
+
let _classExtraInitializers = [];
|
|
61
|
+
let _classThis;
|
|
62
|
+
let _classSuper = index_1.Token;
|
|
63
|
+
var ExtLinkToken = class extends _classSuper {
|
|
64
|
+
static { _classThis = this; }
|
|
65
|
+
static {
|
|
66
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
67
|
+
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
68
|
+
ExtLinkToken = _classThis = _classDescriptor.value;
|
|
69
|
+
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
70
|
+
__runInitializers(_classThis, _classExtraInitializers);
|
|
75
71
|
}
|
|
76
|
-
|
|
77
|
-
this.protectChildren(0);
|
|
78
|
-
}
|
|
79
|
-
/** @private */
|
|
80
|
-
toString(skip) {
|
|
81
|
-
if (this.length === 1) {
|
|
82
|
-
return `[${super.toString(skip)}${this.#space}]`;
|
|
83
|
-
}
|
|
84
|
-
/* NOT FOR BROWSER */
|
|
85
|
-
this.#correct();
|
|
86
|
-
(0, string_1.normalizeSpace)(this.lastChild);
|
|
87
|
-
/* NOT FOR BROWSER END */
|
|
88
|
-
return `[${super.toString(skip, this.#space)}]`;
|
|
89
|
-
}
|
|
90
|
-
/** @private */
|
|
91
|
-
text() {
|
|
92
|
-
/* NOT FOR BROWSER */
|
|
93
|
-
(0, string_1.normalizeSpace)(this.childNodes[1]);
|
|
72
|
+
#space;
|
|
94
73
|
/* NOT FOR BROWSER END */
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
getAttribute(key) {
|
|
99
|
-
return key === 'padding' ? 1 : super.getAttribute(key);
|
|
100
|
-
}
|
|
101
|
-
/** @private */
|
|
102
|
-
getGaps() {
|
|
74
|
+
get type() {
|
|
75
|
+
return 'ext-link';
|
|
76
|
+
}
|
|
103
77
|
/* NOT FOR BROWSER */
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
lint(start = this.getAbsoluteIndex(), re) {
|
|
110
|
-
const errors = super.lint(start, re);
|
|
111
|
-
if (this.length === 1 && this.closest('heading-title')) {
|
|
112
|
-
errors.push((0, lint_1.generateForSelf)(this, { start }, 'var-anchor', 'variable anchor in a section header'));
|
|
78
|
+
/** text of the link / 链接显示文字 */
|
|
79
|
+
get innerText() {
|
|
80
|
+
return this.length > 1
|
|
81
|
+
? this.lastChild.text()
|
|
82
|
+
: `[${this.getRootNode().querySelectorAll('ext-link[childElementCount=1]').indexOf(this) + 1}]`;
|
|
113
83
|
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
84
|
+
set innerText(text) {
|
|
85
|
+
this.setLinkText(text);
|
|
86
|
+
}
|
|
87
|
+
/** URL protocol / 协议 */
|
|
88
|
+
get protocol() {
|
|
89
|
+
return this.firstChild.protocol;
|
|
90
|
+
}
|
|
91
|
+
set protocol(value) {
|
|
92
|
+
this.firstChild.protocol = value;
|
|
93
|
+
}
|
|
94
|
+
/** link / 链接 */
|
|
95
|
+
get link() {
|
|
96
|
+
return this.firstChild.link;
|
|
97
|
+
}
|
|
98
|
+
set link(url) {
|
|
99
|
+
this.firstChild.link = url;
|
|
100
|
+
}
|
|
101
|
+
/* NOT FOR BROWSER END */
|
|
102
|
+
/**
|
|
103
|
+
* @param url 网址
|
|
104
|
+
* @param space 空白字符
|
|
105
|
+
* @param text 链接文字
|
|
106
|
+
*/
|
|
107
|
+
constructor(url, space = '', text = '', config, accum = []) {
|
|
108
|
+
super(undefined, config, accum, {
|
|
109
|
+
MagicLinkToken: 0, Token: 1,
|
|
110
|
+
});
|
|
111
|
+
const link = url && /^\0\d+f\x7F$/u.test(url)
|
|
112
|
+
? accum[Number(url.slice(1, -2))]
|
|
113
|
+
// @ts-expect-error abstract class
|
|
114
|
+
: new magicLink_1.MagicLinkToken(url, 'ext-link-url', config, accum);
|
|
115
|
+
this.insertAt(link);
|
|
116
|
+
this.#space = space;
|
|
127
117
|
if (text) {
|
|
128
|
-
|
|
118
|
+
const inner = new index_1.Token(text, config, accum, {
|
|
119
|
+
'Stage-7': ':', ConverterToken: ':',
|
|
120
|
+
});
|
|
121
|
+
inner.type = 'ext-link-text';
|
|
122
|
+
inner.setAttribute('stage', constants_1.MAX_STAGE - 1);
|
|
123
|
+
this.insertAt(inner);
|
|
129
124
|
}
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
}
|
|
133
|
-
/** 修正空白字符 */
|
|
134
|
-
#correct() {
|
|
135
|
-
const { lastChild, length } = this, { firstChild } = lastChild;
|
|
136
|
-
if (!this.#space
|
|
137
|
-
&& length > 1
|
|
138
|
-
&& (firstChild?.type === 'text' || firstChild?.type === 'converter')
|
|
139
|
-
// 都替换成`<`肯定不对,但无妨
|
|
140
|
-
// eslint-disable-next-line es-x/no-regexp-unicode-property-escapes
|
|
141
|
-
&& /^[^[\]<>"\0-\x1F\x7F\p{Zs}\uFFFD]/u
|
|
142
|
-
.test(lastChild.text().replace(/&[lg]t;/u, '<'))) {
|
|
143
|
-
this.#space = ' ';
|
|
125
|
+
/* NOT FOR BROWSER */
|
|
126
|
+
this.protectChildren(0);
|
|
144
127
|
}
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
128
|
+
/** @private */
|
|
129
|
+
toString(skip) {
|
|
130
|
+
if (this.length === 1) {
|
|
131
|
+
return `[${super.toString(skip)}${this.#space}]`;
|
|
132
|
+
}
|
|
133
|
+
/* NOT FOR BROWSER */
|
|
134
|
+
this.#correct();
|
|
135
|
+
(0, string_1.normalizeSpace)(this.lastChild);
|
|
136
|
+
/* NOT FOR BROWSER END */
|
|
137
|
+
return `[${super.toString(skip, this.#space)}]`;
|
|
138
|
+
}
|
|
139
|
+
/** @private */
|
|
140
|
+
text() {
|
|
141
|
+
/* NOT FOR BROWSER */
|
|
142
|
+
(0, string_1.normalizeSpace)(this.childNodes[1]);
|
|
143
|
+
/* NOT FOR BROWSER END */
|
|
144
|
+
return `[${super.text(' ')}]`;
|
|
145
|
+
}
|
|
146
|
+
/** @private */
|
|
147
|
+
getGaps() {
|
|
148
|
+
/* NOT FOR BROWSER */
|
|
149
|
+
this.#correct();
|
|
150
|
+
/* NOT FOR BROWSER END */
|
|
151
|
+
return this.#space.length;
|
|
152
|
+
}
|
|
153
|
+
/** @private */
|
|
154
|
+
lint(start = this.getAbsoluteIndex(), re) {
|
|
155
|
+
const errors = super.lint(start, re);
|
|
156
|
+
if (this.length === 1 && this.closest('heading-title')) {
|
|
157
|
+
errors.push((0, lint_1.generateForSelf)(this, { start }, 'var-anchor', 'variable anchor in a section header'));
|
|
158
|
+
}
|
|
159
|
+
return errors;
|
|
160
|
+
}
|
|
161
|
+
/** @private */
|
|
162
|
+
print() {
|
|
163
|
+
return super.print(this.length === 1 ? { pre: '[', post: `${this.#space}]` } : { pre: '[', sep: this.#space, post: ']' });
|
|
164
|
+
}
|
|
165
|
+
/* NOT FOR BROWSER */
|
|
166
|
+
cloneNode() {
|
|
167
|
+
const [url, text] = this.cloneChildNodes();
|
|
168
|
+
return debug_1.Shadow.run(() => {
|
|
169
|
+
// @ts-expect-error abstract class
|
|
170
|
+
const token = new ExtLinkToken(undefined, this.#space, '', this.getAttribute('config'));
|
|
171
|
+
token.firstChild.safeReplaceWith(url);
|
|
172
|
+
if (text) {
|
|
173
|
+
token.insertAt(text);
|
|
174
|
+
}
|
|
175
|
+
return token;
|
|
159
176
|
});
|
|
160
|
-
this.insertAt(root);
|
|
161
177
|
}
|
|
162
|
-
|
|
163
|
-
|
|
178
|
+
/** 修正空白字符 */
|
|
179
|
+
#correct() {
|
|
180
|
+
const { lastChild, length } = this, { firstChild } = lastChild;
|
|
181
|
+
if (!this.#space
|
|
182
|
+
&& length > 1
|
|
183
|
+
&& (firstChild?.type === 'text' || firstChild?.type === 'converter')
|
|
184
|
+
// 都替换成`<`肯定不对,但无妨
|
|
185
|
+
// eslint-disable-next-line es-x/no-regexp-unicode-property-escapes
|
|
186
|
+
&& /^[^[\]<>"\0-\x1F\x7F\p{Zs}\uFFFD]/u
|
|
187
|
+
.test(lastChild.text().replace(/&[lg]t;/u, '<'))) {
|
|
188
|
+
this.#space = ' ';
|
|
189
|
+
}
|
|
164
190
|
}
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
191
|
+
/**
|
|
192
|
+
* Set the text of the link
|
|
193
|
+
*
|
|
194
|
+
* 设置链接显示文字
|
|
195
|
+
* @param str text of the link / 链接显示文字
|
|
196
|
+
*/
|
|
197
|
+
setLinkText(str) {
|
|
198
|
+
const root = index_2.default
|
|
199
|
+
.parse(str, this.getAttribute('include'), 7, this.getAttribute('config'));
|
|
200
|
+
if (this.length === 1) {
|
|
201
|
+
root.type = 'ext-link-text';
|
|
202
|
+
root.setAttribute('acceptable', {
|
|
203
|
+
'Stage-7': ':', ConverterToken: ':',
|
|
204
|
+
});
|
|
205
|
+
this.insertAt(root);
|
|
206
|
+
}
|
|
207
|
+
else {
|
|
208
|
+
this.lastChild.safeReplaceChildren(root.childNodes);
|
|
179
209
|
}
|
|
180
|
-
|
|
210
|
+
this.#space ||= ' ';
|
|
181
211
|
}
|
|
182
|
-
|
|
183
|
-
|
|
212
|
+
/** @private */
|
|
213
|
+
toHtmlInternal(opt) {
|
|
214
|
+
const { length, lastChild } = this;
|
|
215
|
+
let innerText, href;
|
|
216
|
+
if (length > 1) {
|
|
217
|
+
lastChild.normalize();
|
|
218
|
+
const { childNodes } = lastChild, i = childNodes.findIndex(child => child.type === 'link'
|
|
219
|
+
|| child.is('file')
|
|
220
|
+
&& child.getValue('link')?.trim() !== '');
|
|
221
|
+
if (i !== -1) {
|
|
222
|
+
const after = childNodes.slice(i);
|
|
223
|
+
this.insertAdjacent(after, 1);
|
|
224
|
+
}
|
|
225
|
+
innerText = lastChild.toHtmlInternal(opt);
|
|
226
|
+
}
|
|
227
|
+
else {
|
|
228
|
+
({ innerText } = this);
|
|
229
|
+
}
|
|
230
|
+
try {
|
|
231
|
+
({ href } = this.getUrl());
|
|
232
|
+
}
|
|
233
|
+
catch { }
|
|
234
|
+
return `<a rel="nofollow" class="external"${href === undefined ? '' : ` href="${href}"`}>${innerText}</a>`;
|
|
184
235
|
}
|
|
185
|
-
|
|
186
|
-
|
|
236
|
+
/**
|
|
237
|
+
* Get the URL
|
|
238
|
+
*
|
|
239
|
+
* 获取网址
|
|
240
|
+
*/
|
|
241
|
+
getUrl() {
|
|
242
|
+
return this.firstChild.getUrl();
|
|
187
243
|
}
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
* Set the target of the link
|
|
201
|
-
*
|
|
202
|
-
* 设置外链目标
|
|
203
|
-
* @param url URL containing the protocol / 含协议的网址
|
|
204
|
-
*/
|
|
205
|
-
setTarget(url) {
|
|
206
|
-
this.firstChild.setTarget(url);
|
|
207
|
-
}
|
|
208
|
-
}
|
|
244
|
+
/**
|
|
245
|
+
* Set the target of the link
|
|
246
|
+
*
|
|
247
|
+
* 设置外链目标
|
|
248
|
+
* @param url URL containing the protocol / 含协议的网址
|
|
249
|
+
*/
|
|
250
|
+
setTarget(url) {
|
|
251
|
+
this.firstChild.setTarget(url);
|
|
252
|
+
}
|
|
253
|
+
};
|
|
254
|
+
return ExtLinkToken = _classThis;
|
|
255
|
+
})();
|
|
209
256
|
exports.ExtLinkToken = ExtLinkToken;
|
|
210
257
|
constants_1.classes['ExtLinkToken'] = __filename;
|
package/dist/src/gallery.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import Parser from '../index';
|
|
2
1
|
import { Token } from './index';
|
|
3
2
|
import { GalleryImageToken } from './link/galleryImage';
|
|
4
3
|
import { NoincludeToken } from './nowiki/noinclude';
|
|
5
|
-
import type { LintError, AST } from '../base';
|
|
4
|
+
import type { Config, LintError, AST } from '../base';
|
|
6
5
|
import type { AstText, AttributesToken, ExtToken, AstNodes } from '../internal';
|
|
7
6
|
declare type Child = GalleryImageToken | NoincludeToken;
|
|
8
7
|
/**
|
|
@@ -18,13 +17,13 @@ export declare abstract class GalleryToken extends Token {
|
|
|
18
17
|
abstract get firstChild(): Child | AstText | undefined;
|
|
19
18
|
abstract get lastChild(): Child | AstText | undefined;
|
|
20
19
|
abstract get nextSibling(): undefined;
|
|
21
|
-
abstract get previousSibling(): AttributesToken;
|
|
20
|
+
abstract get previousSibling(): AttributesToken | undefined;
|
|
22
21
|
abstract get parentNode(): ExtToken | undefined;
|
|
23
22
|
abstract get children(): Child[];
|
|
24
23
|
abstract get firstElementChild(): Child | undefined;
|
|
25
24
|
abstract get lastElementChild(): Child | undefined;
|
|
26
25
|
abstract get nextElementSibling(): undefined;
|
|
27
|
-
abstract get previousElementSibling(): AttributesToken;
|
|
26
|
+
abstract get previousElementSibling(): AttributesToken | undefined;
|
|
28
27
|
abstract get parentElement(): ExtToken | undefined;
|
|
29
28
|
get type(): 'ext-inner';
|
|
30
29
|
/** image widths / 图片宽度 */
|
|
@@ -34,7 +33,7 @@ export declare abstract class GalleryToken extends Token {
|
|
|
34
33
|
/** all images / 所有图片 */
|
|
35
34
|
get images(): GalleryImageToken[];
|
|
36
35
|
/** @param inner 标签内部wikitext */
|
|
37
|
-
constructor(inner?: string, config?:
|
|
36
|
+
constructor(inner?: string, config?: Config, accum?: Token[]);
|
|
38
37
|
cloneNode(): this;
|
|
39
38
|
/**
|
|
40
39
|
* Insert an image
|