mirror of
https://github.com/Smaug123/KaTeX
synced 2025-10-19 09:38:40 +00:00
* unicodeTextInMathMode setting * When `unicodeTextInMathMode` is `true`, accented letters from `unicodeSymbols.js`, and CJK and other supported languages, get added support in math mode (as requested in #895). * When `unicodeTextInMathMode` is `false, all of these stop working in math mode, and are only supported in text mode (matching XeTeX behavior). Note that this is a backwards incompatibility with some 0.9.0 alpha/betas. * Fix handling of Unicode characters ð, Å, å * Fix double handling of ð (math maps to \eth, not special Unicode character) * Remove Åå special math handling, thanks to #1125 * Forbid extraLatin when unicodeTextInMathMode is false
55 lines
1.7 KiB
JavaScript
55 lines
1.7 KiB
JavaScript
// @flow
|
|
/**
|
|
* This is a module for storing settings passed into KaTeX. It correctly handles
|
|
* default settings.
|
|
*/
|
|
|
|
import utils from "./utils";
|
|
|
|
import type { MacroMap } from "./macros";
|
|
|
|
export type SettingsOptions = {
|
|
displayMode?: boolean;
|
|
throwOnError?: boolean;
|
|
errorColor?: string;
|
|
macros?: MacroMap;
|
|
colorIsTextColor?: boolean;
|
|
unicodeTextInMathMode?: boolean;
|
|
maxSize?: number;
|
|
};
|
|
|
|
/**
|
|
* The main Settings object
|
|
*
|
|
* The current options stored are:
|
|
* - displayMode: Whether the expression should be typeset as inline math
|
|
* (false, the default), meaning that the math starts in
|
|
* \textstyle and is placed in an inline-block); or as display
|
|
* math (true), meaning that the math starts in \displaystyle
|
|
* and is placed in a block with vertical margin.
|
|
*/
|
|
class Settings {
|
|
displayMode: boolean;
|
|
throwOnError: boolean;
|
|
errorColor: string;
|
|
macros: MacroMap;
|
|
colorIsTextColor: boolean;
|
|
unicodeTextInMathMode: boolean;
|
|
maxSize: number;
|
|
|
|
constructor(options: SettingsOptions) {
|
|
// allow null options
|
|
options = options || {};
|
|
this.displayMode = utils.deflt(options.displayMode, false);
|
|
this.throwOnError = utils.deflt(options.throwOnError, true);
|
|
this.errorColor = utils.deflt(options.errorColor, "#cc0000");
|
|
this.macros = options.macros || {};
|
|
this.colorIsTextColor = utils.deflt(options.colorIsTextColor, false);
|
|
this.unicodeTextInMathMode =
|
|
utils.deflt(options.unicodeTextInMathMode, false);
|
|
this.maxSize = Math.max(0, utils.deflt(options.maxSize, Infinity));
|
|
}
|
|
}
|
|
|
|
export default Settings;
|