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