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