Skip to content

Commit

Permalink
Add katex option ThrowOnError
Browse files Browse the repository at this point in the history
As an internal option for now. Katex misbehaves in error situations without a value set.
  • Loading branch information
bep committed Aug 11, 2024
1 parent 891aa00 commit e422635
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
4 changes: 4 additions & 0 deletions internal/warpc/katex.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
3 changes: 3 additions & 0 deletions tpl/transform/transform.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit e422635

Please sign in to comment.