Skip to content
Snippets Groups Projects
Commit 637e9c13 authored by Martin Bekeč's avatar Martin Bekeč
Browse files

Add error extraction

Pass an array to which KaTeX errors should be pushed. Can be used to implement a custom way to display errors.
parent 64b95f08
No related branches found
No related tags found
No related merge requests found
......@@ -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>`;
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment