mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-07-01 15:50:13 +00:00
18
katex/katex-tests.ts
Normal file
18
katex/katex-tests.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
/// <reference path="katex.d.ts" />
|
||||
|
||||
import katexLib = require('katex');
|
||||
|
||||
class KatexTest {
|
||||
constructor() {
|
||||
katexLib.render('My Latex String', document.createElement('div'));
|
||||
|
||||
try {
|
||||
let options: katexLib.KatexOptions = { breakOnUnsupportedCmds: true };
|
||||
let value: string = katexLib.renderToString('My Latex String', options);
|
||||
} catch (error) {
|
||||
if (error instanceof katexLib.ParseError) {
|
||||
//do something with this error
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
33
katex/katex.d.ts
vendored
Normal file
33
katex/katex.d.ts
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
// Type definitions for KaTeX v.0.5.0
|
||||
// Project: http://khan.github.io/KaTeX/
|
||||
// Definitions by: Michael Randolph <https://github.com/mrand01>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
declare module "katex" {
|
||||
interface KatexOptions {
|
||||
displayMode?: boolean;
|
||||
breakOnUnsupportedCmds?: boolean;
|
||||
errorColor?: string;
|
||||
}
|
||||
|
||||
class ParseError implements Error {
|
||||
constructor(message: string, lexer: any, position: number);
|
||||
name: string;
|
||||
message: string;
|
||||
position: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders a TeX expression into the specified DOM element
|
||||
* @param tex A TeX expression
|
||||
* @param element The DOM element to render into
|
||||
* @param options KaTeX options
|
||||
*/
|
||||
function render(tex: string, element: HTMLElement, options?:KatexOptions): void;
|
||||
/**
|
||||
* Renders a TeX expression into an HTML string
|
||||
* @param tex A TeX expression
|
||||
* @param options KaTeX options
|
||||
*/
|
||||
function renderToString(tex: string, options?:KatexOptions): string;
|
||||
}
|
||||
Reference in New Issue
Block a user