Disable throwOnError in KaTeX to reveal user where is the problem

From KaTeX documentation:

> throwOnError: boolean.  If true, KaTeX will throw a ParseError when
> it encounters an unsupported command.  If false, KaTeX will render
> the unsupported command as text in the color given by errorColor.
> (default: true)

It's better to render the formula and highlight unsupported commands than
just give up and render whole formula as a code; users are confused and
don't know what's wrong.
This commit is contained in:
Jakub Jirutka 2018-01-24 19:02:40 +01:00
parent a403011e4f
commit 2efadce5e7
2 changed files with 6 additions and 1 deletions

View File

@ -18,7 +18,7 @@ function renderWithKaTeX(elements) {
const display = $this.attr('data-math-style') === 'display';
try {
katex.render($this.text(), mathNode.get(0), { displayMode: display });
katex.render($this.text(), mathNode.get(0), { displayMode: display, throwOnError: false });
mathNode.insertAfter($this);
$this.remove();
} catch (err) {

View File

@ -0,0 +1,5 @@
---
title: Disable throwOnError in KaTeX to reveal user where is the problem
merge_request: 16684
author: Jakub Jirutka
type: other