mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-07-01 15:50:13 +00:00
Merge pull request #32154 from knguyen0125/katex
Upgrade KaTeX to v0.10.0
This commit is contained in:
80
types/katex/index.d.ts
vendored
80
types/katex/index.d.ts
vendored
@@ -1,14 +1,90 @@
|
||||
// Type definitions for KaTeX 0.5
|
||||
// Type definitions for KaTeX 0.10
|
||||
// Project: http://khan.github.io/KaTeX/
|
||||
// Definitions by: Michael Randolph <https://github.com/mrand01>
|
||||
// Kevin Nguyen <https://github.com/knguyen0125>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
export as namespace katex;
|
||||
|
||||
/** Documentation: https://katex.org/docs/options.html */
|
||||
export interface KatexOptions {
|
||||
/**
|
||||
* If `true`, math will be rendered in display mode
|
||||
* (math in display style and center math on page)
|
||||
*
|
||||
* If `false`, math will be rendered in inline mode
|
||||
* @default false
|
||||
*/
|
||||
displayMode?: boolean;
|
||||
breakOnUnsupportedCmds?: boolean;
|
||||
/**
|
||||
* If `true`, KaTeX will throw a `ParseError` when
|
||||
* it encounters an unsupported command or invalid LaTex
|
||||
*
|
||||
* If `false`, KaTeX will render unsupported commands as
|
||||
* text, and render invalid LaTeX as its source code with
|
||||
* hover text giving the error, in color given by errorColor
|
||||
* @default true
|
||||
*/
|
||||
throwOnError?: boolean;
|
||||
/**
|
||||
* A Color string given in format `#XXX` or `#XXXXXX`
|
||||
*/
|
||||
errorColor?: string;
|
||||
/**
|
||||
* A collection of custom macros.
|
||||
*
|
||||
* See `src/macros.js` for its usage
|
||||
*/
|
||||
macros?: any;
|
||||
/**
|
||||
* If `true`, `\color` will work like LaTeX's `\textcolor`
|
||||
* and takes 2 arguments
|
||||
*
|
||||
* If `false`, `\color` will work like LaTeX's `\color`
|
||||
* and takes 1 argument
|
||||
*
|
||||
* In both cases, `\textcolor` works as in LaTeX
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
colorIsTextColor?: boolean;
|
||||
/**
|
||||
* All user-specified sizes will be caped to `maxSize` ems
|
||||
*
|
||||
* If set to Infinity, users can make elements and space
|
||||
* arbitrarily large
|
||||
*
|
||||
* @default Infinity
|
||||
*/
|
||||
maxSize?: number;
|
||||
/**
|
||||
* Limit the number of macro expansions to specified number
|
||||
*
|
||||
* If set to `Infinity`, marco expander will try to fully expand
|
||||
* as in LaTex
|
||||
*
|
||||
* @default 1000
|
||||
*/
|
||||
maxExpand?: number;
|
||||
/**
|
||||
* Allowed protocols in `\href`
|
||||
*
|
||||
* Use `_relative` to allow relative urls
|
||||
*
|
||||
* Use `*` to allow all protocols
|
||||
*/
|
||||
allowedProtocols?: string[]
|
||||
/**
|
||||
* If `false` or `"ignore"`, allow features that make
|
||||
* writing in LaTex convenient but not supported by LaTex
|
||||
*
|
||||
* If `true` or `"error"`, throw an error for such transgressions
|
||||
*
|
||||
* If `"warn"`, warn about behavior via `console.warn`
|
||||
*
|
||||
* @default "warn"
|
||||
*/
|
||||
strict?: boolean | string | Function;
|
||||
}
|
||||
|
||||
export class ParseError implements Error {
|
||||
|
||||
@@ -5,7 +5,7 @@ class KatexTest {
|
||||
katexLib.render('My Latex String', document.createElement('div'));
|
||||
|
||||
try {
|
||||
let options: katexLib.KatexOptions = { breakOnUnsupportedCmds: true };
|
||||
let options: katexLib.KatexOptions = { throwOnError: true };
|
||||
let value: string = katexLib.renderToString('My Latex String', options);
|
||||
} catch (error) {
|
||||
if (error instanceof katexLib.ParseError) {
|
||||
|
||||
Reference in New Issue
Block a user