wikiparser-node 1.11.0 → 1.11.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 (172) hide show
  1. package/bundle/bundle.min.js +38 -0
  2. package/config/enwiki.json +1 -814
  3. package/config/llwiki.json +1 -35
  4. package/config/moegirl.json +1 -44
  5. package/config/zhwiki.json +1 -466
  6. package/extensions/dist/base.js +64 -0
  7. package/extensions/dist/editor.js +159 -0
  8. package/extensions/dist/highlight.js +56 -0
  9. package/extensions/dist/lint.js +72 -0
  10. package/extensions/editor.css +64 -0
  11. package/extensions/ui.css +144 -0
  12. package/package.json +28 -35
  13. package/config/.schema.json +0 -186
  14. package/dist/addon/table.js +0 -486
  15. package/dist/addon/token.js +0 -304
  16. package/dist/addon/transclude.js +0 -184
  17. package/dist/base.d.ts +0 -81
  18. package/dist/base.js +0 -39
  19. package/dist/index.d.ts +0 -33
  20. package/dist/index.js +0 -235
  21. package/dist/internal.d.ts +0 -46
  22. package/dist/lib/element.d.ts +0 -125
  23. package/dist/lib/element.js +0 -375
  24. package/dist/lib/node.d.ts +0 -173
  25. package/dist/lib/node.js +0 -478
  26. package/dist/lib/range.d.ts +0 -105
  27. package/dist/lib/range.js +0 -406
  28. package/dist/lib/ranges.d.ts +0 -28
  29. package/dist/lib/ranges.js +0 -126
  30. package/dist/lib/rect.d.ts +0 -18
  31. package/dist/lib/rect.js +0 -34
  32. package/dist/lib/text.d.ts +0 -58
  33. package/dist/lib/text.js +0 -400
  34. package/dist/lib/title.d.ts +0 -42
  35. package/dist/lib/title.js +0 -208
  36. package/dist/mixin/attributesParent.d.ts +0 -49
  37. package/dist/mixin/attributesParent.js +0 -79
  38. package/dist/mixin/fixed.d.ts +0 -5
  39. package/dist/mixin/fixed.js +0 -32
  40. package/dist/mixin/flagsParent.d.ts +0 -43
  41. package/dist/mixin/flagsParent.js +0 -64
  42. package/dist/mixin/hidden.d.ts +0 -7
  43. package/dist/mixin/hidden.js +0 -37
  44. package/dist/mixin/magicLinkParent.d.ts +0 -19
  45. package/dist/mixin/magicLinkParent.js +0 -43
  46. package/dist/mixin/singleLine.d.ts +0 -5
  47. package/dist/mixin/singleLine.js +0 -25
  48. package/dist/mixin/sol.d.ts +0 -6
  49. package/dist/mixin/sol.js +0 -45
  50. package/dist/mixin/syntax.d.ts +0 -8
  51. package/dist/mixin/syntax.js +0 -46
  52. package/dist/parser/braces.js +0 -150
  53. package/dist/parser/commentAndExt.js +0 -79
  54. package/dist/parser/converter.js +0 -39
  55. package/dist/parser/externalLinks.js +0 -37
  56. package/dist/parser/hrAndDoubleUnderscore.js +0 -42
  57. package/dist/parser/html.js +0 -38
  58. package/dist/parser/links.js +0 -101
  59. package/dist/parser/list.js +0 -114
  60. package/dist/parser/magicLinks.js +0 -52
  61. package/dist/parser/quotes.js +0 -67
  62. package/dist/parser/redirect.js +0 -26
  63. package/dist/parser/selector.js +0 -394
  64. package/dist/parser/table.js +0 -123
  65. package/dist/src/arg.d.ts +0 -51
  66. package/dist/src/arg.js +0 -214
  67. package/dist/src/atom.d.ts +0 -14
  68. package/dist/src/atom.js +0 -52
  69. package/dist/src/attribute.d.ts +0 -64
  70. package/dist/src/attribute.js +0 -480
  71. package/dist/src/attributes.d.ts +0 -101
  72. package/dist/src/attributes.js +0 -381
  73. package/dist/src/converter.d.ts +0 -28
  74. package/dist/src/converter.js +0 -148
  75. package/dist/src/converterFlags.d.ts +0 -80
  76. package/dist/src/converterFlags.js +0 -239
  77. package/dist/src/converterRule.d.ts +0 -71
  78. package/dist/src/converterRule.js +0 -216
  79. package/dist/src/extLink.d.ts +0 -36
  80. package/dist/src/extLink.js +0 -218
  81. package/dist/src/gallery.d.ts +0 -47
  82. package/dist/src/gallery.js +0 -143
  83. package/dist/src/heading.d.ts +0 -40
  84. package/dist/src/heading.js +0 -192
  85. package/dist/src/hidden.d.ts +0 -9
  86. package/dist/src/hidden.js +0 -80
  87. package/dist/src/html.d.ts +0 -61
  88. package/dist/src/html.js +0 -343
  89. package/dist/src/imageParameter.d.ts +0 -60
  90. package/dist/src/imageParameter.js +0 -260
  91. package/dist/src/imagemap.d.ts +0 -47
  92. package/dist/src/imagemap.js +0 -146
  93. package/dist/src/imagemapLink.d.ts +0 -31
  94. package/dist/src/imagemapLink.js +0 -97
  95. package/dist/src/index.d.ts +0 -136
  96. package/dist/src/index.js +0 -834
  97. package/dist/src/link/base.d.ts +0 -52
  98. package/dist/src/link/base.js +0 -256
  99. package/dist/src/link/category.d.ts +0 -22
  100. package/dist/src/link/category.js +0 -34
  101. package/dist/src/link/file.d.ts +0 -102
  102. package/dist/src/link/file.js +0 -333
  103. package/dist/src/link/galleryImage.d.ts +0 -29
  104. package/dist/src/link/galleryImage.js +0 -132
  105. package/dist/src/link/index.d.ts +0 -39
  106. package/dist/src/link/index.js +0 -98
  107. package/dist/src/link/redirectTarget.d.ts +0 -27
  108. package/dist/src/link/redirectTarget.js +0 -69
  109. package/dist/src/magicLink.d.ts +0 -58
  110. package/dist/src/magicLink.js +0 -256
  111. package/dist/src/nested.d.ts +0 -40
  112. package/dist/src/nested.js +0 -106
  113. package/dist/src/nowiki/base.d.ts +0 -28
  114. package/dist/src/nowiki/base.js +0 -89
  115. package/dist/src/nowiki/comment.d.ts +0 -14
  116. package/dist/src/nowiki/comment.js +0 -121
  117. package/dist/src/nowiki/dd.d.ts +0 -8
  118. package/dist/src/nowiki/dd.js +0 -72
  119. package/dist/src/nowiki/doubleUnderscore.d.ts +0 -15
  120. package/dist/src/nowiki/doubleUnderscore.js +0 -97
  121. package/dist/src/nowiki/hr.d.ts +0 -5
  122. package/dist/src/nowiki/hr.js +0 -70
  123. package/dist/src/nowiki/index.d.ts +0 -14
  124. package/dist/src/nowiki/index.js +0 -28
  125. package/dist/src/nowiki/list.d.ts +0 -5
  126. package/dist/src/nowiki/list.js +0 -65
  127. package/dist/src/nowiki/listBase.d.ts +0 -23
  128. package/dist/src/nowiki/listBase.js +0 -99
  129. package/dist/src/nowiki/noinclude.d.ts +0 -6
  130. package/dist/src/nowiki/noinclude.js +0 -75
  131. package/dist/src/nowiki/quote.d.ts +0 -14
  132. package/dist/src/nowiki/quote.js +0 -140
  133. package/dist/src/onlyinclude.d.ts +0 -13
  134. package/dist/src/onlyinclude.js +0 -58
  135. package/dist/src/paramTag/index.d.ts +0 -28
  136. package/dist/src/paramTag/index.js +0 -78
  137. package/dist/src/paramTag/inputbox.d.ts +0 -8
  138. package/dist/src/paramTag/inputbox.js +0 -22
  139. package/dist/src/parameter.d.ts +0 -60
  140. package/dist/src/parameter.js +0 -264
  141. package/dist/src/pre.d.ts +0 -28
  142. package/dist/src/pre.js +0 -60
  143. package/dist/src/redirect.d.ts +0 -30
  144. package/dist/src/redirect.js +0 -126
  145. package/dist/src/syntax.d.ts +0 -17
  146. package/dist/src/syntax.js +0 -87
  147. package/dist/src/table/base.d.ts +0 -28
  148. package/dist/src/table/base.js +0 -81
  149. package/dist/src/table/index.d.ts +0 -230
  150. package/dist/src/table/index.js +0 -506
  151. package/dist/src/table/td.d.ts +0 -72
  152. package/dist/src/table/td.js +0 -370
  153. package/dist/src/table/tr.d.ts +0 -30
  154. package/dist/src/table/tr.js +0 -59
  155. package/dist/src/table/trBase.d.ts +0 -49
  156. package/dist/src/table/trBase.js +0 -164
  157. package/dist/src/tagPair/ext.d.ts +0 -29
  158. package/dist/src/tagPair/ext.js +0 -220
  159. package/dist/src/tagPair/include.d.ts +0 -33
  160. package/dist/src/tagPair/include.js +0 -130
  161. package/dist/src/tagPair/index.d.ts +0 -23
  162. package/dist/src/tagPair/index.js +0 -128
  163. package/dist/src/transclude.d.ts +0 -159
  164. package/dist/src/transclude.js +0 -587
  165. package/dist/util/constants.js +0 -25
  166. package/dist/util/debug.js +0 -95
  167. package/dist/util/diff.js +0 -83
  168. package/dist/util/html.js +0 -143
  169. package/dist/util/lint.js +0 -32
  170. package/dist/util/string.js +0 -87
  171. package/errors/README +0 -3
  172. package/printed/README +0 -3
