UNPKG

@threema/threema-markup

Version:

A markup parser and formatter for the markup language used in Threema.

52 lines (51 loc) 1.47 kB
/** * This file is part of threema-markup. * * Copyright (c) 2018–2025 Threema GmbH. * * Licensed under either of * * - Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0) * - MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT) * * at your option. */ export declare enum TokenType { Text = 0, Newline = 1, Asterisk = 2, Underscore = 3, Tilde = 4 } export interface Token { kind: TokenType; value?: string; } /** * @deprecated use {@link TokenType.Asterisk} intead */ export declare const TOKEN_TYPE_ASTERISK = TokenType.Asterisk; /** * @deprecated use {@link TokenType.Underscore} intead */ export declare const TOKEN_TYPE_UNDERSCORE = TokenType.Underscore; /** * @deprecated use {@link TokenType.Tilde} intead */ export declare const TOKEN_TYPE_TILDE = TokenType.Tilde; /** * This function accepts a string and returns a list of tokens. */ export declare function tokenize(text: string): Token[]; /** * Convert a list of tokens to HTML. * * Optionally, a mapping from token types to CSS class strings can be specified. */ export declare function parse(tokens: Token[], classes?: Record<number, string>): string; /** * Convert text with markup to HTML. * * Optionally, a mapping from token types to CSS class strings can be specified. */ export declare function markify(text: string, classes?: Record<number, string>): string;