UNPKG

4.5 kBTypeScriptView Raw
1export interface TrustContext {
2 command: string;
3 url: string;
4 protocol: string;
5}
6
7/** Documentation: https://katex.org/docs/options.html */
8export interface KatexOptions {
9 /**
10 * If `true`, math will be rendered in display mode
11 * (math in display style and center math on page)
12 *
13 * If `false`, math will be rendered in inline mode
14 * @default false
15 */
16 displayMode?: boolean | undefined;
17 /**
18 * Determines the markup language of the output. The valid choices are:
19 * - `html`: Outputs KaTeX in HTML only.
20 * - `mathml`: Outputs KaTeX in MathML only.
21 * - `htmlAndMathml`: Outputs HTML for visual rendering
22 * and includes MathML for accessibility.
23 *
24 * @default 'htmlAndMathml'
25 */
26 output?: "html" | "mathml" | "htmlAndMathml" | undefined;
27 /**
28 * If `true`, display math has \tags rendered on the left
29 * instead of the right, like \usepackage[leqno]{amsmath} in LaTeX.
30 *
31 * @default false
32 */
33 leqno?: boolean | undefined;
34 /**
35 * If `true`, display math renders flush left with a 2em left margin,
36 * like \documentclass[fleqn] in LaTeX with the amsmath package.
37 *
38 * @default false
39 */
40 fleqn?: boolean | undefined;
41 /**
42 * If `true`, KaTeX will throw a `ParseError` when
43 * it encounters an unsupported command or invalid LaTex
44 *
45 * If `false`, KaTeX will render unsupported commands as
46 * text, and render invalid LaTeX as its source code with
47 * hover text giving the error, in color given by errorColor
48 * @default true
49 */
50 throwOnError?: boolean | undefined;
51 /**
52 * A Color string given in format `#XXX` or `#XXXXXX`
53 */
54 errorColor?: string | undefined;
55 /**
56 * A collection of custom macros.
57 *
58 * See `src/macros.js` for its usage
59 */
60 macros?: any;
61 /**
62 * Specifies a minimum thickness, in ems, for fraction lines,
63 * \sqrt top lines, {array} vertical lines, \hline, \hdashline,
64 * \underline, \overline, and the borders of \fbox, \boxed, and
65 * \fcolorbox.
66 */
67 minRuleThickness?: number | undefined;
68 /**
69 * If `true`, `\color` will work like LaTeX's `\textcolor`
70 * and takes 2 arguments
71 *
72 * If `false`, `\color` will work like LaTeX's `\color`
73 * and takes 1 argument
74 *
75 * In both cases, `\textcolor` works as in LaTeX
76 *
77 * @default false
78 */
79 colorIsTextColor?: boolean | undefined;
80 /**
81 * All user-specified sizes will be caped to `maxSize` ems
82 *
83 * If set to Infinity, users can make elements and space
84 * arbitrarily large
85 *
86 * @default Infinity
87 */
88 maxSize?: number | undefined;
89 /**
90 * Limit the number of macro expansions to specified number
91 *
92 * If set to `Infinity`, marco expander will try to fully expand
93 * as in LaTex
94 *
95 * @default 1000
96 */
97 maxExpand?: number | undefined;
98 /**
99 * If `false` or `"ignore"`, allow features that make
100 * writing in LaTex convenient but not supported by LaTex
101 *
102 * If `true` or `"error"`, throw an error for such transgressions
103 *
104 * If `"warn"`, warn about behavior via `console.warn`
105 *
106 * @default "warn"
107 */
108 strict?: boolean | string | Function | undefined;
109 /**
110 * If `false` (do not trust input), prevent any commands that could enable adverse behavior, rendering them instead in errorColor.
111 *
112 * If `true` (trust input), allow all such commands.
113 *
114 * @default false
115 */
116 trust?: boolean | ((context: TrustContext) => boolean) | undefined;
117 /**
118 * Place KaTeX code in the global group.
119 *
120 * @default false
121 */
122 globalGroup?: boolean | undefined;
123}
124
125/**
126 * KaTeX error, usually during parsing.
127 */
128export class ParseError implements Error {
129 constructor(message: string, lexer: any, position: number);
130
131 name: string;
132 message: string;
133 position: number;
134}
135
136/**
137 * Renders a TeX expression into the specified DOM element
138 * @param tex A TeX expression
139 * @param element The DOM element to render into
140 * @param options KaTeX options
141 */
142export function render(tex: string, element: HTMLElement, options?: KatexOptions): void;
143
144/**
145 * Renders a TeX expression into an HTML string
146 * @param tex A TeX expression
147 * @param options KaTeX options
148 */
149export function renderToString(tex: string, options?: KatexOptions): string;
150
151export as namespace katex;
152
\No newline at end of file