wikiparser-node 1.16.6 → 1.17.1
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 +1 -0
- package/bundle/bundle.es7.js +26 -26
- package/bundle/bundle.lsp.js +27 -27
- package/bundle/bundle.min.js +26 -26
- package/config/.schema.json +6 -2
- package/data/.schema.json +7 -0
- package/data/ext/mapframe.json +4 -0
- package/data/ext/maplink.json +4 -0
- package/data/ext/templatedata.json +184 -0
- package/dist/addon/table.js +16 -10
- package/dist/addon/token.js +26 -32
- package/dist/addon/transclude.js +6 -3
- package/dist/base.d.mts +4 -2
- package/dist/base.d.ts +4 -2
- package/dist/base.js +2 -0
- package/dist/base.mjs +3 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +33 -21
- package/dist/lib/document.d.ts +53 -0
- package/dist/lib/document.js +121 -0
- package/dist/lib/element.js +6 -3
- package/dist/lib/lsp.d.ts +5 -7
- package/dist/lib/lsp.js +154 -28
- package/dist/lib/node.js +19 -9
- package/dist/lib/text.js +4 -1
- package/dist/lib/title.js +9 -6
- package/dist/mixin/attributesParent.d.ts +8 -0
- package/dist/mixin/attributesParent.js +4 -0
- package/dist/parser/links.js +4 -1
- package/dist/parser/redirect.js +4 -1
- package/dist/src/arg.d.ts +2 -3
- package/dist/src/arg.js +16 -9
- package/dist/src/attribute.d.ts +12 -1
- package/dist/src/attribute.js +69 -1
- package/dist/src/attributes.d.ts +10 -3
- package/dist/src/attributes.js +15 -2
- package/dist/src/converter.d.ts +64 -5
- package/dist/src/converter.js +163 -131
- package/dist/src/converterFlags.d.ts +2 -3
- package/dist/src/converterFlags.js +5 -6
- package/dist/src/converterRule.js +4 -1
- package/dist/src/extLink.d.ts +19 -3
- package/dist/src/extLink.js +177 -194
- package/dist/src/gallery.js +7 -3
- package/dist/src/heading.d.ts +2 -3
- package/dist/src/heading.js +10 -5
- package/dist/src/html.d.ts +0 -3
- package/dist/src/html.js +90 -93
- package/dist/src/imageParameter.d.ts +2 -3
- package/dist/src/imageParameter.js +10 -4
- package/dist/src/imagemap.js +4 -1
- package/dist/src/imagemapLink.d.ts +2 -2
- package/dist/src/imagemapLink.js +5 -6
- package/dist/src/index.d.ts +6 -0
- package/dist/src/index.js +54 -4
- package/dist/src/link/base.js +8 -2
- package/dist/src/link/file.js +11 -2
- package/dist/src/link/galleryImage.d.ts +1 -0
- package/dist/src/link/galleryImage.js +15 -1
- package/dist/src/magicLink.js +4 -1
- package/dist/src/nested.d.ts +2 -3
- package/dist/src/nested.js +5 -2
- package/dist/src/nowiki/comment.js +4 -1
- package/dist/src/nowiki/doubleUnderscore.d.ts +2 -2
- package/dist/src/nowiki/doubleUnderscore.js +1 -2
- package/dist/src/nowiki/index.js +4 -1
- package/dist/src/nowiki/quote.js +4 -1
- package/dist/src/onlyinclude.js +4 -1
- package/dist/src/paramTag/index.js +5 -1
- package/dist/src/paramTag/inputbox.js +4 -1
- package/dist/src/parameter.js +4 -1
- package/dist/src/pre.js +4 -1
- package/dist/src/redirect.d.ts +2 -3
- package/dist/src/redirect.js +7 -6
- package/dist/src/table/base.js +4 -1
- package/dist/src/table/index.js +10 -3
- package/dist/src/table/td.d.ts +2 -2
- package/dist/src/table/td.js +5 -2
- package/dist/src/tagPair/ext.js +17 -5
- package/dist/src/tagPair/include.js +4 -1
- package/dist/src/tagPair/index.js +4 -1
- package/dist/src/transclude.d.ts +2 -3
- package/dist/src/transclude.js +20 -11
- package/dist/util/debug.js +1 -13
- package/dist/util/diff.js +20 -6
- package/dist/util/lint.js +4 -1
- package/dist/util/string.js +5 -2
- package/extensions/dist/base.js +29 -17
- package/extensions/dist/lint.js +1 -0
- package/extensions/dist/lsp.js +30 -22
- package/extensions/es7/base.js +29 -17
- package/extensions/es7/lint.js +1 -0
- package/extensions/typings.d.ts +9 -3
- package/package.json +12 -6
- package/dist/mixin/flagsParent.d.ts +0 -69
- package/dist/mixin/flagsParent.js +0 -64
- package/dist/mixin/magicLinkParent.d.ts +0 -25
- package/dist/mixin/magicLinkParent.js +0 -43
package/dist/src/extLink.d.ts
CHANGED
|
@@ -2,9 +2,6 @@ import Parser from '../index';
|
|
|
2
2
|
import { Token } from './index';
|
|
3
3
|
import { MagicLinkToken } from './magicLink';
|
|
4
4
|
import type { LintError } from '../base';
|
|
5
|
-
import type { MagicLinkParentBase } from '../mixin/magicLinkParent';
|
|
6
|
-
export interface ExtLinkToken extends MagicLinkParentBase {
|
|
7
|
-
}
|
|
8
5
|
/**
|
|
9
6
|
* external link
|
|
10
7
|
*
|
|
@@ -23,6 +20,12 @@ export declare abstract class ExtLinkToken extends Token {
|
|
|
23
20
|
/** text of the link / 链接显示文字 */
|
|
24
21
|
get innerText(): string;
|
|
25
22
|
set innerText(text: string);
|
|
23
|
+
/** URL protocol / 协议 */
|
|
24
|
+
get protocol(): string | undefined;
|
|
25
|
+
set protocol(value: string);
|
|
26
|
+
/** link / 链接 */
|
|
27
|
+
get link(): string;
|
|
28
|
+
set link(url: string);
|
|
26
29
|
/**
|
|
27
30
|
* @param url 网址
|
|
28
31
|
* @param space 空白字符
|
|
@@ -37,4 +40,17 @@ export declare abstract class ExtLinkToken extends Token {
|
|
|
37
40
|
* @param str text of the link / 链接显示文字
|
|
38
41
|
*/
|
|
39
42
|
setLinkText(str: string): void;
|
|
43
|
+
/**
|
|
44
|
+
* Get the URL
|
|
45
|
+
*
|
|
46
|
+
* 获取网址
|
|
47
|
+
*/
|
|
48
|
+
getUrl(): URL;
|
|
49
|
+
/**
|
|
50
|
+
* Set the target of the link
|
|
51
|
+
*
|
|
52
|
+
* 设置外链目标
|
|
53
|
+
* @param url URL containing the protocol / 含协议的网址
|
|
54
|
+
*/
|
|
55
|
+
setTarget(url: string): void;
|
|
40
56
|
}
|
package/dist/src/extLink.js
CHANGED
|
@@ -1,49 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
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;
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
35
4
|
};
|
|
36
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
37
6
|
exports.ExtLinkToken = void 0;
|
|
38
7
|
const constants_1 = require("../util/constants");
|
|
39
8
|
const lint_1 = require("../util/lint");
|
|
40
|
-
const index_1 = require("../index");
|
|
9
|
+
const index_1 = __importDefault(require("../index"));
|
|
41
10
|
const index_2 = require("./index");
|
|
42
11
|
const magicLink_1 = require("./magicLink");
|
|
43
12
|
/* NOT FOR BROWSER */
|
|
44
13
|
const string_1 = require("../util/string");
|
|
45
14
|
const debug_1 = require("../util/debug");
|
|
46
|
-
const magicLinkParent_1 = require("../mixin/magicLinkParent");
|
|
47
15
|
/* NOT FOR BROWSER END */
|
|
48
16
|
/**
|
|
49
17
|
* external link
|
|
@@ -51,177 +19,192 @@ const magicLinkParent_1 = require("../mixin/magicLinkParent");
|
|
|
51
19
|
* 外链
|
|
52
20
|
* @classdesc `{childNodes: [MagicLinkToken, ?Token]}`
|
|
53
21
|
*/
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
22
|
+
class ExtLinkToken extends index_2.Token {
|
|
23
|
+
#space;
|
|
24
|
+
/* NOT FOR BROWSER END */
|
|
25
|
+
get type() {
|
|
26
|
+
return 'ext-link';
|
|
27
|
+
}
|
|
28
|
+
/* NOT FOR BROWSER */
|
|
29
|
+
/** text of the link / 链接显示文字 */
|
|
30
|
+
get innerText() {
|
|
31
|
+
return this.length > 1
|
|
32
|
+
? this.lastChild.text()
|
|
33
|
+
: `[${this.getRootNode().querySelectorAll('ext-link[childElementCount=1]').indexOf(this) + 1}]`;
|
|
34
|
+
}
|
|
35
|
+
set innerText(text) {
|
|
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);
|
|
73
75
|
}
|
|
74
76
|
/* NOT FOR BROWSER */
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
set innerText(text) {
|
|
82
|
-
this.setLinkText(text);
|
|
77
|
+
this.protectChildren(0);
|
|
78
|
+
}
|
|
79
|
+
/** @private */
|
|
80
|
+
toString(skip) {
|
|
81
|
+
if (this.length === 1) {
|
|
82
|
+
return `[${super.toString(skip)}${this.#space}]`;
|
|
83
83
|
}
|
|
84
|
+
/* NOT FOR BROWSER */
|
|
85
|
+
this.#correct();
|
|
86
|
+
(0, string_1.normalizeSpace)(this.lastChild);
|
|
84
87
|
/* NOT FOR BROWSER END */
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
}
|
|
111
|
-
/** @private */
|
|
112
|
-
toString(skip) {
|
|
113
|
-
if (this.length === 1) {
|
|
114
|
-
return `[${super.toString(skip)}${this.#space}]`;
|
|
115
|
-
}
|
|
116
|
-
/* NOT FOR BROWSER */
|
|
117
|
-
this.#correct();
|
|
118
|
-
(0, string_1.normalizeSpace)(this.lastChild);
|
|
119
|
-
/* NOT FOR BROWSER END */
|
|
120
|
-
return `[${super.toString(skip, this.#space)}]`;
|
|
121
|
-
}
|
|
122
|
-
/** @private */
|
|
123
|
-
text() {
|
|
124
|
-
/* NOT FOR BROWSER */
|
|
125
|
-
(0, string_1.normalizeSpace)(this.childNodes[1]);
|
|
126
|
-
/* NOT FOR BROWSER END */
|
|
127
|
-
return `[${super.text(' ')}]`;
|
|
128
|
-
}
|
|
129
|
-
/** @private */
|
|
130
|
-
getAttribute(key) {
|
|
131
|
-
return key === 'padding' ? 1 : super.getAttribute(key);
|
|
132
|
-
}
|
|
133
|
-
/** @private */
|
|
134
|
-
getGaps() {
|
|
135
|
-
/* NOT FOR BROWSER */
|
|
136
|
-
this.#correct();
|
|
137
|
-
/* NOT FOR BROWSER END */
|
|
138
|
-
return this.#space.length;
|
|
88
|
+
return `[${super.toString(skip, this.#space)}]`;
|
|
89
|
+
}
|
|
90
|
+
/** @private */
|
|
91
|
+
text() {
|
|
92
|
+
/* NOT FOR BROWSER */
|
|
93
|
+
(0, string_1.normalizeSpace)(this.childNodes[1]);
|
|
94
|
+
/* NOT FOR BROWSER END */
|
|
95
|
+
return `[${super.text(' ')}]`;
|
|
96
|
+
}
|
|
97
|
+
/** @private */
|
|
98
|
+
getAttribute(key) {
|
|
99
|
+
return key === 'padding' ? 1 : super.getAttribute(key);
|
|
100
|
+
}
|
|
101
|
+
/** @private */
|
|
102
|
+
getGaps() {
|
|
103
|
+
/* NOT FOR BROWSER */
|
|
104
|
+
this.#correct();
|
|
105
|
+
/* NOT FOR BROWSER END */
|
|
106
|
+
return this.#space.length;
|
|
107
|
+
}
|
|
108
|
+
/** @private */
|
|
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'));
|
|
139
113
|
}
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
114
|
+
return errors;
|
|
115
|
+
}
|
|
116
|
+
/** @private */
|
|
117
|
+
print() {
|
|
118
|
+
return super.print(this.length === 1 ? { pre: '[', post: `${this.#space}]` } : { pre: '[', sep: this.#space, post: ']' });
|
|
119
|
+
}
|
|
120
|
+
/* NOT FOR BROWSER */
|
|
121
|
+
cloneNode() {
|
|
122
|
+
const [url, text] = this.cloneChildNodes();
|
|
123
|
+
return debug_1.Shadow.run(() => {
|
|
124
|
+
// @ts-expect-error abstract class
|
|
125
|
+
const token = new ExtLinkToken(undefined, this.#space, '', this.getAttribute('config'));
|
|
126
|
+
token.firstChild.safeReplaceWith(url);
|
|
127
|
+
if (text) {
|
|
128
|
+
token.insertAt(text);
|
|
145
129
|
}
|
|
146
|
-
return
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
130
|
+
return token;
|
|
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 = ' ';
|
|
151
144
|
}
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Set the text of the link
|
|
148
|
+
*
|
|
149
|
+
* 设置链接显示文字
|
|
150
|
+
* @param str text of the link / 链接显示文字
|
|
151
|
+
*/
|
|
152
|
+
setLinkText(str) {
|
|
153
|
+
const root = index_1.default
|
|
154
|
+
.parse(str, this.getAttribute('include'), 7, this.getAttribute('config'));
|
|
155
|
+
if (this.length === 1) {
|
|
156
|
+
root.type = 'ext-link-text';
|
|
157
|
+
root.setAttribute('acceptable', {
|
|
158
|
+
'Stage-7': ':', ConverterToken: ':',
|
|
163
159
|
});
|
|
160
|
+
this.insertAt(root);
|
|
164
161
|
}
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
const { lastChild, length } = this, { firstChild } = lastChild;
|
|
168
|
-
if (!this.#space
|
|
169
|
-
&& length > 1
|
|
170
|
-
&& (firstChild?.type === 'text' || firstChild?.type === 'converter')
|
|
171
|
-
// 都替换成`<`肯定不对,但无妨
|
|
172
|
-
// eslint-disable-next-line es-x/no-regexp-unicode-property-escapes
|
|
173
|
-
&& /^[^[\]<>"\0-\x1F\x7F\p{Zs}\uFFFD]/u
|
|
174
|
-
.test(lastChild.text().replace(/&[lg]t;/u, '<'))) {
|
|
175
|
-
this.#space = ' ';
|
|
176
|
-
}
|
|
162
|
+
else {
|
|
163
|
+
this.lastChild.replaceChildren(...root.childNodes);
|
|
177
164
|
}
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
this.insertAt(root);
|
|
193
|
-
}
|
|
194
|
-
else {
|
|
195
|
-
this.lastChild.replaceChildren(...root.childNodes);
|
|
165
|
+
this.#space ||= ' ';
|
|
166
|
+
}
|
|
167
|
+
/** @private */
|
|
168
|
+
toHtmlInternal(opt) {
|
|
169
|
+
const { length, lastChild } = this;
|
|
170
|
+
let innerText, href;
|
|
171
|
+
if (length > 1) {
|
|
172
|
+
lastChild.normalize();
|
|
173
|
+
const { childNodes } = lastChild, i = childNodes.findIndex(child => child.type === 'link'
|
|
174
|
+
|| child.is('file')
|
|
175
|
+
&& child.getValue('link')?.trim() !== '');
|
|
176
|
+
if (i !== -1) {
|
|
177
|
+
const after = childNodes.slice(i);
|
|
178
|
+
this.after(...after);
|
|
196
179
|
}
|
|
197
|
-
|
|
180
|
+
innerText = lastChild.toHtmlInternal(opt);
|
|
198
181
|
}
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
lastChild.normalize();
|
|
205
|
-
const { childNodes } = lastChild, i = childNodes.findIndex(child => child.type === 'link'
|
|
206
|
-
|| child.is('file')
|
|
207
|
-
&& child.getValue('link')?.trim() !== '');
|
|
208
|
-
if (i !== -1) {
|
|
209
|
-
const after = childNodes.slice(i);
|
|
210
|
-
this.after(...after);
|
|
211
|
-
}
|
|
212
|
-
innerText = lastChild.toHtmlInternal(opt);
|
|
213
|
-
}
|
|
214
|
-
else {
|
|
215
|
-
({ innerText } = this);
|
|
216
|
-
}
|
|
217
|
-
try {
|
|
218
|
-
({ href } = this.getUrl());
|
|
219
|
-
}
|
|
220
|
-
catch { }
|
|
221
|
-
return `<a rel="nofollow" class="external"${href === undefined ? '' : ` href="${href}"`}>${innerText}</a>`;
|
|
182
|
+
else {
|
|
183
|
+
({ innerText } = this);
|
|
184
|
+
}
|
|
185
|
+
try {
|
|
186
|
+
({ href } = this.getUrl());
|
|
222
187
|
}
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
}
|
|
188
|
+
catch { }
|
|
189
|
+
return `<a rel="nofollow" class="external"${href === undefined ? '' : ` href="${href}"`}>${innerText}</a>`;
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Get the URL
|
|
193
|
+
*
|
|
194
|
+
* 获取网址
|
|
195
|
+
*/
|
|
196
|
+
getUrl() {
|
|
197
|
+
return this.firstChild.getUrl();
|
|
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
|
+
}
|
|
226
209
|
exports.ExtLinkToken = ExtLinkToken;
|
|
227
210
|
constants_1.classes['ExtLinkToken'] = __filename;
|
package/dist/src/gallery.js
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.GalleryToken = void 0;
|
|
4
|
-
const index_1 = require("../index");
|
|
7
|
+
const index_1 = __importDefault(require("../index"));
|
|
5
8
|
const index_2 = require("./index");
|
|
6
9
|
const galleryImage_1 = require("./link/galleryImage");
|
|
7
10
|
const noinclude_1 = require("./nowiki/noinclude");
|
|
@@ -81,8 +84,9 @@ class GalleryToken extends index_2.Token {
|
|
|
81
84
|
/** @private */
|
|
82
85
|
lint(start = this.getAbsoluteIndex(), re) {
|
|
83
86
|
const { top, left } = this.getRootNode().posFromIndex(start), errors = [];
|
|
84
|
-
for (
|
|
85
|
-
const str = child.toString(), { length } = str, trimmed = str.trim(), { type } = child, startLine = top + i, startCol = i ? 0 : left;
|
|
87
|
+
for (let i = 0; i < this.length; i++) {
|
|
88
|
+
const child = this.childNodes[i], str = child.toString(), { length } = str, trimmed = str.trim(), { type } = child, startLine = top + i, startCol = i ? 0 : left;
|
|
89
|
+
child.setAttribute('aIndex', start);
|
|
86
90
|
if (type === 'noinclude' && trimmed && !/^<!--.*-->$/u.test(trimmed)) {
|
|
87
91
|
const endIndex = start + length;
|
|
88
92
|
errors.push({
|
package/dist/src/heading.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import Parser from '../index';
|
|
2
1
|
import { Token } from './index';
|
|
3
2
|
import { SyntaxToken } from './syntax';
|
|
4
|
-
import type { LintError, AST } from '../base';
|
|
3
|
+
import type { Config, LintError, AST } from '../base';
|
|
5
4
|
import type { AstText } from '../internal';
|
|
6
5
|
/**
|
|
7
6
|
* section heading
|
|
@@ -32,7 +31,7 @@ export declare abstract class HeadingToken extends Token {
|
|
|
32
31
|
* @param level 标题层级
|
|
33
32
|
* @param input 标题文字
|
|
34
33
|
*/
|
|
35
|
-
constructor(level: number, input: readonly [string?, string?], config
|
|
34
|
+
constructor(level: number, input: readonly [string?, string?], config: Config, accum?: Token[]);
|
|
36
35
|
cloneNode(): this;
|
|
37
36
|
/**
|
|
38
37
|
* Set the level of heading
|
package/dist/src/heading.js
CHANGED
|
@@ -33,12 +33,15 @@ var __runInitializers = (this && this.__runInitializers) || function (thisArg, i
|
|
|
33
33
|
}
|
|
34
34
|
return useValue ? value : void 0;
|
|
35
35
|
};
|
|
36
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
37
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
38
|
+
};
|
|
36
39
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
37
40
|
exports.HeadingToken = void 0;
|
|
38
41
|
const lint_1 = require("../util/lint");
|
|
39
42
|
const debug_1 = require("../util/debug");
|
|
40
43
|
const rect_1 = require("../lib/rect");
|
|
41
|
-
const index_1 = require("../index");
|
|
44
|
+
const index_1 = __importDefault(require("../index"));
|
|
42
45
|
const index_2 = require("./index");
|
|
43
46
|
const syntax_1 = require("./syntax");
|
|
44
47
|
/* NOT FOR BROWSER */
|
|
@@ -103,7 +106,7 @@ let HeadingToken = (() => {
|
|
|
103
106
|
* @param level 标题层级
|
|
104
107
|
* @param input 标题文字
|
|
105
108
|
*/
|
|
106
|
-
constructor(level, input, config
|
|
109
|
+
constructor(level, input, config, accum = []) {
|
|
107
110
|
super(undefined, config, accum);
|
|
108
111
|
this.#level = level;
|
|
109
112
|
const token = new index_2.Token(input[0], config, accum);
|
|
@@ -172,9 +175,11 @@ let HeadingToken = (() => {
|
|
|
172
175
|
}
|
|
173
176
|
const rootStr = this.getRootNode().toString();
|
|
174
177
|
if (boldQuotes.length % 2) {
|
|
175
|
-
const e = (0, lint_1.generateForChild)(boldQuotes[boldQuotes.length - 1],
|
|
176
|
-
|
|
177
|
-
|
|
178
|
+
const e = (0, lint_1.generateForChild)(boldQuotes[boldQuotes.length - 1], {
|
|
179
|
+
...rect, // eslint-disable-line @typescript-eslint/no-misused-spread
|
|
180
|
+
start: start + level,
|
|
181
|
+
left: rect.left + level,
|
|
182
|
+
}, 'format-leakage', index_1.default.msg('unbalanced $1 in a section header', 'bold apostrophes')), end = start + level + innerStr.length;
|
|
178
183
|
if (rootStr.slice(e.endIndex, end).trim()) {
|
|
179
184
|
e.suggestions = [{ desc: 'close', range: [end, end], text: "'''" }];
|
|
180
185
|
}
|
package/dist/src/html.d.ts
CHANGED
|
@@ -39,9 +39,6 @@ export declare abstract class HtmlToken extends Token {
|
|
|
39
39
|
* Find the matching tag
|
|
40
40
|
*
|
|
41
41
|
* 搜索匹配的标签
|
|
42
|
-
* @throws `SyntaxError` 同时闭合和自封闭的标签
|
|
43
|
-
* @throws `SyntaxError` 无效自封闭标签
|
|
44
|
-
* @throws `SyntaxError` 未匹配的标签
|
|
45
42
|
*/
|
|
46
43
|
findMatchingTag(): this | undefined;
|
|
47
44
|
cloneNode(): this;
|