tpl/transform: Expose the KaTeX strict option

Closes #13729
This commit is contained in:
Joe Mooring
2025-05-23 08:22:25 -07:00
committed by Bjørn Erik Pedersen
parent e25db38467
commit 013c8cfb25
4 changed files with 68 additions and 2 deletions

View File

@@ -19,6 +19,7 @@ import (
"context"
"encoding/xml"
"errors"
"fmt"
"html"
"html/template"
"io"
@@ -234,6 +235,7 @@ func (ns *Namespace) ToMath(ctx context.Context, args ...any) (template.HTML, er
MinRuleThickness: 0.04,
ErrorColor: "#cc0000",
ThrowOnError: true,
Strict: "error",
},
}
@@ -243,6 +245,13 @@ func (ns *Namespace) ToMath(ctx context.Context, args ...any) (template.HTML, er
}
}
switch katexInput.Options.Strict {
case "error", "ignore", "warn":
// Valid strict mode, continue
default:
return "", fmt.Errorf("invalid strict mode; expected one of error, ignore, or warn; received %s", katexInput.Options.Strict)
}
s := hashing.HashString(args...)
key := "tomath/" + s[:2] + "/" + s[2:]
fileCache := ns.deps.ResourceSpec.FileCaches.MiscCache()