wikiparser-node 1.19.0 → 1.20.0
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/README.md +3 -0
- package/bundle/bundle-es7.min.js +24 -31
- package/bundle/bundle-lsp.min.js +25 -98
- package/bundle/bundle.min.js +25 -32
- package/config/default.json +49 -3
- package/config/minimum.json +5 -1
- package/data/ext/math.json +660 -0
- package/dist/addon/table.js +24 -5
- package/dist/addon/transclude.js +4 -4
- package/dist/base.d.mts +1 -1
- package/dist/base.d.ts +1 -1
- package/dist/bin/config.js +26 -8
- package/dist/index.js +10 -1
- package/dist/internal.d.ts +2 -0
- package/dist/lib/document.d.ts +1 -0
- package/dist/lib/document.js +10 -1
- package/dist/lib/element.js +15 -21
- package/dist/lib/lsp.js +88 -58
- package/dist/lib/node.js +21 -24
- package/dist/lib/text.js +3 -4
- package/dist/lib/title.js +2 -1
- package/dist/mixin/attributesParent.js +1 -1
- package/dist/mixin/fixed.d.ts +1 -2
- package/dist/mixin/fixed.js +2 -3
- package/dist/mixin/gapped.d.ts +4 -0
- package/dist/mixin/gapped.js +24 -0
- package/dist/mixin/hidden.js +1 -1
- package/dist/mixin/multiLine.d.ts +4 -0
- package/dist/mixin/multiLine.js +33 -0
- package/dist/mixin/noEscape.js +1 -1
- package/dist/mixin/padded.d.ts +5 -0
- package/dist/mixin/padded.js +24 -0
- package/dist/mixin/singleLine.js +1 -1
- package/dist/mixin/sol.js +1 -1
- package/dist/mixin/syntax.js +3 -3
- package/dist/parser/braces.js +8 -12
- package/dist/parser/commentAndExt.js +18 -2
- package/dist/parser/magicLinks.js +2 -2
- package/dist/parser/selector.js +5 -2
- package/dist/src/arg.js +10 -13
- package/dist/src/atom.js +2 -7
- package/dist/src/attribute.js +6 -6
- package/dist/src/attributes.js +8 -12
- package/dist/src/commented.d.ts +26 -0
- package/dist/src/commented.js +52 -0
- package/dist/src/converter.js +3 -6
- package/dist/src/converterFlags.js +266 -223
- package/dist/src/converterRule.d.ts +2 -2
- package/dist/src/converterRule.js +2 -2
- package/dist/src/extLink.d.ts +2 -3
- package/dist/src/extLink.js +222 -175
- package/dist/src/gallery.d.ts +4 -5
- package/dist/src/gallery.js +177 -144
- package/dist/src/heading.js +11 -11
- package/dist/src/hidden.js +2 -7
- package/dist/src/imageParameter.d.ts +2 -2
- package/dist/src/imageParameter.js +6 -5
- package/dist/src/imagemap.d.ts +2 -2
- package/dist/src/imagemap.js +155 -123
- package/dist/src/imagemapLink.d.ts +2 -2
- package/dist/src/index.js +44 -20
- package/dist/src/link/base.d.ts +2 -3
- package/dist/src/link/base.js +13 -15
- package/dist/src/link/file.d.ts +2 -3
- package/dist/src/link/file.js +3 -3
- package/dist/src/link/galleryImage.d.ts +2 -3
- package/dist/src/link/galleryImage.js +7 -13
- package/dist/src/magicLink.js +7 -9
- package/dist/src/nested.d.ts +2 -2
- package/dist/src/nested.js +4 -7
- package/dist/src/nowiki/comment.js +2 -5
- package/dist/src/nowiki/doubleUnderscore.js +2 -5
- package/dist/src/nowiki/index.d.ts +2 -2
- package/dist/src/nowiki/index.js +2 -1
- package/dist/src/onlyinclude.js +6 -13
- package/dist/src/paramTag/index.d.ts +2 -2
- package/dist/src/paramTag/index.js +102 -66
- package/dist/src/parameter.d.ts +4 -5
- package/dist/src/parameter.js +13 -13
- package/dist/src/pre.d.ts +4 -5
- package/dist/src/pre.js +8 -17
- package/dist/src/syntax.d.ts +1 -1
- package/dist/src/syntax.js +2 -7
- package/dist/src/table/base.d.ts +2 -2
- package/dist/src/table/base.js +8 -8
- package/dist/src/table/index.js +1 -1
- package/dist/src/table/td.d.ts +3 -3
- package/dist/src/table/td.js +9 -9
- package/dist/src/table/tr.d.ts +2 -2
- package/dist/src/tagPair/ext.js +35 -30
- package/dist/src/tagPair/index.d.ts +1 -1
- package/dist/src/tagPair/index.js +2 -5
- package/dist/src/tagPair/translate.d.ts +38 -0
- package/dist/src/tagPair/translate.js +129 -0
- package/dist/src/transclude.js +5 -6
- package/dist/util/html.js +16 -1
- package/dist/util/lint.js +17 -30
- package/dist/util/sharable.js +29 -1
- package/dist/util/sharable.mjs +31 -3
- package/dist/util/string.js +14 -1
- package/extensions/dist/base.js +1 -1
- package/extensions/dist/lsp.js +13 -2
- package/package.json +4 -3
- package/extensions/es7/base.js +0 -320
- package/extensions/es7/lint.js +0 -97
package/dist/src/pre.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import Parser from '../index';
|
|
2
1
|
import { Token } from './index';
|
|
3
2
|
import { NoincludeToken } from './nowiki/noinclude';
|
|
4
|
-
import type { LintError } from '../base';
|
|
3
|
+
import type { Config, LintError } from '../base';
|
|
5
4
|
import type { AstText, AttributesToken, ExtToken, ConverterToken } from '../internal';
|
|
6
5
|
declare type Child = NoincludeToken | ConverterToken;
|
|
7
6
|
/**
|
|
@@ -14,17 +13,17 @@ export declare abstract class PreToken extends Token {
|
|
|
14
13
|
abstract get firstChild(): AstText | Child | undefined;
|
|
15
14
|
abstract get lastChild(): AstText | Child | undefined;
|
|
16
15
|
abstract get nextSibling(): undefined;
|
|
17
|
-
abstract get previousSibling(): AttributesToken;
|
|
16
|
+
abstract get previousSibling(): AttributesToken | undefined;
|
|
18
17
|
abstract get parentNode(): ExtToken | undefined;
|
|
19
18
|
abstract get children(): Child[];
|
|
20
19
|
abstract get firstElementChild(): Child | undefined;
|
|
21
20
|
abstract get lastElementChild(): Child | undefined;
|
|
22
|
-
abstract get previousElementSibling(): AttributesToken;
|
|
21
|
+
abstract get previousElementSibling(): AttributesToken | undefined;
|
|
23
22
|
abstract get nextElementSibling(): undefined;
|
|
24
23
|
abstract get parentElement(): ExtToken | undefined;
|
|
25
24
|
get type(): 'ext-inner';
|
|
26
25
|
/** @class */
|
|
27
|
-
constructor(wikitext?: string, config?:
|
|
26
|
+
constructor(wikitext?: string, config?: Config, accum?: Token[]);
|
|
28
27
|
cloneNode(): this;
|
|
29
28
|
}
|
|
30
29
|
export {};
|
package/dist/src/pre.js
CHANGED
|
@@ -1,26 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.PreToken = void 0;
|
|
7
4
|
const constants_1 = require("../util/constants");
|
|
8
|
-
const index_1 =
|
|
9
|
-
const index_2 = require("./index");
|
|
5
|
+
const index_1 = require("./index");
|
|
10
6
|
const noinclude_1 = require("./nowiki/noinclude");
|
|
11
7
|
/* NOT FOR BROWSER */
|
|
12
|
-
const
|
|
8
|
+
const html_1 = require("../util/html");
|
|
13
9
|
/**
|
|
14
10
|
* `<pre>`
|
|
15
11
|
* @classdesc `{childNodes: (AstText|NoincludeToken|ConverterToken)[]}`
|
|
16
12
|
*/
|
|
17
|
-
class PreToken extends
|
|
13
|
+
class PreToken extends index_1.Token {
|
|
18
14
|
/* NOT FOR BROWSER END */
|
|
19
15
|
get type() {
|
|
20
16
|
return 'ext-inner';
|
|
21
17
|
}
|
|
22
18
|
/** @class */
|
|
23
|
-
constructor(wikitext, config
|
|
19
|
+
constructor(wikitext, config, accum = []) {
|
|
24
20
|
if (wikitext) {
|
|
25
21
|
const opening = /<nowiki>/giu, closing = /<\/nowiki>/giu, { length } = opening.source;
|
|
26
22
|
let i = opening.exec(wikitext);
|
|
@@ -50,8 +46,8 @@ class PreToken extends index_2.Token {
|
|
|
50
46
|
this.setAttribute('stage', constants_1.MAX_STAGE - 1);
|
|
51
47
|
}
|
|
52
48
|
/** @private */
|
|
53
|
-
|
|
54
|
-
return
|
|
49
|
+
isPlain() {
|
|
50
|
+
return true;
|
|
55
51
|
}
|
|
56
52
|
/** @private */
|
|
57
53
|
lint(start = this.getAbsoluteIndex()) {
|
|
@@ -59,13 +55,8 @@ class PreToken extends index_2.Token {
|
|
|
59
55
|
}
|
|
60
56
|
/* NOT FOR BROWSER */
|
|
61
57
|
cloneNode() {
|
|
62
|
-
|
|
63
|
-
return
|
|
64
|
-
// @ts-expect-error abstract class
|
|
65
|
-
const token = new PreToken(undefined, this.getAttribute('config'));
|
|
66
|
-
token.append(...cloned);
|
|
67
|
-
return token;
|
|
68
|
-
});
|
|
58
|
+
// @ts-expect-error abstract class
|
|
59
|
+
return (0, html_1.cloneNode)(this, () => new PreToken(undefined, this.getAttribute('config')));
|
|
69
60
|
}
|
|
70
61
|
}
|
|
71
62
|
exports.PreToken = PreToken;
|
package/dist/src/syntax.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import type { Config, LintError } from '../base';
|
|
|
3
3
|
import type { SyntaxBase } from '../mixin/syntax';
|
|
4
4
|
export interface SyntaxToken extends SyntaxBase {
|
|
5
5
|
}
|
|
6
|
-
declare type SyntaxTypes = 'heading-trail' | 'magic-word-name' | 'table-syntax' | 'redirect-syntax';
|
|
6
|
+
declare type SyntaxTypes = 'heading-trail' | 'magic-word-name' | 'table-syntax' | 'redirect-syntax' | 'translate-attr';
|
|
7
7
|
/**
|
|
8
8
|
* plain token that satisfies specific grammar syntax
|
|
9
9
|
*
|
package/dist/src/syntax.js
CHANGED
|
@@ -37,8 +37,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
37
37
|
exports.SyntaxToken = void 0;
|
|
38
38
|
const index_1 = require("./index");
|
|
39
39
|
/* NOT FOR BROWSER */
|
|
40
|
-
const debug_1 = require("../util/debug");
|
|
41
40
|
const constants_1 = require("../util/constants");
|
|
41
|
+
const html_1 = require("../util/html");
|
|
42
42
|
const syntax_1 = require("../mixin/syntax");
|
|
43
43
|
/**
|
|
44
44
|
* plain token that satisfies specific grammar syntax
|
|
@@ -80,12 +80,7 @@ let SyntaxToken = (() => {
|
|
|
80
80
|
}
|
|
81
81
|
/* NOT FOR BROWSER */
|
|
82
82
|
cloneNode() {
|
|
83
|
-
|
|
84
|
-
return debug_1.Shadow.run(() => {
|
|
85
|
-
const token = new SyntaxToken(undefined, this.pattern, this.type, config, [], acceptable);
|
|
86
|
-
token.append(...cloned);
|
|
87
|
-
return token;
|
|
88
|
-
});
|
|
83
|
+
return (0, html_1.cloneNode)(this, () => new SyntaxToken(undefined, this.pattern, this.type, this.getAttribute('config'), [], this.getAcceptable()));
|
|
89
84
|
}
|
|
90
85
|
};
|
|
91
86
|
return SyntaxToken = _classThis;
|
package/dist/src/table/base.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import Parser from '../../index';
|
|
2
1
|
import { Token } from '../index';
|
|
3
2
|
import { SyntaxToken } from '../syntax';
|
|
4
3
|
import { AttributesToken } from '../attributes';
|
|
4
|
+
import type { Config } from '../../base';
|
|
5
5
|
import type { AttributesParentBase } from '../../mixin/attributesParent';
|
|
6
6
|
declare type TableTypes = 'table' | 'tr' | 'td';
|
|
7
7
|
export interface TableBaseToken extends AttributesParentBase {
|
|
@@ -20,7 +20,7 @@ export declare abstract class TableBaseToken extends Token {
|
|
|
20
20
|
* @param type 节点类型
|
|
21
21
|
* @param attr 表格属性
|
|
22
22
|
*/
|
|
23
|
-
constructor(pattern: RegExp, syntax: string, type: TableTypes, attr?: string, config?:
|
|
23
|
+
constructor(pattern: RegExp, syntax: string, type: TableTypes, attr?: string, config?: Config, accum?: Token[], acceptable?: Acceptable);
|
|
24
24
|
cloneNode(): this;
|
|
25
25
|
escape(): void;
|
|
26
26
|
}
|
package/dist/src/table/base.js
CHANGED
|
@@ -5,13 +5,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.TableBaseToken = void 0;
|
|
7
7
|
const attributesParent_1 = require("../../mixin/attributesParent");
|
|
8
|
-
const index_1 =
|
|
9
|
-
const index_2 = require("../index");
|
|
8
|
+
const index_1 = require("../index");
|
|
10
9
|
const syntax_1 = require("../syntax");
|
|
11
10
|
const attributes_1 = require("../attributes");
|
|
12
11
|
/* NOT FOR BROWSER */
|
|
13
12
|
const debug_1 = require("../../util/debug");
|
|
14
13
|
const constants_1 = require("../../util/constants");
|
|
14
|
+
const index_2 = __importDefault(require("../../index"));
|
|
15
15
|
/**
|
|
16
16
|
* 转义表格语法
|
|
17
17
|
* @param syntax 表格语法节点
|
|
@@ -19,9 +19,9 @@ const constants_1 = require("../../util/constants");
|
|
|
19
19
|
const escapeTable = (syntax) => {
|
|
20
20
|
const wikitext = syntax.childNodes.map(child => child.type === 'text'
|
|
21
21
|
? child.data.replaceAll('|', '{{!}}')
|
|
22
|
-
: child.toString()).join(''), { childNodes } =
|
|
22
|
+
: child.toString()).join(''), { childNodes } = index_2.default
|
|
23
23
|
.parse(wikitext, syntax.getAttribute('include'), 2, syntax.getAttribute('config'));
|
|
24
|
-
syntax.
|
|
24
|
+
syntax.safeReplaceChildren(childNodes);
|
|
25
25
|
};
|
|
26
26
|
/**
|
|
27
27
|
* table row that contains the newline at the beginning but not at the end
|
|
@@ -29,7 +29,7 @@ const escapeTable = (syntax) => {
|
|
|
29
29
|
* 表格行,含开头的换行,不含结尾的换行
|
|
30
30
|
* @classdesc `{childNodes: [SyntaxToken, AttributesToken, ...Token[]]}`
|
|
31
31
|
*/
|
|
32
|
-
class TableBaseToken extends (0, attributesParent_1.attributesParent)(1)(
|
|
32
|
+
class TableBaseToken extends (0, attributesParent_1.attributesParent)(1)(index_1.Token) {
|
|
33
33
|
/* NOT FOR BROWSER END */
|
|
34
34
|
/**
|
|
35
35
|
* @param pattern 表格语法正则
|
|
@@ -37,13 +37,13 @@ class TableBaseToken extends (0, attributesParent_1.attributesParent)(1)(index_2
|
|
|
37
37
|
* @param type 节点类型
|
|
38
38
|
* @param attr 表格属性
|
|
39
39
|
*/
|
|
40
|
-
constructor(pattern, syntax, type, attr, config
|
|
40
|
+
constructor(pattern, syntax, type, attr, config, accum = [], acceptable) {
|
|
41
41
|
super(undefined, config, accum, acceptable);
|
|
42
42
|
this.append(new syntax_1.SyntaxToken(syntax, pattern, 'table-syntax', config, accum, { 'Stage-1': ':', '!ExtToken': '', TranscludeToken: ':' }),
|
|
43
43
|
// @ts-expect-error abstract class
|
|
44
44
|
new attributes_1.AttributesToken(attr, 'table-attrs', type, config, accum));
|
|
45
45
|
/* NOT FOR BROWSER */
|
|
46
|
-
this.protectChildren(0, 1);
|
|
46
|
+
this.protectChildren([0, 1]);
|
|
47
47
|
}
|
|
48
48
|
/* NOT FOR BROWSER */
|
|
49
49
|
cloneNode() {
|
|
@@ -56,7 +56,7 @@ class TableBaseToken extends (0, attributesParent_1.attributesParent)(1)(index_2
|
|
|
56
56
|
token.childNodes[2].safeReplaceWith(cloned[0]);
|
|
57
57
|
}
|
|
58
58
|
else {
|
|
59
|
-
token.
|
|
59
|
+
token.safeAppend(cloned);
|
|
60
60
|
}
|
|
61
61
|
return token;
|
|
62
62
|
});
|
package/dist/src/table/index.js
CHANGED
package/dist/src/table/td.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import Parser from '../../index';
|
|
2
1
|
import { Token } from '../index';
|
|
3
2
|
import { TableBaseToken } from './base';
|
|
4
|
-
import type { LintError, AST
|
|
3
|
+
import type { Config, LintError, AST } from '../../base';
|
|
5
4
|
import type { SyntaxToken, AttributesToken, TrToken, TableToken } from '../../internal';
|
|
5
|
+
import Parser from '../../index';
|
|
6
6
|
export type TdSubtypes = 'td' | 'th' | 'caption';
|
|
7
7
|
export interface TdSpanAttrs {
|
|
8
8
|
rowspan?: number;
|
|
@@ -43,7 +43,7 @@ export declare abstract class TdToken extends TableBaseToken {
|
|
|
43
43
|
* @param syntax 单元格语法
|
|
44
44
|
* @param inner 内部wikitext
|
|
45
45
|
*/
|
|
46
|
-
constructor(syntax: string, inner?: string, config?:
|
|
46
|
+
constructor(syntax: string, inner?: string, config?: Config, accum?: Token[]);
|
|
47
47
|
/**
|
|
48
48
|
* Check if the cell is at the beginning of a line
|
|
49
49
|
*
|
package/dist/src/table/td.js
CHANGED
|
@@ -41,13 +41,13 @@ exports.createTd = exports.TdToken = void 0;
|
|
|
41
41
|
const lint_1 = require("../../util/lint");
|
|
42
42
|
const constants_1 = require("../../util/constants");
|
|
43
43
|
const rect_1 = require("../../lib/rect");
|
|
44
|
-
const index_1 =
|
|
45
|
-
const index_2 = require("../index");
|
|
44
|
+
const index_1 = require("../index");
|
|
46
45
|
const base_1 = require("./base");
|
|
47
46
|
/* NOT FOR BROWSER */
|
|
48
47
|
const debug_1 = require("../../util/debug");
|
|
49
48
|
const string_1 = require("../../util/string");
|
|
50
49
|
const fixed_1 = require("../../mixin/fixed");
|
|
50
|
+
const index_2 = __importDefault(require("../../index"));
|
|
51
51
|
/* NOT FOR BROWSER END */
|
|
52
52
|
/**
|
|
53
53
|
* `<td>`, `<th>` or `<caption>`
|
|
@@ -104,14 +104,14 @@ let TdToken = (() => {
|
|
|
104
104
|
return this.lastChild.text().trim();
|
|
105
105
|
}
|
|
106
106
|
set innerText(text) {
|
|
107
|
-
this.lastChild.replaceChildren(...
|
|
107
|
+
this.lastChild.replaceChildren(...index_2.default.parse(text, true, undefined, this.getAttribute('config')).childNodes);
|
|
108
108
|
}
|
|
109
109
|
/* NOT FOR BROWSER END */
|
|
110
110
|
/**
|
|
111
111
|
* @param syntax 单元格语法
|
|
112
112
|
* @param inner 内部wikitext
|
|
113
113
|
*/
|
|
114
|
-
constructor(syntax, inner, config
|
|
114
|
+
constructor(syntax, inner, config, accum = []) {
|
|
115
115
|
let innerSyntax = /\||\0\d+!\x7F/u.exec(inner ?? ''), attr = innerSyntax ? inner.slice(0, innerSyntax.index) : '';
|
|
116
116
|
if (/\[\[|-\{/u.test(attr)) {
|
|
117
117
|
innerSyntax = null;
|
|
@@ -121,7 +121,7 @@ let TdToken = (() => {
|
|
|
121
121
|
if (innerSyntax) {
|
|
122
122
|
[this.#innerSyntax] = innerSyntax;
|
|
123
123
|
}
|
|
124
|
-
const innerToken = new
|
|
124
|
+
const innerToken = new index_1.Token(inner?.slice((innerSyntax?.index ?? NaN) + this.#innerSyntax.length), config, accum);
|
|
125
125
|
innerToken.type = 'td-inner';
|
|
126
126
|
innerToken.setAttribute('stage', 4);
|
|
127
127
|
this.insertAt(innerToken);
|
|
@@ -160,7 +160,7 @@ let TdToken = (() => {
|
|
|
160
160
|
/* NOT FOR BROWSER */
|
|
161
161
|
const str = previousSibling.lastChild.toString();
|
|
162
162
|
result.escape ||= esc;
|
|
163
|
-
result.correction = str.includes('\n') && debug_1.Shadow.run(() => new
|
|
163
|
+
result.correction = str.includes('\n') && debug_1.Shadow.run(() => new index_1.Token(str, this.getAttribute('config'))
|
|
164
164
|
.parseOnce(0, this.getAttribute('include'))
|
|
165
165
|
.parseOnce()
|
|
166
166
|
.parseOnce()
|
|
@@ -250,7 +250,7 @@ let TdToken = (() => {
|
|
|
250
250
|
}
|
|
251
251
|
getAttr(key) {
|
|
252
252
|
const value = super.getAttr(key);
|
|
253
|
-
key =
|
|
253
|
+
key = (0, string_1.trimLc)(key);
|
|
254
254
|
return (key === 'rowspan' || key === 'colspan' ? parseInt(value) || 1 : value);
|
|
255
255
|
}
|
|
256
256
|
/** @private */
|
|
@@ -322,7 +322,7 @@ let TdToken = (() => {
|
|
|
322
322
|
}
|
|
323
323
|
return;
|
|
324
324
|
}
|
|
325
|
-
const key =
|
|
325
|
+
const key = (0, string_1.trimLc)(keyOrProp);
|
|
326
326
|
let v;
|
|
327
327
|
if (typeof value === 'number' && (key === 'rowspan' || key === 'colspan')) {
|
|
328
328
|
v = value === 1 ? false : String(value);
|
|
@@ -367,7 +367,7 @@ exports.TdToken = TdToken;
|
|
|
367
367
|
* @param config
|
|
368
368
|
*/
|
|
369
369
|
const createTd = (inner, subtype = 'td', attr = {}, include, config) => {
|
|
370
|
-
const innerToken = typeof inner === 'string' ?
|
|
370
|
+
const innerToken = typeof inner === 'string' ? index_2.default.parse(inner, include, undefined, config) : inner,
|
|
371
371
|
// @ts-expect-error abstract class
|
|
372
372
|
token = debug_1.Shadow.run(() => new TdToken('\n|', undefined, config));
|
|
373
373
|
token.setSyntax(subtype);
|
package/dist/src/table/tr.d.ts
CHANGED
|
@@ -13,12 +13,12 @@ export declare abstract class TrToken extends TrBaseToken {
|
|
|
13
13
|
abstract get lastChild(): AttributesToken | TdToken;
|
|
14
14
|
abstract get parentNode(): TableToken | undefined;
|
|
15
15
|
abstract get nextSibling(): this | SyntaxToken | undefined;
|
|
16
|
-
abstract get previousSibling(): Token;
|
|
16
|
+
abstract get previousSibling(): Token | undefined;
|
|
17
17
|
abstract get children(): [SyntaxToken, AttributesToken, ...TdToken[]];
|
|
18
18
|
abstract get lastElementChild(): AttributesToken | TdToken;
|
|
19
19
|
abstract get parentElement(): TableToken | undefined;
|
|
20
20
|
abstract get nextElementSibling(): this | SyntaxToken | undefined;
|
|
21
|
-
abstract get previousElementSibling(): Token;
|
|
21
|
+
abstract get previousElementSibling(): Token | undefined;
|
|
22
22
|
get type(): 'tr';
|
|
23
23
|
/**
|
|
24
24
|
* @param syntax 表格语法
|
package/dist/src/tagPair/ext.js
CHANGED
|
@@ -45,26 +45,10 @@ const attributesParent_1 = require("../../mixin/attributesParent");
|
|
|
45
45
|
const index_2 = require("../index");
|
|
46
46
|
const index_3 = require("./index");
|
|
47
47
|
const attributes_1 = require("../attributes");
|
|
48
|
-
const pre_1 = require("../pre");
|
|
49
|
-
const index_4 = require("../paramTag/index");
|
|
50
|
-
const inputbox_1 = require("../paramTag/inputbox");
|
|
51
|
-
const gallery_1 = require("../gallery");
|
|
52
|
-
const imagemap_1 = require("../imagemap");
|
|
53
|
-
const index_5 = require("../nowiki/index");
|
|
54
48
|
/* NOT FOR BROWSER */
|
|
55
49
|
const debug_1 = require("../../util/debug");
|
|
56
50
|
const constants_1 = require("../../util/constants");
|
|
57
51
|
const string_1 = require("../../util/string");
|
|
58
|
-
/**
|
|
59
|
-
* 从数组中删除指定元素
|
|
60
|
-
* @param arr 数组
|
|
61
|
-
* @param ele 元素
|
|
62
|
-
*/
|
|
63
|
-
const del = (arr, ele) => {
|
|
64
|
-
const set = new Set(arr);
|
|
65
|
-
set.delete(ele);
|
|
66
|
-
return [...set];
|
|
67
|
-
};
|
|
68
52
|
/**
|
|
69
53
|
* extension tag
|
|
70
54
|
*
|
|
@@ -102,13 +86,13 @@ let ExtToken = (() => {
|
|
|
102
86
|
// @ts-expect-error abstract class
|
|
103
87
|
attrToken = new attributes_1.AttributesToken(!attr || /^\s/u.test(attr) ? attr : ` ${attr}`, 'ext-attrs', lcName, config, accum), newConfig = {
|
|
104
88
|
...config,
|
|
105
|
-
ext:
|
|
89
|
+
ext: config.ext.filter(e => e !== lcName),
|
|
106
90
|
excludes: [...config.excludes],
|
|
107
91
|
};
|
|
108
92
|
let innerToken;
|
|
109
93
|
switch (lcName) {
|
|
110
94
|
case 'tab':
|
|
111
|
-
newConfig.ext =
|
|
95
|
+
newConfig.ext = newConfig.ext.filter(e => e !== 'tabs');
|
|
112
96
|
// fall through
|
|
113
97
|
case 'indicator':
|
|
114
98
|
case 'poem':
|
|
@@ -118,23 +102,31 @@ let ExtToken = (() => {
|
|
|
118
102
|
case 'tabs':
|
|
119
103
|
case 'poll':
|
|
120
104
|
case 'seo':
|
|
105
|
+
case 'langconvert':
|
|
106
|
+
case 'phonos':
|
|
121
107
|
if (lcName === 'poem') {
|
|
122
108
|
newConfig.excludes.push('heading');
|
|
123
109
|
}
|
|
124
110
|
innerToken = new index_2.Token(inner, newConfig, accum);
|
|
125
111
|
break;
|
|
126
|
-
case 'pre':
|
|
112
|
+
case 'pre': {
|
|
113
|
+
const { PreToken } = require('../pre');
|
|
127
114
|
// @ts-expect-error abstract class
|
|
128
|
-
innerToken = new
|
|
115
|
+
innerToken = new PreToken(inner, newConfig, accum);
|
|
129
116
|
break;
|
|
130
|
-
|
|
117
|
+
}
|
|
118
|
+
case 'dynamicpagelist': {
|
|
119
|
+
const { ParamTagToken } = require('../paramTag/index');
|
|
131
120
|
// @ts-expect-error abstract class
|
|
132
|
-
innerToken = new
|
|
121
|
+
innerToken = new ParamTagToken(include, inner, newConfig, accum);
|
|
133
122
|
break;
|
|
134
|
-
|
|
123
|
+
}
|
|
124
|
+
case 'inputbox': {
|
|
125
|
+
const { InputboxToken } = require('../paramTag/inputbox');
|
|
135
126
|
// @ts-expect-error abstract class
|
|
136
|
-
innerToken = new
|
|
127
|
+
innerToken = new InputboxToken(include, inner, newConfig, accum);
|
|
137
128
|
break;
|
|
129
|
+
}
|
|
138
130
|
case 'references': {
|
|
139
131
|
// NestedToken 依赖 ExtToken
|
|
140
132
|
const { NestedToken } = require('../nested');
|
|
@@ -157,14 +149,24 @@ let ExtToken = (() => {
|
|
|
157
149
|
innerToken = new NestedToken(inner, /<(combooption)(\s[^>]*?)?(?:\/>|>([\s\S]*?)<\/(combooption\s*)>)/giu, ['combooption'], newConfig, accum);
|
|
158
150
|
break;
|
|
159
151
|
}
|
|
160
|
-
case 'gallery':
|
|
152
|
+
case 'gallery': {
|
|
153
|
+
const { GalleryToken } = require('../gallery');
|
|
161
154
|
// @ts-expect-error abstract class
|
|
162
|
-
innerToken = new
|
|
155
|
+
innerToken = new GalleryToken(inner, newConfig, accum);
|
|
163
156
|
break;
|
|
164
|
-
|
|
157
|
+
}
|
|
158
|
+
case 'imagemap': {
|
|
159
|
+
const { ImagemapToken } = require('../imagemap');
|
|
160
|
+
// @ts-expect-error abstract class
|
|
161
|
+
innerToken = new ImagemapToken(inner, newConfig, accum);
|
|
162
|
+
break;
|
|
163
|
+
}
|
|
164
|
+
case 'hiero': {
|
|
165
|
+
const { CommentedToken } = require('../commented');
|
|
165
166
|
// @ts-expect-error abstract class
|
|
166
|
-
innerToken = new
|
|
167
|
+
innerToken = new CommentedToken(inner, newConfig, accum);
|
|
167
168
|
break;
|
|
169
|
+
}
|
|
168
170
|
// 更多定制扩展的代码示例:
|
|
169
171
|
// ```
|
|
170
172
|
// case 'extensionName': {
|
|
@@ -173,15 +175,18 @@ let ExtToken = (() => {
|
|
|
173
175
|
// break;
|
|
174
176
|
// }
|
|
175
177
|
// ```
|
|
176
|
-
default:
|
|
178
|
+
default: {
|
|
179
|
+
const { NowikiToken } = require('../nowiki/index');
|
|
177
180
|
// @ts-expect-error abstract class
|
|
178
|
-
innerToken = new
|
|
181
|
+
innerToken = new NowikiToken(inner, newConfig, accum);
|
|
182
|
+
}
|
|
179
183
|
}
|
|
180
184
|
innerToken.setAttribute('name', lcName);
|
|
181
185
|
if (innerToken.type === 'plain') {
|
|
182
186
|
innerToken.type = 'ext-inner';
|
|
183
187
|
}
|
|
184
188
|
super(name, attrToken, innerToken, closed, config, accum);
|
|
189
|
+
/* PRINT ONLY */
|
|
185
190
|
this.seal('closed', true);
|
|
186
191
|
}
|
|
187
192
|
/** @private */
|
|
@@ -11,7 +11,7 @@ export declare abstract class TagPairToken extends Token {
|
|
|
11
11
|
readonly name: string;
|
|
12
12
|
closed: boolean;
|
|
13
13
|
selfClosing: boolean;
|
|
14
|
-
abstract get type(): 'ext' | 'include';
|
|
14
|
+
abstract get type(): 'ext' | 'include' | 'translate';
|
|
15
15
|
readonly childNodes: readonly [AstNodes, AstNodes];
|
|
16
16
|
abstract get firstChild(): AstNodes;
|
|
17
17
|
abstract get lastChild(): AstNodes;
|
|
@@ -38,6 +38,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
38
38
|
};
|
|
39
39
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
40
|
exports.TagPairToken = void 0;
|
|
41
|
+
const gapped_1 = require("../../mixin/gapped");
|
|
41
42
|
const index_1 = require("../index");
|
|
42
43
|
/* NOT FOR BROWSER */
|
|
43
44
|
const constants_1 = require("../../util/constants");
|
|
@@ -51,7 +52,7 @@ const index_2 = __importDefault(require("../../index"));
|
|
|
51
52
|
* 成对标签
|
|
52
53
|
*/
|
|
53
54
|
let TagPairToken = (() => {
|
|
54
|
-
let _classDecorators = [fixed_1.fixedToken, noEscape_1.noEscape];
|
|
55
|
+
let _classDecorators = [fixed_1.fixedToken, noEscape_1.noEscape, (0, gapped_1.gapped)()];
|
|
55
56
|
let _classDescriptor;
|
|
56
57
|
let _classExtraInitializers = [];
|
|
57
58
|
let _classThis;
|
|
@@ -121,10 +122,6 @@ let TagPairToken = (() => {
|
|
|
121
122
|
return key === 'padding' ? this.#tags[0].length + 1 : super.getAttribute(key);
|
|
122
123
|
}
|
|
123
124
|
/** @private */
|
|
124
|
-
getGaps() {
|
|
125
|
-
return 1;
|
|
126
|
-
}
|
|
127
|
-
/** @private */
|
|
128
125
|
print() {
|
|
129
126
|
const [opening, closing] = this.#tags;
|
|
130
127
|
return super.print(this.selfClosing
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Token } from '../index';
|
|
2
|
+
import { TagPairToken } from './index';
|
|
3
|
+
import { SyntaxToken } from '../syntax';
|
|
4
|
+
import type { Config } from '../../base';
|
|
5
|
+
import type { AttributesParentBase } from '../../mixin/attributesParent';
|
|
6
|
+
/**
|
|
7
|
+
* `<translate>`
|
|
8
|
+
* @classdesc `{childNodes: [SyntaxToken, Token]}`
|
|
9
|
+
*/
|
|
10
|
+
export declare abstract class TranslateToken extends TagPairToken implements Omit<AttributesParentBase, 'attributes' | 'className' | 'classList' | 'id' | 'getAttrNames' | 'getAttrs' | 'css'> {
|
|
11
|
+
#private;
|
|
12
|
+
name: 'translate';
|
|
13
|
+
closed: true;
|
|
14
|
+
selfClosing: false;
|
|
15
|
+
readonly childNodes: readonly [SyntaxToken, Token];
|
|
16
|
+
abstract get firstChild(): SyntaxToken;
|
|
17
|
+
abstract get lastChild(): Token;
|
|
18
|
+
abstract get children(): [SyntaxToken, Token];
|
|
19
|
+
abstract get firstElementChild(): SyntaxToken;
|
|
20
|
+
abstract get lastElementChild(): Token;
|
|
21
|
+
get type(): 'translate';
|
|
22
|
+
/**
|
|
23
|
+
* @param attr 标签属性
|
|
24
|
+
* @param inner 内部wikitext
|
|
25
|
+
*/
|
|
26
|
+
constructor(attr?: string, inner?: string, config?: Config, accum?: Token[]);
|
|
27
|
+
/** @implements */
|
|
28
|
+
getAttr(key: string): true | undefined;
|
|
29
|
+
/** @implements */
|
|
30
|
+
hasAttr(key: string): boolean;
|
|
31
|
+
/** @implements */
|
|
32
|
+
setAttr(keyOrProp: string | Record<string, string | boolean>, value?: string | boolean): void;
|
|
33
|
+
/** @implements */
|
|
34
|
+
removeAttr(key: string): void;
|
|
35
|
+
/** @implements */
|
|
36
|
+
toggleAttr(key: string, force?: boolean): void;
|
|
37
|
+
cloneNode(): this;
|
|
38
|
+
}
|