package/dist/src/arg.js DELETED
@@ -1,214 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ArgToken = void 0;
4
- const string_1 = require("../util/string");
5
- const lint_1 = require("../util/lint");
6
- const rect_1 = require("../lib/rect");
7
- const constants_1 = require("../util/constants");
8
- const debug_1 = require("../util/debug");
9
- const index_1 = require("../index");
10
- const index_2 = require("./index");
11
- const atom_1 = require("./atom");
12
- const hidden_1 = require("./hidden");
13
- /**
14
- * `{{{}}}`包裹的参数
15
- * @classdesc `{childNodes: [AtomToken, ?Token, ...HiddenToken]}`
16
- */
17
- class ArgToken extends index_2.Token {
18
- /* NOT FOR BROWSER END */
19
- get type() {
20
- return 'arg';
21
- }
22
- /** 预设值 */
23
- get default() {
24
- return this.childNodes[1]?.text() ?? false;
25
- }
26
- /* NOT FOR BROWSER */
27
- set default(value) {
28
- this.setDefault(value);
29
- }
30
- /* NOT FOR BROWSER END */
31
- /** @param parts 以'|'分隔的各部分 */
32
- constructor(parts, config = index_1.default.getConfig(), accum = []) {
33
- super(undefined, config, accum, {
34
- AtomToken: 0, Token: 1, HiddenToken: '2:',
35
- });
36
- for (let i = 0; i < parts.length; i++) {
37
- if (i === 0) {
38
- const token = new atom_1.AtomToken(parts[i], 'arg-name', config, accum, {
39
- 'Stage-2': ':', '!HeadingToken': '',
40
- });
41
- super.insertAt(token);
42
- }
43
- else if (i > 1) {
44
- const token = new hidden_1.HiddenToken(parts[i], config, accum);
45
- super.insertAt(token);
46
- }
47
- else {
48
- const token = new index_2.Token(parts[i], config, accum);
49
- token.type = 'arg-default';
50
- token.setAttribute('stage', 2);
51
- super.insertAt(token);
52
- }
53
- }
54
- /* NOT FOR BROWSER */
55
- this.protectChildren(0);
56
- }
57
- /** @private */
58
- toString(skip) {
59
- return `{{{${super.toString(skip, '|')}}}}`;
60
- }
61
- /** @private */
62
- text() {
63
- return `{{{${(0, string_1.text)(this.childNodes.slice(0, 2), '|')}}}}`;
64
- }
65
- /** @private */
66
- getAttribute(key) {
67
- return key === 'padding' ? 3 : super.getAttribute(key);
68
- }
69
- /** @private */
70
- getGaps() {
71
- return 1;
72
- }
73
- /** @private */
74
- lint(start = this.getAbsoluteIndex(), re) {
75
- const { childNodes: [argName, argDefault, ...rest] } = this;
76
- if (!this.getAttribute('include')) {
77
- const e = (0, lint_1.generateForSelf)(this, { start }, 'no-arg', 'unexpected template argument');
78
- if (argDefault) {
79
- e.fix = { range: [start, e.endIndex], text: argDefault.text() };
80
- }
81
- return [e];
82
- }
83
- const errors = argName.lint(start + 3, re);
84
- if (argDefault) {
85
- errors.push(...argDefault.lint(start + 4 + argName.toString().length, re));
86
- }
87
- if (rest.length > 0) {
88
- const rect = new rect_1.BoundingRect(this, start);
89
- errors.push(...rest.map(child => {
90
- const e = (0, lint_1.generateForChild)(child, rect, 'no-ignored', 'invisible content inside triple braces');
91
- e.startIndex--;
92
- e.startCol--;
93
- e.suggestions = [
94
- {
95
- desc: 'remove',
96
- range: [e.startIndex, e.endIndex],
97
- text: '',
98
- },
99
- {
100
- desc: 'escape',
101
- range: [e.startIndex, e.startIndex + 1],
102
- text: '{{!}}',
103
- },
104
- ];
105
- return e;
106
- }));
107
- }
108
- return errors;
109
- }
110
- /** @private */
111
- print() {
112
- return super.print({ pre: '{{{', post: '}}}', sep: '|' });
113
- }
114
- /** @override */
115
- json() {
116
- const json = super.json();
117
- json['default'] = this.default;
118
- return json;
119
- }
120
- /* NOT FOR BROWSER */
121
- cloneNode() {
122
- const [name, ...cloned] = this.cloneChildNodes();
123
- return debug_1.Shadow.run(() => {
124
- // @ts-expect-error abstract class
125
- const token = new ArgToken([''], this.getAttribute('config'));
126
- token.firstChild.safeReplaceWith(name);
127
- token.append(...cloned);
128
- return token;
129
- });
130
- }
131
- /** 设置name */
132
- #setName() {
133
- this.setAttribute('name', this.firstChild.toString(true).trim());
134
- }
135
- /** @private */
136
- afterBuild() {
137
- this.#setName();
138
- super.afterBuild();
139
- const /** @implements */ argListener = ({ prevTarget }) => {
140
- if (prevTarget === this.firstChild) {
141
- this.#setName();
142
- }
143
- };
144
- this.addEventListener(['remove', 'insert', 'replace', 'text'], argListener);
145
- }
146
- /** 移除无效部分 */
147
- removeRedundant() {
148
- debug_1.Shadow.run(() => {
149
- for (let i = this.length - 1; i > 1; i--) {
150
- super.removeAt(i);
151
- }
152
- });
153
- }
154
- /**
155
- * @override
156
- * @param i 移除位置
157
- */
158
- removeAt(i) {
159
- if (i === 1) {
160
- this.removeRedundant();
161
- }
162
- return super.removeAt(i);
163
- }
164
- /**
165
- * @override
166
- * @param token 待插入的子节点
167
- * @param i 插入位置
168
- */
169
- insertAt(token, i = this.length) {
170
- i += i < 0 ? this.length : 0;
171
- if (debug_1.Shadow.running) {
172
- //
173
- }
174
- else if (i > 1) {
175
- this.constructorError('cannot insert redundant child nodes');
176
- }
177
- else if (typeof token === 'string') {
178
- this.constructorError('cannot insert text nodes');
179
- }
180
- super.insertAt(token, i);
181
- if (i === 1) {
182
- token.type = 'arg-default';
183
- }
184
- return token;
185
- }
186
- /**
187
- * 设置参数名
188
- * @param name 新参数名
189
- */
190
- setName(name) {
191
- const { childNodes } = index_1.default.parse(name, this.getAttribute('include'), 2, this.getAttribute('config'));
192
- this.firstChild.replaceChildren(...childNodes);
193
- }
194
- /**
195
- * 设置预设值
196
- * @param value 预设值
197
- */
198
- setDefault(value) {
199
- if (value === false) {
200
- this.removeAt(1);
201
- return;
202
- }
203
- const root = index_1.default.parse(value, this.getAttribute('include'), undefined, this.getAttribute('config')), { childNodes: [, oldDefault] } = this;
204
- if (oldDefault) {
205
- oldDefault.replaceChildren(...root.childNodes);
206
- }
207
- else {
208
- root.type = 'arg-default';
209
- this.insertAt(root);
210
- }
211
- }
212
- }
213
- exports.ArgToken = ArgToken;
214
- constants_1.classes['ArgToken'] = __filename;
@@ -1,14 +0,0 @@
1
- import { Token } from './index';
2
- import type { Config } from '../base';
3
- declare const atomTypes: readonly ["arg-name", "attr-key", "attr-value", "ext-attr-dirty", "html-attr-dirty", "table-attr-dirty", "converter-flag", "converter-rule-variant", "converter-rule-to", "converter-rule-from", "invoke-function", "invoke-module", "template-name", "link-target", "param-line"];
4
- declare type AtomTypes = typeof atomTypes[number];
5
- /** 不会被继续解析的plain Token */
6
- export declare class AtomToken extends Token {
7
- #private;
8
- get type(): AtomTypes;
9
- set type(value: AtomTypes);
10
- /** @class */
11
- constructor(wikitext: string | undefined, type: AtomTypes, config?: Config, accum?: Token[], acceptable?: Acceptable);
12
- cloneNode(): this;
13
- }
14
- export {};
package/dist/src/atom.js DELETED
@@ -1,52 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AtomToken = void 0;
4
- const debug_1 = require("../util/debug");
5
- const constants_1 = require("../util/constants");
6
- const index_1 = require("./index");
7
- const atomTypes = [
8
- 'arg-name',
9
- 'attr-key',
10
- 'attr-value',
11
- 'ext-attr-dirty',
12
- 'html-attr-dirty',
13
- 'table-attr-dirty',
14
- 'converter-flag',
15
- 'converter-rule-variant',
16
- 'converter-rule-to',
17
- 'converter-rule-from',
18
- 'invoke-function',
19
- 'invoke-module',
20
- 'template-name',
21
- 'link-target',
22
- 'param-line',
23
- ];
24
- /** 不会被继续解析的plain Token */
25
- class AtomToken extends index_1.Token {
26
- #type;
27
- get type() {
28
- return this.#type;
29
- }
30
- set type(value) {
31
- if (!atomTypes.includes(value)) {
32
- throw new RangeError(`"${value}" is not a valid type for AtomToken!`);
33
- }
34
- this.#type = value;
35
- }
36
- /** @class */
37
- constructor(wikitext, type, config, accum, acceptable) {
38
- super(wikitext, config, accum, acceptable);
39
- this.#type = type;
40
- }
41
- /* NOT FOR BROWSER */
42
- cloneNode() {
43
- const cloned = this.cloneChildNodes(), config = this.getAttribute('config'), acceptable = this.getAcceptable();
44
- return debug_1.Shadow.run(() => {
45
- const token = new AtomToken(undefined, this.type, config, [], acceptable);
46
- token.append(...cloned);
47
- return token;
48
- });
49
- }
50
- }
51
- exports.AtomToken = AtomToken;
52
- constants_1.classes['AtomToken'] = __filename;
@@ -1,64 +0,0 @@
1
- import Parser from '../index';
2
- import { Token } from './index';
3
- import { AtomToken } from './atom';
4
- import type { LintError } from '../base';
5
- import type { AttributesToken } from '../internal';
6
- export type AttributeTypes = 'ext-attr' | 'html-attr' | 'table-attr';
7
- /**
8
- * 扩展和HTML标签属性
9
- * @classdesc `{childNodes: [AtomToken, Token|AtomToken]}`
10
- */
11
- export declare abstract class AttributeToken extends Token {
12
- #private;
13
- readonly name: string;
14
- readonly childNodes: readonly [AtomToken, Token];
15
- abstract get firstChild(): AtomToken;
16
- abstract get lastChild(): Token;
17
- abstract get parentNode(): AttributesToken | undefined;
18
- abstract get nextSibling(): AtomToken | this | undefined;
19
- abstract get previousSibling(): AtomToken | this | undefined;
20
- abstract get children(): [AtomToken, Token];
21
- abstract get firstElementChild(): AtomToken;
22
- abstract get lastElementChild(): Token;
23
- abstract get parentElement(): AttributesToken | undefined;
24
- abstract get nextElementSibling(): AtomToken | this | undefined;
25
- abstract get previousElementSibling(): AtomToken | this | undefined;
26
- get type(): AttributeTypes;
27
- /** 标签名 */
28
- get tag(): string;
29
- /** 引号是否匹配 */
30
- get balanced(): boolean;
31
- set balanced(value: boolean);
32
- /** getValue()的getter */
33
- get value(): string | true;
34
- set value(value: string | true);
35
- /**
36
- * @param type 标签类型
37
- * @param tag 标签名
38
- * @param key 属性名
39
- * @param equal 等号
40
- * @param value 属性值
41
- * @param quotes 引号
42
- */
43
- constructor(type: AttributeTypes, tag: string, key: string, equal?: string, value?: string, quotes?: readonly [string?, string?], config?: Parser.Config, accum?: Token[]);
44
- /** 获取属性值 */
45
- getValue(): string | true;
46
- cloneNode(): this;
47
- /** 转义等号 */
48
- escape(): void;
49
- /** 闭合引号 */
50
- close(): void;
51
- /**
52
- * 设置属性值
53
- * @param value 参数值
54
- * @throws `RangeError` 扩展标签属性不能包含 ">"
55
- * @throws `RangeError` 同时包含单引号和双引号
56
- */
57
- setValue(value: string | boolean): void;
58
- /**
59
- * 修改属性名
60
- * @param key 新属性名
61
- * @throws `Error` title和alt属性不能更名
62
- */
63
- rename(key: string): void;
64
- }