wikiparser-node 1.5.7-b → 1.5.7

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 (163) hide show
  1. package/config/.schema.json +172 -0
  2. package/config/enwiki.json +814 -1
  3. package/config/llwiki.json +35 -1
  4. package/config/moegirl.json +44 -1
  5. package/config/zhwiki.json +466 -1
  6. package/dist/addon/table.d.ts +6 -0
  7. package/dist/addon/table.js +564 -0
  8. package/dist/base.d.ts +72 -0
  9. package/dist/base.js +38 -0
  10. package/dist/index.d.ts +30 -0
  11. package/dist/index.js +214 -0
  12. package/dist/internal.d.ts +44 -0
  13. package/dist/lib/element.d.ts +151 -0
  14. package/dist/lib/element.js +615 -0
  15. package/dist/lib/node.d.ts +146 -0
  16. package/dist/lib/node.js +426 -0
  17. package/dist/lib/range.d.ts +104 -0
  18. package/dist/lib/range.js +385 -0
  19. package/dist/lib/ranges.d.ts +26 -0
  20. package/dist/lib/ranges.js +118 -0
  21. package/dist/lib/text.d.ts +63 -0
  22. package/dist/lib/text.js +354 -0
  23. package/dist/lib/title.d.ts +38 -0
  24. package/dist/lib/title.js +160 -0
  25. package/dist/mixin/attributesParent.d.ts +50 -0
  26. package/dist/mixin/attributesParent.js +78 -0
  27. package/dist/mixin/fixed.d.ts +6 -0
  28. package/dist/mixin/fixed.js +30 -0
  29. package/dist/mixin/flagsParent.d.ts +72 -0
  30. package/dist/mixin/flagsParent.js +59 -0
  31. package/dist/mixin/hidden.d.ts +5 -0
  32. package/dist/mixin/hidden.js +24 -0
  33. package/dist/mixin/magicLinkParent.d.ts +40 -0
  34. package/dist/mixin/magicLinkParent.js +42 -0
  35. package/dist/mixin/singleLine.d.ts +6 -0
  36. package/dist/mixin/singleLine.js +26 -0
  37. package/dist/mixin/sol.d.ts +6 -0
  38. package/dist/mixin/sol.js +43 -0
  39. package/dist/mixin/syntax.d.ts +9 -0
  40. package/dist/mixin/syntax.js +50 -0
  41. package/dist/parser/braces.js +131 -0
  42. package/dist/parser/commentAndExt.js +90 -0
  43. package/dist/parser/converter.js +41 -0
  44. package/dist/parser/externalLinks.js +32 -0
  45. package/dist/parser/hrAndDoubleUnderscore.js +41 -0
  46. package/dist/parser/html.js +39 -0
  47. package/dist/parser/links.js +95 -0
  48. package/dist/parser/list.js +98 -0
  49. package/dist/parser/magicLinks.js +43 -0
  50. package/dist/parser/quotes.js +68 -0
  51. package/dist/parser/selector.js +162 -0
  52. package/dist/parser/table.js +124 -0
  53. package/dist/src/arg.d.ts +58 -0
  54. package/dist/src/arg.js +214 -0
  55. package/dist/src/atom.d.ts +12 -0
  56. package/dist/src/atom.js +27 -0
  57. package/dist/src/attribute.d.ts +71 -0
  58. package/dist/src/attribute.js +502 -0
  59. package/dist/src/attributes.d.ts +109 -0
  60. package/dist/src/attributes.js +356 -0
  61. package/dist/src/converter.d.ts +33 -0
  62. package/dist/src/converter.js +134 -0
  63. package/dist/src/converterFlags.d.ts +87 -0
  64. package/dist/src/converterFlags.js +242 -0
  65. package/dist/src/converterRule.d.ts +77 -0
  66. package/dist/src/converterRule.js +209 -0
  67. package/dist/src/extLink.d.ts +43 -0
  68. package/dist/src/extLink.js +188 -0
  69. package/dist/src/gallery.d.ts +54 -0
  70. package/dist/src/gallery.js +139 -0
  71. package/dist/src/heading.d.ts +47 -0
  72. package/dist/src/heading.js +190 -0
  73. package/dist/src/hidden.d.ts +7 -0
  74. package/dist/src/hidden.js +23 -0
  75. package/dist/src/html.d.ts +65 -0
  76. package/dist/src/html.js +358 -0
  77. package/dist/src/imageParameter.d.ts +65 -0
  78. package/dist/src/imageParameter.js +257 -0
  79. package/dist/src/imagemap.d.ts +54 -0
  80. package/dist/src/imagemap.js +144 -0
  81. package/dist/src/imagemapLink.d.ts +31 -0
  82. package/dist/src/imagemapLink.js +93 -0
  83. package/dist/src/index.d.ts +143 -0
  84. package/dist/src/index.js +813 -0
  85. package/dist/src/link/base.d.ts +52 -0
  86. package/dist/src/link/base.js +229 -0
  87. package/dist/src/link/category.d.ts +13 -0
  88. package/dist/src/link/category.js +28 -0
  89. package/dist/src/link/file.d.ts +98 -0
  90. package/dist/src/link/file.js +272 -0
  91. package/dist/src/link/galleryImage.d.ts +32 -0
  92. package/dist/src/link/galleryImage.js +157 -0
  93. package/dist/src/link/index.d.ts +56 -0
  94. package/dist/src/link/index.js +133 -0
  95. package/dist/src/magicLink.d.ts +59 -0
  96. package/dist/src/magicLink.js +223 -0
  97. package/dist/src/nested.d.ts +43 -0
  98. package/dist/src/nested.js +105 -0
  99. package/dist/src/nowiki/base.d.ts +31 -0
  100. package/dist/src/nowiki/base.js +93 -0
  101. package/dist/src/nowiki/comment.d.ts +25 -0
  102. package/dist/src/nowiki/comment.js +76 -0
  103. package/dist/src/nowiki/dd.d.ts +8 -0
  104. package/dist/src/nowiki/dd.js +24 -0
  105. package/dist/src/nowiki/doubleUnderscore.d.ts +18 -0
  106. package/dist/src/nowiki/doubleUnderscore.js +101 -0
  107. package/dist/src/nowiki/hr.d.ts +5 -0
  108. package/dist/src/nowiki/hr.js +63 -0
  109. package/dist/src/nowiki/index.d.ts +16 -0
  110. package/dist/src/nowiki/index.js +27 -0
  111. package/dist/src/nowiki/list.d.ts +16 -0
  112. package/dist/src/nowiki/list.js +109 -0
  113. package/dist/src/nowiki/listBase.d.ts +5 -0
  114. package/dist/src/nowiki/listBase.js +61 -0
  115. package/dist/src/nowiki/noinclude.d.ts +10 -0
  116. package/dist/src/nowiki/noinclude.js +23 -0
  117. package/dist/src/nowiki/quote.d.ts +14 -0
  118. package/dist/src/nowiki/quote.js +131 -0
  119. package/dist/src/onlyinclude.d.ts +16 -0
  120. package/dist/src/onlyinclude.js +57 -0
  121. package/dist/src/paramTag/index.d.ts +37 -0
  122. package/dist/src/paramTag/index.js +77 -0
  123. package/dist/src/paramTag/inputbox.d.ts +8 -0
  124. package/dist/src/paramTag/inputbox.js +22 -0
  125. package/dist/src/parameter.d.ts +70 -0
  126. package/dist/src/parameter.js +264 -0
  127. package/dist/src/pre.d.ts +31 -0
  128. package/dist/src/pre.js +59 -0
  129. package/dist/src/syntax.d.ts +20 -0
  130. package/dist/src/syntax.js +86 -0
  131. package/dist/src/table/base.d.ts +30 -0
  132. package/dist/src/table/base.js +132 -0
  133. package/dist/src/table/index.d.ts +233 -0
  134. package/dist/src/table/index.js +411 -0
  135. package/dist/src/table/td.d.ts +86 -0
  136. package/dist/src/table/td.js +353 -0
  137. package/dist/src/table/tr.d.ts +32 -0
  138. package/dist/src/table/tr.js +58 -0
  139. package/dist/src/table/trBase.d.ts +53 -0
  140. package/dist/src/table/trBase.js +152 -0
  141. package/dist/src/tagPair/ext.d.ts +32 -0
  142. package/dist/src/tagPair/ext.js +203 -0
  143. package/dist/src/tagPair/include.d.ts +35 -0
  144. package/dist/src/tagPair/include.js +74 -0
  145. package/dist/src/tagPair/index.d.ts +27 -0
  146. package/dist/src/tagPair/index.js +128 -0
  147. package/dist/src/transclude.d.ts +167 -0
  148. package/dist/src/transclude.js +717 -0
  149. package/dist/util/constants.js +28 -0
  150. package/dist/util/debug.js +88 -0
  151. package/dist/util/diff.js +83 -0
  152. package/dist/util/lint.js +31 -0
  153. package/dist/util/string.js +54 -0
  154. package/errors/README +1 -0
  155. package/package.json +17 -28
  156. package/printed/README +1 -0
  157. package/bundle/bundle.min.js +0 -38
  158. package/extensions/dist/base.js +0 -64
  159. package/extensions/dist/editor.js +0 -159
  160. package/extensions/dist/highlight.js +0 -59
  161. package/extensions/dist/lint.js +0 -60
  162. package/extensions/editor.css +0 -63
  163. package/extensions/ui.css +0 -141
