mirror of
https://github.com/Smaug123/KaTeX
synced 2025-10-05 11:18:39 +00:00
* Implement strict mode (replacing unicodeTextInMathMode) Add new "strict" setting (default value false) that can take a boolean (whether to throw an error or silently ignore), string ("ignore", "warn", or "error"), or a function possibly returning such a value. This enables a variety of ways of handling or ignoring transgressions from "true" LaTeX behavior, making KaTeX easier to use while still providing the ability for strict LaTeX adherance. Resolve #1226, implementing that spec, for two existing transgressions from regular LaTeX: * src/functions/kern.js had some errors and warnings about use of (units in) math vs. text mode commands. * The former setting unicodeTextInMathMode (not in any released version) needed to be set to true to enable Unicode text symbols in math mode. Now these are controlled by the strict setting. By default, KaTeX is now very permissive, but if desired, the user can request warnings or errors. * Rewrite strict description * Add tests for strict functions * Stricter type for strict * Switch default strict setting to "warn" * Fix new flow error * Fix another flow bug
21 lines
404 B
JavaScript
21 lines
404 B
JavaScript
// @flow
|
|
|
|
class Warning {
|
|
name: string;
|
|
message: string;
|
|
stack: string;
|
|
|
|
constructor(message: string) {
|
|
// $FlowFixMe
|
|
this.name = "Warning";
|
|
// $FlowFixMe
|
|
this.message = "Warning: " + message;
|
|
// $FlowFixMe
|
|
this.stack = new Error().stack;
|
|
}
|
|
}
|
|
// $FlowFixMe
|
|
Warning.prototype = Object.create(Error.prototype);
|
|
|
|
module.exports = Warning;
|