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