* 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)
| 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 |
no outgoing calls
no test coverage detected