MCPcopy Create free account
hub / github.com/TruthHun/BookStack / useStrictBehavior

Method useStrictBehavior

static/katex/katex.mjs:323–350  ·  view source on GitHub ↗

* Check whether to apply strict (LaTeX-adhering) behavior for unusual * input (like `\\`). Unlike `nonstrict`, will not throw an error; * instead, "error" translates to a return value of `true`, while "ignore" * translates to a return value of `false`. May still print a warning: * "war

(errorCode, errorMsg, token)

Source from the content-addressed store, hash-verified

321
322
323 useStrictBehavior(errorCode, errorMsg, token) {
324 let strict = this.strict;
325
326 if (typeof strict === "function") {
327 // Allow return value of strict function to be boolean or string
328 // (or null/undefined, meaning no further processing).
329 // But catch any exceptions thrown by function, treating them
330 // like "error".
331 try {
332 strict = strict(errorCode, errorMsg, token);
333 } catch (error) {
334 strict = "error";
335 }
336 }
337
338 if (!strict || strict === "ignore") {
339 return false;
340 } else if (strict === true || strict === "error") {
341 return true;
342 } else if (strict === "warn") {
343 typeof console !== "undefined" && console.warn("LaTeX-incompatible input and strict mode is set to 'warn': " + `${errorMsg} [${errorCode}]`);
344 return false;
345 } else {
346 // won't happen in type-safe code
347 typeof console !== "undefined" && console.warn("LaTeX-incompatible input and strict mode is set to " + `unrecognized '${strict}': ${errorMsg} [${errorCode}]`);
348 return false;
349 }
350 }
351
352}
353

Callers 3

katex.jsFile · 0.80
handlerFunction · 0.80
katex.min.jsFile · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected