-
-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Closed
Closed
Copy link
Labels
Milestone
Description
Currently, if the KaTex strict mode is warn, we throw an error regardless of error code:
execute of template failed at <transform.ToMath>: error calling ToMath: not a function
Instead, we should capture and display the warnings as described in the KaTeX documentation. There are some related comments in the code:
Lines 455 to 459 in e25db38
| // The console.log in the Javy/quickjs WebAssembly module will write to stderr. | |
| // In non-error situations, write that to the provided infof logger. | |
| if errBuff.Len() > 0 { | |
| opts.Infof("%s", errBuff.String()) | |
| } |
This isn't a pressing issue in that #13736 changed the default strict mode from "warn" to "error", and we have not documented "warn" mode.
Notes:
- The "not a function" message comes from here (i.e.,
e.messageis "not a function"):
hugo/internal/warpc/js/common.js
Line 55 in f471936
header.err = e.message; - This is an educated guess, but I think if the user sets
stricttowarn, we have to pass in a JS function (instead ofwarn) that somehow captures an error (without throwing one) instead of calling console.warn. See https://katex.org/docs/error. If my guess is correct, this is a bit ugly and probably not worth the effort. - I've looked at this for a few hours and have no idea how to approach it.