From aba6f8fdbda1ce7c16ad3ce1b97399bd3f38544a Mon Sep 17 00:00:00 2001 From: dataCobra Date: Sat, 12 Feb 2022 19:08:38 +0100 Subject: Update KaTeX to version 0.15.2 With this update KaTeX will now use .woff2 instead of .woff webfonts. Now the IE(Internet Explorer) is no longer compatible. --- layouts/partials/head.html | 4 +- static/css/katex.css | 70 +- static/js/auto-render.js | 10 +- static/js/katex.js | 3990 +++++++++++++---------- static/webfonts/KaTeX_AMS-Regular.woff | Bin 36920 -> 0 bytes static/webfonts/KaTeX_AMS-Regular.woff2 | Bin 0 -> 28076 bytes static/webfonts/KaTeX_Caligraphic-Bold.woff | Bin 9384 -> 0 bytes static/webfonts/KaTeX_Caligraphic-Bold.woff2 | Bin 0 -> 6912 bytes static/webfonts/KaTeX_Caligraphic-Regular.woff | Bin 9160 -> 0 bytes static/webfonts/KaTeX_Caligraphic-Regular.woff2 | Bin 0 -> 6908 bytes static/webfonts/KaTeX_Fraktur-Bold.woff | Bin 16216 -> 0 bytes static/webfonts/KaTeX_Fraktur-Bold.woff2 | Bin 0 -> 11348 bytes static/webfonts/KaTeX_Fraktur-Regular.woff | Bin 15884 -> 0 bytes static/webfonts/KaTeX_Fraktur-Regular.woff2 | Bin 0 -> 11316 bytes static/webfonts/KaTeX_Main-Bold.woff | Bin 35060 -> 0 bytes static/webfonts/KaTeX_Main-Bold.woff2 | Bin 0 -> 25324 bytes static/webfonts/KaTeX_Main-BoldItalic.woff | Bin 24504 -> 0 bytes static/webfonts/KaTeX_Main-BoldItalic.woff2 | Bin 0 -> 16780 bytes static/webfonts/KaTeX_Main-Italic.woff | Bin 25360 -> 0 bytes static/webfonts/KaTeX_Main-Italic.woff2 | Bin 0 -> 16988 bytes static/webfonts/KaTeX_Main-Regular.woff | Bin 37864 -> 0 bytes static/webfonts/KaTeX_Main-Regular.woff2 | Bin 0 -> 26272 bytes static/webfonts/KaTeX_Math-BoldItalic.woff | Bin 23988 -> 0 bytes static/webfonts/KaTeX_Math-BoldItalic.woff2 | Bin 0 -> 16400 bytes static/webfonts/KaTeX_Math-Italic.woff | Bin 24672 -> 0 bytes static/webfonts/KaTeX_Math-Italic.woff2 | Bin 0 -> 16440 bytes static/webfonts/KaTeX_SansSerif-Bold.woff | Bin 17988 -> 0 bytes static/webfonts/KaTeX_SansSerif-Bold.woff2 | Bin 0 -> 12216 bytes static/webfonts/KaTeX_SansSerif-Italic.woff | Bin 17052 -> 0 bytes static/webfonts/KaTeX_SansSerif-Italic.woff2 | Bin 0 -> 12028 bytes static/webfonts/KaTeX_SansSerif-Regular.woff | Bin 15724 -> 0 bytes static/webfonts/KaTeX_SansSerif-Regular.woff2 | Bin 0 -> 10344 bytes static/webfonts/KaTeX_Script-Regular.woff | Bin 13000 -> 0 bytes static/webfonts/KaTeX_Script-Regular.woff2 | Bin 0 -> 9644 bytes static/webfonts/KaTeX_Size1-Regular.woff | Bin 6304 -> 0 bytes static/webfonts/KaTeX_Size1-Regular.woff2 | Bin 0 -> 5468 bytes static/webfonts/KaTeX_Size2-Regular.woff | Bin 6016 -> 0 bytes static/webfonts/KaTeX_Size2-Regular.woff2 | Bin 0 -> 5208 bytes static/webfonts/KaTeX_Size3-Regular.woff | Bin 4156 -> 0 bytes static/webfonts/KaTeX_Size3-Regular.woff2 | Bin 0 -> 3624 bytes static/webfonts/KaTeX_Size4-Regular.woff | Bin 5828 -> 0 bytes static/webfonts/KaTeX_Size4-Regular.woff2 | Bin 0 -> 4928 bytes static/webfonts/KaTeX_Typewriter-Regular.woff | Bin 19708 -> 0 bytes static/webfonts/KaTeX_Typewriter-Regular.woff2 | Bin 0 -> 13568 bytes 44 files changed, 2234 insertions(+), 1840 deletions(-) delete mode 100644 static/webfonts/KaTeX_AMS-Regular.woff create mode 100644 static/webfonts/KaTeX_AMS-Regular.woff2 delete mode 100644 static/webfonts/KaTeX_Caligraphic-Bold.woff create mode 100644 static/webfonts/KaTeX_Caligraphic-Bold.woff2 delete mode 100644 static/webfonts/KaTeX_Caligraphic-Regular.woff create mode 100644 static/webfonts/KaTeX_Caligraphic-Regular.woff2 delete mode 100644 static/webfonts/KaTeX_Fraktur-Bold.woff create mode 100644 static/webfonts/KaTeX_Fraktur-Bold.woff2 delete mode 100644 static/webfonts/KaTeX_Fraktur-Regular.woff create mode 100644 static/webfonts/KaTeX_Fraktur-Regular.woff2 delete mode 100644 static/webfonts/KaTeX_Main-Bold.woff create mode 100644 static/webfonts/KaTeX_Main-Bold.woff2 delete mode 100644 static/webfonts/KaTeX_Main-BoldItalic.woff create mode 100644 static/webfonts/KaTeX_Main-BoldItalic.woff2 delete mode 100644 static/webfonts/KaTeX_Main-Italic.woff create mode 100644 static/webfonts/KaTeX_Main-Italic.woff2 delete mode 100644 static/webfonts/KaTeX_Main-Regular.woff create mode 100644 static/webfonts/KaTeX_Main-Regular.woff2 delete mode 100644 static/webfonts/KaTeX_Math-BoldItalic.woff create mode 100644 static/webfonts/KaTeX_Math-BoldItalic.woff2 delete mode 100644 static/webfonts/KaTeX_Math-Italic.woff create mode 100644 static/webfonts/KaTeX_Math-Italic.woff2 delete mode 100644 static/webfonts/KaTeX_SansSerif-Bold.woff create mode 100644 static/webfonts/KaTeX_SansSerif-Bold.woff2 delete mode 100644 static/webfonts/KaTeX_SansSerif-Italic.woff create mode 100644 static/webfonts/KaTeX_SansSerif-Italic.woff2 delete mode 100644 static/webfonts/KaTeX_SansSerif-Regular.woff create mode 100644 static/webfonts/KaTeX_SansSerif-Regular.woff2 delete mode 100644 static/webfonts/KaTeX_Script-Regular.woff create mode 100644 static/webfonts/KaTeX_Script-Regular.woff2 delete mode 100644 static/webfonts/KaTeX_Size1-Regular.woff create mode 100644 static/webfonts/KaTeX_Size1-Regular.woff2 delete mode 100644 static/webfonts/KaTeX_Size2-Regular.woff create mode 100644 static/webfonts/KaTeX_Size2-Regular.woff2 delete mode 100644 static/webfonts/KaTeX_Size3-Regular.woff create mode 100644 static/webfonts/KaTeX_Size3-Regular.woff2 delete mode 100644 static/webfonts/KaTeX_Size4-Regular.woff create mode 100644 static/webfonts/KaTeX_Size4-Regular.woff2 delete mode 100644 static/webfonts/KaTeX_Typewriter-Regular.woff create mode 100644 static/webfonts/KaTeX_Typewriter-Regular.woff2 diff --git a/layouts/partials/head.html b/layouts/partials/head.html index 0694f66..c775704 100644 --- a/layouts/partials/head.html +++ b/layouts/partials/head.html @@ -26,8 +26,8 @@ {{- if or .Params.math .Site.Params.math -}} - - + + diff --git a/static/css/katex.css b/static/css/katex.css index f5d22a5..ab74143 100644 --- a/static/css/katex.css +++ b/static/css/katex.css @@ -1,121 +1,121 @@ /* stylelint-disable font-family-no-missing-generic-family-keyword */ @font-face { font-family: 'KaTeX_AMS'; - src: url(../webfonts/KaTeX_AMS-Regular.woff) format('woff'); + src: url(../webfonts/KaTeX_AMS-Regular.woff2) format('woff2'); font-weight: normal; font-style: normal; } @font-face { font-family: 'KaTeX_Caligraphic'; - src: url(../webfonts/KaTeX_Caligraphic-Bold.woff) format('woff'); + src: url(../webfonts/KaTeX_Caligraphic-Bold.woff2) format('woff2'); font-weight: bold; font-style: normal; } @font-face { font-family: 'KaTeX_Caligraphic'; - src: url(../webfonts/KaTeX_Caligraphic-Regular.woff) format('woff'); + src: url(../webfonts/KaTeX_Caligraphic-Regular.woff2) format('woff2'); font-weight: normal; font-style: normal; } @font-face { font-family: 'KaTeX_Fraktur'; - src: url(../webfonts/KaTeX_Fraktur-Bold.woff) format('woff'); + src: url(../webfonts/KaTeX_Fraktur-Bold.woff2) format('woff2'); font-weight: bold; font-style: normal; } @font-face { font-family: 'KaTeX_Fraktur'; - src: url(../webfonts/KaTeX_Fraktur-Regular.woff) format('woff'); + src: url(../webfonts/KaTeX_Fraktur-Regular.woff2) format('woff2'); font-weight: normal; font-style: normal; } @font-face { font-family: 'KaTeX_Main'; - src: url(../webfonts/KaTeX_Main-Bold.woff) format('woff'); + src: url(../webfonts/KaTeX_Main-Bold.woff2) format('woff2'); font-weight: bold; font-style: normal; } @font-face { font-family: 'KaTeX_Main'; - src: url(../webfonts/KaTeX_Main-BoldItalic.woff) format('woff'); + src: url(../webfonts/KaTeX_Main-BoldItalic.woff2) format('woff2'); font-weight: bold; font-style: italic; } @font-face { font-family: 'KaTeX_Main'; - src: url(../webfonts/KaTeX_Main-Italic.woff) format('woff'); + src: url(../webfonts/KaTeX_Main-Italic.woff2) format('woff2'); font-weight: normal; font-style: italic; } @font-face { font-family: 'KaTeX_Main'; - src: url(../webfonts/KaTeX_Main-Regular.woff) format('woff'); + src: url(../webfonts/KaTeX_Main-Regular.woff2) format('woff2'); font-weight: normal; font-style: normal; } @font-face { font-family: 'KaTeX_Math'; - src: url(../webfonts/KaTeX_Math-BoldItalic.woff) format('woff'); + src: url(../webfonts/KaTeX_Math-BoldItalic.woff2) format('woff2'); font-weight: bold; font-style: italic; } @font-face { font-family: 'KaTeX_Math'; - src: url(../webfonts/KaTeX_Math-Italic.woff) format('woff'); + src: url(../webfonts/KaTeX_Math-Italic.woff2) format('woff2'); font-weight: normal; font-style: italic; } @font-face { font-family: 'KaTeX_SansSerif'; - src: url(../webfonts/KaTeX_SansSerif-Bold.woff) format('woff'); + src: url(../webfonts/KaTeX_SansSerif-Bold.woff2) format('woff2'); font-weight: bold; font-style: normal; } @font-face { font-family: 'KaTeX_SansSerif'; - src: url(../webfonts/KaTeX_SansSerif-Italic.woff) format('woff'); + src: url(../webfonts/KaTeX_SansSerif-Italic.woff2) format('woff2'); font-weight: normal; font-style: italic; } @font-face { font-family: 'KaTeX_SansSerif'; - src: url(../webfonts/KaTeX_SansSerif-Regular.woff) format('woff'); + src: url(../webfonts/KaTeX_SansSerif-Regular.woff2) format('woff2'); font-weight: normal; font-style: normal; } @font-face { font-family: 'KaTeX_Script'; - src: url(../webfonts/KaTeX_Script-Regular.woff) format('woff'); + src: url(../webfonts/KaTeX_Script-Regular.woff2) format('woff2'); font-weight: normal; font-style: normal; } @font-face { font-family: 'KaTeX_Size1'; - src: url(../webfonts/KaTeX_Size1-Regular.woff) format('woff'); + src: url(../webfonts/KaTeX_Size1-Regular.woff2) format('woff2'); font-weight: normal; font-style: normal; } @font-face { font-family: 'KaTeX_Size2'; - src: url(../webfonts/KaTeX_Size2-Regular.woff) format('woff'); + src: url(../webfonts/KaTeX_Size2-Regular.woff2) format('woff2'); font-weight: normal; font-style: normal; } @font-face { font-family: 'KaTeX_Size3'; - src: url(../webfonts/KaTeX_Size3-Regular.woff) format('woff'); + src: url(../webfonts/KaTeX_Size3-Regular.woff2) format('woff2'); font-weight: normal; font-style: normal; } @font-face { font-family: 'KaTeX_Size4'; - src: url(../webfonts/KaTeX_Size4-Regular.woff) format('woff'); + src: url(../webfonts/KaTeX_Size4-Regular.woff2) format('woff2'); font-weight: normal; font-style: normal; } @font-face { font-family: 'KaTeX_Typewriter'; - src: url(../webfonts/KaTeX_Typewriter-Regular.woff) format('woff'); + src: url(../webfonts/KaTeX_Typewriter-Regular.woff2) format('woff2'); font-weight: normal; font-style: normal; } @@ -130,7 +130,7 @@ border-color: currentColor; } .katex .katex-version::after { - content: "0.13.2"; + content: "0.15.2"; } .katex .katex-mathml { /* Accessibility hack to only show to screen readers @@ -270,28 +270,18 @@ min-width: 2px; } .katex .vbox { - display: -webkit-inline-box; display: inline-flex; - -webkit-box-orient: vertical; - -webkit-box-direction: normal; - flex-direction: column; - -webkit-box-align: baseline; - align-items: baseline; + flex-direction: column; + align-items: baseline; } .katex .hbox { - display: -webkit-inline-box; display: inline-flex; - -webkit-box-orient: horizontal; - -webkit-box-direction: normal; - flex-direction: row; + flex-direction: row; width: 100%; } .katex .thinbox { - display: -webkit-inline-box; display: inline-flex; - -webkit-box-orient: horizontal; - -webkit-box-direction: normal; - flex-direction: row; + flex-direction: row; width: 0; max-width: 0; } @@ -1003,7 +993,7 @@ text-align: center; } .katex .boxpad { - padding: 0 0.3em 0 0.3em; + padding: 0 0.3em; } .katex .fbox, .katex .fcolorbox { @@ -1011,7 +1001,7 @@ border: 0.04em solid; } .katex .cancel-pad { - padding: 0 0.2em 0 0.2em; + padding: 0 0.2em; } .katex .cancel-lap { margin-left: -0.2em; @@ -1022,13 +1012,13 @@ border-bottom-width: 0.08em; } .katex .angl { - box-sizing: border-content; + box-sizing: border-box; border-top: 0.049em solid; border-right: 0.049em solid; margin-right: 0.03889em; } .katex .anglpad { - padding: 0 0.03889em 0 0.03889em; + padding: 0 0.03889em; } .katex .eqn-num::before { counter-increment: katexEqnNo; @@ -1048,14 +1038,12 @@ .katex .cd-label-left { display: inline-block; position: absolute; - right: -webkit-calc(50% + 0.3em); right: calc(50% + 0.3em); text-align: left; } .katex .cd-label-right { display: inline-block; position: absolute; - left: -webkit-calc(50% + 0.3em); left: calc(50% + 0.3em); text-align: right; } diff --git a/static/js/auto-render.js b/static/js/auto-render.js index 052e0eb..6980cdd 100644 --- a/static/js/auto-render.js +++ b/static/js/auto-render.js @@ -7,15 +7,15 @@ exports["renderMathInElement"] = factory(require("katex")); else root["renderMathInElement"] = factory(root["katex"]); -})((typeof self !== 'undefined' ? self : this), function(__WEBPACK_EXTERNAL_MODULE__974__) { +})((typeof self !== 'undefined' ? self : this), function(__WEBPACK_EXTERNAL_MODULE__771__) { return /******/ (function() { // webpackBootstrap /******/ "use strict"; /******/ var __webpack_modules__ = ({ -/***/ 974: +/***/ 771: /***/ (function(module) { -module.exports = __WEBPACK_EXTERNAL_MODULE__974__; +module.exports = __WEBPACK_EXTERNAL_MODULE__771__; /***/ }) @@ -86,7 +86,7 @@ __webpack_require__.d(__webpack_exports__, { }); // EXTERNAL MODULE: external "katex" -var external_katex_ = __webpack_require__(974); +var external_katex_ = __webpack_require__(771); var external_katex_default = /*#__PURE__*/__webpack_require__.n(external_katex_); ;// CONCATENATED MODULE: ./contrib/auto-render/splitAtDelimiters.js /* eslint no-constant-condition:0 */ @@ -320,7 +320,7 @@ var renderMathInElement = function renderMathInElement(elem, options) { /* harmony default export */ var auto_render = (renderMathInElement); }(); -__webpack_exports__ = __webpack_exports__.default; +__webpack_exports__ = __webpack_exports__["default"]; /******/ return __webpack_exports__; /******/ })() ; diff --git a/static/js/katex.js b/static/js/katex.js index 5835574..ab4956b 100644 --- a/static/js/katex.js +++ b/static/js/katex.js @@ -52,7 +52,8 @@ __webpack_require__.d(__webpack_exports__, { */ var ParseError = // Error position based on passed-in Token or ParseNode. function ParseError(message, // The error message -token) { +token // An object providing position information +) { this.position = void 0; var error = "KaTeX parse error: " + message; var start; @@ -228,7 +229,136 @@ var protocolFromUrl = function protocolFromUrl(url) { +// TODO: automatically generate documentation +// TODO: check all properties on Settings exist +// TODO: check the type of a property on Settings matches +var SETTINGS_SCHEMA = { + displayMode: { + type: "boolean", + description: "Render math in display mode, which puts the math in " + "display style (so \\int and \\sum are large, for example), and " + "centers the math on the page on its own line.", + cli: "-d, --display-mode" + }, + output: { + type: { + enum: ["htmlAndMathml", "html", "mathml"] + }, + description: "Determines the markup language of the output.", + cli: "-F, --format " + }, + leqno: { + type: "boolean", + description: "Render display math in leqno style (left-justified tags)." + }, + fleqn: { + type: "boolean", + description: "Render display math flush left." + }, + throwOnError: { + type: "boolean", + default: true, + cli: "-t, --no-throw-on-error", + cliDescription: "Render errors (in the color given by --error-color) ins" + "tead of throwing a ParseError exception when encountering an error." + }, + errorColor: { + type: "string", + default: "#cc0000", + cli: "-c, --error-color ", + cliDescription: "A color string given in the format 'rgb' or 'rrggbb' " + "(no #). This option determines the color of errors rendered by the " + "-t option.", + cliProcessor: function cliProcessor(color) { + return "#" + color; + } + }, + macros: { + type: "object", + cli: "-m, --macro ", + cliDescription: "Define custom macro of the form '\\foo:expansion' (use " + "multiple -m arguments for multiple macros).", + cliDefault: [], + cliProcessor: function cliProcessor(def, defs) { + defs.push(def); + return defs; + } + }, + minRuleThickness: { + type: "number", + description: "Specifies a minimum thickness, in ems, for fraction lines," + " `\\sqrt` top lines, `{array}` vertical lines, `\\hline`, " + "`\\hdashline`, `\\underline`, `\\overline`, and the borders of " + "`\\fbox`, `\\boxed`, and `\\fcolorbox`.", + processor: function processor(t) { + return Math.max(0, t); + }, + cli: "--min-rule-thickness ", + cliProcessor: parseFloat + }, + colorIsTextColor: { + type: "boolean", + description: "Makes \\color behave like LaTeX's 2-argument \\textcolor, " + "instead of LaTeX's one-argument \\color mode change.", + cli: "-b, --color-is-text-color" + }, + strict: { + type: [{ + enum: ["warn", "ignore", "error"] + }, "boolean", "function"], + description: "Turn on strict / LaTeX faithfulness mode, which throws an " + "error if the input uses features that are not supported by LaTeX.", + cli: "-S, --strict", + cliDefault: false + }, + trust: { + type: ["boolean", "function"], + description: "Trust the input, enabling all HTML features such as \\url.", + cli: "-T, --trust" + }, + maxSize: { + type: "number", + default: Infinity, + description: "If non-zero, all user-specified sizes, e.g. in " + "\\rule{500em}{500em}, will be capped to maxSize ems. Otherwise, " + "elements and spaces can be arbitrarily large", + processor: function processor(s) { + return Math.max(0, s); + }, + cli: "-s, --max-size ", + cliProcessor: parseInt + }, + maxExpand: { + type: "number", + default: 1000, + description: "Limit the number of macro expansions to the specified " + "number, to prevent e.g. infinite macro loops. If set to Infinity, " + "the macro expander will try to fully expand as in LaTeX.", + processor: function processor(n) { + return Math.max(0, n); + }, + cli: "-e, --max-expand ", + cliProcessor: function cliProcessor(n) { + return n === "Infinity" ? Infinity : parseInt(n); + } + }, + globalGroup: { + type: "boolean", + cli: false + } +}; + +function getDefaultValue(schema) { + if (schema.default) { + return schema.default; + } + var type = schema.type; + var defaultType = Array.isArray(type) ? type[0] : type; + + if (typeof defaultType !== 'string') { + return defaultType.enum[0]; + } + + switch (defaultType) { + case 'boolean': + return false; + + case 'string': + return ''; + + case 'number': + return 0; + + case 'object': + return {}; + } +} /** * The main Settings object * @@ -239,6 +369,8 @@ var protocolFromUrl = function protocolFromUrl(url) { * math (true), meaning that the math starts in \displaystyle * and is placed in a block with vertical margin. */ + + var Settings = /*#__PURE__*/function () { function Settings(options) { this.displayMode = void 0; @@ -257,20 +389,16 @@ var Settings = /*#__PURE__*/function () { this.globalGroup = void 0; // allow null options options = options || {}; - this.displayMode = utils.deflt(options.displayMode, false); - this.output = utils.deflt(options.output, "htmlAndMathml"); - this.leqno = utils.deflt(options.leqno, false); - this.fleqn = utils.deflt(options.fleqn, false); - this.throwOnError = utils.deflt(options.throwOnError, true); - this.errorColor = utils.deflt(options.errorColor, "#cc0000"); - this.macros = options.macros || {}; - this.minRuleThickness = Math.max(0, utils.deflt(options.minRuleThickness, 0)); - this.colorIsTextColor = utils.deflt(options.colorIsTextColor, false); - this.strict = utils.deflt(options.strict, "warn"); - this.trust = utils.deflt(options.trust, false); - this.maxSize = Math.max(0, utils.deflt(options.maxSize, Infinity)); - this.maxExpand = Math.max(0, utils.deflt(options.maxExpand, 1000)); - this.globalGroup = utils.deflt(options.globalGroup, false); + + for (var prop in SETTINGS_SCHEMA) { + if (SETTINGS_SCHEMA.hasOwnProperty(prop)) { + // $FlowFixMe + var schema = SETTINGS_SCHEMA[prop]; // TODO: validate options + // $FlowFixMe + + this[prop] = options[prop] !== undefined ? schema.processor ? schema.processor(options[prop]) : options[prop] : getDefaultValue(schema); + } + } } /** * Report nonstrict (non-LaTeX-compatible) input. @@ -878,559 +1006,6 @@ var DocumentFragment = /*#__PURE__*/function () { return DocumentFragment; }(); -;// CONCATENATED MODULE: ./src/domTree.js -/** - * These objects store the data about the DOM nodes we create, as well as some - * extra data. They can then be transformed into real DOM nodes with the - * `toNode` function or HTML markup using `toMarkup`. They are useful for both - * storing extra properties on the nodes, as well as providing a way to easily - * work with the DOM. - * - * Similar functions for working with MathML nodes exist in mathMLTree.js. - * - * TODO: refactor `span` and `anchor` into common superclass when - * target environments support class inheritance - */ - - - - - -/** - * Create an HTML className based on a list of classes. In addition to joining - * with spaces, we also remove empty classes. - */ -var createClass = function createClass(classes) { - return classes.filter(function (cls) { - return cls; - }).join(" "); -}; - -var initNode = function initNode(classes, options, style) { - this.classes = classes || []; - this.attributes = {}; - this.height = 0; - this.depth = 0; - this.maxFontSize = 0; - this.style = style || {}; - - if (options) { - if (options.style.isTight()) { - this.classes.push("mtight"); - } - - var color = options.getColor(); - - if (color) { - this.style.color = color; - } - } -}; -/** - * Convert into an HTML node - */ - - -var _toNode = function toNode(tagName) { - var node = document.createElement(tagName); // Apply the class - - node.className = createClass(this.classes); // Apply inline styles - - for (var style in this.style) { - if (this.style.hasOwnProperty(style)) { - // $FlowFixMe Flow doesn't seem to understand span.style's type. - node.style[style] = this.style[style]; - } - } // Apply attributes - - - for (var attr in this.attributes) { - if (this.attributes.hasOwnProperty(attr)) { - node.setAttribute(attr, this.attributes[attr]); - } - } // Append the children, also as HTML nodes - - - for (var i = 0; i < this.children.length; i++) { - node.appendChild(this.children[i].toNode()); - } - - return node; -}; -/** - * Convert into an HTML markup string - */ - - -var _toMarkup = function toMarkup(tagName) { - var markup = "<" + tagName; // Add the class - - if (this.classes.length) { - markup += " class=\"" + utils.escape(createClass(this.classes)) + "\""; - } - - var styles = ""; // Add the styles, after hyphenation - - for (var style in this.style) { - if (this.style.hasOwnProperty(style)) { - styles += utils.hyphenate(style) + ":" + this.style[style] + ";"; - } - } - - if (styles) { - markup += " style=\"" + utils.escape(styles) + "\""; - } // Add the attributes - - - for (var attr in this.attributes) { - if (this.attributes.hasOwnProperty(attr)) { - markup += " " + attr + "=\"" + utils.escape(this.attributes[attr]) + "\""; - } - } - - markup += ">"; // Add the markup of the children, also as markup - - for (var i = 0; i < this.children.length; i++) { - markup += this.children[i].toMarkup(); - } - - markup += ""; - return markup; -}; // Making the type below exact with all optional fields doesn't work due to -// - https://github.com/facebook/flow/issues/4582 -// - https://github.com/facebook/flow/issues/5688 -// However, since *all* fields are optional, $Shape<> works as suggested in 5688 -// above. -// This type does not include all CSS properties. Additional properties should -// be added as needed. - - -/** - * This node represents a span node, with a className, a list of children, and - * an inline style. It also contains information about its height, depth, and - * maxFontSize. - * - * Represents two types with different uses: SvgSpan to wrap an SVG and DomSpan - * otherwise. This typesafety is important when HTML builders access a span's - * children. - */ -var Span = /*#__PURE__*/function () { - function Span(classes, children, options, style) { - this.children = void 0; - this.attributes = void 0; - this.classes = void 0; - this.height = void 0; - this.depth = void 0; - this.width = void 0; - this.maxFontSize = void 0; - this.style = void 0; - initNode.call(this, classes, options, style); - this.children = children || []; - } - /** - * Sets an arbitrary attribute on the span. Warning: use this wisely. Not - * all browsers support attributes the same, and having too many custom - * attributes is probably bad. - */ - - - var _proto = Span.prototype; - - _proto.setAttribute = function setAttribute(attribute, value) { - this.attributes[attribute] = value; - }; - - _proto.hasClass = function hasClass(className) { - return utils.contains(this.classes, className); - }; - - _proto.toNode = function toNode() { - return _toNode.call(this, "span"); - }; - - _proto.toMarkup = function toMarkup() { - return _toMarkup.call(this, "span"); - }; - - return Span; -}(); -/** - * This node represents an anchor () element with a hyperlink. See `span` - * for further details. - */ - -var Anchor = /*#__PURE__*/function () { - function Anchor(href, classes, children, options) { - this.children = void 0; - this.attributes = void 0; - this.classes = void 0; - this.height = void 0; - this.depth = void 0; - this.maxFontSize = void 0; - this.style = void 0; - initNode.call(this, classes, options); - this.children = children || []; - this.setAttribute('href', href); - } - - var _proto2 = Anchor.prototype; - - _proto2.setAttribute = function setAttribute(attribute, value) { - this.attributes[attribute] = value; - }; - - _proto2.hasClass = function hasClass(className) { - return utils.contains(this.classes, className); - }; - - _proto2.toNode = function toNode() { - return _toNode.call(this, "a"); - }; - - _proto2.toMarkup = function toMarkup() { - return _toMarkup.call(this, "a"); - }; - - return Anchor; -}(); -/** - * This node represents an image embed () element. - */ - -var Img = /*#__PURE__*/function () { - function Img(src, alt, style) { - this.src = void 0; - this.alt = void 0; - this.classes = void 0; - this.height = void 0; - this.depth = void 0; - this.maxFontSize = void 0; - this.style = void 0; - this.alt = alt; - this.src = src; - this.classes = ["mord"]; - this.style = style; - } - - var _proto3 = Img.prototype; - - _proto3.hasClass = function hasClass(className) { - return utils.contains(this.classes, className); - }; - - _proto3.toNode = function toNode() { - var node = document.createElement("img"); - node.src = this.src; - node.alt = this.alt; - node.className = "mord"; // Apply inline styles - - for (var style in this.style) { - if (this.style.hasOwnProperty(style)) { - // $FlowFixMe - node.style[style] = this.style[style]; - } - } - - return node; - }; - - _proto3.toMarkup = function toMarkup() { - var markup = "" + this.alt + " 0) { - span = document.createElement("span"); - span.style.marginRight = this.italic + "em"; - } - - if (this.classes.length > 0) { - span = span || document.createElement("span"); - span.className = createClass(this.classes); - } - - for (var style in this.style) { - if (this.style.hasOwnProperty(style)) { - span = span || document.createElement("span"); // $FlowFixMe Flow doesn't seem to understand span.style's type. - - span.style[style] = this.style[style]; - } - } - - if (span) { - span.appendChild(node); - return span; - } else { - return node; - } - } - /** - * Creates markup for a symbol node. - */ - ; - - _proto4.toMarkup = function toMarkup() { - // TODO(alpert): More duplication than I'd like from - // span.prototype.toMarkup and symbolNode.prototype.toNode... - var needsSpan = false; - var markup = " 0) { - styles += "margin-right:" + this.italic + "em;"; - } - - for (var style in this.style) { - if (this.style.hasOwnProperty(style)) { - styles += utils.hyphenate(style) + ":" + this.style[style] + ";"; - } - } - - if (styles) { - needsSpan = true; - markup += " style=\"" + utils.escape(styles) + "\""; - } - - var escaped = utils.escape(this.text); - - if (needsSpan) { - markup += ">"; - markup += escaped; - markup += ""; - return markup; - } else { - return escaped; - } - }; - - return SymbolNode; -}(); -/** - * SVG nodes are used to render stretchy wide elements. - */ - -var SvgNode = /*#__PURE__*/function () { - function SvgNode(children, attributes) { - this.children = void 0; - this.attributes = void 0; - this.children = children || []; - this.attributes = attributes || {}; - } - - var _proto5 = SvgNode.prototype; - - _proto5.toNode = function toNode() { - var svgNS = "http://www.w3.org/2000/svg"; - var node = document.createElementNS(svgNS, "svg"); // Apply attributes - - for (var attr in this.attributes) { - if (Object.prototype.hasOwnProperty.call(this.attributes, attr)) { - node.setAttribute(attr, this.attributes[attr]); - } - } - - for (var i = 0; i < this.children.length; i++) { - node.appendChild(this.children[i].toNode()); - } - - return node; - }; - - _proto5.toMarkup = function toMarkup() { - var markup = ""; - } else { - return ""; - } - }; - - return PathNode; -}(); -var LineNode = /*#__PURE__*/function () { - function LineNode(attributes) { - this.attributes = void 0; - this.attributes = attributes || {}; - } - - var _proto7 = LineNode.prototype; - - _proto7.toNode = function toNode() { - var svgNS = "http://www.w3.org/2000/svg"; - var node = document.createElementNS(svgNS, "line"); // Apply attributes - - for (var attr in this.attributes) { - if (Object.prototype.hasOwnProperty.call(this.attributes, attr)) { - node.setAttribute(attr, this.attributes[attr]); - } - } - - return node; - }; - - _proto7.toMarkup = function toMarkup() { - var markup = " but got " + String(group) + "."); - } -} ;// CONCATENATED MODULE: ./src/fontMetricsData.js // This file is GENERATED by buildMetrics.sh. DO NOT MODIFY. /* harmony default export */ var fontMetricsData = ({ @@ -2016,6 +1591,7 @@ function assertSpan(group) { "8764": [-0.10889, 0.39111, 0, 0, 0.89444], "8768": [0.19444, 0.69444, 0, 0, 0.31944], "8771": [0.00222, 0.50222, 0, 0, 0.89444], + "8773": [0.027, 0.638, 0, 0, 0.894], "8776": [0.02444, 0.52444, 0, 0, 0.89444], "8781": [0.00222, 0.50222, 0, 0, 0.89444], "8801": [0.00222, 0.50222, 0, 0, 0.89444], @@ -2472,7 +2048,7 @@ function assertSpan(group) { "8221": [0, 0.69444, 0, 0, 0.5], "8224": [0.19444, 0.69444, 0, 0, 0.44445], "8225": [0.19444, 0.69444, 0, 0, 0.44445], - "8230": [0, 0.12, 0, 0, 1.172], + "8230": [0, 0.123, 0, 0, 1.172], "8242": [0, 0.55556, 0, 0, 0.275], "8407": [0, 0.71444, 0.15382, 0, 0.5], "8463": [0, 0.68889, 0, 0, 0.54028], @@ -2533,10 +2109,10 @@ function assertSpan(group) { "8764": [-0.13313, 0.36687, 0, 0, 0.77778], "8768": [0.19444, 0.69444, 0, 0, 0.27778], "8771": [-0.03625, 0.46375, 0, 0, 0.77778], - "8773": [-0.022, 0.589, 0, 0, 1.0], + "8773": [-0.022, 0.589, 0, 0, 0.778], "8776": [-0.01688, 0.48312, 0, 0, 0.77778], "8781": [-0.03625, 0.46375, 0, 0, 0.77778], - "8784": [-0.133, 0.67, 0, 0, 0.778], + "8784": [-0.133, 0.673, 0, 0, 0.778], "8801": [-0.03625, 0.46375, 0, 0, 0.77778], "8804": [0.13597, 0.63597, 0, 0, 0.77778], "8805": [0.13597, 0.63597, 0, 0, 0.77778], @@ -2567,9 +2143,9 @@ function assertSpan(group) { "8901": [-0.05555, 0.44445, 0, 0, 0.27778], "8902": [-0.03472, 0.46528, 0, 0, 0.5], "8904": [0.005, 0.505, 0, 0, 0.9], - "8942": [0.03, 0.9, 0, 0, 0.278], - "8943": [-0.19, 0.31, 0, 0, 1.172], - "8945": [-0.1, 0.82, 0, 0, 1.282], + "8942": [0.03, 0.903, 0, 0, 0.278], + "8943": [-0.19, 0.313, 0, 0, 1.172], + "8945": [-0.1, 0.823, 0, 0, 1.282], "8968": [0.25, 0.75, 0, 0, 0.44445], "8969": [0.25, 0.75, 0, 0, 0.44445], "8970": [0.25, 0.75, 0, 0, 0.44445], @@ -2577,7 +2153,7 @@ function assertSpan(group) { "8994": [-0.14236, 0.35764, 0, 0, 1.0], "8995": [-0.14236, 0.35764, 0, 0, 1.0], "9136": [0.244, 0.744, 0, 0, 0.412], - "9137": [0.244, 0.744, 0, 0, 0.412], + "9137": [0.244, 0.745, 0, 0, 0.412], "9651": [0.19444, 0.69444, 0, 0, 0.88889], "9657": [-0.03472, 0.46528, 0, 0, 0.5], "9661": [0.19444, 0.69444, 0, 0, 0.88889], @@ -2593,7 +2169,7 @@ function assertSpan(group) { "10216": [0.25, 0.75, 0, 0, 0.38889], "10217": [0.25, 0.75, 0, 0, 0.38889], "10222": [0.244, 0.744, 0, 0, 0.412], - "10223": [0.244, 0.744, 0, 0, 0.412], + "10223": [0.244, 0.745, 0, 0, 0.412], "10229": [0.011, 0.511, 0, 0, 1.609], "10230": [0.011, 0.511, 0, 0, 1.638], "10231": [0.011, 0.511, 0, 0, 1.859], @@ -3507,291 +3083,1279 @@ function assertSpan(group) { "8242": [0, 0.61111, 0, 0, 0.525], "9251": [0.11111, 0.21944, 0, 0, 0.525] } -}); -;// CONCATENATED MODULE: ./src/fontMetrics.js +}); +;// CONCATENATED MODULE: ./src/fontMetrics.js + + +/** + * This file contains metrics regarding fonts and individual symbols. The sigma + * and xi variables, as well as the metricMap map contain data extracted from + * TeX, TeX font metrics, and the TTF files. These data are then exposed via the + * `metrics` variable and the getCharacterMetrics function. + */ +// In TeX, there are actually three sets of dimensions, one for each of +// textstyle (size index 5 and higher: >=9pt), scriptstyle (size index 3 and 4: +// 7-8pt), and scriptscriptstyle (size index 1 and 2: 5-6pt). These are +// provided in the the arrays below, in that order. +// +// The font metrics are stored in fonts cmsy10, cmsy7, and cmsy5 respsectively. +// This was determined by running the following script: +// +// latex -interaction=nonstopmode \ +// '\documentclass{article}\usepackage{amsmath}\begin{document}' \ +// '$a$ \expandafter\show\the\textfont2' \ +// '\expandafter\show\the\scriptfont2' \ +// '\expandafter\show\the\scriptscriptfont2' \ +// '\stop' +// +// The metrics themselves were retreived using the following commands: +// +// tftopl cmsy10 +// tftopl cmsy7 +// tftopl cmsy5 +// +// The output of each of these commands is quite lengthy. The only part we +// care about is the FONTDIMEN section. Each value is measured in EMs. +var sigmasAndXis = { + slant: [0.250, 0.250, 0.250], + // sigma1 + space: [0.000, 0.000, 0.000], + // sigma2 + stretch: [0.000, 0.000, 0.000], + // sigma3 + shrink: [0.000, 0.000, 0.000], + // sigma4 + xHeight: [0.431, 0.431, 0.431], + // sigma5 + quad: [1.000, 1.171, 1.472], + // sigma6 + extraSpace: [0.000, 0.000, 0.000], + // sigma7 + num1: [0.677, 0.732, 0.925], + // sigma8 + num2: [0.394, 0.384, 0.387], + // sigma9 + num3: [0.444, 0.471, 0.504], + // sigma10 + denom1: [0.686, 0.752, 1.025], + // sigma11 + denom2: [0.345, 0.344, 0.532], + // sigma12 + sup1: [0.413, 0.503, 0.504], + // sigma13 + sup2: [0.363, 0.431, 0.404], + // sigma14 + sup3: [0.289, 0.286, 0.294], + // sigma15 + sub1: [0.150, 0.143, 0.200], + // sigma16 + sub2: [0.247, 0.286, 0.400], + // sigma17 + supDrop: [0.386, 0.353, 0.494], + // sigma18 + subDrop: [0.050, 0.071, 0.100], + // sigma19 + delim1: [2.390, 1.700, 1.980], + // sigma20 + delim2: [1.010, 1.157, 1.420], + // sigma21 + axisHeight: [0.250, 0.250, 0.250], + // sigma22 + // These font metrics are extracted from TeX by using tftopl on cmex10.tfm; + // they correspond to the font parameters of the extension fonts (family 3). + // See the TeXbook, page 441. In AMSTeX, the extension fonts scale; to + // match cmex7, we'd use cmex7.tfm values for script and scriptscript + // values. + defaultRuleThickness: [0.04, 0.049, 0.049], + // xi8; cmex7: 0.049 + bigOpSpacing1: [0.111, 0.111, 0.111], + // xi9 + bigOpSpacing2: [0.166, 0.166, 0.166], + // xi10 + bigOpSpacing3: [0.2, 0.2, 0.2], + // xi11 + bigOpSpacing4: [0.6, 0.611, 0.611], + // xi12; cmex7: 0.611 + bigOpSpacing5: [0.1, 0.143, 0.143], + // xi13; cmex7: 0.143 + // The \sqrt rule width is taken from the height of the surd character. + // Since we use the same font at all sizes, this thickness doesn't scale. + sqrtRuleThickness: [0.04, 0.04, 0.04], + // This value determines how large a pt is, for metrics which are defined + // in terms of pts. + // This value is also used in katex.less; if you change it make sure the + // values match. + ptPerEm: [10.0, 10.0, 10.0], + // The space between adjacent `|` columns in an array definition. From + // `\showthe\doublerulesep` in LaTeX. Equals 2.0 / ptPerEm. + doubleRuleSep: [0.2, 0.2, 0.2], + // The width of separator lines in {array} environments. From + // `\showthe\arrayrulewidth` in LaTeX. Equals 0.4 / ptPerEm. + arrayRuleWidth: [0.04, 0.04, 0.04], + // Two values from LaTeX source2e: + fboxsep: [0.3, 0.3, 0.3], + // 3 pt / ptPerEm + fboxrule: [0.04, 0.04, 0.04] // 0.4 pt / ptPerEm + +}; // This map contains a mapping from font name and character code to character +// metrics, including height, depth, italic correction, and skew (kern from the +// character to the corresponding \skewchar) +// This map is generated via `make metrics`. It should not be changed manually. + + // These are very rough approximations. We default to Times New Roman which +// should have Latin-1 and Cyrillic characters, but may not depending on the +// operating system. The metrics do not account for extra height from the +// accents. In the case of Cyrillic characters which have both ascenders and +// descenders we prefer approximations with ascenders, primarily to prevent +// the fraction bar or root line from intersecting the glyph. +// TODO(kevinb) allow union of multiple glyph metrics for better accuracy. + +var extraCharacterMap = { + // Latin-1 + 'Å': 'A', + 'Ð': 'D', + 'Þ': 'o', + 'å': 'a', + 'ð': 'd', + 'þ': 'o', + // Cyrillic + 'А': 'A', + 'Б': 'B', + 'В': 'B', + 'Г': 'F', + 'Д': 'A', + 'Е': 'E', + 'Ж': 'K', + 'З': '3', + 'И': 'N', + 'Й': 'N', + 'К': 'K', + 'Л': 'N', + 'М': 'M', + 'Н': 'H', + 'О': 'O', + 'П': 'N', + 'Р': 'P', + 'С': 'C', + 'Т': 'T', + 'У': 'y', + 'Ф': 'O', + 'Х': 'X', + 'Ц': 'U', + 'Ч': 'h', + 'Ш': 'W', + 'Щ': 'W', + 'Ъ': 'B', + 'Ы': 'X', + 'Ь': 'B', + 'Э': '3', + 'Ю': 'X', + 'Я': 'R', + 'а': 'a', + 'б': 'b', + 'в': 'a', + 'г': 'r', + 'д': 'y', + 'е': 'e', + 'ж': 'm', + 'з': 'e', + 'и': 'n', + 'й': 'n', + 'к': 'n', + 'л': 'n', + 'м': 'm', + 'н': 'n', + 'о': 'o', + 'п': 'n', + 'р': 'p', + 'с': 'c', + 'т': 'o', + 'у': 'y', + 'ф': 'b', + 'х': 'x', + 'ц': 'n', + 'ч': 'n', + 'ш': 'w', + 'щ': 'w', + 'ъ': 'a', + 'ы': 'm', + 'ь': 'a', + 'э': 'e', + 'ю': 'm', + 'я': 'r' +}; + +/** + * This function adds new font metrics to default metricMap + * It can also override existing metrics + */ +function setFontMetrics(fontName, metrics) { + fontMetricsData[fontName] = metrics; +} +/** + * This function is a convenience function for looking up information in the + * metricMap table. It takes a character as a string, and a font. + * + * Note: the `width` property may be undefined if fontMetricsData.js wasn't + * built using `Make extended_metrics`. + */ + +function getCharacterMetrics(character, font, mode) { + if (!fontMetricsData[font]) { + throw new Error("Font metrics not found for font: " + font + "."); + } + + var ch = character.charCodeAt(0); + var metrics = fontMetricsData[font][ch]; + + if (!metrics && character[0] in extraCharacterMap) { + ch = extraCharacterMap[character[0]].charCodeAt(0); + metrics = fontMetricsData[font][ch]; + } + + if (!metrics && mode === 'text') { + // We don't typically have font metrics for Asian scripts. + // But since we support them in text mode, we need to return + // some sort of metrics. + // So if the character is in a script we support but we + // don't have metrics for it, just use the metrics for + // the Latin capital letter M. This is close enough because + // we (currently) only care about the height of the glpyh + // not its width. + if (supportedCodepoint(ch)) { + metrics = fontMetricsData[font][77]; // 77 is the charcode for 'M' + } + } + + if (metrics) { + return { + depth: metrics[0], + height: metrics[1], + italic: metrics[2], + skew: metrics[3], + width: metrics[4] + }; + } +} +var fontMetricsBySizeIndex = {}; +/** + * Get the font metrics for a given size. + */ + +function getGlobalMetrics(size) { + var sizeIndex; + + if (size >= 5) { + sizeIndex = 0; + } else if (size >= 3) { + sizeIndex = 1; + } else { + sizeIndex = 2; + } + + if (!fontMetricsBySizeIndex[sizeIndex]) { + var metrics = fontMetricsBySizeIndex[sizeIndex] = { + cssEmPerMu: sigmasAndXis.quad[sizeIndex] / 18 + }; + + for (var key in sigmasAndXis) { + if (sigmasAndXis.hasOwnProperty(key)) { + metrics[key] = sigmasAndXis[key][sizeIndex]; + } + } + } + + return fontMetricsBySizeIndex[sizeIndex]; +} +;// CONCATENATED MODULE: ./src/Options.js +/** + * This file contains information about the options that the Parser carries + * around with it while parsing. Data is held in an `Options` object, and when + * recursing, a new `Options` object can be created with the `.with*` and + * `.reset` functions. + */ + +var sizeStyleMap = [// Each element contains [textsize, scriptsize, scriptscriptsize]. +// The size mappings are taken from TeX with \normalsize=10pt. +[1, 1, 1], // size1: [5, 5, 5] \tiny +[2, 1, 1], // size2: [6, 5, 5] +[3, 1, 1], // size3: [7, 5, 5] \scriptsize +[4, 2, 1], // size4: [8, 6, 5] \footnotesize +[5, 2, 1], // size5: [9, 6, 5] \small +[6, 3, 1], // size6: [10, 7, 5] \normalsize +[7, 4, 2], // size7: [12, 8, 6] \large +[8, 6, 3], // size8: [14.4, 10, 7] \Large +[9, 7, 6], // size9: [17.28, 12, 10] \LARGE +[10, 8, 7], // size10: [20.74, 14.4, 12] \huge +[11, 10, 9] // size11: [24.88, 20.74, 17.28] \HUGE +]; +var sizeMultipliers = [// fontMetrics.js:getGlobalMetrics also uses size indexes, so if +// you change size indexes, change that function. +0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.2, 1.44, 1.728, 2.074, 2.488]; + +var sizeAtStyle = function sizeAtStyle(size, style) { + return style.size < 2 ? size : sizeStyleMap[size - 1][style.size - 1]; +}; // In these types, "" (empty string) means "no change". + + +/** + * This is the main options class. It contains the current style, size, color, + * and font. + * + * Options objects should not be modified. To create a new Options with + * different properties, call a `.having*` method. + */ +var Options = /*#__PURE__*/function () { + // A font family applies to a group of fonts (i.e. SansSerif), while a font + // represents a specific font (i.e. SansSerif Bold). + // See: https://tex.stackexchange.com/questions/22350/difference-between-textrm-and-mathrm + + /** + * The base size index. + */ + function Options(data) { + this.style = void 0; + this.color = void 0; + this.size = void 0; + this.textSize = void 0; + this.phantom = void 0; + this.font = void 0; + this.fontFamily = void 0; + this.fontWeight = void 0; + this.fontShape = void 0; + this.sizeMultiplier = void 0; + this.maxSize = void 0; + this.minRuleThickness = void 0; + this._fontMetrics = void 0; + this.style = data.style; + this.color = data.color; + this.size = data.size || Options.BASESIZE; + this.textSize = data.textSize || this.size; + this.phantom = !!data.phantom; + this.font = data.font || ""; + this.fontFamily = data.fontFamily || ""; + this.fontWeight = data.fontWeight || ''; + this.fontShape = data.fontShape || ''; + this.sizeMultiplier = sizeMultipliers[this.size - 1]; + this.maxSize = data.maxSize; + this.minRuleThickness = data.minRuleThickness; + this._fontMetrics = undefined; + } + /** + * Returns a new options object with the same properties as "this". Properties + * from "extension" will be copied to the new options object. + */ + + + var _proto = Options.prototype; + + _proto.extend = function extend(extension) { + var data = { + style: this.style, + size: this.size, + textSize: this.textSize, + color: this.color, + phantom: this.phantom, + font: this.font, + fontFamily: this.fontFamily, + fontWeight: this.fontWeight, + fontShape: this.fontShape, + maxSize: this.maxSize, + minRuleThickness: this.minRuleThickness + }; + + for (var key in extension) { + if (extension.hasOwnProperty(key)) { + data[key] = extension[key]; + } + } + + return new Options(data); + } + /** + * Return an options object with the given style. If `this.style === style`, + * returns `this`. + */ + ; + + _proto.havingStyle = function havingStyle(style) { + if (this.style === style) { + return this; + } else { + return this.extend({ + style: style, + size: sizeAtStyle(this.textSize, style) + }); + } + } + /** + * Return an options object with a cramped version of the current style. If + * the current style is cramped, returns `this`. + */ + ; + + _proto.havingCrampedStyle = function havingCrampedStyle() { + return this.havingStyle(this.style.cramp()); + } + /** + * Return an options object with the given size and in at least `\textstyle`. + * Returns `this` if appropriate. + */ + ; + + _proto.havingSize = function havingSize(size) { + if (this.size === size && this.textSize === size) { + return this; + } else { + return this.extend({ + style: this.style.text(), + size: size, + textSize: size, + sizeMultiplier: sizeMultipliers[size - 1] + }); + } + } + /** + * Like `this.havingSize(BASESIZE).havingStyle(style)`. If `style` is omitted, + * changes to at least `\textstyle`. + */ + ; + + _proto.havingBaseStyle = function havingBaseStyle(style) { + style = style || this.style.text(); + var wantSize = sizeAtStyle(Options.BASESIZE, style); + + if (this.size === wantSize && this.textSize === Options.BASESIZE && this.style === style) { + return this; + } else { + return this.extend({ + style: style, + size: wantSize + }); + } + } + /** + * Remove the effect of sizing changes such as \Huge. + * Keep the effect of the current style, such as \scriptstyle. + */ + ; + + _proto.havingBaseSizing = function havingBaseSizing() { + var size; + + switch (this.style.id) { + case 4: + case 5: + size = 3; // normalsize in scriptstyle + + break; + + case 6: + case 7: + size = 1; // normalsize in scriptscriptstyle + + break; + + default: + size = 6; + // normalsize in textstyle or displaystyle + } + + return this.extend({ + style: this.style.text(), + size: size + }); + } + /** + * Create a new options object with the given color. + */ + ; + + _proto.withColor = function withColor(color) { + return this.extend({ + color: color + }); + } + /** + * Create a new options object with "phantom" set to true. + */ + ; + + _proto.withPhantom = function withPhantom() { + return this.extend({ + phantom: true + }); + } + /** + * Creates a new options object with the given math font or old text font. + * @type {[type]} + */ + ; + + _proto.withFont = function withFont(font) { + return this.extend({ + font: font + }); + } + /** + * Create a new options objects with the given fontFamily. + */ + ; + + _proto.withTextFontFamily = function withTextFontFamily(fontFamily) { + return this.extend({ + fontFamily: fontFamily, + font: "" + }); + } + /** + * Creates a new options object with the given font weight + */ + ; + + _proto.withTextFontWeight = function withTextFontWeight(fontWeight) { + return this.extend({ + fontWeight: fontWeight, + font: "" + }); + } + /** + * Creates a new options object with the given font weight + */ + ; + + _proto.withTextFontShape = function withTextFontShape(fontShape) { + return this.extend({ + fontShape: fontShape, + font: "" + }); + } + /** + * Return the CSS sizing classes required to switch from enclosing options + * `oldOptions` to `this`. Returns an array of classes. + */ + ; + + _proto.sizingClasses = function sizingClasses(oldOptions) { + if (oldOptions.size !== this.size) { + return ["sizing", "reset-size" + oldOptions.size, "size" + this.size]; + } else { + return []; + } + } + /** + * Return the CSS sizing classes required to switch to the base size. Like + * `this.havingSize(BASESIZE).sizingClasses(this)`. + */ + ; + + _proto.baseSizingClasses = function baseSizingClasses() { + if (this.size !== Options.BASESIZE) { + return ["sizing", "reset-size" + this.size, "size" + Options.BASESIZE]; + } else { + return []; + } + } + /** + * Return the font metrics for this size. + */ + ; + + _proto.fontMetrics = function fontMetrics() { + if (!this._fontMetrics) { + this._fontMetrics = getGlobalMetrics(this.size); + } + + return this._fontMetrics; + } + /** + * Gets the CSS color of the current options object + */ + ; + + _proto.getColor = function getColor() { + if (this.phantom) { + return "transparent"; + } else { + return this.color; + } + }; + + return Options; +}(); + +Options.BASESIZE = 6; +/* harmony default export */ var src_Options = (Options); +;// CONCATENATED MODULE: ./src/units.js +/** + * This file does conversion between units. In particular, it provides + * calculateSize to convert other units into ems. + */ + + // This table gives the number of TeX pts in one of each *absolute* TeX unit. +// Thus, multiplying a length by this number converts the length from units +// into pts. Dividing the result by ptPerEm gives the number of ems +// *assuming* a font size of ptPerEm (normal size, normal style). + +var ptPerUnit = { + // https://en.wikibooks.org/wiki/LaTeX/Lengths and + // https://tex.stackexchange.com/a/8263 + "pt": 1, + // TeX point + "mm": 7227 / 2540, + // millimeter + "cm": 7227 / 254, + // centimeter + "in": 72.27, + // inch + "bp": 803 / 800, + // big (PostScript) points + "pc": 12, + // pica + "dd": 1238 / 1157, + // didot + "cc": 14856 / 1157, + // cicero (12 didot) + "nd": 685 / 642, + // new didot + "nc": 1370 / 107, + // new cicero (12 new didot) + "sp": 1 / 65536, + // scaled point (TeX's internal smallest unit) + // https://tex.stackexchange.com/a/41371 + "px": 803 / 800 // \pdfpxdimen defaults to 1 bp in pdfTeX and LuaTeX + +}; // Dictionary of relative units, for fast validity testing. + +var relativeUnit = { + "ex": true, + "em": true, + "mu": true +}; + +/** + * Determine whether the specified unit (either a string defining the unit + * or a "size" parse node containing a unit field) is valid. + */ +var validUnit = function validUnit(unit) { + if (typeof unit !== "string") { + unit = unit.unit; + } + + return unit in ptPerUnit || unit in relativeUnit || unit === "ex"; +}; +/* + * Convert a "size" parse node (with numeric "number" and string "unit" fields, + * as parsed by functions.js argType "size") into a CSS em value for the + * current style/scale. `options` gives the current options. + */ + +var calculateSize = function calculateSize(sizeValue, options) { + var scale; + + if (sizeValue.unit in ptPerUnit) { + // Absolute units + scale = ptPerUnit[sizeValue.unit] // Convert unit to pt + / options.fontMetrics().ptPerEm // Convert pt to CSS em + / options.sizeMultiplier; // Unscale to make absolute units + } else if (sizeValue.unit === "mu") { + // `mu` units scale with scriptstyle/scriptscriptstyle. + scale = options.fontMetrics().cssEmPerMu; + } else { + // Other relative units always refer to the *textstyle* font + // in the current size. + var unitOptions; + + if (options.style.isTight()) { + // isTight() means current style is script/scriptscript. + unitOptions = options.havingStyle(options.style.text()); + } else { + unitOptions = options; + } // TODO: In TeX these units are relative to the quad of the current + // *text* font, e.g. cmr10. KaTeX instead uses values from the + // comparably-sized *Computer Modern symbol* font. At 10pt, these + // match. At 7pt and 5pt, they differ: cmr7=1.138894, cmsy7=1.170641; + // cmr5=1.361133, cmsy5=1.472241. Consider $\scriptsize a\kern1emb$. + // TeX \showlists shows a kern of 1.13889 * fontsize; + // KaTeX shows a kern of 1.171 * fontsize. + + + if (sizeValue.unit === "ex") { + scale = unitOptions.fontMetrics().xHeight; + } else if (sizeValue.unit === "em") { + scale = unitOptions.fontMetrics().quad; + } else { + throw new src_ParseError("Invalid unit: '" + sizeValue.unit + "'"); + } + + if (unitOptions !== options) { + scale *= unitOptions.sizeMultiplier / options.sizeMultiplier; + } + } + + return Math.min(sizeValue.number * scale, options.maxSize); +}; +/** + * Round `n` to 4 decimal places, or to the nearest 1/10,000th em. See + * https://github.com/KaTeX/KaTeX/pull/2460. + */ + +var makeEm = function makeEm(n) { + return +n.toFixed(4) + "em"; +}; +;// CONCATENATED MODULE: ./src/domTree.js +/** + * These objects store the data about the DOM nodes we create, as well as some + * extra data. They can then be transformed into real DOM nodes with the + * `toNode` function or HTML markup using `toMarkup`. They are useful for both + * storing extra properties on the nodes, as well as providing a way to easily + * work with the DOM. + * + * Similar functions for working with MathML nodes exist in mathMLTree.js. + * + * TODO: refactor `span` and `anchor` into common superclass when + * target environments support class inheritance + */ + + + + + + +/** + * Create an HTML className based on a list of classes. In addition to joining + * with spaces, we also remove empty classes. + */ +var createClass = function createClass(classes) { + return classes.filter(function (cls) { + return cls; + }).join(" "); +}; + +var initNode = function initNode(classes, options, style) { + this.classes = classes || []; + this.attributes = {}; + this.height = 0; + this.depth = 0; + this.maxFontSize = 0; + this.style = style || {}; + + if (options) { + if (options.style.isTight()) { + this.classes.push("mtight"); + } + + var color = options.getColor(); + + if (color) { + this.style.color = color; + } + } +}; +/** + * Convert into an HTML node + */ + + +var _toNode = function toNode(tagName) { + var node = document.createElement(tagName); // Apply the class + + node.className = createClass(this.classes); // Apply inline styles + + for (var style in this.style) { + if (this.style.hasOwnProperty(style)) { + // $FlowFixMe Flow doesn't seem to understand span.style's type. + node.style[style] = this.style[style]; + } + } // Apply attributes + + + for (var attr in this.attributes) { + if (this.attributes.hasOwnProperty(attr)) { + node.setAttribute(attr, this.attributes[attr]); + } + } // Append the children, also as HTML nodes + + + for (var i = 0; i < this.children.length; i++) { + node.appendChild(this.children[i].toNode()); + } + + return node; +}; +/** + * Convert into an HTML markup string + */ + + +var _toMarkup = function toMarkup(tagName) { + var markup = "<" + tagName; // Add the class + + if (this.classes.length) { + markup += " class=\"" + utils.escape(createClass(this.classes)) + "\""; + } + + var styles = ""; // Add the styles, after hyphenation + + for (var style in this.style) { + if (this.style.hasOwnProperty(style)) { + styles += utils.hyphenate(style) + ":" + this.style[style] + ";"; + } + } + + if (styles) { + markup += " style=\"" + utils.escape(styles) + "\""; + } // Add the attributes + + + for (var attr in this.attributes) { + if (this.attributes.hasOwnProperty(attr)) { + markup += " " + attr + "=\"" + utils.escape(this.attributes[attr]) + "\""; + } + } + + markup += ">"; // Add the markup of the children, also as markup + + for (var i = 0; i < this.children.length; i++) { + markup += this.children[i].toMarkup(); + } + + markup += ""; + return markup; +}; // Making the type below exact with all optional fields doesn't work due to +// - https://github.com/facebook/flow/issues/4582 +// - https://github.com/facebook/flow/issues/5688 +// However, since *all* fields are optional, $Shape<> works as suggested in 5688 +// above. +// This type does not include all CSS properties. Additional properties should +// be added as needed. + + +/** + * This node represents a span node, with a className, a list of children, and + * an inline style. It also contains information about its height, depth, and + * maxFontSize. + * + * Represents two types with different uses: SvgSpan to wrap an SVG and DomSpan + * otherwise. This typesafety is important when HTML builders access a span's + * children. + */ +var Span = /*#__PURE__*/function () { + function Span(classes, children, options, style) { + this.children = void 0; + this.attributes = void 0; + this.classes = void 0; + this.height = void 0; + this.depth = void 0; + this.width = void 0; + this.maxFontSize = void 0; + this.style = void 0; + initNode.call(this, classes, options, style); + this.children = children || []; + } + /** + * Sets an arbitrary attribute on the span. Warning: use this wisely. Not + * all browsers support attributes the same, and having too many custom + * attributes is probably bad. + */ + + + var _proto = Span.prototype; + + _proto.setAttribute = function setAttribute(attribute, value) { + this.attributes[attribute] = value; + }; + + _proto.hasClass = function hasClass(className) { + return utils.contains(this.classes, className); + }; + + _proto.toNode = function toNode() { + return _toNode.call(this, "span"); + }; + + _proto.toMarkup = function toMarkup() { + return _toMarkup.call(this, "span"); + }; + + return Span; +}(); +/** + * This node represents an anchor () element with a hyperlink. See `span` + * for further details. + */ + +var Anchor = /*#__PURE__*/function () { + function Anchor(href, classes, children, options) { + this.children = void 0; + this.attributes = void 0; + this.classes = void 0; + this.height = void 0; + this.depth = void 0; + this.maxFontSize = void 0; + this.style = void 0; + initNode.call(this, classes, options); + this.children = children || []; + this.setAttribute('href', href); + } + + var _proto2 = Anchor.prototype; + + _proto2.setAttribute = function setAttribute(attribute, value) { + this.attributes[attribute] = value; + }; + + _proto2.hasClass = function hasClass(className) { + return utils.contains(this.classes, className); + }; + + _proto2.toNode = function toNode() { + return _toNode.call(this, "a"); + }; + + _proto2.toMarkup = function toMarkup() { + return _toMarkup.call(this, "a"); + }; + + return Anchor; +}(); +/** + * This node represents an image embed () element. + */ + +var Img = /*#__PURE__*/function () { + function Img(src, alt, style) { + this.src = void 0; + this.alt = void 0; + this.classes = void 0; + this.height = void 0; + this.depth = void 0; + this.maxFontSize = void 0; + this.style = void 0; + this.alt = alt; + this.src = src; + this.classes = ["mord"]; + this.style = style; + } + + var _proto3 = Img.prototype; + + _proto3.hasClass = function hasClass(className) { + return utils.contains(this.classes, className); + }; + + _proto3.toNode = function toNode() { + var node = document.createElement("img"); + node.src = this.src; + node.alt = this.alt; + node.className = "mord"; // Apply inline styles + + for (var style in this.style) { + if (this.style.hasOwnProperty(style)) { + // $FlowFixMe + node.style[style] = this.style[style]; + } + } + + return node; + }; + _proto3.toMarkup = function toMarkup() { + var markup = "" + this.alt + "=9pt), scriptstyle (size index 3 and 4: -// 7-8pt), and scriptscriptstyle (size index 1 and 2: 5-6pt). These are -// provided in the the arrays below, in that order. -// -// The font metrics are stored in fonts cmsy10, cmsy7, and cmsy5 respsectively. -// This was determined by running the following script: -// -// latex -interaction=nonstopmode \ -// '\documentclass{article}\usepackage{amsmath}\begin{document}' \ -// '$a$ \expandafter\show\the\textfont2' \ -// '\expandafter\show\the\scriptfont2' \ -// '\expandafter\show\the\scriptscriptfont2' \ -// '\stop' -// -// The metrics themselves were retreived using the following commands: -// -// tftopl cmsy10 -// tftopl cmsy7 -// tftopl cmsy5 -// -// The output of each of these commands is quite lengthy. The only part we -// care about is the FONTDIMEN section. Each value is measured in EMs. -var sigmasAndXis = { - slant: [0.250, 0.250, 0.250], - // sigma1 - space: [0.000, 0.000, 0.000], - // sigma2 - stretch: [0.000, 0.000, 0.000], - // sigma3 - shrink: [0.000, 0.000, 0.000], - // sigma4 - xHeight: [0.431, 0.431, 0.431], - // sigma5 - quad: [1.000, 1.171, 1.472], - // sigma6 - extraSpace: [0.000, 0.000, 0.000], - // sigma7 - num1: [0.677, 0.732, 0.925], - // sigma8 - num2: [0.394, 0.384, 0.387], - // sigma9 - num3: [0.444, 0.471, 0.504], - // sigma10 - denom1: [0.686, 0.752, 1.025], - // sigma11 - denom2: [0.345, 0.344, 0.532], - // sigma12 - sup1: [0.413, 0.503, 0.504], - // sigma13 - sup2: [0.363, 0.431, 0.404], - // sigma14 - sup3: [0.289, 0.286, 0.294], - // sigma15 - sub1: [0.150, 0.143, 0.200], - // sigma16 - sub2: [0.247, 0.286, 0.400], - // sigma17 - supDrop: [0.386, 0.353, 0.494], - // sigma18 - subDrop: [0.050, 0.071, 0.100], - // sigma19 - delim1: [2.390, 1.700, 1.980], - // sigma20 - delim2: [1.010, 1.157, 1.420], - // sigma21 - axisHeight: [0.250, 0.250, 0.250], - // sigma22 - // These font metrics are extracted from TeX by using tftopl on cmex10.tfm; - // they correspond to the font parameters of the extension fonts (family 3). - // See the TeXbook, page 441. In AMSTeX, the extension fonts scale; to - // match cmex7, we'd use cmex7.tfm values for script and scriptscript - // values. - defaultRuleThickness: [0.04, 0.049, 0.049], - // xi8; cmex7: 0.049 - bigOpSpacing1: [0.111, 0.111, 0.111], - // xi9 - bigOpSpacing2: [0.166, 0.166, 0.166], - // xi10 - bigOpSpacing3: [0.2, 0.2, 0.2], - // xi11 - bigOpSpacing4: [0.6, 0.611, 0.611], - // xi12; cmex7: 0.611 - bigOpSpacing5: [0.1, 0.143, 0.143], - // xi13; cmex7: 0.143 - // The \sqrt rule width is taken from the height of the surd character. - // Since we use the same font at all sizes, this thickness doesn't scale. - sqrtRuleThickness: [0.04, 0.04, 0.04], - // This value determines how large a pt is, for metrics which are defined - // in terms of pts. - // This value is also used in katex.less; if you change it make sure the - // values match. - ptPerEm: [10.0, 10.0, 10.0], - // The space between adjacent `|` columns in an array definition. From - // `\showthe\doublerulesep` in LaTeX. Equals 2.0 / ptPerEm. - doubleRuleSep: [0.2, 0.2, 0.2], - // The width of separator lines in {array} environments. From - // `\showthe\arrayrulewidth` in LaTeX. Equals 0.4 / ptPerEm. - arrayRuleWidth: [0.04, 0.04, 0.04], - // Two values from LaTeX source2e: - fboxsep: [0.3, 0.3, 0.3], - // 3 pt / ptPerEm - fboxrule: [0.04, 0.04, 0.04] // 0.4 pt / ptPerEm -}; // This map contains a mapping from font name and character code to character -// metrics, including height, depth, italic correction, and skew (kern from the -// character to the corresponding \skewchar) -// This map is generated via `make metrics`. It should not be changed manually. +var SymbolNode = /*#__PURE__*/function () { + function SymbolNode(text, height, depth, italic, skew, width, classes, style) { + this.text = void 0; + this.height = void 0; + this.depth = void 0; + this.italic = void 0; + this.skew = void 0; + this.width = void 0; + this.maxFontSize = void 0; + this.classes = void 0; + this.style = void 0; + this.text = text; + this.height = height || 0; + this.depth = depth || 0; + this.italic = italic || 0; + this.skew = skew || 0; + this.width = width || 0; + this.classes = classes || []; + this.style = style || {}; + this.maxFontSize = 0; // Mark text from non-Latin scripts with specific classes so that we + // can specify which fonts to use. This allows us to render these + // characters with a serif font in situations where the browser would + // either default to a sans serif or render a placeholder character. + // We use CSS class names like cjk_fallback, hangul_fallback and + // brahmic_fallback. See ./unicodeScripts.js for the set of possible + // script names + + var script = scriptFromCodepoint(this.text.charCodeAt(0)); + + if (script) { + this.classes.push(script + "_fallback"); + } + + if (/[îïíì]/.test(this.text)) { + // add ī when we add Extended Latin + this.text = iCombinations[this.text]; + } + } + + var _proto4 = SymbolNode.prototype; + + _proto4.hasClass = function hasClass(className) { + return utils.contains(this.classes, className); + } + /** + * Creates a text node or span from a symbol node. Note that a span is only + * created if it is needed. + */ + ; + + _proto4.toNode = function toNode() { + var node = document.createTextNode(this.text); + var span = null; + + if (this.italic > 0) { + span = document.createElement("span"); + span.style.marginRight = makeEm(this.italic); + } + + if (this.classes.length > 0) { + span = span || document.createElement("span"); + span.className = createClass(this.classes); + } + + for (var style in this.style) { + if (this.style.hasOwnProperty(style)) { + span = span || document.createElement("span"); // $FlowFixMe Flow doesn't seem to understand span.style's type. + + span.style[style] = this.style[style]; + } + } + + if (span) { + span.appendChild(node); + return span; + } else { + return node; + } + } + /** + * Creates markup for a symbol node. + */ + ; + + _proto4.toMarkup = function toMarkup() { + // TODO(alpert): More duplication than I'd like from + // span.prototype.toMarkup and symbolNode.prototype.toNode... + var needsSpan = false; + var markup = " 0) { + styles += "margin-right:" + this.italic + "em;"; + } + for (var style in this.style) { + if (this.style.hasOwnProperty(style)) { + styles += utils.hyphenate(style) + ":" + this.style[style] + ";"; + } + } + + if (styles) { + needsSpan = true; + markup += " style=\"" + utils.escape(styles) + "\""; + } + + var escaped = utils.escape(this.text); + + if (needsSpan) { + markup += ">"; + markup += escaped; + markup += ""; + return markup; + } else { + return escaped; + } + }; + + return SymbolNode; +}(); /** - * This function adds new font metrics to default metricMap - * It can also override existing metrics - */ -function setFontMetrics(fontName, metrics) { - fontMetricsData[fontName] = metrics; -} -/** - * This function is a convenience function for looking up information in the - * metricMap table. It takes a character as a string, and a font. - * - * Note: the `width` property may be undefined if fontMetricsData.js wasn't - * built using `Make extended_metrics`. + * SVG nodes are used to render stretchy wide elements. */ -function getCharacterMetrics(character, font, mode) { - if (!fontMetricsData[font]) { - throw new Error("Font metrics not found for font: " + font + "."); +var SvgNode = /*#__PURE__*/function () { + function SvgNode(children, attributes) { + this.children = void 0; + this.attributes = void 0; + this.children = children || []; + this.attributes = attributes || {}; } - var ch = character.charCodeAt(0); - var metrics = fontMetricsData[font][ch]; + var _proto5 = SvgNode.prototype; - if (!metrics && character[0] in extraCharacterMap) { - ch = extraCharacterMap[character[0]].charCodeAt(0); - metrics = fontMetricsData[font][ch]; - } + _proto5.toNode = function toNode() { + var svgNS = "http://www.w3.org/2000/svg"; + var node = document.createElementNS(svgNS, "svg"); // Apply attributes - if (!metrics && mode === 'text') { - // We don't typically have font metrics for Asian scripts. - // But since we support them in text mode, we need to return - // some sort of metrics. - // So if the character is in a script we support but we - // don't have metrics for it, just use the metrics for - // the Latin capital letter M. This is close enough because - // we (currently) only care about the height of the glpyh - // not its width. - if (supportedCodepoint(ch)) { - metrics = fontMetricsData[font][77]; // 77 is the charcode for 'M' + for (var attr in this.attributes) { + if (Object.prototype.hasOwnProperty.call(this.attributes, attr)) { + node.setAttribute(attr, this.attributes[attr]); + } + } + + for (var i = 0; i < this.children.length; i++) { + node.appendChild(this.children[i].toNode()); + } + + return node; + }; + + _proto5.toMarkup = function toMarkup() { + var markup = ""; + } else { + return ""; + } + }; + + return PathNode; +}(); +var LineNode = /*#__PURE__*/function () { + function LineNode(attributes) { + this.attributes = void 0; + this.attributes = attributes || {}; } -} -var fontMetricsBySizeIndex = {}; -/** - * Get the font metrics for a given size. - */ -function getGlobalMetrics(size) { - var sizeIndex; + var _proto7 = LineNode.prototype; + + _proto7.toNode = function toNode() { + var svgNS = "http://www.w3.org/2000/svg"; + var node = document.createElementNS(svgNS, "line"); // Apply attributes + + for (var attr in this.attributes) { + if (Object.prototype.hasOwnProperty.call(this.attributes, attr)) { + node.setAttribute(attr, this.attributes[attr]); + } + } - if (size >= 5) { - sizeIndex = 0; - } else if (size >= 3) { - sizeIndex = 1; - } else { - sizeIndex = 2; - } + return node; + }; - if (!fontMetricsBySizeIndex[sizeIndex]) { - var metrics = fontMetricsBySizeIndex[sizeIndex] = { - cssEmPerMu: sigmasAndXis.quad[sizeIndex] / 18 - }; + _proto7.toMarkup = function toMarkup() { + var markup = " but got " + String(group) + "."); + } } ;// CONCATENATED MODULE: ./src/symbols.js /** @@ -3918,8 +4482,10 @@ defineSymbol(math, main, textord, "\u211C", "\\Re", true); defineSymbol(math, main, textord, "\u2661", "\\heartsuit", true); defineSymbol(math, main, textord, "\u2111", "\\Im", true); defineSymbol(math, main, textord, "\u2660", "\\spadesuit", true); -defineSymbol(symbols_text, main, textord, "\xA7", "\\S", true); -defineSymbol(symbols_text, main, textord, "\xB6", "\\P", true); // Math and Text +defineSymbol(math, main, textord, "\xA7", "\\S", true); +defineSymbol(symbols_text, main, textord, "\xA7", "\\S"); +defineSymbol(math, main, textord, "\xB6", "\\P", true); +defineSymbol(symbols_text, main, textord, "\xB6", "\\P"); // Math and Text defineSymbol(math, main, textord, "\u2020", "\\dag"); defineSymbol(symbols_text, main, textord, "\u2020", "\\dag"); @@ -4295,9 +4861,9 @@ defineSymbol(math, main, mathord, "\u03D6", "\\varpi", true); defineSymbol(math, main, mathord, "\u03F1", "\\varrho", true); defineSymbol(math, main, mathord, "\u03C2", "\\varsigma", true); defineSymbol(math, main, mathord, "\u03C6", "\\varphi", true); -defineSymbol(math, main, bin, "\u2217", "*"); +defineSymbol(math, main, bin, "\u2217", "*", true); defineSymbol(math, main, bin, "+", "+"); -defineSymbol(math, main, bin, "\u2212", "-"); +defineSymbol(math, main, bin, "\u2212", "-", true); defineSymbol(math, main, bin, "\u22C5", "\\cdot", true); defineSymbol(math, main, bin, "\u2218", "\\circ"); defineSymbol(math, main, bin, "\xF7", "\\div", true); @@ -4345,13 +4911,11 @@ defineSymbol(math, main, rel, "\u2192", "\\to"); defineSymbol(math, ams, rel, "\u2271", "\\ngeq", true); defineSymbol(math, ams, rel, "\u2270", "\\nleq", true); defineSymbol(math, main, spacing, "\xA0", "\\ "); -defineSymbol(math, main, spacing, "\xA0", "~"); defineSymbol(math, main, spacing, "\xA0", "\\space"); // Ref: LaTeX Source 2e: \DeclareRobustCommand{\nobreakspace}{% defineSymbol(math, main, spacing, "\xA0", "\\nobreakspace"); defineSymbol(symbols_text, main, spacing, "\xA0", "\\ "); defineSymbol(symbols_text, main, spacing, "\xA0", " "); -defineSymbol(symbols_text, main, spacing, "\xA0", "~"); defineSymbol(symbols_text, main, spacing, "\xA0", "\\space"); defineSymbol(symbols_text, main, spacing, "\xA0", "\\nobreakspace"); defineSymbol(math, main, spacing, null, "\\nobreak"); @@ -4474,712 +5038,286 @@ defineSymbol(symbols_text, main, accent, "\u02C6", "\\^"); // circumflex defineSymbol(symbols_text, main, accent, "\u02DC", "\\~"); // tilde -defineSymbol(symbols_text, main, accent, "\u02C9", "\\="); // macron - -defineSymbol(symbols_text, main, accent, "\u02D8", "\\u"); // breve - -defineSymbol(symbols_text, main, accent, "\u02D9", "\\."); // dot above - -defineSymbol(symbols_text, main, accent, "\u02DA", "\\r"); // ring above - -defineSymbol(symbols_text, main, accent, "\u02C7", "\\v"); // caron - -defineSymbol(symbols_text, main, accent, "\xA8", '\\"'); // diaresis - -defineSymbol(symbols_text, main, accent, "\u02DD", "\\H"); // double acute - -defineSymbol(symbols_text, main, accent, "\u25EF", "\\textcircled"); // \bigcirc glyph -// These ligatures are detected and created in Parser.js's `formLigatures`. - -var ligatures = { - "--": true, - "---": true, - "``": true, - "''": true -}; -defineSymbol(symbols_text, main, textord, "\u2013", "--", true); -defineSymbol(symbols_text, main, textord, "\u2013", "\\textendash"); -defineSymbol(symbols_text, main, textord, "\u2014", "---", true); -defineSymbol(symbols_text, main, textord, "\u2014", "\\textemdash"); -defineSymbol(symbols_text, main, textord, "\u2018", "`", true); -defineSymbol(symbols_text, main, textord, "\u2018", "\\textquoteleft"); -defineSymbol(symbols_text, main, textord, "\u2019", "'", true); -defineSymbol(symbols_text, main, textord, "\u2019", "\\textquoteright"); -defineSymbol(symbols_text, main, textord, "\u201C", "``", true); -defineSymbol(symbols_text, main, textord, "\u201C", "\\textquotedblleft"); -defineSymbol(symbols_text, main, textord, "\u201D", "''", true); -defineSymbol(symbols_text, main, textord, "\u201D", "\\textquotedblright"); // \degree from gensymb package - -defineSymbol(math, main, textord, "\xB0", "\\degree", true); -defineSymbol(symbols_text, main, textord, "\xB0", "\\degree"); // \textdegree from inputenc package - -defineSymbol(symbols_text, main, textord, "\xB0", "\\textdegree", true); // TODO: In LaTeX, \pounds can generate a different character in text and math -// mode, but among our fonts, only Main-Regular defines this character "163". - -defineSymbol(math, main, textord, "\xA3", "\\pounds"); -defineSymbol(math, main, textord, "\xA3", "\\mathsterling", true); -defineSymbol(symbols_text, main, textord, "\xA3", "\\pounds"); -defineSymbol(symbols_text, main, textord, "\xA3", "\\textsterling", true); -defineSymbol(math, ams, textord, "\u2720", "\\maltese"); -defineSymbol(symbols_text, ams, textord, "\u2720", "\\maltese"); // There are lots of symbols which are the same, so we add them in afterwards. -// All of these are textords in math mode - -var mathTextSymbols = "0123456789/@.\""; - -for (var i = 0; i < mathTextSymbols.length; i++) { - var ch = mathTextSymbols.charAt(i); - defineSymbol(math, main, textord, ch, ch); -} // All of these are textords in text mode - - -var textSymbols = "0123456789!@*()-=+\";:?/.,"; - -for (var _i = 0; _i < textSymbols.length; _i++) { - var _ch = textSymbols.charAt(_i); - - defineSymbol(symbols_text, main, textord, _ch, _ch); -} // All of these are textords in text mode, and mathords in math mode - - -var letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; - -for (var _i2 = 0; _i2 < letters.length; _i2++) { - var _ch2 = letters.charAt(_i2); - - defineSymbol(math, main, mathord, _ch2, _ch2); - defineSymbol(symbols_text, main, textord, _ch2, _ch2); -} // Blackboard bold and script letters in Unicode range - - -defineSymbol(math, ams, textord, "C", "\u2102"); // blackboard bold - -defineSymbol(symbols_text, ams, textord, "C", "\u2102"); -defineSymbol(math, ams, textord, "H", "\u210D"); -defineSymbol(symbols_text, ams, textord, "H", "\u210D"); -defineSymbol(math, ams, textord, "N", "\u2115"); -defineSymbol(symbols_text, ams, textord, "N", "\u2115"); -defineSymbol(math, ams, textord, "P", "\u2119"); -defineSymbol(symbols_text, ams, textord, "P", "\u2119"); -defineSymbol(math, ams, textord, "Q", "\u211A"); -defineSymbol(symbols_text, ams, textord, "Q", "\u211A"); -defineSymbol(math, ams, textord, "R", "\u211D"); -defineSymbol(symbols_text, ams, textord, "R", "\u211D"); -defineSymbol(math, ams, textord, "Z", "\u2124"); -defineSymbol(symbols_text, ams, textord, "Z", "\u2124"); -defineSymbol(math, main, mathord, "h", "\u210E"); // italic h, Planck constant - -defineSymbol(symbols_text, main, mathord, "h", "\u210E"); // The next loop loads wide (surrogate pair) characters. -// We support some letters in the Unicode range U+1D400 to U+1D7FF, -// Mathematical Alphanumeric Symbols. -// Some editors do not deal well with wide characters. So don't write the -// string into this file. Instead, create the string from the surrogate pair. - -var wideChar = ""; - -for (var _i3 = 0; _i3 < letters.length; _i3++) { - var _ch3 = letters.charAt(_i3); // The hex numbers in the next line are a surrogate pair. - // 0xD835 is the high surrogate for all letters in the range we support. - // 0xDC00 is the low surrogate for bold A. - - - wideChar = String.fromCharCode(0xD835, 0xDC00 + _i3); // A-Z a-z bold - - defineSymbol(math, main, mathord, _ch3, wideChar); - defineSymbol(symbols_text, main, textord, _ch3, wideChar); - wideChar = String.fromCharCode(0xD835, 0xDC34 + _i3); // A-Z a-z italic - - defineSymbol(math, main, mathord, _ch3, wideChar); - defineSymbol(symbols_text, main, textord, _ch3, wideChar); - wideChar = String.fromCharCode(0xD835, 0xDC68 + _i3); // A-Z a-z bold italic - - defineSymbol(math, main, mathord, _ch3, wideChar); - defineSymbol(symbols_text, main, textord, _ch3, wideChar); - wideChar = String.fromCharCode(0xD835, 0xDD04 + _i3); // A-Z a-z Fractur - - defineSymbol(math, main, mathord, _ch3, wideChar); - defineSymbol(symbols_text, main, textord, _ch3, wideChar); - wideChar = String.fromCharCode(0xD835, 0xDDA0 + _i3); // A-Z a-z sans-serif - - defineSymbol(math, main, mathord, _ch3, wideChar); - defineSymbol(symbols_text, main, textord, _ch3, wideChar); - wideChar = String.fromCharCode(0xD835, 0xDDD4 + _i3); // A-Z a-z sans bold - - defineSymbol(math, main, mathord, _ch3, wideChar); - defineSymbol(symbols_text, main, textord, _ch3, wideChar); - wideChar = String.fromCharCode(0xD835, 0xDE08 + _i3); // A-Z a-z sans italic - - defineSymbol(math, main, mathord, _ch3, wideChar); - defineSymbol(symbols_text, main, textord, _ch3, wideChar); - wideChar = String.fromCharCode(0xD835, 0xDE70 + _i3); // A-Z a-z monospace - - defineSymbol(math, main, mathord, _ch3, wideChar); - defineSymbol(symbols_text, main, textord, _ch3, wideChar); - - if (_i3 < 26) { - // KaTeX fonts have only capital letters for blackboard bold and script. - // See exception for k below. - wideChar = String.fromCharCode(0xD835, 0xDD38 + _i3); // A-Z double struck - - defineSymbol(math, main, mathord, _ch3, wideChar); - defineSymbol(symbols_text, main, textord, _ch3, wideChar); - wideChar = String.fromCharCode(0xD835, 0xDC9C + _i3); // A-Z script - - defineSymbol(math, main, mathord, _ch3, wideChar); - defineSymbol(symbols_text, main, textord, _ch3, wideChar); - } // TODO: Add bold script when it is supported by a KaTeX font. - -} // "k" is the only double struck lower case letter in the KaTeX fonts. - - -wideChar = String.fromCharCode(0xD835, 0xDD5C); // k double struck - -defineSymbol(math, main, mathord, "k", wideChar); -defineSymbol(symbols_text, main, textord, "k", wideChar); // Next, some wide character numerals - -for (var _i4 = 0; _i4 < 10; _i4++) { - var _ch4 = _i4.toString(); - - wideChar = String.fromCharCode(0xD835, 0xDFCE + _i4); // 0-9 bold - - defineSymbol(math, main, mathord, _ch4, wideChar); - defineSymbol(symbols_text, main, textord, _ch4, wideChar); - wideChar = String.fromCharCode(0xD835, 0xDFE2 + _i4); // 0-9 sans serif - - defineSymbol(math, main, mathord, _ch4, wideChar); - defineSymbol(symbols_text, main, textord, _ch4, wideChar); - wideChar = String.fromCharCode(0xD835, 0xDFEC + _i4); // 0-9 bold sans - - defineSymbol(math, main, mathord, _ch4, wideChar); - defineSymbol(symbols_text, main, textord, _ch4, wideChar); - wideChar = String.fromCharCode(0xD835, 0xDFF6 + _i4); // 0-9 monospace - - defineSymbol(math, main, mathord, _ch4, wideChar); - defineSymbol(symbols_text, main, textord, _ch4, wideChar); -} // We add these Latin-1 letters as symbols for backwards-compatibility, -// but they are not actually in the font, nor are they supported by the -// Unicode accent mechanism, so they fall back to Times font and look ugly. -// TODO(edemaine): Fix this. - - -var extraLatin = "\xC7\xD0\xDE\xE7\xFE"; - -for (var _i5 = 0; _i5 < extraLatin.length; _i5++) { - var _ch5 = extraLatin.charAt(_i5); - - defineSymbol(math, main, mathord, _ch5, _ch5); - defineSymbol(symbols_text, main, textord, _ch5, _ch5); -} -;// CONCATENATED MODULE: ./src/wide-character.js -/** - * This file provides support for Unicode range U+1D400 to U+1D7FF, - * Mathematical Alphanumeric Symbols. - * - * Function wideCharacterFont takes a wide character as input and returns - * the font information necessary to render it properly. - */ - -/** - * Data below is from https://www.unicode.org/charts/PDF/U1D400.pdf - * That document sorts characters into groups by font type, say bold or italic. - * - * In the arrays below, each subarray consists three elements: - * * The CSS class of that group when in math mode. - * * The CSS class of that group when in text mode. - * * The font name, so that KaTeX can get font metrics. - */ +defineSymbol(symbols_text, main, accent, "\u02C9", "\\="); // macron -var wideLatinLetterData = [["mathbf", "textbf", "Main-Bold"], // A-Z bold upright -["mathbf", "textbf", "Main-Bold"], // a-z bold upright -["mathnormal", "textit", "Math-Italic"], // A-Z italic -["mathnormal", "textit", "Math-Italic"], // a-z italic -["boldsymbol", "boldsymbol", "Main-BoldItalic"], // A-Z bold italic -["boldsymbol", "boldsymbol", "Main-BoldItalic"], // a-z bold italic -// Map fancy A-Z letters to script, not calligraphic. -// This aligns with unicode-math and math fonts (except Cambria Math). -["mathscr", "textscr", "Script-Regular"], // A-Z script -["", "", ""], // a-z script. No font -["", "", ""], // A-Z bold script. No font -["", "", ""], // a-z bold script. No font -["mathfrak", "textfrak", "Fraktur-Regular"], // A-Z Fraktur -["mathfrak", "textfrak", "Fraktur-Regular"], // a-z Fraktur -["mathbb", "textbb", "AMS-Regular"], // A-Z double-struck -["mathbb", "textbb", "AMS-Regular"], // k double-struck -["", "", ""], // A-Z bold Fraktur No font metrics -["", "", ""], // a-z bold Fraktur. No font. -["mathsf", "textsf", "SansSerif-Regular"], // A-Z sans-serif -["mathsf", "textsf", "SansSerif-Regular"], // a-z sans-serif -["mathboldsf", "textboldsf", "SansSerif-Bold"], // A-Z bold sans-serif -["mathboldsf", "textboldsf", "SansSerif-Bold"], // a-z bold sans-serif -["mathitsf", "textitsf", "SansSerif-Italic"], // A-Z italic sans-serif -["mathitsf", "textitsf", "SansSerif-Italic"], // a-z italic sans-serif -["", "", ""], // A-Z bold italic sans. No font -["", "", ""], // a-z bold italic sans. No font -["mathtt", "texttt", "Typewriter-Regular"], // A-Z monospace -["mathtt", "texttt", "Typewriter-Regular"] // a-z monospace -]; -var wideNumeralData = [["mathbf", "textbf", "Main-Bold"], // 0-9 bold -["", "", ""], // 0-9 double-struck. No KaTeX font. -["mathsf", "textsf", "SansSerif-Regular"], // 0-9 sans-serif -["mathboldsf", "textboldsf", "SansSerif-Bold"], // 0-9 bold sans-serif -["mathtt", "texttt", "Typewriter-Regular"] // 0-9 monospace -]; -var wideCharacterFont = function wideCharacterFont(wideChar, mode) { - // IE doesn't support codePointAt(). So work with the surrogate pair. - var H = wideChar.charCodeAt(0); // high surrogate +defineSymbol(symbols_text, main, accent, "\u02D8", "\\u"); // breve - var L = wideChar.charCodeAt(1); // low surrogate +defineSymbol(symbols_text, main, accent, "\u02D9", "\\."); // dot above - var codePoint = (H - 0xD800) * 0x400 + (L - 0xDC00) + 0x10000; - var j = mode === "math" ? 0 : 1; // column index for CSS class. +defineSymbol(symbols_text, main, accent, "\xB8", "\\c"); // cedilla - if (0x1D400 <= codePoint && codePoint < 0x1D6A4) { - // wideLatinLetterData contains exactly 26 chars on each row. - // So we can calculate the relevant row. No traverse necessary. - var i = Math.floor((codePoint - 0x1D400) / 26); - return [wideLatinLetterData[i][2], wideLatinLetterData[i][j]]; - } else if (0x1D7CE <= codePoint && codePoint <= 0x1D7FF) { - // Numerals, ten per row. - var _i = Math.floor((codePoint - 0x1D7CE) / 10); +defineSymbol(symbols_text, main, accent, "\u02DA", "\\r"); // ring above - return [wideNumeralData[_i][2], wideNumeralData[_i][j]]; - } else if (codePoint === 0x1D6A5 || codePoint === 0x1D6A6) { - // dotless i or j - return [wideLatinLetterData[0][2], wideLatinLetterData[0][j]]; - } else if (0x1D6A6 < codePoint && codePoint < 0x1D7CE) { - // Greek letters. Not supported, yet. - return ["", ""]; - } else { - // We don't support any wide characters outside 1D400–1D7FF. - throw new src_ParseError("Unsupported character: " + wideChar); - } +defineSymbol(symbols_text, main, accent, "\u02C7", "\\v"); // caron + +defineSymbol(symbols_text, main, accent, "\xA8", '\\"'); // diaresis + +defineSymbol(symbols_text, main, accent, "\u02DD", "\\H"); // double acute + +defineSymbol(symbols_text, main, accent, "\u25EF", "\\textcircled"); // \bigcirc glyph +// These ligatures are detected and created in Parser.js's `formLigatures`. + +var ligatures = { + "--": true, + "---": true, + "``": true, + "''": true }; -;// CONCATENATED MODULE: ./src/Options.js -/** - * This file contains information about the options that the Parser carries - * around with it while parsing. Data is held in an `Options` object, and when - * recursing, a new `Options` object can be created with the `.with*` and - * `.reset` functions. - */ +defineSymbol(symbols_text, main, textord, "\u2013", "--", true); +defineSymbol(symbols_text, main, textord, "\u2013", "\\textendash"); +defineSymbol(symbols_text, main, textord, "\u2014", "---", true); +defineSymbol(symbols_text, main, textord, "\u2014", "\\textemdash"); +defineSymbol(symbols_text, main, textord, "\u2018", "`", true); +defineSymbol(symbols_text, main, textord, "\u2018", "\\textquoteleft"); +defineSymbol(symbols_text, main, textord, "\u2019", "'", true); +defineSymbol(symbols_text, main, textord, "\u2019", "\\textquoteright"); +defineSymbol(symbols_text, main, textord, "\u201C", "``", true); +defineSymbol(symbols_text, main, textord, "\u201C", "\\textquotedblleft"); +defineSymbol(symbols_text, main, textord, "\u201D", "''", true); +defineSymbol(symbols_text, main, textord, "\u201D", "\\textquotedblright"); // \degree from gensymb package -var sizeStyleMap = [// Each element contains [textsize, scriptsize, scriptscriptsize]. -// The size mappings are taken from TeX with \normalsize=10pt. -[1, 1, 1], // size1: [5, 5, 5] \tiny -[2, 1, 1], // size2: [6, 5, 5] -[3, 1, 1], // size3: [7, 5, 5] \scriptsize -[4, 2, 1], // size4: [8, 6, 5] \footnotesize -[5, 2, 1], // size5: [9, 6, 5] \small -[6, 3, 1], // size6: [10, 7, 5] \normalsize -[7, 4, 2], // size7: [12, 8, 6] \large -[8, 6, 3], // size8: [14.4, 10, 7] \Large -[9, 7, 6], // size9: [17.28, 12, 10] \LARGE -[10, 8, 7], // size10: [20.74, 14.4, 12] \huge -[11, 10, 9] // size11: [24.88, 20.74, 17.28] \HUGE -]; -var sizeMultipliers = [// fontMetrics.js:getGlobalMetrics also uses size indexes, so if -// you change size indexes, change that function. -0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.2, 1.44, 1.728, 2.074, 2.488]; +defineSymbol(math, main, textord, "\xB0", "\\degree", true); +defineSymbol(symbols_text, main, textord, "\xB0", "\\degree"); // \textdegree from inputenc package -var sizeAtStyle = function sizeAtStyle(size, style) { - return style.size < 2 ? size : sizeStyleMap[size - 1][style.size - 1]; -}; // In these types, "" (empty string) means "no change". +defineSymbol(symbols_text, main, textord, "\xB0", "\\textdegree", true); // TODO: In LaTeX, \pounds can generate a different character in text and math +// mode, but among our fonts, only Main-Regular defines this character "163". +defineSymbol(math, main, textord, "\xA3", "\\pounds"); +defineSymbol(math, main, textord, "\xA3", "\\mathsterling", true); +defineSymbol(symbols_text, main, textord, "\xA3", "\\pounds"); +defineSymbol(symbols_text, main, textord, "\xA3", "\\textsterling", true); +defineSymbol(math, ams, textord, "\u2720", "\\maltese"); +defineSymbol(symbols_text, ams, textord, "\u2720", "\\maltese"); // There are lots of symbols which are the same, so we add them in afterwards. +// All of these are textords in math mode -/** - * This is the main options class. It contains the current style, size, color, - * and font. - * - * Options objects should not be modified. To create a new Options with - * different properties, call a `.having*` method. - */ -var Options = /*#__PURE__*/function () { - // A font family applies to a group of fonts (i.e. SansSerif), while a font - // represents a specific font (i.e. SansSerif Bold). - // See: https://tex.stackexchange.com/questions/22350/difference-between-textrm-and-mathrm +var mathTextSymbols = "0123456789/@.\""; - /** - * The base size index. - */ - function Options(data) { - this.style = void 0; - this.color = void 0; - this.size = void 0; - this.textSize = void 0; - this.phantom = void 0; - this.font = void 0; - this.fontFamily = void 0; - this.fontWeight = void 0; - this.fontShape = void 0; - this.sizeMultiplier = void 0; - this.maxSize = void 0; - this.minRuleThickness = void 0; - this._fontMetrics = void 0; - this.style = data.style; - this.color = data.color; - this.size = data.size || Options.BASESIZE; - this.textSize = data.textSize || this.size; - this.phantom = !!data.phantom; - this.font = data.font || ""; - this.fontFamily = data.fontFamily || ""; - this.fontWeight = data.fontWeight || ''; - this.fontShape = data.fontShape || ''; - this.sizeMultiplier = sizeMultipliers[this.size - 1]; - this.maxSize = data.maxSize; - this.minRuleThickness = data.minRuleThickness; - this._fontMetrics = undefined; - } - /** - * Returns a new options object with the same properties as "this". Properties - * from "extension" will be copied to the new options object. - */ +for (var i = 0; i < mathTextSymbols.length; i++) { + var ch = mathTextSymbols.charAt(i); + defineSymbol(math, main, textord, ch, ch); +} // All of these are textords in text mode - var _proto = Options.prototype; +var textSymbols = "0123456789!@*()-=+\";:?/.,"; - _proto.extend = function extend(extension) { - var data = { - style: this.style, - size: this.size, - textSize: this.textSize, - color: this.color, - phantom: this.phantom, - font: this.font, - fontFamily: this.fontFamily, - fontWeight: this.fontWeight, - fontShape: this.fontShape, - maxSize: this.maxSize, - minRuleThickness: this.minRuleThickness - }; +for (var _i = 0; _i < textSymbols.length; _i++) { + var _ch = textSymbols.charAt(_i); - for (var key in extension) { - if (extension.hasOwnProperty(key)) { - data[key] = extension[key]; - } - } + defineSymbol(symbols_text, main, textord, _ch, _ch); +} // All of these are textords in text mode, and mathords in math mode - return new Options(data); - } - /** - * Return an options object with the given style. If `this.style === style`, - * returns `this`. - */ - ; - _proto.havingStyle = function havingStyle(style) { - if (this.style === style) { - return this; - } else { - return this.extend({ - style: style, - size: sizeAtStyle(this.textSize, style) - }); - } - } - /** - * Return an options object with a cramped version of the current style. If - * the current style is cramped, returns `this`. - */ - ; +var letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; - _proto.havingCrampedStyle = function havingCrampedStyle() { - return this.havingStyle(this.style.cramp()); - } - /** - * Return an options object with the given size and in at least `\textstyle`. - * Returns `this` if appropriate. - */ - ; +for (var _i2 = 0; _i2 < letters.length; _i2++) { + var _ch2 = letters.charAt(_i2); - _proto.havingSize = function havingSize(size) { - if (this.size === size && this.textSize === size) { - return this; - } else { - return this.extend({ - style: this.style.text(), - size: size, - textSize: size, - sizeMultiplier: sizeMultipliers[size - 1] - }); - } - } - /** - * Like `this.havingSize(BASESIZE).havingStyle(style)`. If `style` is omitted, - * changes to at least `\textstyle`. - */ - ; + defineSymbol(math, main, mathord, _ch2, _ch2); + defineSymbol(symbols_text, main, textord, _ch2, _ch2); +} // Blackboard bold and script letters in Unicode range - _proto.havingBaseStyle = function havingBaseStyle(style) { - style = style || this.style.text(); - var wantSize = sizeAtStyle(Options.BASESIZE, style); - if (this.size === wantSize && this.textSize === Options.BASESIZE && this.style === style) { - return this; - } else { - return this.extend({ - style: style, - size: wantSize - }); - } - } - /** - * Remove the effect of sizing changes such as \Huge. - * Keep the effect of the current style, such as \scriptstyle. - */ - ; +defineSymbol(math, ams, textord, "C", "\u2102"); // blackboard bold - _proto.havingBaseSizing = function havingBaseSizing() { - var size; +defineSymbol(symbols_text, ams, textord, "C", "\u2102"); +defineSymbol(math, ams, textord, "H", "\u210D"); +defineSymbol(symbols_text, ams, textord, "H", "\u210D"); +defineSymbol(math, ams, textord, "N", "\u2115"); +defineSymbol(symbols_text, ams, textord, "N", "\u2115"); +defineSymbol(math, ams, textord, "P", "\u2119"); +defineSymbol(symbols_text, ams, textord, "P", "\u2119"); +defineSymbol(math, ams, textord, "Q", "\u211A"); +defineSymbol(symbols_text, ams, textord, "Q", "\u211A"); +defineSymbol(math, ams, textord, "R", "\u211D"); +defineSymbol(symbols_text, ams, textord, "R", "\u211D"); +defineSymbol(math, ams, textord, "Z", "\u2124"); +defineSymbol(symbols_text, ams, textord, "Z", "\u2124"); +defineSymbol(math, main, mathord, "h", "\u210E"); // italic h, Planck constant - switch (this.style.id) { - case 4: - case 5: - size = 3; // normalsize in scriptstyle +defineSymbol(symbols_text, main, mathord, "h", "\u210E"); // The next loop loads wide (surrogate pair) characters. +// We support some letters in the Unicode range U+1D400 to U+1D7FF, +// Mathematical Alphanumeric Symbols. +// Some editors do not deal well with wide characters. So don't write the +// string into this file. Instead, create the string from the surrogate pair. - break; +var wideChar = ""; - case 6: - case 7: - size = 1; // normalsize in scriptscriptstyle +for (var _i3 = 0; _i3 < letters.length; _i3++) { + var _ch3 = letters.charAt(_i3); // The hex numbers in the next line are a surrogate pair. + // 0xD835 is the high surrogate for all letters in the range we support. + // 0xDC00 is the low surrogate for bold A. - break; - default: - size = 6; - // normalsize in textstyle or displaystyle - } + wideChar = String.fromCharCode(0xD835, 0xDC00 + _i3); // A-Z a-z bold - return this.extend({ - style: this.style.text(), - size: size - }); - } - /** - * Create a new options object with the given color. - */ - ; + defineSymbol(math, main, mathord, _ch3, wideChar); + defineSymbol(symbols_text, main, textord, _ch3, wideChar); + wideChar = String.fromCharCode(0xD835, 0xDC34 + _i3); // A-Z a-z italic - _proto.withColor = function withColor(color) { - return this.extend({ - color: color - }); - } - /** - * Create a new options object with "phantom" set to true. - */ - ; + defineSymbol(math, main, mathord, _ch3, wideChar); + defineSymbol(symbols_text, main, textord, _ch3, wideChar); + wideChar = String.fromCharCode(0xD835, 0xDC68 + _i3); // A-Z a-z bold italic - _proto.withPhantom = function withPhantom() { - return this.extend({ - phantom: true - }); - } - /** - * Creates a new options object with the given math font or old text font. - * @type {[type]} - */ - ; + defineSymbol(math, main, mathord, _ch3, wideChar); + defineSymbol(symbols_text, main, textord, _ch3, wideChar); + wideChar = String.fromCharCode(0xD835, 0xDD04 + _i3); // A-Z a-z Fractur - _proto.withFont = function withFont(font) { - return this.extend({ - font: font - }); - } - /** - * Create a new options objects with the given fontFamily. - */ - ; + defineSymbol(math, main, mathord, _ch3, wideChar); + defineSymbol(symbols_text, main, textord, _ch3, wideChar); + wideChar = String.fromCharCode(0xD835, 0xDDA0 + _i3); // A-Z a-z sans-serif - _proto.withTextFontFamily = function withTextFontFamily(fontFamily) { - return this.extend({ - fontFamily: fontFamily, - font: "" - }); - } - /** - * Creates a new options object with the given font weight - */ - ; + defineSymbol(math, main, mathord, _ch3, wideChar); + defineSymbol(symbols_text, main, textord, _ch3, wideChar); + wideChar = String.fromCharCode(0xD835, 0xDDD4 + _i3); // A-Z a-z sans bold - _proto.withTextFontWeight = function withTextFontWeight(fontWeight) { - return this.extend({ - fontWeight: fontWeight, - font: "" - }); - } - /** - * Creates a new options object with the given font weight - */ - ; + defineSymbol(math, main, mathord, _ch3, wideChar); + defineSymbol(symbols_text, main, textord, _ch3, wideChar); + wideChar = String.fromCharCode(0xD835, 0xDE08 + _i3); // A-Z a-z sans italic - _proto.withTextFontShape = function withTextFontShape(fontShape) { - return this.extend({ - fontShape: fontShape, - font: "" - }); - } - /** - * Return the CSS sizing classes required to switch from enclosing options - * `oldOptions` to `this`. Returns an array of classes. - */ - ; + defineSymbol(math, main, mathord, _ch3, wideChar); + defineSymbol(symbols_text, main, textord, _ch3, wideChar); + wideChar = String.fromCharCode(0xD835, 0xDE70 + _i3); // A-Z a-z monospace - _proto.sizingClasses = function sizingClasses(oldOptions) { - if (oldOptions.size !== this.size) { - return ["sizing", "reset-size" + oldOptions.size, "size" + this.size]; - } else { - return []; - } - } - /** - * Return the CSS sizing classes required to switch to the base size. Like - * `this.havingSize(BASESIZE).sizingClasses(this)`. - */ - ; + defineSymbol(math, main, mathord, _ch3, wideChar); + defineSymbol(symbols_text, main, textord, _ch3, wideChar); - _proto.baseSizingClasses = function baseSizingClasses() { - if (this.size !== Options.BASESIZE) { - return ["sizing", "reset-size" + this.size, "size" + Options.BASESIZE]; - } else { - return []; - } - } - /** - * Return the font metrics for this size. - */ - ; + if (_i3 < 26) { + // KaTeX fonts have only capital letters for blackboard bold and script. + // See exception for k below. + wideChar = String.fromCharCode(0xD835, 0xDD38 + _i3); // A-Z double struck - _proto.fontMetrics = function fontMetrics() { - if (!this._fontMetrics) { - this._fontMetrics = getGlobalMetrics(this.size); - } + defineSymbol(math, main, mathord, _ch3, wideChar); + defineSymbol(symbols_text, main, textord, _ch3, wideChar); + wideChar = String.fromCharCode(0xD835, 0xDC9C + _i3); // A-Z script - return this._fontMetrics; - } - /** - * Gets the CSS color of the current options object - */ - ; + defineSymbol(math, main, mathord, _ch3, wideChar); + defineSymbol(symbols_text, main, textord, _ch3, wideChar); + } // TODO: Add bold script when it is supported by a KaTeX font. - _proto.getColor = function getColor() { - if (this.phantom) { - return "transparent"; - } else { - return this.color; - } - }; +} // "k" is the only double struck lower case letter in the KaTeX fonts. - return Options; -}(); -Options.BASESIZE = 6; -/* harmony default export */ var src_Options = (Options); -;// CONCATENATED MODULE: ./src/units.js -/** - * This file does conversion between units. In particular, it provides - * calculateSize to convert other units into ems. - */ +wideChar = String.fromCharCode(0xD835, 0xDD5C); // k double struck - // This table gives the number of TeX pts in one of each *absolute* TeX unit. -// Thus, multiplying a length by this number converts the length from units -// into pts. Dividing the result by ptPerEm gives the number of ems -// *assuming* a font size of ptPerEm (normal size, normal style). +defineSymbol(math, main, mathord, "k", wideChar); +defineSymbol(symbols_text, main, textord, "k", wideChar); // Next, some wide character numerals -var ptPerUnit = { - // https://en.wikibooks.org/wiki/LaTeX/Lengths and - // https://tex.stackexchange.com/a/8263 - "pt": 1, - // TeX point - "mm": 7227 / 2540, - // millimeter - "cm": 7227 / 254, - // centimeter - "in": 72.27, - // inch - "bp": 803 / 800, - // big (PostScript) points - "pc": 12, - // pica - "dd": 1238 / 1157, - // didot - "cc": 14856 / 1157, - // cicero (12 didot) - "nd": 685 / 642, - // new didot - "nc": 1370 / 107, - // new cicero (12 new didot) - "sp": 1 / 65536, - // scaled point (TeX's internal smallest unit) - // https://tex.stackexchange.com/a/41371 - "px": 803 / 800 // \pdfpxdimen defaults to 1 bp in pdfTeX and LuaTeX +for (var _i4 = 0; _i4 < 10; _i4++) { + var _ch4 = _i4.toString(); + + wideChar = String.fromCharCode(0xD835, 0xDFCE + _i4); // 0-9 bold + + defineSymbol(math, main, mathord, _ch4, wideChar); + defineSymbol(symbols_text, main, textord, _ch4, wideChar); + wideChar = String.fromCharCode(0xD835, 0xDFE2 + _i4); // 0-9 sans serif + + defineSymbol(math, main, mathord, _ch4, wideChar); + defineSymbol(symbols_text, main, textord, _ch4, wideChar); + wideChar = String.fromCharCode(0xD835, 0xDFEC + _i4); // 0-9 bold sans -}; // Dictionary of relative units, for fast validity testing. + defineSymbol(math, main, mathord, _ch4, wideChar); + defineSymbol(symbols_text, main, textord, _ch4, wideChar); + wideChar = String.fromCharCode(0xD835, 0xDFF6 + _i4); // 0-9 monospace + + defineSymbol(math, main, mathord, _ch4, wideChar); + defineSymbol(symbols_text, main, textord, _ch4, wideChar); +} // We add these Latin-1 letters as symbols for backwards-compatibility, +// but they are not actually in the font, nor are they supported by the +// Unicode accent mechanism, so they fall back to Times font and look ugly. +// TODO(edemaine): Fix this. -var relativeUnit = { - "ex": true, - "em": true, - "mu": true -}; +var extraLatin = "\xD0\xDE\xFE"; + +for (var _i5 = 0; _i5 < extraLatin.length; _i5++) { + var _ch5 = extraLatin.charAt(_i5); + + defineSymbol(math, main, mathord, _ch5, _ch5); + defineSymbol(symbols_text, main, textord, _ch5, _ch5); +} +;// CONCATENATED MODULE: ./src/wide-character.js /** - * Determine whether the specified unit (either a string defining the unit - * or a "size" parse node containing a unit field) is valid. + * This file provides support for Unicode range U+1D400 to U+1D7FF, + * Mathematical Alphanumeric Symbols. + * + * Function wideCharacterFont takes a wide character as input and returns + * the font information necessary to render it properly. */ -var validUnit = function validUnit(unit) { - if (typeof unit !== "string") { - unit = unit.unit; - } - return unit in ptPerUnit || unit in relativeUnit || unit === "ex"; -}; -/* - * Convert a "size" parse node (with numeric "number" and string "unit" fields, - * as parsed by functions.js argType "size") into a CSS em value for the - * current style/scale. `options` gives the current options. +/** + * Data below is from https://www.unicode.org/charts/PDF/U1D400.pdf + * That document sorts characters into groups by font type, say bold or italic. + * + * In the arrays below, each subarray consists three elements: + * * The CSS class of that group when in math mode. + * * The CSS class of that group when in text mode. + * * The font name, so that KaTeX can get font metrics. */ -var calculateSize = function calculateSize(sizeValue, options) { - var scale; - - if (sizeValue.unit in ptPerUnit) { - // Absolute units - scale = ptPerUnit[sizeValue.unit] // Convert unit to pt - / options.fontMetrics().ptPerEm // Convert pt to CSS em - / options.sizeMultiplier; // Unscale to make absolute units - } else if (sizeValue.unit === "mu") { - // `mu` units scale with scriptstyle/scriptscriptstyle. - scale = options.fontMetrics().cssEmPerMu; - } else { - // Other relative units always refer to the *textstyle* font - // in the current size. - var unitOptions; +var wideLatinLetterData = [["mathbf", "textbf", "Main-Bold"], // A-Z bold upright +["mathbf", "textbf", "Main-Bold"], // a-z bold upright +["mathnormal", "textit", "Math-Italic"], // A-Z italic +["mathnormal", "textit", "Math-Italic"], // a-z italic +["boldsymbol", "boldsymbol", "Main-BoldItalic"], // A-Z bold italic +["boldsymbol", "boldsymbol", "Main-BoldItalic"], // a-z bold italic +// Map fancy A-Z letters to script, not calligraphic. +// This aligns with unicode-math and math fonts (except Cambria Math). +["mathscr", "textscr", "Script-Regular"], // A-Z script +["", "", ""], // a-z script. No font +["", "", ""], // A-Z bold script. No font +["", "", ""], // a-z bold script. No font +["mathfrak", "textfrak", "Fraktur-Regular"], // A-Z Fraktur +["mathfrak", "textfrak", "Fraktur-Regular"], // a-z Fraktur +["mathbb", "textbb", "AMS-Regular"], // A-Z double-struck +["mathbb", "textbb", "AMS-Regular"], // k double-struck +["", "", ""], // A-Z bold Fraktur No font metrics +["", "", ""], // a-z bold Fraktur. No font. +["mathsf", "textsf", "SansSerif-Regular"], // A-Z sans-serif +["mathsf", "textsf", "SansSerif-Regular"], // a-z sans-serif +["mathboldsf", "textboldsf", "SansSerif-Bold"], // A-Z bold sans-serif +["mathboldsf", "textboldsf", "SansSerif-Bold"], // a-z bold sans-serif +["mathitsf", "textitsf", "SansSerif-Italic"], // A-Z italic sans-serif +["mathitsf", "textitsf", "SansSerif-Italic"], // a-z italic sans-serif +["", "", ""], // A-Z bold italic sans. No font +["", "", ""], // a-z bold italic sans. No font +["mathtt", "texttt", "Typewriter-Regular"], // A-Z monospace +["mathtt", "texttt", "Typewriter-Regular"] // a-z monospace +]; +var wideNumeralData = [["mathbf", "textbf", "Main-Bold"], // 0-9 bold +["", "", ""], // 0-9 double-struck. No KaTeX font. +["mathsf", "textsf", "SansSerif-Regular"], // 0-9 sans-serif +["mathboldsf", "textboldsf", "SansSerif-Bold"], // 0-9 bold sans-serif +["mathtt", "texttt", "Typewriter-Regular"] // 0-9 monospace +]; +var wideCharacterFont = function wideCharacterFont(wideChar, mode) { + // IE doesn't support codePointAt(). So work with the surrogate pair. + var H = wideChar.charCodeAt(0); // high surrogate - if (options.style.isTight()) { - // isTight() means current style is script/scriptscript. - unitOptions = options.havingStyle(options.style.text()); - } else { - unitOptions = options; - } // TODO: In TeX these units are relative to the quad of the current - // *text* font, e.g. cmr10. KaTeX instead uses values from the - // comparably-sized *Computer Modern symbol* font. At 10pt, these - // match. At 7pt and 5pt, they differ: cmr7=1.138894, cmsy7=1.170641; - // cmr5=1.361133, cmsy5=1.472241. Consider $\scriptsize a\kern1emb$. - // TeX \showlists shows a kern of 1.13889 * fontsize; - // KaTeX shows a kern of 1.171 * fontsize. + var L = wideChar.charCodeAt(1); // low surrogate + var codePoint = (H - 0xD800) * 0x400 + (L - 0xDC00) + 0x10000; + var j = mode === "math" ? 0 : 1; // column index for CSS class. - if (sizeValue.unit === "ex") { - scale = unitOptions.fontMetrics().xHeight; - } else if (sizeValue.unit === "em") { - scale = unitOptions.fontMetrics().quad; - } else { - throw new src_ParseError("Invalid unit: '" + sizeValue.unit + "'"); - } + if (0x1D400 <= codePoint && codePoint < 0x1D6A4) { + // wideLatinLetterData contains exactly 26 chars on each row. + // So we can calculate the relevant row. No traverse necessary. + var i = Math.floor((codePoint - 0x1D400) / 26); + return [wideLatinLetterData[i][2], wideLatinLetterData[i][j]]; + } else if (0x1D7CE <= codePoint && codePoint <= 0x1D7FF) { + // Numerals, ten per row. + var _i = Math.floor((codePoint - 0x1D7CE) / 10); - if (unitOptions !== options) { - scale *= unitOptions.sizeMultiplier / options.sizeMultiplier; - } + return [wideNumeralData[_i][2], wideNumeralData[_i][j]]; + } else if (codePoint === 0x1D6A5 || codePoint === 0x1D6A6) { + // dotless i or j + return [wideLatinLetterData[0][2], wideLatinLetterData[0][j]]; + } else if (0x1D6A6 < codePoint && codePoint < 0x1D7CE) { + // Greek letters. Not supported, yet. + return ["", ""]; + } else { + // We don't support any wide characters outside 1D400–1D7FF. + throw new src_ParseError("Unsupported character: " + wideChar); } - - return Math.min(sizeValue.number * scale, options.maxSize); }; ;// CONCATENATED MODULE: ./src/buildCommon.js /* eslint no-console:0 */ @@ -5500,7 +5638,7 @@ var makeSvgSpan = function makeSvgSpan(classes, children, options, style) { var makeLineSpan = function makeLineSpan(className, options, thickness) { var line = makeSpan([className], [], options); line.height = Math.max(thickness || options.fontMetrics().defaultRuleThickness, options.minRuleThickness); - line.style.borderBottomWidth = line.height + "em"; + line.style.borderBottomWidth = makeEm(line.height); line.maxFontSize = 1.0; return line; }; @@ -5640,7 +5778,7 @@ var makeVList = function makeVList(params, options) { pstrutSize += 2; var pstrut = makeSpan(["pstrut"], []); - pstrut.style.height = pstrutSize + "em"; // Create a new list of actual children at the correct offsets + pstrut.style.height = makeEm(pstrutSize); // Create a new list of actual children at the correct offsets var realChildren = []; var minPos = depth; @@ -5657,7 +5795,7 @@ var makeVList = function makeVList(params, options) { var classes = _child.wrapperClasses || []; var style = _child.wrapperStyle || {}; var childWrap = makeSpan(classes, [pstrut, _elem], undefined, style); - childWrap.style.top = -pstrutSize - currPos - _elem.depth + "em"; + childWrap.style.top = makeEm(-pstrutSize - currPos - _elem.depth); if (_child.marginLeft) { childWrap.style.marginLeft = _child.marginLeft; @@ -5679,7 +5817,7 @@ var makeVList = function makeVList(params, options) { var vlist = makeSpan(["vlist"], realChildren); - vlist.style.height = maxPos + "em"; // A second row is used if necessary to represent the vlist's depth. + vlist.style.height = makeEm(maxPos); // A second row is used if necessary to represent the vlist's depth. var rows; @@ -5691,7 +5829,7 @@ var makeVList = function makeVList(params, options) { // So we put another empty span inside the depth strut span. var emptySpan = makeSpan([], []); var depthStrut = makeSpan(["vlist"], [emptySpan]); - depthStrut.style.height = -minPos + "em"; // Safari wants the first row to have inline content; otherwise it + depthStrut.style.height = makeEm(-minPos); // Safari wants the first row to have inline content; otherwise it // puts the bottom of the *second* row on the baseline. var topStrut = makeSpan(["vlist-s"], [new SymbolNode("\u200B")]); @@ -5718,7 +5856,7 @@ var makeGlue = function makeGlue(measurement, options) { // Make an empty span for the space var rule = makeSpan(["mspace"], [], options); var size = calculateSize(measurement, options); - rule.style.marginRight = size + "em"; + rule.style.marginRight = makeEm(size); return rule; }; // Takes font options, and returns the appropriate fontLookup name @@ -5840,17 +5978,17 @@ var staticSvg = function staticSvg(value, options) { height = _svgData$value[2]; var path = new PathNode(pathName); var svgNode = new SvgNode([path], { - "width": width + "em", - "height": height + "em", + "width": makeEm(width), + "height": makeEm(height), // Override CSS rule `.katex svg { width: 100% }` - "style": "width:" + width + "em", + "style": "width:" + makeEm(width), "viewBox": "0 0 " + 1000 * width + " " + 1000 * height, "preserveAspectRatio": "xMinYMin" }); var span = makeSvgSpan(["overlay"], [svgNode], options); span.height = height; - span.style.height = height + "em"; - span.style.width = width + "em"; + span.style.height = makeEm(height); + span.style.width = makeEm(width); return span; }; @@ -6079,6 +6217,7 @@ var ordargument = function ordargument(arg) { + var buildHTML_makeSpan = buildCommon.makeSpan; // Binary atoms (first class `mbin`) change into ordinary atoms (`mord`) // depending on their surroundings. See TeXbook pg. 442-446, Rules 5 and 6, // and the text before Rule 19. @@ -6338,8 +6477,12 @@ function buildHTMLUnbreakable(children, options) { // falls at the depth of the expression. var strut = buildHTML_makeSpan(["strut"]); - strut.style.height = body.height + body.depth + "em"; - strut.style.verticalAlign = -body.depth + "em"; + strut.style.height = makeEm(body.height + body.depth); + + if (body.depth) { + strut.style.verticalAlign = makeEm(-body.depth); + } + body.children.unshift(strut); return body; } @@ -6433,8 +6576,11 @@ function buildHTML(tree, options) { if (tagChild) { var strut = tagChild.children[0]; - strut.style.height = htmlNode.height + htmlNode.depth + "em"; - strut.style.verticalAlign = -htmlNode.depth + "em"; + strut.style.height = makeEm(htmlNode.height + htmlNode.depth); + + if (htmlNode.depth) { + strut.style.verticalAlign = makeEm(-htmlNode.depth); + } } return htmlNode; @@ -6452,6 +6598,7 @@ function buildHTML(tree, options) { + function newDocumentFragment(children) { return new DocumentFragment(children); } @@ -6646,7 +6793,7 @@ var SpaceNode = /*#__PURE__*/function () { return document.createTextNode(this.character); } else { var node = document.createElementNS("http://www.w3.org/1998/Math/MathML", "mspace"); - node.setAttribute("width", this.width + "em"); + node.setAttribute("width", makeEm(this.width)); return node; } } @@ -6659,7 +6806,7 @@ var SpaceNode = /*#__PURE__*/function () { if (this.character) { return "" + this.character + ""; } else { - return ""; + return ""; } } /** @@ -7008,6 +7155,7 @@ var buildHTMLTree = function buildHTMLTree(tree, expression, settings) { + var stretchyCodePoint = { widehat: "^", widecheck: "ˇ", @@ -7050,13 +7198,13 @@ var stretchyCodePoint = { // Not a perfect match. xleftequilibrium: "\u21CB", // None better available. - "\\\\cdrightarrow": "\u2192", - "\\\\cdleftarrow": "\u2190", - "\\\\cdlongequal": "=" + "\\cdrightarrow": "\u2192", + "\\cdleftarrow": "\u2190", + "\\cdlongequal": "=" }; var mathMLnode = function mathMLnode(label) { - var node = new mathMLTree.MathNode("mo", [new mathMLTree.TextNode(stretchyCodePoint[label])]); + var node = new mathMLTree.MathNode("mo", [new mathMLTree.TextNode(stretchyCodePoint[label.replace(/^\\/, '')])]); node.setAttribute("stretchy", "true"); return node; }; // Many of the KaTeX SVG images have been adapted from glyphs in KaTeX fonts. @@ -7205,7 +7353,7 @@ var svgSpan = function svgSpan(group, options) { var path = new PathNode(pathName); var svgNode = new SvgNode([path], { "width": "100%", - "height": _height + "em", + "height": makeEm(_height), "viewBox": "0 0 " + viewBoxWidth + " " + viewBoxHeight, "preserveAspectRatio": "none" }); @@ -7247,7 +7395,7 @@ var svgSpan = function svgSpan(group, options) { var _svgNode = new SvgNode([_path], { "width": "400em", - "height": _height2 + "em", + "height": makeEm(_height2), "viewBox": "0 0 " + viewBoxWidth + " " + _viewBoxHeight, "preserveAspectRatio": aligns[i] + " slice" }); @@ -7261,7 +7409,7 @@ var svgSpan = function svgSpan(group, options) { height: _height2 }; } else { - _span.style.height = _height2 + "em"; + _span.style.height = makeEm(_height2); spans.push(_span); } } @@ -7283,10 +7431,10 @@ var svgSpan = function svgSpan(group, options) { span.height = height; - span.style.height = height + "em"; + span.style.height = makeEm(height); if (minWidth > 0) { - span.style.minWidth = minWidth + "em"; + span.style.minWidth = makeEm(minWidth); } return span; @@ -7335,13 +7483,13 @@ var encloseSpan = function encloseSpan(inner, label, topPad, bottomPad, options) var svgNode = new SvgNode(lines, { "width": "100%", - "height": totalHeight + "em" + "height": makeEm(totalHeight) }); img = buildCommon.makeSvgSpan([], [svgNode], options); } img.height = totalHeight; - img.style.height = totalHeight + "em"; + img.style.height = makeEm(totalHeight); return img; }; @@ -7402,6 +7550,7 @@ function checkSymbolNodeType(node) { + // NOTE: Unlike most `htmlBuilder`s, this one handles not only "accent", but // also "supsub" since an accent can affect super/subscripting. var htmlBuilder = function htmlBuilder(grp, options) { @@ -7456,10 +7605,11 @@ var htmlBuilder = function htmlBuilder(grp, options) { // removed with getBaseElem might contain things like \color which // we can't get rid of. // TODO(emily): Find a better way to get the skew - } // calculate the amount of space between the body and the accent + } + var accentBelow = group.label === "\\c"; // calculate the amount of space between the body and the accent - var clearance = Math.min(body.height, options.fontMetrics().xHeight); // Build the accent + var clearance = accentBelow ? body.height + body.depth : Math.min(body.height, options.fontMetrics().xHeight); // Build the accent var accentBody; @@ -7485,6 +7635,10 @@ var htmlBuilder = function htmlBuilder(grp, options) { accent.italic = 0; width = accent.width; + + if (accentBelow) { + clearance += accent.depth; + } } accentBody = buildCommon.makeSpan(["accent-body"], [accent]); // "Full" accents expand the width of the resulting symbol to be @@ -7508,7 +7662,7 @@ var htmlBuilder = function htmlBuilder(grp, options) { left -= width / 2; } - accentBody.style.left = left + "em"; // \textcircled uses the \bigcirc glyph, so it needs some + accentBody.style.left = makeEm(left); // \textcircled uses the \bigcirc glyph, so it needs some // vertical adjustment to match LaTeX. if (group.label === "\\textcircled") { @@ -7540,8 +7694,8 @@ var htmlBuilder = function htmlBuilder(grp, options) { elem: accentBody, wrapperClasses: ["svg-align"], wrapperStyle: skew > 0 ? { - width: "calc(100% - " + 2 * skew + "em)", - marginLeft: 2 * skew + "em" + width: "calc(100% - " + makeEm(2 * skew) + ")", + marginLeft: makeEm(2 * skew) } : undefined }] }, options); @@ -7600,18 +7754,26 @@ defineFunction({ defineFunction({ type: "accent", - names: ["\\'", "\\`", "\\^", "\\~", "\\=", "\\u", "\\.", '\\"', "\\r", "\\H", "\\v", "\\textcircled"], + names: ["\\'", "\\`", "\\^", "\\~", "\\=", "\\u", "\\.", '\\"', "\\c", "\\r", "\\H", "\\v", "\\textcircled"], props: { numArgs: 1, allowedInText: true, - allowedInMath: false, + allowedInMath: true, + // unless in strict mode argTypes: ["primitive"] }, handler: function handler(context, args) { var base = args[0]; + var mode = context.parser.mode; + + if (mode === "math") { + context.parser.settings.reportNonstrict("mathVsTextAccents", "LaTeX's accent " + context.funcName + " works only in text mode"); + mode = "text"; + } + return { type: "accent", - mode: context.parser.mode, + mode: mode, label: context.funcName, isStretchy: false, isShifty: true, @@ -7822,6 +7984,7 @@ defineFunction({ + var cdArrowFunctionName = { ">": "\\\\cdrightarrow", "<": "\\\\cdleftarrow", @@ -8084,7 +8247,7 @@ defineFunction({ var newOptions = options.havingStyle(options.style.sup()); var label = buildCommon.wrapFragment(buildGroup(group.label, newOptions, options), options); label.classes.push("cd-label-" + group.side); - label.style.bottom = 0.8 - label.depth + "em"; // Zero out label height & depth, so vertical align of arrow is set + label.style.bottom = makeEm(0.8 - label.depth); // Zero out label height & depth, so vertical align of arrow is set // by the arrow height, not by the label. label.height = 0; @@ -8161,15 +8324,25 @@ defineFunction({ } var code = parseInt(number); + var text; if (isNaN(code)) { - throw new src_ParseError("\\@char has non-numeric argument " + number); + throw new src_ParseError("\\@char has non-numeric argument " + number); // If we drop IE support, the following code could be replaced with + // text = String.fromCodePoint(code) + } else if (code < 0 || code >= 0x10ffff) { + throw new src_ParseError("\\@char with invalid code point " + number); + } else if (code <= 0xffff) { + text = String.fromCharCode(code); + } else { + // Astral code point; split into surrogate halves + code -= 0x10000; + text = String.fromCharCode((code >> 10) + 0xd800, (code & 0x3ff) + 0xdc00); } return { type: "textord", mode: parser.mode, - text: String.fromCharCode(code) + text: text }; } }); @@ -8285,7 +8458,7 @@ defineFunction({ span.classes.push("newline"); if (group.size) { - span.style.marginTop = calculateSize(group.size, options) + "em"; + span.style.marginTop = makeEm(calculateSize(group.size, options)); } } @@ -8298,7 +8471,7 @@ defineFunction({ node.setAttribute("linebreak", "newline"); if (group.size) { - node.setAttribute("height", calculateSize(group.size, options) + "em"); + node.setAttribute("height", makeEm(calculateSize(group.size, options))); } } @@ -8564,6 +8737,7 @@ defineFunction({ + /** * Get the metrics for a given symbol and font, after transformation (i.e. * after following replacement from symbols.js) @@ -8598,7 +8772,7 @@ var centerSpan = function centerSpan(span, options, style) { var newOptions = options.havingBaseStyle(style); var shift = (1 - options.sizeMultiplier / newOptions.sizeMultiplier) * options.fontMetrics().axisHeight; span.classes.push("delimcenter"); - span.style.top = shift + "em"; + span.style.top = makeEm(shift); span.height -= shift; span.depth += shift; }; @@ -8671,20 +8845,20 @@ var makeGlyphSpan = function makeGlyphSpan(symbol, font, mode) { var makeInner = function makeInner(ch, height, options) { // Create a span with inline SVG for the inner part of a tall stacked delimiter. - var width = fontMetricsData["Size4-Regular"][ch.charCodeAt(0)] ? fontMetricsData["Size4-Regular"][ch.charCodeAt(0)][4].toFixed(3) : fontMetricsData["Size1-Regular"][ch.charCodeAt(0)][4].toFixed(3); + var width = fontMetricsData["Size4-Regular"][ch.charCodeAt(0)] ? fontMetricsData["Size4-Regular"][ch.charCodeAt(0)][4] : fontMetricsData["Size1-Regular"][ch.charCodeAt(0)][4]; var path = new PathNode("inner", innerPath(ch, Math.round(1000 * height))); var svgNode = new SvgNode([path], { - "width": width + "em", - "height": height + "em", + "width": makeEm(width), + "height": makeEm(height), // Override CSS rule `.katex svg { width: 100% }` - "style": "width:" + width + "em", + "style": "width:" + makeEm(width), "viewBox": "0 0 " + 1000 * width + " " + Math.round(1000 * height), "preserveAspectRatio": "xMinYMin" }); var span = buildCommon.makeSvgSpan([], [svgNode], options); span.height = height; - span.style.height = height + "em"; - span.style.width = width + "em"; + span.style.height = makeEm(height); + span.style.width = makeEm(width); return { type: "elem", elem: span @@ -8893,7 +9067,7 @@ var sqrtSvg = function sqrtSvg(sqrtName, height, viewBoxHeight, extraViniculum, var svg = new SvgNode([pathNode], { // Note: 1000:1 ratio of viewBox to document em width. "width": "400em", - "height": height + "em", + "height": makeEm(height), "viewBox": "0 0 400000 " + viewBoxHeight, "preserveAspectRatio": "xMinYMin slice" }); @@ -8962,7 +9136,7 @@ var makeSqrtImage = function makeSqrtImage(height, options) { } span.height = texHeight; - span.style.height = spanHeight + "em"; + span.style.height = makeEm(spanHeight); return { span: span, advanceWidth: advanceWidth, @@ -9218,6 +9392,7 @@ var makeLeftRightDelim = function makeLeftRightDelim(delim, height, depth, optio + // Extra data needed for the delimiter handler down below var delimiterSizes = { "\\bigl": { @@ -9347,8 +9522,9 @@ defineFunction({ } node.setAttribute("stretchy", "true"); - node.setAttribute("minsize", delimiter.sizeToMaxHeight[group.size] + "em"); - node.setAttribute("maxsize", delimiter.sizeToMaxHeight[group.size] + "em"); + var size = makeEm(delimiter.sizeToMaxHeight[group.size]); + node.setAttribute("minsize", size); + node.setAttribute("maxsize", size); return node; } }); @@ -9607,19 +9783,19 @@ var enclose_htmlBuilder = function htmlBuilder(group, options) { scale = scale / newOptions.sizeMultiplier; var angleHeight = inner.height + inner.depth + lineWeight + clearance; // Reserve a left pad for the angle. - inner.style.paddingLeft = angleHeight / 2 + lineWeight + "em"; // Create an SVG + inner.style.paddingLeft = makeEm(angleHeight / 2 + lineWeight); // Create an SVG var viewBoxHeight = Math.floor(1000 * angleHeight * scale); var path = phasePath(viewBoxHeight); var svgNode = new SvgNode([new PathNode("phase", path)], { "width": "400em", - "height": viewBoxHeight / 1000 + "em", + "height": makeEm(viewBoxHeight / 1000), "viewBox": "0 0 400000 " + viewBoxHeight, "preserveAspectRatio": "xMinYMin slice" }); // Wrap it in a span with overflow: hidden. img = buildCommon.makeSvgSpan(["hide-tail"], [svgNode], options); - img.style.height = angleHeight + "em"; + img.style.height = makeEm(angleHeight); imgShift = inner.depth + lineWeight + clearance; } else { // Add horizontal padding @@ -9658,10 +9834,10 @@ var enclose_htmlBuilder = function htmlBuilder(group, options) { if (/fbox|boxed|fcolorbox/.test(label)) { img.style.borderStyle = "solid"; - img.style.borderWidth = ruleThickness + "em"; + img.style.borderWidth = makeEm(ruleThickness); } else if (label === "angl" && ruleThickness !== 0.049) { - img.style.borderTopWidth = ruleThickness + "em"; - img.style.borderRightWidth = ruleThickness + "em"; + img.style.borderTopWidth = makeEm(ruleThickness); + img.style.borderRightWidth = makeEm(ruleThickness); } imgShift = inner.depth + bottomPad; @@ -9895,42 +10071,145 @@ defineFunction({ /** - * All registered environments. - * `environments.js` exports this same dictionary again and makes it public. - * `Parser.js` requires this dictionary via `environments.js`. + * All registered environments. + * `environments.js` exports this same dictionary again and makes it public. + * `Parser.js` requires this dictionary via `environments.js`. + */ +var _environments = {}; +function defineEnvironment(_ref) { + var type = _ref.type, + names = _ref.names, + props = _ref.props, + handler = _ref.handler, + htmlBuilder = _ref.htmlBuilder, + mathmlBuilder = _ref.mathmlBuilder; + // Set default values of environments. + var data = { + type: type, + numArgs: props.numArgs || 0, + allowedInText: false, + numOptionalArgs: 0, + handler: handler + }; + + for (var i = 0; i < names.length; ++i) { + // TODO: The value type of _environments should be a type union of all + // possible `EnvSpec<>` possibilities instead of `EnvSpec<*>`, which is + // an existential type. + _environments[names[i]] = data; + } + + if (htmlBuilder) { + _htmlGroupBuilders[type] = htmlBuilder; + } + + if (mathmlBuilder) { + _mathmlGroupBuilders[type] = mathmlBuilder; + } +} +;// CONCATENATED MODULE: ./src/defineMacro.js + + +/** + * All registered global/built-in macros. + * `macros.js` exports this same dictionary again and makes it public. + * `Parser.js` requires this dictionary via `macros.js`. + */ +var _macros = {}; // This function might one day accept an additional argument and do more things. + +function defineMacro(name, body) { + _macros[name] = body; +} +;// CONCATENATED MODULE: ./src/SourceLocation.js +/** + * Lexing or parsing positional information for error reporting. + * This object is immutable. + */ +var SourceLocation = /*#__PURE__*/function () { + // The + prefix indicates that these fields aren't writeable + // Lexer holding the input string. + // Start offset, zero-based inclusive. + // End offset, zero-based exclusive. + function SourceLocation(lexer, start, end) { + this.lexer = void 0; + this.start = void 0; + this.end = void 0; + this.lexer = lexer; + this.start = start; + this.end = end; + } + /** + * Merges two `SourceLocation`s from location providers, given they are + * provided in order of appearance. + * - Returns the first one's location if only the first is provided. + * - Returns a merged range of the first and the last if both are provided + * and their lexers match. + * - Otherwise, returns null. + */ + + + SourceLocation.range = function range(first, second) { + if (!second) { + return first && first.loc; + } else if (!first || !first.loc || !second.loc || first.loc.lexer !== second.loc.lexer) { + return null; + } else { + return new SourceLocation(first.loc.lexer, first.loc.start, second.loc.end); + } + }; + + return SourceLocation; +}(); + + +;// CONCATENATED MODULE: ./src/Token.js + +/** + * Interface required to break circular dependency between Token, Lexer, and + * ParseError. */ -var _environments = {}; -function defineEnvironment(_ref) { - var type = _ref.type, - names = _ref.names, - props = _ref.props, - handler = _ref.handler, - htmlBuilder = _ref.htmlBuilder, - mathmlBuilder = _ref.mathmlBuilder; - // Set default values of environments. - var data = { - type: type, - numArgs: props.numArgs || 0, - allowedInText: false, - numOptionalArgs: 0, - handler: handler - }; - for (var i = 0; i < names.length; ++i) { - // TODO: The value type of _environments should be a type union of all - // possible `EnvSpec<>` possibilities instead of `EnvSpec<*>`, which is - // an existential type. - _environments[names[i]] = data; +/** + * The resulting token returned from `lex`. + * + * It consists of the token text plus some position information. + * The position information is essentially a range in an input string, + * but instead of referencing the bare input string, we refer to the lexer. + * That way it is possible to attach extra metadata to the input string, + * like for example a file name or similar. + * + * The position information is optional, so it is OK to construct synthetic + * tokens if appropriate. Not providing available position information may + * lead to degraded error reporting, though. + */ +var Token = /*#__PURE__*/function () { + // don't expand the token + // used in \noexpand + function Token(text, // the text of this token + loc) { + this.text = void 0; + this.loc = void 0; + this.noexpand = void 0; + this.treatAsRelax = void 0; + this.text = text; + this.loc = loc; } + /** + * Given a pair of tokens (this and endToken), compute a `Token` encompassing + * the whole input range enclosed by these two. + */ - if (htmlBuilder) { - _htmlGroupBuilders[type] = htmlBuilder; - } - if (mathmlBuilder) { - _mathmlGroupBuilders[type] = mathmlBuilder; - } -} + var _proto = Token.prototype; + + _proto.range = function range(endToken, // last token of the range, inclusive + text // the text of the newly constructed token + ) { + return new Token(text, SourceLocation.range(this, endToken)); + }; + + return Token; +}(); ;// CONCATENATED MODULE: ./src/environments/array.js @@ -9946,6 +10225,8 @@ function defineEnvironment(_ref) { + + // Helper functions function getHLines(parser) { // Return an array. The array length = number of hlines. @@ -9970,7 +10251,19 @@ var validateAmsEnvironmentContext = function validateAmsEnvironmentContext(conte if (!settings.displayMode) { throw new src_ParseError("{" + context.envName + "} can be used only in" + " display mode."); } -}; +}; // autoTag (an argument to parseArray) can be one of three values: +// * undefined: Regular (not-top-level) array; no tags on each row +// * true: Automatic equation numbering, overridable by \tag +// * false: Tags allowed on each row, but no automatic numbering +// This function *doesn't* work with the "split" environment name. + + +function getAutoTag(name) { + if (name.indexOf("ed") === -1) { + return name.indexOf("*") === -1; + } // return undefined; + +} /** * Parse the body of the environment, with rows delimited by \\ and * columns delimited by &, and create a nested list in row-major order @@ -9985,8 +10278,9 @@ function parseArray(parser, _ref, style) { cols = _ref.cols, arraystretch = _ref.arraystretch, colSeparationType = _ref.colSeparationType, - addEqnNum = _ref.addEqnNum, + autoTag = _ref.autoTag, singleRow = _ref.singleRow, + emptySingleRow = _ref.emptySingleRow, maxNumCols = _ref.maxNumCols, leqno = _ref.leqno; parser.gullet.beginGroup(); @@ -10018,7 +10312,29 @@ function parseArray(parser, _ref, style) { var row = []; var body = [row]; var rowGaps = []; - var hLinesBeforeRow = []; // Test for \hline at the top of the array. + var hLinesBeforeRow = []; + var tags = autoTag != null ? [] : undefined; // amsmath uses \global\@eqnswtrue and \global\@eqnswfalse to represent + // whether this row should have an equation number. Simulate this with + // a \@eqnsw macro set to 1 or 0. + + function beginRow() { + if (autoTag) { + parser.gullet.macros.set("\\@eqnsw", "1", true); + } + } + + function endRow() { + if (tags) { + if (parser.gullet.macros.get("\\df@tag")) { + tags.push(parser.subparse([new Token("\\df@tag")])); + parser.gullet.macros.set("\\df@tag", undefined, true); + } else { + tags.push(Boolean(autoTag) && parser.gullet.macros.get("\\@eqnsw") === "1"); + } + } + } + + beginRow(); // Test for \hline at the top of the array. hLinesBeforeRow.push(getHLines(parser)); @@ -10059,10 +10375,12 @@ function parseArray(parser, _ref, style) { parser.consume(); } else if (next === "\\end") { - // Arrays terminate newlines with `\crcr` which consumes a `\cr` if - // the last line is empty. + endRow(); // Arrays terminate newlines with `\crcr` which consumes a `\cr` if + // the last line is empty. However, AMS environments keep the + // empty row if it's the only one. // NOTE: Currently, `cell` is the last item added into `row`. - if (row.length === 1 && cell.type === "styling" && cell.body[0].body.length === 0) { + + if (row.length === 1 && cell.type === "styling" && cell.body[0].body.length === 0 && (body.length > 1 || !emptySingleRow)) { body.pop(); } @@ -10083,11 +10401,13 @@ function parseArray(parser, _ref, style) { size = parser.parseSizeGroup(true); } - rowGaps.push(size ? size.value : null); // check for \hline(s) following the row separator + rowGaps.push(size ? size.value : null); + endRow(); // check for \hline(s) following the row separator hLinesBeforeRow.push(getHLines(parser)); row = []; body.push(row); + beginRow(); } else { throw new src_ParseError("Expected & or \\\\ or \\cr or \\end", parser.nextToken); } @@ -10108,7 +10428,7 @@ function parseArray(parser, _ref, style) { hskipBeforeAndAfter: hskipBeforeAndAfter, hLinesBeforeRow: hLinesBeforeRow, colSeparationType: colSeparationType, - addEqnNum: addEqnNum, + tags: tags, leqno: leqno }; } // Decides on a style for cells in an array according to whether the given @@ -10246,20 +10566,35 @@ var array_htmlBuilder = function htmlBuilder(group, options) { var cols = []; var colSep; var colDescrNum; - var eqnNumSpans = []; + var tagSpans = []; - if (group.addEqnNum) { - // An environment with automatic equation numbers. - // Create node(s) that will trigger CSS counter increment. + if (group.tags && group.tags.some(function (tag) { + return tag; + })) { + // An environment with manual tags and/or automatic equation numbers. + // Create node(s), the latter of which trigger CSS counter increment. for (r = 0; r < nr; ++r) { var rw = body[r]; var shift = rw.pos - offset; - var eqnTag = buildCommon.makeSpan(["eqn-num"], [], options); - eqnTag.depth = rw.depth; - eqnTag.height = rw.height; - eqnNumSpans.push({ + var tag = group.tags[r]; + var tagSpan = void 0; + + if (tag === true) { + // automatic numbering + tagSpan = buildCommon.makeSpan(["eqn-num"], [], options); + } else if (tag === false) { + // \nonumber/\notag or starred environment + tagSpan = buildCommon.makeSpan([], [], options); + } else { + // manual \tag + tagSpan = buildCommon.makeSpan([], buildExpression(tag, options, true), options); + } + + tagSpan.depth = rw.depth; + tagSpan.height = rw.height; + tagSpans.push({ type: "elem", - elem: eqnTag, + elem: tagSpan, shift: shift }); } @@ -10276,18 +10611,24 @@ var array_htmlBuilder = function htmlBuilder(group, options) { // between them. if (!firstSeparator) { colSep = buildCommon.makeSpan(["arraycolsep"], []); - colSep.style.width = options.fontMetrics().doubleRuleSep + "em"; + colSep.style.width = makeEm(options.fontMetrics().doubleRuleSep); cols.push(colSep); } if (colDescr.separator === "|" || colDescr.separator === ":") { var lineType = colDescr.separator === "|" ? "solid" : "dashed"; var separator = buildCommon.makeSpan(["vertical-separator"], [], options); - separator.style.height = totalHeight + "em"; - separator.style.borderRightWidth = ruleThickness + "em"; + separator.style.height = makeEm(totalHeight); + separator.style.borderRightWidth = makeEm(ruleThickness); separator.style.borderRightStyle = lineType; - separator.style.margin = "0 -" + ruleThickness / 2 + "em"; - separator.style.verticalAlign = -(totalHeight - offset) + "em"; + separator.style.margin = "0 " + makeEm(-ruleThickness / 2); + + var _shift = totalHeight - offset; + + if (_shift) { + separator.style.verticalAlign = makeEm(-_shift); + } + cols.push(separator); } else { throw new src_ParseError("Invalid separator type: " + colDescr.separator); @@ -10309,7 +10650,7 @@ var array_htmlBuilder = function htmlBuilder(group, options) { if (sepwidth !== 0) { colSep = buildCommon.makeSpan(["arraycolsep"], []); - colSep.style.width = sepwidth + "em"; + colSep.style.width = makeEm(sepwidth); cols.push(colSep); } } @@ -10324,14 +10665,14 @@ var array_htmlBuilder = function htmlBuilder(group, options) { continue; } - var _shift = row.pos - offset; + var _shift2 = row.pos - offset; elem.depth = row.depth; elem.height = row.height; col.push({ type: "elem", elem: elem, - shift: _shift + shift: _shift2 }); } @@ -10347,7 +10688,7 @@ var array_htmlBuilder = function htmlBuilder(group, options) { if (sepwidth !== 0) { colSep = buildCommon.makeSpan(["arraycolsep"], []); - colSep.style.width = sepwidth + "em"; + colSep.style.width = makeEm(sepwidth); cols.push(colSep); } } @@ -10389,12 +10730,12 @@ var array_htmlBuilder = function htmlBuilder(group, options) { }, options); } - if (!group.addEqnNum) { + if (tagSpans.length === 0) { return buildCommon.makeSpan(["mord"], [body], options); } else { var eqnNumCol = buildCommon.makeVList({ positionType: "individualShift", - children: eqnNumSpans + children: tagSpans }, options); eqnNumCol = buildCommon.makeSpan(["tag"], [eqnNumCol], options); return buildCommon.makeFragment([body, eqnNumCol]); @@ -10420,7 +10761,7 @@ var array_mathmlBuilder = function mathmlBuilder(group, options) { row.push(new mathMLTree.MathNode("mtd", [buildMathML_buildGroup(rw[j], options)])); } - if (group.addEqnNum) { + if (group.tags && group.tags[i]) { row.unshift(glue); row.push(glue); @@ -10447,7 +10788,7 @@ var array_mathmlBuilder = function mathmlBuilder(group, options) { var gap = group.arraystretch === 0.5 ? 0.1 // {smallmatrix}, {subarray} : 0.16 + group.arraystretch - 1 + (group.addJot ? 0.09 : 0); - table.setAttribute("rowspacing", gap.toFixed(4) + "em"); // MathML table lines go only between cells. + table.setAttribute("rowspacing", makeEm(gap)); // MathML table lines go only between cells. // To place a line on an edge we'll use , if necessary. var menclose = ""; @@ -10555,12 +10896,14 @@ var alignedHandler = function alignedHandler(context, args) { var cols = []; var separationType = context.envName.indexOf("at") > -1 ? "alignat" : "align"; + var isSplit = context.envName === "split"; var res = parseArray(context.parser, { cols: cols, addJot: true, - addEqnNum: context.envName === "align" || context.envName === "alignat", + autoTag: isSplit ? undefined : getAutoTag(context.envName), + emptySingleRow: true, colSeparationType: separationType, - maxNumCols: context.envName === "split" ? 2 : undefined, + maxNumCols: isSplit ? 2 : undefined, leqno: context.parser.settings.leqno }, "display"); // Determining number of columns. // 1. If the first argument is given, we use it as a number of columns, @@ -10747,7 +11090,10 @@ defineEnvironment({ var res = parseArray(context.parser, payload, dCellStyle(context.envName)); // Populate cols with the correct number of column alignment specs. - res.cols = new Array(res.body[0].length).fill({ + var numCols = Math.max.apply(Math, [0].concat(res.body.map(function (row) { + return row.length; + }))); + res.cols = new Array(numCols).fill({ type: "align", align: colAlign }); @@ -10908,7 +11254,8 @@ defineEnvironment({ }], addJot: true, colSeparationType: "gather", - addEqnNum: context.envName === "gather", + autoTag: getAutoTag(context.envName), + emptySingleRow: true, leqno: context.parser.settings.leqno }; return parseArray(context.parser, res, "display"); @@ -10938,7 +11285,8 @@ defineEnvironment({ handler: function handler(context) { validateAmsEnvironmentContext(context); var res = { - addEqnNum: context.envName === "equation", + autoTag: getAutoTag(context.envName), + emptySingleRow: true, singleRow: true, maxNumCols: 1, leqno: context.parser.settings.leqno @@ -10960,7 +11308,9 @@ defineEnvironment({ }, htmlBuilder: array_htmlBuilder, mathmlBuilder: array_mathmlBuilder -}); // Catch \hline outside array environment +}); +defineMacro("\\nonumber", "\\gdef\\@eqnsw{0}"); +defineMacro("\\notag", "\\nonumber"); // Catch \hline outside array environment defineFunction({ type: "text", @@ -11069,7 +11419,7 @@ function mclass_mathmlBuilder(group, options) { var inner = buildMathML_buildExpression(group.body, options); if (group.mclass === "minner") { - return mathMLTree.newDocumentFragment(inner); + node = new mathMLTree.MathNode("mpadded", inner); } else if (group.mclass === "mord") { if (group.isCharacterBox) { node = inner[0]; @@ -11097,6 +11447,10 @@ function mclass_mathmlBuilder(group, options) { } else if (group.mclass === "mopen" || group.mclass === "mclose") { node.attributes.lspace = "0em"; node.attributes.rspace = "0em"; + } else if (group.mclass === "minner") { + node.attributes.lspace = "0.0556em"; // 1 mu is the most likely option + + node.attributes.width = "+0.1111em"; } // MathML default space is 5/18 em, so needs no action. // Ref: https://developer.mozilla.org/en-US/docs/Web/MathML/Element/mo @@ -11485,6 +11839,8 @@ var genfrac_htmlBuilder = function htmlBuilder(group, options) { if (style.size === src_Style.DISPLAY.size) { delimSize = options.fontMetrics().delim1; + } else if (style.size === src_Style.SCRIPTSCRIPT.size) { + delimSize = options.havingStyle(src_Style.SCRIPT).fontMetrics().delim2; } else { delimSize = options.fontMetrics().delim2; } @@ -11516,7 +11872,7 @@ var genfrac_mathmlBuilder = function mathmlBuilder(group, options) { node.setAttribute("linethickness", "0px"); } else if (group.barSize) { var ruleWidth = calculateSize(group.barSize, options); - node.setAttribute("linethickness", ruleWidth + "em"); + node.setAttribute("linethickness", makeEm(ruleWidth)); } var style = adjustStyle(group.size, options.style); @@ -12377,7 +12733,6 @@ defineFunction({ if (group.totalheight.number > 0) { depth = calculateSize(group.totalheight, options) - height; - depth = Number(depth.toFixed(2)); } var width = 0; @@ -12387,15 +12742,15 @@ defineFunction({ } var style = { - height: height + depth + "em" + height: makeEm(height + depth) }; if (width > 0) { - style.width = width + "em"; + style.width = makeEm(width); } if (depth > 0) { - style.verticalAlign = -depth + "em"; + style.verticalAlign = makeEm(-depth); } var node = new Img(group.src, group.alt, style); @@ -12411,15 +12766,14 @@ defineFunction({ if (group.totalheight.number > 0) { depth = calculateSize(group.totalheight, options) - height; - depth = depth.toFixed(2); - node.setAttribute("valign", "-" + depth + "em"); + node.setAttribute("valign", makeEm(-depth)); } - node.setAttribute("height", height + depth + "em"); + node.setAttribute("height", makeEm(height + depth)); if (group.width.number > 0) { var width = calculateSize(group.width, options); - node.setAttribute("width", width + "em"); + node.setAttribute("width", makeEm(width)); } node.setAttribute("src", group.src); @@ -12490,6 +12844,7 @@ defineFunction({ + defineFunction({ type: "lap", names: ["\\mathllap", "\\mathrlap", "\\mathclap"], @@ -12529,8 +12884,12 @@ defineFunction({ // This code resolved issue #1153 var strut = buildCommon.makeSpan(["strut"]); - strut.style.height = node.height + node.depth + "em"; - strut.style.verticalAlign = -node.depth + "em"; + strut.style.height = makeEm(node.height + node.depth); + + if (node.depth) { + strut.style.verticalAlign = makeEm(-node.depth); + } + node.children.unshift(strut); // Next, prevent vertical misplacement when next to something tall. // This code resolves issue #1234 @@ -12650,9 +13009,12 @@ defineFunction({ ;// CONCATENATED MODULE: ./src/functions/utils/assembleSupSub.js -// For an operator with limits, assemble the base, sup, and sub into a span. + + // For an operator with limits, assemble the base, sup, and sub into a span. + var assembleSupSub = function assembleSupSub(base, supGroup, subGroup, options, style, slant, baseShift) { base = buildCommon.makeSpan([], [base]); + var subIsSingleCharacter = subGroup && utils.isCharacterBox(subGroup); var sub; var sup; // We manually have to handle the superscripts and subscripts. This, // aside from the kern calculations, is copied from supsub. @@ -12689,7 +13051,7 @@ var assembleSupSub = function assembleSupSub(base, supGroup, subGroup, options, }, { type: "elem", elem: sub.elem, - marginLeft: -slant + "em" + marginLeft: makeEm(-slant) }, { type: "kern", size: sub.kern @@ -12702,7 +13064,7 @@ var assembleSupSub = function assembleSupSub(base, supGroup, subGroup, options, }, { type: "elem", elem: sup.elem, - marginLeft: slant + "em" + marginLeft: makeEm(slant) }, { type: "kern", size: options.fontMetrics().bigOpSpacing5 @@ -12723,7 +13085,7 @@ var assembleSupSub = function assembleSupSub(base, supGroup, subGroup, options, }, { type: "elem", elem: sub.elem, - marginLeft: -slant + "em" + marginLeft: makeEm(-slant) }, { type: "kern", size: sub.kern @@ -12747,7 +13109,7 @@ var assembleSupSub = function assembleSupSub(base, supGroup, subGroup, options, }, { type: "elem", elem: sup.elem, - marginLeft: slant + "em" + marginLeft: makeEm(slant) }, { type: "kern", size: options.fontMetrics().bigOpSpacing5 @@ -12760,7 +13122,17 @@ var assembleSupSub = function assembleSupSub(base, supGroup, subGroup, options, return base; } - return buildCommon.makeSpan(["mop", "op-limits"], [finalGroup], options); + var parts = [finalGroup]; + + if (sub && slant !== 0 && !subIsSingleCharacter) { + // A negative margin-left was applied to the lower limit. + // Avoid an overlap by placing a spacer on the left on the group. + var spacer = buildCommon.makeSpan(["mspace"], [], options); + spacer.style.marginRight = makeEm(slant); + parts.unshift(spacer); + } + + return buildCommon.makeSpan(["mop", "op-limits"], parts, options); }; ;// CONCATENATED MODULE: ./src/functions/op.js // Limits, symbols @@ -12774,6 +13146,7 @@ var assembleSupSub = function assembleSupSub(base, supGroup, subGroup, options, + // Most operators have a large successor symbol, but these don't. var noSuccessor = ["\\smallint"]; // NOTE: Unlike most `htmlBuilder`s, this one handles not only "op", but also // "supsub" since some of them (like \int) can affect super/subscripting. @@ -12887,7 +13260,7 @@ var op_htmlBuilder = function htmlBuilder(grp, options) { } else { if (baseShift) { base.style.position = "relative"; - base.style.top = baseShift + "em"; + base.style.top = makeEm(baseShift); } return base; @@ -13082,6 +13455,7 @@ defineFunction({ + // NOTE: Unlike most `htmlBuilder`s, this one handles not only // "operatorname", but also "supsub" since \operatorname* can // affect super/subscripting. @@ -13212,7 +13586,7 @@ var operatorname_mathmlBuilder = function mathmlBuilder(group, options) { defineFunction({ type: "operatorname", - names: ["\\operatorname", "\\operatorname*"], + names: ["\\operatorname@", "\\operatornamewithlimits"], props: { numArgs: 1 }, @@ -13224,7 +13598,7 @@ defineFunction({ type: "operatorname", mode: parser.mode, body: ordargument(body), - alwaysHandleSupSub: funcName === "\\operatorname*", + alwaysHandleSupSub: funcName === "\\operatornamewithlimits", limits: false, parentIsSupSub: false }; @@ -13232,6 +13606,7 @@ defineFunction({ htmlBuilder: operatorname_htmlBuilder, mathmlBuilder: operatorname_mathmlBuilder }); +defineMacro("\\operatorname", "\\@ifstar\\operatornamewithlimits\\operatorname@"); ;// CONCATENATED MODULE: ./src/functions/ordgroup.js @@ -13462,6 +13837,23 @@ defineFunction({ return node; } }); +;// CONCATENATED MODULE: ./src/functions/relax.js + +defineFunction({ + type: "internal", + names: ["\\relax"], + props: { + numArgs: 0, + allowedInText: true + }, + handler: function handler(_ref) { + var parser = _ref.parser; + return { + type: "internal", + mode: parser.mode + }; + } +}); ;// CONCATENATED MODULE: ./src/functions/rule.js @@ -13497,9 +13889,9 @@ defineFunction({ var height = calculateSize(group.height, options); var shift = group.shift ? calculateSize(group.shift, options) : 0; // Style the rule to the right size - rule.style.borderRightWidth = width + "em"; - rule.style.borderTopWidth = height + "em"; - rule.style.bottom = shift + "em"; // Record the height and width + rule.style.borderRightWidth = makeEm(width); + rule.style.borderTopWidth = makeEm(height); + rule.style.bottom = makeEm(shift); // Record the height and width rule.width = width; rule.height = height + shift; @@ -13517,18 +13909,18 @@ defineFunction({ var color = options.color && options.getColor() || "black"; var rule = new mathMLTree.MathNode("mspace"); rule.setAttribute("mathbackground", color); - rule.setAttribute("width", width + "em"); - rule.setAttribute("height", height + "em"); + rule.setAttribute("width", makeEm(width)); + rule.setAttribute("height", makeEm(height)); var wrapper = new mathMLTree.MathNode("mpadded", [rule]); if (shift >= 0) { - wrapper.setAttribute("height", "+" + shift + "em"); + wrapper.setAttribute("height", makeEm(shift)); } else { - wrapper.setAttribute("height", shift + "em"); - wrapper.setAttribute("depth", "+" + -shift + "em"); + wrapper.setAttribute("height", makeEm(shift)); + wrapper.setAttribute("depth", makeEm(-shift)); } - wrapper.setAttribute("voffset", shift + "em"); + wrapper.setAttribute("voffset", makeEm(shift)); return wrapper; } }); @@ -13538,6 +13930,7 @@ defineFunction({ + function sizingGroup(value, options, baseOptions) { var inner = buildExpression(value, options, false); var multiplier = options.sizeMultiplier / baseOptions.sizeMultiplier; // Add size-resetting classes to the inner list and set maxFontSize @@ -13599,7 +13992,7 @@ defineFunction({ // that we're passing an options parameter we should be able to fix // this. - node.setAttribute("mathsize", newOptions.sizeMultiplier + "em"); + node.setAttribute("mathsize", makeEm(newOptions.sizeMultiplier)); return node; } }); @@ -13723,6 +14116,7 @@ defineFunction({ + defineFunction({ type: "sqrt", names: ["\\sqrt"], @@ -13781,7 +14175,7 @@ defineFunction({ var imgShift = img.height - inner.height - lineClearance - ruleWidth; - inner.style.paddingLeft = advanceWidth + "em"; // Overlay the image and the argument. + inner.style.paddingLeft = makeEm(advanceWidth); // Overlay the image and the argument. var body = buildCommon.makeVList({ positionType: "firstBaseline", @@ -13909,6 +14303,7 @@ defineFunction({ + /** * Sometimes, groups perform special rules when they have superscripts or * subscripts attached to them. This function lets the `supsub` group know that @@ -14000,7 +14395,7 @@ defineFunctionBuilders({ var multiplier = options.sizeMultiplier; - var marginRight = 0.5 / metrics.ptPerEm / multiplier + "em"; + var marginRight = makeEm(0.5 / metrics.ptPerEm / multiplier); var marginLeft = null; if (subm) { @@ -14011,7 +14406,7 @@ defineFunctionBuilders({ if (base instanceof SymbolNode || isOiint) { // $FlowFixMe - marginLeft = -base.italic + "em"; + marginLeft = makeEm(-base.italic); } } @@ -14602,95 +14997,7 @@ var functions = _functions; -;// CONCATENATED MODULE: ./src/SourceLocation.js -/** - * Lexing or parsing positional information for error reporting. - * This object is immutable. - */ -var SourceLocation = /*#__PURE__*/function () { - // The + prefix indicates that these fields aren't writeable - // Lexer holding the input string. - // Start offset, zero-based inclusive. - // End offset, zero-based exclusive. - function SourceLocation(lexer, start, end) { - this.lexer = void 0; - this.start = void 0; - this.end = void 0; - this.lexer = lexer; - this.start = start; - this.end = end; - } - /** - * Merges two `SourceLocation`s from location providers, given they are - * provided in order of appearance. - * - Returns the first one's location if only the first is provided. - * - Returns a merged range of the first and the last if both are provided - * and their lexers match. - * - Otherwise, returns null. - */ - - - SourceLocation.range = function range(first, second) { - if (!second) { - return first && first.loc; - } else if (!first || !first.loc || !second.loc || first.loc.lexer !== second.loc.lexer) { - return null; - } else { - return new SourceLocation(first.loc.lexer, first.loc.start, second.loc.end); - } - }; - - return SourceLocation; -}(); - - -;// CONCATENATED MODULE: ./src/Token.js - -/** - * Interface required to break circular dependency between Token, Lexer, and - * ParseError. - */ - -/** - * The resulting token returned from `lex`. - * - * It consists of the token text plus some position information. - * The position information is essentially a range in an input string, - * but instead of referencing the bare input string, we refer to the lexer. - * That way it is possible to attach extra metadata to the input string, - * like for example a file name or similar. - * - * The position information is optional, so it is OK to construct synthetic - * tokens if appropriate. Not providing available position information may - * lead to degraded error reporting, though. - */ -var Token = /*#__PURE__*/function () { - // don't expand the token - // used in \noexpand - function Token(text, // the text of this token - loc) { - this.text = void 0; - this.loc = void 0; - this.noexpand = void 0; - this.treatAsRelax = void 0; - this.text = text; - this.loc = loc; - } - /** - * Given a pair of tokens (this and endToken), compute a `Token` encompassing - * the whole input range enclosed by these two. - */ - - - var _proto = Token.prototype; - - _proto.range = function range(endToken, // last token of the range, inclusive - text) { - return new Token(text, SourceLocation.range(this, endToken)); - }; - return Token; -}(); ;// CONCATENATED MODULE: ./src/Lexer.js /** * The Lexer class handles tokenizing the input in various ways. Since our @@ -14717,8 +15024,16 @@ var Token = /*#__PURE__*/function () { * - does not match bare surrogate code units * - matches any BMP character except for those just described * - matches any valid Unicode surrogate pair - * - matches a backslash followed by one or more letters - * - matches a backslash followed by any BMP character, including newline + * - matches a backslash followed by one or more whitespace characters + * - matches a backslash followed by one or more letters then whitespace + * - matches a backslash followed by any BMP character + * Capturing groups: + * [1] regular whitespace + * [2] backslash followed by whitespace + * [3] anything else, which may include: + * [4] left character of \verb* + * [5] left character of \verb + * [6] backslash followed by word, excluding any trailing whitespace * Just because the Lexer matches something doesn't mean it's valid input: * If there is no matching function or symbol definition, the Parser will * still reject the input. @@ -14726,25 +15041,26 @@ var Token = /*#__PURE__*/function () { var spaceRegexString = "[ \r\n\t]"; var controlWordRegexString = "\\\\[a-zA-Z@]+"; var controlSymbolRegexString = "\\\\[^\uD800-\uDFFF]"; -var controlWordWhitespaceRegexString = "" + controlWordRegexString + spaceRegexString + "*"; -var controlWordWhitespaceRegex = new RegExp("^(" + controlWordRegexString + ")" + spaceRegexString + "*$"); +var controlWordWhitespaceRegexString = "(" + controlWordRegexString + ")" + spaceRegexString + "*"; +var controlSpaceRegexString = "\\\\(\n|[ \r\t]+\n?)[ \r\t]*"; var combiningDiacriticalMarkString = "[\u0300-\u036F]"; var combiningDiacriticalMarksEndRegex = new RegExp(combiningDiacriticalMarkString + "+$"); -var tokenRegexString = "(" + spaceRegexString + "+)|" + // whitespace +var tokenRegexString = "(" + spaceRegexString + "+)|" + ( // whitespace +controlSpaceRegexString + "|") + // \whitespace "([!-\\[\\]-\u2027\u202A-\uD7FF\uF900-\uFFFF]" + ( // single codepoint combiningDiacriticalMarkString + "*") + // ...plus accents "|[\uD800-\uDBFF][\uDC00-\uDFFF]" + ( // surrogate pair combiningDiacriticalMarkString + "*") + // ...plus accents -"|\\\\verb\\*([^]).*?\\3" + // \verb* -"|\\\\verb([^*a-zA-Z]).*?\\4" + // \verb unstarred -"|\\\\operatorname\\*" + ( // \operatorname* +"|\\\\verb\\*([^]).*?\\4" + // \verb* +"|\\\\verb([^*a-zA-Z]).*?\\5" + ( // \verb unstarred "|" + controlWordWhitespaceRegexString) + ( // \macroName + spaces "|" + controlSymbolRegexString + ")"); // \\, \', etc. /** Main Lexer class */ var Lexer = /*#__PURE__*/function () { - // category codes, only supports comment characters (14) for now + // Category codes. The lexer only supports comment characters (14) for now. + // MacroExpander additionally distinguishes active (13). function Lexer(input, settings) { this.input = void 0; this.settings = void 0; @@ -14755,7 +15071,9 @@ var Lexer = /*#__PURE__*/function () { this.settings = settings; this.tokenRegex = new RegExp(tokenRegexString, 'g'); this.catcodes = { - "%": 14 // comment character + "%": 14, + // comment character + "~": 13 // active character }; } @@ -14784,7 +15102,7 @@ var Lexer = /*#__PURE__*/function () { throw new src_ParseError("Unexpected character: '" + input[pos] + "'", new Token(input[pos], new SourceLocation(this, pos, pos + 1))); } - var text = match[2] || " "; + var text = match[6] || match[3] || (match[2] ? "\\ " : " "); if (this.catcodes[text] === 14) { // comment character @@ -14799,13 +15117,6 @@ var Lexer = /*#__PURE__*/function () { } return this.lex(); - } // Trim any trailing whitespace from control word match - - - var controlMatch = text.match(controlWordWhitespaceRegex); - - if (controlMatch) { - text = controlMatch[1]; } return new Token(text, new SourceLocation(this, pos, this.tokenRegex.lastIndex)); @@ -14872,7 +15183,7 @@ var Namespace = /*#__PURE__*/function () { for (var undef in undefs) { if (undefs.hasOwnProperty(undef)) { - if (undefs[undef] === undefined) { + if (undefs[undef] == null) { delete this.current[undef]; } else { this.current[undef] = undefs[undef]; @@ -14880,6 +15191,17 @@ var Namespace = /*#__PURE__*/function () { } } } + /** + * Ends all currently nested groups (if any), restoring values before the + * groups began. Useful in case of an error in the middle of parsing. + */ + ; + + _proto.endGroups = function endGroups() { + while (this.undefStack.length > 0) { + this.endGroup(); + } + } /** * Detect whether `name` has a definition. Equivalent to * `get(name) != null`. @@ -14911,6 +15233,7 @@ var Namespace = /*#__PURE__*/function () { * Local set() sets the current value and (when appropriate) adds an undo * operation to the undo stack. Global set() may change the undo * operation at every level, so takes time linear in their number. + * A value of undefined means to delete existing definitions. */ ; @@ -14942,7 +15265,11 @@ var Namespace = /*#__PURE__*/function () { } } - this.current[name] = value; + if (value == null) { + delete this.current[name]; + } else { + this.current[name] = value; + } }; return Namespace; @@ -14954,18 +15281,16 @@ var Namespace = /*#__PURE__*/function () { * Predefined macros for KaTeX. * This can be used to define some commands in terms of others. */ +// Export global macros object from defineMacro +var macros = _macros; +/* harmony default export */ var src_macros = (macros); -var builtinMacros = {}; -/* harmony default export */ var macros = (builtinMacros); // This function might one day accept an additional argument and do more things. - -function defineMacro(name, body) { - builtinMacros[name] = body; -} ////////////////////////////////////////////////////////////////////// + ////////////////////////////////////////////////////////////////////// // macro tools defineMacro("\\noexpand", function (context) { @@ -15225,11 +15550,13 @@ defineMacro("\\show", function (context) { defineMacro("\\bgroup", "{"); defineMacro("\\egroup", "}"); // Symbols from latex.ltx: +// \def~{\nobreakspace{}} // \def\lq{`} // \def\rq{'} // \def \aa {\r a} // \def \AA {\r A} +defineMacro("~", "\\nobreakspace"); defineMacro("\\lq", "`"); defineMacro("\\rq", "'"); defineMacro("\\aa", "\\r a"); @@ -15340,7 +15667,7 @@ defineMacro("\\varOmega", "\\mathit{\\Omega}"); //\newcommand{\substack}[1]{\sub defineMacro("\\substack", "\\begin{subarray}{c}#1\\end{subarray}"); // \renewcommand{\colon}{\nobreak\mskip2mu\mathpunct{}\nonscript // \mkern-\thinmuskip{:}\mskip6muplus1mu\relax} -defineMacro("\\colon", "\\nobreak\\mskip2mu\\mathpunct{}" + "\\mathchoice{\\mkern-3mu}{\\mkern-3mu}{}{}{:}\\mskip6mu"); // \newcommand{\boxed}[1]{\fbox{\m@th$\displaystyle#1$}} +defineMacro("\\colon", "\\nobreak\\mskip2mu\\mathpunct{}" + "\\mathchoice{\\mkern-3mu}{\\mkern-3mu}{}{}{:}\\mskip6mu\\relax"); // \newcommand{\boxed}[1]{\fbox{\m@th$\displaystyle#1$}} defineMacro("\\boxed", "\\fbox{$\\displaystyle{#1}$}"); // \def\iff{\DOTSB\;\Longleftrightarrow\;} // \def\implies{\DOTSB\;\Longrightarrow\;} @@ -15584,7 +15911,7 @@ defineMacro("\\TeX", "\\textrm{\\html@mathml{" + "T\\kern-.1667em\\raisebox{-.5e // We compute the corresponding \raisebox when A is rendered in \normalsize // \scriptstyle, which has a scale factor of 0.7 (see Options.js). -var latexRaiseA = fontMetricsData["Main-Regular"]["T".charCodeAt(0)][1] - 0.7 * fontMetricsData["Main-Regular"]["A".charCodeAt(0)][1] + "em"; +var latexRaiseA = makeEm(fontMetricsData["Main-Regular"]["T".charCodeAt(0)][1] - 0.7 * fontMetricsData["Main-Regular"]["A".charCodeAt(0)][1]); defineMacro("\\LaTeX", "\\textrm{\\html@mathml{" + ("L\\kern-.36em\\raisebox{" + latexRaiseA + "}{\\scriptstyle A}") + "\\kern-.15em\\TeX}{LaTeX}}"); // New KaTeX logo based on tweaking LaTeX logo defineMacro("\\KaTeX", "\\textrm{\\html@mathml{" + ("K\\kern-.17em\\raisebox{" + latexRaiseA + "}{\\scriptstyle A}") + "\\kern-.15em\\TeX}{KaTeX}}"); // \DeclareRobustCommand\hspace{\@ifstar\@hspacer\@hspace} @@ -15874,8 +16201,6 @@ defineMacro("\\kaGreen", "\\textcolor{##71B307}{#1}"); // List of commands that act like macros but aren't defined as a macro, // function, or symbol. Used in `isDefined`. var implicitCommands = { - "\\relax": true, - // MacroExpander.js "^": true, // Parser.js "_": true, @@ -15898,7 +16223,7 @@ var MacroExpander = /*#__PURE__*/function () { this.expansionCount = 0; this.feed(input); // Make new global namespace - this.macros = new Namespace(macros, settings.macros); + this.macros = new Namespace(src_macros, settings.macros); this.mode = mode; this.stack = []; // contains tokens in REVERSE order } @@ -15937,6 +16262,15 @@ var MacroExpander = /*#__PURE__*/function () { _proto.endGroup = function endGroup() { this.macros.endGroup(); } + /** + * Ends all currently nested groups (if any), restoring values before the + * groups began. Useful in case of an error in the middle of parsing. + */ + ; + + _proto.endGroups = function endGroups() { + this.macros.endGroups(); + } /** * Returns the topmost token on the stack, without expanding it. * Similar in behavior to TeX's `\futurelet`. @@ -16237,15 +16571,13 @@ var MacroExpander = /*#__PURE__*/function () { var expanded = this.expandOnce(); // expandOnce returns Token if and only if it's fully expanded. if (expanded instanceof Token) { - // \relax stops the expansion, but shouldn't get returned (a - // null return value couldn't get implemented as a function). // the token after \noexpand is interpreted as if its meaning // were ‘\relax’ - if (expanded.text === "\\relax" || expanded.treatAsRelax) { - this.stack.pop(); - } else { - return this.stack.pop(); // === expanded + if (expanded.treatAsRelax) { + expanded.text = "\\relax"; } + + return this.stack.pop(); // === expanded } } // Flow unable to figure out that this pathway is impossible. // https://github.com/facebook/flow/issues/4808 @@ -16318,6 +16650,16 @@ var MacroExpander = /*#__PURE__*/function () { if (definition == null) { // mainly checking for undefined here return definition; + } // If a single character has an associated catcode other than 13 + // (active character), then don't expand it. + + + if (name.length === 1) { + var catcode = this.lexer.catcodes[name]; + + if (catcode != null && catcode !== 13) { + return; + } } var expansion = typeof definition === "function" ? definition(this) : definition; @@ -16434,6 +16776,9 @@ var unicodeAccents = { }, "̋": { "text": "\\H" + }, + "̧": { + "text": "\\c" } }; var unicodeSymbols = { @@ -16458,11 +16803,14 @@ var unicodeSymbols = { "ǻ": "ǻ", "ḃ": "ḃ", "ć": "ć", + "ḉ": "ḉ", "č": "č", "ĉ": "ĉ", "ċ": "ċ", + "ç": "ç", "ď": "ď", "ḋ": "ḋ", + "ḑ": "ḑ", "é": "é", "è": "è", "ë": "ë", @@ -16471,12 +16819,14 @@ var unicodeSymbols = { "ḗ": "ḗ", "ḕ": "ḕ", "ĕ": "ĕ", + "ḝ": "ḝ", "ě": "ě", "ê": "ê", "ế": "ế", "ề": "ề", "ễ": "ễ", "ė": "ė", + "ȩ": "ȩ", "ḟ": "ḟ", "ǵ": "ǵ", "ḡ": "ḡ", @@ -16484,10 +16834,12 @@ var unicodeSymbols = { "ǧ": "ǧ", "ĝ": "ĝ", "ġ": "ġ", + "ģ": "ģ", "ḧ": "ḧ", "ȟ": "ȟ", "ĥ": "ĥ", "ḣ": "ḣ", + "ḩ": "ḩ", "í": "í", "ì": "ì", "ï": "ï", @@ -16501,8 +16853,10 @@ var unicodeSymbols = { "ĵ": "ĵ", "ḱ": "ḱ", "ǩ": "ǩ", + "ķ": "ķ", "ĺ": "ĺ", "ľ": "ľ", + "ļ": "ļ", "ḿ": "ḿ", "ṁ": "ṁ", "ń": "ń", @@ -16510,6 +16864,7 @@ var unicodeSymbols = { "ñ": "ñ", "ň": "ň", "ṅ": "ṅ", + "ņ": "ņ", "ó": "ó", "ò": "ò", "ö": "ö", @@ -16535,15 +16890,18 @@ var unicodeSymbols = { "ŕ": "ŕ", "ř": "ř", "ṙ": "ṙ", + "ŗ": "ŗ", "ś": "ś", "ṥ": "ṥ", "š": "š", "ṧ": "ṧ", "ŝ": "ŝ", "ṡ": "ṡ", + "ş": "ş", "ẗ": "ẗ", "ť": "ť", "ṫ": "ṫ", + "ţ": "ţ", "ú": "ú", "ù": "ù", "ü": "ü", @@ -16602,11 +16960,14 @@ var unicodeSymbols = { "Ǻ": "Ǻ", "Ḃ": "Ḃ", "Ć": "Ć", + "Ḉ": "Ḉ", "Č": "Č", "Ĉ": "Ĉ", "Ċ": "Ċ", + "Ç": "Ç", "Ď": "Ď", "Ḋ": "Ḋ", + "Ḑ": "Ḑ", "É": "É", "È": "È", "Ë": "Ë", @@ -16615,12 +16976,14 @@ var unicodeSymbols = { "Ḗ": "Ḗ", "Ḕ": "Ḕ", "Ĕ": "Ĕ", + "Ḝ": "Ḝ", "Ě": "Ě", "Ê": "Ê", "Ế": "Ế", "Ề": "Ề", "Ễ": "Ễ", "Ė": "Ė", + "Ȩ": "Ȩ", "Ḟ": "Ḟ", "Ǵ": "Ǵ", "Ḡ": "Ḡ", @@ -16628,10 +16991,12 @@ var unicodeSymbols = { "Ǧ": "Ǧ", "Ĝ": "Ĝ", "Ġ": "Ġ", + "Ģ": "Ģ", "Ḧ": "Ḧ", "Ȟ": "Ȟ", "Ĥ": "Ĥ", "Ḣ": "Ḣ", + "Ḩ": "Ḩ", "Í": "Í", "Ì": "Ì", "Ï": "Ï", @@ -16645,8 +17010,10 @@ var unicodeSymbols = { "Ĵ": "Ĵ", "Ḱ": "Ḱ", "Ǩ": "Ǩ", + "Ķ": "Ķ", "Ĺ": "Ĺ", "Ľ": "Ľ", + "Ļ": "Ļ", "Ḿ": "Ḿ", "Ṁ": "Ṁ", "Ń": "Ń", @@ -16654,6 +17021,7 @@ var unicodeSymbols = { "Ñ": "Ñ", "Ň": "Ň", "Ṅ": "Ṅ", + "Ņ": "Ņ", "Ó": "Ó", "Ò": "Ò", "Ö": "Ö", @@ -16679,14 +17047,17 @@ var unicodeSymbols = { "Ŕ": "Ŕ", "Ř": "Ř", "Ṙ": "Ṙ", + "Ŗ": "Ŗ", "Ś": "Ś", "Ṥ": "Ṥ", "Š": "Š", "Ṧ": "Ṧ", "Ŝ": "Ŝ", "Ṡ": "Ṡ", + "Ş": "Ş", "Ť": "Ť", "Ṫ": "Ṫ", + "Ţ": "Ţ", "Ú": "Ú", "Ù": "Ù", "Ü": "Ü", @@ -16872,17 +17243,40 @@ var Parser = /*#__PURE__*/function () { if (this.settings.colorIsTextColor) { this.gullet.macros.set("\\color", "\\textcolor"); - } // Try to parse the input + } + try { + // Try to parse the input + var parse = this.parseExpression(false); // If we succeeded, make sure there's an EOF at the end - var parse = this.parseExpression(false); // If we succeeded, make sure there's an EOF at the end + this.expect("EOF"); // End the group namespace for the expression - this.expect("EOF"); // End the group namespace for the expression + if (!this.settings.globalGroup) { + this.gullet.endGroup(); + } - if (!this.settings.globalGroup) { - this.gullet.endGroup(); + return parse; // Close any leftover groups in case of a parse error. + } finally { + this.gullet.endGroups(); } + } + /** + * Fully parse a separate sequence of tokens as a separate job. + * Tokens should be specified in reverse order, as in a MacroDefinition. + */ + ; + + _proto.subparse = function subparse(tokens) { + // Save the next token from the current job. + var oldToken = this.nextToken; + this.consume(); // Run the new job, terminating it with an excess '}' + + this.gullet.pushToken(new Token("}")); + this.gullet.pushTokens(tokens); + var parse = this.parseExpression(false); + this.expect("}"); // Restore the next token from the current job. + this.nextToken = oldToken; return parse; }; @@ -17006,7 +17400,8 @@ var Parser = /*#__PURE__*/function () { */ ; - _proto.handleSupSubscript = function handleSupSubscript(name) { + _proto.handleSupSubscript = function handleSupSubscript(name // For error reporting. + ) { var symbolToken = this.fetch(); var symbol = symbolToken.text; this.consume(); @@ -17080,10 +17475,10 @@ var Parser = /*#__PURE__*/function () { var limits = lex.text === "\\limits"; base.limits = limits; base.alwaysHandleSupSub = true; - } else if (base && base.type === "operatorname" && base.alwaysHandleSupSub) { - var _limits = lex.text === "\\limits"; - - base.limits = _limits; + } else if (base && base.type === "operatorname") { + if (base.alwaysHandleSupSub) { + base.limits = lex.text === "\\limits"; + } } else { throw new src_ParseError("Limit controls must follow a math operator", lex); } @@ -17163,7 +17558,8 @@ var Parser = /*#__PURE__*/function () { */ ; - _proto.parseFunction = function parseFunction(breakOnTokenText, name) { + _proto.parseFunction = function parseFunction(breakOnTokenText, name // For determining its context + ) { var token = this.fetch(); var func = token.text; var funcData = src_functions[func]; @@ -17365,7 +17761,8 @@ var Parser = /*#__PURE__*/function () { */ ; - _proto.parseRegexGroup = function parseRegexGroup(regex, modeName) { + _proto.parseRegexGroup = function parseRegexGroup(regex, modeName // Used to describe the mode in error messages. + ) { var firstToken = this.fetch(); var lastToken = firstToken; var str = ""; @@ -17478,9 +17875,13 @@ var Parser = /*#__PURE__*/function () { _proto.parseUrlGroup = function parseUrlGroup(optional) { this.gullet.lexer.setCatcode("%", 13); // active character + this.gullet.lexer.setCatcode("~", 12); // other character + var res = this.parseStringGroup("url", optional); this.gullet.lexer.setCatcode("%", 14); // comment character + this.gullet.lexer.setCatcode("~", 13); // active character + if (res == null) { return null; } // hyperref package allows backslashes alone in href, but doesn't @@ -17766,7 +18167,7 @@ var Parser = /*#__PURE__*/function () { throw new src_ParseError("Unknown accent ' " + accent + "'", nucleus); } - var command = unicodeAccents[accent][this.mode]; + var command = unicodeAccents[accent][this.mode] || unicodeAccents[accent].text; if (!command) { throw new src_ParseError("Accent " + accent + " unsupported in " + this.mode + " mode", nucleus); @@ -17802,6 +18203,7 @@ Parser.endOfExpression = ["}", "\\endgroup", "\\end", "\\right", "&"]; + /** * Parses an expression using a Parser, then returns the parsed result. */ @@ -17824,12 +18226,11 @@ var parseTree = function parseTree(toParse, settings) { throw new src_ParseError("\\tag works only in display equations"); } - parser.gullet.feed("\\df@tag"); tree = [{ type: "tag", mode: "text", body: tree, - tag: parser.parse() + tag: parser.subparse([new Token("\\df@tag")]) }]; } @@ -17950,7 +18351,7 @@ var renderToHTMLTree = function renderToHTMLTree(expression, options) { /** * Current KaTeX version */ - version: "0.13.2", + version: "0.15.2", /** * Renders the given LaTeX into an HTML+MathML combination, and adds @@ -17969,6 +18370,11 @@ var renderToHTMLTree = function renderToHTMLTree(expression, options) { */ ParseError: src_ParseError, + /** + * The shema of Settings + */ + SETTINGS_SCHEMA: SETTINGS_SCHEMA, + /** * Parses the given LaTeX into KaTeX's internal parse tree structure, * without rendering to HTML or MathML. @@ -18043,7 +18449,7 @@ var renderToHTMLTree = function renderToHTMLTree(expression, options) { /* harmony default export */ var katex_webpack = (katex); -__webpack_exports__ = __webpack_exports__.default; +__webpack_exports__ = __webpack_exports__["default"]; /******/ return __webpack_exports__; /******/ })() ; diff --git a/static/webfonts/KaTeX_AMS-Regular.woff b/static/webfonts/KaTeX_AMS-Regular.woff deleted file mode 100644 index 9b82678..0000000 Binary files a/static/webfonts/KaTeX_AMS-Regular.woff and /dev/null differ diff --git a/static/webfonts/KaTeX_AMS-Regular.woff2 b/static/webfonts/KaTeX_AMS-Regular.woff2 new file mode 100644 index 0000000..0acaaff Binary files /dev/null and b/static/webfonts/KaTeX_AMS-Regular.woff2 differ diff --git a/static/webfonts/KaTeX_Caligraphic-Bold.woff b/static/webfonts/KaTeX_Caligraphic-Bold.woff deleted file mode 100644 index d0e5f82..0000000 Binary files a/static/webfonts/KaTeX_Caligraphic-Bold.woff and /dev/null differ diff --git a/static/webfonts/KaTeX_Caligraphic-Bold.woff2 b/static/webfonts/KaTeX_Caligraphic-Bold.woff2 new file mode 100644 index 0000000..f390922 Binary files /dev/null and b/static/webfonts/KaTeX_Caligraphic-Bold.woff2 differ diff --git a/static/webfonts/KaTeX_Caligraphic-Regular.woff b/static/webfonts/KaTeX_Caligraphic-Regular.woff deleted file mode 100644 index 325fa0a..0000000 Binary files a/static/webfonts/KaTeX_Caligraphic-Regular.woff and /dev/null differ diff --git a/static/webfonts/KaTeX_Caligraphic-Regular.woff2 b/static/webfonts/KaTeX_Caligraphic-Regular.woff2 new file mode 100644 index 0000000..75344a1 Binary files /dev/null and b/static/webfonts/KaTeX_Caligraphic-Regular.woff2 differ diff --git a/static/webfonts/KaTeX_Fraktur-Bold.woff b/static/webfonts/KaTeX_Fraktur-Bold.woff deleted file mode 100644 index 25a39ae..0000000 Binary files a/static/webfonts/KaTeX_Fraktur-Bold.woff and /dev/null differ diff --git a/static/webfonts/KaTeX_Fraktur-Bold.woff2 b/static/webfonts/KaTeX_Fraktur-Bold.woff2 new file mode 100644 index 0000000..395f28b Binary files /dev/null and b/static/webfonts/KaTeX_Fraktur-Bold.woff2 differ diff --git a/static/webfonts/KaTeX_Fraktur-Regular.woff b/static/webfonts/KaTeX_Fraktur-Regular.woff deleted file mode 100644 index e042e7c..0000000 Binary files a/static/webfonts/KaTeX_Fraktur-Regular.woff and /dev/null differ diff --git a/static/webfonts/KaTeX_Fraktur-Regular.woff2 b/static/webfonts/KaTeX_Fraktur-Regular.woff2 new file mode 100644 index 0000000..735f694 Binary files /dev/null and b/static/webfonts/KaTeX_Fraktur-Regular.woff2 differ diff --git a/static/webfonts/KaTeX_Main-Bold.woff b/static/webfonts/KaTeX_Main-Bold.woff deleted file mode 100644 index 49ee886..0000000 Binary files a/static/webfonts/KaTeX_Main-Bold.woff and /dev/null differ diff --git a/static/webfonts/KaTeX_Main-Bold.woff2 b/static/webfonts/KaTeX_Main-Bold.woff2 new file mode 100644 index 0000000..ab2ad21 Binary files /dev/null and b/static/webfonts/KaTeX_Main-Bold.woff2 differ diff --git a/static/webfonts/KaTeX_Main-BoldItalic.woff b/static/webfonts/KaTeX_Main-BoldItalic.woff deleted file mode 100644 index d6ea5a6..0000000 Binary files a/static/webfonts/KaTeX_Main-BoldItalic.woff and /dev/null differ diff --git a/static/webfonts/KaTeX_Main-BoldItalic.woff2 b/static/webfonts/KaTeX_Main-BoldItalic.woff2 new file mode 100644 index 0000000..5931794 Binary files /dev/null and b/static/webfonts/KaTeX_Main-BoldItalic.woff2 differ diff --git a/static/webfonts/KaTeX_Main-Italic.woff b/static/webfonts/KaTeX_Main-Italic.woff deleted file mode 100644 index 3728e33..0000000 Binary files a/static/webfonts/KaTeX_Main-Italic.woff and /dev/null differ diff --git a/static/webfonts/KaTeX_Main-Italic.woff2 b/static/webfonts/KaTeX_Main-Italic.woff2 new file mode 100644 index 0000000..b50920e Binary files /dev/null and b/static/webfonts/KaTeX_Main-Italic.woff2 differ diff --git a/static/webfonts/KaTeX_Main-Regular.woff b/static/webfonts/KaTeX_Main-Regular.woff deleted file mode 100644 index 5c681b1..0000000 Binary files a/static/webfonts/KaTeX_Main-Regular.woff and /dev/null differ diff --git a/static/webfonts/KaTeX_Main-Regular.woff2 b/static/webfonts/KaTeX_Main-Regular.woff2 new file mode 100644 index 0000000..eb24a7b Binary files /dev/null and b/static/webfonts/KaTeX_Main-Regular.woff2 differ diff --git a/static/webfonts/KaTeX_Math-BoldItalic.woff b/static/webfonts/KaTeX_Math-BoldItalic.woff deleted file mode 100644 index b1aebf3..0000000 Binary files a/static/webfonts/KaTeX_Math-BoldItalic.woff and /dev/null differ diff --git a/static/webfonts/KaTeX_Math-BoldItalic.woff2 b/static/webfonts/KaTeX_Math-BoldItalic.woff2 new file mode 100644 index 0000000..2965702 Binary files /dev/null and b/static/webfonts/KaTeX_Math-BoldItalic.woff2 differ diff --git a/static/webfonts/KaTeX_Math-Italic.woff b/static/webfonts/KaTeX_Math-Italic.woff deleted file mode 100644 index 3126ebe..0000000 Binary files a/static/webfonts/KaTeX_Math-Italic.woff and /dev/null differ diff --git a/static/webfonts/KaTeX_Math-Italic.woff2 b/static/webfonts/KaTeX_Math-Italic.woff2 new file mode 100644 index 0000000..215c143 Binary files /dev/null and b/static/webfonts/KaTeX_Math-Italic.woff2 differ diff --git a/static/webfonts/KaTeX_SansSerif-Bold.woff b/static/webfonts/KaTeX_SansSerif-Bold.woff deleted file mode 100644 index 42ee227..0000000 Binary files a/static/webfonts/KaTeX_SansSerif-Bold.woff and /dev/null differ diff --git a/static/webfonts/KaTeX_SansSerif-Bold.woff2 b/static/webfonts/KaTeX_SansSerif-Bold.woff2 new file mode 100644 index 0000000..cfaa3bd Binary files /dev/null and b/static/webfonts/KaTeX_SansSerif-Bold.woff2 differ diff --git a/static/webfonts/KaTeX_SansSerif-Italic.woff b/static/webfonts/KaTeX_SansSerif-Italic.woff deleted file mode 100644 index b4c1660..0000000 Binary files a/static/webfonts/KaTeX_SansSerif-Italic.woff and /dev/null differ diff --git a/static/webfonts/KaTeX_SansSerif-Italic.woff2 b/static/webfonts/KaTeX_SansSerif-Italic.woff2 new file mode 100644 index 0000000..349c06d Binary files /dev/null and b/static/webfonts/KaTeX_SansSerif-Italic.woff2 differ diff --git a/static/webfonts/KaTeX_SansSerif-Regular.woff b/static/webfonts/KaTeX_SansSerif-Regular.woff deleted file mode 100644 index b068a8e..0000000 Binary files a/static/webfonts/KaTeX_SansSerif-Regular.woff and /dev/null differ diff --git a/static/webfonts/KaTeX_SansSerif-Regular.woff2 b/static/webfonts/KaTeX_SansSerif-Regular.woff2 new file mode 100644 index 0000000..a90eea8 Binary files /dev/null and b/static/webfonts/KaTeX_SansSerif-Regular.woff2 differ diff --git a/static/webfonts/KaTeX_Script-Regular.woff b/static/webfonts/KaTeX_Script-Regular.woff deleted file mode 100644 index fe4cb84..0000000 Binary files a/static/webfonts/KaTeX_Script-Regular.woff and /dev/null differ diff --git a/static/webfonts/KaTeX_Script-Regular.woff2 b/static/webfonts/KaTeX_Script-Regular.woff2 new file mode 100644 index 0000000..b3048fc Binary files /dev/null and b/static/webfonts/KaTeX_Script-Regular.woff2 differ diff --git a/static/webfonts/KaTeX_Size1-Regular.woff b/static/webfonts/KaTeX_Size1-Regular.woff deleted file mode 100644 index ae27c24..0000000 Binary files a/static/webfonts/KaTeX_Size1-Regular.woff and /dev/null differ diff --git a/static/webfonts/KaTeX_Size1-Regular.woff2 b/static/webfonts/KaTeX_Size1-Regular.woff2 new file mode 100644 index 0000000..c5a8462 Binary files /dev/null and b/static/webfonts/KaTeX_Size1-Regular.woff2 differ diff --git a/static/webfonts/KaTeX_Size2-Regular.woff b/static/webfonts/KaTeX_Size2-Regular.woff deleted file mode 100644 index 8285fed..0000000 Binary files a/static/webfonts/KaTeX_Size2-Regular.woff and /dev/null differ diff --git a/static/webfonts/KaTeX_Size2-Regular.woff2 b/static/webfonts/KaTeX_Size2-Regular.woff2 new file mode 100644 index 0000000..e1bccfe Binary files /dev/null and b/static/webfonts/KaTeX_Size2-Regular.woff2 differ diff --git a/static/webfonts/KaTeX_Size3-Regular.woff b/static/webfonts/KaTeX_Size3-Regular.woff deleted file mode 100644 index 03bb311..0000000 Binary files a/static/webfonts/KaTeX_Size3-Regular.woff and /dev/null differ diff --git a/static/webfonts/KaTeX_Size3-Regular.woff2 b/static/webfonts/KaTeX_Size3-Regular.woff2 new file mode 100644 index 0000000..249a286 Binary files /dev/null and b/static/webfonts/KaTeX_Size3-Regular.woff2 differ diff --git a/static/webfonts/KaTeX_Size4-Regular.woff b/static/webfonts/KaTeX_Size4-Regular.woff deleted file mode 100644 index 5c99d77..0000000 Binary files a/static/webfonts/KaTeX_Size4-Regular.woff and /dev/null differ diff --git a/static/webfonts/KaTeX_Size4-Regular.woff2 b/static/webfonts/KaTeX_Size4-Regular.woff2 new file mode 100644 index 0000000..680c130 Binary files /dev/null and b/static/webfonts/KaTeX_Size4-Regular.woff2 differ diff --git a/static/webfonts/KaTeX_Typewriter-Regular.woff b/static/webfonts/KaTeX_Typewriter-Regular.woff deleted file mode 100644 index ea5be72..0000000 Binary files a/static/webfonts/KaTeX_Typewriter-Regular.woff and /dev/null differ diff --git a/static/webfonts/KaTeX_Typewriter-Regular.woff2 b/static/webfonts/KaTeX_Typewriter-Regular.woff2 new file mode 100644 index 0000000..771f1af Binary files /dev/null and b/static/webfonts/KaTeX_Typewriter-Regular.woff2 differ -- cgit v1.2.3