diff --git a/index.js b/index.js index 3bf81ab6995d36dbb846d419fe3468fdc738c183..cb170273d60710b133a0ccfa9b94c5ecc8d71ecb 100644 --- a/index.js +++ b/index.js @@ -173,7 +173,8 @@ module.exports = function math_plugin(md, options) { return katex.renderToString(latex, options); } catch(error){ - if(options.throwOnError){ console.log(error); } + if(options.throwOnError && options.logErrors){ console.log(error); } + if(options.errors) options.errors.push(error); return `<span class='katex-error' title='${escapeHtml(error.toString())}'>${escapeHtml(latex)}</span>`; } }; @@ -188,7 +189,8 @@ module.exports = function math_plugin(md, options) { return "<p class='katex-block'>" + katex.renderToString(latex, options) + "</p>"; } catch(error){ - if(options.throwOnError){ console.log(error); } + if(options.throwOnError && options.logErrors){ console.log(error); } + if(options.errors) options.errors.push(error); return `<p class='katex-block katex-error' title='${escapeHtml(error.toString())}'>${escapeHtml(latex)}</p>`; } }