wikiparser-node 1.3.3 → 1.3.4-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/README.en.md +1 -1
- package/README.md +1 -1
- package/bundle/bundle.min.js +36 -0
- package/config/llwiki.json +1 -35
- package/config/moegirl.json +1 -44
- package/config/zhwiki.json +1 -466
- package/extensions/dist/base.js +68 -0
- package/extensions/dist/editor.js +159 -0
- package/extensions/dist/highlight.js +30 -0
- package/extensions/dist/lint.js +48 -0
- package/extensions/editor.css +63 -0
- package/extensions/ui.css +114 -0
- package/package.json +32 -12
- package/config/.schema.json +0 -172
- package/dist/addon/table.d.ts +0 -6
- package/dist/addon/table.js +0 -564
- package/dist/base.d.ts +0 -45
- package/dist/bin/toc.js +0 -18
- package/dist/index.d.ts +0 -31
- package/dist/index.js +0 -209
- package/dist/internal.d.ts +0 -44
- package/dist/lib/element.d.ts +0 -155
- package/dist/lib/element.js +0 -634
- package/dist/lib/node.d.ts +0 -146
- package/dist/lib/node.js +0 -419
- package/dist/lib/range.d.ts +0 -104
- package/dist/lib/range.js +0 -385
- package/dist/lib/ranges.d.ts +0 -26
- package/dist/lib/ranges.js +0 -117
- package/dist/lib/text.d.ts +0 -62
- package/dist/lib/text.js +0 -248
- package/dist/lib/title.d.ts +0 -38
- package/dist/lib/title.js +0 -162
- package/dist/mixin/attributesParent.js +0 -94
- package/dist/mixin/fixed.js +0 -32
- package/dist/mixin/flagsParent.js +0 -70
- package/dist/mixin/hidden.js +0 -26
- package/dist/mixin/magicLinkParent.js +0 -41
- package/dist/mixin/singleLine.js +0 -25
- package/dist/mixin/sol.js +0 -43
- package/dist/mixin/syntax.js +0 -56
- package/dist/parser/braces.js +0 -121
- package/dist/parser/commentAndExt.js +0 -69
- package/dist/parser/converter.js +0 -40
- package/dist/parser/externalLinks.js +0 -28
- package/dist/parser/hrAndDoubleUnderscore.js +0 -38
- package/dist/parser/html.js +0 -36
- package/dist/parser/links.js +0 -94
- package/dist/parser/list.js +0 -59
- package/dist/parser/magicLinks.js +0 -40
- package/dist/parser/quotes.js +0 -67
- package/dist/parser/selector.js +0 -162
- package/dist/parser/table.js +0 -112
- package/dist/src/arg.d.ts +0 -58
- package/dist/src/arg.js +0 -189
- package/dist/src/atom.d.ts +0 -12
- package/dist/src/atom.js +0 -27
- package/dist/src/attribute.d.ts +0 -87
- package/dist/src/attribute.js +0 -392
- package/dist/src/attributes.d.ts +0 -107
- package/dist/src/attributes.js +0 -341
- package/dist/src/converter.d.ts +0 -52
- package/dist/src/converter.js +0 -79
- package/dist/src/converterFlags.d.ts +0 -87
- package/dist/src/converterFlags.js +0 -224
- package/dist/src/converterRule.d.ts +0 -81
- package/dist/src/converterRule.js +0 -212
- package/dist/src/extLink.d.ts +0 -54
- package/dist/src/extLink.js +0 -122
- package/dist/src/gallery.d.ts +0 -55
- package/dist/src/gallery.js +0 -122
- package/dist/src/heading.d.ts +0 -74
- package/dist/src/heading.js +0 -127
- package/dist/src/hidden.d.ts +0 -22
- package/dist/src/hidden.js +0 -23
- package/dist/src/html.d.ts +0 -101
- package/dist/src/html.js +0 -227
- package/dist/src/imageParameter.d.ts +0 -66
- package/dist/src/imageParameter.js +0 -247
- package/dist/src/imagemap.d.ts +0 -57
- package/dist/src/imagemap.js +0 -148
- package/dist/src/imagemapLink.d.ts +0 -59
- package/dist/src/imagemapLink.js +0 -40
- package/dist/src/index.d.ts +0 -146
- package/dist/src/index.js +0 -777
- package/dist/src/link/base.d.ts +0 -52
- package/dist/src/link/base.js +0 -209
- package/dist/src/link/category.d.ts +0 -13
- package/dist/src/link/category.js +0 -29
- package/dist/src/link/file.d.ts +0 -96
- package/dist/src/link/file.js +0 -255
- package/dist/src/link/galleryImage.d.ts +0 -44
- package/dist/src/link/galleryImage.js +0 -106
- package/dist/src/link/index.d.ts +0 -53
- package/dist/src/link/index.js +0 -123
- package/dist/src/magicLink.d.ts +0 -70
- package/dist/src/magicLink.js +0 -147
- package/dist/src/nested.d.ts +0 -44
- package/dist/src/nested.js +0 -87
- package/dist/src/nowiki/base.d.ts +0 -47
- package/dist/src/nowiki/base.js +0 -42
- package/dist/src/nowiki/comment.d.ts +0 -40
- package/dist/src/nowiki/comment.js +0 -67
- package/dist/src/nowiki/dd.d.ts +0 -8
- package/dist/src/nowiki/dd.js +0 -25
- package/dist/src/nowiki/doubleUnderscore.d.ts +0 -45
- package/dist/src/nowiki/doubleUnderscore.js +0 -50
- package/dist/src/nowiki/hr.d.ts +0 -31
- package/dist/src/nowiki/hr.js +0 -14
- package/dist/src/nowiki/index.d.ts +0 -16
- package/dist/src/nowiki/index.js +0 -21
- package/dist/src/nowiki/list.d.ts +0 -30
- package/dist/src/nowiki/list.js +0 -48
- package/dist/src/nowiki/listBase.d.ts +0 -19
- package/dist/src/nowiki/listBase.js +0 -12
- package/dist/src/nowiki/noinclude.d.ts +0 -26
- package/dist/src/nowiki/noinclude.js +0 -25
- package/dist/src/nowiki/quote.d.ts +0 -23
- package/dist/src/nowiki/quote.js +0 -45
- package/dist/src/onlyinclude.d.ts +0 -16
- package/dist/src/onlyinclude.js +0 -57
- package/dist/src/paramTag/index.d.ts +0 -37
- package/dist/src/paramTag/index.js +0 -68
- package/dist/src/paramTag/inputbox.d.ts +0 -8
- package/dist/src/paramTag/inputbox.js +0 -23
- package/dist/src/parameter.d.ts +0 -85
- package/dist/src/parameter.js +0 -205
- package/dist/src/pre.d.ts +0 -28
- package/dist/src/pre.js +0 -51
- package/dist/src/syntax.d.ts +0 -28
- package/dist/src/syntax.js +0 -34
- package/dist/src/table/base.d.ts +0 -53
- package/dist/src/table/base.js +0 -78
- package/dist/src/table/index.d.ts +0 -229
- package/dist/src/table/index.js +0 -379
- package/dist/src/table/td.d.ts +0 -104
- package/dist/src/table/td.js +0 -261
- package/dist/src/table/tr.d.ts +0 -32
- package/dist/src/table/tr.js +0 -56
- package/dist/src/table/trBase.d.ts +0 -54
- package/dist/src/table/trBase.js +0 -159
- package/dist/src/tagPair/ext.d.ts +0 -56
- package/dist/src/tagPair/ext.js +0 -142
- package/dist/src/tagPair/include.d.ts +0 -53
- package/dist/src/tagPair/include.js +0 -63
- package/dist/src/tagPair/index.d.ts +0 -48
- package/dist/src/tagPair/index.js +0 -93
- package/dist/src/transclude.d.ts +0 -167
- package/dist/src/transclude.js +0 -690
- package/dist/util/constants.js +0 -108
- package/dist/util/debug.js +0 -64
- package/dist/util/diff.js +0 -72
- package/dist/util/lint.js +0 -46
- package/dist/util/string.js +0 -61
- package/errors/README +0 -1
- package/printed/README +0 -1
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import * as Parser from '../../index';
|
|
2
|
-
import { Token } from '../index';
|
|
3
|
-
import type { AstText } from '../../lib/text';
|
|
4
|
-
declare type NowikiTypes = 'ext-inner' | 'comment' | 'dd' | 'double-underscore' | 'hr' | 'list' | 'noinclude' | 'quote';
|
|
5
|
-
declare const NowikiBaseToken_base: ((abstract new (...args: any[]) => {
|
|
6
|
-
removeAt(): never;
|
|
7
|
-
insertAt(token: string, i?: number | undefined): Parser.AstText;
|
|
8
|
-
insertAt<T extends Parser.AstNodes>(token: T, i?: number | undefined): T;
|
|
9
|
-
readonly length: number;
|
|
10
|
-
toString(omit?: Set<string> | undefined, separator?: string | undefined): string;
|
|
11
|
-
text(separator?: string | undefined): string;
|
|
12
|
-
lint(start?: number | undefined): Parser.LintError[];
|
|
13
|
-
afterBuild(): void;
|
|
14
|
-
getAttribute<T_1 extends string>(key: T_1): TokenAttributeGetter<T_1>;
|
|
15
|
-
setAttribute<T_2 extends string>(key: T_2, value: TokenAttributeSetter<T_2>): void;
|
|
16
|
-
addEventListener(events: string | string[], listener: AstListener): void;
|
|
17
|
-
replaceChildren(...elements: (string | Parser.AstNodes)[]): void;
|
|
18
|
-
}) & {
|
|
19
|
-
readonly fixed: true;
|
|
20
|
-
}) & typeof Parser.Token;
|
|
21
|
-
/**
|
|
22
|
-
* 纯文字Token,不会被解析
|
|
23
|
-
* @classdesc `{childNodes: [AstText]}`
|
|
24
|
-
*/
|
|
25
|
-
export declare abstract class NowikiBaseToken extends NowikiBaseToken_base {
|
|
26
|
-
type: NowikiTypes;
|
|
27
|
-
readonly childNodes: [AstText];
|
|
28
|
-
abstract get children(): [];
|
|
29
|
-
abstract get firstChild(): AstText;
|
|
30
|
-
abstract get firstElementChild(): undefined;
|
|
31
|
-
abstract get lastChild(): AstText;
|
|
32
|
-
abstract get lastElementChild(): undefined;
|
|
33
|
-
/** 纯文本部分 */
|
|
34
|
-
get innerText(): string;
|
|
35
|
-
/** @param wikitext default: `''` */
|
|
36
|
-
constructor(wikitext?: string, config?: Parser.Config, accum?: Token[]);
|
|
37
|
-
/** @override */
|
|
38
|
-
cloneNode(this: this & {
|
|
39
|
-
constructor: new (...args: any[]) => unknown;
|
|
40
|
-
}): this;
|
|
41
|
-
/**
|
|
42
|
-
* @override
|
|
43
|
-
* @param str 新文本
|
|
44
|
-
*/
|
|
45
|
-
setText(str: string): string;
|
|
46
|
-
}
|
|
47
|
-
export {};
|
package/dist/src/nowiki/base.js
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.NowikiBaseToken = void 0;
|
|
4
|
-
const debug_1 = require("../../util/debug");
|
|
5
|
-
const constants_1 = require("../../util/constants");
|
|
6
|
-
const fixed_1 = require("../../mixin/fixed");
|
|
7
|
-
const Parser = require("../../index");
|
|
8
|
-
const index_1 = require("../index");
|
|
9
|
-
/**
|
|
10
|
-
* 纯文字Token,不会被解析
|
|
11
|
-
* @classdesc `{childNodes: [AstText]}`
|
|
12
|
-
*/
|
|
13
|
-
class NowikiBaseToken extends (0, fixed_1.fixed)(index_1.Token) {
|
|
14
|
-
/** 纯文本部分 */
|
|
15
|
-
get innerText() {
|
|
16
|
-
return this.firstChild.data;
|
|
17
|
-
}
|
|
18
|
-
/** @param wikitext default: `''` */
|
|
19
|
-
constructor(wikitext = '', config = Parser.getConfig(), accum = []) {
|
|
20
|
-
super(wikitext, config, accum);
|
|
21
|
-
}
|
|
22
|
-
/* NOT FOR BROWSER */
|
|
23
|
-
/** @override */
|
|
24
|
-
cloneNode() {
|
|
25
|
-
const { constructor, firstChild: { data }, type } = this;
|
|
26
|
-
return debug_1.Shadow.run(() => {
|
|
27
|
-
const token = new constructor(data, this.getAttribute('config'));
|
|
28
|
-
token.type = type;
|
|
29
|
-
token.afterBuild();
|
|
30
|
-
return token;
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* @override
|
|
35
|
-
* @param str 新文本
|
|
36
|
-
*/
|
|
37
|
-
setText(str) {
|
|
38
|
-
return super.setText(str, 0);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
exports.NowikiBaseToken = NowikiBaseToken;
|
|
42
|
-
constants_1.classes['NowikiBaseToken'] = __filename;
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import * as Parser from '../../index';
|
|
2
|
-
import { NowikiBaseToken } from './base';
|
|
3
|
-
import type { LintError } from '../../base';
|
|
4
|
-
import type { Token } from '../index';
|
|
5
|
-
declare const CommentToken_base: ((abstract new (...args: any[]) => {
|
|
6
|
-
text(): string;
|
|
7
|
-
lint(): Parser.LintError[];
|
|
8
|
-
readonly length: number;
|
|
9
|
-
toString(omit?: Set<string> | undefined, separator?: string | undefined): string;
|
|
10
|
-
insertAt(token: unknown, i?: number | undefined): unknown;
|
|
11
|
-
afterBuild(): void;
|
|
12
|
-
getAttribute<T extends string>(key: T): TokenAttributeGetter<T>;
|
|
13
|
-
setAttribute<T_1 extends string>(key: T_1, value: TokenAttributeSetter<T_1>): void;
|
|
14
|
-
addEventListener(events: string | string[], listener: AstListener): void;
|
|
15
|
-
replaceChildren(...elements: (string | Parser.AstNodes)[]): void;
|
|
16
|
-
}) & {
|
|
17
|
-
readonly hidden: true;
|
|
18
|
-
}) & typeof NowikiBaseToken;
|
|
19
|
-
/** HTML注释,不可见 */
|
|
20
|
-
export declare class CommentToken extends CommentToken_base {
|
|
21
|
-
readonly type = "comment";
|
|
22
|
-
closed: boolean;
|
|
23
|
-
/** 内部文本 */
|
|
24
|
-
get innerText(): string;
|
|
25
|
-
set innerText(text: string);
|
|
26
|
-
/** @param closed 是否闭合 */
|
|
27
|
-
constructor(wikitext: string, closed?: boolean, config?: Parser.Config, accum?: Token[]);
|
|
28
|
-
/** @override */
|
|
29
|
-
lint(start?: number): LintError[];
|
|
30
|
-
/** @override */
|
|
31
|
-
print(): string;
|
|
32
|
-
/** @override */
|
|
33
|
-
cloneNode(): this;
|
|
34
|
-
/**
|
|
35
|
-
* @override
|
|
36
|
-
* @throws `RangeError` 不允许包含`-->`
|
|
37
|
-
*/
|
|
38
|
-
setText(text: string): string;
|
|
39
|
-
}
|
|
40
|
-
export {};
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CommentToken = void 0;
|
|
4
|
-
const lint_1 = require("../../util/lint");
|
|
5
|
-
const debug_1 = require("../../util/debug");
|
|
6
|
-
const constants_1 = require("../../util/constants");
|
|
7
|
-
const hidden_1 = require("../../mixin/hidden");
|
|
8
|
-
const Parser = require("../../index");
|
|
9
|
-
const base_1 = require("./base");
|
|
10
|
-
/** HTML注释,不可见 */
|
|
11
|
-
// @ts-expect-error not implementing all abstract methods
|
|
12
|
-
class CommentToken extends (0, hidden_1.hidden)(base_1.NowikiBaseToken) {
|
|
13
|
-
type = 'comment';
|
|
14
|
-
closed;
|
|
15
|
-
/* NOT FOR BROWSER */
|
|
16
|
-
/** 内部文本 */
|
|
17
|
-
get innerText() {
|
|
18
|
-
return super.innerText;
|
|
19
|
-
}
|
|
20
|
-
set innerText(text) {
|
|
21
|
-
this.setText(text);
|
|
22
|
-
}
|
|
23
|
-
/* NOT FOR BROWSER END */
|
|
24
|
-
/** @param closed 是否闭合 */
|
|
25
|
-
constructor(wikitext, closed = true, config = Parser.getConfig(), accum = []) {
|
|
26
|
-
super(wikitext, config, accum);
|
|
27
|
-
this.closed = closed;
|
|
28
|
-
Object.defineProperty(this, 'closed', { enumerable: false });
|
|
29
|
-
}
|
|
30
|
-
/** @private */
|
|
31
|
-
getAttribute(key) {
|
|
32
|
-
return key === 'padding' ? 4 : super.getAttribute(key);
|
|
33
|
-
}
|
|
34
|
-
/** @override */
|
|
35
|
-
lint(start = this.getAbsoluteIndex()) {
|
|
36
|
-
return this.closed ? [] : [(0, lint_1.generateForSelf)(this, { start }, Parser.msg('unclosed $1', 'HTML comment'))];
|
|
37
|
-
}
|
|
38
|
-
/** @private */
|
|
39
|
-
toString(omit) {
|
|
40
|
-
if (!this.closed && this.nextSibling) {
|
|
41
|
-
Parser.error('自动闭合HTML注释', this);
|
|
42
|
-
this.closed = true;
|
|
43
|
-
}
|
|
44
|
-
return omit && this.matchesTypes(omit) ? '' : `<!--${this.innerText}${this.closed ? '-->' : ''}`;
|
|
45
|
-
}
|
|
46
|
-
/** @override */
|
|
47
|
-
print() {
|
|
48
|
-
return super.print({ pre: '<!--', post: this.closed ? '-->' : '' });
|
|
49
|
-
}
|
|
50
|
-
/* NOT FOR BROWSER */
|
|
51
|
-
/** @override */
|
|
52
|
-
cloneNode() {
|
|
53
|
-
return debug_1.Shadow.run(() => new CommentToken(this.innerText, this.closed, this.getAttribute('config')));
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* @override
|
|
57
|
-
* @throws `RangeError` 不允许包含`-->`
|
|
58
|
-
*/
|
|
59
|
-
setText(text) {
|
|
60
|
-
if (text.includes('-->')) {
|
|
61
|
-
throw new RangeError('不允许包含 "-->"!');
|
|
62
|
-
}
|
|
63
|
-
return super.setText(text);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
exports.CommentToken = CommentToken;
|
|
67
|
-
constants_1.classes['CommentToken'] = __filename;
|
package/dist/src/nowiki/dd.d.ts
DELETED
package/dist/src/nowiki/dd.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DdToken = void 0;
|
|
4
|
-
const constants_1 = require("../../util/constants");
|
|
5
|
-
const listBase_1 = require("./listBase");
|
|
6
|
-
/** `:` */
|
|
7
|
-
// @ts-expect-error not implementing all abstract methods
|
|
8
|
-
class DdToken extends listBase_1.ListBaseToken {
|
|
9
|
-
type = 'dd';
|
|
10
|
-
/* NOT FOR BROWSER */
|
|
11
|
-
/** 缩进数 */
|
|
12
|
-
get indent() {
|
|
13
|
-
return this.innerText.split(':').length - 1;
|
|
14
|
-
}
|
|
15
|
-
set indent(indent) {
|
|
16
|
-
this.setText(':'.repeat(indent));
|
|
17
|
-
}
|
|
18
|
-
/** @private */
|
|
19
|
-
afterBuild() {
|
|
20
|
-
this.setAttribute('pattern', /^:+$/u);
|
|
21
|
-
super.afterBuild();
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
exports.DdToken = DdToken;
|
|
25
|
-
constants_1.classes['DdToken'] = __filename;
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import * as Parser from '../../index';
|
|
2
|
-
import { NowikiBaseToken } from './base';
|
|
3
|
-
import type { Token } from '../index';
|
|
4
|
-
declare const DoubleUnderscoreToken_base: (abstract new (...args: any[]) => {
|
|
5
|
-
"__#10@#pattern": RegExp;
|
|
6
|
-
afterBuild(): void;
|
|
7
|
-
getAttribute<T extends string>(key: T): TokenAttributeGetter<T>;
|
|
8
|
-
setAttribute<T_1 extends string>(key: T_1, value: TokenAttributeSetter<T_1>): void;
|
|
9
|
-
replaceChildren(...elements: (string | Parser.AstNodes)[]): void;
|
|
10
|
-
readonly length: number;
|
|
11
|
-
toString(omit?: Set<string> | undefined, separator?: string | undefined): string;
|
|
12
|
-
text(separator?: string | undefined): string;
|
|
13
|
-
lint(start?: number | undefined): Parser.LintError[];
|
|
14
|
-
insertAt(token: unknown, i?: number | undefined): unknown;
|
|
15
|
-
addEventListener(events: string | string[], listener: AstListener): void;
|
|
16
|
-
}) & ((abstract new (...args: any[]) => {
|
|
17
|
-
text(): string;
|
|
18
|
-
lint(): Parser.LintError[];
|
|
19
|
-
readonly length: number;
|
|
20
|
-
toString(omit?: Set<string> | undefined, separator?: string | undefined): string;
|
|
21
|
-
insertAt(token: unknown, i?: number | undefined): unknown;
|
|
22
|
-
afterBuild(): void;
|
|
23
|
-
getAttribute<T_2 extends string>(key: T_2): TokenAttributeGetter<T_2>;
|
|
24
|
-
setAttribute<T_3 extends string>(key: T_3, value: TokenAttributeSetter<T_3>): void;
|
|
25
|
-
addEventListener(events: string | string[], listener: AstListener): void;
|
|
26
|
-
replaceChildren(...elements: (string | Parser.AstNodes)[]): void;
|
|
27
|
-
}) & {
|
|
28
|
-
readonly hidden: true;
|
|
29
|
-
}) & typeof NowikiBaseToken;
|
|
30
|
-
/** 状态开关 */
|
|
31
|
-
export declare class DoubleUnderscoreToken extends DoubleUnderscoreToken_base {
|
|
32
|
-
#private;
|
|
33
|
-
readonly type = "double-underscore";
|
|
34
|
-
readonly name: string;
|
|
35
|
-
/**
|
|
36
|
-
* @param word 状态开关名
|
|
37
|
-
* @param fixed 是否固定大小写
|
|
38
|
-
*/
|
|
39
|
-
constructor(word: string, fixed: boolean, config?: Parser.Config, accum?: Token[]);
|
|
40
|
-
/** @override */
|
|
41
|
-
print(): string;
|
|
42
|
-
/** @override */
|
|
43
|
-
cloneNode(): this;
|
|
44
|
-
}
|
|
45
|
-
export {};
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DoubleUnderscoreToken = void 0;
|
|
4
|
-
const debug_1 = require("../../util/debug");
|
|
5
|
-
const constants_1 = require("../../util/constants");
|
|
6
|
-
const hidden_1 = require("../../mixin/hidden");
|
|
7
|
-
const syntax_1 = require("../../mixin/syntax");
|
|
8
|
-
const Parser = require("../../index");
|
|
9
|
-
const base_1 = require("./base");
|
|
10
|
-
/** 状态开关 */
|
|
11
|
-
// @ts-expect-error not implementing all abstract methods
|
|
12
|
-
class DoubleUnderscoreToken extends (0, syntax_1.syntax)((0, hidden_1.hidden)(base_1.NowikiBaseToken)) {
|
|
13
|
-
type = 'double-underscore';
|
|
14
|
-
#fixed;
|
|
15
|
-
/* NOT FOR BROWSER END */
|
|
16
|
-
/**
|
|
17
|
-
* @param word 状态开关名
|
|
18
|
-
* @param fixed 是否固定大小写
|
|
19
|
-
*/
|
|
20
|
-
constructor(word, fixed, config = Parser.getConfig(), accum = []) {
|
|
21
|
-
super(word, config, accum);
|
|
22
|
-
this.#fixed = fixed;
|
|
23
|
-
this.setAttribute('name', word.toLowerCase());
|
|
24
|
-
this.setAttribute('pattern', new RegExp(`^${word}$`, fixed ? 'u' : 'iu'));
|
|
25
|
-
}
|
|
26
|
-
/** @private */
|
|
27
|
-
getAttribute(key) {
|
|
28
|
-
return key === 'padding' ? 2 : super.getAttribute(key);
|
|
29
|
-
}
|
|
30
|
-
/** @private */
|
|
31
|
-
toString(omit) {
|
|
32
|
-
return omit && this.matchesTypes(omit) ? '' : `__${this.innerText}__`;
|
|
33
|
-
}
|
|
34
|
-
/** @override */
|
|
35
|
-
print() {
|
|
36
|
-
return super.print({ pre: '__', post: '__' });
|
|
37
|
-
}
|
|
38
|
-
/* NOT FOR BROWSER */
|
|
39
|
-
/** @override */
|
|
40
|
-
cloneNode() {
|
|
41
|
-
const config = this.getAttribute('config');
|
|
42
|
-
return debug_1.Shadow.run(() => {
|
|
43
|
-
const token = new DoubleUnderscoreToken(this.innerText, this.#fixed, config);
|
|
44
|
-
token.afterBuild();
|
|
45
|
-
return token;
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
exports.DoubleUnderscoreToken = DoubleUnderscoreToken;
|
|
50
|
-
constants_1.classes['DoubleUnderscoreToken'] = __filename;
|
package/dist/src/nowiki/hr.d.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { NowikiBaseToken } from './base';
|
|
2
|
-
declare const HrToken_base: (abstract new (...args: any[]) => {
|
|
3
|
-
"__#10@#pattern": RegExp;
|
|
4
|
-
afterBuild(): void;
|
|
5
|
-
getAttribute<T extends string>(key: T): TokenAttributeGetter<T>;
|
|
6
|
-
setAttribute<T_1 extends string>(key: T_1, value: TokenAttributeSetter<T_1>): void;
|
|
7
|
-
replaceChildren(...elements: (string | import("../..").AstNodes)[]): void;
|
|
8
|
-
readonly length: number;
|
|
9
|
-
toString(omit?: Set<string> | undefined, separator?: string | undefined): string;
|
|
10
|
-
text(separator?: string | undefined): string;
|
|
11
|
-
lint(start?: number | undefined): import("../..").LintError[];
|
|
12
|
-
insertAt(token: unknown, i?: number | undefined): unknown;
|
|
13
|
-
addEventListener(events: string | string[], listener: AstListener): void;
|
|
14
|
-
}) & (abstract new (...args: any[]) => {
|
|
15
|
-
prependNewLine(): string;
|
|
16
|
-
toString(omit?: Set<string> | undefined): string;
|
|
17
|
-
getAttribute<S extends string>(key: S): TokenAttributeGetter<S>;
|
|
18
|
-
text(): string;
|
|
19
|
-
readonly length: number;
|
|
20
|
-
lint(start?: number | undefined): import("../..").LintError[];
|
|
21
|
-
insertAt(token: unknown, i?: number | undefined): unknown;
|
|
22
|
-
afterBuild(): void;
|
|
23
|
-
setAttribute<T_2 extends string>(key: T_2, value: TokenAttributeSetter<T_2>): void;
|
|
24
|
-
addEventListener(events: string | string[], listener: AstListener): void;
|
|
25
|
-
replaceChildren(...elements: (string | import("../..").AstNodes)[]): void;
|
|
26
|
-
}) & typeof NowikiBaseToken;
|
|
27
|
-
/** `<hr>` */
|
|
28
|
-
export declare class HrToken extends HrToken_base {
|
|
29
|
-
readonly type = "hr";
|
|
30
|
-
}
|
|
31
|
-
export {};
|
package/dist/src/nowiki/hr.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.HrToken = void 0;
|
|
4
|
-
const constants_1 = require("../../util/constants");
|
|
5
|
-
const sol_1 = require("../../mixin/sol");
|
|
6
|
-
const syntax_1 = require("../../mixin/syntax");
|
|
7
|
-
const base_1 = require("./base");
|
|
8
|
-
/** `<hr>` */
|
|
9
|
-
// @ts-expect-error not implementing all abstract methods
|
|
10
|
-
class HrToken extends (0, syntax_1.syntax)((0, sol_1.sol)(base_1.NowikiBaseToken), /^-{4,}$/u) {
|
|
11
|
-
type = 'hr';
|
|
12
|
-
}
|
|
13
|
-
exports.HrToken = HrToken;
|
|
14
|
-
constants_1.classes['HrToken'] = __filename;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { NowikiBaseToken } from './base';
|
|
2
|
-
import type { LintError } from '../../base';
|
|
3
|
-
import type { AttributesToken, ExtToken } from '../../internal';
|
|
4
|
-
/** 扩展标签内的纯文字Token */
|
|
5
|
-
export declare class NowikiToken extends NowikiBaseToken {
|
|
6
|
-
readonly type = "ext-inner";
|
|
7
|
-
readonly name: string;
|
|
8
|
-
abstract get nextSibling(): undefined;
|
|
9
|
-
abstract get nextElementSibling(): undefined;
|
|
10
|
-
abstract get previousSibling(): AttributesToken;
|
|
11
|
-
abstract get previousElementSibling(): AttributesToken;
|
|
12
|
-
abstract get parentNode(): ExtToken | undefined;
|
|
13
|
-
abstract get parentElement(): ExtToken | undefined;
|
|
14
|
-
/** @override */
|
|
15
|
-
lint(start?: number): LintError[];
|
|
16
|
-
}
|
package/dist/src/nowiki/index.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.NowikiToken = void 0;
|
|
4
|
-
const lint_1 = require("../../util/lint");
|
|
5
|
-
const constants_1 = require("../../util/constants");
|
|
6
|
-
const Parser = require("../../index");
|
|
7
|
-
const base_1 = require("./base");
|
|
8
|
-
/** 扩展标签内的纯文字Token */
|
|
9
|
-
// @ts-expect-error not implementing all abstract methods
|
|
10
|
-
class NowikiToken extends base_1.NowikiBaseToken {
|
|
11
|
-
type = 'ext-inner';
|
|
12
|
-
/** @override */
|
|
13
|
-
lint(start = this.getAbsoluteIndex()) {
|
|
14
|
-
const { name, firstChild: { data } } = this;
|
|
15
|
-
return (name === 'templatestyles' || name === 'section') && data
|
|
16
|
-
? [(0, lint_1.generateForSelf)(this, { start }, Parser.msg('nothing should be in <$1>', name))]
|
|
17
|
-
: super.lint(start);
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
exports.NowikiToken = NowikiToken;
|
|
21
|
-
constants_1.classes['NowikiToken'] = __filename;
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { ListBaseToken } from './listBase';
|
|
2
|
-
import type { AstRange } from '../../lib/range';
|
|
3
|
-
declare const ListToken_base: (abstract new (...args: any[]) => {
|
|
4
|
-
prependNewLine(): string;
|
|
5
|
-
toString(omit?: Set<string> | undefined): string;
|
|
6
|
-
getAttribute<S extends string>(key: S): TokenAttributeGetter<S>;
|
|
7
|
-
text(): string;
|
|
8
|
-
readonly length: number;
|
|
9
|
-
lint(start?: number | undefined): import("../..").LintError[];
|
|
10
|
-
insertAt(token: unknown, i?: number | undefined): unknown;
|
|
11
|
-
afterBuild(): void;
|
|
12
|
-
setAttribute<T extends string>(key: T, value: TokenAttributeSetter<T>): void;
|
|
13
|
-
addEventListener(events: string | string[], listener: AstListener): void;
|
|
14
|
-
replaceChildren(...elements: (string | import("../..").AstNodes)[]): void;
|
|
15
|
-
}) & typeof ListBaseToken;
|
|
16
|
-
/** 位于行首的`;:*#` */
|
|
17
|
-
export declare class ListToken extends ListToken_base {
|
|
18
|
-
readonly type = "list";
|
|
19
|
-
/** 是否包含`:` */
|
|
20
|
-
get dd(): boolean;
|
|
21
|
-
/** 是否包含`;` */
|
|
22
|
-
get dt(): boolean;
|
|
23
|
-
/** 是否包含`*` */
|
|
24
|
-
get ul(): boolean;
|
|
25
|
-
/** 是否包含`#` */
|
|
26
|
-
get ol(): boolean;
|
|
27
|
-
/** 获取列表行的范围 */
|
|
28
|
-
getRange(): AstRange;
|
|
29
|
-
}
|
|
30
|
-
export {};
|
package/dist/src/nowiki/list.js
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ListToken = void 0;
|
|
4
|
-
const constants_1 = require("../../util/constants");
|
|
5
|
-
const sol_1 = require("../../mixin/sol");
|
|
6
|
-
const listBase_1 = require("./listBase");
|
|
7
|
-
/** 位于行首的`;:*#` */
|
|
8
|
-
// @ts-expect-error not implementing all abstract methods
|
|
9
|
-
class ListToken extends (0, sol_1.sol)(listBase_1.ListBaseToken) {
|
|
10
|
-
type = 'list';
|
|
11
|
-
/* NOT FOR BROWSER */
|
|
12
|
-
/** 是否包含`:` */
|
|
13
|
-
get dd() {
|
|
14
|
-
return this.innerText.includes(':');
|
|
15
|
-
}
|
|
16
|
-
/** 是否包含`;` */
|
|
17
|
-
get dt() {
|
|
18
|
-
return this.innerText.includes(';');
|
|
19
|
-
}
|
|
20
|
-
/** 是否包含`*` */
|
|
21
|
-
get ul() {
|
|
22
|
-
return this.innerText.includes('*');
|
|
23
|
-
}
|
|
24
|
-
/** 是否包含`#` */
|
|
25
|
-
get ol() {
|
|
26
|
-
return this.innerText.includes('#');
|
|
27
|
-
}
|
|
28
|
-
/** 获取列表行的范围 */
|
|
29
|
-
getRange() {
|
|
30
|
-
const range = this.createRange();
|
|
31
|
-
range.setStartBefore(this);
|
|
32
|
-
let { nextSibling } = this;
|
|
33
|
-
while (nextSibling && (nextSibling.type !== 'text' || !nextSibling.data.includes('\n'))) {
|
|
34
|
-
({ nextSibling } = nextSibling);
|
|
35
|
-
}
|
|
36
|
-
if (nextSibling) {
|
|
37
|
-
const i = nextSibling.data.indexOf('\n');
|
|
38
|
-
range.setEnd(nextSibling, i);
|
|
39
|
-
}
|
|
40
|
-
else {
|
|
41
|
-
const { parentNode } = this;
|
|
42
|
-
range.setEnd(parentNode, parentNode.length);
|
|
43
|
-
}
|
|
44
|
-
return range;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
exports.ListToken = ListToken;
|
|
48
|
-
constants_1.classes['ListToken'] = __filename;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { NowikiBaseToken } from './base';
|
|
2
|
-
declare const ListBaseToken_base: (abstract new (...args: any[]) => {
|
|
3
|
-
"__#10@#pattern": RegExp;
|
|
4
|
-
afterBuild(): void;
|
|
5
|
-
getAttribute<T extends string>(key: T): TokenAttributeGetter<T>;
|
|
6
|
-
setAttribute<T_1 extends string>(key: T_1, value: TokenAttributeSetter<T_1>): void;
|
|
7
|
-
replaceChildren(...elements: (string | import("../..").AstNodes)[]): void;
|
|
8
|
-
readonly length: number;
|
|
9
|
-
toString(omit?: Set<string> | undefined, separator?: string | undefined): string;
|
|
10
|
-
text(separator?: string | undefined): string;
|
|
11
|
-
lint(start?: number | undefined): import("../..").LintError[];
|
|
12
|
-
insertAt(token: unknown, i?: number | undefined): unknown;
|
|
13
|
-
addEventListener(events: string | string[], listener: AstListener): void;
|
|
14
|
-
}) & typeof NowikiBaseToken;
|
|
15
|
-
/** `;:*#` */
|
|
16
|
-
export declare class ListBaseToken extends ListBaseToken_base {
|
|
17
|
-
type: 'dd' | 'list';
|
|
18
|
-
}
|
|
19
|
-
export {};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ListBaseToken = void 0;
|
|
4
|
-
const constants_1 = require("../../util/constants");
|
|
5
|
-
const syntax_1 = require("../../mixin/syntax");
|
|
6
|
-
const base_1 = require("./base");
|
|
7
|
-
/** `;:*#` */
|
|
8
|
-
// @ts-expect-error not implementing all abstract methods
|
|
9
|
-
class ListBaseToken extends (0, syntax_1.syntax)(base_1.NowikiBaseToken, /^[;:*#]+$/u) {
|
|
10
|
-
}
|
|
11
|
-
exports.ListBaseToken = ListBaseToken;
|
|
12
|
-
constants_1.classes['ListBase'] = __filename;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { NowikiBaseToken } from './base';
|
|
2
|
-
declare const NoincludeToken_base: ((abstract new (...args: any[]) => {
|
|
3
|
-
text(): string;
|
|
4
|
-
lint(): import("../..").LintError[];
|
|
5
|
-
readonly length: number;
|
|
6
|
-
toString(omit?: Set<string> | undefined, separator?: string | undefined): string;
|
|
7
|
-
insertAt(token: unknown, i?: number | undefined): unknown;
|
|
8
|
-
afterBuild(): void;
|
|
9
|
-
getAttribute<T extends string>(key: T): TokenAttributeGetter<T>;
|
|
10
|
-
setAttribute<T_1 extends string>(key: T_1, value: TokenAttributeSetter<T_1>): void;
|
|
11
|
-
addEventListener(events: string | string[], listener: AstListener): void;
|
|
12
|
-
replaceChildren(...elements: (string | import("../..").AstNodes)[]): void;
|
|
13
|
-
}) & {
|
|
14
|
-
readonly hidden: true;
|
|
15
|
-
}) & typeof NowikiBaseToken;
|
|
16
|
-
/** `<noinclude>`和`</noinclude>`,不可进行任何更改 */
|
|
17
|
-
export declare class NoincludeToken extends NoincludeToken_base {
|
|
18
|
-
readonly type = "noinclude";
|
|
19
|
-
/**
|
|
20
|
-
* @override
|
|
21
|
-
* @param str 新文本
|
|
22
|
-
* @throws `Error` 不可更改
|
|
23
|
-
*/
|
|
24
|
-
setText(str: string): string;
|
|
25
|
-
}
|
|
26
|
-
export {};
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.NoincludeToken = void 0;
|
|
4
|
-
const constants_1 = require("../../util/constants");
|
|
5
|
-
const hidden_1 = require("../../mixin/hidden");
|
|
6
|
-
const base_1 = require("./base");
|
|
7
|
-
/** `<noinclude>`和`</noinclude>`,不可进行任何更改 */
|
|
8
|
-
// @ts-expect-error not implementing all abstract methods
|
|
9
|
-
class NoincludeToken extends (0, hidden_1.hidden)(base_1.NowikiBaseToken) {
|
|
10
|
-
type = 'noinclude';
|
|
11
|
-
/* NOT FOR BROWSER */
|
|
12
|
-
/**
|
|
13
|
-
* @override
|
|
14
|
-
* @param str 新文本
|
|
15
|
-
* @throws `Error` 不可更改
|
|
16
|
-
*/
|
|
17
|
-
setText(str) {
|
|
18
|
-
if (/^<\/?(?:(?:no|only)include|includeonly)(?:\s[^>]*)?\/?>$/iu.test(this.innerText)) {
|
|
19
|
-
throw new Error(`${this.constructor.name} 不可更改文字内容!`);
|
|
20
|
-
}
|
|
21
|
-
return super.setText(str);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
exports.NoincludeToken = NoincludeToken;
|
|
25
|
-
constants_1.classes['NoincludeToken'] = __filename;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import * as Parser from '../../index';
|
|
2
|
-
import { NowikiBaseToken } from './base';
|
|
3
|
-
import type { LintError } from '../../base';
|
|
4
|
-
declare const QuoteToken_base: (abstract new (...args: any[]) => {
|
|
5
|
-
"__#10@#pattern": RegExp;
|
|
6
|
-
afterBuild(): void;
|
|
7
|
-
getAttribute<T extends string>(key: T): TokenAttributeGetter<T>;
|
|
8
|
-
setAttribute<T_1 extends string>(key: T_1, value: TokenAttributeSetter<T_1>): void;
|
|
9
|
-
replaceChildren(...elements: (string | Parser.AstNodes)[]): void;
|
|
10
|
-
readonly length: number;
|
|
11
|
-
toString(omit?: Set<string> | undefined, separator?: string | undefined): string;
|
|
12
|
-
text(separator?: string | undefined): string;
|
|
13
|
-
lint(start?: number | undefined): Parser.LintError[];
|
|
14
|
-
insertAt(token: unknown, i?: number | undefined): unknown;
|
|
15
|
-
addEventListener(events: string | string[], listener: AstListener): void;
|
|
16
|
-
}) & typeof NowikiBaseToken;
|
|
17
|
-
/** `''`和`'''` */
|
|
18
|
-
export declare class QuoteToken extends QuoteToken_base {
|
|
19
|
-
readonly type = "quote";
|
|
20
|
-
/** @override */
|
|
21
|
-
lint(start?: number): LintError[];
|
|
22
|
-
}
|
|
23
|
-
export {};
|
package/dist/src/nowiki/quote.js
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.QuoteToken = void 0;
|
|
4
|
-
const lint_1 = require("../../util/lint");
|
|
5
|
-
const constants_1 = require("../../util/constants");
|
|
6
|
-
const syntax_1 = require("../../mixin/syntax");
|
|
7
|
-
const Parser = require("../../index");
|
|
8
|
-
const base_1 = require("./base");
|
|
9
|
-
/** `''`和`'''` */
|
|
10
|
-
// @ts-expect-error not implementing all abstract methods
|
|
11
|
-
class QuoteToken extends (0, syntax_1.syntax)(base_1.NowikiBaseToken, /^(?:'{5}|'''?)$/u) {
|
|
12
|
-
type = 'quote';
|
|
13
|
-
/** @override */
|
|
14
|
-
lint(start = this.getAbsoluteIndex()) {
|
|
15
|
-
const { previousSibling, nextSibling } = this, message = Parser.msg('lonely "$1"', `'`), errors = [];
|
|
16
|
-
let refError;
|
|
17
|
-
if (previousSibling?.type === 'text' && previousSibling.data.endsWith(`'`)) {
|
|
18
|
-
refError = (0, lint_1.generateForSelf)(this, { start }, message);
|
|
19
|
-
const { startIndex: endIndex, startLine: endLine, startCol: endCol } = refError, [{ length }] = /(?<!')'+$/u.exec(previousSibling.data), startIndex = start - length;
|
|
20
|
-
errors.push({
|
|
21
|
-
...refError,
|
|
22
|
-
startIndex,
|
|
23
|
-
endIndex,
|
|
24
|
-
startCol: endCol - length,
|
|
25
|
-
endLine,
|
|
26
|
-
endCol,
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
if (nextSibling?.type === 'text' && nextSibling.data.startsWith(`'`)) {
|
|
30
|
-
refError ??= (0, lint_1.generateForSelf)(this, { start }, message);
|
|
31
|
-
const { endIndex: startIndex, endLine: startLine, endCol: startCol } = refError, [{ length }] = /^'+/u.exec(nextSibling.data), endIndex = startIndex + length;
|
|
32
|
-
errors.push({
|
|
33
|
-
...refError,
|
|
34
|
-
startIndex,
|
|
35
|
-
endIndex,
|
|
36
|
-
startLine,
|
|
37
|
-
startCol,
|
|
38
|
-
endCol: startCol + length,
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
return errors;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
exports.QuoteToken = QuoteToken;
|
|
45
|
-
constants_1.classes['QuoteToken'] = __filename;
|