let mathjax = undefined ; require ( "mathjax" ) . init ( { loader : { load : [ 'adaptors/liteDOM' , 'input/tex-full' , 'output/svg' ] } } ) . then ( ( mathjaxInternal ) => { mathjax = mathjaxInternal ; } ) . catch ( ( err ) => { console . log ( err . message ) ; } ) ; export const tex2mml = ( tex , options ? ) => { try { return mathjax . tex2mml ( tex , options ) ; } catch ( e ) { return "Failed to parse TeX" ; } } ; export const tex2svg = ( tex , options ? ) => { try { if ( ! mathjax ) { throw Error ( "MathJax is not available yet" ) ; } try { return mathjax . startup . adaptor . outerHTML ( mathjax . tex2svg ( tex , options ) ) ; } catch ( e ) { throw Error ( "Failed to parse TeX string" ) ; } } catch ( e ) { const html = tex . replace ( /&/g , "&amp;" ) . replace ( /</g , "&lt;" ) . replace ( />/g , "&gt;" ) . replace ( /"/g , "&quot;" ) . replace ( /'/g , "&#039;" ) ; return `<pre title="${ ( e as Error ) . message }">${ html }</pre>` ; } } ;