Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/dataCobra/hugo-vitae.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--layouts/partials/head.html4
-rw-r--r--static/css/katex.css70
-rw-r--r--static/js/auto-render.js10
-rw-r--r--static/js/katex.js2972
-rw-r--r--static/webfonts/KaTeX_AMS-Regular.woffbin36920 -> 0 bytes
-rw-r--r--static/webfonts/KaTeX_AMS-Regular.woff2bin0 -> 28076 bytes
-rw-r--r--static/webfonts/KaTeX_Caligraphic-Bold.woffbin9384 -> 0 bytes
-rw-r--r--static/webfonts/KaTeX_Caligraphic-Bold.woff2bin0 -> 6912 bytes
-rw-r--r--static/webfonts/KaTeX_Caligraphic-Regular.woffbin9160 -> 0 bytes
-rw-r--r--static/webfonts/KaTeX_Caligraphic-Regular.woff2bin0 -> 6908 bytes
-rw-r--r--static/webfonts/KaTeX_Fraktur-Bold.woffbin16216 -> 0 bytes
-rw-r--r--static/webfonts/KaTeX_Fraktur-Bold.woff2bin0 -> 11348 bytes
-rw-r--r--static/webfonts/KaTeX_Fraktur-Regular.woffbin15884 -> 0 bytes
-rw-r--r--static/webfonts/KaTeX_Fraktur-Regular.woff2bin0 -> 11316 bytes
-rw-r--r--static/webfonts/KaTeX_Main-Bold.woffbin35060 -> 0 bytes
-rw-r--r--static/webfonts/KaTeX_Main-Bold.woff2bin0 -> 25324 bytes
-rw-r--r--static/webfonts/KaTeX_Main-BoldItalic.woffbin24504 -> 0 bytes
-rw-r--r--static/webfonts/KaTeX_Main-BoldItalic.woff2bin0 -> 16780 bytes
-rw-r--r--static/webfonts/KaTeX_Main-Italic.woffbin25360 -> 0 bytes
-rw-r--r--static/webfonts/KaTeX_Main-Italic.woff2bin0 -> 16988 bytes
-rw-r--r--static/webfonts/KaTeX_Main-Regular.woffbin37864 -> 0 bytes
-rw-r--r--static/webfonts/KaTeX_Main-Regular.woff2bin0 -> 26272 bytes
-rw-r--r--static/webfonts/KaTeX_Math-BoldItalic.woffbin23988 -> 0 bytes
-rw-r--r--static/webfonts/KaTeX_Math-BoldItalic.woff2bin0 -> 16400 bytes
-rw-r--r--static/webfonts/KaTeX_Math-Italic.woffbin24672 -> 0 bytes
-rw-r--r--static/webfonts/KaTeX_Math-Italic.woff2bin0 -> 16440 bytes
-rw-r--r--static/webfonts/KaTeX_SansSerif-Bold.woffbin17988 -> 0 bytes
-rw-r--r--static/webfonts/KaTeX_SansSerif-Bold.woff2bin0 -> 12216 bytes
-rw-r--r--static/webfonts/KaTeX_SansSerif-Italic.woffbin17052 -> 0 bytes
-rw-r--r--static/webfonts/KaTeX_SansSerif-Italic.woff2bin0 -> 12028 bytes
-rw-r--r--static/webfonts/KaTeX_SansSerif-Regular.woffbin15724 -> 0 bytes
-rw-r--r--static/webfonts/KaTeX_SansSerif-Regular.woff2bin0 -> 10344 bytes
-rw-r--r--static/webfonts/KaTeX_Script-Regular.woffbin13000 -> 0 bytes
-rw-r--r--static/webfonts/KaTeX_Script-Regular.woff2bin0 -> 9644 bytes
-rw-r--r--static/webfonts/KaTeX_Size1-Regular.woffbin6304 -> 0 bytes
-rw-r--r--static/webfonts/KaTeX_Size1-Regular.woff2bin0 -> 5468 bytes
-rw-r--r--static/webfonts/KaTeX_Size2-Regular.woffbin6016 -> 0 bytes
-rw-r--r--static/webfonts/KaTeX_Size2-Regular.woff2bin0 -> 5208 bytes
-rw-r--r--static/webfonts/KaTeX_Size3-Regular.woffbin4156 -> 0 bytes
-rw-r--r--static/webfonts/KaTeX_Size3-Regular.woff2bin0 -> 3624 bytes
-rw-r--r--static/webfonts/KaTeX_Size4-Regular.woffbin5828 -> 0 bytes
-rw-r--r--static/webfonts/KaTeX_Size4-Regular.woff2bin0 -> 4928 bytes
-rw-r--r--static/webfonts/KaTeX_Typewriter-Regular.woffbin19708 -> 0 bytes
-rw-r--r--static/webfonts/KaTeX_Typewriter-Regular.woff2bin0 -> 13568 bytes
44 files changed, 1725 insertions, 1331 deletions
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 @@
<link rel="stylesheet" type="text/css" media="screen" href="{{ relURL "/css/all.css" }}" />
{{- if or .Params.math .Site.Params.math -}}
<link rel="stylesheet" href="{{ relURL "/css/katex.css" }}" crossorigin="anonymous">
-<script defer src="{{ relURL "js/katex.js" }}" integrity="sha384-PFWG8XW41D5NzhNv5FegM1CUkw9nNLdWug8DuwnUoNEVop9n5frjcnbtsZtxTNjw" crossorigin="anonymous"></script>
-<script defer src="{{ relURL "js/auto-render.js" }}" integrity="sha384-EN2q+JG5/3Z8gD7hT5WZqq+W+9wQR4P3IezfuZmGG5RkNXaaaks85seDJO7WkZlY" crossorigin="anonymous" onload="renderMathInElement(document.body);"></script>
+<script defer src="{{ relURL "js/katex.js" }}" integrity="sha384-HELAAZU8xvHgfT/8z4Mhmu+E2z3oBrMEuywaMh/CEd5uTZIDSct7TEaX+S43+dOi" crossorigin="anonymous"></script>
+<script defer src="{{ relURL "js/auto-render.js" }}" integrity="sha384-0QrOZ8WIARJUoT5pH7Iuzi7iq0mXUXLF9yj5ZvYxTkMRv1zcaPQiOQ9ksHYbKw7M" crossorigin="anonymous" onload="renderMathInElement(document.body);"></script>
<script>
document.addEventListener("DOMContentLoaded", function() { renderMathInElement(document.body, { delimiters: [ {left: "$$", right: "$$", display: true}, {left: "$", right: "$", display: false} ] }); });
</script>
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 <type>"
+ },
+ 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 <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 <def>",
+ 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 <size>",
+ 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 <n>",
+ 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 <n>",
+ 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 += "</" + tagName + ">";
- 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 (<a>) 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 (<img>) 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 = "<img src='" + this.src + " 'alt='" + this.alt + "' "; // Add the styles, after hyphenation
-
- var styles = "";
-
- 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) + "\"";
- }
-
- markup += "'/>";
- return markup;
- };
-
- return Img;
-}();
-var iCombinations = {
- 'î': "\u0131\u0302",
- 'ï': "\u0131\u0308",
- 'í': "\u0131\u0301",
- // 'ī': '\u0131\u0304', // enable when we add Extended Latin
- 'ì': "\u0131\u0300"
-};
-/**
- * A symbol node contains information about a single symbol. It either renders
- * to a single text node, or a span with a single text node in it, depending on
- * whether it has CSS classes, styles, or needs italic correction.
- */
-
-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 = 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 = "<span";
-
- if (this.classes.length) {
- needsSpan = true;
- markup += " class=\"";
- markup += utils.escape(createClass(this.classes));
- markup += "\"";
- }
-
- var styles = "";
-
- if (this.italic > 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 += "</span>";
- 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 = "<svg"; // Apply attributes
-
- for (var attr in this.attributes) {
- if (Object.prototype.hasOwnProperty.call(this.attributes, attr)) {
- markup += " " + attr + "='" + this.attributes[attr] + "'";
- }
- }
-
- markup += ">";
-
- for (var i = 0; i < this.children.length; i++) {
- markup += this.children[i].toMarkup();
- }
-
- markup += "</svg>";
- return markup;
- };
-
- return SvgNode;
-}();
-var PathNode = /*#__PURE__*/function () {
- function PathNode(pathName, alternate) {
- this.pathName = void 0;
- this.alternate = void 0;
- this.pathName = pathName;
- this.alternate = alternate; // Used only for \sqrt, \phase, & tall delims
- }
-
- var _proto6 = PathNode.prototype;
-
- _proto6.toNode = function toNode() {
- var svgNS = "http://www.w3.org/2000/svg";
- var node = document.createElementNS(svgNS, "path");
-
- if (this.alternate) {
- node.setAttribute("d", this.alternate);
- } else {
- node.setAttribute("d", path[this.pathName]);
- }
-
- return node;
- };
-
- _proto6.toMarkup = function toMarkup() {
- if (this.alternate) {
- return "<path d='" + this.alternate + "'/>";
- } else {
- return "<path d='" + path[this.pathName] + "'/>";
- }
- };
-
- 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 = "<line";
-
- for (var attr in this.attributes) {
- if (Object.prototype.hasOwnProperty.call(this.attributes, attr)) {
- markup += " " + attr + "='" + this.attributes[attr] + "'";
- }
- }
-
- markup += "/>";
- return markup;
- };
-
- return LineNode;
-}();
-function assertSymbolDomNode(group) {
- if (group instanceof SymbolNode) {
- return group;
- } else {
- throw new Error("Expected symbolNode but got " + String(group) + ".");
- }
-}
-function assertSpan(group) {
- if (group instanceof Span) {
- return group;
- } else {
- throw new Error("Expected span<HtmlDomNode> 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],
@@ -3637,11 +3213,9 @@ var sigmasAndXis = {
var extraCharacterMap = {
// Latin-1
'Å': 'A',
- 'Ç': 'C',
'Ð': 'D',
'Þ': 'o',
'å': 'a',
- 'ç': 'c',
'ð': 'd',
'þ': 'o',
// Cyrillic
@@ -3793,6 +3367,996 @@ function getGlobalMetrics(size) {
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 += "</" + tagName + ">";
+ 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 (<a>) 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 (<img>) 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 = "<img src='" + this.src + " 'alt='" + this.alt + "' "; // Add the styles, after hyphenation
+
+ var styles = "";
+
+ 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) + "\"";
+ }
+
+ markup += "'/>";
+ return markup;
+ };
+
+ return Img;
+}();
+var iCombinations = {
+ 'î': "\u0131\u0302",
+ 'ï': "\u0131\u0308",
+ 'í': "\u0131\u0301",
+ // 'ī': '\u0131\u0304', // enable when we add Extended Latin
+ 'ì': "\u0131\u0300"
+};
+/**
+ * A symbol node contains information about a single symbol. It either renders
+ * to a single text node, or a span with a single text node in it, depending on
+ * whether it has CSS classes, styles, or needs italic correction.
+ */
+
+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 = "<span";
+
+ if (this.classes.length) {
+ needsSpan = true;
+ markup += " class=\"";
+ markup += utils.escape(createClass(this.classes));
+ markup += "\"";
+ }
+
+ var styles = "";
+
+ if (this.italic > 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 += "</span>";
+ 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 = "<svg xmlns=\"http://www.w3.org/2000/svg\""; // Apply attributes
+
+ for (var attr in this.attributes) {
+ if (Object.prototype.hasOwnProperty.call(this.attributes, attr)) {
+ markup += " " + attr + "='" + this.attributes[attr] + "'";
+ }
+ }
+
+ markup += ">";
+
+ for (var i = 0; i < this.children.length; i++) {
+ markup += this.children[i].toMarkup();
+ }
+
+ markup += "</svg>";
+ return markup;
+ };
+
+ return SvgNode;
+}();
+var PathNode = /*#__PURE__*/function () {
+ function PathNode(pathName, alternate) {
+ this.pathName = void 0;
+ this.alternate = void 0;
+ this.pathName = pathName;
+ this.alternate = alternate; // Used only for \sqrt, \phase, & tall delims
+ }
+
+ var _proto6 = PathNode.prototype;
+
+ _proto6.toNode = function toNode() {
+ var svgNS = "http://www.w3.org/2000/svg";
+ var node = document.createElementNS(svgNS, "path");
+
+ if (this.alternate) {
+ node.setAttribute("d", this.alternate);
+ } else {
+ node.setAttribute("d", path[this.pathName]);
+ }
+
+ return node;
+ };
+
+ _proto6.toMarkup = function toMarkup() {
+ if (this.alternate) {
+ return "<path d='" + this.alternate + "'/>";
+ } else {
+ return "<path d='" + path[this.pathName] + "'/>";
+ }
+ };
+
+ 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 = "<line";
+
+ for (var attr in this.attributes) {
+ if (Object.prototype.hasOwnProperty.call(this.attributes, attr)) {
+ markup += " " + attr + "='" + this.attributes[attr] + "'";
+ }
+ }
+
+ markup += "/>";
+ return markup;
+ };
+
+ return LineNode;
+}();
+function assertSymbolDomNode(group) {
+ if (group instanceof SymbolNode) {
+ return group;
+ } else {
+ throw new Error("Expected symbolNode but got " + String(group) + ".");
+ }
+}
+function assertSpan(group) {
+ if (group instanceof Span) {
+ return group;
+ } else {
+ throw new Error("Expected span<HtmlDomNode> but got " + String(group) + ".");
+ }
+}
;// CONCATENATED MODULE: ./src/symbols.js
/**
* This file holds a list of all no-argument functions and single-character
@@ -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");
@@ -4480,6 +5044,8 @@ defineSymbol(symbols_text, main, accent, "\u02D8", "\\u"); // breve
defineSymbol(symbols_text, main, accent, "\u02D9", "\\."); // dot above
+defineSymbol(symbols_text, main, accent, "\xB8", "\\c"); // cedilla
+
defineSymbol(symbols_text, main, accent, "\u02DA", "\\r"); // ring above
defineSymbol(symbols_text, main, accent, "\u02C7", "\\v"); // caron
@@ -4661,7 +5227,7 @@ for (var _i4 = 0; _i4 < 10; _i4++) {
// TODO(edemaine): Fix this.
-var extraLatin = "\xC7\xD0\xDE\xE7\xFE";
+var extraLatin = "\xD0\xDE\xFE";
for (var _i5 = 0; _i5 < extraLatin.length; _i5++) {
var _ch5 = extraLatin.charAt(_i5);
@@ -4753,434 +5319,6 @@ var wideCharacterFont = function wideCharacterFont(wideChar, mode) {
throw new src_ParseError("Unsupported character: " + wideChar);
}
};
-;// 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);
-};
;// 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 "<mtext>" + this.character + "</mtext>";
} else {
- return "<mspace width=\"" + this.width + "em\"/>";
+ return "<mspace width=\"" + makeEm(this.width) + "\"/>";
}
}
/**
@@ -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;
@@ -9931,6 +10107,109 @@ function defineEnvironment(_ref) {
_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.
+ */
+
+/**
+ * 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 // 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 <menclose>, 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 <mo> default space is 5/18 em, so <mrel> 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];
@@ -14881,6 +15192,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
}
@@ -15938,6 +16263,15 @@ var MacroExpander = /*#__PURE__*/function () {
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
@@ -17970,6 +18371,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
--- a/static/webfonts/KaTeX_AMS-Regular.woff
+++ /dev/null
Binary files differ
diff --git a/static/webfonts/KaTeX_AMS-Regular.woff2 b/static/webfonts/KaTeX_AMS-Regular.woff2
new file mode 100644
index 0000000..0acaaff
--- /dev/null
+++ b/static/webfonts/KaTeX_AMS-Regular.woff2
Binary files differ
diff --git a/static/webfonts/KaTeX_Caligraphic-Bold.woff b/static/webfonts/KaTeX_Caligraphic-Bold.woff
deleted file mode 100644
index d0e5f82..0000000
--- a/static/webfonts/KaTeX_Caligraphic-Bold.woff
+++ /dev/null
Binary files differ
diff --git a/static/webfonts/KaTeX_Caligraphic-Bold.woff2 b/static/webfonts/KaTeX_Caligraphic-Bold.woff2
new file mode 100644
index 0000000..f390922
--- /dev/null
+++ b/static/webfonts/KaTeX_Caligraphic-Bold.woff2
Binary files differ
diff --git a/static/webfonts/KaTeX_Caligraphic-Regular.woff b/static/webfonts/KaTeX_Caligraphic-Regular.woff
deleted file mode 100644
index 325fa0a..0000000
--- a/static/webfonts/KaTeX_Caligraphic-Regular.woff
+++ /dev/null
Binary files differ
diff --git a/static/webfonts/KaTeX_Caligraphic-Regular.woff2 b/static/webfonts/KaTeX_Caligraphic-Regular.woff2
new file mode 100644
index 0000000..75344a1
--- /dev/null
+++ b/static/webfonts/KaTeX_Caligraphic-Regular.woff2
Binary files differ
diff --git a/static/webfonts/KaTeX_Fraktur-Bold.woff b/static/webfonts/KaTeX_Fraktur-Bold.woff
deleted file mode 100644
index 25a39ae..0000000
--- a/static/webfonts/KaTeX_Fraktur-Bold.woff
+++ /dev/null
Binary files differ
diff --git a/static/webfonts/KaTeX_Fraktur-Bold.woff2 b/static/webfonts/KaTeX_Fraktur-Bold.woff2
new file mode 100644
index 0000000..395f28b
--- /dev/null
+++ b/static/webfonts/KaTeX_Fraktur-Bold.woff2
Binary files differ
diff --git a/static/webfonts/KaTeX_Fraktur-Regular.woff b/static/webfonts/KaTeX_Fraktur-Regular.woff
deleted file mode 100644
index e042e7c..0000000
--- a/static/webfonts/KaTeX_Fraktur-Regular.woff
+++ /dev/null
Binary files differ
diff --git a/static/webfonts/KaTeX_Fraktur-Regular.woff2 b/static/webfonts/KaTeX_Fraktur-Regular.woff2
new file mode 100644
index 0000000..735f694
--- /dev/null
+++ b/static/webfonts/KaTeX_Fraktur-Regular.woff2
Binary files differ
diff --git a/static/webfonts/KaTeX_Main-Bold.woff b/static/webfonts/KaTeX_Main-Bold.woff
deleted file mode 100644
index 49ee886..0000000
--- a/static/webfonts/KaTeX_Main-Bold.woff
+++ /dev/null
Binary files differ
diff --git a/static/webfonts/KaTeX_Main-Bold.woff2 b/static/webfonts/KaTeX_Main-Bold.woff2
new file mode 100644
index 0000000..ab2ad21
--- /dev/null
+++ b/static/webfonts/KaTeX_Main-Bold.woff2
Binary files differ
diff --git a/static/webfonts/KaTeX_Main-BoldItalic.woff b/static/webfonts/KaTeX_Main-BoldItalic.woff
deleted file mode 100644
index d6ea5a6..0000000
--- a/static/webfonts/KaTeX_Main-BoldItalic.woff
+++ /dev/null
Binary files differ
diff --git a/static/webfonts/KaTeX_Main-BoldItalic.woff2 b/static/webfonts/KaTeX_Main-BoldItalic.woff2
new file mode 100644
index 0000000..5931794
--- /dev/null
+++ b/static/webfonts/KaTeX_Main-BoldItalic.woff2
Binary files differ
diff --git a/static/webfonts/KaTeX_Main-Italic.woff b/static/webfonts/KaTeX_Main-Italic.woff
deleted file mode 100644
index 3728e33..0000000
--- a/static/webfonts/KaTeX_Main-Italic.woff
+++ /dev/null
Binary files differ
diff --git a/static/webfonts/KaTeX_Main-Italic.woff2 b/static/webfonts/KaTeX_Main-Italic.woff2
new file mode 100644
index 0000000..b50920e
--- /dev/null
+++ b/static/webfonts/KaTeX_Main-Italic.woff2
Binary files differ
diff --git a/static/webfonts/KaTeX_Main-Regular.woff b/static/webfonts/KaTeX_Main-Regular.woff
deleted file mode 100644
index 5c681b1..0000000
--- a/static/webfonts/KaTeX_Main-Regular.woff
+++ /dev/null
Binary files differ
diff --git a/static/webfonts/KaTeX_Main-Regular.woff2 b/static/webfonts/KaTeX_Main-Regular.woff2
new file mode 100644
index 0000000..eb24a7b
--- /dev/null
+++ b/static/webfonts/KaTeX_Main-Regular.woff2
Binary files differ
diff --git a/static/webfonts/KaTeX_Math-BoldItalic.woff b/static/webfonts/KaTeX_Math-BoldItalic.woff
deleted file mode 100644
index b1aebf3..0000000
--- a/static/webfonts/KaTeX_Math-BoldItalic.woff
+++ /dev/null
Binary files differ
diff --git a/static/webfonts/KaTeX_Math-BoldItalic.woff2 b/static/webfonts/KaTeX_Math-BoldItalic.woff2
new file mode 100644
index 0000000..2965702
--- /dev/null
+++ b/static/webfonts/KaTeX_Math-BoldItalic.woff2
Binary files differ
diff --git a/static/webfonts/KaTeX_Math-Italic.woff b/static/webfonts/KaTeX_Math-Italic.woff
deleted file mode 100644
index 3126ebe..0000000
--- a/static/webfonts/KaTeX_Math-Italic.woff
+++ /dev/null
Binary files differ
diff --git a/static/webfonts/KaTeX_Math-Italic.woff2 b/static/webfonts/KaTeX_Math-Italic.woff2
new file mode 100644
index 0000000..215c143
--- /dev/null
+++ b/static/webfonts/KaTeX_Math-Italic.woff2
Binary files differ
diff --git a/static/webfonts/KaTeX_SansSerif-Bold.woff b/static/webfonts/KaTeX_SansSerif-Bold.woff
deleted file mode 100644
index 42ee227..0000000
--- a/static/webfonts/KaTeX_SansSerif-Bold.woff
+++ /dev/null
Binary files differ
diff --git a/static/webfonts/KaTeX_SansSerif-Bold.woff2 b/static/webfonts/KaTeX_SansSerif-Bold.woff2
new file mode 100644
index 0000000..cfaa3bd
--- /dev/null
+++ b/static/webfonts/KaTeX_SansSerif-Bold.woff2
Binary files differ
diff --git a/static/webfonts/KaTeX_SansSerif-Italic.woff b/static/webfonts/KaTeX_SansSerif-Italic.woff
deleted file mode 100644
index b4c1660..0000000
--- a/static/webfonts/KaTeX_SansSerif-Italic.woff
+++ /dev/null
Binary files differ
diff --git a/static/webfonts/KaTeX_SansSerif-Italic.woff2 b/static/webfonts/KaTeX_SansSerif-Italic.woff2
new file mode 100644
index 0000000..349c06d
--- /dev/null
+++ b/static/webfonts/KaTeX_SansSerif-Italic.woff2
Binary files differ
diff --git a/static/webfonts/KaTeX_SansSerif-Regular.woff b/static/webfonts/KaTeX_SansSerif-Regular.woff
deleted file mode 100644
index b068a8e..0000000
--- a/static/webfonts/KaTeX_SansSerif-Regular.woff
+++ /dev/null
Binary files differ
diff --git a/static/webfonts/KaTeX_SansSerif-Regular.woff2 b/static/webfonts/KaTeX_SansSerif-Regular.woff2
new file mode 100644
index 0000000..a90eea8
--- /dev/null
+++ b/static/webfonts/KaTeX_SansSerif-Regular.woff2
Binary files differ
diff --git a/static/webfonts/KaTeX_Script-Regular.woff b/static/webfonts/KaTeX_Script-Regular.woff
deleted file mode 100644
index fe4cb84..0000000
--- a/static/webfonts/KaTeX_Script-Regular.woff
+++ /dev/null
Binary files differ
diff --git a/static/webfonts/KaTeX_Script-Regular.woff2 b/static/webfonts/KaTeX_Script-Regular.woff2
new file mode 100644
index 0000000..b3048fc
--- /dev/null
+++ b/static/webfonts/KaTeX_Script-Regular.woff2
Binary files differ
diff --git a/static/webfonts/KaTeX_Size1-Regular.woff b/static/webfonts/KaTeX_Size1-Regular.woff
deleted file mode 100644
index ae27c24..0000000
--- a/static/webfonts/KaTeX_Size1-Regular.woff
+++ /dev/null
Binary files differ
diff --git a/static/webfonts/KaTeX_Size1-Regular.woff2 b/static/webfonts/KaTeX_Size1-Regular.woff2
new file mode 100644
index 0000000..c5a8462
--- /dev/null
+++ b/static/webfonts/KaTeX_Size1-Regular.woff2
Binary files differ
diff --git a/static/webfonts/KaTeX_Size2-Regular.woff b/static/webfonts/KaTeX_Size2-Regular.woff
deleted file mode 100644
index 8285fed..0000000
--- a/static/webfonts/KaTeX_Size2-Regular.woff
+++ /dev/null
Binary files differ
diff --git a/static/webfonts/KaTeX_Size2-Regular.woff2 b/static/webfonts/KaTeX_Size2-Regular.woff2
new file mode 100644
index 0000000..e1bccfe
--- /dev/null
+++ b/static/webfonts/KaTeX_Size2-Regular.woff2
Binary files differ
diff --git a/static/webfonts/KaTeX_Size3-Regular.woff b/static/webfonts/KaTeX_Size3-Regular.woff
deleted file mode 100644
index 03bb311..0000000
--- a/static/webfonts/KaTeX_Size3-Regular.woff
+++ /dev/null
Binary files differ
diff --git a/static/webfonts/KaTeX_Size3-Regular.woff2 b/static/webfonts/KaTeX_Size3-Regular.woff2
new file mode 100644
index 0000000..249a286
--- /dev/null
+++ b/static/webfonts/KaTeX_Size3-Regular.woff2
Binary files differ
diff --git a/static/webfonts/KaTeX_Size4-Regular.woff b/static/webfonts/KaTeX_Size4-Regular.woff
deleted file mode 100644
index 5c99d77..0000000
--- a/static/webfonts/KaTeX_Size4-Regular.woff
+++ /dev/null
Binary files differ
diff --git a/static/webfonts/KaTeX_Size4-Regular.woff2 b/static/webfonts/KaTeX_Size4-Regular.woff2
new file mode 100644
index 0000000..680c130
--- /dev/null
+++ b/static/webfonts/KaTeX_Size4-Regular.woff2
Binary files differ
diff --git a/static/webfonts/KaTeX_Typewriter-Regular.woff b/static/webfonts/KaTeX_Typewriter-Regular.woff
deleted file mode 100644
index ea5be72..0000000
--- a/static/webfonts/KaTeX_Typewriter-Regular.woff
+++ /dev/null
Binary files differ
diff --git a/static/webfonts/KaTeX_Typewriter-Regular.woff2 b/static/webfonts/KaTeX_Typewriter-Regular.woff2
new file mode 100644
index 0000000..771f1af
--- /dev/null
+++ b/static/webfonts/KaTeX_Typewriter-Regular.woff2
Binary files differ