]> git.maquefel.me Git - brevno-suite/hugo/commitdiff
Add katex option ThrowOnError
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Sun, 11 Aug 2024 18:57:15 +0000 (20:57 +0200)
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Sun, 11 Aug 2024 18:57:15 +0000 (20:57 +0200)
As an internal option for now. Katex misbehaves in error situations without a value set.

internal/warpc/katex.go
tpl/transform/transform.go

index 2412467a98dfeb7d2ce8e8cbad847e6e6afa2ef3..4364dd9ccce3e4fc83c410410fff226ae249f462 100644 (file)
@@ -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 {
index bcec9346bba9c7cc62dabd6c9bfebbdf48e5d862..293d01a00c2ea04cb8b37136edec764bfbeb927a 100644 (file)
@@ -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()