wikiparser-node 1.13.0 → 1.13.1-b

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 (176) hide show
  1. package/bundle/bundle.min.js +37 -0
  2. package/config/default.json +32 -41
  3. package/config/enwiki.json +17 -839
  4. package/config/llwiki.json +21 -56
  5. package/config/moegirl.json +21 -65
  6. package/config/zhwiki.json +32 -498
  7. package/extensions/dist/base.js +163 -0
  8. package/extensions/dist/codejar.js +53 -0
  9. package/extensions/dist/editor.js +159 -0
  10. package/extensions/dist/highlight.js +30 -0
  11. package/extensions/dist/lint.js +72 -0
  12. package/extensions/editor.css +59 -0
  13. package/extensions/ui.css +162 -0
  14. package/i18n/zh-hans.json +1 -0
  15. package/i18n/zh-hant.json +1 -0
  16. package/package.json +29 -22
  17. package/config/.schema.json +0 -203
  18. package/dist/addon/table.js +0 -494
  19. package/dist/addon/token.js +0 -392
  20. package/dist/addon/transclude.js +0 -184
  21. package/dist/base.d.ts +0 -109
  22. package/dist/base.js +0 -67
  23. package/dist/index.d.ts +0 -33
  24. package/dist/index.js +0 -279
  25. package/dist/internal.d.ts +0 -47
  26. package/dist/lib/element.d.ts +0 -125
  27. package/dist/lib/element.js +0 -364
  28. package/dist/lib/node.d.ts +0 -173
  29. package/dist/lib/node.js +0 -478
  30. package/dist/lib/range.d.ts +0 -105
  31. package/dist/lib/range.js +0 -406
  32. package/dist/lib/ranges.d.ts +0 -28
  33. package/dist/lib/ranges.js +0 -126
  34. package/dist/lib/rect.d.ts +0 -18
  35. package/dist/lib/rect.js +0 -36
  36. package/dist/lib/text.d.ts +0 -58
  37. package/dist/lib/text.js +0 -414
  38. package/dist/lib/title.d.ts +0 -49
  39. package/dist/lib/title.js +0 -251
  40. package/dist/mixin/attributesParent.d.ts +0 -49
  41. package/dist/mixin/attributesParent.js +0 -80
  42. package/dist/mixin/fixed.d.ts +0 -5
  43. package/dist/mixin/fixed.js +0 -32
  44. package/dist/mixin/flagsParent.d.ts +0 -43
  45. package/dist/mixin/flagsParent.js +0 -64
  46. package/dist/mixin/hidden.d.ts +0 -7
  47. package/dist/mixin/hidden.js +0 -39
  48. package/dist/mixin/magicLinkParent.d.ts +0 -19
  49. package/dist/mixin/magicLinkParent.js +0 -43
  50. package/dist/mixin/singleLine.d.ts +0 -5
  51. package/dist/mixin/singleLine.js +0 -25
  52. package/dist/mixin/sol.d.ts +0 -6
  53. package/dist/mixin/sol.js +0 -45
  54. package/dist/mixin/syntax.d.ts +0 -8
  55. package/dist/mixin/syntax.js +0 -46
  56. package/dist/parser/braces.js +0 -152
  57. package/dist/parser/commentAndExt.js +0 -84
  58. package/dist/parser/converter.js +0 -41
  59. package/dist/parser/externalLinks.js +0 -39
  60. package/dist/parser/hrAndDoubleUnderscore.js +0 -44
  61. package/dist/parser/html.js +0 -40
  62. package/dist/parser/links.js +0 -103
  63. package/dist/parser/list.js +0 -116
  64. package/dist/parser/magicLinks.js +0 -55
  65. package/dist/parser/quotes.js +0 -69
  66. package/dist/parser/redirect.js +0 -28
  67. package/dist/parser/selector.js +0 -443
  68. package/dist/parser/table.js +0 -125
  69. package/dist/src/arg.d.ts +0 -49
  70. package/dist/src/arg.js +0 -220
  71. package/dist/src/atom.d.ts +0 -14
  72. package/dist/src/atom.js +0 -54
  73. package/dist/src/attribute.d.ts +0 -64
  74. package/dist/src/attribute.js +0 -482
  75. package/dist/src/attributes.d.ts +0 -103
  76. package/dist/src/attributes.js +0 -383
  77. package/dist/src/converter.d.ts +0 -28
  78. package/dist/src/converter.js +0 -153
  79. package/dist/src/converterFlags.d.ts +0 -80
  80. package/dist/src/converterFlags.js +0 -241
  81. package/dist/src/converterRule.d.ts +0 -71
  82. package/dist/src/converterRule.js +0 -218
  83. package/dist/src/extLink.d.ts +0 -36
  84. package/dist/src/extLink.js +0 -223
  85. package/dist/src/gallery.d.ts +0 -51
  86. package/dist/src/gallery.js +0 -166
  87. package/dist/src/heading.d.ts +0 -44
  88. package/dist/src/heading.js +0 -222
  89. package/dist/src/hidden.d.ts +0 -9
  90. package/dist/src/hidden.js +0 -82
  91. package/dist/src/html.d.ts +0 -61
  92. package/dist/src/html.js +0 -344
  93. package/dist/src/imageParameter.d.ts +0 -60
  94. package/dist/src/imageParameter.js +0 -262
  95. package/dist/src/imagemap.d.ts +0 -47
  96. package/dist/src/imagemap.js +0 -148
  97. package/dist/src/imagemapLink.d.ts +0 -35
  98. package/dist/src/imagemapLink.js +0 -99
  99. package/dist/src/index.d.ts +0 -136
  100. package/dist/src/index.js +0 -790
  101. package/dist/src/link/base.d.ts +0 -52
  102. package/dist/src/link/base.js +0 -258
  103. package/dist/src/link/category.d.ts +0 -22
  104. package/dist/src/link/category.js +0 -36
  105. package/dist/src/link/file.d.ts +0 -102
  106. package/dist/src/link/file.js +0 -345
  107. package/dist/src/link/galleryImage.d.ts +0 -29
  108. package/dist/src/link/galleryImage.js +0 -133
  109. package/dist/src/link/index.d.ts +0 -39
  110. package/dist/src/link/index.js +0 -100
  111. package/dist/src/link/redirectTarget.d.ts +0 -27
  112. package/dist/src/link/redirectTarget.js +0 -71
  113. package/dist/src/magicLink.d.ts +0 -57
  114. package/dist/src/magicLink.js +0 -261
  115. package/dist/src/nested.d.ts +0 -40
  116. package/dist/src/nested.js +0 -108
  117. package/dist/src/nowiki/base.d.ts +0 -28
  118. package/dist/src/nowiki/base.js +0 -90
  119. package/dist/src/nowiki/comment.d.ts +0 -14
  120. package/dist/src/nowiki/comment.js +0 -123
  121. package/dist/src/nowiki/dd.d.ts +0 -8
  122. package/dist/src/nowiki/dd.js +0 -74
  123. package/dist/src/nowiki/doubleUnderscore.d.ts +0 -15
  124. package/dist/src/nowiki/doubleUnderscore.js +0 -101
  125. package/dist/src/nowiki/hr.d.ts +0 -5
  126. package/dist/src/nowiki/hr.js +0 -72
  127. package/dist/src/nowiki/index.d.ts +0 -14
  128. package/dist/src/nowiki/index.js +0 -30
  129. package/dist/src/nowiki/list.d.ts +0 -5
  130. package/dist/src/nowiki/list.js +0 -67
  131. package/dist/src/nowiki/listBase.d.ts +0 -23
  132. package/dist/src/nowiki/listBase.js +0 -100
  133. package/dist/src/nowiki/noinclude.d.ts +0 -6
  134. package/dist/src/nowiki/noinclude.js +0 -77
  135. package/dist/src/nowiki/quote.d.ts +0 -14
  136. package/dist/src/nowiki/quote.js +0 -149
  137. package/dist/src/onlyinclude.d.ts +0 -13
  138. package/dist/src/onlyinclude.js +0 -60
  139. package/dist/src/paramTag/index.d.ts +0 -28
  140. package/dist/src/paramTag/index.js +0 -80
  141. package/dist/src/paramTag/inputbox.d.ts +0 -8
  142. package/dist/src/paramTag/inputbox.js +0 -24
  143. package/dist/src/parameter.d.ts +0 -60
  144. package/dist/src/parameter.js +0 -267
  145. package/dist/src/pre.d.ts +0 -28
  146. package/dist/src/pre.js +0 -62
  147. package/dist/src/redirect.d.ts +0 -30
  148. package/dist/src/redirect.js +0 -128
  149. package/dist/src/syntax.d.ts +0 -15
  150. package/dist/src/syntax.js +0 -87
  151. package/dist/src/table/base.d.ts +0 -28
  152. package/dist/src/table/base.js +0 -81
  153. package/dist/src/table/index.d.ts +0 -230
  154. package/dist/src/table/index.js +0 -506
  155. package/dist/src/table/td.d.ts +0 -72
  156. package/dist/src/table/td.js +0 -375
  157. package/dist/src/table/tr.d.ts +0 -30
  158. package/dist/src/table/tr.js +0 -61
  159. package/dist/src/table/trBase.d.ts +0 -49
  160. package/dist/src/table/trBase.js +0 -165
  161. package/dist/src/tagPair/ext.d.ts +0 -29
  162. package/dist/src/tagPair/ext.js +0 -229
  163. package/dist/src/tagPair/include.d.ts +0 -33
  164. package/dist/src/tagPair/include.js +0 -132
  165. package/dist/src/tagPair/index.d.ts +0 -23
  166. package/dist/src/tagPair/index.js +0 -130
  167. package/dist/src/transclude.d.ts +0 -159
  168. package/dist/src/transclude.js +0 -598
  169. package/dist/util/constants.js +0 -26
  170. package/dist/util/debug.js +0 -95
  171. package/dist/util/diff.js +0 -83
  172. package/dist/util/html.js +0 -146
  173. package/dist/util/lint.js +0 -32
  174. package/dist/util/string.js +0 -107
  175. package/errors/README +0 -3
  176. package/printed/README +0 -3
