diff --git a/packages/rehype-katex/lib/index.js b/packages/rehype-katex/lib/index.js index 91c8054..1f858c8 100644 --- a/packages/rehype-katex/lib/index.js +++ b/packages/rehype-katex/lib/index.js @@ -101,18 +101,19 @@ export default function rehypeKatex(options) { source: 'rehype-katex' }) - // KaTeX can handle `ParseError` itself, but not others. - if (ruleId === 'parseerror') { + // KaTeX *should* handle `ParseError` itself, but not others. + // it doesn’t always: + // + try { result = katex.renderToString(value, { ...settings, displayMode, strict: 'ignore', throwOnError: false }) - } - // Generate similar markup if this is an other error. - // See: . - else { + } catch { + // Generate similar markup if this is an other error. + // See: . result = [ { type: 'element',