wikiparser-node 1.9.3-b → 1.10.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.
Files changed (171) hide show
  1. package/config/.schema.json +186 -0
  2. package/config/enwiki.json +816 -2
  3. package/config/llwiki.json +37 -2
  4. package/config/moegirl.json +46 -2
  5. package/config/zhwiki.json +468 -2
  6. package/dist/addon/table.js +486 -0
  7. package/dist/addon/token.js +324 -0
  8. package/dist/addon/transclude.js +185 -0
  9. package/dist/base.d.ts +81 -0
  10. package/dist/base.js +39 -0
  11. package/dist/index.d.ts +33 -0
  12. package/dist/index.js +231 -0
  13. package/dist/internal.d.ts +46 -0
  14. package/dist/lib/element.d.ts +125 -0
  15. package/dist/lib/element.js +374 -0
  16. package/dist/lib/node.d.ts +173 -0
  17. package/dist/lib/node.js +478 -0
  18. package/dist/lib/range.d.ts +105 -0
  19. package/dist/lib/range.js +406 -0
  20. package/dist/lib/ranges.d.ts +28 -0
  21. package/dist/lib/ranges.js +126 -0
  22. package/dist/lib/rect.d.ts +18 -0
  23. package/dist/lib/rect.js +34 -0
  24. package/dist/lib/text.d.ts +58 -0
  25. package/dist/lib/text.js +361 -0
  26. package/dist/lib/title.d.ts +42 -0
  27. package/dist/lib/title.js +205 -0
  28. package/dist/mixin/attributesParent.d.ts +49 -0
  29. package/dist/mixin/attributesParent.js +79 -0
  30. package/dist/mixin/fixed.d.ts +5 -0
  31. package/dist/mixin/fixed.js +32 -0
  32. package/dist/mixin/flagsParent.d.ts +41 -0
  33. package/dist/mixin/flagsParent.js +60 -0
  34. package/dist/mixin/hidden.d.ts +7 -0
  35. package/dist/mixin/hidden.js +37 -0
  36. package/dist/mixin/magicLinkParent.d.ts +19 -0
  37. package/dist/mixin/magicLinkParent.js +43 -0
  38. package/dist/mixin/singleLine.d.ts +5 -0
  39. package/dist/mixin/singleLine.js +25 -0
  40. package/dist/mixin/sol.d.ts +6 -0
  41. package/dist/mixin/sol.js +44 -0
  42. package/dist/mixin/syntax.d.ts +8 -0
  43. package/dist/mixin/syntax.js +46 -0
  44. package/dist/parser/braces.js +150 -0
  45. package/dist/parser/commentAndExt.js +79 -0
  46. package/dist/parser/converter.js +39 -0
  47. package/dist/parser/externalLinks.js +37 -0
  48. package/dist/parser/hrAndDoubleUnderscore.js +42 -0
  49. package/dist/parser/html.js +38 -0
  50. package/dist/parser/links.js +101 -0
  51. package/dist/parser/list.js +99 -0
  52. package/dist/parser/magicLinks.js +53 -0
  53. package/dist/parser/quotes.js +67 -0
  54. package/dist/parser/redirect.js +26 -0
  55. package/dist/parser/selector.js +394 -0
  56. package/dist/parser/table.js +123 -0
  57. package/dist/src/arg.d.ts +51 -0
  58. package/dist/src/arg.js +214 -0
  59. package/dist/src/atom.d.ts +14 -0
  60. package/dist/src/atom.js +52 -0
  61. package/dist/src/attribute.d.ts +64 -0
  62. package/dist/src/attribute.js +483 -0
  63. package/dist/src/attributes.d.ts +101 -0
  64. package/dist/src/attributes.js +382 -0
  65. package/dist/src/converter.d.ts +28 -0
  66. package/dist/src/converter.js +147 -0
  67. package/dist/src/converterFlags.d.ts +80 -0
  68. package/dist/src/converterFlags.js +242 -0
  69. package/dist/src/converterRule.d.ts +71 -0
  70. package/dist/src/converterRule.js +216 -0
  71. package/dist/src/extLink.d.ts +36 -0
  72. package/dist/src/extLink.js +198 -0
  73. package/dist/src/gallery.d.ts +47 -0
  74. package/dist/src/gallery.js +142 -0
  75. package/dist/src/heading.d.ts +40 -0
  76. package/dist/src/heading.js +191 -0
  77. package/dist/src/hidden.d.ts +9 -0
  78. package/dist/src/hidden.js +80 -0
  79. package/dist/src/html.d.ts +57 -0
  80. package/dist/src/html.js +343 -0
  81. package/dist/src/imageParameter.d.ts +58 -0
  82. package/dist/src/imageParameter.js +247 -0
  83. package/dist/src/imagemap.d.ts +47 -0
  84. package/dist/src/imagemap.js +146 -0
  85. package/dist/src/imagemapLink.d.ts +31 -0
  86. package/dist/src/imagemapLink.js +97 -0
  87. package/dist/src/index.d.ts +141 -0
  88. package/dist/src/index.js +795 -0
  89. package/dist/src/link/base.d.ts +54 -0
  90. package/dist/src/link/base.js +263 -0
  91. package/dist/src/link/category.d.ts +22 -0
  92. package/dist/src/link/category.js +34 -0
  93. package/dist/src/link/file.d.ts +96 -0
  94. package/dist/src/link/file.js +276 -0
  95. package/dist/src/link/galleryImage.d.ts +29 -0
  96. package/dist/src/link/galleryImage.js +132 -0
  97. package/dist/src/link/index.d.ts +39 -0
  98. package/dist/src/link/index.js +99 -0
  99. package/dist/src/link/redirectTarget.d.ts +27 -0
  100. package/dist/src/link/redirectTarget.js +72 -0
  101. package/dist/src/magicLink.d.ts +61 -0
  102. package/dist/src/magicLink.js +261 -0
  103. package/dist/src/nested.d.ts +40 -0
  104. package/dist/src/nested.js +106 -0
  105. package/dist/src/nowiki/base.d.ts +30 -0
  106. package/dist/src/nowiki/base.js +89 -0
  107. package/dist/src/nowiki/comment.d.ts +14 -0
  108. package/dist/src/nowiki/comment.js +124 -0
  109. package/dist/src/nowiki/dd.d.ts +8 -0
  110. package/dist/src/nowiki/dd.js +72 -0
  111. package/dist/src/nowiki/doubleUnderscore.d.ts +15 -0
  112. package/dist/src/nowiki/doubleUnderscore.js +97 -0
  113. package/dist/src/nowiki/hr.d.ts +5 -0
  114. package/dist/src/nowiki/hr.js +70 -0
  115. package/dist/src/nowiki/index.d.ts +14 -0
  116. package/dist/src/nowiki/index.js +31 -0
  117. package/dist/src/nowiki/list.d.ts +5 -0
  118. package/dist/src/nowiki/list.js +65 -0
  119. package/dist/src/nowiki/listBase.d.ts +17 -0
  120. package/dist/src/nowiki/listBase.js +75 -0
  121. package/dist/src/nowiki/noinclude.d.ts +6 -0
  122. package/dist/src/nowiki/noinclude.js +75 -0
  123. package/dist/src/nowiki/quote.d.ts +14 -0
  124. package/dist/src/nowiki/quote.js +135 -0
  125. package/dist/src/onlyinclude.d.ts +13 -0
  126. package/dist/src/onlyinclude.js +58 -0
  127. package/dist/src/paramTag/index.d.ts +30 -0
  128. package/dist/src/paramTag/index.js +78 -0
  129. package/dist/src/paramTag/inputbox.d.ts +8 -0
  130. package/dist/src/paramTag/inputbox.js +22 -0
  131. package/dist/src/parameter.d.ts +60 -0
  132. package/dist/src/parameter.js +268 -0
  133. package/dist/src/pre.d.ts +28 -0
  134. package/dist/src/pre.js +60 -0
  135. package/dist/src/redirect.d.ts +30 -0
  136. package/dist/src/redirect.js +126 -0
  137. package/dist/src/syntax.d.ts +17 -0
  138. package/dist/src/syntax.js +87 -0
  139. package/dist/src/table/base.d.ts +28 -0
  140. package/dist/src/table/base.js +81 -0
  141. package/dist/src/table/index.d.ts +230 -0
  142. package/dist/src/table/index.js +505 -0
  143. package/dist/src/table/td.d.ts +72 -0
  144. package/dist/src/table/td.js +370 -0
  145. package/dist/src/table/tr.d.ts +30 -0
  146. package/dist/src/table/tr.js +59 -0
  147. package/dist/src/table/trBase.d.ts +49 -0
  148. package/dist/src/table/trBase.js +164 -0
  149. package/dist/src/tagPair/ext.d.ts +29 -0
  150. package/dist/src/tagPair/ext.js +220 -0
  151. package/dist/src/tagPair/include.d.ts +33 -0
  152. package/dist/src/tagPair/include.js +130 -0
  153. package/dist/src/tagPair/index.d.ts +23 -0
  154. package/dist/src/tagPair/index.js +128 -0
  155. package/dist/src/transclude.d.ts +159 -0
  156. package/dist/src/transclude.js +587 -0
  157. package/dist/util/constants.js +25 -0
  158. package/dist/util/debug.js +95 -0
  159. package/dist/util/diff.js +83 -0
  160. package/dist/util/lint.js +32 -0
  161. package/dist/util/string.js +84 -0
  162. package/errors/README +3 -0
  163. package/package.json +22 -32
  164. package/printed/README +3 -0
  165. package/bundle/bundle.min.js +0 -39
  166. package/extensions/dist/base.js +0 -64
  167. package/extensions/dist/editor.js +0 -159
  168. package/extensions/dist/highlight.js +0 -58
  169. package/extensions/dist/lint.js +0 -72
  170. package/extensions/editor.css +0 -64
  171. package/extensions/ui.css +0 -144
