tm-text
Version:
Trackmania and Maniaplanet text parser and formatter
81 lines (80 loc) • 4.12 kB
TypeScript
export declare const TOKEN: {
readonly BLOCK_END: "BLOCK_END";
readonly BLOCK_START: "BLOCK_START";
readonly BOLD: "BOLD";
readonly COLOR: "COLOR";
readonly HREF_CONTENT: "HREF_CONTENT";
readonly HREF_START: "HREF_START";
readonly HREF_END: "HREF_END";
readonly ITALIC: "ITALIC";
readonly LINK_EXTERNAL: "LINK_EXTERNAL";
readonly LINK_INTERNAL: "LINK_INTERNAL";
readonly LINK_INTERNAL_WITH_PARAMS: "LINK_INTERNAL_WITH_PARAMS";
readonly NEWLINE: "NEWLINE";
readonly RESET_ALL: "RESET_ALL";
readonly RESET_COLOR: "RESET_COLOR";
readonly SHADOW: "SHADOW";
readonly TAB: "TAB";
readonly UPPERCASE: "UPPERCASE";
readonly WIDTH_NARROW: "WIDTH_NARROW";
readonly WIDTH_NORMAL: "WIDTH_NORMAL";
readonly WIDTH_WIDE: "WIDTH_WIDE";
readonly WORD: "WORD";
};
export type TokenKind = typeof TOKEN[keyof typeof TOKEN];
export type BlockTokenKind = typeof TOKEN.BLOCK_END | typeof TOKEN.BLOCK_START;
export type CssTokenKind = typeof TOKEN.BOLD | typeof TOKEN.COLOR | typeof TOKEN.ITALIC | typeof TOKEN.SHADOW | typeof TOKEN.UPPERCASE | typeof TOKEN.WIDTH_NARROW | typeof TOKEN.WIDTH_NORMAL | typeof TOKEN.WIDTH_WIDE;
export type HrefTokenKind = typeof TOKEN.HREF_CONTENT | typeof TOKEN.HREF_END | typeof TOKEN.HREF_START;
export type LinkTokenKind = typeof TOKEN.LINK_EXTERNAL | typeof TOKEN.LINK_INTERNAL | typeof TOKEN.LINK_INTERNAL_WITH_PARAMS;
export type ResetTokenKind = typeof TOKEN.RESET_ALL | typeof TOKEN.RESET_COLOR;
export type WidthTokenKind = typeof TOKEN.WIDTH_NARROW | typeof TOKEN.WIDTH_NORMAL | typeof TOKEN.WIDTH_WIDE;
export type PrefixedTokenKind = Exclude<TokenKind, HrefTokenKind | typeof TOKEN.NEWLINE | typeof TOKEN.TAB | typeof TOKEN.WORD>;
export type SingleCharTokenKind = Exclude<TokenKind, typeof TOKEN.COLOR | typeof TOKEN.HREF_CONTENT | typeof TOKEN.NEWLINE | typeof TOKEN.TAB | typeof TOKEN.WORD>;
export interface Token {
/**
* The kind of the token
*/
kind: TokenKind;
/**
* The content of the token
*/
content: string;
/**
* The position of the token
*/
pos: {
/**
* The start position of the token
*/
start: number;
/**
* The end position of the token
*/
end: number;
};
}
export declare const TOKEN_TO_CHAR_MAP: Readonly<Record<SingleCharTokenKind, string>>;
export type Syntax = typeof SYNTAX[keyof typeof SYNTAX];
export declare const SYNTAX: {
/**
* Games that use this syntax: `Original`, `Sunrise`, `Nations`
*/
readonly CLASSIC: "CLASSIC";
/**
* Games that use this syntax: `United`
*/
readonly UNITED: "UNITED";
/**
* Games that use this syntax: `United Forever`, `Nations Forever`
*/
readonly FOREVER: "FOREVER";
/**
* Games that use this syntax: `Maniapanet`, `Turbo`, `2020`
*/
readonly MANIAPLANET: "MANIAPLANET";
};
export declare const SYNTAX_CLASSIC: readonly ["COLOR", "ITALIC", "RESET_ALL", "RESET_COLOR", "NEWLINE", "SHADOW", "TAB", "UPPERCASE", "WIDTH_NARROW", "WIDTH_NORMAL", "WIDTH_WIDE", "WORD"];
export declare const SYNTAX_UNITED: readonly ["COLOR", "ITALIC", "RESET_ALL", "RESET_COLOR", "NEWLINE", "SHADOW", "TAB", "UPPERCASE", "WIDTH_NARROW", "WIDTH_NORMAL", "WIDTH_WIDE", "WORD", "BOLD", "HREF_CONTENT", "HREF_START", "HREF_END", "LINK_EXTERNAL", "LINK_INTERNAL"];
export declare const SYNTAX_FOREVER: readonly ["COLOR", "ITALIC", "RESET_ALL", "RESET_COLOR", "NEWLINE", "SHADOW", "TAB", "UPPERCASE", "WIDTH_NARROW", "WIDTH_NORMAL", "WIDTH_WIDE", "WORD", "BOLD", "HREF_CONTENT", "HREF_START", "HREF_END", "LINK_EXTERNAL", "LINK_INTERNAL", "LINK_INTERNAL_WITH_PARAMS"];
export declare const SYNTAX_MANIAPLANET: readonly ["COLOR", "ITALIC", "RESET_ALL", "RESET_COLOR", "NEWLINE", "SHADOW", "TAB", "UPPERCASE", "WIDTH_NARROW", "WIDTH_NORMAL", "WIDTH_WIDE", "WORD", "BOLD", "HREF_CONTENT", "HREF_START", "HREF_END", "LINK_EXTERNAL", "LINK_INTERNAL", "LINK_INTERNAL_WITH_PARAMS", "BLOCK_END", "BLOCK_START"];
export declare const SYNTAX_MAP: Readonly<Record<Syntax, readonly TokenKind[]>>;