UNPKG

3.91 kBTypeScriptView Raw
1import type { MermaidConfig } from '../../config.type.js';
2export declare const lineBreakRegex: RegExp;
3/**
4 * Gets the rows of lines in a string
5 *
6 * @param s - The string to check the lines for
7 * @returns The rows in that string
8 */
9export declare const getRows: (s?: string) => string[];
10/**
11 * Removes script tags from a text
12 *
13 * @param txt - The text to sanitize
14 * @returns The safer text
15 */
16export declare const removeScript: (txt: string) => string;
17export declare const sanitizeText: (text: string, config: MermaidConfig) => string;
18export declare const sanitizeTextOrArray: (a: string | string[] | string[][], config: MermaidConfig) => string | string[];
19/**
20 * Whether or not a text has any line breaks
21 *
22 * @param text - The text to test
23 * @returns Whether or not the text has breaks
24 */
25export declare const hasBreaks: (text: string) => boolean;
26/**
27 * Splits on <br> tags
28 *
29 * @param text - Text to split
30 * @returns List of lines as strings
31 */
32export declare const splitBreaks: (text: string) => string[];
33/**
34 * Converts a string/boolean into a boolean
35 *
36 * @param val - String or boolean to convert
37 * @returns The result from the input
38 */
39export declare const evaluate: (val?: string | boolean) => boolean;
40/**
41 * Wrapper around Math.max which removes non-numeric values
42 * Returns the larger of a set of supplied numeric expressions.
43 * @param values - Numeric expressions to be evaluated
44 * @returns The smaller value
45 */
46export declare const getMax: (...values: number[]) => number;
47/**
48 * Wrapper around Math.min which removes non-numeric values
49 * Returns the smaller of a set of supplied numeric expressions.
50 * @param values - Numeric expressions to be evaluated
51 * @returns The smaller value
52 */
53export declare const getMin: (...values: number[]) => number;
54/**
55 * Makes generics in typescript syntax
56 *
57 * @example
58 * Array of array of strings in typescript syntax
59 *
60 * ```js
61 * // returns "Array<Array<string>>"
62 * parseGenericTypes('Array~Array~string~~');
63 * ```
64 * @param text - The text to convert
65 * @returns The converted string
66 */
67export declare const parseGenericTypes: (input: string) => string;
68export declare const countOccurrence: (string: string, substring: string) => number;
69export declare const isMathMLSupported: () => boolean;
70export declare const katexRegex: RegExp;
71/**
72 * Whether or not a text has KaTeX delimiters
73 *
74 * @param text - The text to test
75 * @returns Whether or not the text has KaTeX delimiters
76 */
77export declare const hasKatex: (text: string) => boolean;
78/**
79 * Computes the minimum dimensions needed to display a div containing MathML
80 *
81 * @param text - The text to test
82 * @param config - Configuration for Mermaid
83 * @returns Object containing \{width, height\}
84 */
85export declare const calculateMathMLDimensions: (text: string, config: MermaidConfig) => Promise<{
86 width: number;
87 height: number;
88}>;
89/**
90 * Attempts to render and return the KaTeX portion of a string with MathML
91 *
92 * @param text - The text to test
93 * @param config - Configuration for Mermaid
94 * @returns String containing MathML if KaTeX is supported, or an error message if it is not and stylesheets aren't present
95 */
96export declare const renderKatex: (text: string, config: MermaidConfig) => Promise<string>;
97declare const _default: {
98 getRows: (s?: string | undefined) => string[];
99 sanitizeText: (text: string, config: MermaidConfig) => string;
100 sanitizeTextOrArray: (a: string | string[] | string[][], config: MermaidConfig) => string | string[];
101 hasBreaks: (text: string) => boolean;
102 splitBreaks: (text: string) => string[];
103 lineBreakRegex: RegExp;
104 removeScript: (txt: string) => string;
105 getUrl: (useAbsolute: boolean) => string;
106 evaluate: (val?: string | boolean | undefined) => boolean;
107 getMax: (...values: number[]) => number;
108 getMin: (...values: number[]) => number;
109};
110export default _default;