wikiparser-node 1.3.7 → 1.3.8-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 (153) hide show
  1. package/bundle/bundle.min.js +36 -0
  2. package/config/llwiki.json +1 -35
  3. package/config/moegirl.json +1 -44
  4. package/config/zhwiki.json +1 -466
  5. package/extensions/dist/base.js +64 -0
  6. package/extensions/dist/editor.js +159 -0
  7. package/extensions/dist/highlight.js +30 -0
  8. package/extensions/dist/lint.js +48 -0
  9. package/extensions/editor.css +63 -0
  10. package/extensions/ui.css +114 -0
  11. package/package.json +31 -13
  12. package/config/.schema.json +0 -172
  13. package/dist/addon/table.d.ts +0 -6
  14. package/dist/addon/table.js +0 -558
  15. package/dist/base.d.ts +0 -45
  16. package/dist/index.d.ts +0 -32
  17. package/dist/index.js +0 -209
  18. package/dist/internal.d.ts +0 -44
  19. package/dist/lib/element.d.ts +0 -154
  20. package/dist/lib/element.js +0 -630
  21. package/dist/lib/node.d.ts +0 -146
  22. package/dist/lib/node.js +0 -417
  23. package/dist/lib/range.d.ts +0 -104
  24. package/dist/lib/range.js +0 -385
  25. package/dist/lib/ranges.d.ts +0 -26
  26. package/dist/lib/ranges.js +0 -118
  27. package/dist/lib/text.d.ts +0 -62
  28. package/dist/lib/text.js +0 -255
  29. package/dist/lib/title.d.ts +0 -38
  30. package/dist/lib/title.js +0 -162
  31. package/dist/mixin/attributesParent.js +0 -89
  32. package/dist/mixin/fixed.js +0 -25
  33. package/dist/mixin/flagsParent.js +0 -70
  34. package/dist/mixin/hidden.js +0 -26
  35. package/dist/mixin/magicLinkParent.js +0 -41
  36. package/dist/mixin/singleLine.js +0 -25
  37. package/dist/mixin/sol.js +0 -43
  38. package/dist/mixin/syntax.js +0 -54
  39. package/dist/parser/braces.js +0 -128
  40. package/dist/parser/commentAndExt.js +0 -80
  41. package/dist/parser/converter.js +0 -40
  42. package/dist/parser/externalLinks.js +0 -28
  43. package/dist/parser/hrAndDoubleUnderscore.js +0 -38
  44. package/dist/parser/html.js +0 -36
  45. package/dist/parser/links.js +0 -94
  46. package/dist/parser/list.js +0 -66
  47. package/dist/parser/magicLinks.js +0 -40
  48. package/dist/parser/quotes.js +0 -67
  49. package/dist/parser/selector.js +0 -162
  50. package/dist/parser/table.js +0 -120
  51. package/dist/src/arg.d.ts +0 -56
  52. package/dist/src/arg.js +0 -187
  53. package/dist/src/atom.d.ts +0 -12
  54. package/dist/src/atom.js +0 -27
  55. package/dist/src/attribute.d.ts +0 -88
  56. package/dist/src/attribute.js +0 -398
  57. package/dist/src/attributes.d.ts +0 -109
  58. package/dist/src/attributes.js +0 -343
  59. package/dist/src/converter.d.ts +0 -53
  60. package/dist/src/converter.js +0 -79
  61. package/dist/src/converterFlags.d.ts +0 -87
  62. package/dist/src/converterFlags.js +0 -224
  63. package/dist/src/converterRule.d.ts +0 -77
  64. package/dist/src/converterRule.js +0 -208
  65. package/dist/src/extLink.d.ts +0 -55
  66. package/dist/src/extLink.js +0 -122
  67. package/dist/src/gallery.d.ts +0 -54
  68. package/dist/src/gallery.js +0 -121
  69. package/dist/src/heading.d.ts +0 -76
  70. package/dist/src/heading.js +0 -127
  71. package/dist/src/hidden.d.ts +0 -23
  72. package/dist/src/hidden.js +0 -23
  73. package/dist/src/html.d.ts +0 -104
  74. package/dist/src/html.js +0 -226
  75. package/dist/src/imageParameter.d.ts +0 -65
  76. package/dist/src/imageParameter.js +0 -245
  77. package/dist/src/imagemap.d.ts +0 -56
  78. package/dist/src/imagemap.js +0 -147
  79. package/dist/src/imagemapLink.d.ts +0 -61
  80. package/dist/src/imagemapLink.js +0 -40
  81. package/dist/src/index.d.ts +0 -140
  82. package/dist/src/index.js +0 -769
  83. package/dist/src/link/base.d.ts +0 -52
  84. package/dist/src/link/base.js +0 -209
  85. package/dist/src/link/category.d.ts +0 -13
  86. package/dist/src/link/category.js +0 -29
  87. package/dist/src/link/file.d.ts +0 -96
  88. package/dist/src/link/file.js +0 -257
  89. package/dist/src/link/galleryImage.d.ts +0 -45
  90. package/dist/src/link/galleryImage.js +0 -106
  91. package/dist/src/link/index.d.ts +0 -53
  92. package/dist/src/link/index.js +0 -124
  93. package/dist/src/magicLink.d.ts +0 -69
  94. package/dist/src/magicLink.js +0 -147
  95. package/dist/src/nested.d.ts +0 -43
  96. package/dist/src/nested.js +0 -86
  97. package/dist/src/nowiki/base.d.ts +0 -48
  98. package/dist/src/nowiki/base.js +0 -42
  99. package/dist/src/nowiki/comment.d.ts +0 -41
  100. package/dist/src/nowiki/comment.js +0 -67
  101. package/dist/src/nowiki/dd.d.ts +0 -8
  102. package/dist/src/nowiki/dd.js +0 -25
  103. package/dist/src/nowiki/doubleUnderscore.d.ts +0 -47
  104. package/dist/src/nowiki/doubleUnderscore.js +0 -50
  105. package/dist/src/nowiki/hr.d.ts +0 -33
  106. package/dist/src/nowiki/hr.js +0 -14
  107. package/dist/src/nowiki/index.d.ts +0 -16
  108. package/dist/src/nowiki/index.js +0 -21
  109. package/dist/src/nowiki/list.d.ts +0 -31
  110. package/dist/src/nowiki/list.js +0 -48
  111. package/dist/src/nowiki/listBase.d.ts +0 -20
  112. package/dist/src/nowiki/listBase.js +0 -12
  113. package/dist/src/nowiki/noinclude.d.ts +0 -26
  114. package/dist/src/nowiki/noinclude.js +0 -24
  115. package/dist/src/nowiki/quote.d.ts +0 -24
  116. package/dist/src/nowiki/quote.js +0 -45
  117. package/dist/src/onlyinclude.d.ts +0 -16
  118. package/dist/src/onlyinclude.js +0 -57
  119. package/dist/src/paramTag/index.d.ts +0 -37
  120. package/dist/src/paramTag/index.js +0 -68
  121. package/dist/src/paramTag/inputbox.d.ts +0 -8
  122. package/dist/src/paramTag/inputbox.js +0 -23
  123. package/dist/src/parameter.d.ts +0 -86
  124. package/dist/src/parameter.js +0 -205
  125. package/dist/src/pre.d.ts +0 -28
  126. package/dist/src/pre.js +0 -51
  127. package/dist/src/syntax.d.ts +0 -30
  128. package/dist/src/syntax.js +0 -34
  129. package/dist/src/table/base.d.ts +0 -59
  130. package/dist/src/table/base.js +0 -78
  131. package/dist/src/table/index.d.ts +0 -228
  132. package/dist/src/table/index.js +0 -379
  133. package/dist/src/table/td.d.ts +0 -107
  134. package/dist/src/table/td.js +0 -263
  135. package/dist/src/table/tr.d.ts +0 -32
  136. package/dist/src/table/tr.js +0 -56
  137. package/dist/src/table/trBase.d.ts +0 -53
  138. package/dist/src/table/trBase.js +0 -153
  139. package/dist/src/tagPair/ext.d.ts +0 -58
  140. package/dist/src/tagPair/ext.js +0 -140
  141. package/dist/src/tagPair/include.d.ts +0 -54
  142. package/dist/src/tagPair/include.js +0 -63
  143. package/dist/src/tagPair/index.d.ts +0 -49
  144. package/dist/src/tagPair/index.js +0 -93
  145. package/dist/src/transclude.d.ts +0 -167
  146. package/dist/src/transclude.js +0 -698
  147. package/dist/util/constants.js +0 -113
  148. package/dist/util/debug.js +0 -83
  149. package/dist/util/diff.js +0 -72
  150. package/dist/util/lint.js +0 -30
  151. package/dist/util/string.js +0 -51
  152. package/errors/README +0 -1
  153. package/printed/README +0 -1
package/dist/src/arg.js DELETED
@@ -1,187 +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
- /* NOT FOR BROWSER */
97
- /** @override */
98
- cloneNode() {
99
- const [name, ...cloned] = this.cloneChildNodes();
100
- return debug_1.Shadow.run(() => {
101
- const token = new ArgToken([''], this.getAttribute('config'));
102
- token.firstChild.safeReplaceWith(name);
103
- token.append(...cloned);
104
- token.afterBuild();
105
- return token;
106
- });
107
- }
108
- /** 设置name */
109
- #setName() {
110
- this.setAttribute('name', this.firstChild.text().trim());
111
- }
112
- /** @private */
113
- afterBuild() {
114
- this.#setName();
115
- const /** @implements */ argListener = ({ prevTarget }) => {
116
- if (prevTarget === this.firstChild) {
117
- this.#setName();
118
- }
119
- };
120
- this.addEventListener(['remove', 'insert', 'replace', 'text'], argListener);
121
- }
122
- /** 移除无效部分 */
123
- removeRedundant() {
124
- debug_1.Shadow.run(() => {
125
- for (let i = this.length - 1; i > 1; i--) {
126
- super.removeAt(i);
127
- }
128
- });
129
- }
130
- /**
131
- * @override
132
- * @param i 移除位置
133
- */
134
- removeAt(i) {
135
- if (i === 1) {
136
- this.removeRedundant();
137
- }
138
- return super.removeAt(i);
139
- }
140
- /**
141
- * @override
142
- * @param token 待插入的子节点
143
- * @param i 插入位置
144
- */
145
- insertAt(token, i = this.length) {
146
- i += i < 0 ? this.length : 0;
147
- if (i > 1) {
148
- this.constructorError('不可插入多余的子节点');
149
- }
150
- else if (typeof token === 'string') {
151
- this.constructorError('不可插入文本节点');
152
- }
153
- super.insertAt(token, i);
154
- if (i === 1) {
155
- token.type = 'arg-default';
156
- }
157
- return token;
158
- }
159
- /**
160
- * 设置参数名
161
- * @param name 新参数名
162
- */
163
- setName(name) {
164
- const { childNodes } = Parser.parse(name, this.getAttribute('include'), 2, this.getAttribute('config'));
165
- this.firstChild.replaceChildren(...childNodes);
166
- }
167
- /**
168
- * 设置预设值
169
- * @param value 预设值
170
- */
171
- setDefault(value) {
172
- if (value === false) {
173
- this.removeAt(1);
174
- return;
175
- }
176
- const root = Parser.parse(value, this.getAttribute('include'), undefined, this.getAttribute('config')), { childNodes: [, oldDefault] } = this;
177
- if (oldDefault) {
178
- oldDefault.replaceChildren(...root.childNodes);
179
- }
180
- else {
181
- root.type = 'arg-default';
182
- this.insertAt(root);
183
- }
184
- }
185
- }
186
- exports.ArgToken = ArgToken;
187
- 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,88 +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
- declare const AttributeToken_base: ((abstract new (...args: any[]) => {
8
- removeAt(): never;
9
- insertAt(token: string, i?: number | undefined): Parser.AstText;
10
- insertAt<T extends Parser.AstNodes>(token: T, i?: number | undefined): T;
11
- readonly length: number;
12
- toString(omit?: Set<string> | undefined, separator?: string | undefined): string;
13
- text(separator?: string | undefined): string;
14
- lint(start?: number | undefined): Parser.LintError[];
15
- afterBuild(): void;
16
- getAttribute<T_1 extends string>(key: T_1): TokenAttributeGetter<T_1>;
17
- setAttribute<T_2 extends string>(key: T_2, value: TokenAttributeSetter<T_2>): void;
18
- addEventListener(events: string | string[], listener: AstListener): void;
19
- replaceChildren(...elements: (string | Parser.AstNodes)[]): void;
20
- constructorError(msg: string): never;
21
- }) & {
22
- readonly fixed: true;
23
- }) & typeof Parser.Token;
24
- /**
25
- * 扩展和HTML标签属性
26
- * @classdesc `{childNodes: [AtomToken, Token|AtomToken]}`
27
- */
28
- export declare class AttributeToken extends AttributeToken_base {
29
- #private;
30
- type: AttributeTypes;
31
- readonly name: string;
32
- readonly tag: string;
33
- readonly childNodes: [AtomToken, Token];
34
- abstract get children(): [AtomToken, Token];
35
- abstract get firstChild(): AtomToken;
36
- abstract get firstElementChild(): AtomToken;
37
- abstract get lastChild(): Token;
38
- abstract get lastElementChild(): Token;
39
- abstract get parentNode(): AttributesToken | undefined;
40
- abstract get parentElement(): AttributesToken | undefined;
41
- abstract get nextSibling(): AtomToken | this | undefined;
42
- abstract get nextElementSibling(): AtomToken | this | undefined;
43
- abstract get previousSibling(): AtomToken | this | undefined;
44
- abstract get previousElementSibling(): AtomToken | this | undefined;
45
- /** 引号是否匹配 */
46
- get balanced(): boolean;
47
- set balanced(value: boolean);
48
- /** getValue()的getter */
49
- get value(): string | true;
50
- set value(value: string | true);
51
- /**
52
- * @param type 标签类型
53
- * @param tag 标签名
54
- * @param key 属性名
55
- * @param equal 等号
56
- * @param value 属性值
57
- * @param quotes 引号
58
- */
59
- constructor(type: AttributeTypes, tag: string, key: string, equal?: string, value?: string, quotes?: readonly [string?, string?], config?: Parser.Config, accum?: Token[]);
60
- /** @override */
61
- text(): string;
62
- /** @override */
63
- lint(start?: number): LintError[];
64
- /** 获取属性值 */
65
- getValue(): string | true;
66
- /** @override */
67
- print(): string;
68
- /** @override */
69
- cloneNode(): this;
70
- /** 转义等号 */
71
- escape(): void;
72
- /** 闭合引号 */
73
- close(): void;
74
- /**
75
- * 设置属性值
76
- * @param value 参数值
77
- * @throws `RangeError` 扩展标签属性不能包含 ">"
78
- * @throws `RangeError` 同时包含单引号和双引号
79
- */
80
- setValue(value: string | boolean): void;
81
- /**
82
- * 修改属性名
83
- * @param key 新属性名
84
- * @throws `Error` title和alt属性不能更名
85
- */
86
- rename(key: string): void;
87
- }
88
- export {};