UNPKG

3.89 kBTypeScriptView Raw
1export declare class KatexSpecificOptions {
2 /**
3 * If `true`, math will be rendered in display mode
4 * (math in display style and center math on page)
5 *
6 * If `false`, math will be rendered in inline mode
7 * @default false
8 */
9 displayMode?: boolean;
10 /**
11 * If `true`, KaTeX will throw a `ParseError` when
12 * it encounters an unsupported command or invalid LaTex
13 *
14 * If `false`, KaTeX will render unsupported commands as
15 * text, and render invalid LaTeX as its source code with
16 * hover text giving the error, in color given by errorColor
17 * @default true
18 */
19 throwOnError?: boolean;
20 /**
21 * A Color string given in format `#XXX` or `#XXXXXX`
22 */
23 errorColor?: string;
24 /**
25 * A collection of custom macros.
26 *
27 * See `src/macros.js` for its usage
28 */
29 macros?: any;
30 /**
31 * If `true`, `\color` will work like LaTeX's `\textcolor`
32 * and takes 2 arguments
33 *
34 * If `false`, `\color` will work like LaTeX's `\color`
35 * and takes 1 argument
36 *
37 * In both cases, `\textcolor` works as in LaTeX
38 *
39 * @default false
40 */
41 colorIsTextColor?: boolean;
42 /**
43 * All user-specified sizes will be caped to `maxSize` ems
44 *
45 * If set to Infinity, users can make elements and space
46 * arbitrarily large
47 *
48 * @default Infinity
49 */
50 maxSize?: number;
51 /**
52 * Limit the number of macro expansions to specified number
53 *
54 * If set to `Infinity`, marco expander will try to fully expand
55 * as in LaTex
56 *
57 * @default 1000
58 */
59 maxExpand?: number;
60 /**
61 * Allowed protocols in `\href`
62 *
63 * Use `_relative` to allow relative urls
64 *
65 * Use `*` to allow all protocols
66 */
67 allowedProtocols?: string[];
68 /**
69 * If `false` or `"ignore"`, allow features that make
70 * writing in LaTex convenient but not supported by LaTex
71 *
72 * If `true` or `"error"`, throw an error for such transgressions
73 *
74 * If `"warn"`, warn about behavior via `console.warn`
75 *
76 * @default "warn"
77 */
78 strict?: boolean | string | Function;
79}
80export interface RenderMathInElementSpecificOptionsDelimiters {
81 /**
82 * A string which starts the math expression (i.e. the left delimiter)
83 */
84 left: string;
85 /**
86 * A string which ends the math expression (i.e. the right delimiter)
87 */
88 right: string;
89 /**
90 * A boolean of whether the math in the expression should be rendered in display mode or not
91 */
92 display: boolean;
93}
94export interface RenderMathInElementSpecificOptions {
95 /**
96 * A list of delimiters to look for math
97 *
98 * @default [
99 * {left: "$$", right: "$$", display: true},
100 * {left: "\\(", right: "\\)", display: false},
101 * {left: "\\[", right: "\\]", display: true}
102 * ]
103 */
104 delimiters?: ReadonlyArray<RenderMathInElementSpecificOptionsDelimiters> | undefined;
105 /**
106 * A list of DOM node types to ignore when recursing through
107 *
108 * @default ["script", "noscript", "style", "textarea", "pre", "code"]
109 */
110 ignoredTags?: ReadonlyArray<keyof HTMLElementTagNameMap> | undefined;
111 /**
112 * A list of DOM node class names to ignore when recursing through
113 *
114 * @default []
115 */
116 ignoredClasses?: string[] | undefined;
117 /**
118 * A callback method returning a message and an error stack in case of an critical error during rendering
119 * @param msg Message generated by KaTeX
120 * @param err Caught error
121 *
122 * @default console.error
123 */
124 errorCallback?(msg: string, err: Error): void;
125}
126/**
127 * renderMathInElement options contain KaTeX render options and renderMathInElement specific options
128 */
129export type KatexOptions = KatexSpecificOptions & RenderMathInElementSpecificOptions;