wikiparser-node 1.12.6 → 1.12.7-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.
- package/bundle/bundle.min.js +37 -0
- package/config/default.json +29 -30
- package/config/enwiki.json +15 -829
- package/config/llwiki.json +21 -56
- package/config/moegirl.json +21 -65
- package/config/zhwiki.json +28 -494
- package/extensions/dist/base.js +163 -0
- package/extensions/dist/codejar.js +53 -0
- package/extensions/dist/editor.js +159 -0
- package/extensions/dist/highlight.js +30 -0
- package/extensions/dist/lint.js +72 -0
- package/extensions/editor.css +59 -0
- package/extensions/ui.css +162 -0
- package/package.json +28 -21
- package/config/.schema.json +0 -203
- package/dist/addon/table.js +0 -494
- package/dist/addon/token.js +0 -392
- package/dist/addon/transclude.js +0 -184
- package/dist/base.d.ts +0 -82
- package/dist/base.js +0 -40
- package/dist/index.d.ts +0 -33
- package/dist/index.js +0 -275
- package/dist/internal.d.ts +0 -47
- package/dist/lib/element.d.ts +0 -125
- package/dist/lib/element.js +0 -377
- package/dist/lib/node.d.ts +0 -173
- package/dist/lib/node.js +0 -478
- package/dist/lib/range.d.ts +0 -105
- package/dist/lib/range.js +0 -406
- package/dist/lib/ranges.d.ts +0 -28
- package/dist/lib/ranges.js +0 -126
- package/dist/lib/rect.d.ts +0 -18
- package/dist/lib/rect.js +0 -36
- package/dist/lib/text.d.ts +0 -58
- package/dist/lib/text.js +0 -414
- package/dist/lib/title.d.ts +0 -49
- package/dist/lib/title.js +0 -253
- package/dist/mixin/attributesParent.d.ts +0 -49
- package/dist/mixin/attributesParent.js +0 -80
- package/dist/mixin/fixed.d.ts +0 -5
- package/dist/mixin/fixed.js +0 -32
- package/dist/mixin/flagsParent.d.ts +0 -43
- package/dist/mixin/flagsParent.js +0 -64
- package/dist/mixin/hidden.d.ts +0 -7
- package/dist/mixin/hidden.js +0 -39
- package/dist/mixin/magicLinkParent.d.ts +0 -19
- package/dist/mixin/magicLinkParent.js +0 -43
- package/dist/mixin/singleLine.d.ts +0 -5
- package/dist/mixin/singleLine.js +0 -25
- package/dist/mixin/sol.d.ts +0 -6
- package/dist/mixin/sol.js +0 -45
- package/dist/mixin/syntax.d.ts +0 -8
- package/dist/mixin/syntax.js +0 -46
- package/dist/parser/braces.js +0 -152
- package/dist/parser/commentAndExt.js +0 -84
- package/dist/parser/converter.js +0 -41
- package/dist/parser/externalLinks.js +0 -39
- package/dist/parser/hrAndDoubleUnderscore.js +0 -44
- package/dist/parser/html.js +0 -40
- package/dist/parser/links.js +0 -103
- package/dist/parser/list.js +0 -116
- package/dist/parser/magicLinks.js +0 -55
- package/dist/parser/quotes.js +0 -69
- package/dist/parser/redirect.js +0 -28
- package/dist/parser/selector.js +0 -393
- package/dist/parser/table.js +0 -125
- package/dist/src/arg.d.ts +0 -49
- package/dist/src/arg.js +0 -220
- package/dist/src/atom.d.ts +0 -14
- package/dist/src/atom.js +0 -54
- package/dist/src/attribute.d.ts +0 -64
- package/dist/src/attribute.js +0 -482
- package/dist/src/attributes.d.ts +0 -103
- package/dist/src/attributes.js +0 -380
- package/dist/src/converter.d.ts +0 -28
- package/dist/src/converter.js +0 -153
- package/dist/src/converterFlags.d.ts +0 -80
- package/dist/src/converterFlags.js +0 -241
- package/dist/src/converterRule.d.ts +0 -71
- package/dist/src/converterRule.js +0 -218
- package/dist/src/extLink.d.ts +0 -36
- package/dist/src/extLink.js +0 -223
- package/dist/src/gallery.d.ts +0 -51
- package/dist/src/gallery.js +0 -166
- package/dist/src/heading.d.ts +0 -44
- package/dist/src/heading.js +0 -222
- package/dist/src/hidden.d.ts +0 -9
- package/dist/src/hidden.js +0 -82
- package/dist/src/html.d.ts +0 -61
- package/dist/src/html.js +0 -344
- package/dist/src/imageParameter.d.ts +0 -60
- package/dist/src/imageParameter.js +0 -262
- package/dist/src/imagemap.d.ts +0 -47
- package/dist/src/imagemap.js +0 -148
- package/dist/src/imagemapLink.d.ts +0 -35
- package/dist/src/imagemapLink.js +0 -99
- package/dist/src/index.d.ts +0 -136
- package/dist/src/index.js +0 -790
- package/dist/src/link/base.d.ts +0 -52
- package/dist/src/link/base.js +0 -258
- package/dist/src/link/category.d.ts +0 -22
- package/dist/src/link/category.js +0 -36
- package/dist/src/link/file.d.ts +0 -102
- package/dist/src/link/file.js +0 -345
- package/dist/src/link/galleryImage.d.ts +0 -29
- package/dist/src/link/galleryImage.js +0 -133
- package/dist/src/link/index.d.ts +0 -39
- package/dist/src/link/index.js +0 -100
- package/dist/src/link/redirectTarget.d.ts +0 -27
- package/dist/src/link/redirectTarget.js +0 -71
- package/dist/src/magicLink.d.ts +0 -57
- package/dist/src/magicLink.js +0 -261
- package/dist/src/nested.d.ts +0 -40
- package/dist/src/nested.js +0 -108
- package/dist/src/nowiki/base.d.ts +0 -28
- package/dist/src/nowiki/base.js +0 -90
- package/dist/src/nowiki/comment.d.ts +0 -14
- package/dist/src/nowiki/comment.js +0 -123
- package/dist/src/nowiki/dd.d.ts +0 -8
- package/dist/src/nowiki/dd.js +0 -74
- package/dist/src/nowiki/doubleUnderscore.d.ts +0 -15
- package/dist/src/nowiki/doubleUnderscore.js +0 -101
- package/dist/src/nowiki/hr.d.ts +0 -5
- package/dist/src/nowiki/hr.js +0 -72
- package/dist/src/nowiki/index.d.ts +0 -14
- package/dist/src/nowiki/index.js +0 -30
- package/dist/src/nowiki/list.d.ts +0 -5
- package/dist/src/nowiki/list.js +0 -67
- package/dist/src/nowiki/listBase.d.ts +0 -23
- package/dist/src/nowiki/listBase.js +0 -100
- package/dist/src/nowiki/noinclude.d.ts +0 -6
- package/dist/src/nowiki/noinclude.js +0 -77
- package/dist/src/nowiki/quote.d.ts +0 -14
- package/dist/src/nowiki/quote.js +0 -149
- package/dist/src/onlyinclude.d.ts +0 -13
- package/dist/src/onlyinclude.js +0 -60
- package/dist/src/paramTag/index.d.ts +0 -28
- package/dist/src/paramTag/index.js +0 -80
- package/dist/src/paramTag/inputbox.d.ts +0 -8
- package/dist/src/paramTag/inputbox.js +0 -24
- package/dist/src/parameter.d.ts +0 -60
- package/dist/src/parameter.js +0 -267
- package/dist/src/pre.d.ts +0 -28
- package/dist/src/pre.js +0 -62
- package/dist/src/redirect.d.ts +0 -30
- package/dist/src/redirect.js +0 -128
- package/dist/src/syntax.d.ts +0 -15
- package/dist/src/syntax.js +0 -87
- package/dist/src/table/base.d.ts +0 -28
- package/dist/src/table/base.js +0 -81
- package/dist/src/table/index.d.ts +0 -230
- package/dist/src/table/index.js +0 -506
- package/dist/src/table/td.d.ts +0 -72
- package/dist/src/table/td.js +0 -375
- package/dist/src/table/tr.d.ts +0 -30
- package/dist/src/table/tr.js +0 -61
- package/dist/src/table/trBase.d.ts +0 -49
- package/dist/src/table/trBase.js +0 -165
- package/dist/src/tagPair/ext.d.ts +0 -29
- package/dist/src/tagPair/ext.js +0 -229
- package/dist/src/tagPair/include.d.ts +0 -33
- package/dist/src/tagPair/include.js +0 -132
- package/dist/src/tagPair/index.d.ts +0 -23
- package/dist/src/tagPair/index.js +0 -130
- package/dist/src/transclude.d.ts +0 -159
- package/dist/src/transclude.js +0 -598
- package/dist/util/constants.js +0 -26
- package/dist/util/debug.js +0 -95
- package/dist/util/diff.js +0 -83
- package/dist/util/html.js +0 -146
- package/dist/util/lint.js +0 -32
- package/dist/util/string.js +0 -107
- package/errors/README +0 -3
- package/printed/README +0 -3
package/dist/parser/table.js
DELETED
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.parseTable = void 0;
|
|
4
|
-
const index_1 = require("../src/index");
|
|
5
|
-
const index_2 = require("../src/table/index");
|
|
6
|
-
const tr_1 = require("../src/table/tr");
|
|
7
|
-
const td_1 = require("../src/table/td");
|
|
8
|
-
const dd_1 = require("../src/nowiki/dd");
|
|
9
|
-
/* NOT FOR BROWSER */
|
|
10
|
-
const constants_1 = require("../util/constants");
|
|
11
|
-
/* NOT FOR BROWSER END */
|
|
12
|
-
/**
|
|
13
|
-
* 判断是否为表格行或表格
|
|
14
|
-
* @param token 表格节点
|
|
15
|
-
*/
|
|
16
|
-
const isTr = (token) => token.lastChild.constructor !== index_1.Token;
|
|
17
|
-
/**
|
|
18
|
-
* 解析表格,注意`tr`和`td`包含开头的换行
|
|
19
|
-
* @param {Token & {firstChild: AstText}} root 根节点
|
|
20
|
-
* @param config
|
|
21
|
-
* @param accum
|
|
22
|
-
*/
|
|
23
|
-
const parseTable = ({ firstChild: { data }, type, name }, config, accum) => {
|
|
24
|
-
const stack = [], lines = data.split('\n');
|
|
25
|
-
let out = type === 'root' || type === 'parameter-value' || type === 'ext-inner' && name === 'poem'
|
|
26
|
-
? ''
|
|
27
|
-
: `\n${lines.shift()}`, top;
|
|
28
|
-
/**
|
|
29
|
-
* 向表格中插入纯文本
|
|
30
|
-
* @param str 待插入的文本
|
|
31
|
-
* @param topToken 当前解析的表格或表格行
|
|
32
|
-
*/
|
|
33
|
-
const push = (str, topToken) => {
|
|
34
|
-
if (!topToken) {
|
|
35
|
-
out += str;
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
38
|
-
const { lastChild } = topToken;
|
|
39
|
-
if (isTr(topToken)) {
|
|
40
|
-
const token = new index_1.Token(str, config, accum);
|
|
41
|
-
token.type = 'table-inter';
|
|
42
|
-
token.setAttribute('stage', 3);
|
|
43
|
-
topToken.insertAt(token);
|
|
44
|
-
}
|
|
45
|
-
else {
|
|
46
|
-
lastChild.setText(lastChild.toString() + str);
|
|
47
|
-
}
|
|
48
|
-
},
|
|
49
|
-
/** 取出最近的表格行 */
|
|
50
|
-
pop = () => top.type === 'td' ? stack.pop() : top;
|
|
51
|
-
for (const outLine of lines) {
|
|
52
|
-
top = stack.pop();
|
|
53
|
-
const [spaces] = /^(?:\s|\0\d+[cno]\x7F)*/u.exec(outLine), line = outLine.slice(spaces.length), matchesStart = /^(:*)((?:\s|\0\d+[cn]\x7F)*)(\{\||\{(?:\0\d+[cn]\x7F)*\0\d+!\x7F|\0\d+\{\x7F)(.*)$/u
|
|
54
|
-
.exec(line);
|
|
55
|
-
if (matchesStart) {
|
|
56
|
-
while (top && top.type !== 'td') {
|
|
57
|
-
top = stack.pop();
|
|
58
|
-
}
|
|
59
|
-
const [, indent, moreSpaces, tableSyntax, attr] = matchesStart;
|
|
60
|
-
if (indent) {
|
|
61
|
-
// @ts-expect-error abstract class
|
|
62
|
-
new dd_1.DdToken(indent, config, accum);
|
|
63
|
-
}
|
|
64
|
-
push(`\n${spaces}${indent && `\0${accum.length - 1}d\x7F`}${moreSpaces}\0${accum.length}b\x7F`, top);
|
|
65
|
-
// @ts-expect-error abstract class
|
|
66
|
-
stack.push(...top ? [top] : [], new index_2.TableToken(tableSyntax, attr, config, accum));
|
|
67
|
-
continue;
|
|
68
|
-
}
|
|
69
|
-
else if (!top) {
|
|
70
|
-
out += `\n${outLine}`;
|
|
71
|
-
continue;
|
|
72
|
-
}
|
|
73
|
-
const matches = // eslint-disable-line @stylistic/operator-linebreak
|
|
74
|
-
/^(?:(\|\}|\0\d+!\x7F\}|\0\d+\}\x7F)|(\|-+|\0\d+!\x7F-+|\0\d+-\x7F-*)(?!-)|(!|(?:\||\0\d+!\x7F)\+?))(.*)$/u
|
|
75
|
-
.exec(line);
|
|
76
|
-
if (!matches) {
|
|
77
|
-
push(`\n${outLine}`, top);
|
|
78
|
-
stack.push(top);
|
|
79
|
-
continue;
|
|
80
|
-
}
|
|
81
|
-
const [, closing, row, cell, attr] = matches;
|
|
82
|
-
if (closing) {
|
|
83
|
-
while (top.type !== 'table') {
|
|
84
|
-
top = stack.pop();
|
|
85
|
-
}
|
|
86
|
-
top.close(`\n${spaces}${closing}`, true);
|
|
87
|
-
push(attr, stack[stack.length - 1]);
|
|
88
|
-
}
|
|
89
|
-
else if (row) {
|
|
90
|
-
top = pop();
|
|
91
|
-
if (top.type === 'tr') {
|
|
92
|
-
top = stack.pop();
|
|
93
|
-
}
|
|
94
|
-
// @ts-expect-error abstract class
|
|
95
|
-
const tr = new tr_1.TrToken(`\n${spaces}${row}`, attr, config, accum);
|
|
96
|
-
stack.push(top, tr);
|
|
97
|
-
top.insertAt(tr);
|
|
98
|
-
}
|
|
99
|
-
else {
|
|
100
|
-
top = pop();
|
|
101
|
-
const regex = cell === '!' ? /!!|(?:\||\0\d+!\x7F){2}|\0\d+\+\x7F/gu : /(?:\||\0\d+!\x7F){2}|\0\d+\+\x7F/gu;
|
|
102
|
-
let mt = regex.exec(attr), lastIndex = 0, lastSyntax = `\n${spaces}${cell}`;
|
|
103
|
-
/**
|
|
104
|
-
* 创建表格单元格
|
|
105
|
-
* @param tr 当前表格行
|
|
106
|
-
*/
|
|
107
|
-
const newTd = (tr) => {
|
|
108
|
-
// @ts-expect-error abstract class
|
|
109
|
-
const td = new td_1.TdToken(lastSyntax, attr.slice(lastIndex, mt?.index), config, accum);
|
|
110
|
-
tr.insertAt(td);
|
|
111
|
-
return td;
|
|
112
|
-
};
|
|
113
|
-
while (mt) {
|
|
114
|
-
newTd(top);
|
|
115
|
-
({ lastIndex } = regex);
|
|
116
|
-
[lastSyntax] = mt;
|
|
117
|
-
mt = regex.exec(attr);
|
|
118
|
-
}
|
|
119
|
-
stack.push(top, newTd(top));
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
return out.slice(1);
|
|
123
|
-
};
|
|
124
|
-
exports.parseTable = parseTable;
|
|
125
|
-
constants_1.parsers['parseTable'] = __filename;
|
package/dist/src/arg.d.ts
DELETED
|
@@ -1,49 +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 } from '../base';
|
|
6
|
-
/**
|
|
7
|
-
* `{{{}}}`包裹的参数
|
|
8
|
-
* @classdesc `{childNodes: [AtomToken, ?Token, ...HiddenToken]}`
|
|
9
|
-
*/
|
|
10
|
-
export declare abstract class ArgToken extends Token {
|
|
11
|
-
#private;
|
|
12
|
-
readonly name: string;
|
|
13
|
-
readonly childNodes: readonly [AtomToken] | readonly [AtomToken, Token, ...HiddenToken[]];
|
|
14
|
-
abstract get firstChild(): AtomToken;
|
|
15
|
-
abstract get lastChild(): Token;
|
|
16
|
-
abstract get children(): [AtomToken] | [AtomToken, Token, ...HiddenToken[]];
|
|
17
|
-
abstract get firstElementChild(): AtomToken;
|
|
18
|
-
abstract get lastElementChild(): Token;
|
|
19
|
-
get type(): 'arg';
|
|
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
|
-
cloneNode(): this;
|
|
26
|
-
/** 移除无效部分 */
|
|
27
|
-
removeRedundant(): void;
|
|
28
|
-
/**
|
|
29
|
-
* @override
|
|
30
|
-
* @param i 移除位置
|
|
31
|
-
*/
|
|
32
|
-
removeAt(i: number): Token;
|
|
33
|
-
/**
|
|
34
|
-
* @override
|
|
35
|
-
* @param token 待插入的子节点
|
|
36
|
-
* @param i 插入位置
|
|
37
|
-
*/
|
|
38
|
-
insertAt<T extends Token>(token: T, i?: number): T;
|
|
39
|
-
/**
|
|
40
|
-
* 设置参数名
|
|
41
|
-
* @param name 新参数名
|
|
42
|
-
*/
|
|
43
|
-
setName(name: string): void;
|
|
44
|
-
/**
|
|
45
|
-
* 设置预设值
|
|
46
|
-
* @param value 预设值
|
|
47
|
-
*/
|
|
48
|
-
setDefault(value: string | false): void;
|
|
49
|
-
}
|
package/dist/src/arg.js
DELETED
|
@@ -1,220 +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 index_1 = require("../index");
|
|
8
|
-
const index_2 = require("./index");
|
|
9
|
-
const atom_1 = require("./atom");
|
|
10
|
-
const hidden_1 = require("./hidden");
|
|
11
|
-
/* NOT FOR BROWSER */
|
|
12
|
-
const constants_1 = require("../util/constants");
|
|
13
|
-
const debug_1 = require("../util/debug");
|
|
14
|
-
const html_1 = require("../util/html");
|
|
15
|
-
/* NOT FOR BROWSER END */
|
|
16
|
-
/**
|
|
17
|
-
* `{{{}}}`包裹的参数
|
|
18
|
-
* @classdesc `{childNodes: [AtomToken, ?Token, ...HiddenToken]}`
|
|
19
|
-
*/
|
|
20
|
-
class ArgToken extends index_2.Token {
|
|
21
|
-
/* NOT FOR BROWSER END */
|
|
22
|
-
get type() {
|
|
23
|
-
return 'arg';
|
|
24
|
-
}
|
|
25
|
-
/** 预设值 */
|
|
26
|
-
get default() {
|
|
27
|
-
return this.childNodes[1]?.text() ?? false;
|
|
28
|
-
}
|
|
29
|
-
/* NOT FOR BROWSER */
|
|
30
|
-
set default(value) {
|
|
31
|
-
this.setDefault(value);
|
|
32
|
-
}
|
|
33
|
-
/* NOT FOR BROWSER END */
|
|
34
|
-
/** @param parts 以'|'分隔的各部分 */
|
|
35
|
-
constructor(parts, config = index_1.default.getConfig(), accum = []) {
|
|
36
|
-
super(undefined, config, accum, {
|
|
37
|
-
AtomToken: 0, Token: 1, HiddenToken: '2:',
|
|
38
|
-
});
|
|
39
|
-
for (const [i, part] of parts.entries()) {
|
|
40
|
-
if (i === 0) {
|
|
41
|
-
const token = new atom_1.AtomToken(part, 'arg-name', config, accum, {
|
|
42
|
-
'Stage-2': ':', '!HeadingToken': '',
|
|
43
|
-
});
|
|
44
|
-
super.insertAt(token);
|
|
45
|
-
}
|
|
46
|
-
else if (i > 1) {
|
|
47
|
-
const token = new hidden_1.HiddenToken(part, config, accum);
|
|
48
|
-
super.insertAt(token);
|
|
49
|
-
}
|
|
50
|
-
else {
|
|
51
|
-
const token = new index_2.Token(part, config, accum);
|
|
52
|
-
token.type = 'arg-default';
|
|
53
|
-
token.setAttribute('stage', 2);
|
|
54
|
-
super.insertAt(token);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
/* NOT FOR BROWSER */
|
|
58
|
-
this.protectChildren(0);
|
|
59
|
-
}
|
|
60
|
-
/** @private */
|
|
61
|
-
toString(skip) {
|
|
62
|
-
return `{{{${super.toString(skip, '|')}}}}`;
|
|
63
|
-
}
|
|
64
|
-
/** @private */
|
|
65
|
-
text() {
|
|
66
|
-
return `{{{${(0, string_1.text)(this.childNodes.slice(0, 2), '|')}}}}`;
|
|
67
|
-
}
|
|
68
|
-
/** @private */
|
|
69
|
-
getAttribute(key) {
|
|
70
|
-
return key === 'padding' ? 3 : super.getAttribute(key);
|
|
71
|
-
}
|
|
72
|
-
/** @private */
|
|
73
|
-
getGaps() {
|
|
74
|
-
return 1;
|
|
75
|
-
}
|
|
76
|
-
/** 设置name */
|
|
77
|
-
#setName() {
|
|
78
|
-
this.setAttribute('name', this.firstChild.toString(true).trim());
|
|
79
|
-
}
|
|
80
|
-
/** @private */
|
|
81
|
-
afterBuild() {
|
|
82
|
-
this.#setName();
|
|
83
|
-
super.afterBuild();
|
|
84
|
-
/* NOT FOR BROWSER */
|
|
85
|
-
const /** @implements */ argListener = ({ prevTarget }) => {
|
|
86
|
-
if (prevTarget === this.firstChild) {
|
|
87
|
-
this.#setName();
|
|
88
|
-
}
|
|
89
|
-
};
|
|
90
|
-
this.addEventListener(['remove', 'insert', 'replace', 'text'], argListener);
|
|
91
|
-
}
|
|
92
|
-
/** @private */
|
|
93
|
-
lint(start = this.getAbsoluteIndex(), re) {
|
|
94
|
-
const { childNodes: [argName, argDefault, ...rest] } = this;
|
|
95
|
-
if (!this.getAttribute('include')) {
|
|
96
|
-
const e = (0, lint_1.generateForSelf)(this, { start }, 'no-arg', 'unexpected template argument');
|
|
97
|
-
if (argDefault) {
|
|
98
|
-
e.fix = { range: [start, e.endIndex], text: argDefault.text() };
|
|
99
|
-
}
|
|
100
|
-
return [e];
|
|
101
|
-
}
|
|
102
|
-
const errors = argName.lint(start + 3, re);
|
|
103
|
-
if (argDefault) {
|
|
104
|
-
errors.push(...argDefault.lint(start + 4 + argName.toString().length, re));
|
|
105
|
-
}
|
|
106
|
-
if (rest.length > 0) {
|
|
107
|
-
const rect = new rect_1.BoundingRect(this, start);
|
|
108
|
-
errors.push(...rest.map(child => {
|
|
109
|
-
const e = (0, lint_1.generateForChild)(child, rect, 'no-ignored', 'invisible content inside triple braces');
|
|
110
|
-
e.startIndex--;
|
|
111
|
-
e.startCol--;
|
|
112
|
-
e.suggestions = [
|
|
113
|
-
{
|
|
114
|
-
desc: 'remove',
|
|
115
|
-
range: [e.startIndex, e.endIndex],
|
|
116
|
-
text: '',
|
|
117
|
-
},
|
|
118
|
-
{
|
|
119
|
-
desc: 'escape',
|
|
120
|
-
range: [e.startIndex, e.startIndex + 1],
|
|
121
|
-
text: '{{!}}',
|
|
122
|
-
},
|
|
123
|
-
];
|
|
124
|
-
return e;
|
|
125
|
-
}));
|
|
126
|
-
}
|
|
127
|
-
return errors;
|
|
128
|
-
}
|
|
129
|
-
/** @private */
|
|
130
|
-
print() {
|
|
131
|
-
return super.print({ pre: '{{{', post: '}}}', sep: '|' });
|
|
132
|
-
}
|
|
133
|
-
/* NOT FOR BROWSER */
|
|
134
|
-
cloneNode() {
|
|
135
|
-
const [name, ...cloned] = this.cloneChildNodes();
|
|
136
|
-
return debug_1.Shadow.run(() => {
|
|
137
|
-
// @ts-expect-error abstract class
|
|
138
|
-
const token = new ArgToken([''], this.getAttribute('config'));
|
|
139
|
-
token.firstChild.safeReplaceWith(name);
|
|
140
|
-
token.append(...cloned);
|
|
141
|
-
return token;
|
|
142
|
-
});
|
|
143
|
-
}
|
|
144
|
-
/** 移除无效部分 */
|
|
145
|
-
removeRedundant() {
|
|
146
|
-
debug_1.Shadow.run(() => {
|
|
147
|
-
for (let i = this.length - 1; i > 1; i--) {
|
|
148
|
-
super.removeAt(i);
|
|
149
|
-
}
|
|
150
|
-
});
|
|
151
|
-
}
|
|
152
|
-
/**
|
|
153
|
-
* @override
|
|
154
|
-
* @param i 移除位置
|
|
155
|
-
*/
|
|
156
|
-
removeAt(i) {
|
|
157
|
-
if (i === 1) {
|
|
158
|
-
this.removeRedundant();
|
|
159
|
-
}
|
|
160
|
-
return super.removeAt(i);
|
|
161
|
-
}
|
|
162
|
-
/**
|
|
163
|
-
* @override
|
|
164
|
-
* @param token 待插入的子节点
|
|
165
|
-
* @param i 插入位置
|
|
166
|
-
*/
|
|
167
|
-
insertAt(token, i = this.length) {
|
|
168
|
-
i += i < 0 ? this.length : 0;
|
|
169
|
-
if (debug_1.Shadow.running) {
|
|
170
|
-
//
|
|
171
|
-
}
|
|
172
|
-
else if (i > 1) {
|
|
173
|
-
this.constructorError('cannot insert redundant child nodes');
|
|
174
|
-
}
|
|
175
|
-
else if (typeof token === 'string') {
|
|
176
|
-
this.constructorError('cannot insert text nodes');
|
|
177
|
-
}
|
|
178
|
-
super.insertAt(token, i);
|
|
179
|
-
if (i === 1) {
|
|
180
|
-
token.type = 'arg-default';
|
|
181
|
-
}
|
|
182
|
-
return token;
|
|
183
|
-
}
|
|
184
|
-
/**
|
|
185
|
-
* 设置参数名
|
|
186
|
-
* @param name 新参数名
|
|
187
|
-
*/
|
|
188
|
-
setName(name) {
|
|
189
|
-
const { childNodes } = index_1.default.parse(name, this.getAttribute('include'), 2, this.getAttribute('config'));
|
|
190
|
-
this.firstChild.replaceChildren(...childNodes);
|
|
191
|
-
}
|
|
192
|
-
/**
|
|
193
|
-
* 设置预设值
|
|
194
|
-
* @param value 预设值
|
|
195
|
-
*/
|
|
196
|
-
setDefault(value) {
|
|
197
|
-
if (value === false) {
|
|
198
|
-
this.removeAt(1);
|
|
199
|
-
return;
|
|
200
|
-
}
|
|
201
|
-
const root = index_1.default.parse(value, this.getAttribute('include'), undefined, this.getAttribute('config')), { childNodes: [, oldDefault] } = this;
|
|
202
|
-
if (oldDefault) {
|
|
203
|
-
oldDefault.replaceChildren(...root.childNodes);
|
|
204
|
-
}
|
|
205
|
-
else {
|
|
206
|
-
root.type = 'arg-default';
|
|
207
|
-
this.insertAt(root);
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
/** @private */
|
|
211
|
-
toHtmlInternal(nowrap, nocc) {
|
|
212
|
-
if (this.length === 1) {
|
|
213
|
-
const html = (0, html_1.font)(this, this.toString());
|
|
214
|
-
return nowrap ? html.replaceAll('\n', ' ') : html;
|
|
215
|
-
}
|
|
216
|
-
return (0, html_1.font)(this, this.childNodes[1].toHtmlInternal(nowrap, nocc));
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
exports.ArgToken = ArgToken;
|
|
220
|
-
constants_1.classes['ArgToken'] = __filename;
|
package/dist/src/atom.d.ts
DELETED
|
@@ -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,54 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AtomToken = void 0;
|
|
4
|
-
const index_1 = require("./index");
|
|
5
|
-
/* NOT FOR BROWSER */
|
|
6
|
-
const debug_1 = require("../util/debug");
|
|
7
|
-
const constants_1 = require("../util/constants");
|
|
8
|
-
/* NOT FOR BROWSER END */
|
|
9
|
-
const atomTypes = [
|
|
10
|
-
'arg-name',
|
|
11
|
-
'attr-key',
|
|
12
|
-
'attr-value',
|
|
13
|
-
'ext-attr-dirty',
|
|
14
|
-
'html-attr-dirty',
|
|
15
|
-
'table-attr-dirty',
|
|
16
|
-
'converter-flag',
|
|
17
|
-
'converter-rule-variant',
|
|
18
|
-
'converter-rule-to',
|
|
19
|
-
'converter-rule-from',
|
|
20
|
-
'invoke-function',
|
|
21
|
-
'invoke-module',
|
|
22
|
-
'template-name',
|
|
23
|
-
'link-target',
|
|
24
|
-
'param-line',
|
|
25
|
-
];
|
|
26
|
-
/** 不会被继续解析的plain Token */
|
|
27
|
-
class AtomToken extends index_1.Token {
|
|
28
|
-
#type;
|
|
29
|
-
get type() {
|
|
30
|
-
return this.#type;
|
|
31
|
-
}
|
|
32
|
-
set type(value) {
|
|
33
|
-
if (!atomTypes.includes(value)) {
|
|
34
|
-
throw new RangeError(`"${value}" is not a valid type for AtomToken!`);
|
|
35
|
-
}
|
|
36
|
-
this.#type = value;
|
|
37
|
-
}
|
|
38
|
-
/** @class */
|
|
39
|
-
constructor(wikitext, type, config, accum, acceptable) {
|
|
40
|
-
super(wikitext, config, accum, acceptable);
|
|
41
|
-
this.#type = type;
|
|
42
|
-
}
|
|
43
|
-
/* NOT FOR BROWSER */
|
|
44
|
-
cloneNode() {
|
|
45
|
-
const cloned = this.cloneChildNodes(), config = this.getAttribute('config'), acceptable = this.getAcceptable();
|
|
46
|
-
return debug_1.Shadow.run(() => {
|
|
47
|
-
const token = new AtomToken(undefined, this.type, config, [], acceptable);
|
|
48
|
-
token.append(...cloned);
|
|
49
|
-
return token;
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
exports.AtomToken = AtomToken;
|
|
54
|
-
constants_1.classes['AtomToken'] = __filename;
|
package/dist/src/attribute.d.ts
DELETED
|
@@ -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
|
-
}
|