@@ -0,0 +1,54 @@
1
+ import Parser from '../../index';
2
+ import { Token } from '../index';
3
+ import { AtomToken } from '../atom';
4
+ import type { LintError } from '../../base';
5
+ import type { Title } from '../../lib/title';
6
+ /**
7
+ * 内链
8
+ * @classdesc `{childNodes: [AtomToken, ...Token]}`
9
+ */
10
+ export declare abstract class LinkBaseToken extends Token {
11
+ #private;
12
+ readonly name: string;
13
+ abstract get type(): 'link' | 'category' | 'file' | 'gallery-image' | 'imagemap-image' | 'redirect-target';
14
+ readonly childNodes: readonly [AtomToken, ...Token[]];
15
+ abstract get firstChild(): AtomToken;
16
+ abstract get lastChild(): Token;
17
+ abstract get children(): [AtomToken, ...Token[]];
18
+ abstract get firstElementChild(): AtomToken;
19
+ abstract get lastElementChild(): Token;
20
+ /** 完整链接 */
21
+ get link(): string | Title;
22
+ set link(link: string);
23
+ /** fragment */
24
+ get fragment(): string | undefined;
25
+ set fragment(fragment: string | undefined);
26
+ /** interwiki */
27
+ get interwiki(): string;
28
+ /** @throws `RangeError` 非法的跨维基前缀 */
29
+ set interwiki(interwiki: string);
30
+ /**
31
+ * @param link 链接标题
32
+ * @param linkText 链接显示文字
33
+ * @param delimiter `|`
34
+ */
35
+ constructor(link: string, linkText?: string, config?: Parser.Config, accum?: Token[], delimiter?: string);
36
+ cloneNode(this: this & {
37
+ constructor: new (...args: any[]) => unknown;
38
+ }): this;
39
+ /**
40
+ * 设置链接目标
41
+ * @param link 链接目标
42
+ */
43
+ setTarget(link: string): void;
44
+ /**
45
+ * 设置fragment
46
+ * @param fragment fragment
47
+ */
48
+ setFragment(fragment?: string): void;
49
+ /**
50
+ * 设置链接显示文字
51
+ * @param linkStr 链接显示文字
52
+ */
53
+ setLinkText(linkStr?: string): void;
54
+ }
@@ -0,0 +1,263 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LinkBaseToken = void 0;
4
+ const lint_1 = require("../../util/lint");
5
+ const constants_1 = require("../../util/constants");
6
+ const debug_1 = require("../../util/debug");
7
+ const string_1 = require("../../util/string");
8
+ const rect_1 = require("../../lib/rect");
9
+ const index_1 = require("../../index");
10
+ const index_2 = require("../index");
11
+ const atom_1 = require("../atom");
12
+ /**
13
+ * 是否为普通内链
14
+ * @param type 节点类型
15
+ */
16
+ const isLink = (type) => type === 'redirect-target' || type === 'link';
17
+ /* NOT FOR BROWSER */
18
+ const fileTypes = new Set(['file', 'gallery-image', 'imagemap-image']);
19
+ /* NOT FOR BROWSER END */
20
+ /**
21
+ * 内链
22
+ * @classdesc `{childNodes: [AtomToken, ...Token]}`
23
+ */
24
+ class LinkBaseToken extends index_2.Token {
25
+ #bracket = true;
26
+ #delimiter;
27
+ #title;
28
+ /** 完整链接 */
29
+ get link() {
30
+ return this.#title;
31
+ }
32
+ set link(link) {
33
+ this.setTarget(link);
34
+ }
35
+ /** fragment */
36
+ get fragment() {
37
+ return this.#title.fragment;
38
+ }
39
+ set fragment(fragment) {
40
+ this.setFragment(fragment);
41
+ }
42
+ /** interwiki */
43
+ get interwiki() {
44
+ return this.#title.interwiki;
45
+ }
46
+ /** @throws `RangeError` 非法的跨维基前缀 */
47
+ set interwiki(interwiki) {
48
+ if (isLink(this.type)) {
49
+ const { prefix, main, fragment } = this.#title, link = `${interwiki}:${prefix}${main}${fragment === undefined ? '' : `#${fragment}`}`;
50
+ if (interwiki && !this.isInterwiki(link)) {
51
+ throw new RangeError(`${interwiki} is not a valid interwiki prefix!`);
52
+ }
53
+ this.setTarget(link);
54
+ }
55
+ }
56
+ /* NOT FOR BROWSER END */
57
+ /**
58
+ * @param link 链接标题
59
+ * @param linkText 链接显示文字
60
+ * @param delimiter `|`
61
+ */
62
+ constructor(link, linkText, config = index_1.default.getConfig(), accum = [], delimiter = '|') {
63
+ super(undefined, config, accum, {
64
+ AtomToken: 0, Token: 1,
65
+ });
66
+ this.insertAt(new atom_1.AtomToken(link, 'link-target', config, accum, {
67
+ 'Stage-2': ':', '!ExtToken': '', '!HeadingToken': '',
68
+ }));
69
+ if (linkText !== undefined) {
70
+ const inner = new index_2.Token(linkText, config, accum, {
71
+ 'Stage-5': ':', QuoteToken: ':', ConverterToken: ':',
72
+ });
73
+ inner.type = 'link-text';
74
+ inner.setAttribute('stage', constants_1.MAX_STAGE - 1);
75
+ this.insertAt(inner);
76
+ }
77
+ this.#delimiter = delimiter;
78
+ /* NOT FOR BROWSER */
79
+ this.protectChildren(0);
80
+ }
81
+ /** @private */
82
+ afterBuild() {
83
+ this.#title = this.getTitle();
84
+ if (this.#delimiter.includes('\0')) {
85
+ this.#delimiter = this.buildFromStr(this.#delimiter, constants_1.BuildMethod.String);
86
+ }
87
+ this.setAttribute('name', this.#title.title);
88
+ super.afterBuild();
89
+ /* NOT FOR BROWSER */
90
+ const /** @implements */ linkListener = (e, data) => {
91
+ const { prevTarget } = e;
92
+ if (prevTarget?.type === 'link-target') {
93
+ const name = prevTarget.toString(true), titleObj = this.getTitle(), { title, interwiki, ns, valid } = titleObj;
94
+ if (!valid) {
95
+ (0, debug_1.undo)(e, data);
96
+ throw new Error(`Invalid link target: ${name}`);
97
+ }
98
+ else if (this.type === 'category' && (interwiki || ns !== 14)
99
+ || fileTypes.has(this.type) && (interwiki || ns !== 6)) {
100
+ (0, debug_1.undo)(e, data);
101
+ throw new Error(`${this.type === 'category' ? 'Category' : 'File'} link cannot change namespace: ${name}`);
102
+ }
103
+ else if (this.type === 'link'
104
+ && !interwiki
105
+ && (ns === 6 || ns === 14)
106
+ && !name.trim().startsWith(':')) {
107
+ const { firstChild } = prevTarget;
108
+ if (firstChild?.type === 'text') {
109
+ firstChild.insertData(0, ':');
110
+ }
111
+ else {
112
+ prevTarget.prepend(':');
113
+ }
114
+ }
115
+ this.#title = titleObj;
116
+ this.setAttribute('name', title);
117
+ }
118
+ };
119
+ this.addEventListener(['remove', 'insert', 'replace', 'text'], linkListener);
120
+ }
121
+ /** @private */
122
+ setAttribute(key, value) {
123
+ if (key === 'bracket') {
124
+ this.#bracket = value;
125
+ }
126
+ else if (key === 'title') {
127
+ this.#title = value;
128
+ }
129
+ else {
130
+ super.setAttribute(key, value);
131
+ }
132
+ }
133
+ /** @private */
134
+ toString(skip) {
135
+ const str = super.toString(skip, this.#delimiter);
136
+ return this.#bracket ? `[[${str}]]` : str;
137
+ }
138
+ /** @private */
139
+ text() {
140
+ const str = super.text('|');
141
+ return this.#bracket ? `[[${str}]]` : str;
142
+ }
143
+ /** @private */
144
+ getAttribute(key) {
145
+ if (key === 'title') {
146
+ return this.#title;
147
+ }
148
+ return key === 'padding' ? 2 : super.getAttribute(key);
149
+ }
150
+ /** @private */
151
+ getGaps(i) {
152
+ return i === 0 ? this.#delimiter.length : 1;
153
+ }
154
+ /** @private */
155
+ lint(start = this.getAbsoluteIndex(), re) {
156
+ const errors = super.lint(start, re), { childNodes: [target, linkText], type } = this, { encoded, fragment } = this.#title, rect = new rect_1.BoundingRect(this, start);
157
+ if (target.childNodes.some(({ type: t }) => t === 'template')) {
158
+ errors.push((0, lint_1.generateForChild)(target, rect, 'unknown-page', 'template in an internal link target', 'warning'));
159
+ }
160
+ if (encoded) {
161
+ errors.push((0, lint_1.generateForChild)(target, rect, 'url-encoding', 'unnecessary URL encoding in an internal link'));
162
+ }
163
+ if (type === 'link' || type === 'category') {
164
+ const textNode = linkText?.childNodes.find((c) => c.type === 'text' && c.data.includes('|'));
165
+ if (textNode) {
166
+ const e = (0, lint_1.generateForChild)(linkText, rect, 'pipe-like', 'additional "|" in the link text', 'warning');
167
+ e.suggestions = [
168
+ {
169
+ desc: 'escape',
170
+ range: [
171
+ e.startIndex + textNode.getRelativeIndex(),
172
+ e.startIndex + textNode.getRelativeIndex() + textNode.data.length,
173
+ ],
174
+ text: textNode.data.replace(/\|/gu, '|'),
175
+ },
176
+ ];
177
+ errors.push(e);
178
+ }
179
+ }
180
+ if (fragment !== undefined && !isLink(type)) {
181
+ const e = (0, lint_1.generateForChild)(target, rect, 'no-ignored', 'useless fragment'), textNode = target.childNodes.find((c) => c.type === 'text' && c.data.includes('#'));
182
+ if (textNode) {
183
+ e.fix = {
184
+ range: [e.startIndex + textNode.getRelativeIndex() + textNode.data.indexOf('#'), e.endIndex],
185
+ text: '',
186
+ };
187
+ }
188
+ errors.push(e);
189
+ }
190
+ return errors;
191
+ }
192
+ /** @private */
193
+ getTitle(halfParsed) {
194
+ return this.normalizeTitle(this.firstChild.toString(true), 0, halfParsed, true, true);
195
+ }
196
+ /** @private */
197
+ print() {
198
+ return super.print(this.#bracket ? { pre: '[[', post: ']]', sep: this.#delimiter } : { sep: this.#delimiter });
199
+ }
200
+ /* NOT FOR BROWSER */
201
+ cloneNode() {
202
+ const [link, ...linkText] = this.cloneChildNodes();
203
+ return debug_1.Shadow.run(() => {
204
+ const token = new this.constructor('', undefined, this.getAttribute('config'));
205
+ token.firstChild.safeReplaceWith(link);
206
+ token.append(...linkText);
207
+ return token;
208
+ });
209
+ }
210
+ /**
211
+ * 设置链接目标
212
+ * @param link 链接目标
213
+ */
214
+ setTarget(link) {
215
+ const config = this.getAttribute('config'), { childNodes } = index_1.default.parse(link, this.getAttribute('include'), 2, config), token = debug_1.Shadow.run(() => new atom_1.AtomToken(undefined, 'link-target', config, [], {
216
+ 'Stage-2': ':', '!ExtToken': '', '!HeadingToken': '',
217
+ }));
218
+ token.append(...childNodes);
219
+ this.firstChild.safeReplaceWith(token);
220
+ }
221
+ /**
222
+ * 设置fragment
223
+ * @param fragment fragment
224
+ */
225
+ setFragment(fragment) {
226
+ const { type, name } = this;
227
+ if (fragment === undefined || isLink(type)) {
228
+ fragment &&= (0, string_1.encode)(fragment);
229
+ this.setTarget(`${name}${fragment === undefined ? '' : `#${fragment}`}`);
230
+ }
231
+ }
232
+ /**
233
+ * 设置链接显示文字
234
+ * @param linkStr 链接显示文字
235
+ */
236
+ setLinkText(linkStr) {
237
+ if (linkStr === undefined) {
238
+ this.childNodes[1]?.remove();
239
+ return;
240
+ }
241
+ const root = index_1.default.parse(linkStr, this.getAttribute('include'), undefined, this.getAttribute('config'));
242
+ if (this.length === 1) {
243
+ root.type = 'link-text';
244
+ root.setAttribute('acceptable', {
245
+ 'Stage-5': ':', QuoteToken: ':', ConverterToken: ':',
246
+ });
247
+ this.insertAt(root);
248
+ }
249
+ else {
250
+ this.lastChild.replaceChildren(...root.childNodes);
251
+ }
252
+ }
253
+ /** @private */
254
+ toHtml() {
255
+ if (this.is('link') || this.is('redirect-target')) {
256
+ const { link, length, lastChild, type } = this;
257
+ return `<a ${link.interwiki && 'class="extiw" '}href="${link.getUrl()}" title="${link.title.replace(/"/gu, '&quot;')}">${type === 'link' && length > 1 ? lastChild.toHtml(true) : this.innerText}</a>`;
258
+ }
259
+ return '';
260
+ }
261
+ }
262
+ exports.LinkBaseToken = LinkBaseToken;
263
+ constants_1.classes['LinkBaseToken'] = __filename;
@@ -0,0 +1,22 @@
1
+ import { LinkBaseToken } from './base';
2
+ import type { Title } from '../../lib/title';
3
+ import type { Token, AtomToken } from '../../internal';
4
+ /**
5
+ * 分类
6
+ * @classdesc `{childNodes: [AtomToken, ?Token]}`
7
+ */
8
+ export declare abstract class CategoryToken extends LinkBaseToken {
9
+ readonly childNodes: readonly [AtomToken] | readonly [AtomToken, Token];
10
+ abstract get children(): [AtomToken] | [AtomToken, Token];
11
+ abstract get link(): Title;
12
+ abstract set link(link: string);
13
+ get type(): 'category';
14
+ /** 分类排序关键字 */
15
+ get sortkey(): string | undefined;
16
+ set sortkey(text: string | undefined);
17
+ /**
18
+ * 设置排序关键字
19
+ * @param text 排序关键字
20
+ */
21
+ setSortkey(text?: string): void;
22
+ }
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CategoryToken = void 0;
4
+ const string_1 = require("../../util/string");
5
+ const constants_1 = require("../../util/constants");
6
+ const base_1 = require("./base");
7
+ /**
8
+ * 分类
9
+ * @classdesc `{childNodes: [AtomToken, ?Token]}`
10
+ */
11
+ class CategoryToken extends base_1.LinkBaseToken {
12
+ /* NOT FOR BROWSER END */
13
+ get type() {
14
+ return 'category';
15
+ }
16
+ /* NOT FOR BROWSER */
17
+ /** 分类排序关键字 */
18
+ get sortkey() {
19
+ const { childNodes: [, child] } = this;
20
+ return child && (0, string_1.decodeHtml)(child.text());
21
+ }
22
+ set sortkey(text) {
23
+ this.setSortkey(text);
24
+ }
25
+ /**
26
+ * 设置排序关键字
27
+ * @param text 排序关键字
28
+ */
29
+ setSortkey(text) {
30
+ this.setLinkText(text);
31
+ }
32
+ }
33
+ exports.CategoryToken = CategoryToken;
34
+ constants_1.classes['CategoryToken'] = __filename;
@@ -0,0 +1,96 @@
1
+ import Parser from '../../index';
2
+ import { LinkBaseToken } from './base';
3
+ import { ImageParameterToken } from '../imageParameter';
4
+ import type { Title } from '../../lib/title';
5
+ import type { LintError } from '../../base';
6
+ import type { Token, AtomToken } from '../../internal';
7
+ /**
8
+ * 图片
9
+ * @classdesc `{childNodes: [AtomToken, ...ImageParameterToken]}`
10
+ */
11
+ export declare abstract class FileToken extends LinkBaseToken {
12
+ #private;
13
+ readonly childNodes: readonly [AtomToken, ...ImageParameterToken[]];
14
+ abstract get lastChild(): AtomToken | ImageParameterToken;
15
+ abstract get children(): [AtomToken, ...ImageParameterToken[]];
16
+ abstract get lastElementChild(): AtomToken | ImageParameterToken;
17
+ get type(): 'file' | 'gallery-image' | 'imagemap-image';
18
+ /** 扩展名 */
19
+ get extension(): string | undefined;
20
+ /** 图片链接 */
21
+ get link(): string | Title;
22
+ set link(value: string);
23
+ /** 图片大小 */
24
+ get size(): {
25
+ width: string;
26
+ height: string;
27
+ } | undefined;
28
+ set size(size: {
29
+ width: string;
30
+ height: string;
31
+ } | undefined);
32
+ /** 图片宽度 */
33
+ get width(): string | undefined;
34
+ set width(width: string | undefined);
35
+ /** 图片高度 */
36
+ get height(): string | undefined;
37
+ set height(height: string | undefined);
38
+ /**
39
+ * @param link 文件名
40
+ * @param text 图片参数
41
+ * @param delimiter `|`
42
+ */
43
+ constructor(link: string, text?: string, config?: Parser.Config, accum?: Token[], delimiter?: string);
44
+ /** 获取所有图片参数节点 */
45
+ getAllArgs(): ImageParameterToken[];
46
+ /**
47
+ * 获取指定图片参数
48
+ * @param key 参数名
49
+ */
50
+ getArgs(key: string): ImageParameterToken[];
51
+ /** 获取图片框架属性参数节点 */
52
+ getFrameArgs(): ImageParameterToken[];
53
+ /** 获取图片水平对齐参数节点 */
54
+ getHorizAlignArgs(): ImageParameterToken[];
55
+ /** 获取图片垂直对齐参数节点 */
56
+ getVertAlignArgs(): ImageParameterToken[];
57
+ /**
58
+ * 获取生效的指定图片参数
59
+ * @param key 参数名
60
+ */
61
+ getArg(key: string): ImageParameterToken | undefined;
62
+ /**
63
+ * 获取生效的指定图片参数值
64
+ * @param key 参数名
65
+ */
66
+ getValue(key: string): string | true | undefined;
67
+ /**
68
+ * 是否具有指定图片参数
69
+ * @param key 参数名
70
+ */
71
+ hasArg(key: string): boolean;
72
+ /**
73
+ * 移除指定图片参数
74
+ * @param key 参数名
75
+ */
76
+ removeArg(key: string): void;
77
+ /** 获取图片参数名 */
78
+ getKeys(): Set<string>;
79
+ /**
80
+ * 获取指定的图片参数值
81
+ * @param key 参数名
82
+ */
83
+ getValues(key: string): (string | true)[];
84
+ /**
85
+ * 设置图片参数
86
+ * @param key 参数名
87
+ * @param value 参数值
88
+ * @throws `RangeError` 未定义的图片参数
89
+ */
90
+ setValue(key: string, value?: string | boolean): void;
91
+ /**
92
+ * @override
93
+ * @throws `Error` 不适用于图片
94
+ */
95
+ setLinkText(): never;
96
+ }