wikiparser-node 1.12.5-b → 1.12.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/config/.schema.json +203 -0
- package/config/default.json +30 -29
- package/config/enwiki.json +829 -15
- package/config/llwiki.json +56 -21
- package/config/moegirl.json +65 -21
- package/config/zhwiki.json +494 -28
- package/dist/addon/table.js +494 -0
- package/dist/addon/token.js +392 -0
- package/dist/addon/transclude.js +184 -0
- package/dist/base.d.ts +82 -0
- package/dist/base.js +40 -0
- package/dist/index.d.ts +33 -0
- package/dist/index.js +275 -0
- package/dist/internal.d.ts +47 -0
- package/dist/lib/element.d.ts +125 -0
- package/dist/lib/element.js +377 -0
- package/dist/lib/node.d.ts +173 -0
- package/dist/lib/node.js +478 -0
- package/dist/lib/range.d.ts +105 -0
- package/dist/lib/range.js +406 -0
- package/dist/lib/ranges.d.ts +28 -0
- package/dist/lib/ranges.js +126 -0
- package/dist/lib/rect.d.ts +18 -0
- package/dist/lib/rect.js +36 -0
- package/dist/lib/text.d.ts +58 -0
- package/dist/lib/text.js +414 -0
- package/dist/lib/title.d.ts +49 -0
- package/dist/lib/title.js +253 -0
- package/dist/mixin/attributesParent.d.ts +49 -0
- package/dist/mixin/attributesParent.js +80 -0
- package/dist/mixin/fixed.d.ts +5 -0
- package/dist/mixin/fixed.js +32 -0
- package/dist/mixin/flagsParent.d.ts +43 -0
- package/dist/mixin/flagsParent.js +64 -0
- package/dist/mixin/hidden.d.ts +7 -0
- package/dist/mixin/hidden.js +39 -0
- package/dist/mixin/magicLinkParent.d.ts +19 -0
- package/dist/mixin/magicLinkParent.js +43 -0
- package/dist/mixin/singleLine.d.ts +5 -0
- package/dist/mixin/singleLine.js +25 -0
- package/dist/mixin/sol.d.ts +6 -0
- package/dist/mixin/sol.js +45 -0
- package/dist/mixin/syntax.d.ts +8 -0
- package/dist/mixin/syntax.js +46 -0
- package/dist/parser/braces.js +152 -0
- package/dist/parser/commentAndExt.js +84 -0
- package/dist/parser/converter.js +41 -0
- package/dist/parser/externalLinks.js +39 -0
- package/dist/parser/hrAndDoubleUnderscore.js +44 -0
- package/dist/parser/html.js +40 -0
- package/dist/parser/links.js +103 -0
- package/dist/parser/list.js +116 -0
- package/dist/parser/magicLinks.js +55 -0
- package/dist/parser/quotes.js +69 -0
- package/dist/parser/redirect.js +28 -0
- package/dist/parser/selector.js +393 -0
- package/dist/parser/table.js +125 -0
- package/dist/src/arg.d.ts +49 -0
- package/dist/src/arg.js +220 -0
- package/dist/src/atom.d.ts +14 -0
- package/dist/src/atom.js +54 -0
- package/dist/src/attribute.d.ts +64 -0
- package/dist/src/attribute.js +482 -0
- package/dist/src/attributes.d.ts +103 -0
- package/dist/src/attributes.js +380 -0
- package/dist/src/converter.d.ts +28 -0
- package/dist/src/converter.js +153 -0
- package/dist/src/converterFlags.d.ts +80 -0
- package/dist/src/converterFlags.js +241 -0
- package/dist/src/converterRule.d.ts +71 -0
- package/dist/src/converterRule.js +218 -0
- package/dist/src/extLink.d.ts +36 -0
- package/dist/src/extLink.js +223 -0
- package/dist/src/gallery.d.ts +51 -0
- package/dist/src/gallery.js +166 -0
- package/dist/src/heading.d.ts +44 -0
- package/dist/src/heading.js +222 -0
- package/dist/src/hidden.d.ts +9 -0
- package/dist/src/hidden.js +82 -0
- package/dist/src/html.d.ts +61 -0
- package/dist/src/html.js +344 -0
- package/dist/src/imageParameter.d.ts +60 -0
- package/dist/src/imageParameter.js +262 -0
- package/dist/src/imagemap.d.ts +47 -0
- package/dist/src/imagemap.js +148 -0
- package/dist/src/imagemapLink.d.ts +35 -0
- package/dist/src/imagemapLink.js +99 -0
- package/dist/src/index.d.ts +136 -0
- package/dist/src/index.js +790 -0
- package/dist/src/link/base.d.ts +52 -0
- package/dist/src/link/base.js +258 -0
- package/dist/src/link/category.d.ts +22 -0
- package/dist/src/link/category.js +36 -0
- package/dist/src/link/file.d.ts +102 -0
- package/dist/src/link/file.js +345 -0
- package/dist/src/link/galleryImage.d.ts +29 -0
- package/dist/src/link/galleryImage.js +133 -0
- package/dist/src/link/index.d.ts +39 -0
- package/dist/src/link/index.js +100 -0
- package/dist/src/link/redirectTarget.d.ts +27 -0
- package/dist/src/link/redirectTarget.js +71 -0
- package/dist/src/magicLink.d.ts +57 -0
- package/dist/src/magicLink.js +261 -0
- package/dist/src/nested.d.ts +40 -0
- package/dist/src/nested.js +108 -0
- package/dist/src/nowiki/base.d.ts +28 -0
- package/dist/src/nowiki/base.js +90 -0
- package/dist/src/nowiki/comment.d.ts +14 -0
- package/dist/src/nowiki/comment.js +123 -0
- package/dist/src/nowiki/dd.d.ts +8 -0
- package/dist/src/nowiki/dd.js +74 -0
- package/dist/src/nowiki/doubleUnderscore.d.ts +15 -0
- package/dist/src/nowiki/doubleUnderscore.js +101 -0
- package/dist/src/nowiki/hr.d.ts +5 -0
- package/dist/src/nowiki/hr.js +72 -0
- package/dist/src/nowiki/index.d.ts +14 -0
- package/dist/src/nowiki/index.js +30 -0
- package/dist/src/nowiki/list.d.ts +5 -0
- package/dist/src/nowiki/list.js +67 -0
- package/dist/src/nowiki/listBase.d.ts +23 -0
- package/dist/src/nowiki/listBase.js +100 -0
- package/dist/src/nowiki/noinclude.d.ts +6 -0
- package/dist/src/nowiki/noinclude.js +77 -0
- package/dist/src/nowiki/quote.d.ts +14 -0
- package/dist/src/nowiki/quote.js +149 -0
- package/dist/src/onlyinclude.d.ts +13 -0
- package/dist/src/onlyinclude.js +60 -0
- package/dist/src/paramTag/index.d.ts +28 -0
- package/dist/src/paramTag/index.js +80 -0
- package/dist/src/paramTag/inputbox.d.ts +8 -0
- package/dist/src/paramTag/inputbox.js +24 -0
- package/dist/src/parameter.d.ts +60 -0
- package/dist/src/parameter.js +267 -0
- package/dist/src/pre.d.ts +28 -0
- package/dist/src/pre.js +62 -0
- package/dist/src/redirect.d.ts +30 -0
- package/dist/src/redirect.js +128 -0
- package/dist/src/syntax.d.ts +15 -0
- package/dist/src/syntax.js +87 -0
- package/dist/src/table/base.d.ts +28 -0
- package/dist/src/table/base.js +81 -0
- package/dist/src/table/index.d.ts +230 -0
- package/dist/src/table/index.js +506 -0
- package/dist/src/table/td.d.ts +72 -0
- package/dist/src/table/td.js +375 -0
- package/dist/src/table/tr.d.ts +30 -0
- package/dist/src/table/tr.js +61 -0
- package/dist/src/table/trBase.d.ts +49 -0
- package/dist/src/table/trBase.js +165 -0
- package/dist/src/tagPair/ext.d.ts +29 -0
- package/dist/src/tagPair/ext.js +229 -0
- package/dist/src/tagPair/include.d.ts +33 -0
- package/dist/src/tagPair/include.js +132 -0
- package/dist/src/tagPair/index.d.ts +23 -0
- package/dist/src/tagPair/index.js +130 -0
- package/dist/src/transclude.d.ts +159 -0
- package/dist/src/transclude.js +598 -0
- package/dist/util/constants.js +26 -0
- package/dist/util/debug.js +95 -0
- package/dist/util/diff.js +83 -0
- package/dist/util/html.js +146 -0
- package/dist/util/lint.js +32 -0
- package/dist/util/string.js +107 -0
- package/errors/README +3 -0
- package/package.json +21 -28
- package/printed/README +3 -0
- package/bundle/bundle.min.js +0 -37
- package/extensions/dist/base.js +0 -163
- package/extensions/dist/codejar.js +0 -52
- package/extensions/dist/editor.js +0 -159
- package/extensions/dist/highlight.js +0 -30
- package/extensions/dist/lint.js +0 -72
- package/extensions/editor.css +0 -59
- package/extensions/ui.css +0 -162
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import Parser from '../index';
|
|
2
|
+
import { Token } from './index';
|
|
3
|
+
import { NoincludeToken } from './nowiki/noinclude';
|
|
4
|
+
import { GalleryImageToken } from './link/galleryImage';
|
|
5
|
+
import { ImagemapLinkToken } from './imagemapLink';
|
|
6
|
+
import type { LintError } from '../base';
|
|
7
|
+
import type { AstText, AttributesToken, ExtToken, AstNodes } from '../internal';
|
|
8
|
+
/**
|
|
9
|
+
* `<imagemap>`
|
|
10
|
+
* @classdesc `{childNodes: ...NoincludeToken, GalleryImageToken, ...(NoincludeToken|ImagemapLinkToken|AstText)}`
|
|
11
|
+
*/
|
|
12
|
+
export declare abstract class ImagemapToken extends Token {
|
|
13
|
+
readonly name: 'imagemap';
|
|
14
|
+
readonly childNodes: readonly (GalleryImageToken | NoincludeToken | ImagemapLinkToken | AstText)[];
|
|
15
|
+
abstract get firstChild(): NoincludeToken | GalleryImageToken | undefined;
|
|
16
|
+
abstract get lastChild(): GalleryImageToken | NoincludeToken | ImagemapLinkToken | AstText | undefined;
|
|
17
|
+
abstract get nextSibling(): undefined;
|
|
18
|
+
abstract get previousSibling(): AttributesToken;
|
|
19
|
+
abstract get parentNode(): ExtToken | undefined;
|
|
20
|
+
abstract get children(): (GalleryImageToken | NoincludeToken | ImagemapLinkToken)[];
|
|
21
|
+
abstract get firstElementChild(): NoincludeToken | GalleryImageToken | undefined;
|
|
22
|
+
abstract get lastElementChild(): GalleryImageToken | NoincludeToken | ImagemapLinkToken | undefined;
|
|
23
|
+
abstract get nextElementSibling(): undefined;
|
|
24
|
+
abstract get previousElementSibling(): AttributesToken;
|
|
25
|
+
abstract get parentElement(): ExtToken | undefined;
|
|
26
|
+
get type(): 'ext-inner';
|
|
27
|
+
/** 图片 */
|
|
28
|
+
get image(): GalleryImageToken | undefined;
|
|
29
|
+
/** @param inner 标签内部wikitext */
|
|
30
|
+
constructor(inner?: string, config?: Parser.Config, accum?: Token[]);
|
|
31
|
+
/**
|
|
32
|
+
* @override
|
|
33
|
+
* @param token 待插入的节点
|
|
34
|
+
* @param i 插入位置
|
|
35
|
+
* @throws `Error` 当前缺少合法图片
|
|
36
|
+
* @throws `RangeError` 已有一张合法图片
|
|
37
|
+
*/
|
|
38
|
+
insertAt(token: string, i?: number): AstText;
|
|
39
|
+
insertAt<T extends AstNodes>(token: T, i?: number): T;
|
|
40
|
+
/**
|
|
41
|
+
* @override
|
|
42
|
+
* @param i 移除位置
|
|
43
|
+
* @throws `Error` 禁止移除图片
|
|
44
|
+
*/
|
|
45
|
+
removeAt(i: number): AstNodes;
|
|
46
|
+
cloneNode(): this;
|
|
47
|
+
}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ImagemapToken = void 0;
|
|
4
|
+
const lint_1 = require("../util/lint");
|
|
5
|
+
const debug_1 = require("../util/debug");
|
|
6
|
+
const rect_1 = require("../lib/rect");
|
|
7
|
+
const index_1 = require("../index");
|
|
8
|
+
const index_2 = require("./index");
|
|
9
|
+
const noinclude_1 = require("./nowiki/noinclude");
|
|
10
|
+
const galleryImage_1 = require("./link/galleryImage");
|
|
11
|
+
const imagemapLink_1 = require("./imagemapLink");
|
|
12
|
+
/* NOT FOR BROWSER */
|
|
13
|
+
const constants_1 = require("../util/constants");
|
|
14
|
+
const singleLine_1 = require("../mixin/singleLine");
|
|
15
|
+
/* NOT FOR BROWSER END */
|
|
16
|
+
/**
|
|
17
|
+
* `<imagemap>`
|
|
18
|
+
* @classdesc `{childNodes: ...NoincludeToken, GalleryImageToken, ...(NoincludeToken|ImagemapLinkToken|AstText)}`
|
|
19
|
+
*/
|
|
20
|
+
class ImagemapToken extends index_2.Token {
|
|
21
|
+
/* NOT FOR BROWSER END */
|
|
22
|
+
get type() {
|
|
23
|
+
return 'ext-inner';
|
|
24
|
+
}
|
|
25
|
+
/** 图片 */
|
|
26
|
+
get image() {
|
|
27
|
+
return this.childNodes.find((0, debug_1.isToken)('imagemap-image'));
|
|
28
|
+
}
|
|
29
|
+
/** @param inner 标签内部wikitext */
|
|
30
|
+
constructor(inner, config = index_1.default.getConfig(), accum = []) {
|
|
31
|
+
super(undefined, config, accum, {
|
|
32
|
+
GalleryImageToken: ':', ImagemapLinkToken: ':', NoincludeToken: ':', AstText: ':',
|
|
33
|
+
});
|
|
34
|
+
if (!inner) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
const lines = inner.split('\n'), protocols = new Set(config.protocol.split('|')), SingleLineNoincludeToken = (0, singleLine_1.singleLine)(noinclude_1.NoincludeToken);
|
|
38
|
+
let first = true, error = false;
|
|
39
|
+
for (const line of lines) {
|
|
40
|
+
const trimmed = line.trim();
|
|
41
|
+
if (error || !trimmed || trimmed.startsWith('#')) {
|
|
42
|
+
//
|
|
43
|
+
}
|
|
44
|
+
else if (first) {
|
|
45
|
+
const [file, ...options] = line.split('|'), title = this.normalizeTitle(file, 0, true);
|
|
46
|
+
if (title.valid && !title.interwiki && title.ns === 6) {
|
|
47
|
+
// @ts-expect-error abstract class
|
|
48
|
+
const token = new galleryImage_1.GalleryImageToken('imagemap', file, options.length > 0 ? options.join('|') : undefined, config, accum);
|
|
49
|
+
super.insertAt(token);
|
|
50
|
+
first = false;
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
error = true;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
else if (line.trim().split(/[\t ]/u)[0] === 'desc') {
|
|
58
|
+
super.insertAt(line);
|
|
59
|
+
continue;
|
|
60
|
+
}
|
|
61
|
+
else if (line.includes('[')) {
|
|
62
|
+
const i = line.indexOf('['), substr = line.slice(i), mtIn = /^\[\[([^|]+)(?:\|([^\]]+))?\]\][\w\s]*$/u
|
|
63
|
+
.exec(substr);
|
|
64
|
+
if (mtIn) {
|
|
65
|
+
if (this.normalizeTitle(mtIn[1], 0, true, false, true).valid) {
|
|
66
|
+
// @ts-expect-error abstract class
|
|
67
|
+
super.insertAt(new imagemapLink_1.ImagemapLinkToken(line.slice(0, i), mtIn.slice(1), substr.slice(substr.indexOf(']]') + 2), config, accum));
|
|
68
|
+
continue;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
else if (protocols.has(substr.slice(1, substr.indexOf(':') + 1))
|
|
72
|
+
|| protocols.has(substr.slice(1, substr.indexOf('//') + 2))) {
|
|
73
|
+
const mtEx = /^\[([^\]\s]+)(?:(\s+(?!\s))([^\]]*))?\][\w\s]*$/u
|
|
74
|
+
.exec(substr);
|
|
75
|
+
if (mtEx) {
|
|
76
|
+
// @ts-expect-error abstract class
|
|
77
|
+
super.insertAt(new imagemapLink_1.ImagemapLinkToken(line.slice(0, i), mtEx.slice(1), substr.slice(substr.indexOf(']') + 1), config, accum));
|
|
78
|
+
continue;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
// @ts-expect-error abstract class
|
|
83
|
+
super.insertAt(new SingleLineNoincludeToken(line, config, accum));
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
/** @private */
|
|
87
|
+
toString(skip) {
|
|
88
|
+
return super.toString(skip, '\n');
|
|
89
|
+
}
|
|
90
|
+
/** @private */
|
|
91
|
+
text() {
|
|
92
|
+
return super.text('\n').replace(/\n{2,}/gu, '\n');
|
|
93
|
+
}
|
|
94
|
+
/** @private */
|
|
95
|
+
getGaps() {
|
|
96
|
+
return 1;
|
|
97
|
+
}
|
|
98
|
+
/** @private */
|
|
99
|
+
lint(start = this.getAbsoluteIndex(), re) {
|
|
100
|
+
const errors = super.lint(start, re), rect = new rect_1.BoundingRect(this, start);
|
|
101
|
+
if (this.image) {
|
|
102
|
+
errors.push(...this.childNodes.filter(child => {
|
|
103
|
+
const str = child.toString().trim();
|
|
104
|
+
return child.type === 'noinclude' && str && !str.startsWith('#');
|
|
105
|
+
}).map(child => (0, lint_1.generateForChild)(child, rect, 'invalid-imagemap', 'invalid link in <imagemap>')));
|
|
106
|
+
}
|
|
107
|
+
else {
|
|
108
|
+
errors.push((0, lint_1.generateForSelf)(this, rect, 'invalid-imagemap', '<imagemap> without an image'));
|
|
109
|
+
}
|
|
110
|
+
return errors;
|
|
111
|
+
}
|
|
112
|
+
/** @private */
|
|
113
|
+
print() {
|
|
114
|
+
return super.print({ sep: '\n' });
|
|
115
|
+
}
|
|
116
|
+
insertAt(token, i) {
|
|
117
|
+
const { image } = this;
|
|
118
|
+
if (!image && (typeof token === 'string' || token.type === 'imagemap-link' || token.type === 'text')) {
|
|
119
|
+
throw new Error('Missing a valid image!');
|
|
120
|
+
}
|
|
121
|
+
else if (image && typeof token !== 'string' && token.type === 'imagemap-image') {
|
|
122
|
+
throw new RangeError('Already have a valid image!');
|
|
123
|
+
}
|
|
124
|
+
return super.insertAt(token, i);
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* @override
|
|
128
|
+
* @param i 移除位置
|
|
129
|
+
* @throws `Error` 禁止移除图片
|
|
130
|
+
*/
|
|
131
|
+
removeAt(i) {
|
|
132
|
+
if (this.childNodes[i]?.type === 'imagemap-image') {
|
|
133
|
+
throw new Error('Do not remove the image in <imagemap>!');
|
|
134
|
+
}
|
|
135
|
+
return super.removeAt(i);
|
|
136
|
+
}
|
|
137
|
+
cloneNode() {
|
|
138
|
+
const cloned = this.cloneChildNodes();
|
|
139
|
+
return debug_1.Shadow.run(() => {
|
|
140
|
+
// @ts-expect-error abstract class
|
|
141
|
+
const token = new ImagemapToken(undefined, this.getAttribute('config'));
|
|
142
|
+
token.append(...cloned);
|
|
143
|
+
return token;
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
exports.ImagemapToken = ImagemapToken;
|
|
148
|
+
constants_1.classes['ImagemapToken'] = __filename;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import Parser from '../index';
|
|
2
|
+
import { Token } from './index';
|
|
3
|
+
import { NoincludeToken } from './nowiki/noinclude';
|
|
4
|
+
import { LinkToken } from './link/index';
|
|
5
|
+
import { ExtLinkToken } from './extLink';
|
|
6
|
+
import type { AstText, ImagemapToken, GalleryImageToken } from '../internal';
|
|
7
|
+
import type { Title } from '../lib/title';
|
|
8
|
+
/**
|
|
9
|
+
* `<imagemap>`内的链接
|
|
10
|
+
* @classdesc `{childNodes: [AstText, LinkToken|ExtLinkToken, NoincludeToken]}`
|
|
11
|
+
*/
|
|
12
|
+
export declare abstract class ImagemapLinkToken extends Token {
|
|
13
|
+
readonly childNodes: readonly [AstText, LinkToken | ExtLinkToken, NoincludeToken];
|
|
14
|
+
abstract get firstChild(): AstText;
|
|
15
|
+
abstract get lastChild(): NoincludeToken;
|
|
16
|
+
abstract get parentNode(): ImagemapToken | undefined;
|
|
17
|
+
abstract get previousSibling(): GalleryImageToken | this | NoincludeToken | AstText;
|
|
18
|
+
abstract get nextSibling(): this | NoincludeToken | AstText | undefined;
|
|
19
|
+
abstract get children(): [LinkToken | ExtLinkToken, NoincludeToken];
|
|
20
|
+
abstract get firstElementChild(): LinkToken | ExtLinkToken;
|
|
21
|
+
abstract get lastElementChild(): NoincludeToken;
|
|
22
|
+
abstract get parentElement(): ImagemapToken | undefined;
|
|
23
|
+
abstract get previousElementSibling(): GalleryImageToken | this | NoincludeToken;
|
|
24
|
+
abstract get nextElementSibling(): this | NoincludeToken | undefined;
|
|
25
|
+
get type(): 'imagemap-link';
|
|
26
|
+
/** 内外链接 */
|
|
27
|
+
get link(): string | Title;
|
|
28
|
+
set link(link: string);
|
|
29
|
+
/**
|
|
30
|
+
* @param pre 链接前的文本
|
|
31
|
+
* @param linkStuff 内外链接
|
|
32
|
+
* @param post 链接后的文本
|
|
33
|
+
*/
|
|
34
|
+
constructor(pre: string, linkStuff: readonly [string, string | undefined, string | undefined] | readonly [string, string | undefined], post: string, config?: Parser.Config, accum?: Token[]);
|
|
35
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
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
|
+
};
|
|
36
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
37
|
+
exports.ImagemapLinkToken = void 0;
|
|
38
|
+
const index_1 = require("../index");
|
|
39
|
+
const index_2 = require("./index");
|
|
40
|
+
const noinclude_1 = require("./nowiki/noinclude");
|
|
41
|
+
const index_3 = require("./link/index");
|
|
42
|
+
const extLink_1 = require("./extLink");
|
|
43
|
+
/* NOT FOR BROWSER */
|
|
44
|
+
const constants_1 = require("../util/constants");
|
|
45
|
+
const fixed_1 = require("../mixin/fixed");
|
|
46
|
+
const singleLine_1 = require("../mixin/singleLine");
|
|
47
|
+
/* NOT FOR BROWSER END */
|
|
48
|
+
/**
|
|
49
|
+
* `<imagemap>`内的链接
|
|
50
|
+
* @classdesc `{childNodes: [AstText, LinkToken|ExtLinkToken, NoincludeToken]}`
|
|
51
|
+
*/
|
|
52
|
+
let ImagemapLinkToken = (() => {
|
|
53
|
+
let _classDecorators = [fixed_1.fixedToken, singleLine_1.singleLine];
|
|
54
|
+
let _classDescriptor;
|
|
55
|
+
let _classExtraInitializers = [];
|
|
56
|
+
let _classThis;
|
|
57
|
+
let _classSuper = index_2.Token;
|
|
58
|
+
var ImagemapLinkToken = class extends _classSuper {
|
|
59
|
+
static { _classThis = this; }
|
|
60
|
+
static {
|
|
61
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
62
|
+
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
63
|
+
ImagemapLinkToken = _classThis = _classDescriptor.value;
|
|
64
|
+
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
65
|
+
__runInitializers(_classThis, _classExtraInitializers);
|
|
66
|
+
}
|
|
67
|
+
/* NOT FOR BROWSER END */
|
|
68
|
+
get type() {
|
|
69
|
+
return 'imagemap-link';
|
|
70
|
+
}
|
|
71
|
+
/* NOT FOR BROWSER */
|
|
72
|
+
/** 内外链接 */
|
|
73
|
+
get link() {
|
|
74
|
+
return this.childNodes[1].link;
|
|
75
|
+
}
|
|
76
|
+
set link(link) {
|
|
77
|
+
this.childNodes[1].link = link;
|
|
78
|
+
}
|
|
79
|
+
/* NOT FOR BROWSER END */
|
|
80
|
+
/**
|
|
81
|
+
* @param pre 链接前的文本
|
|
82
|
+
* @param linkStuff 内外链接
|
|
83
|
+
* @param post 链接后的文本
|
|
84
|
+
*/
|
|
85
|
+
constructor(pre, linkStuff, post, config = index_1.default.getConfig(), accum = []) {
|
|
86
|
+
super(undefined, config, accum);
|
|
87
|
+
this.append(pre, linkStuff.length === 2
|
|
88
|
+
// @ts-expect-error abstract class
|
|
89
|
+
? new index_3.LinkToken(...linkStuff, config, accum)
|
|
90
|
+
// @ts-expect-error abstract class
|
|
91
|
+
: new extLink_1.ExtLinkToken(...linkStuff, config, accum),
|
|
92
|
+
// @ts-expect-error abstract class
|
|
93
|
+
new noinclude_1.NoincludeToken(post, config, accum));
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
return ImagemapLinkToken = _classThis;
|
|
97
|
+
})();
|
|
98
|
+
exports.ImagemapLinkToken = ImagemapLinkToken;
|
|
99
|
+
constants_1.classes['ImagemapLinkToken'] = __filename;
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import Parser from '../index';
|
|
2
|
+
import { AstElement } from '../lib/element';
|
|
3
|
+
import { AstText } from '../lib/text';
|
|
4
|
+
import type { LintError, TokenTypes } from '../base';
|
|
5
|
+
import type { Title } from '../lib/title';
|
|
6
|
+
import type { AstNodes, IncludeToken, HtmlToken, ExtToken, TranscludeToken, CommentToken, FileToken, LinkToken, RedirectTargetToken, ExtLinkToken, MagicLinkToken, ImageParameterToken } from '../internal';
|
|
7
|
+
import { Ranges } from '../lib/ranges';
|
|
8
|
+
import { AstRange } from '../lib/range';
|
|
9
|
+
import type { Range } from '../lib/ranges';
|
|
10
|
+
import type { CaretPosition } from '../lib/node';
|
|
11
|
+
export type TagToken = IncludeToken | ExtToken | HtmlToken;
|
|
12
|
+
/**
|
|
13
|
+
* 所有节点的基类
|
|
14
|
+
* @classdesc `{childNodes: ...(AstText|Token)}`
|
|
15
|
+
*/
|
|
16
|
+
export declare class Token extends AstElement {
|
|
17
|
+
#private;
|
|
18
|
+
get type(): TokenTypes;
|
|
19
|
+
set type(value: TokenTypes);
|
|
20
|
+
/** 所有图片,包括图库 */
|
|
21
|
+
get images(): FileToken[];
|
|
22
|
+
/** 所有内链、外链和自由外链 */
|
|
23
|
+
get links(): (LinkToken | RedirectTargetToken | ExtLinkToken | MagicLinkToken | ImageParameterToken)[];
|
|
24
|
+
/** 所有模板和模块 */
|
|
25
|
+
get embeds(): TranscludeToken[];
|
|
26
|
+
/** @class */
|
|
27
|
+
constructor(wikitext?: string, config?: Parser.Config, accum?: Token[], acceptable?: Acceptable);
|
|
28
|
+
/**
|
|
29
|
+
* @override
|
|
30
|
+
* @param child 待插入的子节点
|
|
31
|
+
* @param i 插入位置
|
|
32
|
+
*/
|
|
33
|
+
insertAt(child: string, i?: number): AstText;
|
|
34
|
+
insertAt<T extends AstNodes>(child: T, i?: number): T;
|
|
35
|
+
/**
|
|
36
|
+
* @override
|
|
37
|
+
* @param i 移除位置
|
|
38
|
+
*/
|
|
39
|
+
removeAt(i: number): AstNodes;
|
|
40
|
+
/**
|
|
41
|
+
* 替换为同类节点
|
|
42
|
+
* @param token 待替换的节点
|
|
43
|
+
* @throws `Error` 不存在父节点
|
|
44
|
+
*/
|
|
45
|
+
safeReplaceWith(token: this): void;
|
|
46
|
+
/**
|
|
47
|
+
* 创建HTML注释
|
|
48
|
+
* @param data 注释内容
|
|
49
|
+
*/
|
|
50
|
+
createComment(data?: string): CommentToken;
|
|
51
|
+
/**
|
|
52
|
+
* 创建标签
|
|
53
|
+
* @param tagName 标签名
|
|
54
|
+
* @param options 选项
|
|
55
|
+
* @param options.selfClosing 是否自封闭
|
|
56
|
+
* @param options.closing 是否是闭合标签
|
|
57
|
+
* @throws `RangeError` 非法的标签名
|
|
58
|
+
*/
|
|
59
|
+
createElement(tagName: string, options?: {
|
|
60
|
+
selfClosing?: boolean;
|
|
61
|
+
closing?: boolean;
|
|
62
|
+
}): TagToken;
|
|
63
|
+
/**
|
|
64
|
+
* 创建纯文本节点
|
|
65
|
+
* @param data 文本内容
|
|
66
|
+
*/
|
|
67
|
+
createTextNode(data?: string): AstText;
|
|
68
|
+
/** 创建AstRange对象 */
|
|
69
|
+
createRange(): AstRange;
|
|
70
|
+
/**
|
|
71
|
+
* 找到给定位置
|
|
72
|
+
* @param index 位置
|
|
73
|
+
*/
|
|
74
|
+
caretPositionFromIndex(index?: number): CaretPosition | undefined;
|
|
75
|
+
/**
|
|
76
|
+
* 找到给定位置
|
|
77
|
+
* @param x 列数
|
|
78
|
+
* @param y 行数
|
|
79
|
+
*/
|
|
80
|
+
caretPositionFromPoint(x: number, y: number): CaretPosition | undefined;
|
|
81
|
+
/**
|
|
82
|
+
* 找到给定位置所在的最外层节点
|
|
83
|
+
* @param index 位置
|
|
84
|
+
*/
|
|
85
|
+
elementFromIndex(index?: number): AstNodes | undefined;
|
|
86
|
+
/**
|
|
87
|
+
* 找到给定位置所在的最外层节点
|
|
88
|
+
* @param x 列数
|
|
89
|
+
* @param y 行数
|
|
90
|
+
*/
|
|
91
|
+
elementFromPoint(x: number, y: number): AstNodes | undefined;
|
|
92
|
+
/**
|
|
93
|
+
* 找到给定位置所在的所有节点
|
|
94
|
+
* @param index 位置
|
|
95
|
+
*/
|
|
96
|
+
elementsFromIndex(index?: number): AstNodes[];
|
|
97
|
+
/**
|
|
98
|
+
* 找到给定位置所在的所有节点
|
|
99
|
+
* @param x 列数
|
|
100
|
+
* @param y 行数
|
|
101
|
+
*/
|
|
102
|
+
elementsFromPoint(x: number, y: number): AstNodes[];
|
|
103
|
+
/**
|
|
104
|
+
* 判断标题是否是跨维基链接
|
|
105
|
+
* @param title 标题
|
|
106
|
+
*/
|
|
107
|
+
isInterwiki(title: string): RegExpExecArray | null;
|
|
108
|
+
/** 深拷贝节点 */
|
|
109
|
+
cloneNode(): this;
|
|
110
|
+
/** 获取全部章节 */
|
|
111
|
+
sections(): AstRange[] | undefined;
|
|
112
|
+
/**
|
|
113
|
+
* 获取指定章节
|
|
114
|
+
* @param n 章节序号
|
|
115
|
+
*/
|
|
116
|
+
section(n: number): AstRange | undefined;
|
|
117
|
+
/**
|
|
118
|
+
* 获取指定的外层HTML标签
|
|
119
|
+
* @param tag HTML标签名
|
|
120
|
+
* @throws `RangeError` 非法的标签或空标签
|
|
121
|
+
*/
|
|
122
|
+
findEnclosingHtml(tag?: string): AstRange | undefined;
|
|
123
|
+
/** 获取全部分类 */
|
|
124
|
+
getCategories(): [string, string | undefined][];
|
|
125
|
+
/**
|
|
126
|
+
* 展开模板
|
|
127
|
+
* @param context 模板调用环境
|
|
128
|
+
*/
|
|
129
|
+
expand(): Token;
|
|
130
|
+
/** 解析部分魔术字 */
|
|
131
|
+
solveConst(): Token;
|
|
132
|
+
/** 合并普通节点的普通子节点 */
|
|
133
|
+
flatten(): void;
|
|
134
|
+
/** 生成HTML */
|
|
135
|
+
toHtml(): string;
|
|
136
|
+
}
|