From e42263529c35d966b752690ad1bcb461b90b470d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Pedersen?= Date: Sun, 11 Aug 2024 20:57:15 +0200 Subject: [PATCH] Add katex option ThrowOnError As an internal option for now. Katex misbehaves in error situations without a value set. --- internal/warpc/katex.go | 4 ++++ tpl/transform/transform.go | 3 +++ 2 files changed, 7 insertions(+) diff --git a/internal/warpc/katex.go b/internal/warpc/katex.go index 2412467a98d..4364dd9ccce 100644 --- a/internal/warpc/katex.go +++ b/internal/warpc/katex.go @@ -37,6 +37,10 @@ type KatexOptions struct { // Specifies a minimum thickness, in ems, for fraction lines. MinRuleThickness float64 `json:"minRuleThickness"` + + // If true, KaTeX will throw a ParseError when it encounters an unsupported command. + // For internal use only, for now. + ThrowOnError bool `json:"throwOnError"` } type KatexOutput struct { diff --git a/tpl/transform/transform.go b/tpl/transform/transform.go index bcec9346bba..293d01a00c2 100644 --- a/tpl/transform/transform.go +++ b/tpl/transform/transform.go @@ -223,6 +223,9 @@ func (ns *Namespace) ToMath(ctx context.Context, args ...any) (template.HTML, er } } + // Make sure this isn't set by the client (for now). + katexInput.Options.ThrowOnError = false + s := hashing.HashString(args...) key := "tomath/" + s[:2] + "/" + s[2:] fileCache := ns.deps.ResourceSpec.FileCaches.MiscCache()