Skip to content

Commit

Permalink
Add renderError function to KaTeX bundle
Browse files Browse the repository at this point in the history
  • Loading branch information
0xpapercut committed Mar 2, 2024
1 parent baff81d commit a48262f
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/katex/katex.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,23 @@ import ParseError from 'katex/src/ParseError';
import Settings from 'katex/src/Settings';
import parseTree from 'katex/src/parseTree';
import buildTree from 'katex/src/buildTree';
import buildCommon from 'katex/src/buildCommon';
import { SymbolNode } from 'katex/src/domTree';

function renderError(error, expression, settings) {
if (settings.throwOnError) {
throw error;
}
const node = buildCommon.makeSpan(["katex-error"], [new SymbolNode(expression)]);
node.setAttribute("title", error.toString());
node.setAttribute("style", `color:${settings.errorColor}`);
return node;
}

export default {
ParseError,
Settings,
parseTree,
buildTree,
renderError,
};

0 comments on commit a48262f

Please sign in to comment.