@@ -0,0 +1,124 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parseTable = void 0;
4
+ const constants_1 = require("../util/constants");
5
+ const index_1 = require("../index");
6
+ const index_2 = require("../src/index");
7
+ const index_3 = require("../src/table/index");
8
+ const tr_1 = require("../src/table/tr");
9
+ const td_1 = require("../src/table/td");
10
+ const dd_1 = require("../src/nowiki/dd");
11
+ /**
12
+ * 判断是否为表格行或表格
13
+ * @param token 表格节点
14
+ */
15
+ const isTr = (token) => token.lastChild.constructor !== index_2.Token;
16
+ /**
17
+ * 解析表格,注意`tr`和`td`包含开头的换行
18
+ * @param {Token & {firstChild: AstText}} root 根节点
19
+ * @param config
20
+ * @param accum
21
+ */
22
+ const parseTable = ({ firstChild: { data }, type, name }, config = index_1.default.getConfig(), accum = []) => {
23
+ const stack = [], lines = data.split('\n');
24
+ let out = type === 'root' || type === 'parameter-value' || type === 'ext-inner' && name === 'poem'
25
+ ? ''
26
+ : `\n${lines.shift()}`, top;
27
+ /**
28
+ * 向表格中插入纯文本
29
+ * @param str 待插入的文本
30
+ * @param topToken 当前解析的表格或表格行
31
+ */
32
+ const push = (str, topToken) => {
33
+ if (!topToken) {
34
+ out += str;
35
+ return;
36
+ }
37
+ const { lastChild } = topToken;
38
+ if (isTr(topToken)) {
39
+ const token = new index_2.Token(str, config, accum);
40
+ token.type = 'table-inter';
41
+ token.setAttribute('stage', 3);
42
+ topToken.insertAt(token);
43
+ }
44
+ else {
45
+ lastChild.setText(String(lastChild) + str);
46
+ }
47
+ },
48
+ /** 取出最近的表格行 */
49
+ pop = () => top.type === 'td' ? stack.pop() : top;
50
+ for (const outLine of lines) {
51
+ top = stack.pop();
52
+ const [spaces] = /^(?:\s|\0\d+c\x7F)*/u.exec(outLine), line = outLine.slice(spaces.length), matchesStart = /^(:*)((?:\s|\0\d+c\x7F)*)(\{\||\{(?:\0\d+c\x7F)*\0\d+!\x7F|\0\d+\{\x7F)(.*)$/u
53
+ .exec(line);
54
+ if (matchesStart) {
55
+ while (top && top.type !== 'td') {
56
+ top = stack.pop();
57
+ }
58
+ const [, indent, moreSpaces, tableSyntax, attr] = matchesStart;
59
+ if (indent) {
60
+ // @ts-expect-error abstract class
61
+ new dd_1.DdToken(indent, config, accum);
62
+ }
63
+ push(`\n${spaces}${indent && `\0${accum.length - 1}d\x7F`}${moreSpaces}\0${accum.length}b\x7F`, top);
64
+ // @ts-expect-error abstract class
65
+ stack.push(...top ? [top] : [], new index_3.TableToken(tableSyntax, attr, config, accum));
66
+ continue;
67
+ }
68
+ else if (!top) {
69
+ out += `\n${outLine}`;
70
+ continue;
71
+ }
72
+ // eslint-disable-next-line @stylistic/operator-linebreak
73
+ const matches = /^(?:(\|\}|\0\d+!\x7F\}|\0\d+\}\x7F)|(\|-+|\0\d+!\x7F-+|\0\d+-\x7F-*)(?!-)|(!|(?:\||\0\d+!\x7F)\+?))(.*)$/u
74
+ .exec(line);
75
+ if (!matches) {
76
+ push(`\n${outLine}`, top);
77
+ stack.push(top);
78
+ continue;
79
+ }
80
+ const [, closing, row, cell, attr] = matches;
81
+ if (closing) {
82
+ while (top.type !== 'table') {
83
+ top = stack.pop();
84
+ }
85
+ top.close(`\n${spaces}${closing}`, true);
86
+ push(attr, stack[stack.length - 1]);
87
+ }
88
+ else if (row) {
89
+ top = pop();
90
+ if (top.type === 'tr') {
91
+ top = stack.pop();
92
+ }
93
+ // @ts-expect-error abstract class
94
+ const tr = new tr_1.TrToken(`\n${spaces}${row}`, attr, config, accum);
95
+ stack.push(top, tr);
96
+ top.insertAt(tr);
97
+ }
98
+ else {
99
+ top = pop();
100
+ const regex = cell === '!' ? /!!|(?:\||\0\d+!\x7F){2}|\0\d+\+\x7F/gu : /(?:\||\0\d+!\x7F){2}|\0\d+\+\x7F/gu;
101
+ let mt = regex.exec(attr), lastIndex = 0, lastSyntax = `\n${spaces}${cell}`;
102
+ /**
103
+ * 创建表格单元格
104
+ * @param tr 当前表格行
105
+ */
106
+ const createTd = (tr) => {
107
+ // @ts-expect-error abstract class
108
+ const td = new td_1.TdToken(lastSyntax, attr.slice(lastIndex, mt?.index), config, accum);
109
+ tr.insertAt(td);
110
+ return td;
111
+ };
112
+ while (mt) {
113
+ createTd(top);
114
+ ({ lastIndex } = regex);
115
+ [lastSyntax] = mt;
116
+ mt = regex.exec(attr);
117
+ }
118
+ stack.push(top, createTd(top));
119
+ }
120
+ }
121
+ return out.slice(1);
122
+ };
123
+ exports.parseTable = parseTable;
124
+ constants_1.parsers['parseTable'] = __filename;
@@ -0,0 +1,58 @@
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, re?: RegExp): 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
+ }
@@ -0,0 +1,214 @@
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(), re) {
74
+ const { childNodes: [argName, argDefault, ...rest] } = this;
75
+ if (!this.getAttribute('include')) {
76
+ const e = (0, lint_1.generateForSelf)(this, { start }, 'no-arg', 'unexpected template argument');
77
+ if (argDefault) {
78
+ e.fix = {
79
+ range: [start, e.endIndex],
80
+ text: argDefault.text(),
81
+ };
82
+ }
83
+ return [e];
84
+ }
85
+ const errors = argName.lint(start + 3, re);
86
+ if (argDefault) {
87
+ errors.push(...argDefault.lint(start + 4 + String(argName).length, re));
88
+ }
89
+ if (rest.length > 0) {
90
+ const rect = { start, ...this.getRootNode().posFromIndex(start) };
91
+ errors.push(...rest.map(child => {
92
+ const e = (0, lint_1.generateForChild)(child, rect, 'no-ignored', 'invisible content inside triple braces');
93
+ e.startIndex--;
94
+ e.startCol--;
95
+ e.suggestions = [
96
+ {
97
+ desc: 'remove',
98
+ range: [e.startIndex, e.endIndex],
99
+ text: '',
100
+ },
101
+ {
102
+ desc: 'escape',
103
+ range: [e.startIndex, e.startIndex + 1],
104
+ text: '{{!}}',
105
+ },
106
+ ];
107
+ return e;
108
+ }));
109
+ }
110
+ return errors;
111
+ }
112
+ /** @override */
113
+ print() {
114
+ return super.print({ pre: '{{{', post: '}}}', sep: '|' });
115
+ }
116
+ /** @override */
117
+ json() {
118
+ const json = super.json();
119
+ json['default'] = this.default;
120
+ return json;
121
+ }
122
+ /* NOT FOR BROWSER */
123
+ /** @override */
124
+ cloneNode() {
125
+ const [name, ...cloned] = this.cloneChildNodes();
126
+ return debug_1.Shadow.run(() => {
127
+ // @ts-expect-error abstract class
128
+ const token = new ArgToken([''], this.getAttribute('config'));
129
+ token.firstChild.safeReplaceWith(name);
130
+ token.append(...cloned);
131
+ token.afterBuild();
132
+ return token;
133
+ });
134
+ }
135
+ /** 设置name */
136
+ #setName() {
137
+ this.setAttribute('name', this.firstChild.text().trim());
138
+ }
139
+ /** @private */
140
+ afterBuild() {
141
+ this.#setName();
142
+ const /** @implements */ argListener = ({ prevTarget }) => {
143
+ if (prevTarget === this.firstChild) {
144
+ this.#setName();
145
+ }
146
+ };
147
+ this.addEventListener(['remove', 'insert', 'replace', 'text'], argListener);
148
+ }
149
+ /** 移除无效部分 */
150
+ removeRedundant() {
151
+ debug_1.Shadow.run(() => {
152
+ for (let i = this.length - 1; i > 1; i--) {
153
+ super.removeAt(i);
154
+ }
155
+ });
156
+ }
157
+ /**
158
+ * @override
159
+ * @param i 移除位置
160
+ */
161
+ removeAt(i) {
162
+ if (i === 1) {
163
+ this.removeRedundant();
164
+ }
165
+ return super.removeAt(i);
166
+ }
167
+ /**
168
+ * @override
169
+ * @param token 待插入的子节点
170
+ * @param i 插入位置
171
+ */
172
+ insertAt(token, i = this.length) {
173
+ i += i < 0 ? this.length : 0;
174
+ if (i > 1) {
175
+ this.constructorError('不可插入多余的子节点');
176
+ }
177
+ else if (typeof token === 'string') {
178
+ this.constructorError('不可插入文本节点');
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;
@@ -0,0 +1,12 @@
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 {};
@@ -0,0 +1,27 @@
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;
@@ -0,0 +1,71 @@
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 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
+ /** @override */
45
+ text(): string;
46
+ /** @override */
47
+ lint(start?: number, re?: RegExp): LintError[];
48
+ /** 获取属性值 */
49
+ getValue(): string | true;
50
+ /** @override */
51
+ print(): string;
52
+ /** @override */
53
+ cloneNode(): this;
54
+ /** 转义等号 */
55
+ escape(): void;
56
+ /** 闭合引号 */
57
+ close(): void;
58
+ /**
59
+ * 设置属性值
60
+ * @param value 参数值
61
+ * @throws `RangeError` 扩展标签属性不能包含 ">"
62
+ * @throws `RangeError` 同时包含单引号和双引号
63
+ */
64
+ setValue(value: string | boolean): void;
65
+ /**
66
+ * 修改属性名
67
+ * @param key 新属性名
68
+ * @throws `Error` title和alt属性不能更名
69
+ */
70
+ rename(key: string): void;
71
+ }