File tree Expand file tree Collapse file tree 2 files changed +51
-0
lines changed Expand file tree Collapse file tree 2 files changed +51
-0
lines changed Original file line number Diff line number Diff line change
1
+ /// <reference path="katex.d.ts" />
2
+
3
+ import katexLib = require( 'katex' ) ;
4
+
5
+ class KatexTest {
6
+ constructor ( ) {
7
+ katexLib . render ( 'My Latex String' , document . createElement ( 'div' ) ) ;
8
+
9
+ try {
10
+ let options : katexLib . KatexOptions = { breakOnUnsupportedCmds : true } ;
11
+ let value : string = katexLib . renderToString ( 'My Latex String' , options ) ;
12
+ } catch ( error ) {
13
+ if ( error instanceof katexLib . ParseError ) {
14
+ //do something with this error
15
+ }
16
+ }
17
+ }
18
+ }
Original file line number Diff line number Diff line change
1
+ // Type definitions for KaTeX v.0.5.0
2
+ // Project: http://khan.github.io/KaTeX/
3
+ // Definitions by: Michael Randolph <https://github.com/mrand01>
4
+ // Definitions: https://github.com/borisyankov/DefinitelyTyped
5
+
6
+ declare module "katex" {
7
+ interface KatexOptions {
8
+ displayMode ?: boolean ;
9
+ breakOnUnsupportedCmds ?: boolean ;
10
+ errorColor ?: string ;
11
+ }
12
+
13
+ class ParseError implements Error {
14
+ constructor ( message : string , lexer : any , position : number ) ;
15
+ name : string ;
16
+ message : string ;
17
+ position : number ;
18
+ }
19
+
20
+ /**
21
+ * Renders a TeX expression into the specified DOM element
22
+ * @param tex A TeX expression
23
+ * @param element The DOM element to render into
24
+ * @param options KaTeX options
25
+ */
26
+ function render ( tex : string , element : HTMLElement , options ?:KatexOptions ) : void ;
27
+ /**
28
+ * Renders a TeX expression into an HTML string
29
+ * @param tex A TeX expression
30
+ * @param options KaTeX options
31
+ */
32
+ function renderToString ( tex : string , options ?:KatexOptions ) : string ;
33
+ }
You can’t perform that action at this time.
0 commit comments