@ -1,6 +1,6 @@
function displayError ( el , err ) {
function displayError ( el , err ) {
const target = targetElement ( el ) ;
const target = targetElement ( el ) ;
target . remove ( 'is-loading' ) ;
target . classList . remove ( 'is-loading' ) ;
const errorNode = document . createElement ( 'div' ) ;
const errorNode = document . createElement ( 'div' ) ;
errorNode . setAttribute ( 'class' , 'ui message error markup-block-error mono' ) ;
errorNode . setAttribute ( 'class' , 'ui message error markup-block-error mono' ) ;
errorNode . textContent = err . str || err . message || String ( err ) ;
errorNode . textContent = err . str || err . message || String ( err ) ;
@ -23,12 +23,16 @@ export async function renderMath() {
for ( const el of els ) {
for ( const el of els ) {
const source = el . textContent ;
const source = el . textContent ;
const options = { display : el . classList . contains ( 'display' ) } ;
const displayMode = el . classList . contains ( 'display' ) ;
const nodeName = displayMode ? 'p' : 'span' ;
try {
try {
const markup = katex . renderToString ( source , options ) ;
const tempEl = document . createElement ( nodeName ) ;
const tempEl = document . createElement ( options . display ? 'p' : 'span' ) ;
katex . render ( source , tempEl , {
tempEl . innerHTML = markup ;
maxSize : 25 ,
maxExpand : 50 ,
displayMode ,
} ) ;
targetElement ( el ) . replaceWith ( tempEl ) ;
targetElement ( el ) . replaceWith ( tempEl ) ;
} catch ( error ) {
} catch ( error ) {
displayError ( el , error ) ;
displayError ( el , error ) ;