package/dist/lib/text.js DELETED
@@ -1,414 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AstText = void 0;
4
- const string_1 = require("../util/string");
5
- const index_1 = require("../index");
6
- const node_1 = require("./node");
7
- /* NOT FOR BROWSER */
8
- const constants_1 = require("../util/constants");
9
- const debug_1 = require("../util/debug");
10
- const html_1 = require("../util/html");
11
- /* NOT FOR BROWSER END */
12
- /* eslint-disable @typescript-eslint/no-unused-expressions */
13
- /<\s*(?:\/\s*)?([a-z]\w*)|\{+|\}+|\[{2,}|\[(?![^[]*?\])|((?:^|\])[^[]*?)\]+|https?[:/]\/+/giu;
14
- /^https?:\/\/(?:\[[\da-f:.]+\]|[^[\]<>"\t\n\p{Zs}])[^[\]<>"\t\n\p{Zs}]*\.(?:gif|png|jpg|jpeg)$/iu;
15
- /* eslint-enable @typescript-eslint/no-unused-expressions */
16
- const source = String.raw `<\s*(?:/\s*)?([a-z]\w*)|\{+|\}+|\[{2,}|\[(?![^[]*?\])|((?:^|\])[^[]*?)\]+`, errorSyntax = new RegExp(String.raw `${source}|https?[:/]/+`, 'giu'), errorSyntaxUrl = new RegExp(source, 'giu'), extImage = new RegExp(String.raw `^https?://${string_1.extUrlCharFirst}${string_1.extUrlChar}\.(?:gif|png|jpg|jpeg)$`, 'iu'), regexes = {
17
- '[': /[[\]]/u,
18
- '{': /[{}]/u,
19
- ']': /[[\]](?=[^[\]]*$)/u,
20
- '}': /[{}](?=[^{}]*$)/u,
21
- }, ruleMap = {
22
- '<': 'tag-like',
23
- '[': 'lonely-bracket',
24
- '{': 'lonely-bracket',
25
- ']': 'lonely-bracket',
26
- '}': 'lonely-bracket',
27
- h: 'lonely-http',
28
- }, disallowedTags = [
29
- 'html',
30
- 'base',
31
- 'head',
32
- 'style',
33
- 'title',
34
- 'body',
35
- 'menu',
36
- 'a',
37
- 'area',
38
- 'audio',
39
- 'img',
40
- 'map',
41
- 'track',
42
- 'video',
43
- 'embed',
44
- 'iframe',
45
- 'object',
46
- 'picture',
47
- 'source',
48
- 'canvas',
49
- 'script',
50
- 'col',
51
- 'colgroup',
52
- 'tbody',
53
- 'tfoot',
54
- 'thead',
55
- 'button',
56
- 'datalist',
57
- 'fieldset',
58
- 'form',
59
- 'input',
60
- 'label',
61
- 'legend',
62
- 'meter',
63
- 'optgroup',
64
- 'option',
65
- 'output',
66
- 'progress',
67
- 'select',
68
- 'textarea',
69
- 'details',
70
- 'dialog',
71
- 'slot',
72
- 'template',
73
- 'dir',
74
- 'frame',
75
- 'frameset',
76
- 'marquee',
77
- 'param',
78
- 'xmp',
79
- ];
80
- /** 文本节点 */
81
- class AstText extends node_1.AstNode {
82
- data = '';
83
- get type() {
84
- return 'text';
85
- }
86
- /* NOT FOR BROWSER */
87
- /** 文本长度 */
88
- get length() {
89
- return this.data.length;
90
- }
91
- set length(n) {
92
- if (n >= 0 && n < this.length) {
93
- this.replaceData(this.data.slice(0, n));
94
- }
95
- }
96
- /* NOT FOR BROWSER END */
97
- /** @param text 包含文本 */
98
- constructor(text) {
99
- super();
100
- Object.defineProperties(this, {
101
- childNodes: { enumerable: false, configurable: false },
102
- data: {
103
- value: text,
104
- /* NOT FOR BROWSER */
105
- writable: false,
106
- },
107
- });
108
- }
109
- /** @private */
110
- toString(skip) {
111
- return skip && !this.parentNode?.getAttribute('built') ? (0, string_1.removeComment)(this.data) : this.data;
112
- }
113
- /** @private */
114
- text() {
115
- return this.data;
116
- }
117
- /** @private */
118
- lint(start = this.getAbsoluteIndex(), errorRegex) {
119
- if (errorRegex === false) {
120
- return [];
121
- }
122
- const { data, parentNode, nextSibling, previousSibling } = this;
123
- if (!parentNode) {
124
- throw new Error('An isolated text node cannot be linted!');
125
- }
126
- const { type, name, parentNode: grandparent } = parentNode;
127
- let isHtmlAttrVal = false;
128
- if (type === 'attr-value') {
129
- const { type: grandType, name: grandName, tag } = grandparent;
130
- if (grandType !== 'ext-attr') {
131
- isHtmlAttrVal = true;
132
- }
133
- else if (tag === 'choose' && (grandName === 'before' || grandName === 'after')) {
134
- return [];
135
- }
136
- }
137
- errorRegex ??= type === 'free-ext-link'
138
- || type === 'ext-link-url'
139
- || type === 'ext-link-text'
140
- || type === 'image-parameter' && name === 'link'
141
- || isHtmlAttrVal
142
- ? errorSyntaxUrl
143
- : errorSyntax;
144
- if (data.search(errorRegex) === -1) {
145
- return [];
146
- }
147
- errorRegex.lastIndex = 0;
148
- const errors = [], nextType = nextSibling?.type, nextName = nextSibling?.name, previousType = previousSibling?.type, root = this.getRootNode(), { ext, html } = root.getAttribute('config'), { top, left } = root.posFromIndex(start), tags = new Set(['onlyinclude', 'noinclude', 'includeonly', ext, html, disallowedTags].flat(2));
149
- for (let mt = errorRegex.exec(data); mt; mt = errorRegex.exec(data)) {
150
- const [, tag, prefix] = mt;
151
- let { 0: error, index } = mt;
152
- if (prefix && prefix !== ']') {
153
- const { length } = prefix;
154
- index += length;
155
- error = error.slice(length);
156
- }
157
- const { 0: char, length } = error;
158
- if (char === '<' && !tags.has(tag.toLowerCase())
159
- || char === '['
160
- && type === 'ext-link-text'
161
- && (/&(?:rbrack|#93|#x5[Dd];);/u.test(data.slice(index + 1))
162
- || nextSibling?.is('ext') && nextName === 'nowiki' && nextSibling.innerText?.includes(']'))) {
163
- continue;
164
- }
165
- else if (char === ']' && (index || length > 1)) {
166
- errorRegex.lastIndex--;
167
- }
168
- else if (char === 'h' && index === 0 && type === 'ext-link-text' && extImage.test(data)) {
169
- continue;
170
- }
171
- const startIndex = start + index, endIndex = startIndex + length, rootStr = root.toString(), nextChar = rootStr[endIndex], previousChar = rootStr[startIndex - 1], severity = length > 1 && !(char === '<' && !/[\s/>]/u.test(nextChar ?? '')
172
- || isHtmlAttrVal && (char === '[' || char === ']'))
173
- || char === '{' && (nextChar === char || previousChar === '-')
174
- || char === '}' && (previousChar === char || nextChar === '-')
175
- || char === '[' && (nextChar === char
176
- || type === 'ext-link-text'
177
- || nextType === 'free-ext-link' && !data.slice(index + 1).trim())
178
- || char === ']' && (previousChar === char
179
- || previousType === 'free-ext-link' && !data.slice(0, index).includes(']'))
180
- ? 'error'
181
- : 'warning';
182
- const leftBracket = char === '{' || char === '[', rightBracket = char === ']' || char === '}';
183
- if (severity === 'warning' && (leftBracket || rightBracket)) {
184
- const regex = regexes[char], remains = leftBracket ? data.slice(index + 1) : data.slice(0, index);
185
- if (char === '{' && regex.exec(remains)?.[0] === '}'
186
- || char === '}' && regex.exec(remains)?.[0] === '{') {
187
- continue;
188
- }
189
- else if (!remains.includes(char)) {
190
- const sibling = leftBracket ? 'nextSibling' : 'previousSibling';
191
- let cur = this[sibling];
192
- while (cur && (cur.type !== 'text' || !regex.test(cur.data))) {
193
- cur = cur[sibling];
194
- }
195
- if (cur && regex.exec(cur.data)[0] !== char) {
196
- continue;
197
- }
198
- }
199
- }
200
- const lines = data.slice(0, index).split('\n'), startLine = lines.length + top - 1, line = lines[lines.length - 1], startCol = lines.length === 1 ? left + line.length : line.length, e = {
201
- rule: ruleMap[char],
202
- message: index_1.default.msg('lonely "$1"', char === 'h' ? error : char),
203
- severity,
204
- startIndex,
205
- endIndex,
206
- startLine,
207
- endLine: startLine,
208
- startCol,
209
- endCol: startCol + length,
210
- };
211
- if (char === '<') {
212
- e.suggestions = [
213
- {
214
- desc: 'escape',
215
- range: [startIndex, startIndex + 1],
216
- text: '&lt;',
217
- },
218
- ];
219
- }
220
- else if (char === 'h'
221
- && !(type === 'ext-link-text' || type === 'link-text')
222
- && /[\p{L}\d_]/u.test(previousChar || '')) {
223
- e.suggestions = [
224
- {
225
- desc: 'whitespace',
226
- range: [startIndex, startIndex],
227
- text: ' ',
228
- },
229
- ];
230
- }
231
- else if (char === '[' && type === 'ext-link-text') {
232
- const i = parentNode.getAbsoluteIndex() + parentNode.toString().length;
233
- e.suggestions = [
234
- {
235
- desc: 'escape',
236
- range: [i, i + 1],
237
- text: '&#93;',
238
- },
239
- ];
240
- }
241
- else if (char === ']' && previousType === 'free-ext-link' && severity === 'error') {
242
- const i = start - previousSibling.toString().length;
243
- e.fix = { range: [i, i], text: '[' };
244
- }
245
- errors.push(e);
246
- }
247
- return errors;
248
- }
249
- /**
250
- * 修改内容
251
- * @param text 新内容
252
- */
253
- #setData(text) {
254
- /* NOT FOR BROWSER */
255
- const { data } = this, e = new Event('text', { bubbles: true });
256
- /* NOT FOR BROWSER END */
257
- this.setAttribute('data', text);
258
- /* NOT FOR BROWSER */
259
- if (data !== text) {
260
- this.dispatchEvent(e, { type: 'text', oldText: data });
261
- }
262
- }
263
- /**
264
- * 替换字符串
265
- * @param text 替换的字符串
266
- */
267
- replaceData(text) {
268
- this.#setData(text);
269
- }
270
- /** @private */
271
- print() {
272
- return (0, string_1.escape)(this.data);
273
- }
274
- /* NOT FOR BROWSER */
275
- /** 复制 */
276
- cloneNode() {
277
- return new AstText(this.data);
278
- }
279
- /**
280
- * 在后方添加字符串
281
- * @param text 添加的字符串
282
- */
283
- appendData(text) {
284
- this.#setData(this.data + text);
285
- }
286
- /**
287
- * 删减字符串
288
- * @param offset 起始位置
289
- * @param count 删减字符数
290
- */
291
- deleteData(offset, count = Infinity) {
292
- this.#setData(this.data.slice(0, offset) + (offset < 0 && offset + count >= 0 ? '' : this.data.slice(offset + count)));
293
- }
294
- /**
295
- * 插入字符串
296
- * @param offset 插入位置
297
- * @param text 待插入的字符串
298
- */
299
- insertData(offset, text) {
300
- this.#setData(this.data.slice(0, offset) + text + this.data.slice(offset));
301
- }
302
- /**
303
- * 提取子串
304
- * @param offset 起始位置
305
- * @param count 字符数
306
- */
307
- substringData(offset, count) {
308
- return this.data.substr(offset, count);
309
- }
310
- /**
311
- * 将文本子节点分裂为两部分
312
- * @param offset 分裂位置
313
- * @throws `RangeError` 错误的断开位置
314
- * @throws `Error` 没有父节点
315
- */
316
- splitText(offset) {
317
- if (offset > this.length || offset < -this.length) {
318
- throw new RangeError(`Wrong offset to split: ${offset}`);
319
- }
320
- const { parentNode, data } = this;
321
- if (!parentNode) {
322
- throw new Error('The text node to be split has no parent node!');
323
- }
324
- const newText = new AstText(data.slice(offset));
325
- (0, debug_1.setChildNodes)(parentNode, parentNode.childNodes.indexOf(this) + 1, 0, [newText]);
326
- this.setAttribute('data', data.slice(0, offset));
327
- return newText;
328
- }
329
- /** @private */
330
- getRelativeIndex(j) {
331
- if (j === undefined) {
332
- return super.getRelativeIndex();
333
- }
334
- else if (j < 0 || j > this.length) {
335
- throw new RangeError('Exceeding the text length range!');
336
- }
337
- return j;
338
- }
339
- /** 转义 `=` */
340
- escape() {
341
- const { TranscludeToken } = require('../src/transclude');
342
- for (let i = this.data.lastIndexOf('='); i >= 0; i = this.data.lastIndexOf('=', i - 1)) {
343
- if (i < this.length - 1) {
344
- this.splitText(i + 1);
345
- }
346
- this.after(debug_1.Shadow.run(
347
- // @ts-expect-error abstract class
348
- () => new TranscludeToken('=', [], this.parentNode.getAttribute('config'))));
349
- this.#setData(this.data.slice(0, i));
350
- }
351
- }
352
- /**
353
- * 生成HTML
354
- * @param nowrap 是否不换行
355
- */
356
- toHtml(nowrap) {
357
- const { data } = this;
358
- return (0, html_1.font)(this, (0, string_1.sanitize)(nowrap ? data.replaceAll('\n', ' ') : data));
359
- }
360
- /** @private */
361
- removeBlankLines() {
362
- const mt = /\n[^\S\n]*$/u.exec(this.data);
363
- if (/\s$/u.test(this.data)) {
364
- const spaces = [];
365
- let { nextSibling } = this, mt2 = null;
366
- while (nextSibling
367
- && (nextSibling.type === 'comment' || nextSibling.type === 'category' || nextSibling.type === 'text')) {
368
- if (nextSibling.type === 'text') {
369
- const { data } = nextSibling;
370
- mt2 = mt && /^[^\S\n]*(?=\n)/u.exec(data);
371
- if (mt2 || data.trim()) {
372
- break;
373
- }
374
- else {
375
- spaces.push(nextSibling);
376
- }
377
- }
378
- else if (mt && nextSibling.type === 'category') {
379
- const trimmed = this.data.trimEnd();
380
- if (this.data !== trimmed) {
381
- const { length } = trimmed;
382
- this.deleteData(length + this.data.slice(length).indexOf('\n'));
383
- }
384
- for (const space of spaces) {
385
- space.#setData('');
386
- }
387
- spaces.length = 0;
388
- }
389
- ({ nextSibling } = nextSibling);
390
- }
391
- if (mt2 || nextSibling?.type === 'table') {
392
- if (mt) {
393
- this.deleteData(mt.index + (mt2 ? 0 : 1));
394
- if (mt2) {
395
- nextSibling.deleteData(0, mt2[0].length);
396
- }
397
- }
398
- else {
399
- this.#setData(this.data.trimEnd());
400
- }
401
- for (const space of spaces) {
402
- space.#setData('');
403
- }
404
- }
405
- }
406
- }
407
- /** @private */
408
- toHtmlInternal(nowrap) {
409
- this.removeBlankLines();
410
- return this.toHtml(nowrap);
411
- }
412
- }
413
- exports.AstText = AstText;
414
- constants_1.classes['AstText'] = __filename;
@@ -1,49 +0,0 @@
1
- import type { Config } from '../base';
2
- /** MediaWiki页面标题对象 */
3
- export declare class Title {
4
- #private;
5
- interwiki: string;
6
- readonly valid: boolean;
7
- /** 命名空间 */
8
- get ns(): number;
9
- /** 片段标识符 */
10
- get fragment(): string | undefined;
11
- /** 不含命名空间的标题主体部分 */
12
- get main(): string;
13
- set main(title: string);
14
- /** 命名空间前缀 */
15
- get prefix(): string;
16
- /** 完整标题 */
17
- get title(): string;
18
- /** 扩展名 */
19
- get extension(): string | undefined;
20
- set extension(extension: string | undefined);
21
- /** @throws `RangeError` undefined namespace */
22
- set ns(ns: number);
23
- set fragment(fragment: string | undefined);
24
- /**
25
- * @see MediaWikiTitleCodec::splitTitleString
26
- *
27
- * @param title 标题(含或不含命名空间前缀)
28
- * @param defaultNs 命名空间
29
- * @param decode 是否需要解码
30
- * @param selfLink 是否允许selfLink
31
- */
32
- constructor(title: string, defaultNs: number, config: Config, decode: boolean, selfLink: boolean);
33
- /** 检测是否是重定向 */
34
- getRedirection(): [boolean, string];
35
- /** 执行单向转换 */
36
- autoConvert(): void;
37
- /** 转换为主页面 */
38
- toSubjectPage(): void;
39
- /** 转换为讨论页面 */
40
- toTalkPage(): void;
41
- /** 是否是讨论页 */
42
- isTalkPage(): boolean;
43
- /** 转换为上一级页面 */
44
- toBasePage(): void;
45
- /** 转换为根页面 */
46
- toRootPage(): void;
47
- /** 生成URL */
48
- getUrl(): string;
49
- }