You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

18455 lines
604 KiB

  1. (function webpackUniversalModuleDefinition(root, factory) {
  2. if(typeof exports === 'object' && typeof module === 'object')
  3. module.exports = factory();
  4. else if(typeof define === 'function' && define.amd)
  5. define([], factory);
  6. else if(typeof exports === 'object')
  7. exports["katex"] = factory();
  8. else
  9. root["katex"] = factory();
  10. })((typeof self !== 'undefined' ? self : this), function() {
  11. return /******/ (function() { // webpackBootstrap
  12. /******/ "use strict";
  13. /******/ // The require scope
  14. /******/ var __webpack_require__ = {};
  15. /******/
  16. /************************************************************************/
  17. /******/ /* webpack/runtime/define property getters */
  18. /******/ !function() {
  19. /******/ // define getter functions for harmony exports
  20. /******/ __webpack_require__.d = function(exports, definition) {
  21. /******/ for(var key in definition) {
  22. /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
  23. /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
  24. /******/ }
  25. /******/ }
  26. /******/ };
  27. /******/ }();
  28. /******/
  29. /******/ /* webpack/runtime/hasOwnProperty shorthand */
  30. /******/ !function() {
  31. /******/ __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); }
  32. /******/ }();
  33. /******/
  34. /************************************************************************/
  35. var __webpack_exports__ = {};
  36. // EXPORTS
  37. __webpack_require__.d(__webpack_exports__, {
  38. "default": function() { return /* binding */ katex_webpack; }
  39. });
  40. ;// CONCATENATED MODULE: ./src/ParseError.js
  41. /**
  42. * This is the ParseError class, which is the main error thrown by KaTeX
  43. * functions when something has gone wrong. This is used to distinguish internal
  44. * errors from errors in the expression that the user provided.
  45. *
  46. * If possible, a caller should provide a Token or ParseNode with information
  47. * about where in the source string the problem occurred.
  48. */
  49. var ParseError = // Error position based on passed-in Token or ParseNode.
  50. function ParseError(message, // The error message
  51. token // An object providing position information
  52. ) {
  53. this.position = void 0;
  54. var error = "KaTeX parse error: " + message;
  55. var start;
  56. var loc = token && token.loc;
  57. if (loc && loc.start <= loc.end) {
  58. // If we have the input and a position, make the error a bit fancier
  59. // Get the input
  60. var input = loc.lexer.input; // Prepend some information
  61. start = loc.start;
  62. var end = loc.end;
  63. if (start === input.length) {
  64. error += " at end of input: ";
  65. } else {
  66. error += " at position " + (start + 1) + ": ";
  67. } // Underline token in question using combining underscores
  68. var underlined = input.slice(start, end).replace(/[^]/g, "$&\u0332"); // Extract some context from the input and add it to the error
  69. var left;
  70. if (start > 15) {
  71. left = "…" + input.slice(start - 15, start);
  72. } else {
  73. left = input.slice(0, start);
  74. }
  75. var right;
  76. if (end + 15 < input.length) {
  77. right = input.slice(end, end + 15) + "…";
  78. } else {
  79. right = input.slice(end);
  80. }
  81. error += left + underlined + right;
  82. } // Some hackery to make ParseError a prototype of Error
  83. // See http://stackoverflow.com/a/8460753
  84. var self = new Error(error);
  85. self.name = "ParseError"; // $FlowFixMe
  86. self.__proto__ = ParseError.prototype; // $FlowFixMe
  87. self.position = start;
  88. return self;
  89. }; // $FlowFixMe More hackery
  90. ParseError.prototype.__proto__ = Error.prototype;
  91. /* harmony default export */ var src_ParseError = (ParseError);
  92. ;// CONCATENATED MODULE: ./src/utils.js
  93. /**
  94. * This file contains a list of utility functions which are useful in other
  95. * files.
  96. */
  97. /**
  98. * Return whether an element is contained in a list
  99. */
  100. var contains = function contains(list, elem) {
  101. return list.indexOf(elem) !== -1;
  102. };
  103. /**
  104. * Provide a default value if a setting is undefined
  105. * NOTE: Couldn't use `T` as the output type due to facebook/flow#5022.
  106. */
  107. var deflt = function deflt(setting, defaultIfUndefined) {
  108. return setting === undefined ? defaultIfUndefined : setting;
  109. }; // hyphenate and escape adapted from Facebook's React under Apache 2 license
  110. var uppercase = /([A-Z])/g;
  111. var hyphenate = function hyphenate(str) {
  112. return str.replace(uppercase, "-$1").toLowerCase();
  113. };
  114. var ESCAPE_LOOKUP = {
  115. "&": "&amp;",
  116. ">": "&gt;",
  117. "<": "&lt;",
  118. "\"": "&quot;",
  119. "'": "&#x27;"
  120. };
  121. var ESCAPE_REGEX = /[&><"']/g;
  122. /**
  123. * Escapes text to prevent scripting attacks.
  124. */
  125. function utils_escape(text) {
  126. return String(text).replace(ESCAPE_REGEX, function (match) {
  127. return ESCAPE_LOOKUP[match];
  128. });
  129. }
  130. /**
  131. * Sometimes we want to pull out the innermost element of a group. In most
  132. * cases, this will just be the group itself, but when ordgroups and colors have
  133. * a single element, we want to pull that out.
  134. */
  135. var getBaseElem = function getBaseElem(group) {
  136. if (group.type === "ordgroup") {
  137. if (group.body.length === 1) {
  138. return getBaseElem(group.body[0]);
  139. } else {
  140. return group;
  141. }
  142. } else if (group.type === "color") {
  143. if (group.body.length === 1) {
  144. return getBaseElem(group.body[0]);
  145. } else {
  146. return group;
  147. }
  148. } else if (group.type === "font") {
  149. return getBaseElem(group.body);
  150. } else {
  151. return group;
  152. }
  153. };
  154. /**
  155. * TeXbook algorithms often reference "character boxes", which are simply groups
  156. * with a single character in them. To decide if something is a character box,
  157. * we find its innermost group, and see if it is a single character.
  158. */
  159. var isCharacterBox = function isCharacterBox(group) {
  160. var baseElem = getBaseElem(group); // These are all they types of groups which hold single characters
  161. return baseElem.type === "mathord" || baseElem.type === "textord" || baseElem.type === "atom";
  162. };
  163. var assert = function assert(value) {
  164. if (!value) {
  165. throw new Error('Expected non-null, but got ' + String(value));
  166. }
  167. return value;
  168. };
  169. /**
  170. * Return the protocol of a URL, or "_relative" if the URL does not specify a
  171. * protocol (and thus is relative).
  172. */
  173. var protocolFromUrl = function protocolFromUrl(url) {
  174. var protocol = /^\s*([^\\/#]*?)(?::|&#0*58|&#x0*3a)/i.exec(url);
  175. return protocol != null ? protocol[1] : "_relative";
  176. };
  177. /* harmony default export */ var utils = ({
  178. contains: contains,
  179. deflt: deflt,
  180. escape: utils_escape,
  181. hyphenate: hyphenate,
  182. getBaseElem: getBaseElem,
  183. isCharacterBox: isCharacterBox,
  184. protocolFromUrl: protocolFromUrl
  185. });
  186. ;// CONCATENATED MODULE: ./src/Settings.js
  187. /* eslint no-console:0 */
  188. /**
  189. * This is a module for storing settings passed into KaTeX. It correctly handles
  190. * default settings.
  191. */
  192. // TODO: automatically generate documentation
  193. // TODO: check all properties on Settings exist
  194. // TODO: check the type of a property on Settings matches
  195. var SETTINGS_SCHEMA = {
  196. displayMode: {
  197. type: "boolean",
  198. 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.",
  199. cli: "-d, --display-mode"
  200. },
  201. output: {
  202. type: {
  203. enum: ["htmlAndMathml", "html", "mathml"]
  204. },
  205. description: "Determines the markup language of the output.",
  206. cli: "-F, --format <type>"
  207. },
  208. leqno: {
  209. type: "boolean",
  210. description: "Render display math in leqno style (left-justified tags)."
  211. },
  212. fleqn: {
  213. type: "boolean",
  214. description: "Render display math flush left."
  215. },
  216. throwOnError: {
  217. type: "boolean",
  218. default: true,
  219. cli: "-t, --no-throw-on-error",
  220. cliDescription: "Render errors (in the color given by --error-color) ins" + "tead of throwing a ParseError exception when encountering an error."
  221. },
  222. errorColor: {
  223. type: "string",
  224. default: "#cc0000",
  225. cli: "-c, --error-color <color>",
  226. cliDescription: "A color string given in the format 'rgb' or 'rrggbb' " + "(no #). This option determines the color of errors rendered by the " + "-t option.",
  227. cliProcessor: function cliProcessor(color) {
  228. return "#" + color;
  229. }
  230. },
  231. macros: {
  232. type: "object",
  233. cli: "-m, --macro <def>",
  234. cliDescription: "Define custom macro of the form '\\foo:expansion' (use " + "multiple -m arguments for multiple macros).",
  235. cliDefault: [],
  236. cliProcessor: function cliProcessor(def, defs) {
  237. defs.push(def);
  238. return defs;
  239. }
  240. },
  241. minRuleThickness: {
  242. type: "number",
  243. 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`.",
  244. processor: function processor(t) {
  245. return Math.max(0, t);
  246. },
  247. cli: "--min-rule-thickness <size>",
  248. cliProcessor: parseFloat
  249. },
  250. colorIsTextColor: {
  251. type: "boolean",
  252. description: "Makes \\color behave like LaTeX's 2-argument \\textcolor, " + "instead of LaTeX's one-argument \\color mode change.",
  253. cli: "-b, --color-is-text-color"
  254. },
  255. strict: {
  256. type: [{
  257. enum: ["warn", "ignore", "error"]
  258. }, "boolean", "function"],
  259. description: "Turn on strict / LaTeX faithfulness mode, which throws an " + "error if the input uses features that are not supported by LaTeX.",
  260. cli: "-S, --strict",
  261. cliDefault: false
  262. },
  263. trust: {
  264. type: ["boolean", "function"],
  265. description: "Trust the input, enabling all HTML features such as \\url.",
  266. cli: "-T, --trust"
  267. },
  268. maxSize: {
  269. type: "number",
  270. default: Infinity,
  271. 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",
  272. processor: function processor(s) {
  273. return Math.max(0, s);
  274. },
  275. cli: "-s, --max-size <n>",
  276. cliProcessor: parseInt
  277. },
  278. maxExpand: {
  279. type: "number",
  280. default: 1000,
  281. 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.",
  282. processor: function processor(n) {
  283. return Math.max(0, n);
  284. },
  285. cli: "-e, --max-expand <n>",
  286. cliProcessor: function cliProcessor(n) {
  287. return n === "Infinity" ? Infinity : parseInt(n);
  288. }
  289. },
  290. globalGroup: {
  291. type: "boolean",
  292. cli: false
  293. }
  294. };
  295. function getDefaultValue(schema) {
  296. if (schema.default) {
  297. return schema.default;
  298. }
  299. var type = schema.type;
  300. var defaultType = Array.isArray(type) ? type[0] : type;
  301. if (typeof defaultType !== 'string') {
  302. return defaultType.enum[0];
  303. }
  304. switch (defaultType) {
  305. case 'boolean':
  306. return false;
  307. case 'string':
  308. return '';
  309. case 'number':
  310. return 0;
  311. case 'object':
  312. return {};
  313. }
  314. }
  315. /**
  316. * The main Settings object
  317. *
  318. * The current options stored are:
  319. * - displayMode: Whether the expression should be typeset as inline math
  320. * (false, the default), meaning that the math starts in
  321. * \textstyle and is placed in an inline-block); or as display
  322. * math (true), meaning that the math starts in \displaystyle
  323. * and is placed in a block with vertical margin.
  324. */
  325. var Settings = /*#__PURE__*/function () {
  326. function Settings(options) {
  327. this.displayMode = void 0;
  328. this.output = void 0;
  329. this.leqno = void 0;
  330. this.fleqn = void 0;
  331. this.throwOnError = void 0;
  332. this.errorColor = void 0;
  333. this.macros = void 0;
  334. this.minRuleThickness = void 0;
  335. this.colorIsTextColor = void 0;
  336. this.strict = void 0;
  337. this.trust = void 0;
  338. this.maxSize = void 0;
  339. this.maxExpand = void 0;
  340. this.globalGroup = void 0;
  341. // allow null options
  342. options = options || {};
  343. for (var prop in SETTINGS_SCHEMA) {
  344. if (SETTINGS_SCHEMA.hasOwnProperty(prop)) {
  345. // $FlowFixMe
  346. var schema = SETTINGS_SCHEMA[prop]; // TODO: validate options
  347. // $FlowFixMe
  348. this[prop] = options[prop] !== undefined ? schema.processor ? schema.processor(options[prop]) : options[prop] : getDefaultValue(schema);
  349. }
  350. }
  351. }
  352. /**
  353. * Report nonstrict (non-LaTeX-compatible) input.
  354. * Can safely not be called if `this.strict` is false in JavaScript.
  355. */
  356. var _proto = Settings.prototype;
  357. _proto.reportNonstrict = function reportNonstrict(errorCode, errorMsg, token) {
  358. var strict = this.strict;
  359. if (typeof strict === "function") {
  360. // Allow return value of strict function to be boolean or string
  361. // (or null/undefined, meaning no further processing).
  362. strict = strict(errorCode, errorMsg, token);
  363. }
  364. if (!strict || strict === "ignore") {
  365. return;
  366. } else if (strict === true || strict === "error") {
  367. throw new src_ParseError("LaTeX-incompatible input and strict mode is set to 'error': " + (errorMsg + " [" + errorCode + "]"), token);
  368. } else if (strict === "warn") {
  369. typeof console !== "undefined" && console.warn("LaTeX-incompatible input and strict mode is set to 'warn': " + (errorMsg + " [" + errorCode + "]"));
  370. } else {
  371. // won't happen in type-safe code
  372. typeof console !== "undefined" && console.warn("LaTeX-incompatible input and strict mode is set to " + ("unrecognized '" + strict + "': " + errorMsg + " [" + errorCode + "]"));
  373. }
  374. }
  375. /**
  376. * Check whether to apply strict (LaTeX-adhering) behavior for unusual
  377. * input (like `\\`). Unlike `nonstrict`, will not throw an error;
  378. * instead, "error" translates to a return value of `true`, while "ignore"
  379. * translates to a return value of `false`. May still print a warning:
  380. * "warn" prints a warning and returns `false`.
  381. * This is for the second category of `errorCode`s listed in the README.
  382. */
  383. ;
  384. _proto.useStrictBehavior = function useStrictBehavior(errorCode, errorMsg, token) {
  385. var strict = this.strict;
  386. if (typeof strict === "function") {
  387. // Allow return value of strict function to be boolean or string
  388. // (or null/undefined, meaning no further processing).
  389. // But catch any exceptions thrown by function, treating them
  390. // like "error".
  391. try {
  392. strict = strict(errorCode, errorMsg, token);
  393. } catch (error) {
  394. strict = "error";
  395. }
  396. }
  397. if (!strict || strict === "ignore") {
  398. return false;
  399. } else if (strict === true || strict === "error") {
  400. return true;
  401. } else if (strict === "warn") {
  402. typeof console !== "undefined" && console.warn("LaTeX-incompatible input and strict mode is set to 'warn': " + (errorMsg + " [" + errorCode + "]"));
  403. return false;
  404. } else {
  405. // won't happen in type-safe code
  406. typeof console !== "undefined" && console.warn("LaTeX-incompatible input and strict mode is set to " + ("unrecognized '" + strict + "': " + errorMsg + " [" + errorCode + "]"));
  407. return false;
  408. }
  409. }
  410. /**
  411. * Check whether to test potentially dangerous input, and return
  412. * `true` (trusted) or `false` (untrusted). The sole argument `context`
  413. * should be an object with `command` field specifying the relevant LaTeX
  414. * command (as a string starting with `\`), and any other arguments, etc.
  415. * If `context` has a `url` field, a `protocol` field will automatically
  416. * get added by this function (changing the specified object).
  417. */
  418. ;
  419. _proto.isTrusted = function isTrusted(context) {
  420. if (context.url && !context.protocol) {
  421. context.protocol = utils.protocolFromUrl(context.url);
  422. }
  423. var trust = typeof this.trust === "function" ? this.trust(context) : this.trust;
  424. return Boolean(trust);
  425. };
  426. return Settings;
  427. }();
  428. ;// CONCATENATED MODULE: ./src/Style.js
  429. /**
  430. * This file contains information and classes for the various kinds of styles
  431. * used in TeX. It provides a generic `Style` class, which holds information
  432. * about a specific style. It then provides instances of all the different kinds
  433. * of styles possible, and provides functions to move between them and get
  434. * information about them.
  435. */
  436. /**
  437. * The main style class. Contains a unique id for the style, a size (which is
  438. * the same for cramped and uncramped version of a style), and a cramped flag.
  439. */
  440. var Style = /*#__PURE__*/function () {
  441. function Style(id, size, cramped) {
  442. this.id = void 0;
  443. this.size = void 0;
  444. this.cramped = void 0;
  445. this.id = id;
  446. this.size = size;
  447. this.cramped = cramped;
  448. }
  449. /**
  450. * Get the style of a superscript given a base in the current style.
  451. */
  452. var _proto = Style.prototype;
  453. _proto.sup = function sup() {
  454. return styles[_sup[this.id]];
  455. }
  456. /**
  457. * Get the style of a subscript given a base in the current style.
  458. */
  459. ;
  460. _proto.sub = function sub() {
  461. return styles[_sub[this.id]];
  462. }
  463. /**
  464. * Get the style of a fraction numerator given the fraction in the current
  465. * style.
  466. */
  467. ;
  468. _proto.fracNum = function fracNum() {
  469. return styles[_fracNum[this.id]];
  470. }
  471. /**
  472. * Get the style of a fraction denominator given the fraction in the current
  473. * style.
  474. */
  475. ;
  476. _proto.fracDen = function fracDen() {
  477. return styles[_fracDen[this.id]];
  478. }
  479. /**
  480. * Get the cramped version of a style (in particular, cramping a cramped style
  481. * doesn't change the style).
  482. */
  483. ;
  484. _proto.cramp = function cramp() {
  485. return styles[_cramp[this.id]];
  486. }
  487. /**
  488. * Get a text or display version of this style.
  489. */
  490. ;
  491. _proto.text = function text() {
  492. return styles[_text[this.id]];
  493. }
  494. /**
  495. * Return true if this style is tightly spaced (scriptstyle/scriptscriptstyle)
  496. */
  497. ;
  498. _proto.isTight = function isTight() {
  499. return this.size >= 2;
  500. };
  501. return Style;
  502. }(); // Export an interface for type checking, but don't expose the implementation.
  503. // This way, no more styles can be generated.
  504. // IDs of the different styles
  505. var D = 0;
  506. var Dc = 1;
  507. var T = 2;
  508. var Tc = 3;
  509. var S = 4;
  510. var Sc = 5;
  511. var SS = 6;
  512. var SSc = 7; // Instances of the different styles
  513. var styles = [new Style(D, 0, false), new Style(Dc, 0, true), new Style(T, 1, false), new Style(Tc, 1, true), new Style(S, 2, false), new Style(Sc, 2, true), new Style(SS, 3, false), new Style(SSc, 3, true)]; // Lookup tables for switching from one style to another
  514. var _sup = [S, Sc, S, Sc, SS, SSc, SS, SSc];
  515. var _sub = [Sc, Sc, Sc, Sc, SSc, SSc, SSc, SSc];
  516. var _fracNum = [T, Tc, S, Sc, SS, SSc, SS, SSc];
  517. var _fracDen = [Tc, Tc, Sc, Sc, SSc, SSc, SSc, SSc];
  518. var _cramp = [Dc, Dc, Tc, Tc, Sc, Sc, SSc, SSc];
  519. var _text = [D, Dc, T, Tc, T, Tc, T, Tc]; // We only export some of the styles.
  520. /* harmony default export */ var src_Style = ({
  521. DISPLAY: styles[D],
  522. TEXT: styles[T],
  523. SCRIPT: styles[S],
  524. SCRIPTSCRIPT: styles[SS]
  525. });
  526. ;// CONCATENATED MODULE: ./src/unicodeScripts.js
  527. /*
  528. * This file defines the Unicode scripts and script families that we
  529. * support. To add new scripts or families, just add a new entry to the
  530. * scriptData array below. Adding scripts to the scriptData array allows
  531. * characters from that script to appear in \text{} environments.
  532. */
  533. /**
  534. * Each script or script family has a name and an array of blocks.
  535. * Each block is an array of two numbers which specify the start and
  536. * end points (inclusive) of a block of Unicode codepoints.
  537. */
  538. /**
  539. * Unicode block data for the families of scripts we support in \text{}.
  540. * Scripts only need to appear here if they do not have font metrics.
  541. */
  542. var scriptData = [{
  543. // Latin characters beyond the Latin-1 characters we have metrics for.
  544. // Needed for Czech, Hungarian and Turkish text, for example.
  545. name: 'latin',
  546. blocks: [[0x0100, 0x024f], // Latin Extended-A and Latin Extended-B
  547. [0x0300, 0x036f] // Combining Diacritical marks
  548. ]
  549. }, {
  550. // The Cyrillic script used by Russian and related languages.
  551. // A Cyrillic subset used to be supported as explicitly defined
  552. // symbols in symbols.js
  553. name: 'cyrillic',
  554. blocks: [[0x0400, 0x04ff]]
  555. }, {
  556. // Armenian
  557. name: 'armenian',
  558. blocks: [[0x0530, 0x058F]]
  559. }, {
  560. // The Brahmic scripts of South and Southeast Asia
  561. // Devanagari (0900–097F)
  562. // Bengali (0980–09FF)
  563. // Gurmukhi (0A00–0A7F)
  564. // Gujarati (0A80–0AFF)
  565. // Oriya (0B00–0B7F)
  566. // Tamil (0B80–0BFF)
  567. // Telugu (0C00–0C7F)
  568. // Kannada (0C80–0CFF)
  569. // Malayalam (0D00–0D7F)
  570. // Sinhala (0D80–0DFF)
  571. // Thai (0E00–0E7F)
  572. // Lao (0E80–0EFF)
  573. // Tibetan (0F00–0FFF)
  574. // Myanmar (1000–109F)
  575. name: 'brahmic',
  576. blocks: [[0x0900, 0x109F]]
  577. }, {
  578. name: 'georgian',
  579. blocks: [[0x10A0, 0x10ff]]
  580. }, {
  581. // Chinese and Japanese.
  582. // The "k" in cjk is for Korean, but we've separated Korean out
  583. name: "cjk",
  584. blocks: [[0x3000, 0x30FF], // CJK symbols and punctuation, Hiragana, Katakana
  585. [0x4E00, 0x9FAF], // CJK ideograms
  586. [0xFF00, 0xFF60] // Fullwidth punctuation
  587. // TODO: add halfwidth Katakana and Romanji glyphs
  588. ]
  589. }, {
  590. // Korean
  591. name: 'hangul',
  592. blocks: [[0xAC00, 0xD7AF]]
  593. }];
  594. /**
  595. * Given a codepoint, return the name of the script or script family
  596. * it is from, or null if it is not part of a known block
  597. */
  598. function scriptFromCodepoint(codepoint) {
  599. for (var i = 0; i < scriptData.length; i++) {
  600. var script = scriptData[i];
  601. for (var _i = 0; _i < script.blocks.length; _i++) {
  602. var block = script.blocks[_i];
  603. if (codepoint >= block[0] && codepoint <= block[1]) {
  604. return script.name;
  605. }
  606. }
  607. }
  608. return null;
  609. }
  610. /**
  611. * A flattened version of all the supported blocks in a single array.
  612. * This is an optimization to make supportedCodepoint() fast.
  613. */
  614. var allBlocks = [];
  615. scriptData.forEach(function (s) {
  616. return s.blocks.forEach(function (b) {
  617. return allBlocks.push.apply(allBlocks, b);
  618. });
  619. });
  620. /**
  621. * Given a codepoint, return true if it falls within one of the
  622. * scripts or script families defined above and false otherwise.
  623. *
  624. * Micro benchmarks shows that this is faster than
  625. * /[\u3000-\u30FF\u4E00-\u9FAF\uFF00-\uFF60\uAC00-\uD7AF\u0900-\u109F]/.test()
  626. * in Firefox, Chrome and Node.
  627. */
  628. function supportedCodepoint(codepoint) {
  629. for (var i = 0; i < allBlocks.length; i += 2) {
  630. if (codepoint >= allBlocks[i] && codepoint <= allBlocks[i + 1]) {
  631. return true;
  632. }
  633. }
  634. return false;
  635. }
  636. ;// CONCATENATED MODULE: ./src/svgGeometry.js
  637. /**
  638. * This file provides support to domTree.js and delimiter.js.
  639. * It's a storehouse of path geometry for SVG images.
  640. */
  641. // In all paths below, the viewBox-to-em scale is 1000:1.
  642. var hLinePad = 80; // padding above a sqrt viniculum. Prevents image cropping.
  643. // The viniculum of a \sqrt can be made thicker by a KaTeX rendering option.
  644. // Think of variable extraViniculum as two detours in the SVG path.
  645. // The detour begins at the lower left of the area labeled extraViniculum below.
  646. // The detour proceeds one extraViniculum distance up and slightly to the right,
  647. // displacing the radiused corner between surd and viniculum. The radius is
  648. // traversed as usual, then the detour resumes. It goes right, to the end of
  649. // the very long viniculumn, then down one extraViniculum distance,
  650. // after which it resumes regular path geometry for the radical.
  651. /* viniculum
  652. /
  653. /extraViniculum
  654. / 0.04em (40 unit) std viniculum thickness
  655. / /
  656. / /
  657. / /\
  658. / / surd
  659. */
  660. var sqrtMain = function sqrtMain(extraViniculum, hLinePad) {
  661. // sqrtMain path geometry is from glyph U221A in the font KaTeX Main
  662. return "M95," + (622 + extraViniculum + hLinePad) + "\nc-2.7,0,-7.17,-2.7,-13.5,-8c-5.8,-5.3,-9.5,-10,-9.5,-14\nc0,-2,0.3,-3.3,1,-4c1.3,-2.7,23.83,-20.7,67.5,-54\nc44.2,-33.3,65.8,-50.3,66.5,-51c1.3,-1.3,3,-2,5,-2c4.7,0,8.7,3.3,12,10\ns173,378,173,378c0.7,0,35.3,-71,104,-213c68.7,-142,137.5,-285,206.5,-429\nc69,-144,104.5,-217.7,106.5,-221\nl" + extraViniculum / 2.075 + " -" + extraViniculum + "\nc5.3,-9.3,12,-14,20,-14\nH400000v" + (40 + extraViniculum) + "H845.2724\ns-225.272,467,-225.272,467s-235,486,-235,486c-2.7,4.7,-9,7,-19,7\nc-6,0,-10,-1,-12,-3s-194,-422,-194,-422s-65,47,-65,47z\nM" + (834 + extraViniculum) + " " + hLinePad + "h400000v" + (40 + extraViniculum) + "h-400000z";
  663. };
  664. var sqrtSize1 = function sqrtSize1(extraViniculum, hLinePad) {
  665. // size1 is from glyph U221A in the font KaTeX_Size1-Regular
  666. return "M263," + (601 + extraViniculum + hLinePad) + "c0.7,0,18,39.7,52,119\nc34,79.3,68.167,158.7,102.5,238c34.3,79.3,51.8,119.3,52.5,120\nc340,-704.7,510.7,-1060.3,512,-1067\nl" + extraViniculum / 2.084 + " -" + extraViniculum + "\nc4.7,-7.3,11,-11,19,-11\nH40000v" + (40 + extraViniculum) + "H1012.3\ns-271.3,567,-271.3,567c-38.7,80.7,-84,175,-136,283c-52,108,-89.167,185.3,-111.5,232\nc-22.3,46.7,-33.8,70.3,-34.5,71c-4.7,4.7,-12.3,7,-23,7s-12,-1,-12,-1\ns-109,-253,-109,-253c-72.7,-168,-109.3,-252,-110,-252c-10.7,8,-22,16.7,-34,26\nc-22,17.3,-33.3,26,-34,26s-26,-26,-26,-26s76,-59,76,-59s76,-60,76,-60z\nM" + (1001 + extraViniculum) + " " + hLinePad + "h400000v" + (40 + extraViniculum) + "h-400000z";
  667. };
  668. var sqrtSize2 = function sqrtSize2(extraViniculum, hLinePad) {
  669. // size2 is from glyph U221A in the font KaTeX_Size2-Regular
  670. return "M983 " + (10 + extraViniculum + hLinePad) + "\nl" + extraViniculum / 3.13 + " -" + extraViniculum + "\nc4,-6.7,10,-10,18,-10 H400000v" + (40 + extraViniculum) + "\nH1013.1s-83.4,268,-264.1,840c-180.7,572,-277,876.3,-289,913c-4.7,4.7,-12.7,7,-24,7\ns-12,0,-12,0c-1.3,-3.3,-3.7,-11.7,-7,-25c-35.3,-125.3,-106.7,-373.3,-214,-744\nc-10,12,-21,25,-33,39s-32,39,-32,39c-6,-5.3,-15,-14,-27,-26s25,-30,25,-30\nc26.7,-32.7,52,-63,76,-91s52,-60,52,-60s208,722,208,722\nc56,-175.3,126.3,-397.3,211,-666c84.7,-268.7,153.8,-488.2,207.5,-658.5\nc53.7,-170.3,84.5,-266.8,92.5,-289.5z\nM" + (1001 + extraViniculum) + " " + hLinePad + "h400000v" + (40 + extraViniculum) + "h-400000z";
  671. };
  672. var sqrtSize3 = function sqrtSize3(extraViniculum, hLinePad) {
  673. // size3 is from glyph U221A in the font KaTeX_Size3-Regular
  674. return "M424," + (2398 + extraViniculum + hLinePad) + "\nc-1.3,-0.7,-38.5,-172,-111.5,-514c-73,-342,-109.8,-513.3,-110.5,-514\nc0,-2,-10.7,14.3,-32,49c-4.7,7.3,-9.8,15.7,-15.5,25c-5.7,9.3,-9.8,16,-12.5,20\ns-5,7,-5,7c-4,-3.3,-8.3,-7.7,-13,-13s-13,-13,-13,-13s76,-122,76,-122s77,-121,77,-121\ns209,968,209,968c0,-2,84.7,-361.7,254,-1079c169.3,-717.3,254.7,-1077.7,256,-1081\nl" + extraViniculum / 4.223 + " -" + extraViniculum + "c4,-6.7,10,-10,18,-10 H400000\nv" + (40 + extraViniculum) + "H1014.6\ns-87.3,378.7,-272.6,1166c-185.3,787.3,-279.3,1182.3,-282,1185\nc-2,6,-10,9,-24,9\nc-8,0,-12,-0.7,-12,-2z M" + (1001 + extraViniculum) + " " + hLinePad + "\nh400000v" + (40 + extraViniculum) + "h-400000z";
  675. };
  676. var sqrtSize4 = function sqrtSize4(extraViniculum, hLinePad) {
  677. // size4 is from glyph U221A in the font KaTeX_Size4-Regular
  678. return "M473," + (2713 + extraViniculum + hLinePad) + "\nc339.3,-1799.3,509.3,-2700,510,-2702 l" + extraViniculum / 5.298 + " -" + extraViniculum + "\nc3.3,-7.3,9.3,-11,18,-11 H400000v" + (40 + extraViniculum) + "H1017.7\ns-90.5,478,-276.2,1466c-185.7,988,-279.5,1483,-281.5,1485c-2,6,-10,9,-24,9\nc-8,0,-12,-0.7,-12,-2c0,-1.3,-5.3,-32,-16,-92c-50.7,-293.3,-119.7,-693.3,-207,-1200\nc0,-1.3,-5.3,8.7,-16,30c-10.7,21.3,-21.3,42.7,-32,64s-16,33,-16,33s-26,-26,-26,-26\ns76,-153,76,-153s77,-151,77,-151c0.7,0.7,35.7,202,105,604c67.3,400.7,102,602.7,104,\n606zM" + (1001 + extraViniculum) + " " + hLinePad + "h400000v" + (40 + extraViniculum) + "H1017.7z";
  679. };
  680. var phasePath = function phasePath(y) {
  681. var x = y / 2; // x coordinate at top of angle
  682. return "M400000 " + y + " H0 L" + x + " 0 l65 45 L145 " + (y - 80) + " H400000z";
  683. };
  684. var sqrtTall = function sqrtTall(extraViniculum, hLinePad, viewBoxHeight) {
  685. // sqrtTall is from glyph U23B7 in the font KaTeX_Size4-Regular
  686. // One path edge has a variable length. It runs vertically from the viniculumn
  687. // to a point near (14 units) the bottom of the surd. The viniculum
  688. // is normally 40 units thick. So the length of the line in question is:
  689. var vertSegment = viewBoxHeight - 54 - hLinePad - extraViniculum;
  690. return "M702 " + (extraViniculum + hLinePad) + "H400000" + (40 + extraViniculum) + "\nH742v" + vertSegment + "l-4 4-4 4c-.667.7 -2 1.5-4 2.5s-4.167 1.833-6.5 2.5-5.5 1-9.5 1\nh-12l-28-84c-16.667-52-96.667 -294.333-240-727l-212 -643 -85 170\nc-4-3.333-8.333-7.667-13 -13l-13-13l77-155 77-156c66 199.333 139 419.667\n219 661 l218 661zM702 " + hLinePad + "H400000v" + (40 + extraViniculum) + "H742z";
  691. };
  692. var sqrtPath = function sqrtPath(size, extraViniculum, viewBoxHeight) {
  693. extraViniculum = 1000 * extraViniculum; // Convert from document ems to viewBox.
  694. var path = "";
  695. switch (size) {
  696. case "sqrtMain":
  697. path = sqrtMain(extraViniculum, hLinePad);
  698. break;
  699. case "sqrtSize1":
  700. path = sqrtSize1(extraViniculum, hLinePad);
  701. break;
  702. case "sqrtSize2":
  703. path = sqrtSize2(extraViniculum, hLinePad);
  704. break;
  705. case "sqrtSize3":
  706. path = sqrtSize3(extraViniculum, hLinePad);
  707. break;
  708. case "sqrtSize4":
  709. path = sqrtSize4(extraViniculum, hLinePad);
  710. break;
  711. case "sqrtTall":
  712. path = sqrtTall(extraViniculum, hLinePad, viewBoxHeight);
  713. }
  714. return path;
  715. };
  716. var innerPath = function innerPath(name, height) {
  717. // The inner part of stretchy tall delimiters
  718. switch (name) {
  719. case "\u239C":
  720. return "M291 0 H417 V" + height + " H291z M291 0 H417 V" + height + " H291z";
  721. case "\u2223":
  722. return "M145 0 H188 V" + height + " H145z M145 0 H188 V" + height + " H145z";
  723. case "\u2225":
  724. return "M145 0 H188 V" + height + " H145z M145 0 H188 V" + height + " H145z" + ("M367 0 H410 V" + height + " H367z M367 0 H410 V" + height + " H367z");
  725. case "\u239F":
  726. return "M457 0 H583 V" + height + " H457z M457 0 H583 V" + height + " H457z";
  727. case "\u23A2":
  728. return "M319 0 H403 V" + height + " H319z M319 0 H403 V" + height + " H319z";
  729. case "\u23A5":
  730. return "M263 0 H347 V" + height + " H263z M263 0 H347 V" + height + " H263z";
  731. case "\u23AA":
  732. return "M384 0 H504 V" + height + " H384z M384 0 H504 V" + height + " H384z";
  733. case "\u23D0":
  734. return "M312 0 H355 V" + height + " H312z M312 0 H355 V" + height + " H312z";
  735. case "\u2016":
  736. return "M257 0 H300 V" + height + " H257z M257 0 H300 V" + height + " H257z" + ("M478 0 H521 V" + height + " H478z M478 0 H521 V" + height + " H478z");
  737. default:
  738. return "";
  739. }
  740. };
  741. var path = {
  742. // The doubleleftarrow geometry is from glyph U+21D0 in the font KaTeX Main
  743. doubleleftarrow: "M262 157\nl10-10c34-36 62.7-77 86-123 3.3-8 5-13.3 5-16 0-5.3-6.7-8-20-8-7.3\n 0-12.2.5-14.5 1.5-2.3 1-4.8 4.5-7.5 10.5-49.3 97.3-121.7 169.3-217 216-28\n 14-57.3 25-88 33-6.7 2-11 3.8-13 5.5-2 1.7-3 4.2-3 7.5s1 5.8 3 7.5\nc2 1.7 6.3 3.5 13 5.5 68 17.3 128.2 47.8 180.5 91.5 52.3 43.7 93.8 96.2 124.5\n 157.5 9.3 8 15.3 12.3 18 13h6c12-.7 18-4 18-10 0-2-1.7-7-5-15-23.3-46-52-87\n-86-123l-10-10h399738v-40H218c328 0 0 0 0 0l-10-8c-26.7-20-65.7-43-117-69 2.7\n-2 6-3.7 10-5 36.7-16 72.3-37.3 107-64l10-8h399782v-40z\nm8 0v40h399730v-40zm0 194v40h399730v-40z",
  744. // doublerightarrow is from glyph U+21D2 in font KaTeX Main
  745. doublerightarrow: "M399738 392l\n-10 10c-34 36-62.7 77-86 123-3.3 8-5 13.3-5 16 0 5.3 6.7 8 20 8 7.3 0 12.2-.5\n 14.5-1.5 2.3-1 4.8-4.5 7.5-10.5 49.3-97.3 121.7-169.3 217-216 28-14 57.3-25 88\n-33 6.7-2 11-3.8 13-5.5 2-1.7 3-4.2 3-7.5s-1-5.8-3-7.5c-2-1.7-6.3-3.5-13-5.5-68\n-17.3-128.2-47.8-180.5-91.5-52.3-43.7-93.8-96.2-124.5-157.5-9.3-8-15.3-12.3-18\n-13h-6c-12 .7-18 4-18 10 0 2 1.7 7 5 15 23.3 46 52 87 86 123l10 10H0v40h399782\nc-328 0 0 0 0 0l10 8c26.7 20 65.7 43 117 69-2.7 2-6 3.7-10 5-36.7 16-72.3 37.3\n-107 64l-10 8H0v40zM0 157v40h399730v-40zm0 194v40h399730v-40z",
  746. // leftarrow is from glyph U+2190 in font KaTeX Main
  747. leftarrow: "M400000 241H110l3-3c68.7-52.7 113.7-120\n 135-202 4-14.7 6-23 6-25 0-7.3-7-11-21-11-8 0-13.2.8-15.5 2.5-2.3 1.7-4.2 5.8\n-5.5 12.5-1.3 4.7-2.7 10.3-4 17-12 48.7-34.8 92-68.5 130S65.3 228.3 18 247\nc-10 4-16 7.7-18 11 0 8.7 6 14.3 18 17 47.3 18.7 87.8 47 121.5 85S196 441.3 208\n 490c.7 2 1.3 5 2 9s1.2 6.7 1.5 8c.3 1.3 1 3.3 2 6s2.2 4.5 3.5 5.5c1.3 1 3.3\n 1.8 6 2.5s6 1 10 1c14 0 21-3.7 21-11 0-2-2-10.3-6-25-20-79.3-65-146.7-135-202\n l-3-3h399890zM100 241v40h399900v-40z",
  748. // overbrace is from glyphs U+23A9/23A8/23A7 in font KaTeX_Size4-Regular
  749. leftbrace: "M6 548l-6-6v-35l6-11c56-104 135.3-181.3 238-232 57.3-28.7 117\n-45 179-50h399577v120H403c-43.3 7-81 15-113 26-100.7 33-179.7 91-237 174-2.7\n 5-6 9-10 13-.7 1-7.3 1-20 1H6z",
  750. leftbraceunder: "M0 6l6-6h17c12.688 0 19.313.3 20 1 4 4 7.313 8.3 10 13\n 35.313 51.3 80.813 93.8 136.5 127.5 55.688 33.7 117.188 55.8 184.5 66.5.688\n 0 2 .3 4 1 18.688 2.7 76 4.3 172 5h399450v120H429l-6-1c-124.688-8-235-61.7\n-331-161C60.687 138.7 32.312 99.3 7 54L0 41V6z",
  751. // overgroup is from the MnSymbol package (public domain)
  752. leftgroup: "M400000 80\nH435C64 80 168.3 229.4 21 260c-5.9 1.2-18 0-18 0-2 0-3-1-3-3v-38C76 61 257 0\n 435 0h399565z",
  753. leftgroupunder: "M400000 262\nH435C64 262 168.3 112.6 21 82c-5.9-1.2-18 0-18 0-2 0-3 1-3 3v38c76 158 257 219\n 435 219h399565z",
  754. // Harpoons are from glyph U+21BD in font KaTeX Main
  755. leftharpoon: "M0 267c.7 5.3 3 10 7 14h399993v-40H93c3.3\n-3.3 10.2-9.5 20.5-18.5s17.8-15.8 22.5-20.5c50.7-52 88-110.3 112-175 4-11.3 5\n-18.3 3-21-1.3-4-7.3-6-18-6-8 0-13 .7-15 2s-4.7 6.7-8 16c-42 98.7-107.3 174.7\n-196 228-6.7 4.7-10.7 8-12 10-1.3 2-2 5.7-2 11zm100-26v40h399900v-40z",
  756. leftharpoonplus: "M0 267c.7 5.3 3 10 7 14h399993v-40H93c3.3-3.3 10.2-9.5\n 20.5-18.5s17.8-15.8 22.5-20.5c50.7-52 88-110.3 112-175 4-11.3 5-18.3 3-21-1.3\n-4-7.3-6-18-6-8 0-13 .7-15 2s-4.7 6.7-8 16c-42 98.7-107.3 174.7-196 228-6.7 4.7\n-10.7 8-12 10-1.3 2-2 5.7-2 11zm100-26v40h399900v-40zM0 435v40h400000v-40z\nm0 0v40h400000v-40z",
  757. leftharpoondown: "M7 241c-4 4-6.333 8.667-7 14 0 5.333.667 9 2 11s5.333\n 5.333 12 10c90.667 54 156 130 196 228 3.333 10.667 6.333 16.333 9 17 2 .667 5\n 1 9 1h5c10.667 0 16.667-2 18-6 2-2.667 1-9.667-3-21-32-87.333-82.667-157.667\n-152-211l-3-3h399907v-40zM93 281 H400000 v-40L7 241z",
  758. leftharpoondownplus: "M7 435c-4 4-6.3 8.7-7 14 0 5.3.7 9 2 11s5.3 5.3 12\n 10c90.7 54 156 130 196 228 3.3 10.7 6.3 16.3 9 17 2 .7 5 1 9 1h5c10.7 0 16.7\n-2 18-6 2-2.7 1-9.7-3-21-32-87.3-82.7-157.7-152-211l-3-3h399907v-40H7zm93 0\nv40h399900v-40zM0 241v40h399900v-40zm0 0v40h399900v-40z",
  759. // hook is from glyph U+21A9 in font KaTeX Main
  760. lefthook: "M400000 281 H103s-33-11.2-61-33.5S0 197.3 0 164s14.2-61.2 42.5\n-83.5C70.8 58.2 104 47 142 47 c16.7 0 25 6.7 25 20 0 12-8.7 18.7-26 20-40 3.3\n-68.7 15.7-86 37-10 12-15 25.3-15 40 0 22.7 9.8 40.7 29.5 54 19.7 13.3 43.5 21\n 71.5 23h399859zM103 281v-40h399897v40z",
  761. leftlinesegment: "M40 281 V428 H0 V94 H40 V241 H400000 v40z\nM40 281 V428 H0 V94 H40 V241 H400000 v40z",
  762. leftmapsto: "M40 281 V448H0V74H40V241H400000v40z\nM40 281 V448H0V74H40V241H400000v40z",
  763. // tofrom is from glyph U+21C4 in font KaTeX AMS Regular
  764. leftToFrom: "M0 147h400000v40H0zm0 214c68 40 115.7 95.7 143 167h22c15.3 0 23\n-.3 23-1 0-1.3-5.3-13.7-16-37-18-35.3-41.3-69-70-101l-7-8h399905v-40H95l7-8\nc28.7-32 52-65.7 70-101 10.7-23.3 16-35.7 16-37 0-.7-7.7-1-23-1h-22C115.7 265.3\n 68 321 0 361zm0-174v-40h399900v40zm100 154v40h399900v-40z",
  765. longequal: "M0 50 h400000 v40H0z m0 194h40000v40H0z\nM0 50 h400000 v40H0z m0 194h40000v40H0z",
  766. midbrace: "M200428 334\nc-100.7-8.3-195.3-44-280-108-55.3-42-101.7-93-139-153l-9-14c-2.7 4-5.7 8.7-9 14\n-53.3 86.7-123.7 153-211 199-66.7 36-137.3 56.3-212 62H0V214h199568c178.3-11.7\n 311.7-78.3 403-201 6-8 9.7-12 11-12 .7-.7 6.7-1 18-1s17.3.3 18 1c1.3 0 5 4 11\n 12 44.7 59.3 101.3 106.3 170 141s145.3 54.3 229 60h199572v120z",
  767. midbraceunder: "M199572 214\nc100.7 8.3 195.3 44 280 108 55.3 42 101.7 93 139 153l9 14c2.7-4 5.7-8.7 9-14\n 53.3-86.7 123.7-153 211-199 66.7-36 137.3-56.3 212-62h199568v120H200432c-178.3\n 11.7-311.7 78.3-403 201-6 8-9.7 12-11 12-.7.7-6.7 1-18 1s-17.3-.3-18-1c-1.3 0\n-5-4-11-12-44.7-59.3-101.3-106.3-170-141s-145.3-54.3-229-60H0V214z",
  768. oiintSize1: "M512.6 71.6c272.6 0 320.3 106.8 320.3 178.2 0 70.8-47.7 177.6\n-320.3 177.6S193.1 320.6 193.1 249.8c0-71.4 46.9-178.2 319.5-178.2z\nm368.1 178.2c0-86.4-60.9-215.4-368.1-215.4-306.4 0-367.3 129-367.3 215.4 0 85.8\n60.9 214.8 367.3 214.8 307.2 0 368.1-129 368.1-214.8z",
  769. oiintSize2: "M757.8 100.1c384.7 0 451.1 137.6 451.1 230 0 91.3-66.4 228.8\n-451.1 228.8-386.3 0-452.7-137.5-452.7-228.8 0-92.4 66.4-230 452.7-230z\nm502.4 230c0-111.2-82.4-277.2-502.4-277.2s-504 166-504 277.2\nc0 110 84 276 504 276s502.4-166 502.4-276z",
  770. oiiintSize1: "M681.4 71.6c408.9 0 480.5 106.8 480.5 178.2 0 70.8-71.6 177.6\n-480.5 177.6S202.1 320.6 202.1 249.8c0-71.4 70.5-178.2 479.3-178.2z\nm525.8 178.2c0-86.4-86.8-215.4-525.7-215.4-437.9 0-524.7 129-524.7 215.4 0\n85.8 86.8 214.8 524.7 214.8 438.9 0 525.7-129 525.7-214.8z",
  771. oiiintSize2: "M1021.2 53c603.6 0 707.8 165.8 707.8 277.2 0 110-104.2 275.8\n-707.8 275.8-606 0-710.2-165.8-710.2-275.8C311 218.8 415.2 53 1021.2 53z\nm770.4 277.1c0-131.2-126.4-327.6-770.5-327.6S248.4 198.9 248.4 330.1\nc0 130 128.8 326.4 772.7 326.4s770.5-196.4 770.5-326.4z",
  772. rightarrow: "M0 241v40h399891c-47.3 35.3-84 78-110 128\n-16.7 32-27.7 63.7-33 95 0 1.3-.2 2.7-.5 4-.3 1.3-.5 2.3-.5 3 0 7.3 6.7 11 20\n 11 8 0 13.2-.8 15.5-2.5 2.3-1.7 4.2-5.5 5.5-11.5 2-13.3 5.7-27 11-41 14.7-44.7\n 39-84.5 73-119.5s73.7-60.2 119-75.5c6-2 9-5.7 9-11s-3-9-9-11c-45.3-15.3-85\n-40.5-119-75.5s-58.3-74.8-73-119.5c-4.7-14-8.3-27.3-11-40-1.3-6.7-3.2-10.8-5.5\n-12.5-2.3-1.7-7.5-2.5-15.5-2.5-14 0-21 3.7-21 11 0 2 2 10.3 6 25 20.7 83.3 67\n 151.7 139 205zm0 0v40h399900v-40z",
  773. rightbrace: "M400000 542l\n-6 6h-17c-12.7 0-19.3-.3-20-1-4-4-7.3-8.3-10-13-35.3-51.3-80.8-93.8-136.5-127.5\ns-117.2-55.8-184.5-66.5c-.7 0-2-.3-4-1-18.7-2.7-76-4.3-172-5H0V214h399571l6 1\nc124.7 8 235 61.7 331 161 31.3 33.3 59.7 72.7 85 118l7 13v35z",
  774. rightbraceunder: "M399994 0l6 6v35l-6 11c-56 104-135.3 181.3-238 232-57.3\n 28.7-117 45-179 50H-300V214h399897c43.3-7 81-15 113-26 100.7-33 179.7-91 237\n-174 2.7-5 6-9 10-13 .7-1 7.3-1 20-1h17z",
  775. rightgroup: "M0 80h399565c371 0 266.7 149.4 414 180 5.9 1.2 18 0 18 0 2 0\n 3-1 3-3v-38c-76-158-257-219-435-219H0z",
  776. rightgroupunder: "M0 262h399565c371 0 266.7-149.4 414-180 5.9-1.2 18 0 18\n 0 2 0 3 1 3 3v38c-76 158-257 219-435 219H0z",
  777. rightharpoon: "M0 241v40h399993c4.7-4.7 7-9.3 7-14 0-9.3\n-3.7-15.3-11-18-92.7-56.7-159-133.7-199-231-3.3-9.3-6-14.7-8-16-2-1.3-7-2-15-2\n-10.7 0-16.7 2-18 6-2 2.7-1 9.7 3 21 15.3 42 36.7 81.8 64 119.5 27.3 37.7 58\n 69.2 92 94.5zm0 0v40h399900v-40z",
  778. rightharpoonplus: "M0 241v40h399993c4.7-4.7 7-9.3 7-14 0-9.3-3.7-15.3-11\n-18-92.7-56.7-159-133.7-199-231-3.3-9.3-6-14.7-8-16-2-1.3-7-2-15-2-10.7 0-16.7\n 2-18 6-2 2.7-1 9.7 3 21 15.3 42 36.7 81.8 64 119.5 27.3 37.7 58 69.2 92 94.5z\nm0 0v40h399900v-40z m100 194v40h399900v-40zm0 0v40h399900v-40z",
  779. rightharpoondown: "M399747 511c0 7.3 6.7 11 20 11 8 0 13-.8 15-2.5s4.7-6.8\n 8-15.5c40-94 99.3-166.3 178-217 13.3-8 20.3-12.3 21-13 5.3-3.3 8.5-5.8 9.5\n-7.5 1-1.7 1.5-5.2 1.5-10.5s-2.3-10.3-7-15H0v40h399908c-34 25.3-64.7 57-92 95\n-27.3 38-48.7 77.7-64 119-3.3 8.7-5 14-5 16zM0 241v40h399900v-40z",
  780. rightharpoondownplus: "M399747 705c0 7.3 6.7 11 20 11 8 0 13-.8\n 15-2.5s4.7-6.8 8-15.5c40-94 99.3-166.3 178-217 13.3-8 20.3-12.3 21-13 5.3-3.3\n 8.5-5.8 9.5-7.5 1-1.7 1.5-5.2 1.5-10.5s-2.3-10.3-7-15H0v40h399908c-34 25.3\n-64.7 57-92 95-27.3 38-48.7 77.7-64 119-3.3 8.7-5 14-5 16zM0 435v40h399900v-40z\nm0-194v40h400000v-40zm0 0v40h400000v-40z",
  781. righthook: "M399859 241c-764 0 0 0 0 0 40-3.3 68.7-15.7 86-37 10-12 15-25.3\n 15-40 0-22.7-9.8-40.7-29.5-54-19.7-13.3-43.5-21-71.5-23-17.3-1.3-26-8-26-20 0\n-13.3 8.7-20 26-20 38 0 71 11.2 99 33.5 0 0 7 5.6 21 16.7 14 11.2 21 33.5 21\n 66.8s-14 61.2-42 83.5c-28 22.3-61 33.5-99 33.5L0 241z M0 281v-40h399859v40z",
  782. rightlinesegment: "M399960 241 V94 h40 V428 h-40 V281 H0 v-40z\nM399960 241 V94 h40 V428 h-40 V281 H0 v-40z",
  783. rightToFrom: "M400000 167c-70.7-42-118-97.7-142-167h-23c-15.3 0-23 .3-23\n 1 0 1.3 5.3 13.7 16 37 18 35.3 41.3 69 70 101l7 8H0v40h399905l-7 8c-28.7 32\n-52 65.7-70 101-10.7 23.3-16 35.7-16 37 0 .7 7.7 1 23 1h23c24-69.3 71.3-125 142\n-167z M100 147v40h399900v-40zM0 341v40h399900v-40z",
  784. // twoheadleftarrow is from glyph U+219E in font KaTeX AMS Regular
  785. twoheadleftarrow: "M0 167c68 40\n 115.7 95.7 143 167h22c15.3 0 23-.3 23-1 0-1.3-5.3-13.7-16-37-18-35.3-41.3-69\n-70-101l-7-8h125l9 7c50.7 39.3 85 86 103 140h46c0-4.7-6.3-18.7-19-42-18-35.3\n-40-67.3-66-96l-9-9h399716v-40H284l9-9c26-28.7 48-60.7 66-96 12.7-23.333 19\n-37.333 19-42h-46c-18 54-52.3 100.7-103 140l-9 7H95l7-8c28.7-32 52-65.7 70-101\n 10.7-23.333 16-35.7 16-37 0-.7-7.7-1-23-1h-22C115.7 71.3 68 127 0 167z",
  786. twoheadrightarrow: "M400000 167\nc-68-40-115.7-95.7-143-167h-22c-15.3 0-23 .3-23 1 0 1.3 5.3 13.7 16 37 18 35.3\n 41.3 69 70 101l7 8h-125l-9-7c-50.7-39.3-85-86-103-140h-46c0 4.7 6.3 18.7 19 42\n 18 35.3 40 67.3 66 96l9 9H0v40h399716l-9 9c-26 28.7-48 60.7-66 96-12.7 23.333\n-19 37.333-19 42h46c18-54 52.3-100.7 103-140l9-7h125l-7 8c-28.7 32-52 65.7-70\n 101-10.7 23.333-16 35.7-16 37 0 .7 7.7 1 23 1h22c27.3-71.3 75-127 143-167z",
  787. // tilde1 is a modified version of a glyph from the MnSymbol package
  788. tilde1: "M200 55.538c-77 0-168 73.953-177 73.953-3 0-7\n-2.175-9-5.437L2 97c-1-2-2-4-2-6 0-4 2-7 5-9l20-12C116 12 171 0 207 0c86 0\n 114 68 191 68 78 0 168-68 177-68 4 0 7 2 9 5l12 19c1 2.175 2 4.35 2 6.525 0\n 4.35-2 7.613-5 9.788l-19 13.05c-92 63.077-116.937 75.308-183 76.128\n-68.267.847-113-73.952-191-73.952z",
  789. // ditto tilde2, tilde3, & tilde4
  790. tilde2: "M344 55.266c-142 0-300.638 81.316-311.5 86.418\n-8.01 3.762-22.5 10.91-23.5 5.562L1 120c-1-2-1-3-1-4 0-5 3-9 8-10l18.4-9C160.9\n 31.9 283 0 358 0c148 0 188 122 331 122s314-97 326-97c4 0 8 2 10 7l7 21.114\nc1 2.14 1 3.21 1 4.28 0 5.347-3 9.626-7 10.696l-22.3 12.622C852.6 158.372 751\n 181.476 676 181.476c-149 0-189-126.21-332-126.21z",
  791. tilde3: "M786 59C457 59 32 175.242 13 175.242c-6 0-10-3.457\n-11-10.37L.15 138c-1-7 3-12 10-13l19.2-6.4C378.4 40.7 634.3 0 804.3 0c337 0\n 411.8 157 746.8 157 328 0 754-112 773-112 5 0 10 3 11 9l1 14.075c1 8.066-.697\n 16.595-6.697 17.492l-21.052 7.31c-367.9 98.146-609.15 122.696-778.15 122.696\n -338 0-409-156.573-744-156.573z",
  792. tilde4: "M786 58C457 58 32 177.487 13 177.487c-6 0-10-3.345\n-11-10.035L.15 143c-1-7 3-12 10-13l22-6.7C381.2 35 637.15 0 807.15 0c337 0 409\n 177 744 177 328 0 754-127 773-127 5 0 10 3 11 9l1 14.794c1 7.805-3 13.38-9\n 14.495l-20.7 5.574c-366.85 99.79-607.3 139.372-776.3 139.372-338 0-409\n -175.236-744-175.236z",
  793. // vec is from glyph U+20D7 in font KaTeX Main
  794. vec: "M377 20c0-5.333 1.833-10 5.5-14S391 0 397 0c4.667 0 8.667 1.667 12 5\n3.333 2.667 6.667 9 10 19 6.667 24.667 20.333 43.667 41 57 7.333 4.667 11\n10.667 11 18 0 6-1 10-3 12s-6.667 5-14 9c-28.667 14.667-53.667 35.667-75 63\n-1.333 1.333-3.167 3.5-5.5 6.5s-4 4.833-5 5.5c-1 .667-2.5 1.333-4.5 2s-4.333 1\n-7 1c-4.667 0-9.167-1.833-13.5-5.5S337 184 337 178c0-12.667 15.667-32.333 47-59\nH213l-171-1c-8.667-6-13-12.333-13-19 0-4.667 4.333-11.333 13-20h359\nc-16-25.333-24-45-24-59z",
  795. // widehat1 is a modified version of a glyph from the MnSymbol package
  796. widehat1: "M529 0h5l519 115c5 1 9 5 9 10 0 1-1 2-1 3l-4 22\nc-1 5-5 9-11 9h-2L532 67 19 159h-2c-5 0-9-4-11-9l-5-22c-1-6 2-12 8-13z",
  797. // ditto widehat2, widehat3, & widehat4
  798. widehat2: "M1181 0h2l1171 176c6 0 10 5 10 11l-2 23c-1 6-5 10\n-11 10h-1L1182 67 15 220h-1c-6 0-10-4-11-10l-2-23c-1-6 4-11 10-11z",
  799. widehat3: "M1181 0h2l1171 236c6 0 10 5 10 11l-2 23c-1 6-5 10\n-11 10h-1L1182 67 15 280h-1c-6 0-10-4-11-10l-2-23c-1-6 4-11 10-11z",
  800. widehat4: "M1181 0h2l1171 296c6 0 10 5 10 11l-2 23c-1 6-5 10\n-11 10h-1L1182 67 15 340h-1c-6 0-10-4-11-10l-2-23c-1-6 4-11 10-11z",
  801. // widecheck paths are all inverted versions of widehat
  802. widecheck1: "M529,159h5l519,-115c5,-1,9,-5,9,-10c0,-1,-1,-2,-1,-3l-4,-22c-1,\n-5,-5,-9,-11,-9h-2l-512,92l-513,-92h-2c-5,0,-9,4,-11,9l-5,22c-1,6,2,12,8,13z",
  803. widecheck2: "M1181,220h2l1171,-176c6,0,10,-5,10,-11l-2,-23c-1,-6,-5,-10,\n-11,-10h-1l-1168,153l-1167,-153h-1c-6,0,-10,4,-11,10l-2,23c-1,6,4,11,10,11z",
  804. widecheck3: "M1181,280h2l1171,-236c6,0,10,-5,10,-11l-2,-23c-1,-6,-5,-10,\n-11,-10h-1l-1168,213l-1167,-213h-1c-6,0,-10,4,-11,10l-2,23c-1,6,4,11,10,11z",
  805. widecheck4: "M1181,340h2l1171,-296c6,0,10,-5,10,-11l-2,-23c-1,-6,-5,-10,\n-11,-10h-1l-1168,273l-1167,-273h-1c-6,0,-10,4,-11,10l-2,23c-1,6,4,11,10,11z",
  806. // The next ten paths support reaction arrows from the mhchem package.
  807. // Arrows for \ce{<-->} are offset from xAxis by 0.22ex, per mhchem in LaTeX
  808. // baraboveleftarrow is mostly from from glyph U+2190 in font KaTeX Main
  809. baraboveleftarrow: "M400000 620h-399890l3 -3c68.7 -52.7 113.7 -120 135 -202\nc4 -14.7 6 -23 6 -25c0 -7.3 -7 -11 -21 -11c-8 0 -13.2 0.8 -15.5 2.5\nc-2.3 1.7 -4.2 5.8 -5.5 12.5c-1.3 4.7 -2.7 10.3 -4 17c-12 48.7 -34.8 92 -68.5 130\ns-74.2 66.3 -121.5 85c-10 4 -16 7.7 -18 11c0 8.7 6 14.3 18 17c47.3 18.7 87.8 47\n121.5 85s56.5 81.3 68.5 130c0.7 2 1.3 5 2 9s1.2 6.7 1.5 8c0.3 1.3 1 3.3 2 6\ns2.2 4.5 3.5 5.5c1.3 1 3.3 1.8 6 2.5s6 1 10 1c14 0 21 -3.7 21 -11\nc0 -2 -2 -10.3 -6 -25c-20 -79.3 -65 -146.7 -135 -202l-3 -3h399890z\nM100 620v40h399900v-40z M0 241v40h399900v-40zM0 241v40h399900v-40z",
  810. // rightarrowabovebar is mostly from glyph U+2192, KaTeX Main
  811. rightarrowabovebar: "M0 241v40h399891c-47.3 35.3-84 78-110 128-16.7 32\n-27.7 63.7-33 95 0 1.3-.2 2.7-.5 4-.3 1.3-.5 2.3-.5 3 0 7.3 6.7 11 20 11 8 0\n13.2-.8 15.5-2.5 2.3-1.7 4.2-5.5 5.5-11.5 2-13.3 5.7-27 11-41 14.7-44.7 39\n-84.5 73-119.5s73.7-60.2 119-75.5c6-2 9-5.7 9-11s-3-9-9-11c-45.3-15.3-85-40.5\n-119-75.5s-58.3-74.8-73-119.5c-4.7-14-8.3-27.3-11-40-1.3-6.7-3.2-10.8-5.5\n-12.5-2.3-1.7-7.5-2.5-15.5-2.5-14 0-21 3.7-21 11 0 2 2 10.3 6 25 20.7 83.3 67\n151.7 139 205zm96 379h399894v40H0zm0 0h399904v40H0z",
  812. // The short left harpoon has 0.5em (i.e. 500 units) kern on the left end.
  813. // Ref from mhchem.sty: \rlap{\raisebox{-.22ex}{$\kern0.5em
  814. baraboveshortleftharpoon: "M507,435c-4,4,-6.3,8.7,-7,14c0,5.3,0.7,9,2,11\nc1.3,2,5.3,5.3,12,10c90.7,54,156,130,196,228c3.3,10.7,6.3,16.3,9,17\nc2,0.7,5,1,9,1c0,0,5,0,5,0c10.7,0,16.7,-2,18,-6c2,-2.7,1,-9.7,-3,-21\nc-32,-87.3,-82.7,-157.7,-152,-211c0,0,-3,-3,-3,-3l399351,0l0,-40\nc-398570,0,-399437,0,-399437,0z M593 435 v40 H399500 v-40z\nM0 281 v-40 H399908 v40z M0 281 v-40 H399908 v40z",
  815. rightharpoonaboveshortbar: "M0,241 l0,40c399126,0,399993,0,399993,0\nc4.7,-4.7,7,-9.3,7,-14c0,-9.3,-3.7,-15.3,-11,-18c-92.7,-56.7,-159,-133.7,-199,\n-231c-3.3,-9.3,-6,-14.7,-8,-16c-2,-1.3,-7,-2,-15,-2c-10.7,0,-16.7,2,-18,6\nc-2,2.7,-1,9.7,3,21c15.3,42,36.7,81.8,64,119.5c27.3,37.7,58,69.2,92,94.5z\nM0 241 v40 H399908 v-40z M0 475 v-40 H399500 v40z M0 475 v-40 H399500 v40z",
  816. shortbaraboveleftharpoon: "M7,435c-4,4,-6.3,8.7,-7,14c0,5.3,0.7,9,2,11\nc1.3,2,5.3,5.3,12,10c90.7,54,156,130,196,228c3.3,10.7,6.3,16.3,9,17c2,0.7,5,1,9,\n1c0,0,5,0,5,0c10.7,0,16.7,-2,18,-6c2,-2.7,1,-9.7,-3,-21c-32,-87.3,-82.7,-157.7,\n-152,-211c0,0,-3,-3,-3,-3l399907,0l0,-40c-399126,0,-399993,0,-399993,0z\nM93 435 v40 H400000 v-40z M500 241 v40 H400000 v-40z M500 241 v40 H400000 v-40z",
  817. shortrightharpoonabovebar: "M53,241l0,40c398570,0,399437,0,399437,0\nc4.7,-4.7,7,-9.3,7,-14c0,-9.3,-3.7,-15.3,-11,-18c-92.7,-56.7,-159,-133.7,-199,\n-231c-3.3,-9.3,-6,-14.7,-8,-16c-2,-1.3,-7,-2,-15,-2c-10.7,0,-16.7,2,-18,6\nc-2,2.7,-1,9.7,3,21c15.3,42,36.7,81.8,64,119.5c27.3,37.7,58,69.2,92,94.5z\nM500 241 v40 H399408 v-40z M500 435 v40 H400000 v-40z"
  818. };
  819. ;// CONCATENATED MODULE: ./src/tree.js
  820. /**
  821. * This node represents a document fragment, which contains elements, but when
  822. * placed into the DOM doesn't have any representation itself. It only contains
  823. * children and doesn't have any DOM node properties.
  824. */
  825. var DocumentFragment = /*#__PURE__*/function () {
  826. // HtmlDomNode
  827. // Never used; needed for satisfying interface.
  828. function DocumentFragment(children) {
  829. this.children = void 0;
  830. this.classes = void 0;
  831. this.height = void 0;
  832. this.depth = void 0;
  833. this.maxFontSize = void 0;
  834. this.style = void 0;
  835. this.children = children;
  836. this.classes = [];
  837. this.height = 0;
  838. this.depth = 0;
  839. this.maxFontSize = 0;
  840. this.style = {};
  841. }
  842. var _proto = DocumentFragment.prototype;
  843. _proto.hasClass = function hasClass(className) {
  844. return utils.contains(this.classes, className);
  845. }
  846. /** Convert the fragment into a node. */
  847. ;
  848. _proto.toNode = function toNode() {
  849. var frag = document.createDocumentFragment();
  850. for (var i = 0; i < this.children.length; i++) {
  851. frag.appendChild(this.children[i].toNode());
  852. }
  853. return frag;
  854. }
  855. /** Convert the fragment into HTML markup. */
  856. ;
  857. _proto.toMarkup = function toMarkup() {
  858. var markup = ""; // Simply concatenate the markup for the children together.
  859. for (var i = 0; i < this.children.length; i++) {
  860. markup += this.children[i].toMarkup();
  861. }
  862. return markup;
  863. }
  864. /**
  865. * Converts the math node into a string, similar to innerText. Applies to
  866. * MathDomNode's only.
  867. */
  868. ;
  869. _proto.toText = function toText() {
  870. // To avoid this, we would subclass documentFragment separately for
  871. // MathML, but polyfills for subclassing is expensive per PR 1469.
  872. // $FlowFixMe: Only works for ChildType = MathDomNode.
  873. var toText = function toText(child) {
  874. return child.toText();
  875. };
  876. return this.children.map(toText).join("");
  877. };
  878. return DocumentFragment;
  879. }();
  880. ;// CONCATENATED MODULE: ./src/fontMetricsData.js
  881. // This file is GENERATED by buildMetrics.sh. DO NOT MODIFY.
  882. /* harmony default export */ var fontMetricsData = ({
  883. "AMS-Regular": {
  884. "32": [0, 0, 0, 0, 0.25],
  885. "65": [0, 0.68889, 0, 0, 0.72222],
  886. "66": [0, 0.68889, 0, 0, 0.66667],
  887. "67": [0, 0.68889, 0, 0, 0.72222],
  888. "68": [0, 0.68889, 0, 0, 0.72222],
  889. "69": [0, 0.68889, 0, 0, 0.66667],
  890. "70": [0, 0.68889, 0, 0, 0.61111],
  891. "71": [0, 0.68889, 0, 0, 0.77778],
  892. "72": [0, 0.68889, 0, 0, 0.77778],
  893. "73": [0, 0.68889, 0, 0, 0.38889],
  894. "74": [0.16667, 0.68889, 0, 0, 0.5],
  895. "75": [0, 0.68889, 0, 0, 0.77778],
  896. "76": [0, 0.68889, 0, 0, 0.66667],
  897. "77": [0, 0.68889, 0, 0, 0.94445],
  898. "78": [0, 0.68889, 0, 0, 0.72222],
  899. "79": [0.16667, 0.68889, 0, 0, 0.77778],
  900. "80": [0, 0.68889, 0, 0, 0.61111],
  901. "81": [0.16667, 0.68889, 0, 0, 0.77778],
  902. "82": [0, 0.68889, 0, 0, 0.72222],
  903. "83": [0, 0.68889, 0, 0, 0.55556],
  904. "84": [0, 0.68889, 0, 0, 0.66667],
  905. "85": [0, 0.68889, 0, 0, 0.72222],
  906. "86": [0, 0.68889, 0, 0, 0.72222],
  907. "87": [0, 0.68889, 0, 0, 1.0],
  908. "88": [0, 0.68889, 0, 0, 0.72222],
  909. "89": [0, 0.68889, 0, 0, 0.72222],
  910. "90": [0, 0.68889, 0, 0, 0.66667],
  911. "107": [0, 0.68889, 0, 0, 0.55556],
  912. "160": [0, 0, 0, 0, 0.25],
  913. "165": [0, 0.675, 0.025, 0, 0.75],
  914. "174": [0.15559, 0.69224, 0, 0, 0.94666],
  915. "240": [0, 0.68889, 0, 0, 0.55556],
  916. "295": [0, 0.68889, 0, 0, 0.54028],
  917. "710": [0, 0.825, 0, 0, 2.33334],
  918. "732": [0, 0.9, 0, 0, 2.33334],
  919. "770": [0, 0.825, 0, 0, 2.33334],
  920. "771": [0, 0.9, 0, 0, 2.33334],
  921. "989": [0.08167, 0.58167, 0, 0, 0.77778],
  922. "1008": [0, 0.43056, 0.04028, 0, 0.66667],
  923. "8245": [0, 0.54986, 0, 0, 0.275],
  924. "8463": [0, 0.68889, 0, 0, 0.54028],
  925. "8487": [0, 0.68889, 0, 0, 0.72222],
  926. "8498": [0, 0.68889, 0, 0, 0.55556],
  927. "8502": [0, 0.68889, 0, 0, 0.66667],
  928. "8503": [0, 0.68889, 0, 0, 0.44445],
  929. "8504": [0, 0.68889, 0, 0, 0.66667],
  930. "8513": [0, 0.68889, 0, 0, 0.63889],
  931. "8592": [-0.03598, 0.46402, 0, 0, 0.5],
  932. "8594": [-0.03598, 0.46402, 0, 0, 0.5],
  933. "8602": [-0.13313, 0.36687, 0, 0, 1.0],
  934. "8603": [-0.13313, 0.36687, 0, 0, 1.0],
  935. "8606": [0.01354, 0.52239, 0, 0, 1.0],
  936. "8608": [0.01354, 0.52239, 0, 0, 1.0],
  937. "8610": [0.01354, 0.52239, 0, 0, 1.11111],
  938. "8611": [0.01354, 0.52239, 0, 0, 1.11111],
  939. "8619": [0, 0.54986, 0, 0, 1.0],
  940. "8620": [0, 0.54986, 0, 0, 1.0],
  941. "8621": [-0.13313, 0.37788, 0, 0, 1.38889],
  942. "8622": [-0.13313, 0.36687, 0, 0, 1.0],
  943. "8624": [0, 0.69224, 0, 0, 0.5],
  944. "8625": [0, 0.69224, 0, 0, 0.5],
  945. "8630": [0, 0.43056, 0, 0, 1.0],
  946. "8631": [0, 0.43056, 0, 0, 1.0],
  947. "8634": [0.08198, 0.58198, 0, 0, 0.77778],
  948. "8635": [0.08198, 0.58198, 0, 0, 0.77778],
  949. "8638": [0.19444, 0.69224, 0, 0, 0.41667],
  950. "8639": [0.19444, 0.69224, 0, 0, 0.41667],
  951. "8642": [0.19444, 0.69224, 0, 0, 0.41667],
  952. "8643": [0.19444, 0.69224, 0, 0, 0.41667],
  953. "8644": [0.1808, 0.675, 0, 0, 1.0],
  954. "8646": [0.1808, 0.675, 0, 0, 1.0],
  955. "8647": [0.1808, 0.675, 0, 0, 1.0],
  956. "8648": [0.19444, 0.69224, 0, 0, 0.83334],
  957. "8649": [0.1808, 0.675, 0, 0, 1.0],
  958. "8650": [0.19444, 0.69224, 0, 0, 0.83334],
  959. "8651": [0.01354, 0.52239, 0, 0, 1.0],
  960. "8652": [0.01354, 0.52239, 0, 0, 1.0],
  961. "8653": [-0.13313, 0.36687, 0, 0, 1.0],
  962. "8654": [-0.13313, 0.36687, 0, 0, 1.0],
  963. "8655": [-0.13313, 0.36687, 0, 0, 1.0],
  964. "8666": [0.13667, 0.63667, 0, 0, 1.0],
  965. "8667": [0.13667, 0.63667, 0, 0, 1.0],
  966. "8669": [-0.13313, 0.37788, 0, 0, 1.0],
  967. "8672": [-0.064, 0.437, 0, 0, 1.334],
  968. "8674": [-0.064, 0.437, 0, 0, 1.334],
  969. "8705": [0, 0.825, 0, 0, 0.5],
  970. "8708": [0, 0.68889, 0, 0, 0.55556],
  971. "8709": [0.08167, 0.58167, 0, 0, 0.77778],
  972. "8717": [0, 0.43056, 0, 0, 0.42917],
  973. "8722": [-0.03598, 0.46402, 0, 0, 0.5],
  974. "8724": [0.08198, 0.69224, 0, 0, 0.77778],
  975. "8726": [0.08167, 0.58167, 0, 0, 0.77778],
  976. "8733": [0, 0.69224, 0, 0, 0.77778],
  977. "8736": [0, 0.69224, 0, 0, 0.72222],
  978. "8737": [0, 0.69224, 0, 0, 0.72222],
  979. "8738": [0.03517, 0.52239, 0, 0, 0.72222],
  980. "8739": [0.08167, 0.58167, 0, 0, 0.22222],
  981. "8740": [0.25142, 0.74111, 0, 0, 0.27778],
  982. "8741": [0.08167, 0.58167, 0, 0, 0.38889],
  983. "8742": [0.25142, 0.74111, 0, 0, 0.5],
  984. "8756": [0, 0.69224, 0, 0, 0.66667],
  985. "8757": [0, 0.69224, 0, 0, 0.66667],
  986. "8764": [-0.13313, 0.36687, 0, 0, 0.77778],
  987. "8765": [-0.13313, 0.37788, 0, 0, 0.77778],
  988. "8769": [-0.13313, 0.36687, 0, 0, 0.77778],
  989. "8770": [-0.03625, 0.46375, 0, 0, 0.77778],
  990. "8774": [0.30274, 0.79383, 0, 0, 0.77778],
  991. "8776": [-0.01688, 0.48312, 0, 0, 0.77778],
  992. "8778": [0.08167, 0.58167, 0, 0, 0.77778],
  993. "8782": [0.06062, 0.54986, 0, 0, 0.77778],
  994. "8783": [0.06062, 0.54986, 0, 0, 0.77778],
  995. "8785": [0.08198, 0.58198, 0, 0, 0.77778],
  996. "8786": [0.08198, 0.58198, 0, 0, 0.77778],
  997. "8787": [0.08198, 0.58198, 0, 0, 0.77778],
  998. "8790": [0, 0.69224, 0, 0, 0.77778],
  999. "8791": [0.22958, 0.72958, 0, 0, 0.77778],
  1000. "8796": [0.08198, 0.91667, 0, 0, 0.77778],
  1001. "8806": [0.25583, 0.75583, 0, 0, 0.77778],
  1002. "8807": [0.25583, 0.75583, 0, 0, 0.77778],
  1003. "8808": [0.25142, 0.75726, 0, 0, 0.77778],
  1004. "8809": [0.25142, 0.75726, 0, 0, 0.77778],
  1005. "8812": [0.25583, 0.75583, 0, 0, 0.5],
  1006. "8814": [0.20576, 0.70576, 0, 0, 0.77778],
  1007. "8815": [0.20576, 0.70576, 0, 0, 0.77778],
  1008. "8816": [0.30274, 0.79383, 0, 0, 0.77778],
  1009. "8817": [0.30274, 0.79383, 0, 0, 0.77778],
  1010. "8818": [0.22958, 0.72958, 0, 0, 0.77778],
  1011. "8819": [0.22958, 0.72958, 0, 0, 0.77778],
  1012. "8822": [0.1808, 0.675, 0, 0, 0.77778],
  1013. "8823": [0.1808, 0.675, 0, 0, 0.77778],
  1014. "8828": [0.13667, 0.63667, 0, 0, 0.77778],
  1015. "8829": [0.13667, 0.63667, 0, 0, 0.77778],
  1016. "8830": [0.22958, 0.72958, 0, 0, 0.77778],
  1017. "8831": [0.22958, 0.72958, 0, 0, 0.77778],
  1018. "8832": [0.20576, 0.70576, 0, 0, 0.77778],
  1019. "8833": [0.20576, 0.70576, 0, 0, 0.77778],
  1020. "8840": [0.30274, 0.79383, 0, 0, 0.77778],
  1021. "8841": [0.30274, 0.79383, 0, 0, 0.77778],
  1022. "8842": [0.13597, 0.63597, 0, 0, 0.77778],
  1023. "8843": [0.13597, 0.63597, 0, 0, 0.77778],
  1024. "8847": [0.03517, 0.54986, 0, 0, 0.77778],
  1025. "8848": [0.03517, 0.54986, 0, 0, 0.77778],
  1026. "8858": [0.08198, 0.58198, 0, 0, 0.77778],
  1027. "8859": [0.08198, 0.58198, 0, 0, 0.77778],
  1028. "8861": [0.08198, 0.58198, 0, 0, 0.77778],
  1029. "8862": [0, 0.675, 0, 0, 0.77778],
  1030. "8863": [0, 0.675, 0, 0, 0.77778],
  1031. "8864": [0, 0.675, 0, 0, 0.77778],
  1032. "8865": [0, 0.675, 0, 0, 0.77778],
  1033. "8872": [0, 0.69224, 0, 0, 0.61111],
  1034. "8873": [0, 0.69224, 0, 0, 0.72222],
  1035. "8874": [0, 0.69224, 0, 0, 0.88889],
  1036. "8876": [0, 0.68889, 0, 0, 0.61111],
  1037. "8877": [0, 0.68889, 0, 0, 0.61111],
  1038. "8878": [0, 0.68889, 0, 0, 0.72222],
  1039. "8879": [0, 0.68889, 0, 0, 0.72222],
  1040. "8882": [0.03517, 0.54986, 0, 0, 0.77778],
  1041. "8883": [0.03517, 0.54986, 0, 0, 0.77778],
  1042. "8884": [0.13667, 0.63667, 0, 0, 0.77778],
  1043. "8885": [0.13667, 0.63667, 0, 0, 0.77778],
  1044. "8888": [0, 0.54986, 0, 0, 1.11111],
  1045. "8890": [0.19444, 0.43056, 0, 0, 0.55556],
  1046. "8891": [0.19444, 0.69224, 0, 0, 0.61111],
  1047. "8892": [0.19444, 0.69224, 0, 0, 0.61111],
  1048. "8901": [0, 0.54986, 0, 0, 0.27778],
  1049. "8903": [0.08167, 0.58167, 0, 0, 0.77778],
  1050. "8905": [0.08167, 0.58167, 0, 0, 0.77778],
  1051. "8906": [0.08167, 0.58167, 0, 0, 0.77778],
  1052. "8907": [0, 0.69224, 0, 0, 0.77778],
  1053. "8908": [0, 0.69224, 0, 0, 0.77778],
  1054. "8909": [-0.03598, 0.46402, 0, 0, 0.77778],
  1055. "8910": [0, 0.54986, 0, 0, 0.76042],
  1056. "8911": [0, 0.54986, 0, 0, 0.76042],
  1057. "8912": [0.03517, 0.54986, 0, 0, 0.77778],
  1058. "8913": [0.03517, 0.54986, 0, 0, 0.77778],
  1059. "8914": [0, 0.54986, 0, 0, 0.66667],
  1060. "8915": [0, 0.54986, 0, 0, 0.66667],
  1061. "8916": [0, 0.69224, 0, 0, 0.66667],
  1062. "8918": [0.0391, 0.5391, 0, 0, 0.77778],
  1063. "8919": [0.0391, 0.5391, 0, 0, 0.77778],
  1064. "8920": [0.03517, 0.54986, 0, 0, 1.33334],
  1065. "8921": [0.03517, 0.54986, 0, 0, 1.33334],
  1066. "8922": [0.38569, 0.88569, 0, 0, 0.77778],
  1067. "8923": [0.38569, 0.88569, 0, 0, 0.77778],
  1068. "8926": [0.13667, 0.63667, 0, 0, 0.77778],
  1069. "8927": [0.13667, 0.63667, 0, 0, 0.77778],
  1070. "8928": [0.30274, 0.79383, 0, 0, 0.77778],
  1071. "8929": [0.30274, 0.79383, 0, 0, 0.77778],
  1072. "8934": [0.23222, 0.74111, 0, 0, 0.77778],
  1073. "8935": [0.23222, 0.74111, 0, 0, 0.77778],
  1074. "8936": [0.23222, 0.74111, 0, 0, 0.77778],
  1075. "8937": [0.23222, 0.74111, 0, 0, 0.77778],
  1076. "8938": [0.20576, 0.70576, 0, 0, 0.77778],
  1077. "8939": [0.20576, 0.70576, 0, 0, 0.77778],
  1078. "8940": [0.30274, 0.79383, 0, 0, 0.77778],
  1079. "8941": [0.30274, 0.79383, 0, 0, 0.77778],
  1080. "8994": [0.19444, 0.69224, 0, 0, 0.77778],
  1081. "8995": [0.19444, 0.69224, 0, 0, 0.77778],
  1082. "9416": [0.15559, 0.69224, 0, 0, 0.90222],
  1083. "9484": [0, 0.69224, 0, 0, 0.5],
  1084. "9488": [0, 0.69224, 0, 0, 0.5],
  1085. "9492": [0, 0.37788, 0, 0, 0.5],
  1086. "9496": [0, 0.37788, 0, 0, 0.5],
  1087. "9585": [0.19444, 0.68889, 0, 0, 0.88889],
  1088. "9586": [0.19444, 0.74111, 0, 0, 0.88889],
  1089. "9632": [0, 0.675, 0, 0, 0.77778],
  1090. "9633": [0, 0.675, 0, 0, 0.77778],
  1091. "9650": [0, 0.54986, 0, 0, 0.72222],
  1092. "9651": [0, 0.54986, 0, 0, 0.72222],
  1093. "9654": [0.03517, 0.54986, 0, 0, 0.77778],
  1094. "9660": [0, 0.54986, 0, 0, 0.72222],
  1095. "9661": [0, 0.54986, 0, 0, 0.72222],
  1096. "9664": [0.03517, 0.54986, 0, 0, 0.77778],
  1097. "9674": [0.11111, 0.69224, 0, 0, 0.66667],
  1098. "9733": [0.19444, 0.69224, 0, 0, 0.94445],
  1099. "10003": [0, 0.69224, 0, 0, 0.83334],
  1100. "10016": [0, 0.69224, 0, 0, 0.83334],
  1101. "10731": [0.11111, 0.69224, 0, 0, 0.66667],
  1102. "10846": [0.19444, 0.75583, 0, 0, 0.61111],
  1103. "10877": [0.13667, 0.63667, 0, 0, 0.77778],
  1104. "10878": [0.13667, 0.63667, 0, 0, 0.77778],
  1105. "10885": [0.25583, 0.75583, 0, 0, 0.77778],
  1106. "10886": [0.25583, 0.75583, 0, 0, 0.77778],
  1107. "10887": [0.13597, 0.63597, 0, 0, 0.77778],
  1108. "10888": [0.13597, 0.63597, 0, 0, 0.77778],
  1109. "10889": [0.26167, 0.75726, 0, 0, 0.77778],
  1110. "10890": [0.26167, 0.75726, 0, 0, 0.77778],
  1111. "10891": [0.48256, 0.98256, 0, 0, 0.77778],
  1112. "10892": [0.48256, 0.98256, 0, 0, 0.77778],
  1113. "10901": [0.13667, 0.63667, 0, 0, 0.77778],
  1114. "10902": [0.13667, 0.63667, 0, 0, 0.77778],
  1115. "10933": [0.25142, 0.75726, 0, 0, 0.77778],
  1116. "10934": [0.25142, 0.75726, 0, 0, 0.77778],
  1117. "10935": [0.26167, 0.75726, 0, 0, 0.77778],
  1118. "10936": [0.26167, 0.75726, 0, 0, 0.77778],
  1119. "10937": [0.26167, 0.75726, 0, 0, 0.77778],
  1120. "10938": [0.26167, 0.75726, 0, 0, 0.77778],
  1121. "10949": [0.25583, 0.75583, 0, 0, 0.77778],
  1122. "10950": [0.25583, 0.75583, 0, 0, 0.77778],
  1123. "10955": [0.28481, 0.79383, 0, 0, 0.77778],
  1124. "10956": [0.28481, 0.79383, 0, 0, 0.77778],
  1125. "57350": [0.08167, 0.58167, 0, 0, 0.22222],
  1126. "57351": [0.08167, 0.58167, 0, 0, 0.38889],
  1127. "57352": [0.08167, 0.58167, 0, 0, 0.77778],
  1128. "57353": [0, 0.43056, 0.04028, 0, 0.66667],
  1129. "57356": [0.25142, 0.75726, 0, 0, 0.77778],
  1130. "57357": [0.25142, 0.75726, 0, 0, 0.77778],
  1131. "57358": [0.41951, 0.91951, 0, 0, 0.77778],
  1132. "57359": [0.30274, 0.79383, 0, 0, 0.77778],
  1133. "57360": [0.30274, 0.79383, 0, 0, 0.77778],
  1134. "57361": [0.41951, 0.91951, 0, 0, 0.77778],
  1135. "57366": [0.25142, 0.75726, 0, 0, 0.77778],
  1136. "57367": [0.25142, 0.75726, 0, 0, 0.77778],
  1137. "57368": [0.25142, 0.75726, 0, 0, 0.77778],
  1138. "57369": [0.25142, 0.75726, 0, 0, 0.77778],
  1139. "57370": [0.13597, 0.63597, 0, 0, 0.77778],
  1140. "57371": [0.13597, 0.63597, 0, 0, 0.77778]
  1141. },
  1142. "Caligraphic-Regular": {
  1143. "32": [0, 0, 0, 0, 0.25],
  1144. "65": [0, 0.68333, 0, 0.19445, 0.79847],
  1145. "66": [0, 0.68333, 0.03041, 0.13889, 0.65681],
  1146. "67": [0, 0.68333, 0.05834, 0.13889, 0.52653],
  1147. "68": [0, 0.68333, 0.02778, 0.08334, 0.77139],
  1148. "69": [0, 0.68333, 0.08944, 0.11111, 0.52778],
  1149. "70": [0, 0.68333, 0.09931, 0.11111, 0.71875],
  1150. "71": [0.09722, 0.68333, 0.0593, 0.11111, 0.59487],
  1151. "72": [0, 0.68333, 0.00965, 0.11111, 0.84452],
  1152. "73": [0, 0.68333, 0.07382, 0, 0.54452],
  1153. "74": [0.09722, 0.68333, 0.18472, 0.16667, 0.67778],
  1154. "75": [0, 0.68333, 0.01445, 0.05556, 0.76195],
  1155. "76": [0, 0.68333, 0, 0.13889, 0.68972],
  1156. "77": [0, 0.68333, 0, 0.13889, 1.2009],
  1157. "78": [0, 0.68333, 0.14736, 0.08334, 0.82049],
  1158. "79": [0, 0.68333, 0.02778, 0.11111, 0.79611],
  1159. "80": [0, 0.68333, 0.08222, 0.08334, 0.69556],
  1160. "81": [0.09722, 0.68333, 0, 0.11111, 0.81667],
  1161. "82": [0, 0.68333, 0, 0.08334, 0.8475],
  1162. "83": [0, 0.68333, 0.075, 0.13889, 0.60556],
  1163. "84": [0, 0.68333, 0.25417, 0, 0.54464],
  1164. "85": [0, 0.68333, 0.09931, 0.08334, 0.62583],
  1165. "86": [0, 0.68333, 0.08222, 0, 0.61278],
  1166. "87": [0, 0.68333, 0.08222, 0.08334, 0.98778],
  1167. "88": [0, 0.68333, 0.14643, 0.13889, 0.7133],
  1168. "89": [0.09722, 0.68333, 0.08222, 0.08334, 0.66834],
  1169. "90": [0, 0.68333, 0.07944, 0.13889, 0.72473],
  1170. "160": [0, 0, 0, 0, 0.25]
  1171. },
  1172. "Fraktur-Regular": {
  1173. "32": [0, 0, 0, 0, 0.25],
  1174. "33": [0, 0.69141, 0, 0, 0.29574],
  1175. "34": [0, 0.69141, 0, 0, 0.21471],
  1176. "38": [0, 0.69141, 0, 0, 0.73786],
  1177. "39": [0, 0.69141, 0, 0, 0.21201],
  1178. "40": [0.24982, 0.74947, 0, 0, 0.38865],
  1179. "41": [0.24982, 0.74947, 0, 0, 0.38865],
  1180. "42": [0, 0.62119, 0, 0, 0.27764],
  1181. "43": [0.08319, 0.58283, 0, 0, 0.75623],
  1182. "44": [0, 0.10803, 0, 0, 0.27764],
  1183. "45": [0.08319, 0.58283, 0, 0, 0.75623],
  1184. "46": [0, 0.10803, 0, 0, 0.27764],
  1185. "47": [0.24982, 0.74947, 0, 0, 0.50181],
  1186. "48": [0, 0.47534, 0, 0, 0.50181],
  1187. "49": [0, 0.47534, 0, 0, 0.50181],
  1188. "50": [0, 0.47534, 0, 0, 0.50181],
  1189. "51": [0.18906, 0.47534, 0, 0, 0.50181],
  1190. "52": [0.18906, 0.47534, 0, 0, 0.50181],
  1191. "53": [0.18906, 0.47534, 0, 0, 0.50181],
  1192. "54": [0, 0.69141, 0, 0, 0.50181],
  1193. "55": [0.18906, 0.47534, 0, 0, 0.50181],
  1194. "56": [0, 0.69141, 0, 0, 0.50181],
  1195. "57": [0.18906, 0.47534, 0, 0, 0.50181],
  1196. "58": [0, 0.47534, 0, 0, 0.21606],
  1197. "59": [0.12604, 0.47534, 0, 0, 0.21606],
  1198. "61": [-0.13099, 0.36866, 0, 0, 0.75623],
  1199. "63": [0, 0.69141, 0, 0, 0.36245],
  1200. "65": [0, 0.69141, 0, 0, 0.7176],
  1201. "66": [0, 0.69141, 0, 0, 0.88397],
  1202. "67": [0, 0.69141, 0, 0, 0.61254],
  1203. "68": [0, 0.69141, 0, 0, 0.83158],
  1204. "69": [0, 0.69141, 0, 0, 0.66278],
  1205. "70": [0.12604, 0.69141, 0, 0, 0.61119],
  1206. "71": [0, 0.69141, 0, 0, 0.78539],
  1207. "72": [0.06302, 0.69141, 0, 0, 0.7203],
  1208. "73": [0, 0.69141, 0, 0, 0.55448],
  1209. "74": [0.12604, 0.69141, 0, 0, 0.55231],
  1210. "75": [0, 0.69141, 0, 0, 0.66845],
  1211. "76": [0, 0.69141, 0, 0, 0.66602],
  1212. "77": [0, 0.69141, 0, 0, 1.04953],
  1213. "78": [0, 0.69141, 0, 0, 0.83212],
  1214. "79": [0, 0.69141, 0, 0, 0.82699],
  1215. "80": [0.18906, 0.69141, 0, 0, 0.82753],
  1216. "81": [0.03781, 0.69141, 0, 0, 0.82699],
  1217. "82": [0, 0.69141, 0, 0, 0.82807],
  1218. "83": [0, 0.69141, 0, 0, 0.82861],
  1219. "84": [0, 0.69141, 0, 0, 0.66899],
  1220. "85": [0, 0.69141, 0, 0, 0.64576],
  1221. "86": [0, 0.69141, 0, 0, 0.83131],
  1222. "87": [0, 0.69141, 0, 0, 1.04602],
  1223. "88": [0, 0.69141, 0, 0, 0.71922],
  1224. "89": [0.18906, 0.69141, 0, 0, 0.83293],
  1225. "90": [0.12604, 0.69141, 0, 0, 0.60201],
  1226. "91": [0.24982, 0.74947, 0, 0, 0.27764],
  1227. "93": [0.24982, 0.74947, 0, 0, 0.27764],
  1228. "94": [0, 0.69141, 0, 0, 0.49965],
  1229. "97": [0, 0.47534, 0, 0, 0.50046],
  1230. "98": [0, 0.69141, 0, 0, 0.51315],
  1231. "99": [0, 0.47534, 0, 0, 0.38946],
  1232. "100": [0, 0.62119, 0, 0, 0.49857],
  1233. "101": [0, 0.47534, 0, 0, 0.40053],
  1234. "102": [0.18906, 0.69141, 0, 0, 0.32626],
  1235. "103": [0.18906, 0.47534, 0, 0, 0.5037],
  1236. "104": [0.18906, 0.69141, 0, 0, 0.52126],
  1237. "105": [0, 0.69141, 0, 0, 0.27899],
  1238. "106": [0, 0.69141, 0, 0, 0.28088],
  1239. "107": [0, 0.69141, 0, 0, 0.38946],
  1240. "108": [0, 0.69141, 0, 0, 0.27953],
  1241. "109": [0, 0.47534, 0, 0, 0.76676],
  1242. "110": [0, 0.47534, 0, 0, 0.52666],
  1243. "111": [0, 0.47534, 0, 0, 0.48885],
  1244. "112": [0.18906, 0.52396, 0, 0, 0.50046],
  1245. "113": [0.18906, 0.47534, 0, 0, 0.48912],
  1246. "114": [0, 0.47534, 0, 0, 0.38919],
  1247. "115": [0, 0.47534, 0, 0, 0.44266],
  1248. "116": [0, 0.62119, 0, 0, 0.33301],
  1249. "117": [0, 0.47534, 0, 0, 0.5172],
  1250. "118": [0, 0.52396, 0, 0, 0.5118],
  1251. "119": [0, 0.52396, 0, 0, 0.77351],
  1252. "120": [0.18906, 0.47534, 0, 0, 0.38865],
  1253. "121": [0.18906, 0.47534, 0, 0, 0.49884],
  1254. "122": [0.18906, 0.47534, 0, 0, 0.39054],
  1255. "160": [0, 0, 0, 0, 0.25],
  1256. "8216": [0, 0.69141, 0, 0, 0.21471],
  1257. "8217": [0, 0.69141, 0, 0, 0.21471],
  1258. "58112": [0, 0.62119, 0, 0, 0.49749],
  1259. "58113": [0, 0.62119, 0, 0, 0.4983],
  1260. "58114": [0.18906, 0.69141, 0, 0, 0.33328],
  1261. "58115": [0.18906, 0.69141, 0, 0, 0.32923],
  1262. "58116": [0.18906, 0.47534, 0, 0, 0.50343],
  1263. "58117": [0, 0.69141, 0, 0, 0.33301],
  1264. "58118": [0, 0.62119, 0, 0, 0.33409],
  1265. "58119": [0, 0.47534, 0, 0, 0.50073]
  1266. },
  1267. "Main-Bold": {
  1268. "32": [0, 0, 0, 0, 0.25],
  1269. "33": [0, 0.69444, 0, 0, 0.35],
  1270. "34": [0, 0.69444, 0, 0, 0.60278],
  1271. "35": [0.19444, 0.69444, 0, 0, 0.95833],
  1272. "36": [0.05556, 0.75, 0, 0, 0.575],
  1273. "37": [0.05556, 0.75, 0, 0, 0.95833],
  1274. "38": [0, 0.69444, 0, 0, 0.89444],
  1275. "39": [0, 0.69444, 0, 0, 0.31944],
  1276. "40": [0.25, 0.75, 0, 0, 0.44722],
  1277. "41": [0.25, 0.75, 0, 0, 0.44722],
  1278. "42": [0, 0.75, 0, 0, 0.575],
  1279. "43": [0.13333, 0.63333, 0, 0, 0.89444],
  1280. "44": [0.19444, 0.15556, 0, 0, 0.31944],
  1281. "45": [0, 0.44444, 0, 0, 0.38333],
  1282. "46": [0, 0.15556, 0, 0, 0.31944],
  1283. "47": [0.25, 0.75, 0, 0, 0.575],
  1284. "48": [0, 0.64444, 0, 0, 0.575],
  1285. "49": [0, 0.64444, 0, 0, 0.575],
  1286. "50": [0, 0.64444, 0, 0, 0.575],
  1287. "51": [0, 0.64444, 0, 0, 0.575],
  1288. "52": [0, 0.64444, 0, 0, 0.575],
  1289. "53": [0, 0.64444, 0, 0, 0.575],
  1290. "54": [0, 0.64444, 0, 0, 0.575],
  1291. "55": [0, 0.64444, 0, 0, 0.575],
  1292. "56": [0, 0.64444, 0, 0, 0.575],
  1293. "57": [0, 0.64444, 0, 0, 0.575],
  1294. "58": [0, 0.44444, 0, 0, 0.31944],
  1295. "59": [0.19444, 0.44444, 0, 0, 0.31944],
  1296. "60": [0.08556, 0.58556, 0, 0, 0.89444],
  1297. "61": [-0.10889, 0.39111, 0, 0, 0.89444],
  1298. "62": [0.08556, 0.58556, 0, 0, 0.89444],
  1299. "63": [0, 0.69444, 0, 0, 0.54305],
  1300. "64": [0, 0.69444, 0, 0, 0.89444],
  1301. "65": [0, 0.68611, 0, 0, 0.86944],
  1302. "66": [0, 0.68611, 0, 0, 0.81805],
  1303. "67": [0, 0.68611, 0, 0, 0.83055],
  1304. "68": [0, 0.68611, 0, 0, 0.88194],
  1305. "69": [0, 0.68611, 0, 0, 0.75555],
  1306. "70": [0, 0.68611, 0, 0, 0.72361],
  1307. "71": [0, 0.68611, 0, 0, 0.90416],
  1308. "72": [0, 0.68611, 0, 0, 0.9],
  1309. "73": [0, 0.68611, 0, 0, 0.43611],
  1310. "74": [0, 0.68611, 0, 0, 0.59444],
  1311. "75": [0, 0.68611, 0, 0, 0.90138],
  1312. "76": [0, 0.68611, 0, 0, 0.69166],
  1313. "77": [0, 0.68611, 0, 0, 1.09166],
  1314. "78": [0, 0.68611, 0, 0, 0.9],
  1315. "79": [0, 0.68611, 0, 0, 0.86388],
  1316. "80": [0, 0.68611, 0, 0, 0.78611],
  1317. "81": [0.19444, 0.68611, 0, 0, 0.86388],
  1318. "82": [0, 0.68611, 0, 0, 0.8625],
  1319. "83": [0, 0.68611, 0, 0, 0.63889],
  1320. "84": [0, 0.68611, 0, 0, 0.8],
  1321. "85": [0, 0.68611, 0, 0, 0.88472],
  1322. "86": [0, 0.68611, 0.01597, 0, 0.86944],
  1323. "87": [0, 0.68611, 0.01597, 0, 1.18888],
  1324. "88": [0, 0.68611, 0, 0, 0.86944],
  1325. "89": [0, 0.68611, 0.02875, 0, 0.86944],
  1326. "90": [0, 0.68611, 0, 0, 0.70277],
  1327. "91": [0.25, 0.75, 0, 0, 0.31944],
  1328. "92": [0.25, 0.75, 0, 0, 0.575],
  1329. "93": [0.25, 0.75, 0, 0, 0.31944],
  1330. "94": [0, 0.69444, 0, 0, 0.575],
  1331. "95": [0.31, 0.13444, 0.03194, 0, 0.575],
  1332. "97": [0, 0.44444, 0, 0, 0.55902],
  1333. "98": [0, 0.69444, 0, 0, 0.63889],
  1334. "99": [0, 0.44444, 0, 0, 0.51111],
  1335. "100": [0, 0.69444, 0, 0, 0.63889],
  1336. "101": [0, 0.44444, 0, 0, 0.52708],
  1337. "102": [0, 0.69444, 0.10903, 0, 0.35139],
  1338. "103": [0.19444, 0.44444, 0.01597, 0, 0.575],
  1339. "104": [0, 0.69444, 0, 0, 0.63889],
  1340. "105": [0, 0.69444, 0, 0, 0.31944],
  1341. "106": [0.19444, 0.69444, 0, 0, 0.35139],
  1342. "107": [0, 0.69444, 0, 0, 0.60694],
  1343. "108": [0, 0.69444, 0, 0, 0.31944],
  1344. "109": [0, 0.44444, 0, 0, 0.95833],
  1345. "110": [0, 0.44444, 0, 0, 0.63889],
  1346. "111": [0, 0.44444, 0, 0, 0.575],
  1347. "112": [0.19444, 0.44444, 0, 0, 0.63889],
  1348. "113": [0.19444, 0.44444, 0, 0, 0.60694],
  1349. "114": [0, 0.44444, 0, 0, 0.47361],
  1350. "115": [0, 0.44444, 0, 0, 0.45361],
  1351. "116": [0, 0.63492, 0, 0, 0.44722],
  1352. "117": [0, 0.44444, 0, 0, 0.63889],
  1353. "118": [0, 0.44444, 0.01597, 0, 0.60694],
  1354. "119": [0, 0.44444, 0.01597, 0, 0.83055],
  1355. "120": [0, 0.44444, 0, 0, 0.60694],
  1356. "121": [0.19444, 0.44444, 0.01597, 0, 0.60694],
  1357. "122": [0, 0.44444, 0, 0, 0.51111],
  1358. "123": [0.25, 0.75, 0, 0, 0.575],
  1359. "124": [0.25, 0.75, 0, 0, 0.31944],
  1360. "125": [0.25, 0.75, 0, 0, 0.575],
  1361. "126": [0.35, 0.34444, 0, 0, 0.575],
  1362. "160": [0, 0, 0, 0, 0.25],
  1363. "163": [0, 0.69444, 0, 0, 0.86853],
  1364. "168": [0, 0.69444, 0, 0, 0.575],
  1365. "172": [0, 0.44444, 0, 0, 0.76666],
  1366. "176": [0, 0.69444, 0, 0, 0.86944],
  1367. "177": [0.13333, 0.63333, 0, 0, 0.89444],
  1368. "184": [0.17014, 0, 0, 0, 0.51111],
  1369. "198": [0, 0.68611, 0, 0, 1.04166],
  1370. "215": [0.13333, 0.63333, 0, 0, 0.89444],
  1371. "216": [0.04861, 0.73472, 0, 0, 0.89444],
  1372. "223": [0, 0.69444, 0, 0, 0.59722],
  1373. "230": [0, 0.44444, 0, 0, 0.83055],
  1374. "247": [0.13333, 0.63333, 0, 0, 0.89444],
  1375. "248": [0.09722, 0.54167, 0, 0, 0.575],
  1376. "305": [0, 0.44444, 0, 0, 0.31944],
  1377. "338": [0, 0.68611, 0, 0, 1.16944],
  1378. "339": [0, 0.44444, 0, 0, 0.89444],
  1379. "567": [0.19444, 0.44444, 0, 0, 0.35139],
  1380. "710": [0, 0.69444, 0, 0, 0.575],
  1381. "711": [0, 0.63194, 0, 0, 0.575],
  1382. "713": [0, 0.59611, 0, 0, 0.575],
  1383. "714": [0, 0.69444, 0, 0, 0.575],
  1384. "715": [0, 0.69444, 0, 0, 0.575],
  1385. "728": [0, 0.69444, 0, 0, 0.575],
  1386. "729": [0, 0.69444, 0, 0, 0.31944],
  1387. "730": [0, 0.69444, 0, 0, 0.86944],
  1388. "732": [0, 0.69444, 0, 0, 0.575],
  1389. "733": [0, 0.69444, 0, 0, 0.575],
  1390. "915": [0, 0.68611, 0, 0, 0.69166],
  1391. "916": [0, 0.68611, 0, 0, 0.95833],
  1392. "920": [0, 0.68611, 0, 0, 0.89444],
  1393. "923": [0, 0.68611, 0, 0, 0.80555],
  1394. "926": [0, 0.68611, 0, 0, 0.76666],
  1395. "928": [0, 0.68611, 0, 0, 0.9],
  1396. "931": [0, 0.68611, 0, 0, 0.83055],
  1397. "933": [0, 0.68611, 0, 0, 0.89444],
  1398. "934": [0, 0.68611, 0, 0, 0.83055],
  1399. "936": [0, 0.68611, 0, 0, 0.89444],
  1400. "937": [0, 0.68611, 0, 0, 0.83055],
  1401. "8211": [0, 0.44444, 0.03194, 0, 0.575],
  1402. "8212": [0, 0.44444, 0.03194, 0, 1.14999],
  1403. "8216": [0, 0.69444, 0, 0, 0.31944],
  1404. "8217": [0, 0.69444, 0, 0, 0.31944],
  1405. "8220": [0, 0.69444, 0, 0, 0.60278],
  1406. "8221": [0, 0.69444, 0, 0, 0.60278],
  1407. "8224": [0.19444, 0.69444, 0, 0, 0.51111],
  1408. "8225": [0.19444, 0.69444, 0, 0, 0.51111],
  1409. "8242": [0, 0.55556, 0, 0, 0.34444],
  1410. "8407": [0, 0.72444, 0.15486, 0, 0.575],
  1411. "8463": [0, 0.69444, 0, 0, 0.66759],
  1412. "8465": [0, 0.69444, 0, 0, 0.83055],
  1413. "8467": [0, 0.69444, 0, 0, 0.47361],
  1414. "8472": [0.19444, 0.44444, 0, 0, 0.74027],
  1415. "8476": [0, 0.69444, 0, 0, 0.83055],
  1416. "8501": [0, 0.69444, 0, 0, 0.70277],
  1417. "8592": [-0.10889, 0.39111, 0, 0, 1.14999],
  1418. "8593": [0.19444, 0.69444, 0, 0, 0.575],
  1419. "8594": [-0.10889, 0.39111, 0, 0, 1.14999],
  1420. "8595": [0.19444, 0.69444, 0, 0, 0.575],
  1421. "8596": [-0.10889, 0.39111, 0, 0, 1.14999],
  1422. "8597": [0.25, 0.75, 0, 0, 0.575],
  1423. "8598": [0.19444, 0.69444, 0, 0, 1.14999],
  1424. "8599": [0.19444, 0.69444, 0, 0, 1.14999],
  1425. "8600": [0.19444, 0.69444, 0, 0, 1.14999],
  1426. "8601": [0.19444, 0.69444, 0, 0, 1.14999],
  1427. "8636": [-0.10889, 0.39111, 0, 0, 1.14999],
  1428. "8637": [-0.10889, 0.39111, 0, 0, 1.14999],
  1429. "8640": [-0.10889, 0.39111, 0, 0, 1.14999],
  1430. "8641": [-0.10889, 0.39111, 0, 0, 1.14999],
  1431. "8656": [-0.10889, 0.39111, 0, 0, 1.14999],
  1432. "8657": [0.19444, 0.69444, 0, 0, 0.70277],
  1433. "8658": [-0.10889, 0.39111, 0, 0, 1.14999],
  1434. "8659": [0.19444, 0.69444, 0, 0, 0.70277],
  1435. "8660": [-0.10889, 0.39111, 0, 0, 1.14999],
  1436. "8661": [0.25, 0.75, 0, 0, 0.70277],
  1437. "8704": [0, 0.69444, 0, 0, 0.63889],
  1438. "8706": [0, 0.69444, 0.06389, 0, 0.62847],
  1439. "8707": [0, 0.69444, 0, 0, 0.63889],
  1440. "8709": [0.05556, 0.75, 0, 0, 0.575],
  1441. "8711": [0, 0.68611, 0, 0, 0.95833],
  1442. "8712": [0.08556, 0.58556, 0, 0, 0.76666],
  1443. "8715": [0.08556, 0.58556, 0, 0, 0.76666],
  1444. "8722": [0.13333, 0.63333, 0, 0, 0.89444],
  1445. "8723": [0.13333, 0.63333, 0, 0, 0.89444],
  1446. "8725": [0.25, 0.75, 0, 0, 0.575],
  1447. "8726": [0.25, 0.75, 0, 0, 0.575],
  1448. "8727": [-0.02778, 0.47222, 0, 0, 0.575],
  1449. "8728": [-0.02639, 0.47361, 0, 0, 0.575],
  1450. "8729": [-0.02639, 0.47361, 0, 0, 0.575],
  1451. "8730": [0.18, 0.82, 0, 0, 0.95833],
  1452. "8733": [0, 0.44444, 0, 0, 0.89444],
  1453. "8734": [0, 0.44444, 0, 0, 1.14999],
  1454. "8736": [0, 0.69224, 0, 0, 0.72222],
  1455. "8739": [0.25, 0.75, 0, 0, 0.31944],
  1456. "8741": [0.25, 0.75, 0, 0, 0.575],
  1457. "8743": [0, 0.55556, 0, 0, 0.76666],
  1458. "8744": [0, 0.55556, 0, 0, 0.76666],
  1459. "8745": [0, 0.55556, 0, 0, 0.76666],
  1460. "8746": [0, 0.55556, 0, 0, 0.76666],
  1461. "8747": [0.19444, 0.69444, 0.12778, 0, 0.56875],
  1462. "8764": [-0.10889, 0.39111, 0, 0, 0.89444],
  1463. "8768": [0.19444, 0.69444, 0, 0, 0.31944],
  1464. "8771": [0.00222, 0.50222, 0, 0, 0.89444],
  1465. "8773": [0.027, 0.638, 0, 0, 0.894],
  1466. "8776": [0.02444, 0.52444, 0, 0, 0.89444],
  1467. "8781": [0.00222, 0.50222, 0, 0, 0.89444],
  1468. "8801": [0.00222, 0.50222, 0, 0, 0.89444],
  1469. "8804": [0.19667, 0.69667, 0, 0, 0.89444],
  1470. "8805": [0.19667, 0.69667, 0, 0, 0.89444],
  1471. "8810": [0.08556, 0.58556, 0, 0, 1.14999],
  1472. "8811": [0.08556, 0.58556, 0, 0, 1.14999],
  1473. "8826": [0.08556, 0.58556, 0, 0, 0.89444],
  1474. "8827": [0.08556, 0.58556, 0, 0, 0.89444],
  1475. "8834": [0.08556, 0.58556, 0, 0, 0.89444],
  1476. "8835": [0.08556, 0.58556, 0, 0, 0.89444],
  1477. "8838": [0.19667, 0.69667, 0, 0, 0.89444],
  1478. "8839": [0.19667, 0.69667, 0, 0, 0.89444],
  1479. "8846": [0, 0.55556, 0, 0, 0.76666],
  1480. "8849": [0.19667, 0.69667, 0, 0, 0.89444],
  1481. "8850": [0.19667, 0.69667, 0, 0, 0.89444],
  1482. "8851": [0, 0.55556, 0, 0, 0.76666],
  1483. "8852": [0, 0.55556, 0, 0, 0.76666],
  1484. "8853": [0.13333, 0.63333, 0, 0, 0.89444],
  1485. "8854": [0.13333, 0.63333, 0, 0, 0.89444],
  1486. "8855": [0.13333, 0.63333, 0, 0, 0.89444],
  1487. "8856": [0.13333, 0.63333, 0, 0, 0.89444],
  1488. "8857": [0.13333, 0.63333, 0, 0, 0.89444],
  1489. "8866": [0, 0.69444, 0, 0, 0.70277],
  1490. "8867": [0, 0.69444, 0, 0, 0.70277],
  1491. "8868": [0, 0.69444, 0, 0, 0.89444],
  1492. "8869": [0, 0.69444, 0, 0, 0.89444],
  1493. "8900": [-0.02639, 0.47361, 0, 0, 0.575],
  1494. "8901": [-0.02639, 0.47361, 0, 0, 0.31944],
  1495. "8902": [-0.02778, 0.47222, 0, 0, 0.575],
  1496. "8968": [0.25, 0.75, 0, 0, 0.51111],
  1497. "8969": [0.25, 0.75, 0, 0, 0.51111],
  1498. "8970": [0.25, 0.75, 0, 0, 0.51111],
  1499. "8971": [0.25, 0.75, 0, 0, 0.51111],
  1500. "8994": [-0.13889, 0.36111, 0, 0, 1.14999],
  1501. "8995": [-0.13889, 0.36111, 0, 0, 1.14999],
  1502. "9651": [0.19444, 0.69444, 0, 0, 1.02222],
  1503. "9657": [-0.02778, 0.47222, 0, 0, 0.575],
  1504. "9661": [0.19444, 0.69444, 0, 0, 1.02222],
  1505. "9667": [-0.02778, 0.47222, 0, 0, 0.575],
  1506. "9711": [0.19444, 0.69444, 0, 0, 1.14999],
  1507. "9824": [0.12963, 0.69444, 0, 0, 0.89444],
  1508. "9825": [0.12963, 0.69444, 0, 0, 0.89444],
  1509. "9826": [0.12963, 0.69444, 0, 0, 0.89444],
  1510. "9827": [0.12963, 0.69444, 0, 0, 0.89444],
  1511. "9837": [0, 0.75, 0, 0, 0.44722],
  1512. "9838": [0.19444, 0.69444, 0, 0, 0.44722],
  1513. "9839": [0.19444, 0.69444, 0, 0, 0.44722],
  1514. "10216": [0.25, 0.75, 0, 0, 0.44722],
  1515. "10217": [0.25, 0.75, 0, 0, 0.44722],
  1516. "10815": [0, 0.68611, 0, 0, 0.9],
  1517. "10927": [0.19667, 0.69667, 0, 0, 0.89444],
  1518. "10928": [0.19667, 0.69667, 0, 0, 0.89444],
  1519. "57376": [0.19444, 0.69444, 0, 0, 0]
  1520. },
  1521. "Main-BoldItalic": {
  1522. "32": [0, 0, 0, 0, 0.25],
  1523. "33": [0, 0.69444, 0.11417, 0, 0.38611],
  1524. "34": [0, 0.69444, 0.07939, 0, 0.62055],
  1525. "35": [0.19444, 0.69444, 0.06833, 0, 0.94444],
  1526. "37": [0.05556, 0.75, 0.12861, 0, 0.94444],
  1527. "38": [0, 0.69444, 0.08528, 0, 0.88555],
  1528. "39": [0, 0.69444, 0.12945, 0, 0.35555],
  1529. "40": [0.25, 0.75, 0.15806, 0, 0.47333],
  1530. "41": [0.25, 0.75, 0.03306, 0, 0.47333],
  1531. "42": [0, 0.75, 0.14333, 0, 0.59111],
  1532. "43": [0.10333, 0.60333, 0.03306, 0, 0.88555],
  1533. "44": [0.19444, 0.14722, 0, 0, 0.35555],
  1534. "45": [0, 0.44444, 0.02611, 0, 0.41444],
  1535. "46": [0, 0.14722, 0, 0, 0.35555],
  1536. "47": [0.25, 0.75, 0.15806, 0, 0.59111],
  1537. "48": [0, 0.64444, 0.13167, 0, 0.59111],
  1538. "49": [0, 0.64444, 0.13167, 0, 0.59111],
  1539. "50": [0, 0.64444, 0.13167, 0, 0.59111],
  1540. "51": [0, 0.64444, 0.13167, 0, 0.59111],
  1541. "52": [0.19444, 0.64444, 0.13167, 0, 0.59111],
  1542. "53": [0, 0.64444, 0.13167, 0, 0.59111],
  1543. "54": [0, 0.64444, 0.13167, 0, 0.59111],
  1544. "55": [0.19444, 0.64444, 0.13167, 0, 0.59111],
  1545. "56": [0, 0.64444, 0.13167, 0, 0.59111],
  1546. "57": [0, 0.64444, 0.13167, 0, 0.59111],
  1547. "58": [0, 0.44444, 0.06695, 0, 0.35555],
  1548. "59": [0.19444, 0.44444, 0.06695, 0, 0.35555],
  1549. "61": [-0.10889, 0.39111, 0.06833, 0, 0.88555],
  1550. "63": [0, 0.69444, 0.11472, 0, 0.59111],
  1551. "64": [0, 0.69444, 0.09208, 0, 0.88555],
  1552. "65": [0, 0.68611, 0, 0, 0.86555],
  1553. "66": [0, 0.68611, 0.0992, 0, 0.81666],
  1554. "67": [0, 0.68611, 0.14208, 0, 0.82666],
  1555. "68": [0, 0.68611, 0.09062, 0, 0.87555],
  1556. "69": [0, 0.68611, 0.11431, 0, 0.75666],
  1557. "70": [0, 0.68611, 0.12903, 0, 0.72722],
  1558. "71": [0, 0.68611, 0.07347, 0, 0.89527],
  1559. "72": [0, 0.68611, 0.17208, 0, 0.8961],
  1560. "73": [0, 0.68611, 0.15681, 0, 0.47166],
  1561. "74": [0, 0.68611, 0.145, 0, 0.61055],
  1562. "75": [0, 0.68611, 0.14208, 0, 0.89499],
  1563. "76": [0, 0.68611, 0, 0, 0.69777],
  1564. "77": [0, 0.68611, 0.17208, 0, 1.07277],
  1565. "78": [0, 0.68611, 0.17208, 0, 0.8961],
  1566. "79": [0, 0.68611, 0.09062, 0, 0.85499],
  1567. "80": [0, 0.68611, 0.0992, 0, 0.78721],
  1568. "81": [0.19444, 0.68611, 0.09062, 0, 0.85499],
  1569. "82": [0, 0.68611, 0.02559, 0, 0.85944],
  1570. "83": [0, 0.68611, 0.11264, 0, 0.64999],
  1571. "84": [0, 0.68611, 0.12903, 0, 0.7961],
  1572. "85": [0, 0.68611, 0.17208, 0, 0.88083],
  1573. "86": [0, 0.68611, 0.18625, 0, 0.86555],
  1574. "87": [0, 0.68611, 0.18625, 0, 1.15999],
  1575. "88": [0, 0.68611, 0.15681, 0, 0.86555],
  1576. "89": [0, 0.68611, 0.19803, 0, 0.86555],
  1577. "90": [0, 0.68611, 0.14208, 0, 0.70888],
  1578. "91": [0.25, 0.75, 0.1875, 0, 0.35611],
  1579. "93": [0.25, 0.75, 0.09972, 0, 0.35611],
  1580. "94": [0, 0.69444, 0.06709, 0, 0.59111],
  1581. "95": [0.31, 0.13444, 0.09811, 0, 0.59111],
  1582. "97": [0, 0.44444, 0.09426, 0, 0.59111],
  1583. "98": [0, 0.69444, 0.07861, 0, 0.53222],
  1584. "99": [0, 0.44444, 0.05222, 0, 0.53222],
  1585. "100": [0, 0.69444, 0.10861, 0, 0.59111],
  1586. "101": [0, 0.44444, 0.085, 0, 0.53222],
  1587. "102": [0.19444, 0.69444, 0.21778, 0, 0.4],
  1588. "103": [0.19444, 0.44444, 0.105, 0, 0.53222],
  1589. "104": [0, 0.69444, 0.09426, 0, 0.59111],
  1590. "105": [0, 0.69326, 0.11387, 0, 0.35555],
  1591. "106": [0.19444, 0.69326, 0.1672, 0, 0.35555],
  1592. "107": [0, 0.69444, 0.11111, 0, 0.53222],
  1593. "108": [0, 0.69444, 0.10861, 0, 0.29666],
  1594. "109": [0, 0.44444, 0.09426, 0, 0.94444],
  1595. "110": [0, 0.44444, 0.09426, 0, 0.64999],
  1596. "111": [0, 0.44444, 0.07861, 0, 0.59111],
  1597. "112": [0.19444, 0.44444, 0.07861, 0, 0.59111],
  1598. "113": [0.19444, 0.44444, 0.105, 0, 0.53222],
  1599. "114": [0, 0.44444, 0.11111, 0, 0.50167],
  1600. "115": [0, 0.44444, 0.08167, 0, 0.48694],
  1601. "116": [0, 0.63492, 0.09639, 0, 0.385],
  1602. "117": [0, 0.44444, 0.09426, 0, 0.62055],
  1603. "118": [0, 0.44444, 0.11111, 0, 0.53222],
  1604. "119": [0, 0.44444, 0.11111, 0, 0.76777],
  1605. "120": [0, 0.44444, 0.12583, 0, 0.56055],
  1606. "121": [0.19444, 0.44444, 0.105, 0, 0.56166],
  1607. "122": [0, 0.44444, 0.13889, 0, 0.49055],
  1608. "126": [0.35, 0.34444, 0.11472, 0, 0.59111],
  1609. "160": [0, 0, 0, 0, 0.25],
  1610. "168": [0, 0.69444, 0.11473, 0, 0.59111],
  1611. "176": [0, 0.69444, 0, 0, 0.94888],
  1612. "184": [0.17014, 0, 0, 0, 0.53222],
  1613. "198": [0, 0.68611, 0.11431, 0, 1.02277],
  1614. "216": [0.04861, 0.73472, 0.09062, 0, 0.88555],
  1615. "223": [0.19444, 0.69444, 0.09736, 0, 0.665],
  1616. "230": [0, 0.44444, 0.085, 0, 0.82666],
  1617. "248": [0.09722, 0.54167, 0.09458, 0, 0.59111],
  1618. "305": [0, 0.44444, 0.09426, 0, 0.35555],
  1619. "338": [0, 0.68611, 0.11431, 0, 1.14054],
  1620. "339": [0, 0.44444, 0.085, 0, 0.82666],
  1621. "567": [0.19444, 0.44444, 0.04611, 0, 0.385],
  1622. "710": [0, 0.69444, 0.06709, 0, 0.59111],
  1623. "711": [0, 0.63194, 0.08271, 0, 0.59111],
  1624. "713": [0, 0.59444, 0.10444, 0, 0.59111],
  1625. "714": [0, 0.69444, 0.08528, 0, 0.59111],
  1626. "715": [0, 0.69444, 0, 0, 0.59111],
  1627. "728": [0, 0.69444, 0.10333, 0, 0.59111],
  1628. "729": [0, 0.69444, 0.12945, 0, 0.35555],
  1629. "730": [0, 0.69444, 0, 0, 0.94888],
  1630. "732": [0, 0.69444, 0.11472, 0, 0.59111],
  1631. "733": [0, 0.69444, 0.11472, 0, 0.59111],
  1632. "915": [0, 0.68611, 0.12903, 0, 0.69777],
  1633. "916": [0, 0.68611, 0, 0, 0.94444],
  1634. "920": [0, 0.68611, 0.09062, 0, 0.88555],
  1635. "923": [0, 0.68611, 0, 0, 0.80666],
  1636. "926": [0, 0.68611, 0.15092, 0, 0.76777],
  1637. "928": [0, 0.68611, 0.17208, 0, 0.8961],
  1638. "931": [0, 0.68611, 0.11431, 0, 0.82666],
  1639. "933": [0, 0.68611, 0.10778, 0, 0.88555],
  1640. "934": [0, 0.68611, 0.05632, 0, 0.82666],
  1641. "936": [0, 0.68611, 0.10778, 0, 0.88555],
  1642. "937": [0, 0.68611, 0.0992, 0, 0.82666],
  1643. "8211": [0, 0.44444, 0.09811, 0, 0.59111],
  1644. "8212": [0, 0.44444, 0.09811, 0, 1.18221],
  1645. "8216": [0, 0.69444, 0.12945, 0, 0.35555],
  1646. "8217": [0, 0.69444, 0.12945, 0, 0.35555],
  1647. "8220": [0, 0.69444, 0.16772, 0, 0.62055],
  1648. "8221": [0, 0.69444, 0.07939, 0, 0.62055]
  1649. },
  1650. "Main-Italic": {
  1651. "32": [0, 0, 0, 0, 0.25],
  1652. "33": [0, 0.69444, 0.12417, 0, 0.30667],
  1653. "34": [0, 0.69444, 0.06961, 0, 0.51444],
  1654. "35": [0.19444, 0.69444, 0.06616, 0, 0.81777],
  1655. "37": [0.05556, 0.75, 0.13639, 0, 0.81777],
  1656. "38": [0, 0.69444, 0.09694, 0, 0.76666],
  1657. "39": [0, 0.69444, 0.12417, 0, 0.30667],
  1658. "40": [0.25, 0.75, 0.16194, 0, 0.40889],
  1659. "41": [0.25, 0.75, 0.03694, 0, 0.40889],
  1660. "42": [0, 0.75, 0.14917, 0, 0.51111],
  1661. "43": [0.05667, 0.56167, 0.03694, 0, 0.76666],
  1662. "44": [0.19444, 0.10556, 0, 0, 0.30667],
  1663. "45": [0, 0.43056, 0.02826, 0, 0.35778],
  1664. "46": [0, 0.10556, 0, 0, 0.30667],
  1665. "47": [0.25, 0.75, 0.16194, 0, 0.51111],
  1666. "48": [0, 0.64444, 0.13556, 0, 0.51111],
  1667. "49": [0, 0.64444, 0.13556, 0, 0.51111],
  1668. "50": [0, 0.64444, 0.13556, 0, 0.51111],
  1669. "51": [0, 0.64444, 0.13556, 0, 0.51111],
  1670. "52": [0.19444, 0.64444, 0.13556, 0, 0.51111],
  1671. "53": [0, 0.64444, 0.13556, 0, 0.51111],
  1672. "54": [0, 0.64444, 0.13556, 0, 0.51111],
  1673. "55": [0.19444, 0.64444, 0.13556, 0, 0.51111],
  1674. "56": [0, 0.64444, 0.13556, 0, 0.51111],
  1675. "57": [0, 0.64444, 0.13556, 0, 0.51111],
  1676. "58": [0, 0.43056, 0.0582, 0, 0.30667],
  1677. "59": [0.19444, 0.43056, 0.0582, 0, 0.30667],
  1678. "61": [-0.13313, 0.36687, 0.06616, 0, 0.76666],
  1679. "63": [0, 0.69444, 0.1225, 0, 0.51111],
  1680. "64": [0, 0.69444, 0.09597, 0, 0.76666],
  1681. "65": [0, 0.68333, 0, 0, 0.74333],
  1682. "66": [0, 0.68333, 0.10257, 0, 0.70389],
  1683. "67": [0, 0.68333, 0.14528, 0, 0.71555],
  1684. "68": [0, 0.68333, 0.09403, 0, 0.755],
  1685. "69": [0, 0.68333, 0.12028, 0, 0.67833],
  1686. "70": [0, 0.68333, 0.13305, 0, 0.65277],
  1687. "71": [0, 0.68333, 0.08722, 0, 0.77361],
  1688. "72": [0, 0.68333, 0.16389, 0, 0.74333],
  1689. "73": [0, 0.68333, 0.15806, 0, 0.38555],
  1690. "74": [0, 0.68333, 0.14028, 0, 0.525],
  1691. "75": [0, 0.68333, 0.14528, 0, 0.76888],
  1692. "76": [0, 0.68333, 0, 0, 0.62722],
  1693. "77": [0, 0.68333, 0.16389, 0, 0.89666],
  1694. "78": [0, 0.68333, 0.16389, 0, 0.74333],
  1695. "79": [0, 0.68333, 0.09403, 0, 0.76666],
  1696. "80": [0, 0.68333, 0.10257, 0, 0.67833],
  1697. "81": [0.19444, 0.68333, 0.09403, 0, 0.76666],
  1698. "82": [0, 0.68333, 0.03868, 0, 0.72944],
  1699. "83": [0, 0.68333, 0.11972, 0, 0.56222],
  1700. "84": [0, 0.68333, 0.13305, 0, 0.71555],
  1701. "85": [0, 0.68333, 0.16389, 0, 0.74333],
  1702. "86": [0, 0.68333, 0.18361, 0, 0.74333],
  1703. "87": [0, 0.68333, 0.18361, 0, 0.99888],
  1704. "88": [0, 0.68333, 0.15806, 0, 0.74333],
  1705. "89": [0, 0.68333, 0.19383, 0, 0.74333],
  1706. "90": [0, 0.68333, 0.14528, 0, 0.61333],
  1707. "91": [0.25, 0.75, 0.1875, 0, 0.30667],
  1708. "93": [0.25, 0.75, 0.10528, 0, 0.30667],
  1709. "94": [0, 0.69444, 0.06646, 0, 0.51111],
  1710. "95": [0.31, 0.12056, 0.09208, 0, 0.51111],
  1711. "97": [0, 0.43056, 0.07671, 0, 0.51111],
  1712. "98": [0, 0.69444, 0.06312, 0, 0.46],
  1713. "99": [0, 0.43056, 0.05653, 0, 0.46],
  1714. "100": [0, 0.69444, 0.10333, 0, 0.51111],
  1715. "101": [0, 0.43056, 0.07514, 0, 0.46],
  1716. "102": [0.19444, 0.69444, 0.21194, 0, 0.30667],
  1717. "103": [0.19444, 0.43056, 0.08847, 0, 0.46],
  1718. "104": [0, 0.69444, 0.07671, 0, 0.51111],
  1719. "105": [0, 0.65536, 0.1019, 0, 0.30667],
  1720. "106": [0.19444, 0.65536, 0.14467, 0, 0.30667],
  1721. "107": [0, 0.69444, 0.10764, 0, 0.46],
  1722. "108": [0, 0.69444, 0.10333, 0, 0.25555],
  1723. "109": [0, 0.43056, 0.07671, 0, 0.81777],
  1724. "110": [0, 0.43056, 0.07671, 0, 0.56222],
  1725. "111": [0, 0.43056, 0.06312, 0, 0.51111],
  1726. "112": [0.19444, 0.43056, 0.06312, 0, 0.51111],
  1727. "113": [0.19444, 0.43056, 0.08847, 0, 0.46],
  1728. "114": [0, 0.43056, 0.10764, 0, 0.42166],
  1729. "115": [0, 0.43056, 0.08208, 0, 0.40889],
  1730. "116": [0, 0.61508, 0.09486, 0, 0.33222],
  1731. "117": [0, 0.43056, 0.07671, 0, 0.53666],
  1732. "118": [0, 0.43056, 0.10764, 0, 0.46],
  1733. "119": [0, 0.43056, 0.10764, 0, 0.66444],
  1734. "120": [0, 0.43056, 0.12042, 0, 0.46389],
  1735. "121": [0.19444, 0.43056, 0.08847, 0, 0.48555],
  1736. "122": [0, 0.43056, 0.12292, 0, 0.40889],
  1737. "126": [0.35, 0.31786, 0.11585, 0, 0.51111],
  1738. "160": [0, 0, 0, 0, 0.25],
  1739. "168": [0, 0.66786, 0.10474, 0, 0.51111],
  1740. "176": [0, 0.69444, 0, 0, 0.83129],
  1741. "184": [0.17014, 0, 0, 0, 0.46],
  1742. "198": [0, 0.68333, 0.12028, 0, 0.88277],
  1743. "216": [0.04861, 0.73194, 0.09403, 0, 0.76666],
  1744. "223": [0.19444, 0.69444, 0.10514, 0, 0.53666],
  1745. "230": [0, 0.43056, 0.07514, 0, 0.71555],
  1746. "248": [0.09722, 0.52778, 0.09194, 0, 0.51111],
  1747. "338": [0, 0.68333, 0.12028, 0, 0.98499],
  1748. "339": [0, 0.43056, 0.07514, 0, 0.71555],
  1749. "710": [0, 0.69444, 0.06646, 0, 0.51111],
  1750. "711": [0, 0.62847, 0.08295, 0, 0.51111],
  1751. "713": [0, 0.56167, 0.10333, 0, 0.51111],
  1752. "714": [0, 0.69444, 0.09694, 0, 0.51111],
  1753. "715": [0, 0.69444, 0, 0, 0.51111],
  1754. "728": [0, 0.69444, 0.10806, 0, 0.51111],
  1755. "729": [0, 0.66786, 0.11752, 0, 0.30667],
  1756. "730": [0, 0.69444, 0, 0, 0.83129],
  1757. "732": [0, 0.66786, 0.11585, 0, 0.51111],
  1758. "733": [0, 0.69444, 0.1225, 0, 0.51111],
  1759. "915": [0, 0.68333, 0.13305, 0, 0.62722],
  1760. "916": [0, 0.68333, 0, 0, 0.81777],
  1761. "920": [0, 0.68333, 0.09403, 0, 0.76666],
  1762. "923": [0, 0.68333, 0, 0, 0.69222],
  1763. "926": [0, 0.68333, 0.15294, 0, 0.66444],
  1764. "928": [0, 0.68333, 0.16389, 0, 0.74333],
  1765. "931": [0, 0.68333, 0.12028, 0, 0.71555],
  1766. "933": [0, 0.68333, 0.11111, 0, 0.76666],
  1767. "934": [0, 0.68333, 0.05986, 0, 0.71555],
  1768. "936": [0, 0.68333, 0.11111, 0, 0.76666],
  1769. "937": [0, 0.68333, 0.10257, 0, 0.71555],
  1770. "8211": [0, 0.43056, 0.09208, 0, 0.51111],
  1771. "8212": [0, 0.43056, 0.09208, 0, 1.02222],
  1772. "8216": [0, 0.69444, 0.12417, 0, 0.30667],
  1773. "8217": [0, 0.69444, 0.12417, 0, 0.30667],
  1774. "8220": [0, 0.69444, 0.1685, 0, 0.51444],
  1775. "8221": [0, 0.69444, 0.06961, 0, 0.51444],
  1776. "8463": [0, 0.68889, 0, 0, 0.54028]
  1777. },
  1778. "Main-Regular": {
  1779. "32": [0, 0, 0, 0, 0.25],
  1780. "33": [0, 0.69444, 0, 0, 0.27778],
  1781. "34": [0, 0.69444, 0, 0, 0.5],
  1782. "35": [0.19444, 0.69444, 0, 0, 0.83334],
  1783. "36": [0.05556, 0.75, 0, 0, 0.5],
  1784. "37": [0.05556, 0.75, 0, 0, 0.83334],
  1785. "38": [0, 0.69444, 0, 0, 0.77778],
  1786. "39": [0, 0.69444, 0, 0, 0.27778],
  1787. "40": [0.25, 0.75, 0, 0, 0.38889],
  1788. "41": [0.25, 0.75, 0, 0, 0.38889],
  1789. "42": [0, 0.75, 0, 0, 0.5],
  1790. "43": [0.08333, 0.58333, 0, 0, 0.77778],
  1791. "44": [0.19444, 0.10556, 0, 0, 0.27778],
  1792. "45": [0, 0.43056, 0, 0, 0.33333],
  1793. "46": [0, 0.10556, 0, 0, 0.27778],
  1794. "47": [0.25, 0.75, 0, 0, 0.5],
  1795. "48": [0, 0.64444, 0, 0, 0.5],
  1796. "49": [0, 0.64444, 0, 0, 0.5],
  1797. "50": [0, 0.64444, 0, 0, 0.5],
  1798. "51": [0, 0.64444, 0, 0, 0.5],
  1799. "52": [0, 0.64444, 0, 0, 0.5],
  1800. "53": [0, 0.64444, 0, 0, 0.5],
  1801. "54": [0, 0.64444, 0, 0, 0.5],
  1802. "55": [0, 0.64444, 0, 0, 0.5],
  1803. "56": [0, 0.64444, 0, 0, 0.5],
  1804. "57": [0, 0.64444, 0, 0, 0.5],
  1805. "58": [0, 0.43056, 0, 0, 0.27778],
  1806. "59": [0.19444, 0.43056, 0, 0, 0.27778],
  1807. "60": [0.0391, 0.5391, 0, 0, 0.77778],
  1808. "61": [-0.13313, 0.36687, 0, 0, 0.77778],
  1809. "62": [0.0391, 0.5391, 0, 0, 0.77778],
  1810. "63": [0, 0.69444, 0, 0, 0.47222],
  1811. "64": [0, 0.69444, 0, 0, 0.77778],
  1812. "65": [0, 0.68333, 0, 0, 0.75],
  1813. "66": [0, 0.68333, 0, 0, 0.70834],
  1814. "67": [0, 0.68333, 0, 0, 0.72222],
  1815. "68": [0, 0.68333, 0, 0, 0.76389],
  1816. "69": [0, 0.68333, 0, 0, 0.68056],
  1817. "70": [0, 0.68333, 0, 0, 0.65278],
  1818. "71": [0, 0.68333, 0, 0, 0.78472],
  1819. "72": [0, 0.68333, 0, 0, 0.75],
  1820. "73": [0, 0.68333, 0, 0, 0.36111],
  1821. "74": [0, 0.68333, 0, 0, 0.51389],
  1822. "75": [0, 0.68333, 0, 0, 0.77778],
  1823. "76": [0, 0.68333, 0, 0, 0.625],
  1824. "77": [0, 0.68333, 0, 0, 0.91667],
  1825. "78": [0, 0.68333, 0, 0, 0.75],
  1826. "79": [0, 0.68333, 0, 0, 0.77778],
  1827. "80": [0, 0.68333, 0, 0, 0.68056],
  1828. "81": [0.19444, 0.68333, 0, 0, 0.77778],
  1829. "82": [0, 0.68333, 0, 0, 0.73611],
  1830. "83": [0, 0.68333, 0, 0, 0.55556],
  1831. "84": [0, 0.68333, 0, 0, 0.72222],
  1832. "85": [0, 0.68333, 0, 0, 0.75],
  1833. "86": [0, 0.68333, 0.01389, 0, 0.75],
  1834. "87": [0, 0.68333, 0.01389, 0, 1.02778],
  1835. "88": [0, 0.68333, 0, 0, 0.75],
  1836. "89": [0, 0.68333, 0.025, 0, 0.75],
  1837. "90": [0, 0.68333, 0, 0, 0.61111],
  1838. "91": [0.25, 0.75, 0, 0, 0.27778],
  1839. "92": [0.25, 0.75, 0, 0, 0.5],
  1840. "93": [0.25, 0.75, 0, 0, 0.27778],
  1841. "94": [0, 0.69444, 0, 0, 0.5],
  1842. "95": [0.31, 0.12056, 0.02778, 0, 0.5],
  1843. "97": [0, 0.43056, 0, 0, 0.5],
  1844. "98": [0, 0.69444, 0, 0, 0.55556],
  1845. "99": [0, 0.43056, 0, 0, 0.44445],
  1846. "100": [0, 0.69444, 0, 0, 0.55556],
  1847. "101": [0, 0.43056, 0, 0, 0.44445],
  1848. "102": [0, 0.69444, 0.07778, 0, 0.30556],
  1849. "103": [0.19444, 0.43056, 0.01389, 0, 0.5],
  1850. "104": [0, 0.69444, 0, 0, 0.55556],
  1851. "105": [0, 0.66786, 0, 0, 0.27778],
  1852. "106": [0.19444, 0.66786, 0, 0, 0.30556],
  1853. "107": [0, 0.69444, 0, 0, 0.52778],
  1854. "108": [0, 0.69444, 0, 0, 0.27778],
  1855. "109": [0, 0.43056, 0, 0, 0.83334],
  1856. "110": [0, 0.43056, 0, 0, 0.55556],
  1857. "111": [0, 0.43056, 0, 0, 0.5],
  1858. "112": [0.19444, 0.43056, 0, 0, 0.55556],
  1859. "113": [0.19444, 0.43056, 0, 0, 0.52778],
  1860. "114": [0, 0.43056, 0, 0, 0.39167],
  1861. "115": [0, 0.43056, 0, 0, 0.39445],
  1862. "116": [0, 0.61508, 0, 0, 0.38889],
  1863. "117": [0, 0.43056, 0, 0, 0.55556],
  1864. "118": [0, 0.43056, 0.01389, 0, 0.52778],
  1865. "119": [0, 0.43056, 0.01389, 0, 0.72222],
  1866. "120": [0, 0.43056, 0, 0, 0.52778],
  1867. "121": [0.19444, 0.43056, 0.01389, 0, 0.52778],
  1868. "122": [0, 0.43056, 0, 0, 0.44445],
  1869. "123": [0.25, 0.75, 0, 0, 0.5],
  1870. "124": [0.25, 0.75, 0, 0, 0.27778],
  1871. "125": [0.25, 0.75, 0, 0, 0.5],
  1872. "126": [0.35, 0.31786, 0, 0, 0.5],
  1873. "160": [0, 0, 0, 0, 0.25],
  1874. "163": [0, 0.69444, 0, 0, 0.76909],
  1875. "167": [0.19444, 0.69444, 0, 0, 0.44445],
  1876. "168": [0, 0.66786, 0, 0, 0.5],
  1877. "172": [0, 0.43056, 0, 0, 0.66667],
  1878. "176": [0, 0.69444, 0, 0, 0.75],
  1879. "177": [0.08333, 0.58333, 0, 0, 0.77778],
  1880. "182": [0.19444, 0.69444, 0, 0, 0.61111],
  1881. "184": [0.17014, 0, 0, 0, 0.44445],
  1882. "198": [0, 0.68333, 0, 0, 0.90278],
  1883. "215": [0.08333, 0.58333, 0, 0, 0.77778],
  1884. "216": [0.04861, 0.73194, 0, 0, 0.77778],
  1885. "223": [0, 0.69444, 0, 0, 0.5],
  1886. "230": [0, 0.43056, 0, 0, 0.72222],
  1887. "247": [0.08333, 0.58333, 0, 0, 0.77778],
  1888. "248": [0.09722, 0.52778, 0, 0, 0.5],
  1889. "305": [0, 0.43056, 0, 0, 0.27778],
  1890. "338": [0, 0.68333, 0, 0, 1.01389],
  1891. "339": [0, 0.43056, 0, 0, 0.77778],
  1892. "567": [0.19444, 0.43056, 0, 0, 0.30556],
  1893. "710": [0, 0.69444, 0, 0, 0.5],
  1894. "711": [0, 0.62847, 0, 0, 0.5],
  1895. "713": [0, 0.56778, 0, 0, 0.5],
  1896. "714": [0, 0.69444, 0, 0, 0.5],
  1897. "715": [0, 0.69444, 0, 0, 0.5],
  1898. "728": [0, 0.69444, 0, 0, 0.5],
  1899. "729": [0, 0.66786, 0, 0, 0.27778],
  1900. "730": [0, 0.69444, 0, 0, 0.75],
  1901. "732": [0, 0.66786, 0, 0, 0.5],
  1902. "733": [0, 0.69444, 0, 0, 0.5],
  1903. "915": [0, 0.68333, 0, 0, 0.625],
  1904. "916": [0, 0.68333, 0, 0, 0.83334],
  1905. "920": [0, 0.68333, 0, 0, 0.77778],
  1906. "923": [0, 0.68333, 0, 0, 0.69445],
  1907. "926": [0, 0.68333, 0, 0, 0.66667],
  1908. "928": [0, 0.68333, 0, 0, 0.75],
  1909. "931": [0, 0.68333, 0, 0, 0.72222],
  1910. "933": [0, 0.68333, 0, 0, 0.77778],
  1911. "934": [0, 0.68333, 0, 0, 0.72222],
  1912. "936": [0, 0.68333, 0, 0, 0.77778],
  1913. "937": [0, 0.68333, 0, 0, 0.72222],
  1914. "8211": [0, 0.43056, 0.02778, 0, 0.5],
  1915. "8212": [0, 0.43056, 0.02778, 0, 1.0],
  1916. "8216": [0, 0.69444, 0, 0, 0.27778],
  1917. "8217": [0, 0.69444, 0, 0, 0.27778],
  1918. "8220": [0, 0.69444, 0, 0, 0.5],
  1919. "8221": [0, 0.69444, 0, 0, 0.5],
  1920. "8224": [0.19444, 0.69444, 0, 0, 0.44445],
  1921. "8225": [0.19444, 0.69444, 0, 0, 0.44445],
  1922. "8230": [0, 0.123, 0, 0, 1.172],
  1923. "8242": [0, 0.55556, 0, 0, 0.275],
  1924. "8407": [0, 0.71444, 0.15382, 0, 0.5],
  1925. "8463": [0, 0.68889, 0, 0, 0.54028],
  1926. "8465": [0, 0.69444, 0, 0, 0.72222],
  1927. "8467": [0, 0.69444, 0, 0.11111, 0.41667],
  1928. "8472": [0.19444, 0.43056, 0, 0.11111, 0.63646],
  1929. "8476": [0, 0.69444, 0, 0, 0.72222],
  1930. "8501": [0, 0.69444, 0, 0, 0.61111],
  1931. "8592": [-0.13313, 0.36687, 0, 0, 1.0],
  1932. "8593": [0.19444, 0.69444, 0, 0, 0.5],
  1933. "8594": [-0.13313, 0.36687, 0, 0, 1.0],
  1934. "8595": [0.19444, 0.69444, 0, 0, 0.5],
  1935. "8596": [-0.13313, 0.36687, 0, 0, 1.0],
  1936. "8597": [0.25, 0.75, 0, 0, 0.5],
  1937. "8598": [0.19444, 0.69444, 0, 0, 1.0],
  1938. "8599": [0.19444, 0.69444, 0, 0, 1.0],
  1939. "8600": [0.19444, 0.69444, 0, 0, 1.0],
  1940. "8601": [0.19444, 0.69444, 0, 0, 1.0],
  1941. "8614": [0.011, 0.511, 0, 0, 1.0],
  1942. "8617": [0.011, 0.511, 0, 0, 1.126],
  1943. "8618": [0.011, 0.511, 0, 0, 1.126],
  1944. "8636": [-0.13313, 0.36687, 0, 0, 1.0],
  1945. "8637": [-0.13313, 0.36687, 0, 0, 1.0],
  1946. "8640": [-0.13313, 0.36687, 0, 0, 1.0],
  1947. "8641": [-0.13313, 0.36687, 0, 0, 1.0],
  1948. "8652": [0.011, 0.671, 0, 0, 1.0],
  1949. "8656": [-0.13313, 0.36687, 0, 0, 1.0],
  1950. "8657": [0.19444, 0.69444, 0, 0, 0.61111],
  1951. "8658": [-0.13313, 0.36687, 0, 0, 1.0],
  1952. "8659": [0.19444, 0.69444, 0, 0, 0.61111],
  1953. "8660": [-0.13313, 0.36687, 0, 0, 1.0],
  1954. "8661": [0.25, 0.75, 0, 0, 0.61111],
  1955. "8704": [0, 0.69444, 0, 0, 0.55556],
  1956. "8706": [0, 0.69444, 0.05556, 0.08334, 0.5309],
  1957. "8707": [0, 0.69444, 0, 0, 0.55556],
  1958. "8709": [0.05556, 0.75, 0, 0, 0.5],
  1959. "8711": [0, 0.68333, 0, 0, 0.83334],
  1960. "8712": [0.0391, 0.5391, 0, 0, 0.66667],
  1961. "8715": [0.0391, 0.5391, 0, 0, 0.66667],
  1962. "8722": [0.08333, 0.58333, 0, 0, 0.77778],
  1963. "8723": [0.08333, 0.58333, 0, 0, 0.77778],
  1964. "8725": [0.25, 0.75, 0, 0, 0.5],
  1965. "8726": [0.25, 0.75, 0, 0, 0.5],
  1966. "8727": [-0.03472, 0.46528, 0, 0, 0.5],
  1967. "8728": [-0.05555, 0.44445, 0, 0, 0.5],
  1968. "8729": [-0.05555, 0.44445, 0, 0, 0.5],
  1969. "8730": [0.2, 0.8, 0, 0, 0.83334],
  1970. "8733": [0, 0.43056, 0, 0, 0.77778],
  1971. "8734": [0, 0.43056, 0, 0, 1.0],
  1972. "8736": [0, 0.69224, 0, 0, 0.72222],
  1973. "8739": [0.25, 0.75, 0, 0, 0.27778],
  1974. "8741": [0.25, 0.75, 0, 0, 0.5],
  1975. "8743": [0, 0.55556, 0, 0, 0.66667],
  1976. "8744": [0, 0.55556, 0, 0, 0.66667],
  1977. "8745": [0, 0.55556, 0, 0, 0.66667],
  1978. "8746": [0, 0.55556, 0, 0, 0.66667],
  1979. "8747": [0.19444, 0.69444, 0.11111, 0, 0.41667],
  1980. "8764": [-0.13313, 0.36687, 0, 0, 0.77778],
  1981. "8768": [0.19444, 0.69444, 0, 0, 0.27778],
  1982. "8771": [-0.03625, 0.46375, 0, 0, 0.77778],
  1983. "8773": [-0.022, 0.589, 0, 0, 0.778],
  1984. "8776": [-0.01688, 0.48312, 0, 0, 0.77778],
  1985. "8781": [-0.03625, 0.46375, 0, 0, 0.77778],
  1986. "8784": [-0.133, 0.673, 0, 0, 0.778],
  1987. "8801": [-0.03625, 0.46375, 0, 0, 0.77778],
  1988. "8804": [0.13597, 0.63597, 0, 0, 0.77778],
  1989. "8805": [0.13597, 0.63597, 0, 0, 0.77778],
  1990. "8810": [0.0391, 0.5391, 0, 0, 1.0],
  1991. "8811": [0.0391, 0.5391, 0, 0, 1.0],
  1992. "8826": [0.0391, 0.5391, 0, 0, 0.77778],
  1993. "8827": [0.0391, 0.5391, 0, 0, 0.77778],
  1994. "8834": [0.0391, 0.5391, 0, 0, 0.77778],
  1995. "8835": [0.0391, 0.5391, 0, 0, 0.77778],
  1996. "8838": [0.13597, 0.63597, 0, 0, 0.77778],
  1997. "8839": [0.13597, 0.63597, 0, 0, 0.77778],
  1998. "8846": [0, 0.55556, 0, 0, 0.66667],
  1999. "8849": [0.13597, 0.63597, 0, 0, 0.77778],
  2000. "8850": [0.13597, 0.63597, 0, 0, 0.77778],
  2001. "8851": [0, 0.55556, 0, 0, 0.66667],
  2002. "8852": [0, 0.55556, 0, 0, 0.66667],
  2003. "8853": [0.08333, 0.58333, 0, 0, 0.77778],
  2004. "8854": [0.08333, 0.58333, 0, 0, 0.77778],
  2005. "8855": [0.08333, 0.58333, 0, 0, 0.77778],
  2006. "8856": [0.08333, 0.58333, 0, 0, 0.77778],
  2007. "8857": [0.08333, 0.58333, 0, 0, 0.77778],
  2008. "8866": [0, 0.69444, 0, 0, 0.61111],
  2009. "8867": [0, 0.69444, 0, 0, 0.61111],
  2010. "8868": [0, 0.69444, 0, 0, 0.77778],
  2011. "8869": [0, 0.69444, 0, 0, 0.77778],
  2012. "8872": [0.249, 0.75, 0, 0, 0.867],
  2013. "8900": [-0.05555, 0.44445, 0, 0, 0.5],
  2014. "8901": [-0.05555, 0.44445, 0, 0, 0.27778],
  2015. "8902": [-0.03472, 0.46528, 0, 0, 0.5],
  2016. "8904": [0.005, 0.505, 0, 0, 0.9],
  2017. "8942": [0.03, 0.903, 0, 0, 0.278],
  2018. "8943": [-0.19, 0.313, 0, 0, 1.172],
  2019. "8945": [-0.1, 0.823, 0, 0, 1.282],
  2020. "8968": [0.25, 0.75, 0, 0, 0.44445],
  2021. "8969": [0.25, 0.75, 0, 0, 0.44445],
  2022. "8970": [0.25, 0.75, 0, 0, 0.44445],
  2023. "8971": [0.25, 0.75, 0, 0, 0.44445],
  2024. "8994": [-0.14236, 0.35764, 0, 0, 1.0],
  2025. "8995": [-0.14236, 0.35764, 0, 0, 1.0],
  2026. "9136": [0.244, 0.744, 0, 0, 0.412],
  2027. "9137": [0.244, 0.745, 0, 0, 0.412],
  2028. "9651": [0.19444, 0.69444, 0, 0, 0.88889],
  2029. "9657": [-0.03472, 0.46528, 0, 0, 0.5],
  2030. "9661": [0.19444, 0.69444, 0, 0, 0.88889],
  2031. "9667": [-0.03472, 0.46528, 0, 0, 0.5],
  2032. "9711": [0.19444, 0.69444, 0, 0, 1.0],
  2033. "9824": [0.12963, 0.69444, 0, 0, 0.77778],
  2034. "9825": [0.12963, 0.69444, 0, 0, 0.77778],
  2035. "9826": [0.12963, 0.69444, 0, 0, 0.77778],
  2036. "9827": [0.12963, 0.69444, 0, 0, 0.77778],
  2037. "9837": [0, 0.75, 0, 0, 0.38889],
  2038. "9838": [0.19444, 0.69444, 0, 0, 0.38889],
  2039. "9839": [0.19444, 0.69444, 0, 0, 0.38889],
  2040. "10216": [0.25, 0.75, 0, 0, 0.38889],
  2041. "10217": [0.25, 0.75, 0, 0, 0.38889],
  2042. "10222": [0.244, 0.744, 0, 0, 0.412],
  2043. "10223": [0.244, 0.745, 0, 0, 0.412],
  2044. "10229": [0.011, 0.511, 0, 0, 1.609],
  2045. "10230": [0.011, 0.511, 0, 0, 1.638],
  2046. "10231": [0.011, 0.511, 0, 0, 1.859],
  2047. "10232": [0.024, 0.525, 0, 0, 1.609],
  2048. "10233": [0.024, 0.525, 0, 0, 1.638],
  2049. "10234": [0.024, 0.525, 0, 0, 1.858],
  2050. "10236": [0.011, 0.511, 0, 0, 1.638],
  2051. "10815": [0, 0.68333, 0, 0, 0.75],
  2052. "10927": [0.13597, 0.63597, 0, 0, 0.77778],
  2053. "10928": [0.13597, 0.63597, 0, 0, 0.77778],
  2054. "57376": [0.19444, 0.69444, 0, 0, 0]
  2055. },
  2056. "Math-BoldItalic": {
  2057. "32": [0, 0, 0, 0, 0.25],
  2058. "48": [0, 0.44444, 0, 0, 0.575],
  2059. "49": [0, 0.44444, 0, 0, 0.575],
  2060. "50": [0, 0.44444, 0, 0, 0.575],
  2061. "51": [0.19444, 0.44444, 0, 0, 0.575],
  2062. "52": [0.19444, 0.44444, 0, 0, 0.575],
  2063. "53": [0.19444, 0.44444, 0, 0, 0.575],
  2064. "54": [0, 0.64444, 0, 0, 0.575],
  2065. "55": [0.19444, 0.44444, 0, 0, 0.575],
  2066. "56": [0, 0.64444, 0, 0, 0.575],
  2067. "57": [0.19444, 0.44444, 0, 0, 0.575],
  2068. "65": [0, 0.68611, 0, 0, 0.86944],
  2069. "66": [0, 0.68611, 0.04835, 0, 0.8664],
  2070. "67": [0, 0.68611, 0.06979, 0, 0.81694],
  2071. "68": [0, 0.68611, 0.03194, 0, 0.93812],
  2072. "69": [0, 0.68611, 0.05451, 0, 0.81007],
  2073. "70": [0, 0.68611, 0.15972, 0, 0.68889],
  2074. "71": [0, 0.68611, 0, 0, 0.88673],
  2075. "72": [0, 0.68611, 0.08229, 0, 0.98229],
  2076. "73": [0, 0.68611, 0.07778, 0, 0.51111],
  2077. "74": [0, 0.68611, 0.10069, 0, 0.63125],
  2078. "75": [0, 0.68611, 0.06979, 0, 0.97118],
  2079. "76": [0, 0.68611, 0, 0, 0.75555],
  2080. "77": [0, 0.68611, 0.11424, 0, 1.14201],
  2081. "78": [0, 0.68611, 0.11424, 0, 0.95034],
  2082. "79": [0, 0.68611, 0.03194, 0, 0.83666],
  2083. "80": [0, 0.68611, 0.15972, 0, 0.72309],
  2084. "81": [0.19444, 0.68611, 0, 0, 0.86861],
  2085. "82": [0, 0.68611, 0.00421, 0, 0.87235],
  2086. "83": [0, 0.68611, 0.05382, 0, 0.69271],
  2087. "84": [0, 0.68611, 0.15972, 0, 0.63663],
  2088. "85": [0, 0.68611, 0.11424, 0, 0.80027],
  2089. "86": [0, 0.68611, 0.25555, 0, 0.67778],
  2090. "87": [0, 0.68611, 0.15972, 0, 1.09305],
  2091. "88": [0, 0.68611, 0.07778, 0, 0.94722],
  2092. "89": [0, 0.68611, 0.25555, 0, 0.67458],
  2093. "90": [0, 0.68611, 0.06979, 0, 0.77257],
  2094. "97": [0, 0.44444, 0, 0, 0.63287],
  2095. "98": [0, 0.69444, 0, 0, 0.52083],
  2096. "99": [0, 0.44444, 0, 0, 0.51342],
  2097. "100": [0, 0.69444, 0, 0, 0.60972],
  2098. "101": [0, 0.44444, 0, 0, 0.55361],
  2099. "102": [0.19444, 0.69444, 0.11042, 0, 0.56806],
  2100. "103": [0.19444, 0.44444, 0.03704, 0, 0.5449],
  2101. "104": [0, 0.69444, 0, 0, 0.66759],
  2102. "105": [0, 0.69326, 0, 0, 0.4048],
  2103. "106": [0.19444, 0.69326, 0.0622, 0, 0.47083],
  2104. "107": [0, 0.69444, 0.01852, 0, 0.6037],
  2105. "108": [0, 0.69444, 0.0088, 0, 0.34815],
  2106. "109": [0, 0.44444, 0, 0, 1.0324],
  2107. "110": [0, 0.44444, 0, 0, 0.71296],
  2108. "111": [0, 0.44444, 0, 0, 0.58472],
  2109. "112": [0.19444, 0.44444, 0, 0, 0.60092],
  2110. "113": [0.19444, 0.44444, 0.03704, 0, 0.54213],
  2111. "114": [0, 0.44444, 0.03194, 0, 0.5287],
  2112. "115": [0, 0.44444, 0, 0, 0.53125],
  2113. "116": [0, 0.63492, 0, 0, 0.41528],
  2114. "117": [0, 0.44444, 0, 0, 0.68102],
  2115. "118": [0, 0.44444, 0.03704, 0, 0.56666],
  2116. "119": [0, 0.44444, 0.02778, 0, 0.83148],
  2117. "120": [0, 0.44444, 0, 0, 0.65903],
  2118. "121": [0.19444, 0.44444, 0.03704, 0, 0.59028],
  2119. "122": [0, 0.44444, 0.04213, 0, 0.55509],
  2120. "160": [0, 0, 0, 0, 0.25],
  2121. "915": [0, 0.68611, 0.15972, 0, 0.65694],
  2122. "916": [0, 0.68611, 0, 0, 0.95833],
  2123. "920": [0, 0.68611, 0.03194, 0, 0.86722],
  2124. "923": [0, 0.68611, 0, 0, 0.80555],
  2125. "926": [0, 0.68611, 0.07458, 0, 0.84125],
  2126. "928": [0, 0.68611, 0.08229, 0, 0.98229],
  2127. "931": [0, 0.68611, 0.05451, 0, 0.88507],
  2128. "933": [0, 0.68611, 0.15972, 0, 0.67083],
  2129. "934": [0, 0.68611, 0, 0, 0.76666],
  2130. "936": [0, 0.68611, 0.11653, 0, 0.71402],
  2131. "937": [0, 0.68611, 0.04835, 0, 0.8789],
  2132. "945": [0, 0.44444, 0, 0, 0.76064],
  2133. "946": [0.19444, 0.69444, 0.03403, 0, 0.65972],
  2134. "947": [0.19444, 0.44444, 0.06389, 0, 0.59003],
  2135. "948": [0, 0.69444, 0.03819, 0, 0.52222],
  2136. "949": [0, 0.44444, 0, 0, 0.52882],
  2137. "950": [0.19444, 0.69444, 0.06215, 0, 0.50833],
  2138. "951": [0.19444, 0.44444, 0.03704, 0, 0.6],
  2139. "952": [0, 0.69444, 0.03194, 0, 0.5618],
  2140. "953": [0, 0.44444, 0, 0, 0.41204],
  2141. "954": [0, 0.44444, 0, 0, 0.66759],
  2142. "955": [0, 0.69444, 0, 0, 0.67083],
  2143. "956": [0.19444, 0.44444, 0, 0, 0.70787],
  2144. "957": [0, 0.44444, 0.06898, 0, 0.57685],
  2145. "958": [0.19444, 0.69444, 0.03021, 0, 0.50833],
  2146. "959": [0, 0.44444, 0, 0, 0.58472],
  2147. "960": [0, 0.44444, 0.03704, 0, 0.68241],
  2148. "961": [0.19444, 0.44444, 0, 0, 0.6118],
  2149. "962": [0.09722, 0.44444, 0.07917, 0, 0.42361],
  2150. "963": [0, 0.44444, 0.03704, 0, 0.68588],
  2151. "964": [0, 0.44444, 0.13472, 0, 0.52083],
  2152. "965": [0, 0.44444, 0.03704, 0, 0.63055],
  2153. "966": [0.19444, 0.44444, 0, 0, 0.74722],
  2154. "967": [0.19444, 0.44444, 0, 0, 0.71805],
  2155. "968": [0.19444, 0.69444, 0.03704, 0, 0.75833],
  2156. "969": [0, 0.44444, 0.03704, 0, 0.71782],
  2157. "977": [0, 0.69444, 0, 0, 0.69155],
  2158. "981": [0.19444, 0.69444, 0, 0, 0.7125],
  2159. "982": [0, 0.44444, 0.03194, 0, 0.975],
  2160. "1009": [0.19444, 0.44444, 0, 0, 0.6118],
  2161. "1013": [0, 0.44444, 0, 0, 0.48333],
  2162. "57649": [0, 0.44444, 0, 0, 0.39352],
  2163. "57911": [0.19444, 0.44444, 0, 0, 0.43889]
  2164. },
  2165. "Math-Italic": {
  2166. "32": [0, 0, 0, 0, 0.25],
  2167. "48": [0, 0.43056, 0, 0, 0.5],
  2168. "49": [0, 0.43056, 0, 0, 0.5],
  2169. "50": [0, 0.43056, 0, 0, 0.5],
  2170. "51": [0.19444, 0.43056, 0, 0, 0.5],
  2171. "52": [0.19444, 0.43056, 0, 0, 0.5],
  2172. "53": [0.19444, 0.43056, 0, 0, 0.5],
  2173. "54": [0, 0.64444, 0, 0, 0.5],
  2174. "55": [0.19444, 0.43056, 0, 0, 0.5],
  2175. "56": [0, 0.64444, 0, 0, 0.5],
  2176. "57": [0.19444, 0.43056, 0, 0, 0.5],
  2177. "65": [0, 0.68333, 0, 0.13889, 0.75],
  2178. "66": [0, 0.68333, 0.05017, 0.08334, 0.75851],
  2179. "67": [0, 0.68333, 0.07153, 0.08334, 0.71472],
  2180. "68": [0, 0.68333, 0.02778, 0.05556, 0.82792],
  2181. "69": [0, 0.68333, 0.05764, 0.08334, 0.7382],
  2182. "70": [0, 0.68333, 0.13889, 0.08334, 0.64306],
  2183. "71": [0, 0.68333, 0, 0.08334, 0.78625],
  2184. "72": [0, 0.68333, 0.08125, 0.05556, 0.83125],
  2185. "73": [0, 0.68333, 0.07847, 0.11111, 0.43958],
  2186. "74": [0, 0.68333, 0.09618, 0.16667, 0.55451],
  2187. "75": [0, 0.68333, 0.07153, 0.05556, 0.84931],
  2188. "76": [0, 0.68333, 0, 0.02778, 0.68056],
  2189. "77": [0, 0.68333, 0.10903, 0.08334, 0.97014],
  2190. "78": [0, 0.68333, 0.10903, 0.08334, 0.80347],
  2191. "79": [0, 0.68333, 0.02778, 0.08334, 0.76278],
  2192. "80": [0, 0.68333, 0.13889, 0.08334, 0.64201],
  2193. "81": [0.19444, 0.68333, 0, 0.08334, 0.79056],
  2194. "82": [0, 0.68333, 0.00773, 0.08334, 0.75929],
  2195. "83": [0, 0.68333, 0.05764, 0.08334, 0.6132],
  2196. "84": [0, 0.68333, 0.13889, 0.08334, 0.58438],
  2197. "85": [0, 0.68333, 0.10903, 0.02778, 0.68278],
  2198. "86": [0, 0.68333, 0.22222, 0, 0.58333],
  2199. "87": [0, 0.68333, 0.13889, 0, 0.94445],
  2200. "88": [0, 0.68333, 0.07847, 0.08334, 0.82847],
  2201. "89": [0, 0.68333, 0.22222, 0, 0.58056],
  2202. "90": [0, 0.68333, 0.07153, 0.08334, 0.68264],
  2203. "97": [0, 0.43056, 0, 0, 0.52859],
  2204. "98": [0, 0.69444, 0, 0, 0.42917],
  2205. "99": [0, 0.43056, 0, 0.05556, 0.43276],
  2206. "100": [0, 0.69444, 0, 0.16667, 0.52049],
  2207. "101": [0, 0.43056, 0, 0.05556, 0.46563],
  2208. "102": [0.19444, 0.69444, 0.10764, 0.16667, 0.48959],
  2209. "103": [0.19444, 0.43056, 0.03588, 0.02778, 0.47697],
  2210. "104": [0, 0.69444, 0, 0, 0.57616],
  2211. "105": [0, 0.65952, 0, 0, 0.34451],
  2212. "106": [0.19444, 0.65952, 0.05724, 0, 0.41181],
  2213. "107": [0, 0.69444, 0.03148, 0, 0.5206],
  2214. "108": [0, 0.69444, 0.01968, 0.08334, 0.29838],
  2215. "109": [0, 0.43056, 0, 0, 0.87801],
  2216. "110": [0, 0.43056, 0, 0, 0.60023],
  2217. "111": [0, 0.43056, 0, 0.05556, 0.48472],
  2218. "112": [0.19444, 0.43056, 0, 0.08334, 0.50313],
  2219. "113": [0.19444, 0.43056, 0.03588, 0.08334, 0.44641],
  2220. "114": [0, 0.43056, 0.02778, 0.05556, 0.45116],
  2221. "115": [0, 0.43056, 0, 0.05556, 0.46875],
  2222. "116": [0, 0.61508, 0, 0.08334, 0.36111],
  2223. "117": [0, 0.43056, 0, 0.02778, 0.57246],
  2224. "118": [0, 0.43056, 0.03588, 0.02778, 0.48472],
  2225. "119": [0, 0.43056, 0.02691, 0.08334, 0.71592],
  2226. "120": [0, 0.43056, 0, 0.02778, 0.57153],
  2227. "121": [0.19444, 0.43056, 0.03588, 0.05556, 0.49028],
  2228. "122": [0, 0.43056, 0.04398, 0.05556, 0.46505],
  2229. "160": [0, 0, 0, 0, 0.25],
  2230. "915": [0, 0.68333, 0.13889, 0.08334, 0.61528],
  2231. "916": [0, 0.68333, 0, 0.16667, 0.83334],
  2232. "920": [0, 0.68333, 0.02778, 0.08334, 0.76278],
  2233. "923": [0, 0.68333, 0, 0.16667, 0.69445],
  2234. "926": [0, 0.68333, 0.07569, 0.08334, 0.74236],
  2235. "928": [0, 0.68333, 0.08125, 0.05556, 0.83125],
  2236. "931": [0, 0.68333, 0.05764, 0.08334, 0.77986],
  2237. "933": [0, 0.68333, 0.13889, 0.05556, 0.58333],
  2238. "934": [0, 0.68333, 0, 0.08334, 0.66667],
  2239. "936": [0, 0.68333, 0.11, 0.05556, 0.61222],
  2240. "937": [0, 0.68333, 0.05017, 0.08334, 0.7724],
  2241. "945": [0, 0.43056, 0.0037, 0.02778, 0.6397],
  2242. "946": [0.19444, 0.69444, 0.05278, 0.08334, 0.56563],
  2243. "947": [0.19444, 0.43056, 0.05556, 0, 0.51773],
  2244. "948": [0, 0.69444, 0.03785, 0.05556, 0.44444],
  2245. "949": [0, 0.43056, 0, 0.08334, 0.46632],
  2246. "950": [0.19444, 0.69444, 0.07378, 0.08334, 0.4375],
  2247. "951": [0.19444, 0.43056, 0.03588, 0.05556, 0.49653],
  2248. "952": [0, 0.69444, 0.02778, 0.08334, 0.46944],
  2249. "953": [0, 0.43056, 0, 0.05556, 0.35394],
  2250. "954": [0, 0.43056, 0, 0, 0.57616],
  2251. "955": [0, 0.69444, 0, 0, 0.58334],
  2252. "956": [0.19444, 0.43056, 0, 0.02778, 0.60255],
  2253. "957": [0, 0.43056, 0.06366, 0.02778, 0.49398],
  2254. "958": [0.19444, 0.69444, 0.04601, 0.11111, 0.4375],
  2255. "959": [0, 0.43056, 0, 0.05556, 0.48472],
  2256. "960": [0, 0.43056, 0.03588, 0, 0.57003],
  2257. "961": [0.19444, 0.43056, 0, 0.08334, 0.51702],
  2258. "962": [0.09722, 0.43056, 0.07986, 0.08334, 0.36285],
  2259. "963": [0, 0.43056, 0.03588, 0, 0.57141],
  2260. "964": [0, 0.43056, 0.1132, 0.02778, 0.43715],
  2261. "965": [0, 0.43056, 0.03588, 0.02778, 0.54028],
  2262. "966": [0.19444, 0.43056, 0, 0.08334, 0.65417],
  2263. "967": [0.19444, 0.43056, 0, 0.05556, 0.62569],
  2264. "968": [0.19444, 0.69444, 0.03588, 0.11111, 0.65139],
  2265. "969": [0, 0.43056, 0.03588, 0, 0.62245],
  2266. "977": [0, 0.69444, 0, 0.08334, 0.59144],
  2267. "981": [0.19444, 0.69444, 0, 0.08334, 0.59583],
  2268. "982": [0, 0.43056, 0.02778, 0, 0.82813],
  2269. "1009": [0.19444, 0.43056, 0, 0.08334, 0.51702],
  2270. "1013": [0, 0.43056, 0, 0.05556, 0.4059],
  2271. "57649": [0, 0.43056, 0, 0.02778, 0.32246],
  2272. "57911": [0.19444, 0.43056, 0, 0.08334, 0.38403]
  2273. },
  2274. "SansSerif-Bold": {
  2275. "32": [0, 0, 0, 0, 0.25],
  2276. "33": [0, 0.69444, 0, 0, 0.36667],
  2277. "34": [0, 0.69444, 0, 0, 0.55834],
  2278. "35": [0.19444, 0.69444, 0, 0, 0.91667],
  2279. "36": [0.05556, 0.75, 0, 0, 0.55],
  2280. "37": [0.05556, 0.75, 0, 0, 1.02912],
  2281. "38": [0, 0.69444, 0, 0, 0.83056],
  2282. "39": [0, 0.69444, 0, 0, 0.30556],
  2283. "40": [0.25, 0.75, 0, 0, 0.42778],
  2284. "41": [0.25, 0.75, 0, 0, 0.42778],
  2285. "42": [0, 0.75, 0, 0, 0.55],
  2286. "43": [0.11667, 0.61667, 0, 0, 0.85556],
  2287. "44": [0.10556, 0.13056, 0, 0, 0.30556],
  2288. "45": [0, 0.45833, 0, 0, 0.36667],
  2289. "46": [0, 0.13056, 0, 0, 0.30556],
  2290. "47": [0.25, 0.75, 0, 0, 0.55],
  2291. "48": [0, 0.69444, 0, 0, 0.55],
  2292. "49": [0, 0.69444, 0, 0, 0.55],
  2293. "50": [0, 0.69444, 0, 0, 0.55],
  2294. "51": [0, 0.69444, 0, 0, 0.55],
  2295. "52": [0, 0.69444, 0, 0, 0.55],
  2296. "53": [0, 0.69444, 0, 0, 0.55],
  2297. "54": [0, 0.69444, 0, 0, 0.55],
  2298. "55": [0, 0.69444, 0, 0, 0.55],
  2299. "56": [0, 0.69444, 0, 0, 0.55],
  2300. "57": [0, 0.69444, 0, 0, 0.55],
  2301. "58": [0, 0.45833, 0, 0, 0.30556],
  2302. "59": [0.10556, 0.45833, 0, 0, 0.30556],
  2303. "61": [-0.09375, 0.40625, 0, 0, 0.85556],
  2304. "63": [0, 0.69444, 0, 0, 0.51945],
  2305. "64": [0, 0.69444, 0, 0, 0.73334],
  2306. "65": [0, 0.69444, 0, 0, 0.73334],
  2307. "66": [0, 0.69444, 0, 0, 0.73334],
  2308. "67": [0, 0.69444, 0, 0, 0.70278],
  2309. "68": [0, 0.69444, 0, 0, 0.79445],
  2310. "69": [0, 0.69444, 0, 0, 0.64167],
  2311. "70": [0, 0.69444, 0, 0, 0.61111],
  2312. "71": [0, 0.69444, 0, 0, 0.73334],
  2313. "72": [0, 0.69444, 0, 0, 0.79445],
  2314. "73": [0, 0.69444, 0, 0, 0.33056],
  2315. "74": [0, 0.69444, 0, 0, 0.51945],
  2316. "75": [0, 0.69444, 0, 0, 0.76389],
  2317. "76": [0, 0.69444, 0, 0, 0.58056],
  2318. "77": [0, 0.69444, 0, 0, 0.97778],
  2319. "78": [0, 0.69444, 0, 0, 0.79445],
  2320. "79": [0, 0.69444, 0, 0, 0.79445],
  2321. "80": [0, 0.69444, 0, 0, 0.70278],
  2322. "81": [0.10556, 0.69444, 0, 0, 0.79445],
  2323. "82": [0, 0.69444, 0, 0, 0.70278],
  2324. "83": [0, 0.69444, 0, 0, 0.61111],
  2325. "84": [0, 0.69444, 0, 0, 0.73334],
  2326. "85": [0, 0.69444, 0, 0, 0.76389],
  2327. "86": [0, 0.69444, 0.01528, 0, 0.73334],
  2328. "87": [0, 0.69444, 0.01528, 0, 1.03889],
  2329. "88": [0, 0.69444, 0, 0, 0.73334],
  2330. "89": [0, 0.69444, 0.0275, 0, 0.73334],
  2331. "90": [0, 0.69444, 0, 0, 0.67223],
  2332. "91": [0.25, 0.75, 0, 0, 0.34306],
  2333. "93": [0.25, 0.75, 0, 0, 0.34306],
  2334. "94": [0, 0.69444, 0, 0, 0.55],
  2335. "95": [0.35, 0.10833, 0.03056, 0, 0.55],
  2336. "97": [0, 0.45833, 0, 0, 0.525],
  2337. "98": [0, 0.69444, 0, 0, 0.56111],
  2338. "99": [0, 0.45833, 0, 0, 0.48889],
  2339. "100": [0, 0.69444, 0, 0, 0.56111],
  2340. "101": [0, 0.45833, 0, 0, 0.51111],
  2341. "102": [0, 0.69444, 0.07639, 0, 0.33611],
  2342. "103": [0.19444, 0.45833, 0.01528, 0, 0.55],
  2343. "104": [0, 0.69444, 0, 0, 0.56111],
  2344. "105": [0, 0.69444, 0, 0, 0.25556],
  2345. "106": [0.19444, 0.69444, 0, 0, 0.28611],
  2346. "107": [0, 0.69444, 0, 0, 0.53056],
  2347. "108": [0, 0.69444, 0, 0, 0.25556],
  2348. "109": [0, 0.45833, 0, 0, 0.86667],
  2349. "110": [0, 0.45833, 0, 0, 0.56111],
  2350. "111": [0, 0.45833, 0, 0, 0.55],
  2351. "112": [0.19444, 0.45833, 0, 0, 0.56111],
  2352. "113": [0.19444, 0.45833, 0, 0, 0.56111],
  2353. "114": [0, 0.45833, 0.01528, 0, 0.37222],
  2354. "115": [0, 0.45833, 0, 0, 0.42167],
  2355. "116": [0, 0.58929, 0, 0, 0.40417],
  2356. "117": [0, 0.45833, 0, 0, 0.56111],
  2357. "118": [0, 0.45833, 0.01528, 0, 0.5],
  2358. "119": [0, 0.45833, 0.01528, 0, 0.74445],
  2359. "120": [0, 0.45833, 0, 0, 0.5],
  2360. "121": [0.19444, 0.45833, 0.01528, 0, 0.5],
  2361. "122": [0, 0.45833, 0, 0, 0.47639],
  2362. "126": [0.35, 0.34444, 0, 0, 0.55],
  2363. "160": [0, 0, 0, 0, 0.25],
  2364. "168": [0, 0.69444, 0, 0, 0.55],
  2365. "176": [0, 0.69444, 0, 0, 0.73334],
  2366. "180": [0, 0.69444, 0, 0, 0.55],
  2367. "184": [0.17014, 0, 0, 0, 0.48889],
  2368. "305": [0, 0.45833, 0, 0, 0.25556],
  2369. "567": [0.19444, 0.45833, 0, 0, 0.28611],
  2370. "710": [0, 0.69444, 0, 0, 0.55],
  2371. "711": [0, 0.63542, 0, 0, 0.55],
  2372. "713": [0, 0.63778, 0, 0, 0.55],
  2373. "728": [0, 0.69444, 0, 0, 0.55],
  2374. "729": [0, 0.69444, 0, 0, 0.30556],
  2375. "730": [0, 0.69444, 0, 0, 0.73334],
  2376. "732": [0, 0.69444, 0, 0, 0.55],
  2377. "733": [0, 0.69444, 0, 0, 0.55],
  2378. "915": [0, 0.69444, 0, 0, 0.58056],
  2379. "916": [0, 0.69444, 0, 0, 0.91667],
  2380. "920": [0, 0.69444, 0, 0, 0.85556],
  2381. "923": [0, 0.69444, 0, 0, 0.67223],
  2382. "926": [0, 0.69444, 0, 0, 0.73334],
  2383. "928": [0, 0.69444, 0, 0, 0.79445],
  2384. "931": [0, 0.69444, 0, 0, 0.79445],
  2385. "933": [0, 0.69444, 0, 0, 0.85556],
  2386. "934": [0, 0.69444, 0, 0, 0.79445],
  2387. "936": [0, 0.69444, 0, 0, 0.85556],
  2388. "937": [0, 0.69444, 0, 0, 0.79445],
  2389. "8211": [0, 0.45833, 0.03056, 0, 0.55],
  2390. "8212": [0, 0.45833, 0.03056, 0, 1.10001],
  2391. "8216": [0, 0.69444, 0, 0, 0.30556],
  2392. "8217": [0, 0.69444, 0, 0, 0.30556],
  2393. "8220": [0, 0.69444, 0, 0, 0.55834],
  2394. "8221": [0, 0.69444, 0, 0, 0.55834]
  2395. },
  2396. "SansSerif-Italic": {
  2397. "32": [0, 0, 0, 0, 0.25],
  2398. "33": [0, 0.69444, 0.05733, 0, 0.31945],
  2399. "34": [0, 0.69444, 0.00316, 0, 0.5],
  2400. "35": [0.19444, 0.69444, 0.05087, 0, 0.83334],
  2401. "36": [0.05556, 0.75, 0.11156, 0, 0.5],
  2402. "37": [0.05556, 0.75, 0.03126, 0, 0.83334],
  2403. "38": [0, 0.69444, 0.03058, 0, 0.75834],
  2404. "39": [0, 0.69444, 0.07816, 0, 0.27778],
  2405. "40": [0.25, 0.75, 0.13164, 0, 0.38889],
  2406. "41": [0.25, 0.75, 0.02536, 0, 0.38889],
  2407. "42": [0, 0.75, 0.11775, 0, 0.5],
  2408. "43": [0.08333, 0.58333, 0.02536, 0, 0.77778],
  2409. "44": [0.125, 0.08333, 0, 0, 0.27778],
  2410. "45": [0, 0.44444, 0.01946, 0, 0.33333],
  2411. "46": [0, 0.08333, 0, 0, 0.27778],
  2412. "47": [0.25, 0.75, 0.13164, 0, 0.5],
  2413. "48": [0, 0.65556, 0.11156, 0, 0.5],
  2414. "49": [0, 0.65556, 0.11156, 0, 0.5],
  2415. "50": [0, 0.65556, 0.11156, 0, 0.5],
  2416. "51": [0, 0.65556, 0.11156, 0, 0.5],
  2417. "52": [0, 0.65556, 0.11156, 0, 0.5],
  2418. "53": [0, 0.65556, 0.11156, 0, 0.5],
  2419. "54": [0, 0.65556, 0.11156, 0, 0.5],
  2420. "55": [0, 0.65556, 0.11156, 0, 0.5],
  2421. "56": [0, 0.65556, 0.11156, 0, 0.5],
  2422. "57": [0, 0.65556, 0.11156, 0, 0.5],
  2423. "58": [0, 0.44444, 0.02502, 0, 0.27778],
  2424. "59": [0.125, 0.44444, 0.02502, 0, 0.27778],
  2425. "61": [-0.13, 0.37, 0.05087, 0, 0.77778],
  2426. "63": [0, 0.69444, 0.11809, 0, 0.47222],
  2427. "64": [0, 0.69444, 0.07555, 0, 0.66667],
  2428. "65": [0, 0.69444, 0, 0, 0.66667],
  2429. "66": [0, 0.69444, 0.08293, 0, 0.66667],
  2430. "67": [0, 0.69444, 0.11983, 0, 0.63889],
  2431. "68": [0, 0.69444, 0.07555, 0, 0.72223],
  2432. "69": [0, 0.69444, 0.11983, 0, 0.59722],
  2433. "70": [0, 0.69444, 0.13372, 0, 0.56945],
  2434. "71": [0, 0.69444, 0.11983, 0, 0.66667],
  2435. "72": [0, 0.69444, 0.08094, 0, 0.70834],
  2436. "73": [0, 0.69444, 0.13372, 0, 0.27778],
  2437. "74": [0, 0.69444, 0.08094, 0, 0.47222],
  2438. "75": [0, 0.69444, 0.11983, 0, 0.69445],
  2439. "76": [0, 0.69444, 0, 0, 0.54167],
  2440. "77": [0, 0.69444, 0.08094, 0, 0.875],
  2441. "78": [0, 0.69444, 0.08094, 0, 0.70834],
  2442. "79": [0, 0.69444, 0.07555, 0, 0.73611],
  2443. "80": [0, 0.69444, 0.08293, 0, 0.63889],
  2444. "81": [0.125, 0.69444, 0.07555, 0, 0.73611],
  2445. "82": [0, 0.69444, 0.08293, 0, 0.64584],
  2446. "83": [0, 0.69444, 0.09205, 0, 0.55556],
  2447. "84": [0, 0.69444, 0.13372, 0, 0.68056],
  2448. "85": [0, 0.69444, 0.08094, 0, 0.6875],
  2449. "86": [0, 0.69444, 0.1615, 0, 0.66667],
  2450. "87": [0, 0.69444, 0.1615, 0, 0.94445],
  2451. "88": [0, 0.69444, 0.13372, 0, 0.66667],
  2452. "89": [0, 0.69444, 0.17261, 0, 0.66667],
  2453. "90": [0, 0.69444, 0.11983, 0, 0.61111],
  2454. "91": [0.25, 0.75, 0.15942, 0, 0.28889],
  2455. "93": [0.25, 0.75, 0.08719, 0, 0.28889],
  2456. "94": [0, 0.69444, 0.0799, 0, 0.5],
  2457. "95": [0.35, 0.09444, 0.08616, 0, 0.5],
  2458. "97": [0, 0.44444, 0.00981, 0, 0.48056],
  2459. "98": [0, 0.69444, 0.03057, 0, 0.51667],
  2460. "99": [0, 0.44444, 0.08336, 0, 0.44445],
  2461. "100": [0, 0.69444, 0.09483, 0, 0.51667],
  2462. "101": [0, 0.44444, 0.06778, 0, 0.44445],
  2463. "102": [0, 0.69444, 0.21705, 0, 0.30556],
  2464. "103": [0.19444, 0.44444, 0.10836, 0, 0.5],
  2465. "104": [0, 0.69444, 0.01778, 0, 0.51667],
  2466. "105": [0, 0.67937, 0.09718, 0, 0.23889],
  2467. "106": [0.19444, 0.67937, 0.09162, 0, 0.26667],
  2468. "107": [0, 0.69444, 0.08336, 0, 0.48889],
  2469. "108": [0, 0.69444, 0.09483, 0, 0.23889],
  2470. "109": [0, 0.44444, 0.01778, 0, 0.79445],
  2471. "110": [0, 0.44444, 0.01778, 0, 0.51667],
  2472. "111": [0, 0.44444, 0.06613, 0, 0.5],
  2473. "112": [0.19444, 0.44444, 0.0389, 0, 0.51667],
  2474. "113": [0.19444, 0.44444, 0.04169, 0, 0.51667],
  2475. "114": [0, 0.44444, 0.10836, 0, 0.34167],
  2476. "115": [0, 0.44444, 0.0778, 0, 0.38333],
  2477. "116": [0, 0.57143, 0.07225, 0, 0.36111],
  2478. "117": [0, 0.44444, 0.04169, 0, 0.51667],
  2479. "118": [0, 0.44444, 0.10836, 0, 0.46111],
  2480. "119": [0, 0.44444, 0.10836, 0, 0.68334],
  2481. "120": [0, 0.44444, 0.09169, 0, 0.46111],
  2482. "121": [0.19444, 0.44444, 0.10836, 0, 0.46111],
  2483. "122": [0, 0.44444, 0.08752, 0, 0.43472],
  2484. "126": [0.35, 0.32659, 0.08826, 0, 0.5],
  2485. "160": [0, 0, 0, 0, 0.25],
  2486. "168": [0, 0.67937, 0.06385, 0, 0.5],
  2487. "176": [0, 0.69444, 0, 0, 0.73752],
  2488. "184": [0.17014, 0, 0, 0, 0.44445],
  2489. "305": [0, 0.44444, 0.04169, 0, 0.23889],
  2490. "567": [0.19444, 0.44444, 0.04169, 0, 0.26667],
  2491. "710": [0, 0.69444, 0.0799, 0, 0.5],
  2492. "711": [0, 0.63194, 0.08432, 0, 0.5],
  2493. "713": [0, 0.60889, 0.08776, 0, 0.5],
  2494. "714": [0, 0.69444, 0.09205, 0, 0.5],
  2495. "715": [0, 0.69444, 0, 0, 0.5],
  2496. "728": [0, 0.69444, 0.09483, 0, 0.5],
  2497. "729": [0, 0.67937, 0.07774, 0, 0.27778],
  2498. "730": [0, 0.69444, 0, 0, 0.73752],
  2499. "732": [0, 0.67659, 0.08826, 0, 0.5],
  2500. "733": [0, 0.69444, 0.09205, 0, 0.5],
  2501. "915": [0, 0.69444, 0.13372, 0, 0.54167],
  2502. "916": [0, 0.69444, 0, 0, 0.83334],
  2503. "920": [0, 0.69444, 0.07555, 0, 0.77778],
  2504. "923": [0, 0.69444, 0, 0, 0.61111],
  2505. "926": [0, 0.69444, 0.12816, 0, 0.66667],
  2506. "928": [0, 0.69444, 0.08094, 0, 0.70834],
  2507. "931": [0, 0.69444, 0.11983, 0, 0.72222],
  2508. "933": [0, 0.69444, 0.09031, 0, 0.77778],
  2509. "934": [0, 0.69444, 0.04603, 0, 0.72222],
  2510. "936": [0, 0.69444, 0.09031, 0, 0.77778],
  2511. "937": [0, 0.69444, 0.08293, 0, 0.72222],
  2512. "8211": [0, 0.44444, 0.08616, 0, 0.5],
  2513. "8212": [0, 0.44444, 0.08616, 0, 1.0],
  2514. "8216": [0, 0.69444, 0.07816, 0, 0.27778],
  2515. "8217": [0, 0.69444, 0.07816, 0, 0.27778],
  2516. "8220": [0, 0.69444, 0.14205, 0, 0.5],
  2517. "8221": [0, 0.69444, 0.00316, 0, 0.5]
  2518. },
  2519. "SansSerif-Regular": {
  2520. "32": [0, 0, 0, 0, 0.25],
  2521. "33": [0, 0.69444, 0, 0, 0.31945],
  2522. "34": [0, 0.69444, 0, 0, 0.5],
  2523. "35": [0.19444, 0.69444, 0, 0, 0.83334],
  2524. "36": [0.05556, 0.75, 0, 0, 0.5],
  2525. "37": [0.05556, 0.75, 0, 0, 0.83334],
  2526. "38": [0, 0.69444, 0, 0, 0.75834],
  2527. "39": [0, 0.69444, 0, 0, 0.27778],
  2528. "40": [0.25, 0.75, 0, 0, 0.38889],
  2529. "41": [0.25, 0.75, 0, 0, 0.38889],
  2530. "42": [0, 0.75, 0, 0, 0.5],
  2531. "43": [0.08333, 0.58333, 0, 0, 0.77778],
  2532. "44": [0.125, 0.08333, 0, 0, 0.27778],
  2533. "45": [0, 0.44444, 0, 0, 0.33333],
  2534. "46": [0, 0.08333, 0, 0, 0.27778],
  2535. "47": [0.25, 0.75, 0, 0, 0.5],
  2536. "48": [0, 0.65556, 0, 0, 0.5],
  2537. "49": [0, 0.65556, 0, 0, 0.5],
  2538. "50": [0, 0.65556, 0, 0, 0.5],
  2539. "51": [0, 0.65556, 0, 0, 0.5],
  2540. "52": [0, 0.65556, 0, 0, 0.5],
  2541. "53": [0, 0.65556, 0, 0, 0.5],
  2542. "54": [0, 0.65556, 0, 0, 0.5],
  2543. "55": [0, 0.65556, 0, 0, 0.5],
  2544. "56": [0, 0.65556, 0, 0, 0.5],
  2545. "57": [0, 0.65556, 0, 0, 0.5],
  2546. "58": [0, 0.44444, 0, 0, 0.27778],
  2547. "59": [0.125, 0.44444, 0, 0, 0.27778],
  2548. "61": [-0.13, 0.37, 0, 0, 0.77778],
  2549. "63": [0, 0.69444, 0, 0, 0.47222],
  2550. "64": [0, 0.69444, 0, 0, 0.66667],
  2551. "65": [0, 0.69444, 0, 0, 0.66667],
  2552. "66": [0, 0.69444, 0, 0, 0.66667],
  2553. "67": [0, 0.69444, 0, 0, 0.63889],
  2554. "68": [0, 0.69444, 0, 0, 0.72223],
  2555. "69": [0, 0.69444, 0, 0, 0.59722],
  2556. "70": [0, 0.69444, 0, 0, 0.56945],
  2557. "71": [0, 0.69444, 0, 0, 0.66667],
  2558. "72": [0, 0.69444, 0, 0, 0.70834],
  2559. "73": [0, 0.69444, 0, 0, 0.27778],
  2560. "74": [0, 0.69444, 0, 0, 0.47222],
  2561. "75": [0, 0.69444, 0, 0, 0.69445],
  2562. "76": [0, 0.69444, 0, 0, 0.54167],
  2563. "77": [0, 0.69444, 0, 0, 0.875],
  2564. "78": [0, 0.69444, 0, 0, 0.70834],
  2565. "79": [0, 0.69444, 0, 0, 0.73611],
  2566. "80": [0, 0.69444, 0, 0, 0.63889],
  2567. "81": [0.125, 0.69444, 0, 0, 0.73611],
  2568. "82": [0, 0.69444, 0, 0, 0.64584],
  2569. "83": [0, 0.69444, 0, 0, 0.55556],
  2570. "84": [0, 0.69444, 0, 0, 0.68056],
  2571. "85": [0, 0.69444, 0, 0, 0.6875],
  2572. "86": [0, 0.69444, 0.01389, 0, 0.66667],
  2573. "87": [0, 0.69444, 0.01389, 0, 0.94445],
  2574. "88": [0, 0.69444, 0, 0, 0.66667],
  2575. "89": [0, 0.69444, 0.025, 0, 0.66667],
  2576. "90": [0, 0.69444, 0, 0, 0.61111],
  2577. "91": [0.25, 0.75, 0, 0, 0.28889],
  2578. "93": [0.25, 0.75, 0, 0, 0.28889],
  2579. "94": [0, 0.69444, 0, 0, 0.5],
  2580. "95": [0.35, 0.09444, 0.02778, 0, 0.5],
  2581. "97": [0, 0.44444, 0, 0, 0.48056],
  2582. "98": [0, 0.69444, 0, 0, 0.51667],
  2583. "99": [0, 0.44444, 0, 0, 0.44445],
  2584. "100": [0, 0.69444, 0, 0, 0.51667],
  2585. "101": [0, 0.44444, 0, 0, 0.44445],
  2586. "102": [0, 0.69444, 0.06944, 0, 0.30556],
  2587. "103": [0.19444, 0.44444, 0.01389, 0, 0.5],
  2588. "104": [0, 0.69444, 0, 0, 0.51667],
  2589. "105": [0, 0.67937, 0, 0, 0.23889],
  2590. "106": [0.19444, 0.67937, 0, 0, 0.26667],
  2591. "107": [0, 0.69444, 0, 0, 0.48889],
  2592. "108": [0, 0.69444, 0, 0, 0.23889],
  2593. "109": [0, 0.44444, 0, 0, 0.79445],
  2594. "110": [0, 0.44444, 0, 0, 0.51667],
  2595. "111": [0, 0.44444, 0, 0, 0.5],
  2596. "112": [0.19444, 0.44444, 0, 0, 0.51667],
  2597. "113": [0.19444, 0.44444, 0, 0, 0.51667],
  2598. "114": [0, 0.44444, 0.01389, 0, 0.34167],
  2599. "115": [0, 0.44444, 0, 0, 0.38333],
  2600. "116": [0, 0.57143, 0, 0, 0.36111],
  2601. "117": [0, 0.44444, 0, 0, 0.51667],
  2602. "118": [0, 0.44444, 0.01389, 0, 0.46111],
  2603. "119": [0, 0.44444, 0.01389, 0, 0.68334],
  2604. "120": [0, 0.44444, 0, 0, 0.46111],
  2605. "121": [0.19444, 0.44444, 0.01389, 0, 0.46111],
  2606. "122": [0, 0.44444, 0, 0, 0.43472],
  2607. "126": [0.35, 0.32659, 0, 0, 0.5],
  2608. "160": [0, 0, 0, 0, 0.25],
  2609. "168": [0, 0.67937, 0, 0, 0.5],
  2610. "176": [0, 0.69444, 0, 0, 0.66667],
  2611. "184": [0.17014, 0, 0, 0, 0.44445],
  2612. "305": [0, 0.44444, 0, 0, 0.23889],
  2613. "567": [0.19444, 0.44444, 0, 0, 0.26667],
  2614. "710": [0, 0.69444, 0, 0, 0.5],
  2615. "711": [0, 0.63194, 0, 0, 0.5],
  2616. "713": [0, 0.60889, 0, 0, 0.5],
  2617. "714": [0, 0.69444, 0, 0, 0.5],
  2618. "715": [0, 0.69444, 0, 0, 0.5],
  2619. "728": [0, 0.69444, 0, 0, 0.5],
  2620. "729": [0, 0.67937, 0, 0, 0.27778],
  2621. "730": [0, 0.69444, 0, 0, 0.66667],
  2622. "732": [0, 0.67659, 0, 0, 0.5],
  2623. "733": [0, 0.69444, 0, 0, 0.5],
  2624. "915": [0, 0.69444, 0, 0, 0.54167],
  2625. "916": [0, 0.69444, 0, 0, 0.83334],
  2626. "920": [0, 0.69444, 0, 0, 0.77778],
  2627. "923": [0, 0.69444, 0, 0, 0.61111],
  2628. "926": [0, 0.69444, 0, 0, 0.66667],
  2629. "928": [0, 0.69444, 0, 0, 0.70834],
  2630. "931": [0, 0.69444, 0, 0, 0.72222],
  2631. "933": [0, 0.69444, 0, 0, 0.77778],
  2632. "934": [0, 0.69444, 0, 0, 0.72222],
  2633. "936": [0, 0.69444, 0, 0, 0.77778],
  2634. "937": [0, 0.69444, 0, 0, 0.72222],
  2635. "8211": [0, 0.44444, 0.02778, 0, 0.5],
  2636. "8212": [0, 0.44444, 0.02778, 0, 1.0],
  2637. "8216": [0, 0.69444, 0, 0, 0.27778],
  2638. "8217": [0, 0.69444, 0, 0, 0.27778],
  2639. "8220": [0, 0.69444, 0, 0, 0.5],
  2640. "8221": [0, 0.69444, 0, 0, 0.5]
  2641. },
  2642. "Script-Regular": {
  2643. "32": [0, 0, 0, 0, 0.25],
  2644. "65": [0, 0.7, 0.22925, 0, 0.80253],
  2645. "66": [0, 0.7, 0.04087, 0, 0.90757],
  2646. "67": [0, 0.7, 0.1689, 0, 0.66619],
  2647. "68": [0, 0.7, 0.09371, 0, 0.77443],
  2648. "69": [0, 0.7, 0.18583, 0, 0.56162],
  2649. "70": [0, 0.7, 0.13634, 0, 0.89544],
  2650. "71": [0, 0.7, 0.17322, 0, 0.60961],
  2651. "72": [0, 0.7, 0.29694, 0, 0.96919],
  2652. "73": [0, 0.7, 0.19189, 0, 0.80907],
  2653. "74": [0.27778, 0.7, 0.19189, 0, 1.05159],
  2654. "75": [0, 0.7, 0.31259, 0, 0.91364],
  2655. "76": [0, 0.7, 0.19189, 0, 0.87373],
  2656. "77": [0, 0.7, 0.15981, 0, 1.08031],
  2657. "78": [0, 0.7, 0.3525, 0, 0.9015],
  2658. "79": [0, 0.7, 0.08078, 0, 0.73787],
  2659. "80": [0, 0.7, 0.08078, 0, 1.01262],
  2660. "81": [0, 0.7, 0.03305, 0, 0.88282],
  2661. "82": [0, 0.7, 0.06259, 0, 0.85],
  2662. "83": [0, 0.7, 0.19189, 0, 0.86767],
  2663. "84": [0, 0.7, 0.29087, 0, 0.74697],
  2664. "85": [0, 0.7, 0.25815, 0, 0.79996],
  2665. "86": [0, 0.7, 0.27523, 0, 0.62204],
  2666. "87": [0, 0.7, 0.27523, 0, 0.80532],
  2667. "88": [0, 0.7, 0.26006, 0, 0.94445],
  2668. "89": [0, 0.7, 0.2939, 0, 0.70961],
  2669. "90": [0, 0.7, 0.24037, 0, 0.8212],
  2670. "160": [0, 0, 0, 0, 0.25]
  2671. },
  2672. "Size1-Regular": {
  2673. "32": [0, 0, 0, 0, 0.25],
  2674. "40": [0.35001, 0.85, 0, 0, 0.45834],
  2675. "41": [0.35001, 0.85, 0, 0, 0.45834],
  2676. "47": [0.35001, 0.85, 0, 0, 0.57778],
  2677. "91": [0.35001, 0.85, 0, 0, 0.41667],
  2678. "92": [0.35001, 0.85, 0, 0, 0.57778],
  2679. "93": [0.35001, 0.85, 0, 0, 0.41667],
  2680. "123": [0.35001, 0.85, 0, 0, 0.58334],
  2681. "125": [0.35001, 0.85, 0, 0, 0.58334],
  2682. "160": [0, 0, 0, 0, 0.25],
  2683. "710": [0, 0.72222, 0, 0, 0.55556],
  2684. "732": [0, 0.72222, 0, 0, 0.55556],
  2685. "770": [0, 0.72222, 0, 0, 0.55556],
  2686. "771": [0, 0.72222, 0, 0, 0.55556],
  2687. "8214": [-0.00099, 0.601, 0, 0, 0.77778],
  2688. "8593": [1e-05, 0.6, 0, 0, 0.66667],
  2689. "8595": [1e-05, 0.6, 0, 0, 0.66667],
  2690. "8657": [1e-05, 0.6, 0, 0, 0.77778],
  2691. "8659": [1e-05, 0.6, 0, 0, 0.77778],
  2692. "8719": [0.25001, 0.75, 0, 0, 0.94445],
  2693. "8720": [0.25001, 0.75, 0, 0, 0.94445],
  2694. "8721": [0.25001, 0.75, 0, 0, 1.05556],
  2695. "8730": [0.35001, 0.85, 0, 0, 1.0],
  2696. "8739": [-0.00599, 0.606, 0, 0, 0.33333],
  2697. "8741": [-0.00599, 0.606, 0, 0, 0.55556],
  2698. "8747": [0.30612, 0.805, 0.19445, 0, 0.47222],
  2699. "8748": [0.306, 0.805, 0.19445, 0, 0.47222],
  2700. "8749": [0.306, 0.805, 0.19445, 0, 0.47222],
  2701. "8750": [0.30612, 0.805, 0.19445, 0, 0.47222],
  2702. "8896": [0.25001, 0.75, 0, 0, 0.83334],
  2703. "8897": [0.25001, 0.75, 0, 0, 0.83334],
  2704. "8898": [0.25001, 0.75, 0, 0, 0.83334],
  2705. "8899": [0.25001, 0.75, 0, 0, 0.83334],
  2706. "8968": [0.35001, 0.85, 0, 0, 0.47222],
  2707. "8969": [0.35001, 0.85, 0, 0, 0.47222],
  2708. "8970": [0.35001, 0.85, 0, 0, 0.47222],
  2709. "8971": [0.35001, 0.85, 0, 0, 0.47222],
  2710. "9168": [-0.00099, 0.601, 0, 0, 0.66667],
  2711. "10216": [0.35001, 0.85, 0, 0, 0.47222],
  2712. "10217": [0.35001, 0.85, 0, 0, 0.47222],
  2713. "10752": [0.25001, 0.75, 0, 0, 1.11111],
  2714. "10753": [0.25001, 0.75, 0, 0, 1.11111],
  2715. "10754": [0.25001, 0.75, 0, 0, 1.11111],
  2716. "10756": [0.25001, 0.75, 0, 0, 0.83334],
  2717. "10758": [0.25001, 0.75, 0, 0, 0.83334]
  2718. },
  2719. "Size2-Regular": {
  2720. "32": [0, 0, 0, 0, 0.25],
  2721. "40": [0.65002, 1.15, 0, 0, 0.59722],
  2722. "41": [0.65002, 1.15, 0, 0, 0.59722],
  2723. "47": [0.65002, 1.15, 0, 0, 0.81111],
  2724. "91": [0.65002, 1.15, 0, 0, 0.47222],
  2725. "92": [0.65002, 1.15, 0, 0, 0.81111],
  2726. "93": [0.65002, 1.15, 0, 0, 0.47222],
  2727. "123": [0.65002, 1.15, 0, 0, 0.66667],
  2728. "125": [0.65002, 1.15, 0, 0, 0.66667],
  2729. "160": [0, 0, 0, 0, 0.25],
  2730. "710": [0, 0.75, 0, 0, 1.0],
  2731. "732": [0, 0.75, 0, 0, 1.0],
  2732. "770": [0, 0.75, 0, 0, 1.0],
  2733. "771": [0, 0.75, 0, 0, 1.0],
  2734. "8719": [0.55001, 1.05, 0, 0, 1.27778],
  2735. "8720": [0.55001, 1.05, 0, 0, 1.27778],
  2736. "8721": [0.55001, 1.05, 0, 0, 1.44445],
  2737. "8730": [0.65002, 1.15, 0, 0, 1.0],
  2738. "8747": [0.86225, 1.36, 0.44445, 0, 0.55556],
  2739. "8748": [0.862, 1.36, 0.44445, 0, 0.55556],
  2740. "8749": [0.862, 1.36, 0.44445, 0, 0.55556],
  2741. "8750": [0.86225, 1.36, 0.44445, 0, 0.55556],
  2742. "8896": [0.55001, 1.05, 0, 0, 1.11111],
  2743. "8897": [0.55001, 1.05, 0, 0, 1.11111],
  2744. "8898": [0.55001, 1.05, 0, 0, 1.11111],
  2745. "8899": [0.55001, 1.05, 0, 0, 1.11111],
  2746. "8968": [0.65002, 1.15, 0, 0, 0.52778],
  2747. "8969": [0.65002, 1.15, 0, 0, 0.52778],
  2748. "8970": [0.65002, 1.15, 0, 0, 0.52778],
  2749. "8971": [0.65002, 1.15, 0, 0, 0.52778],
  2750. "10216": [0.65002, 1.15, 0, 0, 0.61111],
  2751. "10217": [0.65002, 1.15, 0, 0, 0.61111],
  2752. "10752": [0.55001, 1.05, 0, 0, 1.51112],
  2753. "10753": [0.55001, 1.05, 0, 0, 1.51112],
  2754. "10754": [0.55001, 1.05, 0, 0, 1.51112],
  2755. "10756": [0.55001, 1.05, 0, 0, 1.11111],
  2756. "10758": [0.55001, 1.05, 0, 0, 1.11111]
  2757. },
  2758. "Size3-Regular": {
  2759. "32": [0, 0, 0, 0, 0.25],
  2760. "40": [0.95003, 1.45, 0, 0, 0.73611],
  2761. "41": [0.95003, 1.45, 0, 0, 0.73611],
  2762. "47": [0.95003, 1.45, 0, 0, 1.04445],
  2763. "91": [0.95003, 1.45, 0, 0, 0.52778],
  2764. "92": [0.95003, 1.45, 0, 0, 1.04445],
  2765. "93": [0.95003, 1.45, 0, 0, 0.52778],
  2766. "123": [0.95003, 1.45, 0, 0, 0.75],
  2767. "125": [0.95003, 1.45, 0, 0, 0.75],
  2768. "160": [0, 0, 0, 0, 0.25],
  2769. "710": [0, 0.75, 0, 0, 1.44445],
  2770. "732": [0, 0.75, 0, 0, 1.44445],
  2771. "770": [0, 0.75, 0, 0, 1.44445],
  2772. "771": [0, 0.75, 0, 0, 1.44445],
  2773. "8730": [0.95003, 1.45, 0, 0, 1.0],
  2774. "8968": [0.95003, 1.45, 0, 0, 0.58334],
  2775. "8969": [0.95003, 1.45, 0, 0, 0.58334],
  2776. "8970": [0.95003, 1.45, 0, 0, 0.58334],
  2777. "8971": [0.95003, 1.45, 0, 0, 0.58334],
  2778. "10216": [0.95003, 1.45, 0, 0, 0.75],
  2779. "10217": [0.95003, 1.45, 0, 0, 0.75]
  2780. },
  2781. "Size4-Regular": {
  2782. "32": [0, 0, 0, 0, 0.25],
  2783. "40": [1.25003, 1.75, 0, 0, 0.79167],
  2784. "41": [1.25003, 1.75, 0, 0, 0.79167],
  2785. "47": [1.25003, 1.75, 0, 0, 1.27778],
  2786. "91": [1.25003, 1.75, 0, 0, 0.58334],
  2787. "92": [1.25003, 1.75, 0, 0, 1.27778],
  2788. "93": [1.25003, 1.75, 0, 0, 0.58334],
  2789. "123": [1.25003, 1.75, 0, 0, 0.80556],
  2790. "125": [1.25003, 1.75, 0, 0, 0.80556],
  2791. "160": [0, 0, 0, 0, 0.25],
  2792. "710": [0, 0.825, 0, 0, 1.8889],
  2793. "732": [0, 0.825, 0, 0, 1.8889],
  2794. "770": [0, 0.825, 0, 0, 1.8889],
  2795. "771": [0, 0.825, 0, 0, 1.8889],
  2796. "8730": [1.25003, 1.75, 0, 0, 1.0],
  2797. "8968": [1.25003, 1.75, 0, 0, 0.63889],
  2798. "8969": [1.25003, 1.75, 0, 0, 0.63889],
  2799. "8970": [1.25003, 1.75, 0, 0, 0.63889],
  2800. "8971": [1.25003, 1.75, 0, 0, 0.63889],
  2801. "9115": [0.64502, 1.155, 0, 0, 0.875],
  2802. "9116": [1e-05, 0.6, 0, 0, 0.875],
  2803. "9117": [0.64502, 1.155, 0, 0, 0.875],
  2804. "9118": [0.64502, 1.155, 0, 0, 0.875],
  2805. "9119": [1e-05, 0.6, 0, 0, 0.875],
  2806. "9120": [0.64502, 1.155, 0, 0, 0.875],
  2807. "9121": [0.64502, 1.155, 0, 0, 0.66667],
  2808. "9122": [-0.00099, 0.601, 0, 0, 0.66667],
  2809. "9123": [0.64502, 1.155, 0, 0, 0.66667],
  2810. "9124": [0.64502, 1.155, 0, 0, 0.66667],
  2811. "9125": [-0.00099, 0.601, 0, 0, 0.66667],
  2812. "9126": [0.64502, 1.155, 0, 0, 0.66667],
  2813. "9127": [1e-05, 0.9, 0, 0, 0.88889],
  2814. "9128": [0.65002, 1.15, 0, 0, 0.88889],
  2815. "9129": [0.90001, 0, 0, 0, 0.88889],
  2816. "9130": [0, 0.3, 0, 0, 0.88889],
  2817. "9131": [1e-05, 0.9, 0, 0, 0.88889],
  2818. "9132": [0.65002, 1.15, 0, 0, 0.88889],
  2819. "9133": [0.90001, 0, 0, 0, 0.88889],
  2820. "9143": [0.88502, 0.915, 0, 0, 1.05556],
  2821. "10216": [1.25003, 1.75, 0, 0, 0.80556],
  2822. "10217": [1.25003, 1.75, 0, 0, 0.80556],
  2823. "57344": [-0.00499, 0.605, 0, 0, 1.05556],
  2824. "57345": [-0.00499, 0.605, 0, 0, 1.05556],
  2825. "57680": [0, 0.12, 0, 0, 0.45],
  2826. "57681": [0, 0.12, 0, 0, 0.45],
  2827. "57682": [0, 0.12, 0, 0, 0.45],
  2828. "57683": [0, 0.12, 0, 0, 0.45]
  2829. },
  2830. "Typewriter-Regular": {
  2831. "32": [0, 0, 0, 0, 0.525],
  2832. "33": [0, 0.61111, 0, 0, 0.525],
  2833. "34": [0, 0.61111, 0, 0, 0.525],
  2834. "35": [0, 0.61111, 0, 0, 0.525],
  2835. "36": [0.08333, 0.69444, 0, 0, 0.525],
  2836. "37": [0.08333, 0.69444, 0, 0, 0.525],
  2837. "38": [0, 0.61111, 0, 0, 0.525],
  2838. "39": [0, 0.61111, 0, 0, 0.525],
  2839. "40": [0.08333, 0.69444, 0, 0, 0.525],
  2840. "41": [0.08333, 0.69444, 0, 0, 0.525],
  2841. "42": [0, 0.52083, 0, 0, 0.525],
  2842. "43": [-0.08056, 0.53055, 0, 0, 0.525],
  2843. "44": [0.13889, 0.125, 0, 0, 0.525],
  2844. "45": [-0.08056, 0.53055, 0, 0, 0.525],
  2845. "46": [0, 0.125, 0, 0, 0.525],
  2846. "47": [0.08333, 0.69444, 0, 0, 0.525],
  2847. "48": [0, 0.61111, 0, 0, 0.525],
  2848. "49": [0, 0.61111, 0, 0, 0.525],
  2849. "50": [0, 0.61111, 0, 0, 0.525],
  2850. "51": [0, 0.61111, 0, 0, 0.525],
  2851. "52": [0, 0.61111, 0, 0, 0.525],
  2852. "53": [0, 0.61111, 0, 0, 0.525],
  2853. "54": [0, 0.61111, 0, 0, 0.525],
  2854. "55": [0, 0.61111, 0, 0, 0.525],
  2855. "56": [0, 0.61111, 0, 0, 0.525],
  2856. "57": [0, 0.61111, 0, 0, 0.525],
  2857. "58": [0, 0.43056, 0, 0, 0.525],
  2858. "59": [0.13889, 0.43056, 0, 0, 0.525],
  2859. "60": [-0.05556, 0.55556, 0, 0, 0.525],
  2860. "61": [-0.19549, 0.41562, 0, 0, 0.525],
  2861. "62": [-0.05556, 0.55556, 0, 0, 0.525],
  2862. "63": [0, 0.61111, 0, 0, 0.525],
  2863. "64": [0, 0.61111, 0, 0, 0.525],
  2864. "65": [0, 0.61111, 0, 0, 0.525],
  2865. "66": [0, 0.61111, 0, 0, 0.525],
  2866. "67": [0, 0.61111, 0, 0, 0.525],
  2867. "68": [0, 0.61111, 0, 0, 0.525],
  2868. "69": [0, 0.61111, 0, 0, 0.525],
  2869. "70": [0, 0.61111, 0, 0, 0.525],
  2870. "71": [0, 0.61111, 0, 0, 0.525],
  2871. "72": [0, 0.61111, 0, 0, 0.525],
  2872. "73": [0, 0.61111, 0, 0, 0.525],
  2873. "74": [0, 0.61111, 0, 0, 0.525],
  2874. "75": [0, 0.61111, 0, 0, 0.525],
  2875. "76": [0, 0.61111, 0, 0, 0.525],
  2876. "77": [0, 0.61111, 0, 0, 0.525],
  2877. "78": [0, 0.61111, 0, 0, 0.525],
  2878. "79": [0, 0.61111, 0, 0, 0.525],
  2879. "80": [0, 0.61111, 0, 0, 0.525],
  2880. "81": [0.13889, 0.61111, 0, 0, 0.525],
  2881. "82": [0, 0.61111, 0, 0, 0.525],
  2882. "83": [0, 0.61111, 0, 0, 0.525],
  2883. "84": [0, 0.61111, 0, 0, 0.525],
  2884. "85": [0, 0.61111, 0, 0, 0.525],
  2885. "86": [0, 0.61111, 0, 0, 0.525],
  2886. "87": [0, 0.61111, 0, 0, 0.525],
  2887. "88": [0, 0.61111, 0, 0, 0.525],
  2888. "89": [0, 0.61111, 0, 0, 0.525],
  2889. "90": [0, 0.61111, 0, 0, 0.525],
  2890. "91": [0.08333, 0.69444, 0, 0, 0.525],
  2891. "92": [0.08333, 0.69444, 0, 0, 0.525],
  2892. "93": [0.08333, 0.69444, 0, 0, 0.525],
  2893. "94": [0, 0.61111, 0, 0, 0.525],
  2894. "95": [0.09514, 0, 0, 0, 0.525],
  2895. "96": [0, 0.61111, 0, 0, 0.525],
  2896. "97": [0, 0.43056, 0, 0, 0.525],
  2897. "98": [0, 0.61111, 0, 0, 0.525],
  2898. "99": [0, 0.43056, 0, 0, 0.525],
  2899. "100": [0, 0.61111, 0, 0, 0.525],
  2900. "101": [0, 0.43056, 0, 0, 0.525],
  2901. "102": [0, 0.61111, 0, 0, 0.525],
  2902. "103": [0.22222, 0.43056, 0, 0, 0.525],
  2903. "104": [0, 0.61111, 0, 0, 0.525],
  2904. "105": [0, 0.61111, 0, 0, 0.525],
  2905. "106": [0.22222, 0.61111, 0, 0, 0.525],
  2906. "107": [0, 0.61111, 0, 0, 0.525],
  2907. "108": [0, 0.61111, 0, 0, 0.525],
  2908. "109": [0, 0.43056, 0, 0, 0.525],
  2909. "110": [0, 0.43056, 0, 0, 0.525],
  2910. "111": [0, 0.43056, 0, 0, 0.525],
  2911. "112": [0.22222, 0.43056, 0, 0, 0.525],
  2912. "113": [0.22222, 0.43056, 0, 0, 0.525],
  2913. "114": [0, 0.43056, 0, 0, 0.525],
  2914. "115": [0, 0.43056, 0, 0, 0.525],
  2915. "116": [0, 0.55358, 0, 0, 0.525],
  2916. "117": [0, 0.43056, 0, 0, 0.525],
  2917. "118": [0, 0.43056, 0, 0, 0.525],
  2918. "119": [0, 0.43056, 0, 0, 0.525],
  2919. "120": [0, 0.43056, 0, 0, 0.525],
  2920. "121": [0.22222, 0.43056, 0, 0, 0.525],
  2921. "122": [0, 0.43056, 0, 0, 0.525],
  2922. "123": [0.08333, 0.69444, 0, 0, 0.525],
  2923. "124": [0.08333, 0.69444, 0, 0, 0.525],
  2924. "125": [0.08333, 0.69444, 0, 0, 0.525],
  2925. "126": [0, 0.61111, 0, 0, 0.525],
  2926. "127": [0, 0.61111, 0, 0, 0.525],
  2927. "160": [0, 0, 0, 0, 0.525],
  2928. "176": [0, 0.61111, 0, 0, 0.525],
  2929. "184": [0.19445, 0, 0, 0, 0.525],
  2930. "305": [0, 0.43056, 0, 0, 0.525],
  2931. "567": [0.22222, 0.43056, 0, 0, 0.525],
  2932. "711": [0, 0.56597, 0, 0, 0.525],
  2933. "713": [0, 0.56555, 0, 0, 0.525],
  2934. "714": [0, 0.61111, 0, 0, 0.525],
  2935. "715": [0, 0.61111, 0, 0, 0.525],
  2936. "728": [0, 0.61111, 0, 0, 0.525],
  2937. "730": [0, 0.61111, 0, 0, 0.525],
  2938. "770": [0, 0.61111, 0, 0, 0.525],
  2939. "771": [0, 0.61111, 0, 0, 0.525],
  2940. "776": [0, 0.61111, 0, 0, 0.525],
  2941. "915": [0, 0.61111, 0, 0, 0.525],
  2942. "916": [0, 0.61111, 0, 0, 0.525],
  2943. "920": [0, 0.61111, 0, 0, 0.525],
  2944. "923": [0, 0.61111, 0, 0, 0.525],
  2945. "926": [0, 0.61111, 0, 0, 0.525],
  2946. "928": [0, 0.61111, 0, 0, 0.525],
  2947. "931": [0, 0.61111, 0, 0, 0.525],
  2948. "933": [0, 0.61111, 0, 0, 0.525],
  2949. "934": [0, 0.61111, 0, 0, 0.525],
  2950. "936": [0, 0.61111, 0, 0, 0.525],
  2951. "937": [0, 0.61111, 0, 0, 0.525],
  2952. "8216": [0, 0.61111, 0, 0, 0.525],
  2953. "8217": [0, 0.61111, 0, 0, 0.525],
  2954. "8242": [0, 0.61111, 0, 0, 0.525],
  2955. "9251": [0.11111, 0.21944, 0, 0, 0.525]
  2956. }
  2957. });
  2958. ;// CONCATENATED MODULE: ./src/fontMetrics.js
  2959. /**
  2960. * This file contains metrics regarding fonts and individual symbols. The sigma
  2961. * and xi variables, as well as the metricMap map contain data extracted from
  2962. * TeX, TeX font metrics, and the TTF files. These data are then exposed via the
  2963. * `metrics` variable and the getCharacterMetrics function.
  2964. */
  2965. // In TeX, there are actually three sets of dimensions, one for each of
  2966. // textstyle (size index 5 and higher: >=9pt), scriptstyle (size index 3 and 4:
  2967. // 7-8pt), and scriptscriptstyle (size index 1 and 2: 5-6pt). These are
  2968. // provided in the the arrays below, in that order.
  2969. //
  2970. // The font metrics are stored in fonts cmsy10, cmsy7, and cmsy5 respsectively.
  2971. // This was determined by running the following script:
  2972. //
  2973. // latex -interaction=nonstopmode \
  2974. // '\documentclass{article}\usepackage{amsmath}\begin{document}' \
  2975. // '$a$ \expandafter\show\the\textfont2' \
  2976. // '\expandafter\show\the\scriptfont2' \
  2977. // '\expandafter\show\the\scriptscriptfont2' \
  2978. // '\stop'
  2979. //
  2980. // The metrics themselves were retreived using the following commands:
  2981. //
  2982. // tftopl cmsy10
  2983. // tftopl cmsy7
  2984. // tftopl cmsy5
  2985. //
  2986. // The output of each of these commands is quite lengthy. The only part we
  2987. // care about is the FONTDIMEN section. Each value is measured in EMs.
  2988. var sigmasAndXis = {
  2989. slant: [0.250, 0.250, 0.250],
  2990. // sigma1
  2991. space: [0.000, 0.000, 0.000],
  2992. // sigma2
  2993. stretch: [0.000, 0.000, 0.000],
  2994. // sigma3
  2995. shrink: [0.000, 0.000, 0.000],
  2996. // sigma4
  2997. xHeight: [0.431, 0.431, 0.431],
  2998. // sigma5
  2999. quad: [1.000, 1.171, 1.472],
  3000. // sigma6
  3001. extraSpace: [0.000, 0.000, 0.000],
  3002. // sigma7
  3003. num1: [0.677, 0.732, 0.925],
  3004. // sigma8
  3005. num2: [0.394, 0.384, 0.387],
  3006. // sigma9
  3007. num3: [0.444, 0.471, 0.504],
  3008. // sigma10
  3009. denom1: [0.686, 0.752, 1.025],
  3010. // sigma11
  3011. denom2: [0.345, 0.344, 0.532],
  3012. // sigma12
  3013. sup1: [0.413, 0.503, 0.504],
  3014. // sigma13
  3015. sup2: [0.363, 0.431, 0.404],
  3016. // sigma14
  3017. sup3: [0.289, 0.286, 0.294],
  3018. // sigma15
  3019. sub1: [0.150, 0.143, 0.200],
  3020. // sigma16
  3021. sub2: [0.247, 0.286, 0.400],
  3022. // sigma17
  3023. supDrop: [0.386, 0.353, 0.494],
  3024. // sigma18
  3025. subDrop: [0.050, 0.071, 0.100],
  3026. // sigma19
  3027. delim1: [2.390, 1.700, 1.980],
  3028. // sigma20
  3029. delim2: [1.010, 1.157, 1.420],
  3030. // sigma21
  3031. axisHeight: [0.250, 0.250, 0.250],
  3032. // sigma22
  3033. // These font metrics are extracted from TeX by using tftopl on cmex10.tfm;
  3034. // they correspond to the font parameters of the extension fonts (family 3).
  3035. // See the TeXbook, page 441. In AMSTeX, the extension fonts scale; to
  3036. // match cmex7, we'd use cmex7.tfm values for script and scriptscript
  3037. // values.
  3038. defaultRuleThickness: [0.04, 0.049, 0.049],
  3039. // xi8; cmex7: 0.049
  3040. bigOpSpacing1: [0.111, 0.111, 0.111],
  3041. // xi9
  3042. bigOpSpacing2: [0.166, 0.166, 0.166],
  3043. // xi10
  3044. bigOpSpacing3: [0.2, 0.2, 0.2],
  3045. // xi11
  3046. bigOpSpacing4: [0.6, 0.611, 0.611],
  3047. // xi12; cmex7: 0.611
  3048. bigOpSpacing5: [0.1, 0.143, 0.143],
  3049. // xi13; cmex7: 0.143
  3050. // The \sqrt rule width is taken from the height of the surd character.
  3051. // Since we use the same font at all sizes, this thickness doesn't scale.
  3052. sqrtRuleThickness: [0.04, 0.04, 0.04],
  3053. // This value determines how large a pt is, for metrics which are defined
  3054. // in terms of pts.
  3055. // This value is also used in katex.less; if you change it make sure the
  3056. // values match.
  3057. ptPerEm: [10.0, 10.0, 10.0],
  3058. // The space between adjacent `|` columns in an array definition. From
  3059. // `\showthe\doublerulesep` in LaTeX. Equals 2.0 / ptPerEm.
  3060. doubleRuleSep: [0.2, 0.2, 0.2],
  3061. // The width of separator lines in {array} environments. From
  3062. // `\showthe\arrayrulewidth` in LaTeX. Equals 0.4 / ptPerEm.
  3063. arrayRuleWidth: [0.04, 0.04, 0.04],
  3064. // Two values from LaTeX source2e:
  3065. fboxsep: [0.3, 0.3, 0.3],
  3066. // 3 pt / ptPerEm
  3067. fboxrule: [0.04, 0.04, 0.04] // 0.4 pt / ptPerEm
  3068. }; // This map contains a mapping from font name and character code to character
  3069. // metrics, including height, depth, italic correction, and skew (kern from the
  3070. // character to the corresponding \skewchar)
  3071. // This map is generated via `make metrics`. It should not be changed manually.
  3072. // These are very rough approximations. We default to Times New Roman which
  3073. // should have Latin-1 and Cyrillic characters, but may not depending on the
  3074. // operating system. The metrics do not account for extra height from the
  3075. // accents. In the case of Cyrillic characters which have both ascenders and
  3076. // descenders we prefer approximations with ascenders, primarily to prevent
  3077. // the fraction bar or root line from intersecting the glyph.
  3078. // TODO(kevinb) allow union of multiple glyph metrics for better accuracy.
  3079. var extraCharacterMap = {
  3080. // Latin-1
  3081. 'Å': 'A',
  3082. 'Ð': 'D',
  3083. 'Þ': 'o',
  3084. 'å': 'a',
  3085. 'ð': 'd',
  3086. 'þ': 'o',
  3087. // Cyrillic
  3088. 'А': 'A',
  3089. 'Б': 'B',
  3090. 'В': 'B',
  3091. 'Г': 'F',
  3092. 'Д': 'A',
  3093. 'Е': 'E',
  3094. 'Ж': 'K',
  3095. 'З': '3',
  3096. 'И': 'N',
  3097. 'Й': 'N',
  3098. 'К': 'K',
  3099. 'Л': 'N',
  3100. 'М': 'M',
  3101. 'Н': 'H',
  3102. 'О': 'O',
  3103. 'П': 'N',
  3104. 'Р': 'P',
  3105. 'С': 'C',
  3106. 'Т': 'T',
  3107. 'У': 'y',
  3108. 'Ф': 'O',
  3109. 'Х': 'X',
  3110. 'Ц': 'U',
  3111. 'Ч': 'h',
  3112. 'Ш': 'W',
  3113. 'Щ': 'W',
  3114. 'Ъ': 'B',
  3115. 'Ы': 'X',
  3116. 'Ь': 'B',
  3117. 'Э': '3',
  3118. 'Ю': 'X',
  3119. 'Я': 'R',
  3120. 'а': 'a',
  3121. 'б': 'b',
  3122. 'в': 'a',
  3123. 'г': 'r',
  3124. 'д': 'y',
  3125. 'е': 'e',
  3126. 'ж': 'm',
  3127. 'з': 'e',
  3128. 'и': 'n',
  3129. 'й': 'n',
  3130. 'к': 'n',
  3131. 'л': 'n',
  3132. 'м': 'm',
  3133. 'н': 'n',
  3134. 'о': 'o',
  3135. 'п': 'n',
  3136. 'р': 'p',
  3137. 'с': 'c',
  3138. 'т': 'o',
  3139. 'у': 'y',
  3140. 'ф': 'b',
  3141. 'х': 'x',
  3142. 'ц': 'n',
  3143. 'ч': 'n',
  3144. 'ш': 'w',
  3145. 'щ': 'w',
  3146. 'ъ': 'a',
  3147. 'ы': 'm',
  3148. 'ь': 'a',
  3149. 'э': 'e',
  3150. 'ю': 'm',
  3151. 'я': 'r'
  3152. };
  3153. /**
  3154. * This function adds new font metrics to default metricMap
  3155. * It can also override existing metrics
  3156. */
  3157. function setFontMetrics(fontName, metrics) {
  3158. fontMetricsData[fontName] = metrics;
  3159. }
  3160. /**
  3161. * This function is a convenience function for looking up information in the
  3162. * metricMap table. It takes a character as a string, and a font.
  3163. *
  3164. * Note: the `width` property may be undefined if fontMetricsData.js wasn't
  3165. * built using `Make extended_metrics`.
  3166. */
  3167. function getCharacterMetrics(character, font, mode) {
  3168. if (!fontMetricsData[font]) {
  3169. throw new Error("Font metrics not found for font: " + font + ".");
  3170. }
  3171. var ch = character.charCodeAt(0);
  3172. var metrics = fontMetricsData[font][ch];
  3173. if (!metrics && character[0] in extraCharacterMap) {
  3174. ch = extraCharacterMap[character[0]].charCodeAt(0);
  3175. metrics = fontMetricsData[font][ch];
  3176. }
  3177. if (!metrics && mode === 'text') {
  3178. // We don't typically have font metrics for Asian scripts.
  3179. // But since we support them in text mode, we need to return
  3180. // some sort of metrics.
  3181. // So if the character is in a script we support but we
  3182. // don't have metrics for it, just use the metrics for
  3183. // the Latin capital letter M. This is close enough because
  3184. // we (currently) only care about the height of the glpyh
  3185. // not its width.
  3186. if (supportedCodepoint(ch)) {
  3187. metrics = fontMetricsData[font][77]; // 77 is the charcode for 'M'
  3188. }
  3189. }
  3190. if (metrics) {
  3191. return {
  3192. depth: metrics[0],
  3193. height: metrics[1],
  3194. italic: metrics[2],
  3195. skew: metrics[3],
  3196. width: metrics[4]
  3197. };
  3198. }
  3199. }
  3200. var fontMetricsBySizeIndex = {};
  3201. /**
  3202. * Get the font metrics for a given size.
  3203. */
  3204. function getGlobalMetrics(size) {
  3205. var sizeIndex;
  3206. if (size >= 5) {
  3207. sizeIndex = 0;
  3208. } else if (size >= 3) {
  3209. sizeIndex = 1;
  3210. } else {
  3211. sizeIndex = 2;
  3212. }
  3213. if (!fontMetricsBySizeIndex[sizeIndex]) {
  3214. var metrics = fontMetricsBySizeIndex[sizeIndex] = {
  3215. cssEmPerMu: sigmasAndXis.quad[sizeIndex] / 18
  3216. };
  3217. for (var key in sigmasAndXis) {
  3218. if (sigmasAndXis.hasOwnProperty(key)) {
  3219. metrics[key] = sigmasAndXis[key][sizeIndex];
  3220. }
  3221. }
  3222. }
  3223. return fontMetricsBySizeIndex[sizeIndex];
  3224. }
  3225. ;// CONCATENATED MODULE: ./src/Options.js
  3226. /**
  3227. * This file contains information about the options that the Parser carries
  3228. * around with it while parsing. Data is held in an `Options` object, and when
  3229. * recursing, a new `Options` object can be created with the `.with*` and
  3230. * `.reset` functions.
  3231. */
  3232. var sizeStyleMap = [// Each element contains [textsize, scriptsize, scriptscriptsize].
  3233. // The size mappings are taken from TeX with \normalsize=10pt.
  3234. [1, 1, 1], // size1: [5, 5, 5] \tiny
  3235. [2, 1, 1], // size2: [6, 5, 5]
  3236. [3, 1, 1], // size3: [7, 5, 5] \scriptsize
  3237. [4, 2, 1], // size4: [8, 6, 5] \footnotesize
  3238. [5, 2, 1], // size5: [9, 6, 5] \small
  3239. [6, 3, 1], // size6: [10, 7, 5] \normalsize
  3240. [7, 4, 2], // size7: [12, 8, 6] \large
  3241. [8, 6, 3], // size8: [14.4, 10, 7] \Large
  3242. [9, 7, 6], // size9: [17.28, 12, 10] \LARGE
  3243. [10, 8, 7], // size10: [20.74, 14.4, 12] \huge
  3244. [11, 10, 9] // size11: [24.88, 20.74, 17.28] \HUGE
  3245. ];
  3246. var sizeMultipliers = [// fontMetrics.js:getGlobalMetrics also uses size indexes, so if
  3247. // you change size indexes, change that function.
  3248. 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.2, 1.44, 1.728, 2.074, 2.488];
  3249. var sizeAtStyle = function sizeAtStyle(size, style) {
  3250. return style.size < 2 ? size : sizeStyleMap[size - 1][style.size - 1];
  3251. }; // In these types, "" (empty string) means "no change".
  3252. /**
  3253. * This is the main options class. It contains the current style, size, color,
  3254. * and font.
  3255. *
  3256. * Options objects should not be modified. To create a new Options with
  3257. * different properties, call a `.having*` method.
  3258. */
  3259. var Options = /*#__PURE__*/function () {
  3260. // A font family applies to a group of fonts (i.e. SansSerif), while a font
  3261. // represents a specific font (i.e. SansSerif Bold).
  3262. // See: https://tex.stackexchange.com/questions/22350/difference-between-textrm-and-mathrm
  3263. /**
  3264. * The base size index.
  3265. */
  3266. function Options(data) {
  3267. this.style = void 0;
  3268. this.color = void 0;
  3269. this.size = void 0;
  3270. this.textSize = void 0;
  3271. this.phantom = void 0;
  3272. this.font = void 0;
  3273. this.fontFamily = void 0;
  3274. this.fontWeight = void 0;
  3275. this.fontShape = void 0;
  3276. this.sizeMultiplier = void 0;
  3277. this.maxSize = void 0;
  3278. this.minRuleThickness = void 0;
  3279. this._fontMetrics = void 0;
  3280. this.style = data.style;
  3281. this.color = data.color;
  3282. this.size = data.size || Options.BASESIZE;
  3283. this.textSize = data.textSize || this.size;
  3284. this.phantom = !!data.phantom;
  3285. this.font = data.font || "";
  3286. this.fontFamily = data.fontFamily || "";
  3287. this.fontWeight = data.fontWeight || '';
  3288. this.fontShape = data.fontShape || '';
  3289. this.sizeMultiplier = sizeMultipliers[this.size - 1];
  3290. this.maxSize = data.maxSize;
  3291. this.minRuleThickness = data.minRuleThickness;
  3292. this._fontMetrics = undefined;
  3293. }
  3294. /**
  3295. * Returns a new options object with the same properties as "this". Properties
  3296. * from "extension" will be copied to the new options object.
  3297. */
  3298. var _proto = Options.prototype;
  3299. _proto.extend = function extend(extension) {
  3300. var data = {
  3301. style: this.style,
  3302. size: this.size,
  3303. textSize: this.textSize,
  3304. color: this.color,
  3305. phantom: this.phantom,
  3306. font: this.font,
  3307. fontFamily: this.fontFamily,
  3308. fontWeight: this.fontWeight,
  3309. fontShape: this.fontShape,
  3310. maxSize: this.maxSize,
  3311. minRuleThickness: this.minRuleThickness
  3312. };
  3313. for (var key in extension) {
  3314. if (extension.hasOwnProperty(key)) {
  3315. data[key] = extension[key];
  3316. }
  3317. }
  3318. return new Options(data);
  3319. }
  3320. /**
  3321. * Return an options object with the given style. If `this.style === style`,
  3322. * returns `this`.
  3323. */
  3324. ;
  3325. _proto.havingStyle = function havingStyle(style) {
  3326. if (this.style === style) {
  3327. return this;
  3328. } else {
  3329. return this.extend({
  3330. style: style,
  3331. size: sizeAtStyle(this.textSize, style)
  3332. });
  3333. }
  3334. }
  3335. /**
  3336. * Return an options object with a cramped version of the current style. If
  3337. * the current style is cramped, returns `this`.
  3338. */
  3339. ;
  3340. _proto.havingCrampedStyle = function havingCrampedStyle() {
  3341. return this.havingStyle(this.style.cramp());
  3342. }
  3343. /**
  3344. * Return an options object with the given size and in at least `\textstyle`.
  3345. * Returns `this` if appropriate.
  3346. */
  3347. ;
  3348. _proto.havingSize = function havingSize(size) {
  3349. if (this.size === size && this.textSize === size) {
  3350. return this;
  3351. } else {
  3352. return this.extend({
  3353. style: this.style.text(),
  3354. size: size,
  3355. textSize: size,
  3356. sizeMultiplier: sizeMultipliers[size - 1]
  3357. });
  3358. }
  3359. }
  3360. /**
  3361. * Like `this.havingSize(BASESIZE).havingStyle(style)`. If `style` is omitted,
  3362. * changes to at least `\textstyle`.
  3363. */
  3364. ;
  3365. _proto.havingBaseStyle = function havingBaseStyle(style) {
  3366. style = style || this.style.text();
  3367. var wantSize = sizeAtStyle(Options.BASESIZE, style);
  3368. if (this.size === wantSize && this.textSize === Options.BASESIZE && this.style === style) {
  3369. return this;
  3370. } else {
  3371. return this.extend({
  3372. style: style,
  3373. size: wantSize
  3374. });
  3375. }
  3376. }
  3377. /**
  3378. * Remove the effect of sizing changes such as \Huge.
  3379. * Keep the effect of the current style, such as \scriptstyle.
  3380. */
  3381. ;
  3382. _proto.havingBaseSizing = function havingBaseSizing() {
  3383. var size;
  3384. switch (this.style.id) {
  3385. case 4:
  3386. case 5:
  3387. size = 3; // normalsize in scriptstyle
  3388. break;
  3389. case 6:
  3390. case 7:
  3391. size = 1; // normalsize in scriptscriptstyle
  3392. break;
  3393. default:
  3394. size = 6;
  3395. // normalsize in textstyle or displaystyle
  3396. }
  3397. return this.extend({
  3398. style: this.style.text(),
  3399. size: size
  3400. });
  3401. }
  3402. /**
  3403. * Create a new options object with the given color.
  3404. */
  3405. ;
  3406. _proto.withColor = function withColor(color) {
  3407. return this.extend({
  3408. color: color
  3409. });
  3410. }
  3411. /**
  3412. * Create a new options object with "phantom" set to true.
  3413. */
  3414. ;
  3415. _proto.withPhantom = function withPhantom() {
  3416. return this.extend({
  3417. phantom: true
  3418. });
  3419. }
  3420. /**
  3421. * Creates a new options object with the given math font or old text font.
  3422. * @type {[type]}
  3423. */
  3424. ;
  3425. _proto.withFont = function withFont(font) {
  3426. return this.extend({
  3427. font: font
  3428. });
  3429. }
  3430. /**
  3431. * Create a new options objects with the given fontFamily.
  3432. */
  3433. ;
  3434. _proto.withTextFontFamily = function withTextFontFamily(fontFamily) {
  3435. return this.extend({
  3436. fontFamily: fontFamily,
  3437. font: ""
  3438. });
  3439. }
  3440. /**
  3441. * Creates a new options object with the given font weight
  3442. */
  3443. ;
  3444. _proto.withTextFontWeight = function withTextFontWeight(fontWeight) {
  3445. return this.extend({
  3446. fontWeight: fontWeight,
  3447. font: ""
  3448. });
  3449. }
  3450. /**
  3451. * Creates a new options object with the given font weight
  3452. */
  3453. ;
  3454. _proto.withTextFontShape = function withTextFontShape(fontShape) {
  3455. return this.extend({
  3456. fontShape: fontShape,
  3457. font: ""
  3458. });
  3459. }
  3460. /**
  3461. * Return the CSS sizing classes required to switch from enclosing options
  3462. * `oldOptions` to `this`. Returns an array of classes.
  3463. */
  3464. ;
  3465. _proto.sizingClasses = function sizingClasses(oldOptions) {
  3466. if (oldOptions.size !== this.size) {
  3467. return ["sizing", "reset-size" + oldOptions.size, "size" + this.size];
  3468. } else {
  3469. return [];
  3470. }
  3471. }
  3472. /**
  3473. * Return the CSS sizing classes required to switch to the base size. Like
  3474. * `this.havingSize(BASESIZE).sizingClasses(this)`.
  3475. */
  3476. ;
  3477. _proto.baseSizingClasses = function baseSizingClasses() {
  3478. if (this.size !== Options.BASESIZE) {
  3479. return ["sizing", "reset-size" + this.size, "size" + Options.BASESIZE];
  3480. } else {
  3481. return [];
  3482. }
  3483. }
  3484. /**
  3485. * Return the font metrics for this size.
  3486. */
  3487. ;
  3488. _proto.fontMetrics = function fontMetrics() {
  3489. if (!this._fontMetrics) {
  3490. this._fontMetrics = getGlobalMetrics(this.size);
  3491. }
  3492. return this._fontMetrics;
  3493. }
  3494. /**
  3495. * Gets the CSS color of the current options object
  3496. */
  3497. ;
  3498. _proto.getColor = function getColor() {
  3499. if (this.phantom) {
  3500. return "transparent";
  3501. } else {
  3502. return this.color;
  3503. }
  3504. };
  3505. return Options;
  3506. }();
  3507. Options.BASESIZE = 6;
  3508. /* harmony default export */ var src_Options = (Options);
  3509. ;// CONCATENATED MODULE: ./src/units.js
  3510. /**
  3511. * This file does conversion between units. In particular, it provides
  3512. * calculateSize to convert other units into ems.
  3513. */
  3514. // This table gives the number of TeX pts in one of each *absolute* TeX unit.
  3515. // Thus, multiplying a length by this number converts the length from units
  3516. // into pts. Dividing the result by ptPerEm gives the number of ems
  3517. // *assuming* a font size of ptPerEm (normal size, normal style).
  3518. var ptPerUnit = {
  3519. // https://en.wikibooks.org/wiki/LaTeX/Lengths and
  3520. // https://tex.stackexchange.com/a/8263
  3521. "pt": 1,
  3522. // TeX point
  3523. "mm": 7227 / 2540,
  3524. // millimeter
  3525. "cm": 7227 / 254,
  3526. // centimeter
  3527. "in": 72.27,
  3528. // inch
  3529. "bp": 803 / 800,
  3530. // big (PostScript) points
  3531. "pc": 12,
  3532. // pica
  3533. "dd": 1238 / 1157,
  3534. // didot
  3535. "cc": 14856 / 1157,
  3536. // cicero (12 didot)
  3537. "nd": 685 / 642,
  3538. // new didot
  3539. "nc": 1370 / 107,
  3540. // new cicero (12 new didot)
  3541. "sp": 1 / 65536,
  3542. // scaled point (TeX's internal smallest unit)
  3543. // https://tex.stackexchange.com/a/41371
  3544. "px": 803 / 800 // \pdfpxdimen defaults to 1 bp in pdfTeX and LuaTeX
  3545. }; // Dictionary of relative units, for fast validity testing.
  3546. var relativeUnit = {
  3547. "ex": true,
  3548. "em": true,
  3549. "mu": true
  3550. };
  3551. /**
  3552. * Determine whether the specified unit (either a string defining the unit
  3553. * or a "size" parse node containing a unit field) is valid.
  3554. */
  3555. var validUnit = function validUnit(unit) {
  3556. if (typeof unit !== "string") {
  3557. unit = unit.unit;
  3558. }
  3559. return unit in ptPerUnit || unit in relativeUnit || unit === "ex";
  3560. };
  3561. /*
  3562. * Convert a "size" parse node (with numeric "number" and string "unit" fields,
  3563. * as parsed by functions.js argType "size") into a CSS em value for the
  3564. * current style/scale. `options` gives the current options.
  3565. */
  3566. var calculateSize = function calculateSize(sizeValue, options) {
  3567. var scale;
  3568. if (sizeValue.unit in ptPerUnit) {
  3569. // Absolute units
  3570. scale = ptPerUnit[sizeValue.unit] // Convert unit to pt
  3571. / options.fontMetrics().ptPerEm // Convert pt to CSS em
  3572. / options.sizeMultiplier; // Unscale to make absolute units
  3573. } else if (sizeValue.unit === "mu") {
  3574. // `mu` units scale with scriptstyle/scriptscriptstyle.
  3575. scale = options.fontMetrics().cssEmPerMu;
  3576. } else {
  3577. // Other relative units always refer to the *textstyle* font
  3578. // in the current size.
  3579. var unitOptions;
  3580. if (options.style.isTight()) {
  3581. // isTight() means current style is script/scriptscript.
  3582. unitOptions = options.havingStyle(options.style.text());
  3583. } else {
  3584. unitOptions = options;
  3585. } // TODO: In TeX these units are relative to the quad of the current
  3586. // *text* font, e.g. cmr10. KaTeX instead uses values from the
  3587. // comparably-sized *Computer Modern symbol* font. At 10pt, these
  3588. // match. At 7pt and 5pt, they differ: cmr7=1.138894, cmsy7=1.170641;
  3589. // cmr5=1.361133, cmsy5=1.472241. Consider $\scriptsize a\kern1emb$.
  3590. // TeX \showlists shows a kern of 1.13889 * fontsize;
  3591. // KaTeX shows a kern of 1.171 * fontsize.
  3592. if (sizeValue.unit === "ex") {
  3593. scale = unitOptions.fontMetrics().xHeight;
  3594. } else if (sizeValue.unit === "em") {
  3595. scale = unitOptions.fontMetrics().quad;
  3596. } else {
  3597. throw new src_ParseError("Invalid unit: '" + sizeValue.unit + "'");
  3598. }
  3599. if (unitOptions !== options) {
  3600. scale *= unitOptions.sizeMultiplier / options.sizeMultiplier;
  3601. }
  3602. }
  3603. return Math.min(sizeValue.number * scale, options.maxSize);
  3604. };
  3605. /**
  3606. * Round `n` to 4 decimal places, or to the nearest 1/10,000th em. See
  3607. * https://github.com/KaTeX/KaTeX/pull/2460.
  3608. */
  3609. var makeEm = function makeEm(n) {
  3610. return +n.toFixed(4) + "em";
  3611. };
  3612. ;// CONCATENATED MODULE: ./src/domTree.js
  3613. /**
  3614. * These objects store the data about the DOM nodes we create, as well as some
  3615. * extra data. They can then be transformed into real DOM nodes with the
  3616. * `toNode` function or HTML markup using `toMarkup`. They are useful for both
  3617. * storing extra properties on the nodes, as well as providing a way to easily
  3618. * work with the DOM.
  3619. *
  3620. * Similar functions for working with MathML nodes exist in mathMLTree.js.
  3621. *
  3622. * TODO: refactor `span` and `anchor` into common superclass when
  3623. * target environments support class inheritance
  3624. */
  3625. /**
  3626. * Create an HTML className based on a list of classes. In addition to joining
  3627. * with spaces, we also remove empty classes.
  3628. */
  3629. var createClass = function createClass(classes) {
  3630. return classes.filter(function (cls) {
  3631. return cls;
  3632. }).join(" ");
  3633. };
  3634. var initNode = function initNode(classes, options, style) {
  3635. this.classes = classes || [];
  3636. this.attributes = {};
  3637. this.height = 0;
  3638. this.depth = 0;
  3639. this.maxFontSize = 0;
  3640. this.style = style || {};
  3641. if (options) {
  3642. if (options.style.isTight()) {
  3643. this.classes.push("mtight");
  3644. }
  3645. var color = options.getColor();
  3646. if (color) {
  3647. this.style.color = color;
  3648. }
  3649. }
  3650. };
  3651. /**
  3652. * Convert into an HTML node
  3653. */
  3654. var _toNode = function toNode(tagName) {
  3655. var node = document.createElement(tagName); // Apply the class
  3656. node.className = createClass(this.classes); // Apply inline styles
  3657. for (var style in this.style) {
  3658. if (this.style.hasOwnProperty(style)) {
  3659. // $FlowFixMe Flow doesn't seem to understand span.style's type.
  3660. node.style[style] = this.style[style];
  3661. }
  3662. } // Apply attributes
  3663. for (var attr in this.attributes) {
  3664. if (this.attributes.hasOwnProperty(attr)) {
  3665. node.setAttribute(attr, this.attributes[attr]);
  3666. }
  3667. } // Append the children, also as HTML nodes
  3668. for (var i = 0; i < this.children.length; i++) {
  3669. node.appendChild(this.children[i].toNode());
  3670. }
  3671. return node;
  3672. };
  3673. /**
  3674. * Convert into an HTML markup string
  3675. */
  3676. var _toMarkup = function toMarkup(tagName) {
  3677. var markup = "<" + tagName; // Add the class
  3678. if (this.classes.length) {
  3679. markup += " class=\"" + utils.escape(createClass(this.classes)) + "\"";
  3680. }
  3681. var styles = ""; // Add the styles, after hyphenation
  3682. for (var style in this.style) {
  3683. if (this.style.hasOwnProperty(style)) {
  3684. styles += utils.hyphenate(style) + ":" + this.style[style] + ";";
  3685. }
  3686. }
  3687. if (styles) {
  3688. markup += " style=\"" + utils.escape(styles) + "\"";
  3689. } // Add the attributes
  3690. for (var attr in this.attributes) {
  3691. if (this.attributes.hasOwnProperty(attr)) {
  3692. markup += " " + attr + "=\"" + utils.escape(this.attributes[attr]) + "\"";
  3693. }
  3694. }
  3695. markup += ">"; // Add the markup of the children, also as markup
  3696. for (var i = 0; i < this.children.length; i++) {
  3697. markup += this.children[i].toMarkup();
  3698. }
  3699. markup += "</" + tagName + ">";
  3700. return markup;
  3701. }; // Making the type below exact with all optional fields doesn't work due to
  3702. // - https://github.com/facebook/flow/issues/4582
  3703. // - https://github.com/facebook/flow/issues/5688
  3704. // However, since *all* fields are optional, $Shape<> works as suggested in 5688
  3705. // above.
  3706. // This type does not include all CSS properties. Additional properties should
  3707. // be added as needed.
  3708. /**
  3709. * This node represents a span node, with a className, a list of children, and
  3710. * an inline style. It also contains information about its height, depth, and
  3711. * maxFontSize.
  3712. *
  3713. * Represents two types with different uses: SvgSpan to wrap an SVG and DomSpan
  3714. * otherwise. This typesafety is important when HTML builders access a span's
  3715. * children.
  3716. */
  3717. var Span = /*#__PURE__*/function () {
  3718. function Span(classes, children, options, style) {
  3719. this.children = void 0;
  3720. this.attributes = void 0;
  3721. this.classes = void 0;
  3722. this.height = void 0;
  3723. this.depth = void 0;
  3724. this.width = void 0;
  3725. this.maxFontSize = void 0;
  3726. this.style = void 0;
  3727. initNode.call(this, classes, options, style);
  3728. this.children = children || [];
  3729. }
  3730. /**
  3731. * Sets an arbitrary attribute on the span. Warning: use this wisely. Not
  3732. * all browsers support attributes the same, and having too many custom
  3733. * attributes is probably bad.
  3734. */
  3735. var _proto = Span.prototype;
  3736. _proto.setAttribute = function setAttribute(attribute, value) {
  3737. this.attributes[attribute] = value;
  3738. };
  3739. _proto.hasClass = function hasClass(className) {
  3740. return utils.contains(this.classes, className);
  3741. };
  3742. _proto.toNode = function toNode() {
  3743. return _toNode.call(this, "span");
  3744. };
  3745. _proto.toMarkup = function toMarkup() {
  3746. return _toMarkup.call(this, "span");
  3747. };
  3748. return Span;
  3749. }();
  3750. /**
  3751. * This node represents an anchor (<a>) element with a hyperlink. See `span`
  3752. * for further details.
  3753. */
  3754. var Anchor = /*#__PURE__*/function () {
  3755. function Anchor(href, classes, children, options) {
  3756. this.children = void 0;
  3757. this.attributes = void 0;
  3758. this.classes = void 0;
  3759. this.height = void 0;
  3760. this.depth = void 0;
  3761. this.maxFontSize = void 0;
  3762. this.style = void 0;
  3763. initNode.call(this, classes, options);
  3764. this.children = children || [];
  3765. this.setAttribute('href', href);
  3766. }
  3767. var _proto2 = Anchor.prototype;
  3768. _proto2.setAttribute = function setAttribute(attribute, value) {
  3769. this.attributes[attribute] = value;
  3770. };
  3771. _proto2.hasClass = function hasClass(className) {
  3772. return utils.contains(this.classes, className);
  3773. };
  3774. _proto2.toNode = function toNode() {
  3775. return _toNode.call(this, "a");
  3776. };
  3777. _proto2.toMarkup = function toMarkup() {
  3778. return _toMarkup.call(this, "a");
  3779. };
  3780. return Anchor;
  3781. }();
  3782. /**
  3783. * This node represents an image embed (<img>) element.
  3784. */
  3785. var Img = /*#__PURE__*/function () {
  3786. function Img(src, alt, style) {
  3787. this.src = void 0;
  3788. this.alt = void 0;
  3789. this.classes = void 0;
  3790. this.height = void 0;
  3791. this.depth = void 0;
  3792. this.maxFontSize = void 0;
  3793. this.style = void 0;
  3794. this.alt = alt;
  3795. this.src = src;
  3796. this.classes = ["mord"];
  3797. this.style = style;
  3798. }
  3799. var _proto3 = Img.prototype;
  3800. _proto3.hasClass = function hasClass(className) {
  3801. return utils.contains(this.classes, className);
  3802. };
  3803. _proto3.toNode = function toNode() {
  3804. var node = document.createElement("img");
  3805. node.src = this.src;
  3806. node.alt = this.alt;
  3807. node.className = "mord"; // Apply inline styles
  3808. for (var style in this.style) {
  3809. if (this.style.hasOwnProperty(style)) {
  3810. // $FlowFixMe
  3811. node.style[style] = this.style[style];
  3812. }
  3813. }
  3814. return node;
  3815. };
  3816. _proto3.toMarkup = function toMarkup() {
  3817. var markup = "<img src='" + this.src + " 'alt='" + this.alt + "' "; // Add the styles, after hyphenation
  3818. var styles = "";
  3819. for (var style in this.style) {
  3820. if (this.style.hasOwnProperty(style)) {
  3821. styles += utils.hyphenate(style) + ":" + this.style[style] + ";";
  3822. }
  3823. }
  3824. if (styles) {
  3825. markup += " style=\"" + utils.escape(styles) + "\"";
  3826. }
  3827. markup += "'/>";
  3828. return markup;
  3829. };
  3830. return Img;
  3831. }();
  3832. var iCombinations = {
  3833. 'î': "\u0131\u0302",
  3834. 'ï': "\u0131\u0308",
  3835. 'í': "\u0131\u0301",
  3836. // 'ī': '\u0131\u0304', // enable when we add Extended Latin
  3837. 'ì': "\u0131\u0300"
  3838. };
  3839. /**
  3840. * A symbol node contains information about a single symbol. It either renders
  3841. * to a single text node, or a span with a single text node in it, depending on
  3842. * whether it has CSS classes, styles, or needs italic correction.
  3843. */
  3844. var SymbolNode = /*#__PURE__*/function () {
  3845. function SymbolNode(text, height, depth, italic, skew, width, classes, style) {
  3846. this.text = void 0;
  3847. this.height = void 0;
  3848. this.depth = void 0;
  3849. this.italic = void 0;
  3850. this.skew = void 0;
  3851. this.width = void 0;
  3852. this.maxFontSize = void 0;
  3853. this.classes = void 0;
  3854. this.style = void 0;
  3855. this.text = text;
  3856. this.height = height || 0;
  3857. this.depth = depth || 0;
  3858. this.italic = italic || 0;
  3859. this.skew = skew || 0;
  3860. this.width = width || 0;
  3861. this.classes = classes || [];
  3862. this.style = style || {};
  3863. this.maxFontSize = 0; // Mark text from non-Latin scripts with specific classes so that we
  3864. // can specify which fonts to use. This allows us to render these
  3865. // characters with a serif font in situations where the browser would
  3866. // either default to a sans serif or render a placeholder character.
  3867. // We use CSS class names like cjk_fallback, hangul_fallback and
  3868. // brahmic_fallback. See ./unicodeScripts.js for the set of possible
  3869. // script names
  3870. var script = scriptFromCodepoint(this.text.charCodeAt(0));
  3871. if (script) {
  3872. this.classes.push(script + "_fallback");
  3873. }
  3874. if (/[îïíì]/.test(this.text)) {
  3875. // add ī when we add Extended Latin
  3876. this.text = iCombinations[this.text];
  3877. }
  3878. }
  3879. var _proto4 = SymbolNode.prototype;
  3880. _proto4.hasClass = function hasClass(className) {
  3881. return utils.contains(this.classes, className);
  3882. }
  3883. /**
  3884. * Creates a text node or span from a symbol node. Note that a span is only
  3885. * created if it is needed.
  3886. */
  3887. ;
  3888. _proto4.toNode = function toNode() {
  3889. var node = document.createTextNode(this.text);
  3890. var span = null;
  3891. if (this.italic > 0) {
  3892. span = document.createElement("span");
  3893. span.style.marginRight = makeEm(this.italic);
  3894. }
  3895. if (this.classes.length > 0) {
  3896. span = span || document.createElement("span");
  3897. span.className = createClass(this.classes);
  3898. }
  3899. for (var style in this.style) {
  3900. if (this.style.hasOwnProperty(style)) {
  3901. span = span || document.createElement("span"); // $FlowFixMe Flow doesn't seem to understand span.style's type.
  3902. span.style[style] = this.style[style];
  3903. }
  3904. }
  3905. if (span) {
  3906. span.appendChild(node);
  3907. return span;
  3908. } else {
  3909. return node;
  3910. }
  3911. }
  3912. /**
  3913. * Creates markup for a symbol node.
  3914. */
  3915. ;
  3916. _proto4.toMarkup = function toMarkup() {
  3917. // TODO(alpert): More duplication than I'd like from
  3918. // span.prototype.toMarkup and symbolNode.prototype.toNode...
  3919. var needsSpan = false;
  3920. var markup = "<span";
  3921. if (this.classes.length) {
  3922. needsSpan = true;
  3923. markup += " class=\"";
  3924. markup += utils.escape(createClass(this.classes));
  3925. markup += "\"";
  3926. }
  3927. var styles = "";
  3928. if (this.italic > 0) {
  3929. styles += "margin-right:" + this.italic + "em;";
  3930. }
  3931. for (var style in this.style) {
  3932. if (this.style.hasOwnProperty(style)) {
  3933. styles += utils.hyphenate(style) + ":" + this.style[style] + ";";
  3934. }
  3935. }
  3936. if (styles) {
  3937. needsSpan = true;
  3938. markup += " style=\"" + utils.escape(styles) + "\"";
  3939. }
  3940. var escaped = utils.escape(this.text);
  3941. if (needsSpan) {
  3942. markup += ">";
  3943. markup += escaped;
  3944. markup += "</span>";
  3945. return markup;
  3946. } else {
  3947. return escaped;
  3948. }
  3949. };
  3950. return SymbolNode;
  3951. }();
  3952. /**
  3953. * SVG nodes are used to render stretchy wide elements.
  3954. */
  3955. var SvgNode = /*#__PURE__*/function () {
  3956. function SvgNode(children, attributes) {
  3957. this.children = void 0;
  3958. this.attributes = void 0;
  3959. this.children = children || [];
  3960. this.attributes = attributes || {};
  3961. }
  3962. var _proto5 = SvgNode.prototype;
  3963. _proto5.toNode = function toNode() {
  3964. var svgNS = "http://www.w3.org/2000/svg";
  3965. var node = document.createElementNS(svgNS, "svg"); // Apply attributes
  3966. for (var attr in this.attributes) {
  3967. if (Object.prototype.hasOwnProperty.call(this.attributes, attr)) {
  3968. node.setAttribute(attr, this.attributes[attr]);
  3969. }
  3970. }
  3971. for (var i = 0; i < this.children.length; i++) {
  3972. node.appendChild(this.children[i].toNode());
  3973. }
  3974. return node;
  3975. };
  3976. _proto5.toMarkup = function toMarkup() {
  3977. var markup = "<svg xmlns=\"http://www.w3.org/2000/svg\""; // Apply attributes
  3978. for (var attr in this.attributes) {
  3979. if (Object.prototype.hasOwnProperty.call(this.attributes, attr)) {
  3980. markup += " " + attr + "='" + this.attributes[attr] + "'";
  3981. }
  3982. }
  3983. markup += ">";
  3984. for (var i = 0; i < this.children.length; i++) {
  3985. markup += this.children[i].toMarkup();
  3986. }
  3987. markup += "</svg>";
  3988. return markup;
  3989. };
  3990. return SvgNode;
  3991. }();
  3992. var PathNode = /*#__PURE__*/function () {
  3993. function PathNode(pathName, alternate) {
  3994. this.pathName = void 0;
  3995. this.alternate = void 0;
  3996. this.pathName = pathName;
  3997. this.alternate = alternate; // Used only for \sqrt, \phase, & tall delims
  3998. }
  3999. var _proto6 = PathNode.prototype;
  4000. _proto6.toNode = function toNode() {
  4001. var svgNS = "http://www.w3.org/2000/svg";
  4002. var node = document.createElementNS(svgNS, "path");
  4003. if (this.alternate) {
  4004. node.setAttribute("d", this.alternate);
  4005. } else {
  4006. node.setAttribute("d", path[this.pathName]);
  4007. }
  4008. return node;
  4009. };
  4010. _proto6.toMarkup = function toMarkup() {
  4011. if (this.alternate) {
  4012. return "<path d='" + this.alternate + "'/>";
  4013. } else {
  4014. return "<path d='" + path[this.pathName] + "'/>";
  4015. }
  4016. };
  4017. return PathNode;
  4018. }();
  4019. var LineNode = /*#__PURE__*/function () {
  4020. function LineNode(attributes) {
  4021. this.attributes = void 0;
  4022. this.attributes = attributes || {};
  4023. }
  4024. var _proto7 = LineNode.prototype;
  4025. _proto7.toNode = function toNode() {
  4026. var svgNS = "http://www.w3.org/2000/svg";
  4027. var node = document.createElementNS(svgNS, "line"); // Apply attributes
  4028. for (var attr in this.attributes) {
  4029. if (Object.prototype.hasOwnProperty.call(this.attributes, attr)) {
  4030. node.setAttribute(attr, this.attributes[attr]);
  4031. }
  4032. }
  4033. return node;
  4034. };
  4035. _proto7.toMarkup = function toMarkup() {
  4036. var markup = "<line";
  4037. for (var attr in this.attributes) {
  4038. if (Object.prototype.hasOwnProperty.call(this.attributes, attr)) {
  4039. markup += " " + attr + "='" + this.attributes[attr] + "'";
  4040. }
  4041. }
  4042. markup += "/>";
  4043. return markup;
  4044. };
  4045. return LineNode;
  4046. }();
  4047. function assertSymbolDomNode(group) {
  4048. if (group instanceof SymbolNode) {
  4049. return group;
  4050. } else {
  4051. throw new Error("Expected symbolNode but got " + String(group) + ".");
  4052. }
  4053. }
  4054. function assertSpan(group) {
  4055. if (group instanceof Span) {
  4056. return group;
  4057. } else {
  4058. throw new Error("Expected span<HtmlDomNode> but got " + String(group) + ".");
  4059. }
  4060. }
  4061. ;// CONCATENATED MODULE: ./src/symbols.js
  4062. /**
  4063. * This file holds a list of all no-argument functions and single-character
  4064. * symbols (like 'a' or ';').
  4065. *
  4066. * For each of the symbols, there are three properties they can have:
  4067. * - font (required): the font to be used for this symbol. Either "main" (the
  4068. normal font), or "ams" (the ams fonts).
  4069. * - group (required): the ParseNode group type the symbol should have (i.e.
  4070. "textord", "mathord", etc).
  4071. See https://github.com/KaTeX/KaTeX/wiki/Examining-TeX#group-types
  4072. * - replace: the character that this symbol or function should be
  4073. * replaced with (i.e. "\phi" has a replace value of "\u03d5", the phi
  4074. * character in the main font).
  4075. *
  4076. * The outermost map in the table indicates what mode the symbols should be
  4077. * accepted in (e.g. "math" or "text").
  4078. */
  4079. // Some of these have a "-token" suffix since these are also used as `ParseNode`
  4080. // types for raw text tokens, and we want to avoid conflicts with higher-level
  4081. // `ParseNode` types. These `ParseNode`s are constructed within `Parser` by
  4082. // looking up the `symbols` map.
  4083. var ATOMS = {
  4084. "bin": 1,
  4085. "close": 1,
  4086. "inner": 1,
  4087. "open": 1,
  4088. "punct": 1,
  4089. "rel": 1
  4090. };
  4091. var NON_ATOMS = {
  4092. "accent-token": 1,
  4093. "mathord": 1,
  4094. "op-token": 1,
  4095. "spacing": 1,
  4096. "textord": 1
  4097. };
  4098. var symbols = {
  4099. "math": {},
  4100. "text": {}
  4101. };
  4102. /* harmony default export */ var src_symbols = (symbols);
  4103. /** `acceptUnicodeChar = true` is only applicable if `replace` is set. */
  4104. function defineSymbol(mode, font, group, replace, name, acceptUnicodeChar) {
  4105. symbols[mode][name] = {
  4106. font: font,
  4107. group: group,
  4108. replace: replace
  4109. };
  4110. if (acceptUnicodeChar && replace) {
  4111. symbols[mode][replace] = symbols[mode][name];
  4112. }
  4113. } // Some abbreviations for commonly used strings.
  4114. // This helps minify the code, and also spotting typos using jshint.
  4115. // modes:
  4116. var math = "math";
  4117. var symbols_text = "text"; // fonts:
  4118. var main = "main";
  4119. var ams = "ams"; // groups:
  4120. var accent = "accent-token";
  4121. var bin = "bin";
  4122. var symbols_close = "close";
  4123. var inner = "inner";
  4124. var mathord = "mathord";
  4125. var op = "op-token";
  4126. var symbols_open = "open";
  4127. var punct = "punct";
  4128. var rel = "rel";
  4129. var spacing = "spacing";
  4130. var textord = "textord"; // Now comes the symbol table
  4131. // Relation Symbols
  4132. defineSymbol(math, main, rel, "\u2261", "\\equiv", true);
  4133. defineSymbol(math, main, rel, "\u227A", "\\prec", true);
  4134. defineSymbol(math, main, rel, "\u227B", "\\succ", true);
  4135. defineSymbol(math, main, rel, "\u223C", "\\sim", true);
  4136. defineSymbol(math, main, rel, "\u22A5", "\\perp");
  4137. defineSymbol(math, main, rel, "\u2AAF", "\\preceq", true);
  4138. defineSymbol(math, main, rel, "\u2AB0", "\\succeq", true);
  4139. defineSymbol(math, main, rel, "\u2243", "\\simeq", true);
  4140. defineSymbol(math, main, rel, "\u2223", "\\mid", true);
  4141. defineSymbol(math, main, rel, "\u226A", "\\ll", true);
  4142. defineSymbol(math, main, rel, "\u226B", "\\gg", true);
  4143. defineSymbol(math, main, rel, "\u224D", "\\asymp", true);
  4144. defineSymbol(math, main, rel, "\u2225", "\\parallel");
  4145. defineSymbol(math, main, rel, "\u22C8", "\\bowtie", true);
  4146. defineSymbol(math, main, rel, "\u2323", "\\smile", true);
  4147. defineSymbol(math, main, rel, "\u2291", "\\sqsubseteq", true);
  4148. defineSymbol(math, main, rel, "\u2292", "\\sqsupseteq", true);
  4149. defineSymbol(math, main, rel, "\u2250", "\\doteq", true);
  4150. defineSymbol(math, main, rel, "\u2322", "\\frown", true);
  4151. defineSymbol(math, main, rel, "\u220B", "\\ni", true);
  4152. defineSymbol(math, main, rel, "\u221D", "\\propto", true);
  4153. defineSymbol(math, main, rel, "\u22A2", "\\vdash", true);
  4154. defineSymbol(math, main, rel, "\u22A3", "\\dashv", true);
  4155. defineSymbol(math, main, rel, "\u220B", "\\owns"); // Punctuation
  4156. defineSymbol(math, main, punct, ".", "\\ldotp");
  4157. defineSymbol(math, main, punct, "\u22C5", "\\cdotp"); // Misc Symbols
  4158. defineSymbol(math, main, textord, "#", "\\#");
  4159. defineSymbol(symbols_text, main, textord, "#", "\\#");
  4160. defineSymbol(math, main, textord, "&", "\\&");
  4161. defineSymbol(symbols_text, main, textord, "&", "\\&");
  4162. defineSymbol(math, main, textord, "\u2135", "\\aleph", true);
  4163. defineSymbol(math, main, textord, "\u2200", "\\forall", true);
  4164. defineSymbol(math, main, textord, "\u210F", "\\hbar", true);
  4165. defineSymbol(math, main, textord, "\u2203", "\\exists", true);
  4166. defineSymbol(math, main, textord, "\u2207", "\\nabla", true);
  4167. defineSymbol(math, main, textord, "\u266D", "\\flat", true);
  4168. defineSymbol(math, main, textord, "\u2113", "\\ell", true);
  4169. defineSymbol(math, main, textord, "\u266E", "\\natural", true);
  4170. defineSymbol(math, main, textord, "\u2663", "\\clubsuit", true);
  4171. defineSymbol(math, main, textord, "\u2118", "\\wp", true);
  4172. defineSymbol(math, main, textord, "\u266F", "\\sharp", true);
  4173. defineSymbol(math, main, textord, "\u2662", "\\diamondsuit", true);
  4174. defineSymbol(math, main, textord, "\u211C", "\\Re", true);
  4175. defineSymbol(math, main, textord, "\u2661", "\\heartsuit", true);
  4176. defineSymbol(math, main, textord, "\u2111", "\\Im", true);
  4177. defineSymbol(math, main, textord, "\u2660", "\\spadesuit", true);
  4178. defineSymbol(math, main, textord, "\xA7", "\\S", true);
  4179. defineSymbol(symbols_text, main, textord, "\xA7", "\\S");
  4180. defineSymbol(math, main, textord, "\xB6", "\\P", true);
  4181. defineSymbol(symbols_text, main, textord, "\xB6", "\\P"); // Math and Text
  4182. defineSymbol(math, main, textord, "\u2020", "\\dag");
  4183. defineSymbol(symbols_text, main, textord, "\u2020", "\\dag");
  4184. defineSymbol(symbols_text, main, textord, "\u2020", "\\textdagger");
  4185. defineSymbol(math, main, textord, "\u2021", "\\ddag");
  4186. defineSymbol(symbols_text, main, textord, "\u2021", "\\ddag");
  4187. defineSymbol(symbols_text, main, textord, "\u2021", "\\textdaggerdbl"); // Large Delimiters
  4188. defineSymbol(math, main, symbols_close, "\u23B1", "\\rmoustache", true);
  4189. defineSymbol(math, main, symbols_open, "\u23B0", "\\lmoustache", true);
  4190. defineSymbol(math, main, symbols_close, "\u27EF", "\\rgroup", true);
  4191. defineSymbol(math, main, symbols_open, "\u27EE", "\\lgroup", true); // Binary Operators
  4192. defineSymbol(math, main, bin, "\u2213", "\\mp", true);
  4193. defineSymbol(math, main, bin, "\u2296", "\\ominus", true);
  4194. defineSymbol(math, main, bin, "\u228E", "\\uplus", true);
  4195. defineSymbol(math, main, bin, "\u2293", "\\sqcap", true);
  4196. defineSymbol(math, main, bin, "\u2217", "\\ast");
  4197. defineSymbol(math, main, bin, "\u2294", "\\sqcup", true);
  4198. defineSymbol(math, main, bin, "\u25EF", "\\bigcirc", true);
  4199. defineSymbol(math, main, bin, "\u2219", "\\bullet", true);
  4200. defineSymbol(math, main, bin, "\u2021", "\\ddagger");
  4201. defineSymbol(math, main, bin, "\u2240", "\\wr", true);
  4202. defineSymbol(math, main, bin, "\u2A3F", "\\amalg");
  4203. defineSymbol(math, main, bin, "&", "\\And"); // from amsmath
  4204. // Arrow Symbols
  4205. defineSymbol(math, main, rel, "\u27F5", "\\longleftarrow", true);
  4206. defineSymbol(math, main, rel, "\u21D0", "\\Leftarrow", true);
  4207. defineSymbol(math, main, rel, "\u27F8", "\\Longleftarrow", true);
  4208. defineSymbol(math, main, rel, "\u27F6", "\\longrightarrow", true);
  4209. defineSymbol(math, main, rel, "\u21D2", "\\Rightarrow", true);
  4210. defineSymbol(math, main, rel, "\u27F9", "\\Longrightarrow", true);
  4211. defineSymbol(math, main, rel, "\u2194", "\\leftrightarrow", true);
  4212. defineSymbol(math, main, rel, "\u27F7", "\\longleftrightarrow", true);
  4213. defineSymbol(math, main, rel, "\u21D4", "\\Leftrightarrow", true);
  4214. defineSymbol(math, main, rel, "\u27FA", "\\Longleftrightarrow", true);
  4215. defineSymbol(math, main, rel, "\u21A6", "\\mapsto", true);
  4216. defineSymbol(math, main, rel, "\u27FC", "\\longmapsto", true);
  4217. defineSymbol(math, main, rel, "\u2197", "\\nearrow", true);
  4218. defineSymbol(math, main, rel, "\u21A9", "\\hookleftarrow", true);
  4219. defineSymbol(math, main, rel, "\u21AA", "\\hookrightarrow", true);
  4220. defineSymbol(math, main, rel, "\u2198", "\\searrow", true);
  4221. defineSymbol(math, main, rel, "\u21BC", "\\leftharpoonup", true);
  4222. defineSymbol(math, main, rel, "\u21C0", "\\rightharpoonup", true);
  4223. defineSymbol(math, main, rel, "\u2199", "\\swarrow", true);
  4224. defineSymbol(math, main, rel, "\u21BD", "\\leftharpoondown", true);
  4225. defineSymbol(math, main, rel, "\u21C1", "\\rightharpoondown", true);
  4226. defineSymbol(math, main, rel, "\u2196", "\\nwarrow", true);
  4227. defineSymbol(math, main, rel, "\u21CC", "\\rightleftharpoons", true); // AMS Negated Binary Relations
  4228. defineSymbol(math, ams, rel, "\u226E", "\\nless", true); // Symbol names preceeded by "@" each have a corresponding macro.
  4229. defineSymbol(math, ams, rel, "\uE010", "\\@nleqslant");
  4230. defineSymbol(math, ams, rel, "\uE011", "\\@nleqq");
  4231. defineSymbol(math, ams, rel, "\u2A87", "\\lneq", true);
  4232. defineSymbol(math, ams, rel, "\u2268", "\\lneqq", true);
  4233. defineSymbol(math, ams, rel, "\uE00C", "\\@lvertneqq");
  4234. defineSymbol(math, ams, rel, "\u22E6", "\\lnsim", true);
  4235. defineSymbol(math, ams, rel, "\u2A89", "\\lnapprox", true);
  4236. defineSymbol(math, ams, rel, "\u2280", "\\nprec", true); // unicode-math maps \u22e0 to \npreccurlyeq. We'll use the AMS synonym.
  4237. defineSymbol(math, ams, rel, "\u22E0", "\\npreceq", true);
  4238. defineSymbol(math, ams, rel, "\u22E8", "\\precnsim", true);
  4239. defineSymbol(math, ams, rel, "\u2AB9", "\\precnapprox", true);
  4240. defineSymbol(math, ams, rel, "\u2241", "\\nsim", true);
  4241. defineSymbol(math, ams, rel, "\uE006", "\\@nshortmid");
  4242. defineSymbol(math, ams, rel, "\u2224", "\\nmid", true);
  4243. defineSymbol(math, ams, rel, "\u22AC", "\\nvdash", true);
  4244. defineSymbol(math, ams, rel, "\u22AD", "\\nvDash", true);
  4245. defineSymbol(math, ams, rel, "\u22EA", "\\ntriangleleft");
  4246. defineSymbol(math, ams, rel, "\u22EC", "\\ntrianglelefteq", true);
  4247. defineSymbol(math, ams, rel, "\u228A", "\\subsetneq", true);
  4248. defineSymbol(math, ams, rel, "\uE01A", "\\@varsubsetneq");
  4249. defineSymbol(math, ams, rel, "\u2ACB", "\\subsetneqq", true);
  4250. defineSymbol(math, ams, rel, "\uE017", "\\@varsubsetneqq");
  4251. defineSymbol(math, ams, rel, "\u226F", "\\ngtr", true);
  4252. defineSymbol(math, ams, rel, "\uE00F", "\\@ngeqslant");
  4253. defineSymbol(math, ams, rel, "\uE00E", "\\@ngeqq");
  4254. defineSymbol(math, ams, rel, "\u2A88", "\\gneq", true);
  4255. defineSymbol(math, ams, rel, "\u2269", "\\gneqq", true);
  4256. defineSymbol(math, ams, rel, "\uE00D", "\\@gvertneqq");
  4257. defineSymbol(math, ams, rel, "\u22E7", "\\gnsim", true);
  4258. defineSymbol(math, ams, rel, "\u2A8A", "\\gnapprox", true);
  4259. defineSymbol(math, ams, rel, "\u2281", "\\nsucc", true); // unicode-math maps \u22e1 to \nsucccurlyeq. We'll use the AMS synonym.
  4260. defineSymbol(math, ams, rel, "\u22E1", "\\nsucceq", true);
  4261. defineSymbol(math, ams, rel, "\u22E9", "\\succnsim", true);
  4262. defineSymbol(math, ams, rel, "\u2ABA", "\\succnapprox", true); // unicode-math maps \u2246 to \simneqq. We'll use the AMS synonym.
  4263. defineSymbol(math, ams, rel, "\u2246", "\\ncong", true);
  4264. defineSymbol(math, ams, rel, "\uE007", "\\@nshortparallel");
  4265. defineSymbol(math, ams, rel, "\u2226", "\\nparallel", true);
  4266. defineSymbol(math, ams, rel, "\u22AF", "\\nVDash", true);
  4267. defineSymbol(math, ams, rel, "\u22EB", "\\ntriangleright");
  4268. defineSymbol(math, ams, rel, "\u22ED", "\\ntrianglerighteq", true);
  4269. defineSymbol(math, ams, rel, "\uE018", "\\@nsupseteqq");
  4270. defineSymbol(math, ams, rel, "\u228B", "\\supsetneq", true);
  4271. defineSymbol(math, ams, rel, "\uE01B", "\\@varsupsetneq");
  4272. defineSymbol(math, ams, rel, "\u2ACC", "\\supsetneqq", true);
  4273. defineSymbol(math, ams, rel, "\uE019", "\\@varsupsetneqq");
  4274. defineSymbol(math, ams, rel, "\u22AE", "\\nVdash", true);
  4275. defineSymbol(math, ams, rel, "\u2AB5", "\\precneqq", true);
  4276. defineSymbol(math, ams, rel, "\u2AB6", "\\succneqq", true);
  4277. defineSymbol(math, ams, rel, "\uE016", "\\@nsubseteqq");
  4278. defineSymbol(math, ams, bin, "\u22B4", "\\unlhd");
  4279. defineSymbol(math, ams, bin, "\u22B5", "\\unrhd"); // AMS Negated Arrows
  4280. defineSymbol(math, ams, rel, "\u219A", "\\nleftarrow", true);
  4281. defineSymbol(math, ams, rel, "\u219B", "\\nrightarrow", true);
  4282. defineSymbol(math, ams, rel, "\u21CD", "\\nLeftarrow", true);
  4283. defineSymbol(math, ams, rel, "\u21CF", "\\nRightarrow", true);
  4284. defineSymbol(math, ams, rel, "\u21AE", "\\nleftrightarrow", true);
  4285. defineSymbol(math, ams, rel, "\u21CE", "\\nLeftrightarrow", true); // AMS Misc
  4286. defineSymbol(math, ams, rel, "\u25B3", "\\vartriangle");
  4287. defineSymbol(math, ams, textord, "\u210F", "\\hslash");
  4288. defineSymbol(math, ams, textord, "\u25BD", "\\triangledown");
  4289. defineSymbol(math, ams, textord, "\u25CA", "\\lozenge");
  4290. defineSymbol(math, ams, textord, "\u24C8", "\\circledS");
  4291. defineSymbol(math, ams, textord, "\xAE", "\\circledR");
  4292. defineSymbol(symbols_text, ams, textord, "\xAE", "\\circledR");
  4293. defineSymbol(math, ams, textord, "\u2221", "\\measuredangle", true);
  4294. defineSymbol(math, ams, textord, "\u2204", "\\nexists");
  4295. defineSymbol(math, ams, textord, "\u2127", "\\mho");
  4296. defineSymbol(math, ams, textord, "\u2132", "\\Finv", true);
  4297. defineSymbol(math, ams, textord, "\u2141", "\\Game", true);
  4298. defineSymbol(math, ams, textord, "\u2035", "\\backprime");
  4299. defineSymbol(math, ams, textord, "\u25B2", "\\blacktriangle");
  4300. defineSymbol(math, ams, textord, "\u25BC", "\\blacktriangledown");
  4301. defineSymbol(math, ams, textord, "\u25A0", "\\blacksquare");
  4302. defineSymbol(math, ams, textord, "\u29EB", "\\blacklozenge");
  4303. defineSymbol(math, ams, textord, "\u2605", "\\bigstar");
  4304. defineSymbol(math, ams, textord, "\u2222", "\\sphericalangle", true);
  4305. defineSymbol(math, ams, textord, "\u2201", "\\complement", true); // unicode-math maps U+F0 to \matheth. We map to AMS function \eth
  4306. defineSymbol(math, ams, textord, "\xF0", "\\eth", true);
  4307. defineSymbol(symbols_text, main, textord, "\xF0", "\xF0");
  4308. defineSymbol(math, ams, textord, "\u2571", "\\diagup");
  4309. defineSymbol(math, ams, textord, "\u2572", "\\diagdown");
  4310. defineSymbol(math, ams, textord, "\u25A1", "\\square");
  4311. defineSymbol(math, ams, textord, "\u25A1", "\\Box");
  4312. defineSymbol(math, ams, textord, "\u25CA", "\\Diamond"); // unicode-math maps U+A5 to \mathyen. We map to AMS function \yen
  4313. defineSymbol(math, ams, textord, "\xA5", "\\yen", true);
  4314. defineSymbol(symbols_text, ams, textord, "\xA5", "\\yen", true);
  4315. defineSymbol(math, ams, textord, "\u2713", "\\checkmark", true);
  4316. defineSymbol(symbols_text, ams, textord, "\u2713", "\\checkmark"); // AMS Hebrew
  4317. defineSymbol(math, ams, textord, "\u2136", "\\beth", true);
  4318. defineSymbol(math, ams, textord, "\u2138", "\\daleth", true);
  4319. defineSymbol(math, ams, textord, "\u2137", "\\gimel", true); // AMS Greek
  4320. defineSymbol(math, ams, textord, "\u03DD", "\\digamma", true);
  4321. defineSymbol(math, ams, textord, "\u03F0", "\\varkappa"); // AMS Delimiters
  4322. defineSymbol(math, ams, symbols_open, "\u250C", "\\@ulcorner", true);
  4323. defineSymbol(math, ams, symbols_close, "\u2510", "\\@urcorner", true);
  4324. defineSymbol(math, ams, symbols_open, "\u2514", "\\@llcorner", true);
  4325. defineSymbol(math, ams, symbols_close, "\u2518", "\\@lrcorner", true); // AMS Binary Relations
  4326. defineSymbol(math, ams, rel, "\u2266", "\\leqq", true);
  4327. defineSymbol(math, ams, rel, "\u2A7D", "\\leqslant", true);
  4328. defineSymbol(math, ams, rel, "\u2A95", "\\eqslantless", true);
  4329. defineSymbol(math, ams, rel, "\u2272", "\\lesssim", true);
  4330. defineSymbol(math, ams, rel, "\u2A85", "\\lessapprox", true);
  4331. defineSymbol(math, ams, rel, "\u224A", "\\approxeq", true);
  4332. defineSymbol(math, ams, bin, "\u22D6", "\\lessdot");
  4333. defineSymbol(math, ams, rel, "\u22D8", "\\lll", true);
  4334. defineSymbol(math, ams, rel, "\u2276", "\\lessgtr", true);
  4335. defineSymbol(math, ams, rel, "\u22DA", "\\lesseqgtr", true);
  4336. defineSymbol(math, ams, rel, "\u2A8B", "\\lesseqqgtr", true);
  4337. defineSymbol(math, ams, rel, "\u2251", "\\doteqdot");
  4338. defineSymbol(math, ams, rel, "\u2253", "\\risingdotseq", true);
  4339. defineSymbol(math, ams, rel, "\u2252", "\\fallingdotseq", true);
  4340. defineSymbol(math, ams, rel, "\u223D", "\\backsim", true);
  4341. defineSymbol(math, ams, rel, "\u22CD", "\\backsimeq", true);
  4342. defineSymbol(math, ams, rel, "\u2AC5", "\\subseteqq", true);
  4343. defineSymbol(math, ams, rel, "\u22D0", "\\Subset", true);
  4344. defineSymbol(math, ams, rel, "\u228F", "\\sqsubset", true);
  4345. defineSymbol(math, ams, rel, "\u227C", "\\preccurlyeq", true);
  4346. defineSymbol(math, ams, rel, "\u22DE", "\\curlyeqprec", true);
  4347. defineSymbol(math, ams, rel, "\u227E", "\\precsim", true);
  4348. defineSymbol(math, ams, rel, "\u2AB7", "\\precapprox", true);
  4349. defineSymbol(math, ams, rel, "\u22B2", "\\vartriangleleft");
  4350. defineSymbol(math, ams, rel, "\u22B4", "\\trianglelefteq");
  4351. defineSymbol(math, ams, rel, "\u22A8", "\\vDash", true);
  4352. defineSymbol(math, ams, rel, "\u22AA", "\\Vvdash", true);
  4353. defineSymbol(math, ams, rel, "\u2323", "\\smallsmile");
  4354. defineSymbol(math, ams, rel, "\u2322", "\\smallfrown");
  4355. defineSymbol(math, ams, rel, "\u224F", "\\bumpeq", true);
  4356. defineSymbol(math, ams, rel, "\u224E", "\\Bumpeq", true);
  4357. defineSymbol(math, ams, rel, "\u2267", "\\geqq", true);
  4358. defineSymbol(math, ams, rel, "\u2A7E", "\\geqslant", true);
  4359. defineSymbol(math, ams, rel, "\u2A96", "\\eqslantgtr", true);
  4360. defineSymbol(math, ams, rel, "\u2273", "\\gtrsim", true);
  4361. defineSymbol(math, ams, rel, "\u2A86", "\\gtrapprox", true);
  4362. defineSymbol(math, ams, bin, "\u22D7", "\\gtrdot");
  4363. defineSymbol(math, ams, rel, "\u22D9", "\\ggg", true);
  4364. defineSymbol(math, ams, rel, "\u2277", "\\gtrless", true);
  4365. defineSymbol(math, ams, rel, "\u22DB", "\\gtreqless", true);
  4366. defineSymbol(math, ams, rel, "\u2A8C", "\\gtreqqless", true);
  4367. defineSymbol(math, ams, rel, "\u2256", "\\eqcirc", true);
  4368. defineSymbol(math, ams, rel, "\u2257", "\\circeq", true);
  4369. defineSymbol(math, ams, rel, "\u225C", "\\triangleq", true);
  4370. defineSymbol(math, ams, rel, "\u223C", "\\thicksim");
  4371. defineSymbol(math, ams, rel, "\u2248", "\\thickapprox");
  4372. defineSymbol(math, ams, rel, "\u2AC6", "\\supseteqq", true);
  4373. defineSymbol(math, ams, rel, "\u22D1", "\\Supset", true);
  4374. defineSymbol(math, ams, rel, "\u2290", "\\sqsupset", true);
  4375. defineSymbol(math, ams, rel, "\u227D", "\\succcurlyeq", true);
  4376. defineSymbol(math, ams, rel, "\u22DF", "\\curlyeqsucc", true);
  4377. defineSymbol(math, ams, rel, "\u227F", "\\succsim", true);
  4378. defineSymbol(math, ams, rel, "\u2AB8", "\\succapprox", true);
  4379. defineSymbol(math, ams, rel, "\u22B3", "\\vartriangleright");
  4380. defineSymbol(math, ams, rel, "\u22B5", "\\trianglerighteq");
  4381. defineSymbol(math, ams, rel, "\u22A9", "\\Vdash", true);
  4382. defineSymbol(math, ams, rel, "\u2223", "\\shortmid");
  4383. defineSymbol(math, ams, rel, "\u2225", "\\shortparallel");
  4384. defineSymbol(math, ams, rel, "\u226C", "\\between", true);
  4385. defineSymbol(math, ams, rel, "\u22D4", "\\pitchfork", true);
  4386. defineSymbol(math, ams, rel, "\u221D", "\\varpropto");
  4387. defineSymbol(math, ams, rel, "\u25C0", "\\blacktriangleleft"); // unicode-math says that \therefore is a mathord atom.
  4388. // We kept the amssymb atom type, which is rel.
  4389. defineSymbol(math, ams, rel, "\u2234", "\\therefore", true);
  4390. defineSymbol(math, ams, rel, "\u220D", "\\backepsilon");
  4391. defineSymbol(math, ams, rel, "\u25B6", "\\blacktriangleright"); // unicode-math says that \because is a mathord atom.
  4392. // We kept the amssymb atom type, which is rel.
  4393. defineSymbol(math, ams, rel, "\u2235", "\\because", true);
  4394. defineSymbol(math, ams, rel, "\u22D8", "\\llless");
  4395. defineSymbol(math, ams, rel, "\u22D9", "\\gggtr");
  4396. defineSymbol(math, ams, bin, "\u22B2", "\\lhd");
  4397. defineSymbol(math, ams, bin, "\u22B3", "\\rhd");
  4398. defineSymbol(math, ams, rel, "\u2242", "\\eqsim", true);
  4399. defineSymbol(math, main, rel, "\u22C8", "\\Join");
  4400. defineSymbol(math, ams, rel, "\u2251", "\\Doteq", true); // AMS Binary Operators
  4401. defineSymbol(math, ams, bin, "\u2214", "\\dotplus", true);
  4402. defineSymbol(math, ams, bin, "\u2216", "\\smallsetminus");
  4403. defineSymbol(math, ams, bin, "\u22D2", "\\Cap", true);
  4404. defineSymbol(math, ams, bin, "\u22D3", "\\Cup", true);
  4405. defineSymbol(math, ams, bin, "\u2A5E", "\\doublebarwedge", true);
  4406. defineSymbol(math, ams, bin, "\u229F", "\\boxminus", true);
  4407. defineSymbol(math, ams, bin, "\u229E", "\\boxplus", true);
  4408. defineSymbol(math, ams, bin, "\u22C7", "\\divideontimes", true);
  4409. defineSymbol(math, ams, bin, "\u22C9", "\\ltimes", true);
  4410. defineSymbol(math, ams, bin, "\u22CA", "\\rtimes", true);
  4411. defineSymbol(math, ams, bin, "\u22CB", "\\leftthreetimes", true);
  4412. defineSymbol(math, ams, bin, "\u22CC", "\\rightthreetimes", true);
  4413. defineSymbol(math, ams, bin, "\u22CF", "\\curlywedge", true);
  4414. defineSymbol(math, ams, bin, "\u22CE", "\\curlyvee", true);
  4415. defineSymbol(math, ams, bin, "\u229D", "\\circleddash", true);
  4416. defineSymbol(math, ams, bin, "\u229B", "\\circledast", true);
  4417. defineSymbol(math, ams, bin, "\u22C5", "\\centerdot");
  4418. defineSymbol(math, ams, bin, "\u22BA", "\\intercal", true);
  4419. defineSymbol(math, ams, bin, "\u22D2", "\\doublecap");
  4420. defineSymbol(math, ams, bin, "\u22D3", "\\doublecup");
  4421. defineSymbol(math, ams, bin, "\u22A0", "\\boxtimes", true); // AMS Arrows
  4422. // Note: unicode-math maps \u21e2 to their own function \rightdasharrow.
  4423. // We'll map it to AMS function \dashrightarrow. It produces the same atom.
  4424. defineSymbol(math, ams, rel, "\u21E2", "\\dashrightarrow", true); // unicode-math maps \u21e0 to \leftdasharrow. We'll use the AMS synonym.
  4425. defineSymbol(math, ams, rel, "\u21E0", "\\dashleftarrow", true);
  4426. defineSymbol(math, ams, rel, "\u21C7", "\\leftleftarrows", true);
  4427. defineSymbol(math, ams, rel, "\u21C6", "\\leftrightarrows", true);
  4428. defineSymbol(math, ams, rel, "\u21DA", "\\Lleftarrow", true);
  4429. defineSymbol(math, ams, rel, "\u219E", "\\twoheadleftarrow", true);
  4430. defineSymbol(math, ams, rel, "\u21A2", "\\leftarrowtail", true);
  4431. defineSymbol(math, ams, rel, "\u21AB", "\\looparrowleft", true);
  4432. defineSymbol(math, ams, rel, "\u21CB", "\\leftrightharpoons", true);
  4433. defineSymbol(math, ams, rel, "\u21B6", "\\curvearrowleft", true); // unicode-math maps \u21ba to \acwopencirclearrow. We'll use the AMS synonym.
  4434. defineSymbol(math, ams, rel, "\u21BA", "\\circlearrowleft", true);
  4435. defineSymbol(math, ams, rel, "\u21B0", "\\Lsh", true);
  4436. defineSymbol(math, ams, rel, "\u21C8", "\\upuparrows", true);
  4437. defineSymbol(math, ams, rel, "\u21BF", "\\upharpoonleft", true);
  4438. defineSymbol(math, ams, rel, "\u21C3", "\\downharpoonleft", true);
  4439. defineSymbol(math, main, rel, "\u22B6", "\\origof", true); // not in font
  4440. defineSymbol(math, main, rel, "\u22B7", "\\imageof", true); // not in font
  4441. defineSymbol(math, ams, rel, "\u22B8", "\\multimap", true);
  4442. defineSymbol(math, ams, rel, "\u21AD", "\\leftrightsquigarrow", true);
  4443. defineSymbol(math, ams, rel, "\u21C9", "\\rightrightarrows", true);
  4444. defineSymbol(math, ams, rel, "\u21C4", "\\rightleftarrows", true);
  4445. defineSymbol(math, ams, rel, "\u21A0", "\\twoheadrightarrow", true);
  4446. defineSymbol(math, ams, rel, "\u21A3", "\\rightarrowtail", true);
  4447. defineSymbol(math, ams, rel, "\u21AC", "\\looparrowright", true);
  4448. defineSymbol(math, ams, rel, "\u21B7", "\\curvearrowright", true); // unicode-math maps \u21bb to \cwopencirclearrow. We'll use the AMS synonym.
  4449. defineSymbol(math, ams, rel, "\u21BB", "\\circlearrowright", true);
  4450. defineSymbol(math, ams, rel, "\u21B1", "\\Rsh", true);
  4451. defineSymbol(math, ams, rel, "\u21CA", "\\downdownarrows", true);
  4452. defineSymbol(math, ams, rel, "\u21BE", "\\upharpoonright", true);
  4453. defineSymbol(math, ams, rel, "\u21C2", "\\downharpoonright", true);
  4454. defineSymbol(math, ams, rel, "\u21DD", "\\rightsquigarrow", true);
  4455. defineSymbol(math, ams, rel, "\u21DD", "\\leadsto");
  4456. defineSymbol(math, ams, rel, "\u21DB", "\\Rrightarrow", true);
  4457. defineSymbol(math, ams, rel, "\u21BE", "\\restriction");
  4458. defineSymbol(math, main, textord, "\u2018", "`");
  4459. defineSymbol(math, main, textord, "$", "\\$");
  4460. defineSymbol(symbols_text, main, textord, "$", "\\$");
  4461. defineSymbol(symbols_text, main, textord, "$", "\\textdollar");
  4462. defineSymbol(math, main, textord, "%", "\\%");
  4463. defineSymbol(symbols_text, main, textord, "%", "\\%");
  4464. defineSymbol(math, main, textord, "_", "\\_");
  4465. defineSymbol(symbols_text, main, textord, "_", "\\_");
  4466. defineSymbol(symbols_text, main, textord, "_", "\\textunderscore");
  4467. defineSymbol(math, main, textord, "\u2220", "\\angle", true);
  4468. defineSymbol(math, main, textord, "\u221E", "\\infty", true);
  4469. defineSymbol(math, main, textord, "\u2032", "\\prime");
  4470. defineSymbol(math, main, textord, "\u25B3", "\\triangle");
  4471. defineSymbol(math, main, textord, "\u0393", "\\Gamma", true);
  4472. defineSymbol(math, main, textord, "\u0394", "\\Delta", true);
  4473. defineSymbol(math, main, textord, "\u0398", "\\Theta", true);
  4474. defineSymbol(math, main, textord, "\u039B", "\\Lambda", true);
  4475. defineSymbol(math, main, textord, "\u039E", "\\Xi", true);
  4476. defineSymbol(math, main, textord, "\u03A0", "\\Pi", true);
  4477. defineSymbol(math, main, textord, "\u03A3", "\\Sigma", true);
  4478. defineSymbol(math, main, textord, "\u03A5", "\\Upsilon", true);
  4479. defineSymbol(math, main, textord, "\u03A6", "\\Phi", true);
  4480. defineSymbol(math, main, textord, "\u03A8", "\\Psi", true);
  4481. defineSymbol(math, main, textord, "\u03A9", "\\Omega", true);
  4482. defineSymbol(math, main, textord, "A", "\u0391");
  4483. defineSymbol(math, main, textord, "B", "\u0392");
  4484. defineSymbol(math, main, textord, "E", "\u0395");
  4485. defineSymbol(math, main, textord, "Z", "\u0396");
  4486. defineSymbol(math, main, textord, "H", "\u0397");
  4487. defineSymbol(math, main, textord, "I", "\u0399");
  4488. defineSymbol(math, main, textord, "K", "\u039A");
  4489. defineSymbol(math, main, textord, "M", "\u039C");
  4490. defineSymbol(math, main, textord, "N", "\u039D");
  4491. defineSymbol(math, main, textord, "O", "\u039F");
  4492. defineSymbol(math, main, textord, "P", "\u03A1");
  4493. defineSymbol(math, main, textord, "T", "\u03A4");
  4494. defineSymbol(math, main, textord, "X", "\u03A7");
  4495. defineSymbol(math, main, textord, "\xAC", "\\neg", true);
  4496. defineSymbol(math, main, textord, "\xAC", "\\lnot");
  4497. defineSymbol(math, main, textord, "\u22A4", "\\top");
  4498. defineSymbol(math, main, textord, "\u22A5", "\\bot");
  4499. defineSymbol(math, main, textord, "\u2205", "\\emptyset");
  4500. defineSymbol(math, ams, textord, "\u2205", "\\varnothing");
  4501. defineSymbol(math, main, mathord, "\u03B1", "\\alpha", true);
  4502. defineSymbol(math, main, mathord, "\u03B2", "\\beta", true);
  4503. defineSymbol(math, main, mathord, "\u03B3", "\\gamma", true);
  4504. defineSymbol(math, main, mathord, "\u03B4", "\\delta", true);
  4505. defineSymbol(math, main, mathord, "\u03F5", "\\epsilon", true);
  4506. defineSymbol(math, main, mathord, "\u03B6", "\\zeta", true);
  4507. defineSymbol(math, main, mathord, "\u03B7", "\\eta", true);
  4508. defineSymbol(math, main, mathord, "\u03B8", "\\theta", true);
  4509. defineSymbol(math, main, mathord, "\u03B9", "\\iota", true);
  4510. defineSymbol(math, main, mathord, "\u03BA", "\\kappa", true);
  4511. defineSymbol(math, main, mathord, "\u03BB", "\\lambda", true);
  4512. defineSymbol(math, main, mathord, "\u03BC", "\\mu", true);
  4513. defineSymbol(math, main, mathord, "\u03BD", "\\nu", true);
  4514. defineSymbol(math, main, mathord, "\u03BE", "\\xi", true);
  4515. defineSymbol(math, main, mathord, "\u03BF", "\\omicron", true);
  4516. defineSymbol(math, main, mathord, "\u03C0", "\\pi", true);
  4517. defineSymbol(math, main, mathord, "\u03C1", "\\rho", true);
  4518. defineSymbol(math, main, mathord, "\u03C3", "\\sigma", true);
  4519. defineSymbol(math, main, mathord, "\u03C4", "\\tau", true);
  4520. defineSymbol(math, main, mathord, "\u03C5", "\\upsilon", true);
  4521. defineSymbol(math, main, mathord, "\u03D5", "\\phi", true);
  4522. defineSymbol(math, main, mathord, "\u03C7", "\\chi", true);
  4523. defineSymbol(math, main, mathord, "\u03C8", "\\psi", true);
  4524. defineSymbol(math, main, mathord, "\u03C9", "\\omega", true);
  4525. defineSymbol(math, main, mathord, "\u03B5", "\\varepsilon", true);
  4526. defineSymbol(math, main, mathord, "\u03D1", "\\vartheta", true);
  4527. defineSymbol(math, main, mathord, "\u03D6", "\\varpi", true);
  4528. defineSymbol(math, main, mathord, "\u03F1", "\\varrho", true);
  4529. defineSymbol(math, main, mathord, "\u03C2", "\\varsigma", true);
  4530. defineSymbol(math, main, mathord, "\u03C6", "\\varphi", true);
  4531. defineSymbol(math, main, bin, "\u2217", "*", true);
  4532. defineSymbol(math, main, bin, "+", "+");
  4533. defineSymbol(math, main, bin, "\u2212", "-", true);
  4534. defineSymbol(math, main, bin, "\u22C5", "\\cdot", true);
  4535. defineSymbol(math, main, bin, "\u2218", "\\circ", true);
  4536. defineSymbol(math, main, bin, "\xF7", "\\div", true);
  4537. defineSymbol(math, main, bin, "\xB1", "\\pm", true);
  4538. defineSymbol(math, main, bin, "\xD7", "\\times", true);
  4539. defineSymbol(math, main, bin, "\u2229", "\\cap", true);
  4540. defineSymbol(math, main, bin, "\u222A", "\\cup", true);
  4541. defineSymbol(math, main, bin, "\u2216", "\\setminus", true);
  4542. defineSymbol(math, main, bin, "\u2227", "\\land");
  4543. defineSymbol(math, main, bin, "\u2228", "\\lor");
  4544. defineSymbol(math, main, bin, "\u2227", "\\wedge", true);
  4545. defineSymbol(math, main, bin, "\u2228", "\\vee", true);
  4546. defineSymbol(math, main, textord, "\u221A", "\\surd");
  4547. defineSymbol(math, main, symbols_open, "\u27E8", "\\langle", true);
  4548. defineSymbol(math, main, symbols_open, "\u2223", "\\lvert");
  4549. defineSymbol(math, main, symbols_open, "\u2225", "\\lVert");
  4550. defineSymbol(math, main, symbols_close, "?", "?");
  4551. defineSymbol(math, main, symbols_close, "!", "!");
  4552. defineSymbol(math, main, symbols_close, "\u27E9", "\\rangle", true);
  4553. defineSymbol(math, main, symbols_close, "\u2223", "\\rvert");
  4554. defineSymbol(math, main, symbols_close, "\u2225", "\\rVert");
  4555. defineSymbol(math, main, rel, "=", "=");
  4556. defineSymbol(math, main, rel, ":", ":");
  4557. defineSymbol(math, main, rel, "\u2248", "\\approx", true);
  4558. defineSymbol(math, main, rel, "\u2245", "\\cong", true);
  4559. defineSymbol(math, main, rel, "\u2265", "\\ge");
  4560. defineSymbol(math, main, rel, "\u2265", "\\geq", true);
  4561. defineSymbol(math, main, rel, "\u2190", "\\gets");
  4562. defineSymbol(math, main, rel, ">", "\\gt", true);
  4563. defineSymbol(math, main, rel, "\u2208", "\\in", true);
  4564. defineSymbol(math, main, rel, "\uE020", "\\@not");
  4565. defineSymbol(math, main, rel, "\u2282", "\\subset", true);
  4566. defineSymbol(math, main, rel, "\u2283", "\\supset", true);
  4567. defineSymbol(math, main, rel, "\u2286", "\\subseteq", true);
  4568. defineSymbol(math, main, rel, "\u2287", "\\supseteq", true);
  4569. defineSymbol(math, ams, rel, "\u2288", "\\nsubseteq", true);
  4570. defineSymbol(math, ams, rel, "\u2289", "\\nsupseteq", true);
  4571. defineSymbol(math, main, rel, "\u22A8", "\\models");
  4572. defineSymbol(math, main, rel, "\u2190", "\\leftarrow", true);
  4573. defineSymbol(math, main, rel, "\u2264", "\\le");
  4574. defineSymbol(math, main, rel, "\u2264", "\\leq", true);
  4575. defineSymbol(math, main, rel, "<", "\\lt", true);
  4576. defineSymbol(math, main, rel, "\u2192", "\\rightarrow", true);
  4577. defineSymbol(math, main, rel, "\u2192", "\\to");
  4578. defineSymbol(math, ams, rel, "\u2271", "\\ngeq", true);
  4579. defineSymbol(math, ams, rel, "\u2270", "\\nleq", true);
  4580. defineSymbol(math, main, spacing, "\xA0", "\\ ");
  4581. defineSymbol(math, main, spacing, "\xA0", "\\space"); // Ref: LaTeX Source 2e: \DeclareRobustCommand{\nobreakspace}{%
  4582. defineSymbol(math, main, spacing, "\xA0", "\\nobreakspace");
  4583. defineSymbol(symbols_text, main, spacing, "\xA0", "\\ ");
  4584. defineSymbol(symbols_text, main, spacing, "\xA0", " ");
  4585. defineSymbol(symbols_text, main, spacing, "\xA0", "\\space");
  4586. defineSymbol(symbols_text, main, spacing, "\xA0", "\\nobreakspace");
  4587. defineSymbol(math, main, spacing, null, "\\nobreak");
  4588. defineSymbol(math, main, spacing, null, "\\allowbreak");
  4589. defineSymbol(math, main, punct, ",", ",");
  4590. defineSymbol(math, main, punct, ";", ";");
  4591. defineSymbol(math, ams, bin, "\u22BC", "\\barwedge", true);
  4592. defineSymbol(math, ams, bin, "\u22BB", "\\veebar", true);
  4593. defineSymbol(math, main, bin, "\u2299", "\\odot", true);
  4594. defineSymbol(math, main, bin, "\u2295", "\\oplus", true);
  4595. defineSymbol(math, main, bin, "\u2297", "\\otimes", true);
  4596. defineSymbol(math, main, textord, "\u2202", "\\partial", true);
  4597. defineSymbol(math, main, bin, "\u2298", "\\oslash", true);
  4598. defineSymbol(math, ams, bin, "\u229A", "\\circledcirc", true);
  4599. defineSymbol(math, ams, bin, "\u22A1", "\\boxdot", true);
  4600. defineSymbol(math, main, bin, "\u25B3", "\\bigtriangleup");
  4601. defineSymbol(math, main, bin, "\u25BD", "\\bigtriangledown");
  4602. defineSymbol(math, main, bin, "\u2020", "\\dagger");
  4603. defineSymbol(math, main, bin, "\u22C4", "\\diamond");
  4604. defineSymbol(math, main, bin, "\u22C6", "\\star");
  4605. defineSymbol(math, main, bin, "\u25C3", "\\triangleleft");
  4606. defineSymbol(math, main, bin, "\u25B9", "\\triangleright");
  4607. defineSymbol(math, main, symbols_open, "{", "\\{");
  4608. defineSymbol(symbols_text, main, textord, "{", "\\{");
  4609. defineSymbol(symbols_text, main, textord, "{", "\\textbraceleft");
  4610. defineSymbol(math, main, symbols_close, "}", "\\}");
  4611. defineSymbol(symbols_text, main, textord, "}", "\\}");
  4612. defineSymbol(symbols_text, main, textord, "}", "\\textbraceright");
  4613. defineSymbol(math, main, symbols_open, "{", "\\lbrace");
  4614. defineSymbol(math, main, symbols_close, "}", "\\rbrace");
  4615. defineSymbol(math, main, symbols_open, "[", "\\lbrack", true);
  4616. defineSymbol(symbols_text, main, textord, "[", "\\lbrack", true);
  4617. defineSymbol(math, main, symbols_close, "]", "\\rbrack", true);
  4618. defineSymbol(symbols_text, main, textord, "]", "\\rbrack", true);
  4619. defineSymbol(math, main, symbols_open, "(", "\\lparen", true);
  4620. defineSymbol(math, main, symbols_close, ")", "\\rparen", true);
  4621. defineSymbol(symbols_text, main, textord, "<", "\\textless", true); // in T1 fontenc
  4622. defineSymbol(symbols_text, main, textord, ">", "\\textgreater", true); // in T1 fontenc
  4623. defineSymbol(math, main, symbols_open, "\u230A", "\\lfloor", true);
  4624. defineSymbol(math, main, symbols_close, "\u230B", "\\rfloor", true);
  4625. defineSymbol(math, main, symbols_open, "\u2308", "\\lceil", true);
  4626. defineSymbol(math, main, symbols_close, "\u2309", "\\rceil", true);
  4627. defineSymbol(math, main, textord, "\\", "\\backslash");
  4628. defineSymbol(math, main, textord, "\u2223", "|");
  4629. defineSymbol(math, main, textord, "\u2223", "\\vert");
  4630. defineSymbol(symbols_text, main, textord, "|", "\\textbar", true); // in T1 fontenc
  4631. defineSymbol(math, main, textord, "\u2225", "\\|");
  4632. defineSymbol(math, main, textord, "\u2225", "\\Vert");
  4633. defineSymbol(symbols_text, main, textord, "\u2225", "\\textbardbl");
  4634. defineSymbol(symbols_text, main, textord, "~", "\\textasciitilde");
  4635. defineSymbol(symbols_text, main, textord, "\\", "\\textbackslash");
  4636. defineSymbol(symbols_text, main, textord, "^", "\\textasciicircum");
  4637. defineSymbol(math, main, rel, "\u2191", "\\uparrow", true);
  4638. defineSymbol(math, main, rel, "\u21D1", "\\Uparrow", true);
  4639. defineSymbol(math, main, rel, "\u2193", "\\downarrow", true);
  4640. defineSymbol(math, main, rel, "\u21D3", "\\Downarrow", true);
  4641. defineSymbol(math, main, rel, "\u2195", "\\updownarrow", true);
  4642. defineSymbol(math, main, rel, "\u21D5", "\\Updownarrow", true);
  4643. defineSymbol(math, main, op, "\u2210", "\\coprod");
  4644. defineSymbol(math, main, op, "\u22C1", "\\bigvee");
  4645. defineSymbol(math, main, op, "\u22C0", "\\bigwedge");
  4646. defineSymbol(math, main, op, "\u2A04", "\\biguplus");
  4647. defineSymbol(math, main, op, "\u22C2", "\\bigcap");
  4648. defineSymbol(math, main, op, "\u22C3", "\\bigcup");
  4649. defineSymbol(math, main, op, "\u222B", "\\int");
  4650. defineSymbol(math, main, op, "\u222B", "\\intop");
  4651. defineSymbol(math, main, op, "\u222C", "\\iint");
  4652. defineSymbol(math, main, op, "\u222D", "\\iiint");
  4653. defineSymbol(math, main, op, "\u220F", "\\prod");
  4654. defineSymbol(math, main, op, "\u2211", "\\sum");
  4655. defineSymbol(math, main, op, "\u2A02", "\\bigotimes");
  4656. defineSymbol(math, main, op, "\u2A01", "\\bigoplus");
  4657. defineSymbol(math, main, op, "\u2A00", "\\bigodot");
  4658. defineSymbol(math, main, op, "\u222E", "\\oint");
  4659. defineSymbol(math, main, op, "\u222F", "\\oiint");
  4660. defineSymbol(math, main, op, "\u2230", "\\oiiint");
  4661. defineSymbol(math, main, op, "\u2A06", "\\bigsqcup");
  4662. defineSymbol(math, main, op, "\u222B", "\\smallint");
  4663. defineSymbol(symbols_text, main, inner, "\u2026", "\\textellipsis");
  4664. defineSymbol(math, main, inner, "\u2026", "\\mathellipsis");
  4665. defineSymbol(symbols_text, main, inner, "\u2026", "\\ldots", true);
  4666. defineSymbol(math, main, inner, "\u2026", "\\ldots", true);
  4667. defineSymbol(math, main, inner, "\u22EF", "\\@cdots", true);
  4668. defineSymbol(math, main, inner, "\u22F1", "\\ddots", true);
  4669. defineSymbol(math, main, textord, "\u22EE", "\\varvdots"); // \vdots is a macro
  4670. defineSymbol(math, main, accent, "\u02CA", "\\acute");
  4671. defineSymbol(math, main, accent, "\u02CB", "\\grave");
  4672. defineSymbol(math, main, accent, "\xA8", "\\ddot");
  4673. defineSymbol(math, main, accent, "~", "\\tilde");
  4674. defineSymbol(math, main, accent, "\u02C9", "\\bar");
  4675. defineSymbol(math, main, accent, "\u02D8", "\\breve");
  4676. defineSymbol(math, main, accent, "\u02C7", "\\check");
  4677. defineSymbol(math, main, accent, "^", "\\hat");
  4678. defineSymbol(math, main, accent, "\u20D7", "\\vec");
  4679. defineSymbol(math, main, accent, "\u02D9", "\\dot");
  4680. defineSymbol(math, main, accent, "\u02DA", "\\mathring"); // \imath and \jmath should be invariant to \mathrm, \mathbf, etc., so use PUA
  4681. defineSymbol(math, main, mathord, "\uE131", "\\@imath");
  4682. defineSymbol(math, main, mathord, "\uE237", "\\@jmath");
  4683. defineSymbol(math, main, textord, "\u0131", "\u0131");
  4684. defineSymbol(math, main, textord, "\u0237", "\u0237");
  4685. defineSymbol(symbols_text, main, textord, "\u0131", "\\i", true);
  4686. defineSymbol(symbols_text, main, textord, "\u0237", "\\j", true);
  4687. defineSymbol(symbols_text, main, textord, "\xDF", "\\ss", true);
  4688. defineSymbol(symbols_text, main, textord, "\xE6", "\\ae", true);
  4689. defineSymbol(symbols_text, main, textord, "\u0153", "\\oe", true);
  4690. defineSymbol(symbols_text, main, textord, "\xF8", "\\o", true);
  4691. defineSymbol(symbols_text, main, textord, "\xC6", "\\AE", true);
  4692. defineSymbol(symbols_text, main, textord, "\u0152", "\\OE", true);
  4693. defineSymbol(symbols_text, main, textord, "\xD8", "\\O", true);
  4694. defineSymbol(symbols_text, main, accent, "\u02CA", "\\'"); // acute
  4695. defineSymbol(symbols_text, main, accent, "\u02CB", "\\`"); // grave
  4696. defineSymbol(symbols_text, main, accent, "\u02C6", "\\^"); // circumflex
  4697. defineSymbol(symbols_text, main, accent, "\u02DC", "\\~"); // tilde
  4698. defineSymbol(symbols_text, main, accent, "\u02C9", "\\="); // macron
  4699. defineSymbol(symbols_text, main, accent, "\u02D8", "\\u"); // breve
  4700. defineSymbol(symbols_text, main, accent, "\u02D9", "\\."); // dot above
  4701. defineSymbol(symbols_text, main, accent, "\xB8", "\\c"); // cedilla
  4702. defineSymbol(symbols_text, main, accent, "\u02DA", "\\r"); // ring above
  4703. defineSymbol(symbols_text, main, accent, "\u02C7", "\\v"); // caron
  4704. defineSymbol(symbols_text, main, accent, "\xA8", '\\"'); // diaresis
  4705. defineSymbol(symbols_text, main, accent, "\u02DD", "\\H"); // double acute
  4706. defineSymbol(symbols_text, main, accent, "\u25EF", "\\textcircled"); // \bigcirc glyph
  4707. // These ligatures are detected and created in Parser.js's `formLigatures`.
  4708. var ligatures = {
  4709. "--": true,
  4710. "---": true,
  4711. "``": true,
  4712. "''": true
  4713. };
  4714. defineSymbol(symbols_text, main, textord, "\u2013", "--", true);
  4715. defineSymbol(symbols_text, main, textord, "\u2013", "\\textendash");
  4716. defineSymbol(symbols_text, main, textord, "\u2014", "---", true);
  4717. defineSymbol(symbols_text, main, textord, "\u2014", "\\textemdash");
  4718. defineSymbol(symbols_text, main, textord, "\u2018", "`", true);
  4719. defineSymbol(symbols_text, main, textord, "\u2018", "\\textquoteleft");
  4720. defineSymbol(symbols_text, main, textord, "\u2019", "'", true);
  4721. defineSymbol(symbols_text, main, textord, "\u2019", "\\textquoteright");
  4722. defineSymbol(symbols_text, main, textord, "\u201C", "``", true);
  4723. defineSymbol(symbols_text, main, textord, "\u201C", "\\textquotedblleft");
  4724. defineSymbol(symbols_text, main, textord, "\u201D", "''", true);
  4725. defineSymbol(symbols_text, main, textord, "\u201D", "\\textquotedblright"); // \degree from gensymb package
  4726. defineSymbol(math, main, textord, "\xB0", "\\degree", true);
  4727. defineSymbol(symbols_text, main, textord, "\xB0", "\\degree"); // \textdegree from inputenc package
  4728. defineSymbol(symbols_text, main, textord, "\xB0", "\\textdegree", true); // TODO: In LaTeX, \pounds can generate a different character in text and math
  4729. // mode, but among our fonts, only Main-Regular defines this character "163".
  4730. defineSymbol(math, main, textord, "\xA3", "\\pounds");
  4731. defineSymbol(math, main, textord, "\xA3", "\\mathsterling", true);
  4732. defineSymbol(symbols_text, main, textord, "\xA3", "\\pounds");
  4733. defineSymbol(symbols_text, main, textord, "\xA3", "\\textsterling", true);
  4734. defineSymbol(math, ams, textord, "\u2720", "\\maltese");
  4735. defineSymbol(symbols_text, ams, textord, "\u2720", "\\maltese"); // There are lots of symbols which are the same, so we add them in afterwards.
  4736. // All of these are textords in math mode
  4737. var mathTextSymbols = "0123456789/@.\"";
  4738. for (var i = 0; i < mathTextSymbols.length; i++) {
  4739. var ch = mathTextSymbols.charAt(i);
  4740. defineSymbol(math, main, textord, ch, ch);
  4741. } // All of these are textords in text mode
  4742. var textSymbols = "0123456789!@*()-=+\";:?/.,";
  4743. for (var _i = 0; _i < textSymbols.length; _i++) {
  4744. var _ch = textSymbols.charAt(_i);
  4745. defineSymbol(symbols_text, main, textord, _ch, _ch);
  4746. } // All of these are textords in text mode, and mathords in math mode
  4747. var letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
  4748. for (var _i2 = 0; _i2 < letters.length; _i2++) {
  4749. var _ch2 = letters.charAt(_i2);
  4750. defineSymbol(math, main, mathord, _ch2, _ch2);
  4751. defineSymbol(symbols_text, main, textord, _ch2, _ch2);
  4752. } // Blackboard bold and script letters in Unicode range
  4753. defineSymbol(math, ams, textord, "C", "\u2102"); // blackboard bold
  4754. defineSymbol(symbols_text, ams, textord, "C", "\u2102");
  4755. defineSymbol(math, ams, textord, "H", "\u210D");
  4756. defineSymbol(symbols_text, ams, textord, "H", "\u210D");
  4757. defineSymbol(math, ams, textord, "N", "\u2115");
  4758. defineSymbol(symbols_text, ams, textord, "N", "\u2115");
  4759. defineSymbol(math, ams, textord, "P", "\u2119");
  4760. defineSymbol(symbols_text, ams, textord, "P", "\u2119");
  4761. defineSymbol(math, ams, textord, "Q", "\u211A");
  4762. defineSymbol(symbols_text, ams, textord, "Q", "\u211A");
  4763. defineSymbol(math, ams, textord, "R", "\u211D");
  4764. defineSymbol(symbols_text, ams, textord, "R", "\u211D");
  4765. defineSymbol(math, ams, textord, "Z", "\u2124");
  4766. defineSymbol(symbols_text, ams, textord, "Z", "\u2124");
  4767. defineSymbol(math, main, mathord, "h", "\u210E"); // italic h, Planck constant
  4768. defineSymbol(symbols_text, main, mathord, "h", "\u210E"); // The next loop loads wide (surrogate pair) characters.
  4769. // We support some letters in the Unicode range U+1D400 to U+1D7FF,
  4770. // Mathematical Alphanumeric Symbols.
  4771. // Some editors do not deal well with wide characters. So don't write the
  4772. // string into this file. Instead, create the string from the surrogate pair.
  4773. var wideChar = "";
  4774. for (var _i3 = 0; _i3 < letters.length; _i3++) {
  4775. var _ch3 = letters.charAt(_i3); // The hex numbers in the next line are a surrogate pair.
  4776. // 0xD835 is the high surrogate for all letters in the range we support.
  4777. // 0xDC00 is the low surrogate for bold A.
  4778. wideChar = String.fromCharCode(0xD835, 0xDC00 + _i3); // A-Z a-z bold
  4779. defineSymbol(math, main, mathord, _ch3, wideChar);
  4780. defineSymbol(symbols_text, main, textord, _ch3, wideChar);
  4781. wideChar = String.fromCharCode(0xD835, 0xDC34 + _i3); // A-Z a-z italic
  4782. defineSymbol(math, main, mathord, _ch3, wideChar);
  4783. defineSymbol(symbols_text, main, textord, _ch3, wideChar);
  4784. wideChar = String.fromCharCode(0xD835, 0xDC68 + _i3); // A-Z a-z bold italic
  4785. defineSymbol(math, main, mathord, _ch3, wideChar);
  4786. defineSymbol(symbols_text, main, textord, _ch3, wideChar);
  4787. wideChar = String.fromCharCode(0xD835, 0xDD04 + _i3); // A-Z a-z Fractur
  4788. defineSymbol(math, main, mathord, _ch3, wideChar);
  4789. defineSymbol(symbols_text, main, textord, _ch3, wideChar);
  4790. wideChar = String.fromCharCode(0xD835, 0xDDA0 + _i3); // A-Z a-z sans-serif
  4791. defineSymbol(math, main, mathord, _ch3, wideChar);
  4792. defineSymbol(symbols_text, main, textord, _ch3, wideChar);
  4793. wideChar = String.fromCharCode(0xD835, 0xDDD4 + _i3); // A-Z a-z sans bold
  4794. defineSymbol(math, main, mathord, _ch3, wideChar);
  4795. defineSymbol(symbols_text, main, textord, _ch3, wideChar);
  4796. wideChar = String.fromCharCode(0xD835, 0xDE08 + _i3); // A-Z a-z sans italic
  4797. defineSymbol(math, main, mathord, _ch3, wideChar);
  4798. defineSymbol(symbols_text, main, textord, _ch3, wideChar);
  4799. wideChar = String.fromCharCode(0xD835, 0xDE70 + _i3); // A-Z a-z monospace
  4800. defineSymbol(math, main, mathord, _ch3, wideChar);
  4801. defineSymbol(symbols_text, main, textord, _ch3, wideChar);
  4802. if (_i3 < 26) {
  4803. // KaTeX fonts have only capital letters for blackboard bold and script.
  4804. // See exception for k below.
  4805. wideChar = String.fromCharCode(0xD835, 0xDD38 + _i3); // A-Z double struck
  4806. defineSymbol(math, main, mathord, _ch3, wideChar);
  4807. defineSymbol(symbols_text, main, textord, _ch3, wideChar);
  4808. wideChar = String.fromCharCode(0xD835, 0xDC9C + _i3); // A-Z script
  4809. defineSymbol(math, main, mathord, _ch3, wideChar);
  4810. defineSymbol(symbols_text, main, textord, _ch3, wideChar);
  4811. } // TODO: Add bold script when it is supported by a KaTeX font.
  4812. } // "k" is the only double struck lower case letter in the KaTeX fonts.
  4813. wideChar = String.fromCharCode(0xD835, 0xDD5C); // k double struck
  4814. defineSymbol(math, main, mathord, "k", wideChar);
  4815. defineSymbol(symbols_text, main, textord, "k", wideChar); // Next, some wide character numerals
  4816. for (var _i4 = 0; _i4 < 10; _i4++) {
  4817. var _ch4 = _i4.toString();
  4818. wideChar = String.fromCharCode(0xD835, 0xDFCE + _i4); // 0-9 bold
  4819. defineSymbol(math, main, mathord, _ch4, wideChar);
  4820. defineSymbol(symbols_text, main, textord, _ch4, wideChar);
  4821. wideChar = String.fromCharCode(0xD835, 0xDFE2 + _i4); // 0-9 sans serif
  4822. defineSymbol(math, main, mathord, _ch4, wideChar);
  4823. defineSymbol(symbols_text, main, textord, _ch4, wideChar);
  4824. wideChar = String.fromCharCode(0xD835, 0xDFEC + _i4); // 0-9 bold sans
  4825. defineSymbol(math, main, mathord, _ch4, wideChar);
  4826. defineSymbol(symbols_text, main, textord, _ch4, wideChar);
  4827. wideChar = String.fromCharCode(0xD835, 0xDFF6 + _i4); // 0-9 monospace
  4828. defineSymbol(math, main, mathord, _ch4, wideChar);
  4829. defineSymbol(symbols_text, main, textord, _ch4, wideChar);
  4830. } // We add these Latin-1 letters as symbols for backwards-compatibility,
  4831. // but they are not actually in the font, nor are they supported by the
  4832. // Unicode accent mechanism, so they fall back to Times font and look ugly.
  4833. // TODO(edemaine): Fix this.
  4834. var extraLatin = "\xD0\xDE\xFE";
  4835. for (var _i5 = 0; _i5 < extraLatin.length; _i5++) {
  4836. var _ch5 = extraLatin.charAt(_i5);
  4837. defineSymbol(math, main, mathord, _ch5, _ch5);
  4838. defineSymbol(symbols_text, main, textord, _ch5, _ch5);
  4839. }
  4840. ;// CONCATENATED MODULE: ./src/wide-character.js
  4841. /**
  4842. * This file provides support for Unicode range U+1D400 to U+1D7FF,
  4843. * Mathematical Alphanumeric Symbols.
  4844. *
  4845. * Function wideCharacterFont takes a wide character as input and returns
  4846. * the font information necessary to render it properly.
  4847. */
  4848. /**
  4849. * Data below is from https://www.unicode.org/charts/PDF/U1D400.pdf
  4850. * That document sorts characters into groups by font type, say bold or italic.
  4851. *
  4852. * In the arrays below, each subarray consists three elements:
  4853. * * The CSS class of that group when in math mode.
  4854. * * The CSS class of that group when in text mode.
  4855. * * The font name, so that KaTeX can get font metrics.
  4856. */
  4857. var wideLatinLetterData = [["mathbf", "textbf", "Main-Bold"], // A-Z bold upright
  4858. ["mathbf", "textbf", "Main-Bold"], // a-z bold upright
  4859. ["mathnormal", "textit", "Math-Italic"], // A-Z italic
  4860. ["mathnormal", "textit", "Math-Italic"], // a-z italic
  4861. ["boldsymbol", "boldsymbol", "Main-BoldItalic"], // A-Z bold italic
  4862. ["boldsymbol", "boldsymbol", "Main-BoldItalic"], // a-z bold italic
  4863. // Map fancy A-Z letters to script, not calligraphic.
  4864. // This aligns with unicode-math and math fonts (except Cambria Math).
  4865. ["mathscr", "textscr", "Script-Regular"], // A-Z script
  4866. ["", "", ""], // a-z script. No font
  4867. ["", "", ""], // A-Z bold script. No font
  4868. ["", "", ""], // a-z bold script. No font
  4869. ["mathfrak", "textfrak", "Fraktur-Regular"], // A-Z Fraktur
  4870. ["mathfrak", "textfrak", "Fraktur-Regular"], // a-z Fraktur
  4871. ["mathbb", "textbb", "AMS-Regular"], // A-Z double-struck
  4872. ["mathbb", "textbb", "AMS-Regular"], // k double-struck
  4873. ["", "", ""], // A-Z bold Fraktur No font metrics
  4874. ["", "", ""], // a-z bold Fraktur. No font.
  4875. ["mathsf", "textsf", "SansSerif-Regular"], // A-Z sans-serif
  4876. ["mathsf", "textsf", "SansSerif-Regular"], // a-z sans-serif
  4877. ["mathboldsf", "textboldsf", "SansSerif-Bold"], // A-Z bold sans-serif
  4878. ["mathboldsf", "textboldsf", "SansSerif-Bold"], // a-z bold sans-serif
  4879. ["mathitsf", "textitsf", "SansSerif-Italic"], // A-Z italic sans-serif
  4880. ["mathitsf", "textitsf", "SansSerif-Italic"], // a-z italic sans-serif
  4881. ["", "", ""], // A-Z bold italic sans. No font
  4882. ["", "", ""], // a-z bold italic sans. No font
  4883. ["mathtt", "texttt", "Typewriter-Regular"], // A-Z monospace
  4884. ["mathtt", "texttt", "Typewriter-Regular"] // a-z monospace
  4885. ];
  4886. var wideNumeralData = [["mathbf", "textbf", "Main-Bold"], // 0-9 bold
  4887. ["", "", ""], // 0-9 double-struck. No KaTeX font.
  4888. ["mathsf", "textsf", "SansSerif-Regular"], // 0-9 sans-serif
  4889. ["mathboldsf", "textboldsf", "SansSerif-Bold"], // 0-9 bold sans-serif
  4890. ["mathtt", "texttt", "Typewriter-Regular"] // 0-9 monospace
  4891. ];
  4892. var wideCharacterFont = function wideCharacterFont(wideChar, mode) {
  4893. // IE doesn't support codePointAt(). So work with the surrogate pair.
  4894. var H = wideChar.charCodeAt(0); // high surrogate
  4895. var L = wideChar.charCodeAt(1); // low surrogate
  4896. var codePoint = (H - 0xD800) * 0x400 + (L - 0xDC00) + 0x10000;
  4897. var j = mode === "math" ? 0 : 1; // column index for CSS class.
  4898. if (0x1D400 <= codePoint && codePoint < 0x1D6A4) {
  4899. // wideLatinLetterData contains exactly 26 chars on each row.
  4900. // So we can calculate the relevant row. No traverse necessary.
  4901. var i = Math.floor((codePoint - 0x1D400) / 26);
  4902. return [wideLatinLetterData[i][2], wideLatinLetterData[i][j]];
  4903. } else if (0x1D7CE <= codePoint && codePoint <= 0x1D7FF) {
  4904. // Numerals, ten per row.
  4905. var _i = Math.floor((codePoint - 0x1D7CE) / 10);
  4906. return [wideNumeralData[_i][2], wideNumeralData[_i][j]];
  4907. } else if (codePoint === 0x1D6A5 || codePoint === 0x1D6A6) {
  4908. // dotless i or j
  4909. return [wideLatinLetterData[0][2], wideLatinLetterData[0][j]];
  4910. } else if (0x1D6A6 < codePoint && codePoint < 0x1D7CE) {
  4911. // Greek letters. Not supported, yet.
  4912. return ["", ""];
  4913. } else {
  4914. // We don't support any wide characters outside 1D400–1D7FF.
  4915. throw new src_ParseError("Unsupported character: " + wideChar);
  4916. }
  4917. };
  4918. ;// CONCATENATED MODULE: ./src/buildCommon.js
  4919. /* eslint no-console:0 */
  4920. /**
  4921. * This module contains general functions that can be used for building
  4922. * different kinds of domTree nodes in a consistent manner.
  4923. */
  4924. /**
  4925. * Looks up the given symbol in fontMetrics, after applying any symbol
  4926. * replacements defined in symbol.js
  4927. */
  4928. var lookupSymbol = function lookupSymbol(value, // TODO(#963): Use a union type for this.
  4929. fontName, mode) {
  4930. // Replace the value with its replaced value from symbol.js
  4931. if (src_symbols[mode][value] && src_symbols[mode][value].replace) {
  4932. value = src_symbols[mode][value].replace;
  4933. }
  4934. return {
  4935. value: value,
  4936. metrics: getCharacterMetrics(value, fontName, mode)
  4937. };
  4938. };
  4939. /**
  4940. * Makes a symbolNode after translation via the list of symbols in symbols.js.
  4941. * Correctly pulls out metrics for the character, and optionally takes a list of
  4942. * classes to be attached to the node.
  4943. *
  4944. * TODO: make argument order closer to makeSpan
  4945. * TODO: add a separate argument for math class (e.g. `mop`, `mbin`), which
  4946. * should if present come first in `classes`.
  4947. * TODO(#953): Make `options` mandatory and always pass it in.
  4948. */
  4949. var makeSymbol = function makeSymbol(value, fontName, mode, options, classes) {
  4950. var lookup = lookupSymbol(value, fontName, mode);
  4951. var metrics = lookup.metrics;
  4952. value = lookup.value;
  4953. var symbolNode;
  4954. if (metrics) {
  4955. var italic = metrics.italic;
  4956. if (mode === "text" || options && options.font === "mathit") {
  4957. italic = 0;
  4958. }
  4959. symbolNode = new SymbolNode(value, metrics.height, metrics.depth, italic, metrics.skew, metrics.width, classes);
  4960. } else {
  4961. // TODO(emily): Figure out a good way to only print this in development
  4962. typeof console !== "undefined" && console.warn("No character metrics " + ("for '" + value + "' in style '" + fontName + "' and mode '" + mode + "'"));
  4963. symbolNode = new SymbolNode(value, 0, 0, 0, 0, 0, classes);
  4964. }
  4965. if (options) {
  4966. symbolNode.maxFontSize = options.sizeMultiplier;
  4967. if (options.style.isTight()) {
  4968. symbolNode.classes.push("mtight");
  4969. }
  4970. var color = options.getColor();
  4971. if (color) {
  4972. symbolNode.style.color = color;
  4973. }
  4974. }
  4975. return symbolNode;
  4976. };
  4977. /**
  4978. * Makes a symbol in Main-Regular or AMS-Regular.
  4979. * Used for rel, bin, open, close, inner, and punct.
  4980. */
  4981. var mathsym = function mathsym(value, mode, options, classes) {
  4982. if (classes === void 0) {
  4983. classes = [];
  4984. }
  4985. // Decide what font to render the symbol in by its entry in the symbols
  4986. // table.
  4987. // Have a special case for when the value = \ because the \ is used as a
  4988. // textord in unsupported command errors but cannot be parsed as a regular
  4989. // text ordinal and is therefore not present as a symbol in the symbols
  4990. // table for text, as well as a special case for boldsymbol because it
  4991. // can be used for bold + and -
  4992. if (options.font === "boldsymbol" && lookupSymbol(value, "Main-Bold", mode).metrics) {
  4993. return makeSymbol(value, "Main-Bold", mode, options, classes.concat(["mathbf"]));
  4994. } else if (value === "\\" || src_symbols[mode][value].font === "main") {
  4995. return makeSymbol(value, "Main-Regular", mode, options, classes);
  4996. } else {
  4997. return makeSymbol(value, "AMS-Regular", mode, options, classes.concat(["amsrm"]));
  4998. }
  4999. };
  5000. /**
  5001. * Determines which of the two font names (Main-Bold and Math-BoldItalic) and
  5002. * corresponding style tags (mathbf or boldsymbol) to use for font "boldsymbol",
  5003. * depending on the symbol. Use this function instead of fontMap for font
  5004. * "boldsymbol".
  5005. */
  5006. var boldsymbol = function boldsymbol(value, mode, options, classes, type) {
  5007. if (type !== "textord" && lookupSymbol(value, "Math-BoldItalic", mode).metrics) {
  5008. return {
  5009. fontName: "Math-BoldItalic",
  5010. fontClass: "boldsymbol"
  5011. };
  5012. } else {
  5013. // Some glyphs do not exist in Math-BoldItalic so we need to use
  5014. // Main-Bold instead.
  5015. return {
  5016. fontName: "Main-Bold",
  5017. fontClass: "mathbf"
  5018. };
  5019. }
  5020. };
  5021. /**
  5022. * Makes either a mathord or textord in the correct font and color.
  5023. */
  5024. var makeOrd = function makeOrd(group, options, type) {
  5025. var mode = group.mode;
  5026. var text = group.text;
  5027. var classes = ["mord"]; // Math mode or Old font (i.e. \rm)
  5028. var isFont = mode === "math" || mode === "text" && options.font;
  5029. var fontOrFamily = isFont ? options.font : options.fontFamily;
  5030. if (text.charCodeAt(0) === 0xD835) {
  5031. // surrogate pairs get special treatment
  5032. var _wideCharacterFont = wideCharacterFont(text, mode),
  5033. wideFontName = _wideCharacterFont[0],
  5034. wideFontClass = _wideCharacterFont[1];
  5035. return makeSymbol(text, wideFontName, mode, options, classes.concat(wideFontClass));
  5036. } else if (fontOrFamily) {
  5037. var fontName;
  5038. var fontClasses;
  5039. if (fontOrFamily === "boldsymbol") {
  5040. var fontData = boldsymbol(text, mode, options, classes, type);
  5041. fontName = fontData.fontName;
  5042. fontClasses = [fontData.fontClass];
  5043. } else if (isFont) {
  5044. fontName = fontMap[fontOrFamily].fontName;
  5045. fontClasses = [fontOrFamily];
  5046. } else {
  5047. fontName = retrieveTextFontName(fontOrFamily, options.fontWeight, options.fontShape);
  5048. fontClasses = [fontOrFamily, options.fontWeight, options.fontShape];
  5049. }
  5050. if (lookupSymbol(text, fontName, mode).metrics) {
  5051. return makeSymbol(text, fontName, mode, options, classes.concat(fontClasses));
  5052. } else if (ligatures.hasOwnProperty(text) && fontName.substr(0, 10) === "Typewriter") {
  5053. // Deconstruct ligatures in monospace fonts (\texttt, \tt).
  5054. var parts = [];
  5055. for (var i = 0; i < text.length; i++) {
  5056. parts.push(makeSymbol(text[i], fontName, mode, options, classes.concat(fontClasses)));
  5057. }
  5058. return makeFragment(parts);
  5059. }
  5060. } // Makes a symbol in the default font for mathords and textords.
  5061. if (type === "mathord") {
  5062. return makeSymbol(text, "Math-Italic", mode, options, classes.concat(["mathnormal"]));
  5063. } else if (type === "textord") {
  5064. var font = src_symbols[mode][text] && src_symbols[mode][text].font;
  5065. if (font === "ams") {
  5066. var _fontName = retrieveTextFontName("amsrm", options.fontWeight, options.fontShape);
  5067. return makeSymbol(text, _fontName, mode, options, classes.concat("amsrm", options.fontWeight, options.fontShape));
  5068. } else if (font === "main" || !font) {
  5069. var _fontName2 = retrieveTextFontName("textrm", options.fontWeight, options.fontShape);
  5070. return makeSymbol(text, _fontName2, mode, options, classes.concat(options.fontWeight, options.fontShape));
  5071. } else {
  5072. // fonts added by plugins
  5073. var _fontName3 = retrieveTextFontName(font, options.fontWeight, options.fontShape); // We add font name as a css class
  5074. return makeSymbol(text, _fontName3, mode, options, classes.concat(_fontName3, options.fontWeight, options.fontShape));
  5075. }
  5076. } else {
  5077. throw new Error("unexpected type: " + type + " in makeOrd");
  5078. }
  5079. };
  5080. /**
  5081. * Returns true if subsequent symbolNodes have the same classes, skew, maxFont,
  5082. * and styles.
  5083. */
  5084. var canCombine = function canCombine(prev, next) {
  5085. if (createClass(prev.classes) !== createClass(next.classes) || prev.skew !== next.skew || prev.maxFontSize !== next.maxFontSize) {
  5086. return false;
  5087. } // If prev and next both are just "mbin"s or "mord"s we don't combine them
  5088. // so that the proper spacing can be preserved.
  5089. if (prev.classes.length === 1) {
  5090. var cls = prev.classes[0];
  5091. if (cls === "mbin" || cls === "mord") {
  5092. return false;
  5093. }
  5094. }
  5095. for (var style in prev.style) {
  5096. if (prev.style.hasOwnProperty(style) && prev.style[style] !== next.style[style]) {
  5097. return false;
  5098. }
  5099. }
  5100. for (var _style in next.style) {
  5101. if (next.style.hasOwnProperty(_style) && prev.style[_style] !== next.style[_style]) {
  5102. return false;
  5103. }
  5104. }
  5105. return true;
  5106. };
  5107. /**
  5108. * Combine consecutive domTree.symbolNodes into a single symbolNode.
  5109. * Note: this function mutates the argument.
  5110. */
  5111. var tryCombineChars = function tryCombineChars(chars) {
  5112. for (var i = 0; i < chars.length - 1; i++) {
  5113. var prev = chars[i];
  5114. var next = chars[i + 1];
  5115. if (prev instanceof SymbolNode && next instanceof SymbolNode && canCombine(prev, next)) {
  5116. prev.text += next.text;
  5117. prev.height = Math.max(prev.height, next.height);
  5118. prev.depth = Math.max(prev.depth, next.depth); // Use the last character's italic correction since we use
  5119. // it to add padding to the right of the span created from
  5120. // the combined characters.
  5121. prev.italic = next.italic;
  5122. chars.splice(i + 1, 1);
  5123. i--;
  5124. }
  5125. }
  5126. return chars;
  5127. };
  5128. /**
  5129. * Calculate the height, depth, and maxFontSize of an element based on its
  5130. * children.
  5131. */
  5132. var sizeElementFromChildren = function sizeElementFromChildren(elem) {
  5133. var height = 0;
  5134. var depth = 0;
  5135. var maxFontSize = 0;
  5136. for (var i = 0; i < elem.children.length; i++) {
  5137. var child = elem.children[i];
  5138. if (child.height > height) {
  5139. height = child.height;
  5140. }
  5141. if (child.depth > depth) {
  5142. depth = child.depth;
  5143. }
  5144. if (child.maxFontSize > maxFontSize) {
  5145. maxFontSize = child.maxFontSize;
  5146. }
  5147. }
  5148. elem.height = height;
  5149. elem.depth = depth;
  5150. elem.maxFontSize = maxFontSize;
  5151. };
  5152. /**
  5153. * Makes a span with the given list of classes, list of children, and options.
  5154. *
  5155. * TODO(#953): Ensure that `options` is always provided (currently some call
  5156. * sites don't pass it) and make the type below mandatory.
  5157. * TODO: add a separate argument for math class (e.g. `mop`, `mbin`), which
  5158. * should if present come first in `classes`.
  5159. */
  5160. var makeSpan = function makeSpan(classes, children, options, style) {
  5161. var span = new Span(classes, children, options, style);
  5162. sizeElementFromChildren(span);
  5163. return span;
  5164. }; // SVG one is simpler -- doesn't require height, depth, max-font setting.
  5165. // This is also a separate method for typesafety.
  5166. var makeSvgSpan = function makeSvgSpan(classes, children, options, style) {
  5167. return new Span(classes, children, options, style);
  5168. };
  5169. var makeLineSpan = function makeLineSpan(className, options, thickness) {
  5170. var line = makeSpan([className], [], options);
  5171. line.height = Math.max(thickness || options.fontMetrics().defaultRuleThickness, options.minRuleThickness);
  5172. line.style.borderBottomWidth = makeEm(line.height);
  5173. line.maxFontSize = 1.0;
  5174. return line;
  5175. };
  5176. /**
  5177. * Makes an anchor with the given href, list of classes, list of children,
  5178. * and options.
  5179. */
  5180. var makeAnchor = function makeAnchor(href, classes, children, options) {
  5181. var anchor = new Anchor(href, classes, children, options);
  5182. sizeElementFromChildren(anchor);
  5183. return anchor;
  5184. };
  5185. /**
  5186. * Makes a document fragment with the given list of children.
  5187. */
  5188. var makeFragment = function makeFragment(children) {
  5189. var fragment = new DocumentFragment(children);
  5190. sizeElementFromChildren(fragment);
  5191. return fragment;
  5192. };
  5193. /**
  5194. * Wraps group in a span if it's a document fragment, allowing to apply classes
  5195. * and styles
  5196. */
  5197. var wrapFragment = function wrapFragment(group, options) {
  5198. if (group instanceof DocumentFragment) {
  5199. return makeSpan([], [group], options);
  5200. }
  5201. return group;
  5202. }; // These are exact object types to catch typos in the names of the optional fields.
  5203. // Computes the updated `children` list and the overall depth.
  5204. //
  5205. // This helper function for makeVList makes it easier to enforce type safety by
  5206. // allowing early exits (returns) in the logic.
  5207. var getVListChildrenAndDepth = function getVListChildrenAndDepth(params) {
  5208. if (params.positionType === "individualShift") {
  5209. var oldChildren = params.children;
  5210. var children = [oldChildren[0]]; // Add in kerns to the list of params.children to get each element to be
  5211. // shifted to the correct specified shift
  5212. var _depth = -oldChildren[0].shift - oldChildren[0].elem.depth;
  5213. var currPos = _depth;
  5214. for (var i = 1; i < oldChildren.length; i++) {
  5215. var diff = -oldChildren[i].shift - currPos - oldChildren[i].elem.depth;
  5216. var size = diff - (oldChildren[i - 1].elem.height + oldChildren[i - 1].elem.depth);
  5217. currPos = currPos + diff;
  5218. children.push({
  5219. type: "kern",
  5220. size: size
  5221. });
  5222. children.push(oldChildren[i]);
  5223. }
  5224. return {
  5225. children: children,
  5226. depth: _depth
  5227. };
  5228. }
  5229. var depth;
  5230. if (params.positionType === "top") {
  5231. // We always start at the bottom, so calculate the bottom by adding up
  5232. // all the sizes
  5233. var bottom = params.positionData;
  5234. for (var _i = 0; _i < params.children.length; _i++) {
  5235. var child = params.children[_i];
  5236. bottom -= child.type === "kern" ? child.size : child.elem.height + child.elem.depth;
  5237. }
  5238. depth = bottom;
  5239. } else if (params.positionType === "bottom") {
  5240. depth = -params.positionData;
  5241. } else {
  5242. var firstChild = params.children[0];
  5243. if (firstChild.type !== "elem") {
  5244. throw new Error('First child must have type "elem".');
  5245. }
  5246. if (params.positionType === "shift") {
  5247. depth = -firstChild.elem.depth - params.positionData;
  5248. } else if (params.positionType === "firstBaseline") {
  5249. depth = -firstChild.elem.depth;
  5250. } else {
  5251. throw new Error("Invalid positionType " + params.positionType + ".");
  5252. }
  5253. }
  5254. return {
  5255. children: params.children,
  5256. depth: depth
  5257. };
  5258. };
  5259. /**
  5260. * Makes a vertical list by stacking elements and kerns on top of each other.
  5261. * Allows for many different ways of specifying the positioning method.
  5262. *
  5263. * See VListParam documentation above.
  5264. */
  5265. var makeVList = function makeVList(params, options) {
  5266. var _getVListChildrenAndD = getVListChildrenAndDepth(params),
  5267. children = _getVListChildrenAndD.children,
  5268. depth = _getVListChildrenAndD.depth; // Create a strut that is taller than any list item. The strut is added to
  5269. // each item, where it will determine the item's baseline. Since it has
  5270. // `overflow:hidden`, the strut's top edge will sit on the item's line box's
  5271. // top edge and the strut's bottom edge will sit on the item's baseline,
  5272. // with no additional line-height spacing. This allows the item baseline to
  5273. // be positioned precisely without worrying about font ascent and
  5274. // line-height.
  5275. var pstrutSize = 0;
  5276. for (var i = 0; i < children.length; i++) {
  5277. var child = children[i];
  5278. if (child.type === "elem") {
  5279. var elem = child.elem;
  5280. pstrutSize = Math.max(pstrutSize, elem.maxFontSize, elem.height);
  5281. }
  5282. }
  5283. pstrutSize += 2;
  5284. var pstrut = makeSpan(["pstrut"], []);
  5285. pstrut.style.height = makeEm(pstrutSize); // Create a new list of actual children at the correct offsets
  5286. var realChildren = [];
  5287. var minPos = depth;
  5288. var maxPos = depth;
  5289. var currPos = depth;
  5290. for (var _i2 = 0; _i2 < children.length; _i2++) {
  5291. var _child = children[_i2];
  5292. if (_child.type === "kern") {
  5293. currPos += _child.size;
  5294. } else {
  5295. var _elem = _child.elem;
  5296. var classes = _child.wrapperClasses || [];
  5297. var style = _child.wrapperStyle || {};
  5298. var childWrap = makeSpan(classes, [pstrut, _elem], undefined, style);
  5299. childWrap.style.top = makeEm(-pstrutSize - currPos - _elem.depth);
  5300. if (_child.marginLeft) {
  5301. childWrap.style.marginLeft = _child.marginLeft;
  5302. }
  5303. if (_child.marginRight) {
  5304. childWrap.style.marginRight = _child.marginRight;
  5305. }
  5306. realChildren.push(childWrap);
  5307. currPos += _elem.height + _elem.depth;
  5308. }
  5309. minPos = Math.min(minPos, currPos);
  5310. maxPos = Math.max(maxPos, currPos);
  5311. } // The vlist contents go in a table-cell with `vertical-align:bottom`.
  5312. // This cell's bottom edge will determine the containing table's baseline
  5313. // without overly expanding the containing line-box.
  5314. var vlist = makeSpan(["vlist"], realChildren);
  5315. vlist.style.height = makeEm(maxPos); // A second row is used if necessary to represent the vlist's depth.
  5316. var rows;
  5317. if (minPos < 0) {
  5318. // We will define depth in an empty span with display: table-cell.
  5319. // It should render with the height that we define. But Chrome, in
  5320. // contenteditable mode only, treats that span as if it contains some
  5321. // text content. And that min-height over-rides our desired height.
  5322. // So we put another empty span inside the depth strut span.
  5323. var emptySpan = makeSpan([], []);
  5324. var depthStrut = makeSpan(["vlist"], [emptySpan]);
  5325. depthStrut.style.height = makeEm(-minPos); // Safari wants the first row to have inline content; otherwise it
  5326. // puts the bottom of the *second* row on the baseline.
  5327. var topStrut = makeSpan(["vlist-s"], [new SymbolNode("\u200B")]);
  5328. rows = [makeSpan(["vlist-r"], [vlist, topStrut]), makeSpan(["vlist-r"], [depthStrut])];
  5329. } else {
  5330. rows = [makeSpan(["vlist-r"], [vlist])];
  5331. }
  5332. var vtable = makeSpan(["vlist-t"], rows);
  5333. if (rows.length === 2) {
  5334. vtable.classes.push("vlist-t2");
  5335. }
  5336. vtable.height = maxPos;
  5337. vtable.depth = -minPos;
  5338. return vtable;
  5339. }; // Glue is a concept from TeX which is a flexible space between elements in
  5340. // either a vertical or horizontal list. In KaTeX, at least for now, it's
  5341. // static space between elements in a horizontal layout.
  5342. var makeGlue = function makeGlue(measurement, options) {
  5343. // Make an empty span for the space
  5344. var rule = makeSpan(["mspace"], [], options);
  5345. var size = calculateSize(measurement, options);
  5346. rule.style.marginRight = makeEm(size);
  5347. return rule;
  5348. }; // Takes font options, and returns the appropriate fontLookup name
  5349. var retrieveTextFontName = function retrieveTextFontName(fontFamily, fontWeight, fontShape) {
  5350. var baseFontName = "";
  5351. switch (fontFamily) {
  5352. case "amsrm":
  5353. baseFontName = "AMS";
  5354. break;
  5355. case "textrm":
  5356. baseFontName = "Main";
  5357. break;
  5358. case "textsf":
  5359. baseFontName = "SansSerif";
  5360. break;
  5361. case "texttt":
  5362. baseFontName = "Typewriter";
  5363. break;
  5364. default:
  5365. baseFontName = fontFamily;
  5366. // use fonts added by a plugin
  5367. }
  5368. var fontStylesName;
  5369. if (fontWeight === "textbf" && fontShape === "textit") {
  5370. fontStylesName = "BoldItalic";
  5371. } else if (fontWeight === "textbf") {
  5372. fontStylesName = "Bold";
  5373. } else if (fontWeight === "textit") {
  5374. fontStylesName = "Italic";
  5375. } else {
  5376. fontStylesName = "Regular";
  5377. }
  5378. return baseFontName + "-" + fontStylesName;
  5379. };
  5380. /**
  5381. * Maps TeX font commands to objects containing:
  5382. * - variant: string used for "mathvariant" attribute in buildMathML.js
  5383. * - fontName: the "style" parameter to fontMetrics.getCharacterMetrics
  5384. */
  5385. // A map between tex font commands an MathML mathvariant attribute values
  5386. var fontMap = {
  5387. // styles
  5388. "mathbf": {
  5389. variant: "bold",
  5390. fontName: "Main-Bold"
  5391. },
  5392. "mathrm": {
  5393. variant: "normal",
  5394. fontName: "Main-Regular"
  5395. },
  5396. "textit": {
  5397. variant: "italic",
  5398. fontName: "Main-Italic"
  5399. },
  5400. "mathit": {
  5401. variant: "italic",
  5402. fontName: "Main-Italic"
  5403. },
  5404. "mathnormal": {
  5405. variant: "italic",
  5406. fontName: "Math-Italic"
  5407. },
  5408. // "boldsymbol" is missing because they require the use of multiple fonts:
  5409. // Math-BoldItalic and Main-Bold. This is handled by a special case in
  5410. // makeOrd which ends up calling boldsymbol.
  5411. // families
  5412. "mathbb": {
  5413. variant: "double-struck",
  5414. fontName: "AMS-Regular"
  5415. },
  5416. "mathcal": {
  5417. variant: "script",
  5418. fontName: "Caligraphic-Regular"
  5419. },
  5420. "mathfrak": {
  5421. variant: "fraktur",
  5422. fontName: "Fraktur-Regular"
  5423. },
  5424. "mathscr": {
  5425. variant: "script",
  5426. fontName: "Script-Regular"
  5427. },
  5428. "mathsf": {
  5429. variant: "sans-serif",
  5430. fontName: "SansSerif-Regular"
  5431. },
  5432. "mathtt": {
  5433. variant: "monospace",
  5434. fontName: "Typewriter-Regular"
  5435. }
  5436. };
  5437. var svgData = {
  5438. // path, width, height
  5439. vec: ["vec", 0.471, 0.714],
  5440. // values from the font glyph
  5441. oiintSize1: ["oiintSize1", 0.957, 0.499],
  5442. // oval to overlay the integrand
  5443. oiintSize2: ["oiintSize2", 1.472, 0.659],
  5444. oiiintSize1: ["oiiintSize1", 1.304, 0.499],
  5445. oiiintSize2: ["oiiintSize2", 1.98, 0.659]
  5446. };
  5447. var staticSvg = function staticSvg(value, options) {
  5448. // Create a span with inline SVG for the element.
  5449. var _svgData$value = svgData[value],
  5450. pathName = _svgData$value[0],
  5451. width = _svgData$value[1],
  5452. height = _svgData$value[2];
  5453. var path = new PathNode(pathName);
  5454. var svgNode = new SvgNode([path], {
  5455. "width": makeEm(width),
  5456. "height": makeEm(height),
  5457. // Override CSS rule `.katex svg { width: 100% }`
  5458. "style": "width:" + makeEm(width),
  5459. "viewBox": "0 0 " + 1000 * width + " " + 1000 * height,
  5460. "preserveAspectRatio": "xMinYMin"
  5461. });
  5462. var span = makeSvgSpan(["overlay"], [svgNode], options);
  5463. span.height = height;
  5464. span.style.height = makeEm(height);
  5465. span.style.width = makeEm(width);
  5466. return span;
  5467. };
  5468. /* harmony default export */ var buildCommon = ({
  5469. fontMap: fontMap,
  5470. makeSymbol: makeSymbol,
  5471. mathsym: mathsym,
  5472. makeSpan: makeSpan,
  5473. makeSvgSpan: makeSvgSpan,
  5474. makeLineSpan: makeLineSpan,
  5475. makeAnchor: makeAnchor,
  5476. makeFragment: makeFragment,
  5477. wrapFragment: wrapFragment,
  5478. makeVList: makeVList,
  5479. makeOrd: makeOrd,
  5480. makeGlue: makeGlue,
  5481. staticSvg: staticSvg,
  5482. svgData: svgData,
  5483. tryCombineChars: tryCombineChars
  5484. });
  5485. ;// CONCATENATED MODULE: ./src/spacingData.js
  5486. /**
  5487. * Describes spaces between different classes of atoms.
  5488. */
  5489. var thinspace = {
  5490. number: 3,
  5491. unit: "mu"
  5492. };
  5493. var mediumspace = {
  5494. number: 4,
  5495. unit: "mu"
  5496. };
  5497. var thickspace = {
  5498. number: 5,
  5499. unit: "mu"
  5500. }; // Making the type below exact with all optional fields doesn't work due to
  5501. // - https://github.com/facebook/flow/issues/4582
  5502. // - https://github.com/facebook/flow/issues/5688
  5503. // However, since *all* fields are optional, $Shape<> works as suggested in 5688
  5504. // above.
  5505. // Spacing relationships for display and text styles
  5506. var spacings = {
  5507. mord: {
  5508. mop: thinspace,
  5509. mbin: mediumspace,
  5510. mrel: thickspace,
  5511. minner: thinspace
  5512. },
  5513. mop: {
  5514. mord: thinspace,
  5515. mop: thinspace,
  5516. mrel: thickspace,
  5517. minner: thinspace
  5518. },
  5519. mbin: {
  5520. mord: mediumspace,
  5521. mop: mediumspace,
  5522. mopen: mediumspace,
  5523. minner: mediumspace
  5524. },
  5525. mrel: {
  5526. mord: thickspace,
  5527. mop: thickspace,
  5528. mopen: thickspace,
  5529. minner: thickspace
  5530. },
  5531. mopen: {},
  5532. mclose: {
  5533. mop: thinspace,
  5534. mbin: mediumspace,
  5535. mrel: thickspace,
  5536. minner: thinspace
  5537. },
  5538. mpunct: {
  5539. mord: thinspace,
  5540. mop: thinspace,
  5541. mrel: thickspace,
  5542. mopen: thinspace,
  5543. mclose: thinspace,
  5544. mpunct: thinspace,
  5545. minner: thinspace
  5546. },
  5547. minner: {
  5548. mord: thinspace,
  5549. mop: thinspace,
  5550. mbin: mediumspace,
  5551. mrel: thickspace,
  5552. mopen: thinspace,
  5553. mpunct: thinspace,
  5554. minner: thinspace
  5555. }
  5556. }; // Spacing relationships for script and scriptscript styles
  5557. var tightSpacings = {
  5558. mord: {
  5559. mop: thinspace
  5560. },
  5561. mop: {
  5562. mord: thinspace,
  5563. mop: thinspace
  5564. },
  5565. mbin: {},
  5566. mrel: {},
  5567. mopen: {},
  5568. mclose: {
  5569. mop: thinspace
  5570. },
  5571. mpunct: {},
  5572. minner: {
  5573. mop: thinspace
  5574. }
  5575. };
  5576. ;// CONCATENATED MODULE: ./src/defineFunction.js
  5577. /** Context provided to function handlers for error messages. */
  5578. // Note: reverse the order of the return type union will cause a flow error.
  5579. // See https://github.com/facebook/flow/issues/3663.
  5580. // More general version of `HtmlBuilder` for nodes (e.g. \sum, accent types)
  5581. // whose presence impacts super/subscripting. In this case, ParseNode<"supsub">
  5582. // delegates its HTML building to the HtmlBuilder corresponding to these nodes.
  5583. /**
  5584. * Final function spec for use at parse time.
  5585. * This is almost identical to `FunctionPropSpec`, except it
  5586. * 1. includes the function handler, and
  5587. * 2. requires all arguments except argTypes.
  5588. * It is generated by `defineFunction()` below.
  5589. */
  5590. /**
  5591. * All registered functions.
  5592. * `functions.js` just exports this same dictionary again and makes it public.
  5593. * `Parser.js` requires this dictionary.
  5594. */
  5595. var _functions = {};
  5596. /**
  5597. * All HTML builders. Should be only used in the `define*` and the `build*ML`
  5598. * functions.
  5599. */
  5600. var _htmlGroupBuilders = {};
  5601. /**
  5602. * All MathML builders. Should be only used in the `define*` and the `build*ML`
  5603. * functions.
  5604. */
  5605. var _mathmlGroupBuilders = {};
  5606. function defineFunction(_ref) {
  5607. var type = _ref.type,
  5608. names = _ref.names,
  5609. props = _ref.props,
  5610. handler = _ref.handler,
  5611. htmlBuilder = _ref.htmlBuilder,
  5612. mathmlBuilder = _ref.mathmlBuilder;
  5613. // Set default values of functions
  5614. var data = {
  5615. type: type,
  5616. numArgs: props.numArgs,
  5617. argTypes: props.argTypes,
  5618. allowedInArgument: !!props.allowedInArgument,
  5619. allowedInText: !!props.allowedInText,
  5620. allowedInMath: props.allowedInMath === undefined ? true : props.allowedInMath,
  5621. numOptionalArgs: props.numOptionalArgs || 0,
  5622. infix: !!props.infix,
  5623. primitive: !!props.primitive,
  5624. handler: handler
  5625. };
  5626. for (var i = 0; i < names.length; ++i) {
  5627. _functions[names[i]] = data;
  5628. }
  5629. if (type) {
  5630. if (htmlBuilder) {
  5631. _htmlGroupBuilders[type] = htmlBuilder;
  5632. }
  5633. if (mathmlBuilder) {
  5634. _mathmlGroupBuilders[type] = mathmlBuilder;
  5635. }
  5636. }
  5637. }
  5638. /**
  5639. * Use this to register only the HTML and MathML builders for a function (e.g.
  5640. * if the function's ParseNode is generated in Parser.js rather than via a
  5641. * stand-alone handler provided to `defineFunction`).
  5642. */
  5643. function defineFunctionBuilders(_ref2) {
  5644. var type = _ref2.type,
  5645. htmlBuilder = _ref2.htmlBuilder,
  5646. mathmlBuilder = _ref2.mathmlBuilder;
  5647. defineFunction({
  5648. type: type,
  5649. names: [],
  5650. props: {
  5651. numArgs: 0
  5652. },
  5653. handler: function handler() {
  5654. throw new Error('Should never be called.');
  5655. },
  5656. htmlBuilder: htmlBuilder,
  5657. mathmlBuilder: mathmlBuilder
  5658. });
  5659. }
  5660. var normalizeArgument = function normalizeArgument(arg) {
  5661. return arg.type === "ordgroup" && arg.body.length === 1 ? arg.body[0] : arg;
  5662. }; // Since the corresponding buildHTML/buildMathML function expects a
  5663. // list of elements, we normalize for different kinds of arguments
  5664. var ordargument = function ordargument(arg) {
  5665. return arg.type === "ordgroup" ? arg.body : [arg];
  5666. };
  5667. ;// CONCATENATED MODULE: ./src/buildHTML.js
  5668. /**
  5669. * This file does the main work of building a domTree structure from a parse
  5670. * tree. The entry point is the `buildHTML` function, which takes a parse tree.
  5671. * Then, the buildExpression, buildGroup, and various groupBuilders functions
  5672. * are called, to produce a final HTML tree.
  5673. */
  5674. var buildHTML_makeSpan = buildCommon.makeSpan; // Binary atoms (first class `mbin`) change into ordinary atoms (`mord`)
  5675. // depending on their surroundings. See TeXbook pg. 442-446, Rules 5 and 6,
  5676. // and the text before Rule 19.
  5677. var binLeftCanceller = ["leftmost", "mbin", "mopen", "mrel", "mop", "mpunct"];
  5678. var binRightCanceller = ["rightmost", "mrel", "mclose", "mpunct"];
  5679. var styleMap = {
  5680. "display": src_Style.DISPLAY,
  5681. "text": src_Style.TEXT,
  5682. "script": src_Style.SCRIPT,
  5683. "scriptscript": src_Style.SCRIPTSCRIPT
  5684. };
  5685. var DomEnum = {
  5686. mord: "mord",
  5687. mop: "mop",
  5688. mbin: "mbin",
  5689. mrel: "mrel",
  5690. mopen: "mopen",
  5691. mclose: "mclose",
  5692. mpunct: "mpunct",
  5693. minner: "minner"
  5694. };
  5695. /**
  5696. * Take a list of nodes, build them in order, and return a list of the built
  5697. * nodes. documentFragments are flattened into their contents, so the
  5698. * returned list contains no fragments. `isRealGroup` is true if `expression`
  5699. * is a real group (no atoms will be added on either side), as opposed to
  5700. * a partial group (e.g. one created by \color). `surrounding` is an array
  5701. * consisting type of nodes that will be added to the left and right.
  5702. */
  5703. var buildExpression = function buildExpression(expression, options, isRealGroup, surrounding) {
  5704. if (surrounding === void 0) {
  5705. surrounding = [null, null];
  5706. }
  5707. // Parse expressions into `groups`.
  5708. var groups = [];
  5709. for (var i = 0; i < expression.length; i++) {
  5710. var output = buildGroup(expression[i], options);
  5711. if (output instanceof DocumentFragment) {
  5712. var children = output.children;
  5713. groups.push.apply(groups, children);
  5714. } else {
  5715. groups.push(output);
  5716. }
  5717. } // Combine consecutive domTree.symbolNodes into a single symbolNode.
  5718. buildCommon.tryCombineChars(groups); // If `expression` is a partial group, let the parent handle spacings
  5719. // to avoid processing groups multiple times.
  5720. if (!isRealGroup) {
  5721. return groups;
  5722. }
  5723. var glueOptions = options;
  5724. if (expression.length === 1) {
  5725. var node = expression[0];
  5726. if (node.type === "sizing") {
  5727. glueOptions = options.havingSize(node.size);
  5728. } else if (node.type === "styling") {
  5729. glueOptions = options.havingStyle(styleMap[node.style]);
  5730. }
  5731. } // Dummy spans for determining spacings between surrounding atoms.
  5732. // If `expression` has no atoms on the left or right, class "leftmost"
  5733. // or "rightmost", respectively, is used to indicate it.
  5734. var dummyPrev = buildHTML_makeSpan([surrounding[0] || "leftmost"], [], options);
  5735. var dummyNext = buildHTML_makeSpan([surrounding[1] || "rightmost"], [], options); // TODO: These code assumes that a node's math class is the first element
  5736. // of its `classes` array. A later cleanup should ensure this, for
  5737. // instance by changing the signature of `makeSpan`.
  5738. // Before determining what spaces to insert, perform bin cancellation.
  5739. // Binary operators change to ordinary symbols in some contexts.
  5740. var isRoot = isRealGroup === "root";
  5741. traverseNonSpaceNodes(groups, function (node, prev) {
  5742. var prevType = prev.classes[0];
  5743. var type = node.classes[0];
  5744. if (prevType === "mbin" && utils.contains(binRightCanceller, type)) {
  5745. prev.classes[0] = "mord";
  5746. } else if (type === "mbin" && utils.contains(binLeftCanceller, prevType)) {
  5747. node.classes[0] = "mord";
  5748. }
  5749. }, {
  5750. node: dummyPrev
  5751. }, dummyNext, isRoot);
  5752. traverseNonSpaceNodes(groups, function (node, prev) {
  5753. var prevType = getTypeOfDomTree(prev);
  5754. var type = getTypeOfDomTree(node); // 'mtight' indicates that the node is script or scriptscript style.
  5755. var space = prevType && type ? node.hasClass("mtight") ? tightSpacings[prevType][type] : spacings[prevType][type] : null;
  5756. if (space) {
  5757. // Insert glue (spacing) after the `prev`.
  5758. return buildCommon.makeGlue(space, glueOptions);
  5759. }
  5760. }, {
  5761. node: dummyPrev
  5762. }, dummyNext, isRoot);
  5763. return groups;
  5764. }; // Depth-first traverse non-space `nodes`, calling `callback` with the current and
  5765. // previous node as arguments, optionally returning a node to insert after the
  5766. // previous node. `prev` is an object with the previous node and `insertAfter`
  5767. // function to insert after it. `next` is a node that will be added to the right.
  5768. // Used for bin cancellation and inserting spacings.
  5769. var traverseNonSpaceNodes = function traverseNonSpaceNodes(nodes, callback, prev, next, isRoot) {
  5770. if (next) {
  5771. // temporarily append the right node, if exists
  5772. nodes.push(next);
  5773. }
  5774. var i = 0;
  5775. for (; i < nodes.length; i++) {
  5776. var node = nodes[i];
  5777. var partialGroup = checkPartialGroup(node);
  5778. if (partialGroup) {
  5779. // Recursive DFS
  5780. // $FlowFixMe: make nodes a $ReadOnlyArray by returning a new array
  5781. traverseNonSpaceNodes(partialGroup.children, callback, prev, null, isRoot);
  5782. continue;
  5783. } // Ignore explicit spaces (e.g., \;, \,) when determining what implicit
  5784. // spacing should go between atoms of different classes
  5785. var nonspace = !node.hasClass("mspace");
  5786. if (nonspace) {
  5787. var result = callback(node, prev.node);
  5788. if (result) {
  5789. if (prev.insertAfter) {
  5790. prev.insertAfter(result);
  5791. } else {
  5792. // insert at front
  5793. nodes.unshift(result);
  5794. i++;
  5795. }
  5796. }
  5797. }
  5798. if (nonspace) {
  5799. prev.node = node;
  5800. } else if (isRoot && node.hasClass("newline")) {
  5801. prev.node = buildHTML_makeSpan(["leftmost"]); // treat like beginning of line
  5802. }
  5803. prev.insertAfter = function (index) {
  5804. return function (n) {
  5805. nodes.splice(index + 1, 0, n);
  5806. i++;
  5807. };
  5808. }(i);
  5809. }
  5810. if (next) {
  5811. nodes.pop();
  5812. }
  5813. }; // Check if given node is a partial group, i.e., does not affect spacing around.
  5814. var checkPartialGroup = function checkPartialGroup(node) {
  5815. if (node instanceof DocumentFragment || node instanceof Anchor || node instanceof Span && node.hasClass("enclosing")) {
  5816. return node;
  5817. }
  5818. return null;
  5819. }; // Return the outermost node of a domTree.
  5820. var getOutermostNode = function getOutermostNode(node, side) {
  5821. var partialGroup = checkPartialGroup(node);
  5822. if (partialGroup) {
  5823. var children = partialGroup.children;
  5824. if (children.length) {
  5825. if (side === "right") {
  5826. return getOutermostNode(children[children.length - 1], "right");
  5827. } else if (side === "left") {
  5828. return getOutermostNode(children[0], "left");
  5829. }
  5830. }
  5831. }
  5832. return node;
  5833. }; // Return math atom class (mclass) of a domTree.
  5834. // If `side` is given, it will get the type of the outermost node at given side.
  5835. var getTypeOfDomTree = function getTypeOfDomTree(node, side) {
  5836. if (!node) {
  5837. return null;
  5838. }
  5839. if (side) {
  5840. node = getOutermostNode(node, side);
  5841. } // This makes a lot of assumptions as to where the type of atom
  5842. // appears. We should do a better job of enforcing this.
  5843. return DomEnum[node.classes[0]] || null;
  5844. };
  5845. var makeNullDelimiter = function makeNullDelimiter(options, classes) {
  5846. var moreClasses = ["nulldelimiter"].concat(options.baseSizingClasses());
  5847. return buildHTML_makeSpan(classes.concat(moreClasses));
  5848. };
  5849. /**
  5850. * buildGroup is the function that takes a group and calls the correct groupType
  5851. * function for it. It also handles the interaction of size and style changes
  5852. * between parents and children.
  5853. */
  5854. var buildGroup = function buildGroup(group, options, baseOptions) {
  5855. if (!group) {
  5856. return buildHTML_makeSpan();
  5857. }
  5858. if (_htmlGroupBuilders[group.type]) {
  5859. // Call the groupBuilders function
  5860. // $FlowFixMe
  5861. var groupNode = _htmlGroupBuilders[group.type](group, options); // If the size changed between the parent and the current group, account
  5862. // for that size difference.
  5863. if (baseOptions && options.size !== baseOptions.size) {
  5864. groupNode = buildHTML_makeSpan(options.sizingClasses(baseOptions), [groupNode], options);
  5865. var multiplier = options.sizeMultiplier / baseOptions.sizeMultiplier;
  5866. groupNode.height *= multiplier;
  5867. groupNode.depth *= multiplier;
  5868. }
  5869. return groupNode;
  5870. } else {
  5871. throw new src_ParseError("Got group of unknown type: '" + group.type + "'");
  5872. }
  5873. };
  5874. /**
  5875. * Combine an array of HTML DOM nodes (e.g., the output of `buildExpression`)
  5876. * into an unbreakable HTML node of class .base, with proper struts to
  5877. * guarantee correct vertical extent. `buildHTML` calls this repeatedly to
  5878. * make up the entire expression as a sequence of unbreakable units.
  5879. */
  5880. function buildHTMLUnbreakable(children, options) {
  5881. // Compute height and depth of this chunk.
  5882. var body = buildHTML_makeSpan(["base"], children, options); // Add strut, which ensures that the top of the HTML element falls at
  5883. // the height of the expression, and the bottom of the HTML element
  5884. // falls at the depth of the expression.
  5885. var strut = buildHTML_makeSpan(["strut"]);
  5886. strut.style.height = makeEm(body.height + body.depth);
  5887. if (body.depth) {
  5888. strut.style.verticalAlign = makeEm(-body.depth);
  5889. }
  5890. body.children.unshift(strut);
  5891. return body;
  5892. }
  5893. /**
  5894. * Take an entire parse tree, and build it into an appropriate set of HTML
  5895. * nodes.
  5896. */
  5897. function buildHTML(tree, options) {
  5898. // Strip off outer tag wrapper for processing below.
  5899. var tag = null;
  5900. if (tree.length === 1 && tree[0].type === "tag") {
  5901. tag = tree[0].tag;
  5902. tree = tree[0].body;
  5903. } // Build the expression contained in the tree
  5904. var expression = buildExpression(tree, options, "root");
  5905. var eqnNum;
  5906. if (expression.length === 2 && expression[1].hasClass("tag")) {
  5907. // An environment with automatic equation numbers, e.g. {gather}.
  5908. eqnNum = expression.pop();
  5909. }
  5910. var children = []; // Create one base node for each chunk between potential line breaks.
  5911. // The TeXBook [p.173] says "A formula will be broken only after a
  5912. // relation symbol like $=$ or $<$ or $\rightarrow$, or after a binary
  5913. // operation symbol like $+$ or $-$ or $\times$, where the relation or
  5914. // binary operation is on the ``outer level'' of the formula (i.e., not
  5915. // enclosed in {...} and not part of an \over construction)."
  5916. var parts = [];
  5917. for (var i = 0; i < expression.length; i++) {
  5918. parts.push(expression[i]);
  5919. if (expression[i].hasClass("mbin") || expression[i].hasClass("mrel") || expression[i].hasClass("allowbreak")) {
  5920. // Put any post-operator glue on same line as operator.
  5921. // Watch for \nobreak along the way, and stop at \newline.
  5922. var nobreak = false;
  5923. while (i < expression.length - 1 && expression[i + 1].hasClass("mspace") && !expression[i + 1].hasClass("newline")) {
  5924. i++;
  5925. parts.push(expression[i]);
  5926. if (expression[i].hasClass("nobreak")) {
  5927. nobreak = true;
  5928. }
  5929. } // Don't allow break if \nobreak among the post-operator glue.
  5930. if (!nobreak) {
  5931. children.push(buildHTMLUnbreakable(parts, options));
  5932. parts = [];
  5933. }
  5934. } else if (expression[i].hasClass("newline")) {
  5935. // Write the line except the newline
  5936. parts.pop();
  5937. if (parts.length > 0) {
  5938. children.push(buildHTMLUnbreakable(parts, options));
  5939. parts = [];
  5940. } // Put the newline at the top level
  5941. children.push(expression[i]);
  5942. }
  5943. }
  5944. if (parts.length > 0) {
  5945. children.push(buildHTMLUnbreakable(parts, options));
  5946. } // Now, if there was a tag, build it too and append it as a final child.
  5947. var tagChild;
  5948. if (tag) {
  5949. tagChild = buildHTMLUnbreakable(buildExpression(tag, options, true));
  5950. tagChild.classes = ["tag"];
  5951. children.push(tagChild);
  5952. } else if (eqnNum) {
  5953. children.push(eqnNum);
  5954. }
  5955. var htmlNode = buildHTML_makeSpan(["katex-html"], children);
  5956. htmlNode.setAttribute("aria-hidden", "true"); // Adjust the strut of the tag to be the maximum height of all children
  5957. // (the height of the enclosing htmlNode) for proper vertical alignment.
  5958. if (tagChild) {
  5959. var strut = tagChild.children[0];
  5960. strut.style.height = makeEm(htmlNode.height + htmlNode.depth);
  5961. if (htmlNode.depth) {
  5962. strut.style.verticalAlign = makeEm(-htmlNode.depth);
  5963. }
  5964. }
  5965. return htmlNode;
  5966. }
  5967. ;// CONCATENATED MODULE: ./src/mathMLTree.js
  5968. /**
  5969. * These objects store data about MathML nodes. This is the MathML equivalent
  5970. * of the types in domTree.js. Since MathML handles its own rendering, and
  5971. * since we're mainly using MathML to improve accessibility, we don't manage
  5972. * any of the styling state that the plain DOM nodes do.
  5973. *
  5974. * The `toNode` and `toMarkup` functions work simlarly to how they do in
  5975. * domTree.js, creating namespaced DOM nodes and HTML text markup respectively.
  5976. */
  5977. function newDocumentFragment(children) {
  5978. return new DocumentFragment(children);
  5979. }
  5980. /**
  5981. * This node represents a general purpose MathML node of any type. The
  5982. * constructor requires the type of node to create (for example, `"mo"` or
  5983. * `"mspace"`, corresponding to `<mo>` and `<mspace>` tags).
  5984. */
  5985. var MathNode = /*#__PURE__*/function () {
  5986. function MathNode(type, children, classes) {
  5987. this.type = void 0;
  5988. this.attributes = void 0;
  5989. this.children = void 0;
  5990. this.classes = void 0;
  5991. this.type = type;
  5992. this.attributes = {};
  5993. this.children = children || [];
  5994. this.classes = classes || [];
  5995. }
  5996. /**
  5997. * Sets an attribute on a MathML node. MathML depends on attributes to convey a
  5998. * semantic content, so this is used heavily.
  5999. */
  6000. var _proto = MathNode.prototype;
  6001. _proto.setAttribute = function setAttribute(name, value) {
  6002. this.attributes[name] = value;
  6003. }
  6004. /**
  6005. * Gets an attribute on a MathML node.
  6006. */
  6007. ;
  6008. _proto.getAttribute = function getAttribute(name) {
  6009. return this.attributes[name];
  6010. }
  6011. /**
  6012. * Converts the math node into a MathML-namespaced DOM element.
  6013. */
  6014. ;
  6015. _proto.toNode = function toNode() {
  6016. var node = document.createElementNS("http://www.w3.org/1998/Math/MathML", this.type);
  6017. for (var attr in this.attributes) {
  6018. if (Object.prototype.hasOwnProperty.call(this.attributes, attr)) {
  6019. node.setAttribute(attr, this.attributes[attr]);
  6020. }
  6021. }
  6022. if (this.classes.length > 0) {
  6023. node.className = createClass(this.classes);
  6024. }
  6025. for (var i = 0; i < this.children.length; i++) {
  6026. node.appendChild(this.children[i].toNode());
  6027. }
  6028. return node;
  6029. }
  6030. /**
  6031. * Converts the math node into an HTML markup string.
  6032. */
  6033. ;
  6034. _proto.toMarkup = function toMarkup() {
  6035. var markup = "<" + this.type; // Add the attributes
  6036. for (var attr in this.attributes) {
  6037. if (Object.prototype.hasOwnProperty.call(this.attributes, attr)) {
  6038. markup += " " + attr + "=\"";
  6039. markup += utils.escape(this.attributes[attr]);
  6040. markup += "\"";
  6041. }
  6042. }
  6043. if (this.classes.length > 0) {
  6044. markup += " class =\"" + utils.escape(createClass(this.classes)) + "\"";
  6045. }
  6046. markup += ">";
  6047. for (var i = 0; i < this.children.length; i++) {
  6048. markup += this.children[i].toMarkup();
  6049. }
  6050. markup += "</" + this.type + ">";
  6051. return markup;
  6052. }
  6053. /**
  6054. * Converts the math node into a string, similar to innerText, but escaped.
  6055. */
  6056. ;
  6057. _proto.toText = function toText() {
  6058. return this.children.map(function (child) {
  6059. return child.toText();
  6060. }).join("");
  6061. };
  6062. return MathNode;
  6063. }();
  6064. /**
  6065. * This node represents a piece of text.
  6066. */
  6067. var TextNode = /*#__PURE__*/function () {
  6068. function TextNode(text) {
  6069. this.text = void 0;
  6070. this.text = text;
  6071. }
  6072. /**
  6073. * Converts the text node into a DOM text node.
  6074. */
  6075. var _proto2 = TextNode.prototype;
  6076. _proto2.toNode = function toNode() {
  6077. return document.createTextNode(this.text);
  6078. }
  6079. /**
  6080. * Converts the text node into escaped HTML markup
  6081. * (representing the text itself).
  6082. */
  6083. ;
  6084. _proto2.toMarkup = function toMarkup() {
  6085. return utils.escape(this.toText());
  6086. }
  6087. /**
  6088. * Converts the text node into a string
  6089. * (representing the text iteself).
  6090. */
  6091. ;
  6092. _proto2.toText = function toText() {
  6093. return this.text;
  6094. };
  6095. return TextNode;
  6096. }();
  6097. /**
  6098. * This node represents a space, but may render as <mspace.../> or as text,
  6099. * depending on the width.
  6100. */
  6101. var SpaceNode = /*#__PURE__*/function () {
  6102. /**
  6103. * Create a Space node with width given in CSS ems.
  6104. */
  6105. function SpaceNode(width) {
  6106. this.width = void 0;
  6107. this.character = void 0;
  6108. this.width = width; // See https://www.w3.org/TR/2000/WD-MathML2-20000328/chapter6.html
  6109. // for a table of space-like characters. We use Unicode
  6110. // representations instead of &LongNames; as it's not clear how to
  6111. // make the latter via document.createTextNode.
  6112. if (width >= 0.05555 && width <= 0.05556) {
  6113. this.character = "\u200A"; // &VeryThinSpace;
  6114. } else if (width >= 0.1666 && width <= 0.1667) {
  6115. this.character = "\u2009"; // &ThinSpace;
  6116. } else if (width >= 0.2222 && width <= 0.2223) {
  6117. this.character = "\u2005"; // &MediumSpace;
  6118. } else if (width >= 0.2777 && width <= 0.2778) {
  6119. this.character = "\u2005\u200A"; // &ThickSpace;
  6120. } else if (width >= -0.05556 && width <= -0.05555) {
  6121. this.character = "\u200A\u2063"; // &NegativeVeryThinSpace;
  6122. } else if (width >= -0.1667 && width <= -0.1666) {
  6123. this.character = "\u2009\u2063"; // &NegativeThinSpace;
  6124. } else if (width >= -0.2223 && width <= -0.2222) {
  6125. this.character = "\u205F\u2063"; // &NegativeMediumSpace;
  6126. } else if (width >= -0.2778 && width <= -0.2777) {
  6127. this.character = "\u2005\u2063"; // &NegativeThickSpace;
  6128. } else {
  6129. this.character = null;
  6130. }
  6131. }
  6132. /**
  6133. * Converts the math node into a MathML-namespaced DOM element.
  6134. */
  6135. var _proto3 = SpaceNode.prototype;
  6136. _proto3.toNode = function toNode() {
  6137. if (this.character) {
  6138. return document.createTextNode(this.character);
  6139. } else {
  6140. var node = document.createElementNS("http://www.w3.org/1998/Math/MathML", "mspace");
  6141. node.setAttribute("width", makeEm(this.width));
  6142. return node;
  6143. }
  6144. }
  6145. /**
  6146. * Converts the math node into an HTML markup string.
  6147. */
  6148. ;
  6149. _proto3.toMarkup = function toMarkup() {
  6150. if (this.character) {
  6151. return "<mtext>" + this.character + "</mtext>";
  6152. } else {
  6153. return "<mspace width=\"" + makeEm(this.width) + "\"/>";
  6154. }
  6155. }
  6156. /**
  6157. * Converts the math node into a string, similar to innerText.
  6158. */
  6159. ;
  6160. _proto3.toText = function toText() {
  6161. if (this.character) {
  6162. return this.character;
  6163. } else {
  6164. return " ";
  6165. }
  6166. };
  6167. return SpaceNode;
  6168. }();
  6169. /* harmony default export */ var mathMLTree = ({
  6170. MathNode: MathNode,
  6171. TextNode: TextNode,
  6172. SpaceNode: SpaceNode,
  6173. newDocumentFragment: newDocumentFragment
  6174. });
  6175. ;// CONCATENATED MODULE: ./src/buildMathML.js
  6176. /**
  6177. * This file converts a parse tree into a cooresponding MathML tree. The main
  6178. * entry point is the `buildMathML` function, which takes a parse tree from the
  6179. * parser.
  6180. */
  6181. /**
  6182. * Takes a symbol and converts it into a MathML text node after performing
  6183. * optional replacement from symbols.js.
  6184. */
  6185. var makeText = function makeText(text, mode, options) {
  6186. if (src_symbols[mode][text] && src_symbols[mode][text].replace && text.charCodeAt(0) !== 0xD835 && !(ligatures.hasOwnProperty(text) && options && (options.fontFamily && options.fontFamily.substr(4, 2) === "tt" || options.font && options.font.substr(4, 2) === "tt"))) {
  6187. text = src_symbols[mode][text].replace;
  6188. }
  6189. return new mathMLTree.TextNode(text);
  6190. };
  6191. /**
  6192. * Wrap the given array of nodes in an <mrow> node if needed, i.e.,
  6193. * unless the array has length 1. Always returns a single node.
  6194. */
  6195. var makeRow = function makeRow(body) {
  6196. if (body.length === 1) {
  6197. return body[0];
  6198. } else {
  6199. return new mathMLTree.MathNode("mrow", body);
  6200. }
  6201. };
  6202. /**
  6203. * Returns the math variant as a string or null if none is required.
  6204. */
  6205. var getVariant = function getVariant(group, options) {
  6206. // Handle \text... font specifiers as best we can.
  6207. // MathML has a limited list of allowable mathvariant specifiers; see
  6208. // https://www.w3.org/TR/MathML3/chapter3.html#presm.commatt
  6209. if (options.fontFamily === "texttt") {
  6210. return "monospace";
  6211. } else if (options.fontFamily === "textsf") {
  6212. if (options.fontShape === "textit" && options.fontWeight === "textbf") {
  6213. return "sans-serif-bold-italic";
  6214. } else if (options.fontShape === "textit") {
  6215. return "sans-serif-italic";
  6216. } else if (options.fontWeight === "textbf") {
  6217. return "bold-sans-serif";
  6218. } else {
  6219. return "sans-serif";
  6220. }
  6221. } else if (options.fontShape === "textit" && options.fontWeight === "textbf") {
  6222. return "bold-italic";
  6223. } else if (options.fontShape === "textit") {
  6224. return "italic";
  6225. } else if (options.fontWeight === "textbf") {
  6226. return "bold";
  6227. }
  6228. var font = options.font;
  6229. if (!font || font === "mathnormal") {
  6230. return null;
  6231. }
  6232. var mode = group.mode;
  6233. if (font === "mathit") {
  6234. return "italic";
  6235. } else if (font === "boldsymbol") {
  6236. return group.type === "textord" ? "bold" : "bold-italic";
  6237. } else if (font === "mathbf") {
  6238. return "bold";
  6239. } else if (font === "mathbb") {
  6240. return "double-struck";
  6241. } else if (font === "mathfrak") {
  6242. return "fraktur";
  6243. } else if (font === "mathscr" || font === "mathcal") {
  6244. // MathML makes no distinction between script and caligrahpic
  6245. return "script";
  6246. } else if (font === "mathsf") {
  6247. return "sans-serif";
  6248. } else if (font === "mathtt") {
  6249. return "monospace";
  6250. }
  6251. var text = group.text;
  6252. if (utils.contains(["\\imath", "\\jmath"], text)) {
  6253. return null;
  6254. }
  6255. if (src_symbols[mode][text] && src_symbols[mode][text].replace) {
  6256. text = src_symbols[mode][text].replace;
  6257. }
  6258. var fontName = buildCommon.fontMap[font].fontName;
  6259. if (getCharacterMetrics(text, fontName, mode)) {
  6260. return buildCommon.fontMap[font].variant;
  6261. }
  6262. return null;
  6263. };
  6264. /**
  6265. * Takes a list of nodes, builds them, and returns a list of the generated
  6266. * MathML nodes. Also combine consecutive <mtext> outputs into a single
  6267. * <mtext> tag.
  6268. */
  6269. var buildMathML_buildExpression = function buildExpression(expression, options, isOrdgroup) {
  6270. if (expression.length === 1) {
  6271. var group = buildMathML_buildGroup(expression[0], options);
  6272. if (isOrdgroup && group instanceof MathNode && group.type === "mo") {
  6273. // When TeX writers want to suppress spacing on an operator,
  6274. // they often put the operator by itself inside braces.
  6275. group.setAttribute("lspace", "0em");
  6276. group.setAttribute("rspace", "0em");
  6277. }
  6278. return [group];
  6279. }
  6280. var groups = [];
  6281. var lastGroup;
  6282. for (var i = 0; i < expression.length; i++) {
  6283. var _group = buildMathML_buildGroup(expression[i], options);
  6284. if (_group instanceof MathNode && lastGroup instanceof MathNode) {
  6285. // Concatenate adjacent <mtext>s
  6286. if (_group.type === 'mtext' && lastGroup.type === 'mtext' && _group.getAttribute('mathvariant') === lastGroup.getAttribute('mathvariant')) {
  6287. var _lastGroup$children;
  6288. (_lastGroup$children = lastGroup.children).push.apply(_lastGroup$children, _group.children);
  6289. continue; // Concatenate adjacent <mn>s
  6290. } else if (_group.type === 'mn' && lastGroup.type === 'mn') {
  6291. var _lastGroup$children2;
  6292. (_lastGroup$children2 = lastGroup.children).push.apply(_lastGroup$children2, _group.children);
  6293. continue; // Concatenate <mn>...</mn> followed by <mi>.</mi>
  6294. } else if (_group.type === 'mi' && _group.children.length === 1 && lastGroup.type === 'mn') {
  6295. var child = _group.children[0];
  6296. if (child instanceof TextNode && child.text === '.') {
  6297. var _lastGroup$children3;
  6298. (_lastGroup$children3 = lastGroup.children).push.apply(_lastGroup$children3, _group.children);
  6299. continue;
  6300. }
  6301. } else if (lastGroup.type === 'mi' && lastGroup.children.length === 1) {
  6302. var lastChild = lastGroup.children[0];
  6303. if (lastChild instanceof TextNode && lastChild.text === "\u0338" && (_group.type === 'mo' || _group.type === 'mi' || _group.type === 'mn')) {
  6304. var _child = _group.children[0];
  6305. if (_child instanceof TextNode && _child.text.length > 0) {
  6306. // Overlay with combining character long solidus
  6307. _child.text = _child.text.slice(0, 1) + "\u0338" + _child.text.slice(1);
  6308. groups.pop();
  6309. }
  6310. }
  6311. }
  6312. }
  6313. groups.push(_group);
  6314. lastGroup = _group;
  6315. }
  6316. return groups;
  6317. };
  6318. /**
  6319. * Equivalent to buildExpression, but wraps the elements in an <mrow>
  6320. * if there's more than one. Returns a single node instead of an array.
  6321. */
  6322. var buildExpressionRow = function buildExpressionRow(expression, options, isOrdgroup) {
  6323. return makeRow(buildMathML_buildExpression(expression, options, isOrdgroup));
  6324. };
  6325. /**
  6326. * Takes a group from the parser and calls the appropriate groupBuilders function
  6327. * on it to produce a MathML node.
  6328. */
  6329. var buildMathML_buildGroup = function buildGroup(group, options) {
  6330. if (!group) {
  6331. return new mathMLTree.MathNode("mrow");
  6332. }
  6333. if (_mathmlGroupBuilders[group.type]) {
  6334. // Call the groupBuilders function
  6335. // $FlowFixMe
  6336. var result = _mathmlGroupBuilders[group.type](group, options); // $FlowFixMe
  6337. return result;
  6338. } else {
  6339. throw new src_ParseError("Got group of unknown type: '" + group.type + "'");
  6340. }
  6341. };
  6342. /**
  6343. * Takes a full parse tree and settings and builds a MathML representation of
  6344. * it. In particular, we put the elements from building the parse tree into a
  6345. * <semantics> tag so we can also include that TeX source as an annotation.
  6346. *
  6347. * Note that we actually return a domTree element with a `<math>` inside it so
  6348. * we can do appropriate styling.
  6349. */
  6350. function buildMathML(tree, texExpression, options, isDisplayMode, forMathmlOnly) {
  6351. var expression = buildMathML_buildExpression(tree, options); // TODO: Make a pass thru the MathML similar to buildHTML.traverseNonSpaceNodes
  6352. // and add spacing nodes. This is necessary only adjacent to math operators
  6353. // like \sin or \lim or to subsup elements that contain math operators.
  6354. // MathML takes care of the other spacing issues.
  6355. // Wrap up the expression in an mrow so it is presented in the semantics
  6356. // tag correctly, unless it's a single <mrow> or <mtable>.
  6357. var wrapper;
  6358. if (expression.length === 1 && expression[0] instanceof MathNode && utils.contains(["mrow", "mtable"], expression[0].type)) {
  6359. wrapper = expression[0];
  6360. } else {
  6361. wrapper = new mathMLTree.MathNode("mrow", expression);
  6362. } // Build a TeX annotation of the source
  6363. var annotation = new mathMLTree.MathNode("annotation", [new mathMLTree.TextNode(texExpression)]);
  6364. annotation.setAttribute("encoding", "application/x-tex");
  6365. var semantics = new mathMLTree.MathNode("semantics", [wrapper, annotation]);
  6366. var math = new mathMLTree.MathNode("math", [semantics]);
  6367. math.setAttribute("xmlns", "http://www.w3.org/1998/Math/MathML");
  6368. if (isDisplayMode) {
  6369. math.setAttribute("display", "block");
  6370. } // You can't style <math> nodes, so we wrap the node in a span.
  6371. // NOTE: The span class is not typed to have <math> nodes as children, and
  6372. // we don't want to make the children type more generic since the children
  6373. // of span are expected to have more fields in `buildHtml` contexts.
  6374. var wrapperClass = forMathmlOnly ? "katex" : "katex-mathml"; // $FlowFixMe
  6375. return buildCommon.makeSpan([wrapperClass], [math]);
  6376. }
  6377. ;// CONCATENATED MODULE: ./src/buildTree.js
  6378. var optionsFromSettings = function optionsFromSettings(settings) {
  6379. return new src_Options({
  6380. style: settings.displayMode ? src_Style.DISPLAY : src_Style.TEXT,
  6381. maxSize: settings.maxSize,
  6382. minRuleThickness: settings.minRuleThickness
  6383. });
  6384. };
  6385. var displayWrap = function displayWrap(node, settings) {
  6386. if (settings.displayMode) {
  6387. var classes = ["katex-display"];
  6388. if (settings.leqno) {
  6389. classes.push("leqno");
  6390. }
  6391. if (settings.fleqn) {
  6392. classes.push("fleqn");
  6393. }
  6394. node = buildCommon.makeSpan(classes, [node]);
  6395. }
  6396. return node;
  6397. };
  6398. var buildTree = function buildTree(tree, expression, settings) {
  6399. var options = optionsFromSettings(settings);
  6400. var katexNode;
  6401. if (settings.output === "mathml") {
  6402. return buildMathML(tree, expression, options, settings.displayMode, true);
  6403. } else if (settings.output === "html") {
  6404. var htmlNode = buildHTML(tree, options);
  6405. katexNode = buildCommon.makeSpan(["katex"], [htmlNode]);
  6406. } else {
  6407. var mathMLNode = buildMathML(tree, expression, options, settings.displayMode, false);
  6408. var _htmlNode = buildHTML(tree, options);
  6409. katexNode = buildCommon.makeSpan(["katex"], [mathMLNode, _htmlNode]);
  6410. }
  6411. return displayWrap(katexNode, settings);
  6412. };
  6413. var buildHTMLTree = function buildHTMLTree(tree, expression, settings) {
  6414. var options = optionsFromSettings(settings);
  6415. var htmlNode = buildHTML(tree, options);
  6416. var katexNode = buildCommon.makeSpan(["katex"], [htmlNode]);
  6417. return displayWrap(katexNode, settings);
  6418. };
  6419. /* harmony default export */ var src_buildTree = ((/* unused pure expression or super */ null && (buildTree)));
  6420. ;// CONCATENATED MODULE: ./src/stretchy.js
  6421. /**
  6422. * This file provides support to buildMathML.js and buildHTML.js
  6423. * for stretchy wide elements rendered from SVG files
  6424. * and other CSS trickery.
  6425. */
  6426. var stretchyCodePoint = {
  6427. widehat: "^",
  6428. widecheck: "ˇ",
  6429. widetilde: "~",
  6430. utilde: "~",
  6431. overleftarrow: "\u2190",
  6432. underleftarrow: "\u2190",
  6433. xleftarrow: "\u2190",
  6434. overrightarrow: "\u2192",
  6435. underrightarrow: "\u2192",
  6436. xrightarrow: "\u2192",
  6437. underbrace: "\u23DF",
  6438. overbrace: "\u23DE",
  6439. overgroup: "\u23E0",
  6440. undergroup: "\u23E1",
  6441. overleftrightarrow: "\u2194",
  6442. underleftrightarrow: "\u2194",
  6443. xleftrightarrow: "\u2194",
  6444. Overrightarrow: "\u21D2",
  6445. xRightarrow: "\u21D2",
  6446. overleftharpoon: "\u21BC",
  6447. xleftharpoonup: "\u21BC",
  6448. overrightharpoon: "\u21C0",
  6449. xrightharpoonup: "\u21C0",
  6450. xLeftarrow: "\u21D0",
  6451. xLeftrightarrow: "\u21D4",
  6452. xhookleftarrow: "\u21A9",
  6453. xhookrightarrow: "\u21AA",
  6454. xmapsto: "\u21A6",
  6455. xrightharpoondown: "\u21C1",
  6456. xleftharpoondown: "\u21BD",
  6457. xrightleftharpoons: "\u21CC",
  6458. xleftrightharpoons: "\u21CB",
  6459. xtwoheadleftarrow: "\u219E",
  6460. xtwoheadrightarrow: "\u21A0",
  6461. xlongequal: "=",
  6462. xtofrom: "\u21C4",
  6463. xrightleftarrows: "\u21C4",
  6464. xrightequilibrium: "\u21CC",
  6465. // Not a perfect match.
  6466. xleftequilibrium: "\u21CB",
  6467. // None better available.
  6468. "\\cdrightarrow": "\u2192",
  6469. "\\cdleftarrow": "\u2190",
  6470. "\\cdlongequal": "="
  6471. };
  6472. var mathMLnode = function mathMLnode(label) {
  6473. var node = new mathMLTree.MathNode("mo", [new mathMLTree.TextNode(stretchyCodePoint[label.replace(/^\\/, '')])]);
  6474. node.setAttribute("stretchy", "true");
  6475. return node;
  6476. }; // Many of the KaTeX SVG images have been adapted from glyphs in KaTeX fonts.
  6477. // Copyright (c) 2009-2010, Design Science, Inc. (<www.mathjax.org>)
  6478. // Copyright (c) 2014-2017 Khan Academy (<www.khanacademy.org>)
  6479. // Licensed under the SIL Open Font License, Version 1.1.
  6480. // See \nhttp://scripts.sil.org/OFL
  6481. // Very Long SVGs
  6482. // Many of the KaTeX stretchy wide elements use a long SVG image and an
  6483. // overflow: hidden tactic to achieve a stretchy image while avoiding
  6484. // distortion of arrowheads or brace corners.
  6485. // The SVG typically contains a very long (400 em) arrow.
  6486. // The SVG is in a container span that has overflow: hidden, so the span
  6487. // acts like a window that exposes only part of the SVG.
  6488. // The SVG always has a longer, thinner aspect ratio than the container span.
  6489. // After the SVG fills 100% of the height of the container span,
  6490. // there is a long arrow shaft left over. That left-over shaft is not shown.
  6491. // Instead, it is sliced off because the span's CSS has overflow: hidden.
  6492. // Thus, the reader sees an arrow that matches the subject matter width
  6493. // without distortion.
  6494. // Some functions, such as \cancel, need to vary their aspect ratio. These
  6495. // functions do not get the overflow SVG treatment.
  6496. // Second Brush Stroke
  6497. // Low resolution monitors struggle to display images in fine detail.
  6498. // So browsers apply anti-aliasing. A long straight arrow shaft therefore
  6499. // will sometimes appear as if it has a blurred edge.
  6500. // To mitigate this, these SVG files contain a second "brush-stroke" on the
  6501. // arrow shafts. That is, a second long thin rectangular SVG path has been
  6502. // written directly on top of each arrow shaft. This reinforcement causes
  6503. // some of the screen pixels to display as black instead of the anti-aliased
  6504. // gray pixel that a single path would generate. So we get arrow shafts
  6505. // whose edges appear to be sharper.
  6506. // In the katexImagesData object just below, the dimensions all
  6507. // correspond to path geometry inside the relevant SVG.
  6508. // For example, \overrightarrow uses the same arrowhead as glyph U+2192
  6509. // from the KaTeX Main font. The scaling factor is 1000.
  6510. // That is, inside the font, that arrowhead is 522 units tall, which
  6511. // corresponds to 0.522 em inside the document.
  6512. var katexImagesData = {
  6513. // path(s), minWidth, height, align
  6514. overrightarrow: [["rightarrow"], 0.888, 522, "xMaxYMin"],
  6515. overleftarrow: [["leftarrow"], 0.888, 522, "xMinYMin"],
  6516. underrightarrow: [["rightarrow"], 0.888, 522, "xMaxYMin"],
  6517. underleftarrow: [["leftarrow"], 0.888, 522, "xMinYMin"],
  6518. xrightarrow: [["rightarrow"], 1.469, 522, "xMaxYMin"],
  6519. "\\cdrightarrow": [["rightarrow"], 3.0, 522, "xMaxYMin"],
  6520. // CD minwwidth2.5pc
  6521. xleftarrow: [["leftarrow"], 1.469, 522, "xMinYMin"],
  6522. "\\cdleftarrow": [["leftarrow"], 3.0, 522, "xMinYMin"],
  6523. Overrightarrow: [["doublerightarrow"], 0.888, 560, "xMaxYMin"],
  6524. xRightarrow: [["doublerightarrow"], 1.526, 560, "xMaxYMin"],
  6525. xLeftarrow: [["doubleleftarrow"], 1.526, 560, "xMinYMin"],
  6526. overleftharpoon: [["leftharpoon"], 0.888, 522, "xMinYMin"],
  6527. xleftharpoonup: [["leftharpoon"], 0.888, 522, "xMinYMin"],
  6528. xleftharpoondown: [["leftharpoondown"], 0.888, 522, "xMinYMin"],
  6529. overrightharpoon: [["rightharpoon"], 0.888, 522, "xMaxYMin"],
  6530. xrightharpoonup: [["rightharpoon"], 0.888, 522, "xMaxYMin"],
  6531. xrightharpoondown: [["rightharpoondown"], 0.888, 522, "xMaxYMin"],
  6532. xlongequal: [["longequal"], 0.888, 334, "xMinYMin"],
  6533. "\\cdlongequal": [["longequal"], 3.0, 334, "xMinYMin"],
  6534. xtwoheadleftarrow: [["twoheadleftarrow"], 0.888, 334, "xMinYMin"],
  6535. xtwoheadrightarrow: [["twoheadrightarrow"], 0.888, 334, "xMaxYMin"],
  6536. overleftrightarrow: [["leftarrow", "rightarrow"], 0.888, 522],
  6537. overbrace: [["leftbrace", "midbrace", "rightbrace"], 1.6, 548],
  6538. underbrace: [["leftbraceunder", "midbraceunder", "rightbraceunder"], 1.6, 548],
  6539. underleftrightarrow: [["leftarrow", "rightarrow"], 0.888, 522],
  6540. xleftrightarrow: [["leftarrow", "rightarrow"], 1.75, 522],
  6541. xLeftrightarrow: [["doubleleftarrow", "doublerightarrow"], 1.75, 560],
  6542. xrightleftharpoons: [["leftharpoondownplus", "rightharpoonplus"], 1.75, 716],
  6543. xleftrightharpoons: [["leftharpoonplus", "rightharpoondownplus"], 1.75, 716],
  6544. xhookleftarrow: [["leftarrow", "righthook"], 1.08, 522],
  6545. xhookrightarrow: [["lefthook", "rightarrow"], 1.08, 522],
  6546. overlinesegment: [["leftlinesegment", "rightlinesegment"], 0.888, 522],
  6547. underlinesegment: [["leftlinesegment", "rightlinesegment"], 0.888, 522],
  6548. overgroup: [["leftgroup", "rightgroup"], 0.888, 342],
  6549. undergroup: [["leftgroupunder", "rightgroupunder"], 0.888, 342],
  6550. xmapsto: [["leftmapsto", "rightarrow"], 1.5, 522],
  6551. xtofrom: [["leftToFrom", "rightToFrom"], 1.75, 528],
  6552. // The next three arrows are from the mhchem package.
  6553. // In mhchem.sty, min-length is 2.0em. But these arrows might appear in the
  6554. // document as \xrightarrow or \xrightleftharpoons. Those have
  6555. // min-length = 1.75em, so we set min-length on these next three to match.
  6556. xrightleftarrows: [["baraboveleftarrow", "rightarrowabovebar"], 1.75, 901],
  6557. xrightequilibrium: [["baraboveshortleftharpoon", "rightharpoonaboveshortbar"], 1.75, 716],
  6558. xleftequilibrium: [["shortbaraboveleftharpoon", "shortrightharpoonabovebar"], 1.75, 716]
  6559. };
  6560. var groupLength = function groupLength(arg) {
  6561. if (arg.type === "ordgroup") {
  6562. return arg.body.length;
  6563. } else {
  6564. return 1;
  6565. }
  6566. };
  6567. var svgSpan = function svgSpan(group, options) {
  6568. // Create a span with inline SVG for the element.
  6569. function buildSvgSpan_() {
  6570. var viewBoxWidth = 400000; // default
  6571. var label = group.label.substr(1);
  6572. if (utils.contains(["widehat", "widecheck", "widetilde", "utilde"], label)) {
  6573. // Each type in the `if` statement corresponds to one of the ParseNode
  6574. // types below. This narrowing is required to access `grp.base`.
  6575. // $FlowFixMe
  6576. var grp = group; // There are four SVG images available for each function.
  6577. // Choose a taller image when there are more characters.
  6578. var numChars = groupLength(grp.base);
  6579. var viewBoxHeight;
  6580. var pathName;
  6581. var _height;
  6582. if (numChars > 5) {
  6583. if (label === "widehat" || label === "widecheck") {
  6584. viewBoxHeight = 420;
  6585. viewBoxWidth = 2364;
  6586. _height = 0.42;
  6587. pathName = label + "4";
  6588. } else {
  6589. viewBoxHeight = 312;
  6590. viewBoxWidth = 2340;
  6591. _height = 0.34;
  6592. pathName = "tilde4";
  6593. }
  6594. } else {
  6595. var imgIndex = [1, 1, 2, 2, 3, 3][numChars];
  6596. if (label === "widehat" || label === "widecheck") {
  6597. viewBoxWidth = [0, 1062, 2364, 2364, 2364][imgIndex];
  6598. viewBoxHeight = [0, 239, 300, 360, 420][imgIndex];
  6599. _height = [0, 0.24, 0.3, 0.3, 0.36, 0.42][imgIndex];
  6600. pathName = label + imgIndex;
  6601. } else {
  6602. viewBoxWidth = [0, 600, 1033, 2339, 2340][imgIndex];
  6603. viewBoxHeight = [0, 260, 286, 306, 312][imgIndex];
  6604. _height = [0, 0.26, 0.286, 0.3, 0.306, 0.34][imgIndex];
  6605. pathName = "tilde" + imgIndex;
  6606. }
  6607. }
  6608. var path = new PathNode(pathName);
  6609. var svgNode = new SvgNode([path], {
  6610. "width": "100%",
  6611. "height": makeEm(_height),
  6612. "viewBox": "0 0 " + viewBoxWidth + " " + viewBoxHeight,
  6613. "preserveAspectRatio": "none"
  6614. });
  6615. return {
  6616. span: buildCommon.makeSvgSpan([], [svgNode], options),
  6617. minWidth: 0,
  6618. height: _height
  6619. };
  6620. } else {
  6621. var spans = [];
  6622. var data = katexImagesData[label];
  6623. var paths = data[0],
  6624. _minWidth = data[1],
  6625. _viewBoxHeight = data[2];
  6626. var _height2 = _viewBoxHeight / 1000;
  6627. var numSvgChildren = paths.length;
  6628. var widthClasses;
  6629. var aligns;
  6630. if (numSvgChildren === 1) {
  6631. // $FlowFixMe: All these cases must be of the 4-tuple type.
  6632. var align1 = data[3];
  6633. widthClasses = ["hide-tail"];
  6634. aligns = [align1];
  6635. } else if (numSvgChildren === 2) {
  6636. widthClasses = ["halfarrow-left", "halfarrow-right"];
  6637. aligns = ["xMinYMin", "xMaxYMin"];
  6638. } else if (numSvgChildren === 3) {
  6639. widthClasses = ["brace-left", "brace-center", "brace-right"];
  6640. aligns = ["xMinYMin", "xMidYMin", "xMaxYMin"];
  6641. } else {
  6642. throw new Error("Correct katexImagesData or update code here to support\n " + numSvgChildren + " children.");
  6643. }
  6644. for (var i = 0; i < numSvgChildren; i++) {
  6645. var _path = new PathNode(paths[i]);
  6646. var _svgNode = new SvgNode([_path], {
  6647. "width": "400em",
  6648. "height": makeEm(_height2),
  6649. "viewBox": "0 0 " + viewBoxWidth + " " + _viewBoxHeight,
  6650. "preserveAspectRatio": aligns[i] + " slice"
  6651. });
  6652. var _span = buildCommon.makeSvgSpan([widthClasses[i]], [_svgNode], options);
  6653. if (numSvgChildren === 1) {
  6654. return {
  6655. span: _span,
  6656. minWidth: _minWidth,
  6657. height: _height2
  6658. };
  6659. } else {
  6660. _span.style.height = makeEm(_height2);
  6661. spans.push(_span);
  6662. }
  6663. }
  6664. return {
  6665. span: buildCommon.makeSpan(["stretchy"], spans, options),
  6666. minWidth: _minWidth,
  6667. height: _height2
  6668. };
  6669. }
  6670. } // buildSvgSpan_()
  6671. var _buildSvgSpan_ = buildSvgSpan_(),
  6672. span = _buildSvgSpan_.span,
  6673. minWidth = _buildSvgSpan_.minWidth,
  6674. height = _buildSvgSpan_.height; // Note that we are returning span.depth = 0.
  6675. // Any adjustments relative to the baseline must be done in buildHTML.
  6676. span.height = height;
  6677. span.style.height = makeEm(height);
  6678. if (minWidth > 0) {
  6679. span.style.minWidth = makeEm(minWidth);
  6680. }
  6681. return span;
  6682. };
  6683. var encloseSpan = function encloseSpan(inner, label, topPad, bottomPad, options) {
  6684. // Return an image span for \cancel, \bcancel, \xcancel, \fbox, or \angl
  6685. var img;
  6686. var totalHeight = inner.height + inner.depth + topPad + bottomPad;
  6687. if (/fbox|color|angl/.test(label)) {
  6688. img = buildCommon.makeSpan(["stretchy", label], [], options);
  6689. if (label === "fbox") {
  6690. var color = options.color && options.getColor();
  6691. if (color) {
  6692. img.style.borderColor = color;
  6693. }
  6694. }
  6695. } else {
  6696. // \cancel, \bcancel, or \xcancel
  6697. // Since \cancel's SVG is inline and it omits the viewBox attribute,
  6698. // its stroke-width will not vary with span area.
  6699. var lines = [];
  6700. if (/^[bx]cancel$/.test(label)) {
  6701. lines.push(new LineNode({
  6702. "x1": "0",
  6703. "y1": "0",
  6704. "x2": "100%",
  6705. "y2": "100%",
  6706. "stroke-width": "0.046em"
  6707. }));
  6708. }
  6709. if (/^x?cancel$/.test(label)) {
  6710. lines.push(new LineNode({
  6711. "x1": "0",
  6712. "y1": "100%",
  6713. "x2": "100%",
  6714. "y2": "0",
  6715. "stroke-width": "0.046em"
  6716. }));
  6717. }
  6718. var svgNode = new SvgNode(lines, {
  6719. "width": "100%",
  6720. "height": makeEm(totalHeight)
  6721. });
  6722. img = buildCommon.makeSvgSpan([], [svgNode], options);
  6723. }
  6724. img.height = totalHeight;
  6725. img.style.height = makeEm(totalHeight);
  6726. return img;
  6727. };
  6728. /* harmony default export */ var stretchy = ({
  6729. encloseSpan: encloseSpan,
  6730. mathMLnode: mathMLnode,
  6731. svgSpan: svgSpan
  6732. });
  6733. ;// CONCATENATED MODULE: ./src/parseNode.js
  6734. /**
  6735. * Asserts that the node is of the given type and returns it with stricter
  6736. * typing. Throws if the node's type does not match.
  6737. */
  6738. function assertNodeType(node, type) {
  6739. if (!node || node.type !== type) {
  6740. throw new Error("Expected node of type " + type + ", but got " + (node ? "node of type " + node.type : String(node)));
  6741. } // $FlowFixMe, >=0.125
  6742. return node;
  6743. }
  6744. /**
  6745. * Returns the node more strictly typed iff it is of the given type. Otherwise,
  6746. * returns null.
  6747. */
  6748. function assertSymbolNodeType(node) {
  6749. var typedNode = checkSymbolNodeType(node);
  6750. if (!typedNode) {
  6751. throw new Error("Expected node of symbol group type, but got " + (node ? "node of type " + node.type : String(node)));
  6752. }
  6753. return typedNode;
  6754. }
  6755. /**
  6756. * Returns the node more strictly typed iff it is of the given type. Otherwise,
  6757. * returns null.
  6758. */
  6759. function checkSymbolNodeType(node) {
  6760. if (node && (node.type === "atom" || NON_ATOMS.hasOwnProperty(node.type))) {
  6761. // $FlowFixMe
  6762. return node;
  6763. }
  6764. return null;
  6765. }
  6766. ;// CONCATENATED MODULE: ./src/functions/accent.js
  6767. // NOTE: Unlike most `htmlBuilder`s, this one handles not only "accent", but
  6768. // also "supsub" since an accent can affect super/subscripting.
  6769. var htmlBuilder = function htmlBuilder(grp, options) {
  6770. // Accents are handled in the TeXbook pg. 443, rule 12.
  6771. var base;
  6772. var group;
  6773. var supSubGroup;
  6774. if (grp && grp.type === "supsub") {
  6775. // If our base is a character box, and we have superscripts and
  6776. // subscripts, the supsub will defer to us. In particular, we want
  6777. // to attach the superscripts and subscripts to the inner body (so
  6778. // that the position of the superscripts and subscripts won't be
  6779. // affected by the height of the accent). We accomplish this by
  6780. // sticking the base of the accent into the base of the supsub, and
  6781. // rendering that, while keeping track of where the accent is.
  6782. // The real accent group is the base of the supsub group
  6783. group = assertNodeType(grp.base, "accent"); // The character box is the base of the accent group
  6784. base = group.base; // Stick the character box into the base of the supsub group
  6785. grp.base = base; // Rerender the supsub group with its new base, and store that
  6786. // result.
  6787. supSubGroup = assertSpan(buildGroup(grp, options)); // reset original base
  6788. grp.base = group;
  6789. } else {
  6790. group = assertNodeType(grp, "accent");
  6791. base = group.base;
  6792. } // Build the base group
  6793. var body = buildGroup(base, options.havingCrampedStyle()); // Does the accent need to shift for the skew of a character?
  6794. var mustShift = group.isShifty && utils.isCharacterBox(base); // Calculate the skew of the accent. This is based on the line "If the
  6795. // nucleus is not a single character, let s = 0; otherwise set s to the
  6796. // kern amount for the nucleus followed by the \skewchar of its font."
  6797. // Note that our skew metrics are just the kern between each character
  6798. // and the skewchar.
  6799. var skew = 0;
  6800. if (mustShift) {
  6801. // If the base is a character box, then we want the skew of the
  6802. // innermost character. To do that, we find the innermost character:
  6803. var baseChar = utils.getBaseElem(base); // Then, we render its group to get the symbol inside it
  6804. var baseGroup = buildGroup(baseChar, options.havingCrampedStyle()); // Finally, we pull the skew off of the symbol.
  6805. skew = assertSymbolDomNode(baseGroup).skew; // Note that we now throw away baseGroup, because the layers we
  6806. // removed with getBaseElem might contain things like \color which
  6807. // we can't get rid of.
  6808. // TODO(emily): Find a better way to get the skew
  6809. }
  6810. var accentBelow = group.label === "\\c"; // calculate the amount of space between the body and the accent
  6811. var clearance = accentBelow ? body.height + body.depth : Math.min(body.height, options.fontMetrics().xHeight); // Build the accent
  6812. var accentBody;
  6813. if (!group.isStretchy) {
  6814. var accent;
  6815. var width;
  6816. if (group.label === "\\vec") {
  6817. // Before version 0.9, \vec used the combining font glyph U+20D7.
  6818. // But browsers, especially Safari, are not consistent in how they
  6819. // render combining characters when not preceded by a character.
  6820. // So now we use an SVG.
  6821. // If Safari reforms, we should consider reverting to the glyph.
  6822. accent = buildCommon.staticSvg("vec", options);
  6823. width = buildCommon.svgData.vec[1];
  6824. } else {
  6825. accent = buildCommon.makeOrd({
  6826. mode: group.mode,
  6827. text: group.label
  6828. }, options, "textord");
  6829. accent = assertSymbolDomNode(accent); // Remove the italic correction of the accent, because it only serves to
  6830. // shift the accent over to a place we don't want.
  6831. accent.italic = 0;
  6832. width = accent.width;
  6833. if (accentBelow) {
  6834. clearance += accent.depth;
  6835. }
  6836. }
  6837. accentBody = buildCommon.makeSpan(["accent-body"], [accent]); // "Full" accents expand the width of the resulting symbol to be
  6838. // at least the width of the accent, and overlap directly onto the
  6839. // character without any vertical offset.
  6840. var accentFull = group.label === "\\textcircled";
  6841. if (accentFull) {
  6842. accentBody.classes.push('accent-full');
  6843. clearance = body.height;
  6844. } // Shift the accent over by the skew.
  6845. var left = skew; // CSS defines `.katex .accent .accent-body:not(.accent-full) { width: 0 }`
  6846. // so that the accent doesn't contribute to the bounding box.
  6847. // We need to shift the character by its width (effectively half
  6848. // its width) to compensate.
  6849. if (!accentFull) {
  6850. left -= width / 2;
  6851. }
  6852. accentBody.style.left = makeEm(left); // \textcircled uses the \bigcirc glyph, so it needs some
  6853. // vertical adjustment to match LaTeX.
  6854. if (group.label === "\\textcircled") {
  6855. accentBody.style.top = ".2em";
  6856. }
  6857. accentBody = buildCommon.makeVList({
  6858. positionType: "firstBaseline",
  6859. children: [{
  6860. type: "elem",
  6861. elem: body
  6862. }, {
  6863. type: "kern",
  6864. size: -clearance
  6865. }, {
  6866. type: "elem",
  6867. elem: accentBody
  6868. }]
  6869. }, options);
  6870. } else {
  6871. accentBody = stretchy.svgSpan(group, options);
  6872. accentBody = buildCommon.makeVList({
  6873. positionType: "firstBaseline",
  6874. children: [{
  6875. type: "elem",
  6876. elem: body
  6877. }, {
  6878. type: "elem",
  6879. elem: accentBody,
  6880. wrapperClasses: ["svg-align"],
  6881. wrapperStyle: skew > 0 ? {
  6882. width: "calc(100% - " + makeEm(2 * skew) + ")",
  6883. marginLeft: makeEm(2 * skew)
  6884. } : undefined
  6885. }]
  6886. }, options);
  6887. }
  6888. var accentWrap = buildCommon.makeSpan(["mord", "accent"], [accentBody], options);
  6889. if (supSubGroup) {
  6890. // Here, we replace the "base" child of the supsub with our newly
  6891. // generated accent.
  6892. supSubGroup.children[0] = accentWrap; // Since we don't rerun the height calculation after replacing the
  6893. // accent, we manually recalculate height.
  6894. supSubGroup.height = Math.max(accentWrap.height, supSubGroup.height); // Accents should always be ords, even when their innards are not.
  6895. supSubGroup.classes[0] = "mord";
  6896. return supSubGroup;
  6897. } else {
  6898. return accentWrap;
  6899. }
  6900. };
  6901. var mathmlBuilder = function mathmlBuilder(group, options) {
  6902. var accentNode = group.isStretchy ? stretchy.mathMLnode(group.label) : new mathMLTree.MathNode("mo", [makeText(group.label, group.mode)]);
  6903. var node = new mathMLTree.MathNode("mover", [buildMathML_buildGroup(group.base, options), accentNode]);
  6904. node.setAttribute("accent", "true");
  6905. return node;
  6906. };
  6907. var NON_STRETCHY_ACCENT_REGEX = new RegExp(["\\acute", "\\grave", "\\ddot", "\\tilde", "\\bar", "\\breve", "\\check", "\\hat", "\\vec", "\\dot", "\\mathring"].map(function (accent) {
  6908. return "\\" + accent;
  6909. }).join("|")); // Accents
  6910. defineFunction({
  6911. type: "accent",
  6912. names: ["\\acute", "\\grave", "\\ddot", "\\tilde", "\\bar", "\\breve", "\\check", "\\hat", "\\vec", "\\dot", "\\mathring", "\\widecheck", "\\widehat", "\\widetilde", "\\overrightarrow", "\\overleftarrow", "\\Overrightarrow", "\\overleftrightarrow", "\\overgroup", "\\overlinesegment", "\\overleftharpoon", "\\overrightharpoon"],
  6913. props: {
  6914. numArgs: 1
  6915. },
  6916. handler: function handler(context, args) {
  6917. var base = normalizeArgument(args[0]);
  6918. var isStretchy = !NON_STRETCHY_ACCENT_REGEX.test(context.funcName);
  6919. var isShifty = !isStretchy || context.funcName === "\\widehat" || context.funcName === "\\widetilde" || context.funcName === "\\widecheck";
  6920. return {
  6921. type: "accent",
  6922. mode: context.parser.mode,
  6923. label: context.funcName,
  6924. isStretchy: isStretchy,
  6925. isShifty: isShifty,
  6926. base: base
  6927. };
  6928. },
  6929. htmlBuilder: htmlBuilder,
  6930. mathmlBuilder: mathmlBuilder
  6931. }); // Text-mode accents
  6932. defineFunction({
  6933. type: "accent",
  6934. names: ["\\'", "\\`", "\\^", "\\~", "\\=", "\\u", "\\.", '\\"', "\\c", "\\r", "\\H", "\\v", "\\textcircled"],
  6935. props: {
  6936. numArgs: 1,
  6937. allowedInText: true,
  6938. allowedInMath: true,
  6939. // unless in strict mode
  6940. argTypes: ["primitive"]
  6941. },
  6942. handler: function handler(context, args) {
  6943. var base = args[0];
  6944. var mode = context.parser.mode;
  6945. if (mode === "math") {
  6946. context.parser.settings.reportNonstrict("mathVsTextAccents", "LaTeX's accent " + context.funcName + " works only in text mode");
  6947. mode = "text";
  6948. }
  6949. return {
  6950. type: "accent",
  6951. mode: mode,
  6952. label: context.funcName,
  6953. isStretchy: false,
  6954. isShifty: true,
  6955. base: base
  6956. };
  6957. },
  6958. htmlBuilder: htmlBuilder,
  6959. mathmlBuilder: mathmlBuilder
  6960. });
  6961. ;// CONCATENATED MODULE: ./src/functions/accentunder.js
  6962. // Horizontal overlap functions
  6963. defineFunction({
  6964. type: "accentUnder",
  6965. names: ["\\underleftarrow", "\\underrightarrow", "\\underleftrightarrow", "\\undergroup", "\\underlinesegment", "\\utilde"],
  6966. props: {
  6967. numArgs: 1
  6968. },
  6969. handler: function handler(_ref, args) {
  6970. var parser = _ref.parser,
  6971. funcName = _ref.funcName;
  6972. var base = args[0];
  6973. return {
  6974. type: "accentUnder",
  6975. mode: parser.mode,
  6976. label: funcName,
  6977. base: base
  6978. };
  6979. },
  6980. htmlBuilder: function htmlBuilder(group, options) {
  6981. // Treat under accents much like underlines.
  6982. var innerGroup = buildGroup(group.base, options);
  6983. var accentBody = stretchy.svgSpan(group, options);
  6984. var kern = group.label === "\\utilde" ? 0.12 : 0; // Generate the vlist, with the appropriate kerns
  6985. var vlist = buildCommon.makeVList({
  6986. positionType: "top",
  6987. positionData: innerGroup.height,
  6988. children: [{
  6989. type: "elem",
  6990. elem: accentBody,
  6991. wrapperClasses: ["svg-align"]
  6992. }, {
  6993. type: "kern",
  6994. size: kern
  6995. }, {
  6996. type: "elem",
  6997. elem: innerGroup
  6998. }]
  6999. }, options);
  7000. return buildCommon.makeSpan(["mord", "accentunder"], [vlist], options);
  7001. },
  7002. mathmlBuilder: function mathmlBuilder(group, options) {
  7003. var accentNode = stretchy.mathMLnode(group.label);
  7004. var node = new mathMLTree.MathNode("munder", [buildMathML_buildGroup(group.base, options), accentNode]);
  7005. node.setAttribute("accentunder", "true");
  7006. return node;
  7007. }
  7008. });
  7009. ;// CONCATENATED MODULE: ./src/functions/arrow.js
  7010. // Helper function
  7011. var paddedNode = function paddedNode(group) {
  7012. var node = new mathMLTree.MathNode("mpadded", group ? [group] : []);
  7013. node.setAttribute("width", "+0.6em");
  7014. node.setAttribute("lspace", "0.3em");
  7015. return node;
  7016. }; // Stretchy arrows with an optional argument
  7017. defineFunction({
  7018. type: "xArrow",
  7019. names: ["\\xleftarrow", "\\xrightarrow", "\\xLeftarrow", "\\xRightarrow", "\\xleftrightarrow", "\\xLeftrightarrow", "\\xhookleftarrow", "\\xhookrightarrow", "\\xmapsto", "\\xrightharpoondown", "\\xrightharpoonup", "\\xleftharpoondown", "\\xleftharpoonup", "\\xrightleftharpoons", "\\xleftrightharpoons", "\\xlongequal", "\\xtwoheadrightarrow", "\\xtwoheadleftarrow", "\\xtofrom", // The next 3 functions are here to support the mhchem extension.
  7020. // Direct use of these functions is discouraged and may break someday.
  7021. "\\xrightleftarrows", "\\xrightequilibrium", "\\xleftequilibrium", // The next 3 functions are here only to support the {CD} environment.
  7022. "\\\\cdrightarrow", "\\\\cdleftarrow", "\\\\cdlongequal"],
  7023. props: {
  7024. numArgs: 1,
  7025. numOptionalArgs: 1
  7026. },
  7027. handler: function handler(_ref, args, optArgs) {
  7028. var parser = _ref.parser,
  7029. funcName = _ref.funcName;
  7030. return {
  7031. type: "xArrow",
  7032. mode: parser.mode,
  7033. label: funcName,
  7034. body: args[0],
  7035. below: optArgs[0]
  7036. };
  7037. },
  7038. // Flow is unable to correctly infer the type of `group`, even though it's
  7039. // unamibiguously determined from the passed-in `type` above.
  7040. htmlBuilder: function htmlBuilder(group, options) {
  7041. var style = options.style; // Build the argument groups in the appropriate style.
  7042. // Ref: amsmath.dtx: \hbox{$\scriptstyle\mkern#3mu{#6}\mkern#4mu$}%
  7043. // Some groups can return document fragments. Handle those by wrapping
  7044. // them in a span.
  7045. var newOptions = options.havingStyle(style.sup());
  7046. var upperGroup = buildCommon.wrapFragment(buildGroup(group.body, newOptions, options), options);
  7047. var arrowPrefix = group.label.slice(0, 2) === "\\x" ? "x" : "cd";
  7048. upperGroup.classes.push(arrowPrefix + "-arrow-pad");
  7049. var lowerGroup;
  7050. if (group.below) {
  7051. // Build the lower group
  7052. newOptions = options.havingStyle(style.sub());
  7053. lowerGroup = buildCommon.wrapFragment(buildGroup(group.below, newOptions, options), options);
  7054. lowerGroup.classes.push(arrowPrefix + "-arrow-pad");
  7055. }
  7056. var arrowBody = stretchy.svgSpan(group, options); // Re shift: Note that stretchy.svgSpan returned arrowBody.depth = 0.
  7057. // The point we want on the math axis is at 0.5 * arrowBody.height.
  7058. var arrowShift = -options.fontMetrics().axisHeight + 0.5 * arrowBody.height; // 2 mu kern. Ref: amsmath.dtx: #7\if0#2\else\mkern#2mu\fi
  7059. var upperShift = -options.fontMetrics().axisHeight - 0.5 * arrowBody.height - 0.111; // 0.111 em = 2 mu
  7060. if (upperGroup.depth > 0.25 || group.label === "\\xleftequilibrium") {
  7061. upperShift -= upperGroup.depth; // shift up if depth encroaches
  7062. } // Generate the vlist
  7063. var vlist;
  7064. if (lowerGroup) {
  7065. var lowerShift = -options.fontMetrics().axisHeight + lowerGroup.height + 0.5 * arrowBody.height + 0.111;
  7066. vlist = buildCommon.makeVList({
  7067. positionType: "individualShift",
  7068. children: [{
  7069. type: "elem",
  7070. elem: upperGroup,
  7071. shift: upperShift
  7072. }, {
  7073. type: "elem",
  7074. elem: arrowBody,
  7075. shift: arrowShift
  7076. }, {
  7077. type: "elem",
  7078. elem: lowerGroup,
  7079. shift: lowerShift
  7080. }]
  7081. }, options);
  7082. } else {
  7083. vlist = buildCommon.makeVList({
  7084. positionType: "individualShift",
  7085. children: [{
  7086. type: "elem",
  7087. elem: upperGroup,
  7088. shift: upperShift
  7089. }, {
  7090. type: "elem",
  7091. elem: arrowBody,
  7092. shift: arrowShift
  7093. }]
  7094. }, options);
  7095. } // $FlowFixMe: Replace this with passing "svg-align" into makeVList.
  7096. vlist.children[0].children[0].children[1].classes.push("svg-align");
  7097. return buildCommon.makeSpan(["mrel", "x-arrow"], [vlist], options);
  7098. },
  7099. mathmlBuilder: function mathmlBuilder(group, options) {
  7100. var arrowNode = stretchy.mathMLnode(group.label);
  7101. arrowNode.setAttribute("minsize", group.label.charAt(0) === "x" ? "1.75em" : "3.0em");
  7102. var node;
  7103. if (group.body) {
  7104. var upperNode = paddedNode(buildMathML_buildGroup(group.body, options));
  7105. if (group.below) {
  7106. var lowerNode = paddedNode(buildMathML_buildGroup(group.below, options));
  7107. node = new mathMLTree.MathNode("munderover", [arrowNode, lowerNode, upperNode]);
  7108. } else {
  7109. node = new mathMLTree.MathNode("mover", [arrowNode, upperNode]);
  7110. }
  7111. } else if (group.below) {
  7112. var _lowerNode = paddedNode(buildMathML_buildGroup(group.below, options));
  7113. node = new mathMLTree.MathNode("munder", [arrowNode, _lowerNode]);
  7114. } else {
  7115. // This should never happen.
  7116. // Parser.js throws an error if there is no argument.
  7117. node = paddedNode();
  7118. node = new mathMLTree.MathNode("mover", [arrowNode, node]);
  7119. }
  7120. return node;
  7121. }
  7122. });
  7123. ;// CONCATENATED MODULE: ./src/environments/cd.js
  7124. var cdArrowFunctionName = {
  7125. ">": "\\\\cdrightarrow",
  7126. "<": "\\\\cdleftarrow",
  7127. "=": "\\\\cdlongequal",
  7128. "A": "\\uparrow",
  7129. "V": "\\downarrow",
  7130. "|": "\\Vert",
  7131. ".": "no arrow"
  7132. };
  7133. var newCell = function newCell() {
  7134. // Create an empty cell, to be filled below with parse nodes.
  7135. // The parseTree from this module must be constructed like the
  7136. // one created by parseArray(), so an empty CD cell must
  7137. // be a ParseNode<"styling">. And CD is always displaystyle.
  7138. // So these values are fixed and flow can do implicit typing.
  7139. return {
  7140. type: "styling",
  7141. body: [],
  7142. mode: "math",
  7143. style: "display"
  7144. };
  7145. };
  7146. var isStartOfArrow = function isStartOfArrow(node) {
  7147. return node.type === "textord" && node.text === "@";
  7148. };
  7149. var isLabelEnd = function isLabelEnd(node, endChar) {
  7150. return (node.type === "mathord" || node.type === "atom") && node.text === endChar;
  7151. };
  7152. function cdArrow(arrowChar, labels, parser) {
  7153. // Return a parse tree of an arrow and its labels.
  7154. // This acts in a way similar to a macro expansion.
  7155. var funcName = cdArrowFunctionName[arrowChar];
  7156. switch (funcName) {
  7157. case "\\\\cdrightarrow":
  7158. case "\\\\cdleftarrow":
  7159. return parser.callFunction(funcName, [labels[0]], [labels[1]]);
  7160. case "\\uparrow":
  7161. case "\\downarrow":
  7162. {
  7163. var leftLabel = parser.callFunction("\\\\cdleft", [labels[0]], []);
  7164. var bareArrow = {
  7165. type: "atom",
  7166. text: funcName,
  7167. mode: "math",
  7168. family: "rel"
  7169. };
  7170. var sizedArrow = parser.callFunction("\\Big", [bareArrow], []);
  7171. var rightLabel = parser.callFunction("\\\\cdright", [labels[1]], []);
  7172. var arrowGroup = {
  7173. type: "ordgroup",
  7174. mode: "math",
  7175. body: [leftLabel, sizedArrow, rightLabel]
  7176. };
  7177. return parser.callFunction("\\\\cdparent", [arrowGroup], []);
  7178. }
  7179. case "\\\\cdlongequal":
  7180. return parser.callFunction("\\\\cdlongequal", [], []);
  7181. case "\\Vert":
  7182. {
  7183. var arrow = {
  7184. type: "textord",
  7185. text: "\\Vert",
  7186. mode: "math"
  7187. };
  7188. return parser.callFunction("\\Big", [arrow], []);
  7189. }
  7190. default:
  7191. return {
  7192. type: "textord",
  7193. text: " ",
  7194. mode: "math"
  7195. };
  7196. }
  7197. }
  7198. function parseCD(parser) {
  7199. // Get the array's parse nodes with \\ temporarily mapped to \cr.
  7200. var parsedRows = [];
  7201. parser.gullet.beginGroup();
  7202. parser.gullet.macros.set("\\cr", "\\\\\\relax");
  7203. parser.gullet.beginGroup();
  7204. while (true) {
  7205. // eslint-disable-line no-constant-condition
  7206. // Get the parse nodes for the next row.
  7207. parsedRows.push(parser.parseExpression(false, "\\\\"));
  7208. parser.gullet.endGroup();
  7209. parser.gullet.beginGroup();
  7210. var next = parser.fetch().text;
  7211. if (next === "&" || next === "\\\\") {
  7212. parser.consume();
  7213. } else if (next === "\\end") {
  7214. if (parsedRows[parsedRows.length - 1].length === 0) {
  7215. parsedRows.pop(); // final row ended in \\
  7216. }
  7217. break;
  7218. } else {
  7219. throw new src_ParseError("Expected \\\\ or \\cr or \\end", parser.nextToken);
  7220. }
  7221. }
  7222. var row = [];
  7223. var body = [row]; // Loop thru the parse nodes. Collect them into cells and arrows.
  7224. for (var i = 0; i < parsedRows.length; i++) {
  7225. // Start a new row.
  7226. var rowNodes = parsedRows[i]; // Create the first cell.
  7227. var cell = newCell();
  7228. for (var j = 0; j < rowNodes.length; j++) {
  7229. if (!isStartOfArrow(rowNodes[j])) {
  7230. // If a parseNode is not an arrow, it goes into a cell.
  7231. cell.body.push(rowNodes[j]);
  7232. } else {
  7233. // Parse node j is an "@", the start of an arrow.
  7234. // Before starting on the arrow, push the cell into `row`.
  7235. row.push(cell); // Now collect parseNodes into an arrow.
  7236. // The character after "@" defines the arrow type.
  7237. j += 1;
  7238. var arrowChar = assertSymbolNodeType(rowNodes[j]).text; // Create two empty label nodes. We may or may not use them.
  7239. var labels = new Array(2);
  7240. labels[0] = {
  7241. type: "ordgroup",
  7242. mode: "math",
  7243. body: []
  7244. };
  7245. labels[1] = {
  7246. type: "ordgroup",
  7247. mode: "math",
  7248. body: []
  7249. }; // Process the arrow.
  7250. if ("=|.".indexOf(arrowChar) > -1) {// Three "arrows", ``@=`, `@|`, and `@.`, do not take labels.
  7251. // Do nothing here.
  7252. } else if ("<>AV".indexOf(arrowChar) > -1) {
  7253. // Four arrows, `@>>>`, `@<<<`, `@AAA`, and `@VVV`, each take
  7254. // two optional labels. E.g. the right-point arrow syntax is
  7255. // really: @>{optional label}>{optional label}>
  7256. // Collect parseNodes into labels.
  7257. for (var labelNum = 0; labelNum < 2; labelNum++) {
  7258. var inLabel = true;
  7259. for (var k = j + 1; k < rowNodes.length; k++) {
  7260. if (isLabelEnd(rowNodes[k], arrowChar)) {
  7261. inLabel = false;
  7262. j = k;
  7263. break;
  7264. }
  7265. if (isStartOfArrow(rowNodes[k])) {
  7266. throw new src_ParseError("Missing a " + arrowChar + " character to complete a CD arrow.", rowNodes[k]);
  7267. }
  7268. labels[labelNum].body.push(rowNodes[k]);
  7269. }
  7270. if (inLabel) {
  7271. // isLabelEnd never returned a true.
  7272. throw new src_ParseError("Missing a " + arrowChar + " character to complete a CD arrow.", rowNodes[j]);
  7273. }
  7274. }
  7275. } else {
  7276. throw new src_ParseError("Expected one of \"<>AV=|.\" after @", rowNodes[j]);
  7277. } // Now join the arrow to its labels.
  7278. var arrow = cdArrow(arrowChar, labels, parser); // Wrap the arrow in ParseNode<"styling">.
  7279. // This is done to match parseArray() behavior.
  7280. var wrappedArrow = {
  7281. type: "styling",
  7282. body: [arrow],
  7283. mode: "math",
  7284. style: "display" // CD is always displaystyle.
  7285. };
  7286. row.push(wrappedArrow); // In CD's syntax, cells are implicit. That is, everything that
  7287. // is not an arrow gets collected into a cell. So create an empty
  7288. // cell now. It will collect upcoming parseNodes.
  7289. cell = newCell();
  7290. }
  7291. }
  7292. if (i % 2 === 0) {
  7293. // Even-numbered rows consist of: cell, arrow, cell, arrow, ... cell
  7294. // The last cell is not yet pushed into `row`, so:
  7295. row.push(cell);
  7296. } else {
  7297. // Odd-numbered rows consist of: vert arrow, empty cell, ... vert arrow
  7298. // Remove the empty cell that was placed at the beginning of `row`.
  7299. row.shift();
  7300. }
  7301. row = [];
  7302. body.push(row);
  7303. } // End row group
  7304. parser.gullet.endGroup(); // End array group defining \\
  7305. parser.gullet.endGroup(); // define column separation.
  7306. var cols = new Array(body[0].length).fill({
  7307. type: "align",
  7308. align: "c",
  7309. pregap: 0.25,
  7310. // CD package sets \enskip between columns.
  7311. postgap: 0.25 // So pre and post each get half an \enskip, i.e. 0.25em.
  7312. });
  7313. return {
  7314. type: "array",
  7315. mode: "math",
  7316. body: body,
  7317. arraystretch: 1,
  7318. addJot: true,
  7319. rowGaps: [null],
  7320. cols: cols,
  7321. colSeparationType: "CD",
  7322. hLinesBeforeRow: new Array(body.length + 1).fill([])
  7323. };
  7324. } // The functions below are not available for general use.
  7325. // They are here only for internal use by the {CD} environment in placing labels
  7326. // next to vertical arrows.
  7327. // We don't need any such functions for horizontal arrows because we can reuse
  7328. // the functionality that already exists for extensible arrows.
  7329. defineFunction({
  7330. type: "cdlabel",
  7331. names: ["\\\\cdleft", "\\\\cdright"],
  7332. props: {
  7333. numArgs: 1
  7334. },
  7335. handler: function handler(_ref, args) {
  7336. var parser = _ref.parser,
  7337. funcName = _ref.funcName;
  7338. return {
  7339. type: "cdlabel",
  7340. mode: parser.mode,
  7341. side: funcName.slice(4),
  7342. label: args[0]
  7343. };
  7344. },
  7345. htmlBuilder: function htmlBuilder(group, options) {
  7346. var newOptions = options.havingStyle(options.style.sup());
  7347. var label = buildCommon.wrapFragment(buildGroup(group.label, newOptions, options), options);
  7348. label.classes.push("cd-label-" + group.side);
  7349. label.style.bottom = makeEm(0.8 - label.depth); // Zero out label height & depth, so vertical align of arrow is set
  7350. // by the arrow height, not by the label.
  7351. label.height = 0;
  7352. label.depth = 0;
  7353. return label;
  7354. },
  7355. mathmlBuilder: function mathmlBuilder(group, options) {
  7356. var label = new mathMLTree.MathNode("mrow", [buildMathML_buildGroup(group.label, options)]);
  7357. label = new mathMLTree.MathNode("mpadded", [label]);
  7358. label.setAttribute("width", "0");
  7359. if (group.side === "left") {
  7360. label.setAttribute("lspace", "-1width");
  7361. } // We have to guess at vertical alignment. We know the arrow is 1.8em tall,
  7362. // But we don't know the height or depth of the label.
  7363. label.setAttribute("voffset", "0.7em");
  7364. label = new mathMLTree.MathNode("mstyle", [label]);
  7365. label.setAttribute("displaystyle", "false");
  7366. label.setAttribute("scriptlevel", "1");
  7367. return label;
  7368. }
  7369. });
  7370. defineFunction({
  7371. type: "cdlabelparent",
  7372. names: ["\\\\cdparent"],
  7373. props: {
  7374. numArgs: 1
  7375. },
  7376. handler: function handler(_ref2, args) {
  7377. var parser = _ref2.parser;
  7378. return {
  7379. type: "cdlabelparent",
  7380. mode: parser.mode,
  7381. fragment: args[0]
  7382. };
  7383. },
  7384. htmlBuilder: function htmlBuilder(group, options) {
  7385. // Wrap the vertical arrow and its labels.
  7386. // The parent gets position: relative. The child gets position: absolute.
  7387. // So CSS can locate the label correctly.
  7388. var parent = buildCommon.wrapFragment(buildGroup(group.fragment, options), options);
  7389. parent.classes.push("cd-vert-arrow");
  7390. return parent;
  7391. },
  7392. mathmlBuilder: function mathmlBuilder(group, options) {
  7393. return new mathMLTree.MathNode("mrow", [buildMathML_buildGroup(group.fragment, options)]);
  7394. }
  7395. });
  7396. ;// CONCATENATED MODULE: ./src/functions/char.js
  7397. // \@char is an internal function that takes a grouped decimal argument like
  7398. // {123} and converts into symbol with code 123. It is used by the *macro*
  7399. // \char defined in macros.js.
  7400. defineFunction({
  7401. type: "textord",
  7402. names: ["\\@char"],
  7403. props: {
  7404. numArgs: 1,
  7405. allowedInText: true
  7406. },
  7407. handler: function handler(_ref, args) {
  7408. var parser = _ref.parser;
  7409. var arg = assertNodeType(args[0], "ordgroup");
  7410. var group = arg.body;
  7411. var number = "";
  7412. for (var i = 0; i < group.length; i++) {
  7413. var node = assertNodeType(group[i], "textord");
  7414. number += node.text;
  7415. }
  7416. var code = parseInt(number);
  7417. var text;
  7418. if (isNaN(code)) {
  7419. throw new src_ParseError("\\@char has non-numeric argument " + number); // If we drop IE support, the following code could be replaced with
  7420. // text = String.fromCodePoint(code)
  7421. } else if (code < 0 || code >= 0x10ffff) {
  7422. throw new src_ParseError("\\@char with invalid code point " + number);
  7423. } else if (code <= 0xffff) {
  7424. text = String.fromCharCode(code);
  7425. } else {
  7426. // Astral code point; split into surrogate halves
  7427. code -= 0x10000;
  7428. text = String.fromCharCode((code >> 10) + 0xd800, (code & 0x3ff) + 0xdc00);
  7429. }
  7430. return {
  7431. type: "textord",
  7432. mode: parser.mode,
  7433. text: text
  7434. };
  7435. }
  7436. });
  7437. ;// CONCATENATED MODULE: ./src/functions/color.js
  7438. var color_htmlBuilder = function htmlBuilder(group, options) {
  7439. var elements = buildExpression(group.body, options.withColor(group.color), false); // \color isn't supposed to affect the type of the elements it contains.
  7440. // To accomplish this, we wrap the results in a fragment, so the inner
  7441. // elements will be able to directly interact with their neighbors. For
  7442. // example, `\color{red}{2 +} 3` has the same spacing as `2 + 3`
  7443. return buildCommon.makeFragment(elements);
  7444. };
  7445. var color_mathmlBuilder = function mathmlBuilder(group, options) {
  7446. var inner = buildMathML_buildExpression(group.body, options.withColor(group.color));
  7447. var node = new mathMLTree.MathNode("mstyle", inner);
  7448. node.setAttribute("mathcolor", group.color);
  7449. return node;
  7450. };
  7451. defineFunction({
  7452. type: "color",
  7453. names: ["\\textcolor"],
  7454. props: {
  7455. numArgs: 2,
  7456. allowedInText: true,
  7457. argTypes: ["color", "original"]
  7458. },
  7459. handler: function handler(_ref, args) {
  7460. var parser = _ref.parser;
  7461. var color = assertNodeType(args[0], "color-token").color;
  7462. var body = args[1];
  7463. return {
  7464. type: "color",
  7465. mode: parser.mode,
  7466. color: color,
  7467. body: ordargument(body)
  7468. };
  7469. },
  7470. htmlBuilder: color_htmlBuilder,
  7471. mathmlBuilder: color_mathmlBuilder
  7472. });
  7473. defineFunction({
  7474. type: "color",
  7475. names: ["\\color"],
  7476. props: {
  7477. numArgs: 1,
  7478. allowedInText: true,
  7479. argTypes: ["color"]
  7480. },
  7481. handler: function handler(_ref2, args) {
  7482. var parser = _ref2.parser,
  7483. breakOnTokenText = _ref2.breakOnTokenText;
  7484. var color = assertNodeType(args[0], "color-token").color; // Set macro \current@color in current namespace to store the current
  7485. // color, mimicking the behavior of color.sty.
  7486. // This is currently used just to correctly color a \right
  7487. // that follows a \color command.
  7488. parser.gullet.macros.set("\\current@color", color); // Parse out the implicit body that should be colored.
  7489. var body = parser.parseExpression(true, breakOnTokenText);
  7490. return {
  7491. type: "color",
  7492. mode: parser.mode,
  7493. color: color,
  7494. body: body
  7495. };
  7496. },
  7497. htmlBuilder: color_htmlBuilder,
  7498. mathmlBuilder: color_mathmlBuilder
  7499. });
  7500. ;// CONCATENATED MODULE: ./src/functions/cr.js
  7501. // Row breaks within tabular environments, and line breaks at top level
  7502. // \DeclareRobustCommand\\{...\@xnewline}
  7503. defineFunction({
  7504. type: "cr",
  7505. names: ["\\\\"],
  7506. props: {
  7507. numArgs: 0,
  7508. numOptionalArgs: 1,
  7509. argTypes: ["size"],
  7510. allowedInText: true
  7511. },
  7512. handler: function handler(_ref, args, optArgs) {
  7513. var parser = _ref.parser;
  7514. var size = optArgs[0];
  7515. var newLine = !parser.settings.displayMode || !parser.settings.useStrictBehavior("newLineInDisplayMode", "In LaTeX, \\\\ or \\newline " + "does nothing in display mode");
  7516. return {
  7517. type: "cr",
  7518. mode: parser.mode,
  7519. newLine: newLine,
  7520. size: size && assertNodeType(size, "size").value
  7521. };
  7522. },
  7523. // The following builders are called only at the top level,
  7524. // not within tabular/array environments.
  7525. htmlBuilder: function htmlBuilder(group, options) {
  7526. var span = buildCommon.makeSpan(["mspace"], [], options);
  7527. if (group.newLine) {
  7528. span.classes.push("newline");
  7529. if (group.size) {
  7530. span.style.marginTop = makeEm(calculateSize(group.size, options));
  7531. }
  7532. }
  7533. return span;
  7534. },
  7535. mathmlBuilder: function mathmlBuilder(group, options) {
  7536. var node = new mathMLTree.MathNode("mspace");
  7537. if (group.newLine) {
  7538. node.setAttribute("linebreak", "newline");
  7539. if (group.size) {
  7540. node.setAttribute("height", makeEm(calculateSize(group.size, options)));
  7541. }
  7542. }
  7543. return node;
  7544. }
  7545. });
  7546. ;// CONCATENATED MODULE: ./src/functions/def.js
  7547. var globalMap = {
  7548. "\\global": "\\global",
  7549. "\\long": "\\\\globallong",
  7550. "\\\\globallong": "\\\\globallong",
  7551. "\\def": "\\gdef",
  7552. "\\gdef": "\\gdef",
  7553. "\\edef": "\\xdef",
  7554. "\\xdef": "\\xdef",
  7555. "\\let": "\\\\globallet",
  7556. "\\futurelet": "\\\\globalfuture"
  7557. };
  7558. var checkControlSequence = function checkControlSequence(tok) {
  7559. var name = tok.text;
  7560. if (/^(?:[\\{}$&#^_]|EOF)$/.test(name)) {
  7561. throw new src_ParseError("Expected a control sequence", tok);
  7562. }
  7563. return name;
  7564. };
  7565. var getRHS = function getRHS(parser) {
  7566. var tok = parser.gullet.popToken();
  7567. if (tok.text === "=") {
  7568. // consume optional equals
  7569. tok = parser.gullet.popToken();
  7570. if (tok.text === " ") {
  7571. // consume one optional space
  7572. tok = parser.gullet.popToken();
  7573. }
  7574. }
  7575. return tok;
  7576. };
  7577. var letCommand = function letCommand(parser, name, tok, global) {
  7578. var macro = parser.gullet.macros.get(tok.text);
  7579. if (macro == null) {
  7580. // don't expand it later even if a macro with the same name is defined
  7581. // e.g., \let\foo=\frac \def\frac{\relax} \frac12
  7582. tok.noexpand = true;
  7583. macro = {
  7584. tokens: [tok],
  7585. numArgs: 0,
  7586. // reproduce the same behavior in expansion
  7587. unexpandable: !parser.gullet.isExpandable(tok.text)
  7588. };
  7589. }
  7590. parser.gullet.macros.set(name, macro, global);
  7591. }; // <assignment> -> <non-macro assignment>|<macro assignment>
  7592. // <non-macro assignment> -> <simple assignment>|\global<non-macro assignment>
  7593. // <macro assignment> -> <definition>|<prefix><macro assignment>
  7594. // <prefix> -> \global|\long|\outer
  7595. defineFunction({
  7596. type: "internal",
  7597. names: ["\\global", "\\long", "\\\\globallong" // can’t be entered directly
  7598. ],
  7599. props: {
  7600. numArgs: 0,
  7601. allowedInText: true
  7602. },
  7603. handler: function handler(_ref) {
  7604. var parser = _ref.parser,
  7605. funcName = _ref.funcName;
  7606. parser.consumeSpaces();
  7607. var token = parser.fetch();
  7608. if (globalMap[token.text]) {
  7609. // KaTeX doesn't have \par, so ignore \long
  7610. if (funcName === "\\global" || funcName === "\\\\globallong") {
  7611. token.text = globalMap[token.text];
  7612. }
  7613. return assertNodeType(parser.parseFunction(), "internal");
  7614. }
  7615. throw new src_ParseError("Invalid token after macro prefix", token);
  7616. }
  7617. }); // Basic support for macro definitions: \def, \gdef, \edef, \xdef
  7618. // <definition> -> <def><control sequence><definition text>
  7619. // <def> -> \def|\gdef|\edef|\xdef
  7620. // <definition text> -> <parameter text><left brace><balanced text><right brace>
  7621. defineFunction({
  7622. type: "internal",
  7623. names: ["\\def", "\\gdef", "\\edef", "\\xdef"],
  7624. props: {
  7625. numArgs: 0,
  7626. allowedInText: true,
  7627. primitive: true
  7628. },
  7629. handler: function handler(_ref2) {
  7630. var parser = _ref2.parser,
  7631. funcName = _ref2.funcName;
  7632. var tok = parser.gullet.popToken();
  7633. var name = tok.text;
  7634. if (/^(?:[\\{}$&#^_]|EOF)$/.test(name)) {
  7635. throw new src_ParseError("Expected a control sequence", tok);
  7636. }
  7637. var numArgs = 0;
  7638. var insert;
  7639. var delimiters = [[]]; // <parameter text> contains no braces
  7640. while (parser.gullet.future().text !== "{") {
  7641. tok = parser.gullet.popToken();
  7642. if (tok.text === "#") {
  7643. // If the very last character of the <parameter text> is #, so that
  7644. // this # is immediately followed by {, TeX will behave as if the {
  7645. // had been inserted at the right end of both the parameter text
  7646. // and the replacement text.
  7647. if (parser.gullet.future().text === "{") {
  7648. insert = parser.gullet.future();
  7649. delimiters[numArgs].push("{");
  7650. break;
  7651. } // A parameter, the first appearance of # must be followed by 1,
  7652. // the next by 2, and so on; up to nine #’s are allowed
  7653. tok = parser.gullet.popToken();
  7654. if (!/^[1-9]$/.test(tok.text)) {
  7655. throw new src_ParseError("Invalid argument number \"" + tok.text + "\"");
  7656. }
  7657. if (parseInt(tok.text) !== numArgs + 1) {
  7658. throw new src_ParseError("Argument number \"" + tok.text + "\" out of order");
  7659. }
  7660. numArgs++;
  7661. delimiters.push([]);
  7662. } else if (tok.text === "EOF") {
  7663. throw new src_ParseError("Expected a macro definition");
  7664. } else {
  7665. delimiters[numArgs].push(tok.text);
  7666. }
  7667. } // replacement text, enclosed in '{' and '}' and properly nested
  7668. var _parser$gullet$consum = parser.gullet.consumeArg(),
  7669. tokens = _parser$gullet$consum.tokens;
  7670. if (insert) {
  7671. tokens.unshift(insert);
  7672. }
  7673. if (funcName === "\\edef" || funcName === "\\xdef") {
  7674. tokens = parser.gullet.expandTokens(tokens);
  7675. tokens.reverse(); // to fit in with stack order
  7676. } // Final arg is the expansion of the macro
  7677. parser.gullet.macros.set(name, {
  7678. tokens: tokens,
  7679. numArgs: numArgs,
  7680. delimiters: delimiters
  7681. }, funcName === globalMap[funcName]);
  7682. return {
  7683. type: "internal",
  7684. mode: parser.mode
  7685. };
  7686. }
  7687. }); // <simple assignment> -> <let assignment>
  7688. // <let assignment> -> \futurelet<control sequence><token><token>
  7689. // | \let<control sequence><equals><one optional space><token>
  7690. // <equals> -> <optional spaces>|<optional spaces>=
  7691. defineFunction({
  7692. type: "internal",
  7693. names: ["\\let", "\\\\globallet" // can’t be entered directly
  7694. ],
  7695. props: {
  7696. numArgs: 0,
  7697. allowedInText: true,
  7698. primitive: true
  7699. },
  7700. handler: function handler(_ref3) {
  7701. var parser = _ref3.parser,
  7702. funcName = _ref3.funcName;
  7703. var name = checkControlSequence(parser.gullet.popToken());
  7704. parser.gullet.consumeSpaces();
  7705. var tok = getRHS(parser);
  7706. letCommand(parser, name, tok, funcName === "\\\\globallet");
  7707. return {
  7708. type: "internal",
  7709. mode: parser.mode
  7710. };
  7711. }
  7712. }); // ref: https://www.tug.org/TUGboat/tb09-3/tb22bechtolsheim.pdf
  7713. defineFunction({
  7714. type: "internal",
  7715. names: ["\\futurelet", "\\\\globalfuture" // can’t be entered directly
  7716. ],
  7717. props: {
  7718. numArgs: 0,
  7719. allowedInText: true,
  7720. primitive: true
  7721. },
  7722. handler: function handler(_ref4) {
  7723. var parser = _ref4.parser,
  7724. funcName = _ref4.funcName;
  7725. var name = checkControlSequence(parser.gullet.popToken());
  7726. var middle = parser.gullet.popToken();
  7727. var tok = parser.gullet.popToken();
  7728. letCommand(parser, name, tok, funcName === "\\\\globalfuture");
  7729. parser.gullet.pushToken(tok);
  7730. parser.gullet.pushToken(middle);
  7731. return {
  7732. type: "internal",
  7733. mode: parser.mode
  7734. };
  7735. }
  7736. });
  7737. ;// CONCATENATED MODULE: ./src/delimiter.js
  7738. /**
  7739. * This file deals with creating delimiters of various sizes. The TeXbook
  7740. * discusses these routines on page 441-442, in the "Another subroutine sets box
  7741. * x to a specified variable delimiter" paragraph.
  7742. *
  7743. * There are three main routines here. `makeSmallDelim` makes a delimiter in the
  7744. * normal font, but in either text, script, or scriptscript style.
  7745. * `makeLargeDelim` makes a delimiter in textstyle, but in one of the Size1,
  7746. * Size2, Size3, or Size4 fonts. `makeStackedDelim` makes a delimiter out of
  7747. * smaller pieces that are stacked on top of one another.
  7748. *
  7749. * The functions take a parameter `center`, which determines if the delimiter
  7750. * should be centered around the axis.
  7751. *
  7752. * Then, there are three exposed functions. `sizedDelim` makes a delimiter in
  7753. * one of the given sizes. This is used for things like `\bigl`.
  7754. * `customSizedDelim` makes a delimiter with a given total height+depth. It is
  7755. * called in places like `\sqrt`. `leftRightDelim` makes an appropriate
  7756. * delimiter which surrounds an expression of a given height an depth. It is
  7757. * used in `\left` and `\right`.
  7758. */
  7759. /**
  7760. * Get the metrics for a given symbol and font, after transformation (i.e.
  7761. * after following replacement from symbols.js)
  7762. */
  7763. var getMetrics = function getMetrics(symbol, font, mode) {
  7764. var replace = src_symbols.math[symbol] && src_symbols.math[symbol].replace;
  7765. var metrics = getCharacterMetrics(replace || symbol, font, mode);
  7766. if (!metrics) {
  7767. throw new Error("Unsupported symbol " + symbol + " and font size " + font + ".");
  7768. }
  7769. return metrics;
  7770. };
  7771. /**
  7772. * Puts a delimiter span in a given style, and adds appropriate height, depth,
  7773. * and maxFontSizes.
  7774. */
  7775. var styleWrap = function styleWrap(delim, toStyle, options, classes) {
  7776. var newOptions = options.havingBaseStyle(toStyle);
  7777. var span = buildCommon.makeSpan(classes.concat(newOptions.sizingClasses(options)), [delim], options);
  7778. var delimSizeMultiplier = newOptions.sizeMultiplier / options.sizeMultiplier;
  7779. span.height *= delimSizeMultiplier;
  7780. span.depth *= delimSizeMultiplier;
  7781. span.maxFontSize = newOptions.sizeMultiplier;
  7782. return span;
  7783. };
  7784. var centerSpan = function centerSpan(span, options, style) {
  7785. var newOptions = options.havingBaseStyle(style);
  7786. var shift = (1 - options.sizeMultiplier / newOptions.sizeMultiplier) * options.fontMetrics().axisHeight;
  7787. span.classes.push("delimcenter");
  7788. span.style.top = makeEm(shift);
  7789. span.height -= shift;
  7790. span.depth += shift;
  7791. };
  7792. /**
  7793. * Makes a small delimiter. This is a delimiter that comes in the Main-Regular
  7794. * font, but is restyled to either be in textstyle, scriptstyle, or
  7795. * scriptscriptstyle.
  7796. */
  7797. var makeSmallDelim = function makeSmallDelim(delim, style, center, options, mode, classes) {
  7798. var text = buildCommon.makeSymbol(delim, "Main-Regular", mode, options);
  7799. var span = styleWrap(text, style, options, classes);
  7800. if (center) {
  7801. centerSpan(span, options, style);
  7802. }
  7803. return span;
  7804. };
  7805. /**
  7806. * Builds a symbol in the given font size (note size is an integer)
  7807. */
  7808. var mathrmSize = function mathrmSize(value, size, mode, options) {
  7809. return buildCommon.makeSymbol(value, "Size" + size + "-Regular", mode, options);
  7810. };
  7811. /**
  7812. * Makes a large delimiter. This is a delimiter that comes in the Size1, Size2,
  7813. * Size3, or Size4 fonts. It is always rendered in textstyle.
  7814. */
  7815. var makeLargeDelim = function makeLargeDelim(delim, size, center, options, mode, classes) {
  7816. var inner = mathrmSize(delim, size, mode, options);
  7817. var span = styleWrap(buildCommon.makeSpan(["delimsizing", "size" + size], [inner], options), src_Style.TEXT, options, classes);
  7818. if (center) {
  7819. centerSpan(span, options, src_Style.TEXT);
  7820. }
  7821. return span;
  7822. };
  7823. /**
  7824. * Make a span from a font glyph with the given offset and in the given font.
  7825. * This is used in makeStackedDelim to make the stacking pieces for the delimiter.
  7826. */
  7827. var makeGlyphSpan = function makeGlyphSpan(symbol, font, mode) {
  7828. var sizeClass; // Apply the correct CSS class to choose the right font.
  7829. if (font === "Size1-Regular") {
  7830. sizeClass = "delim-size1";
  7831. } else
  7832. /* if (font === "Size4-Regular") */
  7833. {
  7834. sizeClass = "delim-size4";
  7835. }
  7836. var corner = buildCommon.makeSpan(["delimsizinginner", sizeClass], [buildCommon.makeSpan([], [buildCommon.makeSymbol(symbol, font, mode)])]); // Since this will be passed into `makeVList` in the end, wrap the element
  7837. // in the appropriate tag that VList uses.
  7838. return {
  7839. type: "elem",
  7840. elem: corner
  7841. };
  7842. };
  7843. var makeInner = function makeInner(ch, height, options) {
  7844. // Create a span with inline SVG for the inner part of a tall stacked delimiter.
  7845. var width = fontMetricsData["Size4-Regular"][ch.charCodeAt(0)] ? fontMetricsData["Size4-Regular"][ch.charCodeAt(0)][4] : fontMetricsData["Size1-Regular"][ch.charCodeAt(0)][4];
  7846. var path = new PathNode("inner", innerPath(ch, Math.round(1000 * height)));
  7847. var svgNode = new SvgNode([path], {
  7848. "width": makeEm(width),
  7849. "height": makeEm(height),
  7850. // Override CSS rule `.katex svg { width: 100% }`
  7851. "style": "width:" + makeEm(width),
  7852. "viewBox": "0 0 " + 1000 * width + " " + Math.round(1000 * height),
  7853. "preserveAspectRatio": "xMinYMin"
  7854. });
  7855. var span = buildCommon.makeSvgSpan([], [svgNode], options);
  7856. span.height = height;
  7857. span.style.height = makeEm(height);
  7858. span.style.width = makeEm(width);
  7859. return {
  7860. type: "elem",
  7861. elem: span
  7862. };
  7863. }; // Helpers for makeStackedDelim
  7864. var lapInEms = 0.008;
  7865. var lap = {
  7866. type: "kern",
  7867. size: -1 * lapInEms
  7868. };
  7869. var verts = ["|", "\\lvert", "\\rvert", "\\vert"];
  7870. var doubleVerts = ["\\|", "\\lVert", "\\rVert", "\\Vert"];
  7871. /**
  7872. * Make a stacked delimiter out of a given delimiter, with the total height at
  7873. * least `heightTotal`. This routine is mentioned on page 442 of the TeXbook.
  7874. */
  7875. var makeStackedDelim = function makeStackedDelim(delim, heightTotal, center, options, mode, classes) {
  7876. // There are four parts, the top, an optional middle, a repeated part, and a
  7877. // bottom.
  7878. var top;
  7879. var middle;
  7880. var repeat;
  7881. var bottom;
  7882. top = repeat = bottom = delim;
  7883. middle = null; // Also keep track of what font the delimiters are in
  7884. var font = "Size1-Regular"; // We set the parts and font based on the symbol. Note that we use
  7885. // '\u23d0' instead of '|' and '\u2016' instead of '\\|' for the
  7886. // repeats of the arrows
  7887. if (delim === "\\uparrow") {
  7888. repeat = bottom = "\u23D0";
  7889. } else if (delim === "\\Uparrow") {
  7890. repeat = bottom = "\u2016";
  7891. } else if (delim === "\\downarrow") {
  7892. top = repeat = "\u23D0";
  7893. } else if (delim === "\\Downarrow") {
  7894. top = repeat = "\u2016";
  7895. } else if (delim === "\\updownarrow") {
  7896. top = "\\uparrow";
  7897. repeat = "\u23D0";
  7898. bottom = "\\downarrow";
  7899. } else if (delim === "\\Updownarrow") {
  7900. top = "\\Uparrow";
  7901. repeat = "\u2016";
  7902. bottom = "\\Downarrow";
  7903. } else if (utils.contains(verts, delim)) {
  7904. repeat = "\u2223";
  7905. } else if (utils.contains(doubleVerts, delim)) {
  7906. repeat = "\u2225";
  7907. } else if (delim === "[" || delim === "\\lbrack") {
  7908. top = "\u23A1";
  7909. repeat = "\u23A2";
  7910. bottom = "\u23A3";
  7911. font = "Size4-Regular";
  7912. } else if (delim === "]" || delim === "\\rbrack") {
  7913. top = "\u23A4";
  7914. repeat = "\u23A5";
  7915. bottom = "\u23A6";
  7916. font = "Size4-Regular";
  7917. } else if (delim === "\\lfloor" || delim === "\u230A") {
  7918. repeat = top = "\u23A2";
  7919. bottom = "\u23A3";
  7920. font = "Size4-Regular";
  7921. } else if (delim === "\\lceil" || delim === "\u2308") {
  7922. top = "\u23A1";
  7923. repeat = bottom = "\u23A2";
  7924. font = "Size4-Regular";
  7925. } else if (delim === "\\rfloor" || delim === "\u230B") {
  7926. repeat = top = "\u23A5";
  7927. bottom = "\u23A6";
  7928. font = "Size4-Regular";
  7929. } else if (delim === "\\rceil" || delim === "\u2309") {
  7930. top = "\u23A4";
  7931. repeat = bottom = "\u23A5";
  7932. font = "Size4-Regular";
  7933. } else if (delim === "(" || delim === "\\lparen") {
  7934. top = "\u239B";
  7935. repeat = "\u239C";
  7936. bottom = "\u239D";
  7937. font = "Size4-Regular";
  7938. } else if (delim === ")" || delim === "\\rparen") {
  7939. top = "\u239E";
  7940. repeat = "\u239F";
  7941. bottom = "\u23A0";
  7942. font = "Size4-Regular";
  7943. } else if (delim === "\\{" || delim === "\\lbrace") {
  7944. top = "\u23A7";
  7945. middle = "\u23A8";
  7946. bottom = "\u23A9";
  7947. repeat = "\u23AA";
  7948. font = "Size4-Regular";
  7949. } else if (delim === "\\}" || delim === "\\rbrace") {
  7950. top = "\u23AB";
  7951. middle = "\u23AC";
  7952. bottom = "\u23AD";
  7953. repeat = "\u23AA";
  7954. font = "Size4-Regular";
  7955. } else if (delim === "\\lgroup" || delim === "\u27EE") {
  7956. top = "\u23A7";
  7957. bottom = "\u23A9";
  7958. repeat = "\u23AA";
  7959. font = "Size4-Regular";
  7960. } else if (delim === "\\rgroup" || delim === "\u27EF") {
  7961. top = "\u23AB";
  7962. bottom = "\u23AD";
  7963. repeat = "\u23AA";
  7964. font = "Size4-Regular";
  7965. } else if (delim === "\\lmoustache" || delim === "\u23B0") {
  7966. top = "\u23A7";
  7967. bottom = "\u23AD";
  7968. repeat = "\u23AA";
  7969. font = "Size4-Regular";
  7970. } else if (delim === "\\rmoustache" || delim === "\u23B1") {
  7971. top = "\u23AB";
  7972. bottom = "\u23A9";
  7973. repeat = "\u23AA";
  7974. font = "Size4-Regular";
  7975. } // Get the metrics of the four sections
  7976. var topMetrics = getMetrics(top, font, mode);
  7977. var topHeightTotal = topMetrics.height + topMetrics.depth;
  7978. var repeatMetrics = getMetrics(repeat, font, mode);
  7979. var repeatHeightTotal = repeatMetrics.height + repeatMetrics.depth;
  7980. var bottomMetrics = getMetrics(bottom, font, mode);
  7981. var bottomHeightTotal = bottomMetrics.height + bottomMetrics.depth;
  7982. var middleHeightTotal = 0;
  7983. var middleFactor = 1;
  7984. if (middle !== null) {
  7985. var middleMetrics = getMetrics(middle, font, mode);
  7986. middleHeightTotal = middleMetrics.height + middleMetrics.depth;
  7987. middleFactor = 2; // repeat symmetrically above and below middle
  7988. } // Calcuate the minimal height that the delimiter can have.
  7989. // It is at least the size of the top, bottom, and optional middle combined.
  7990. var minHeight = topHeightTotal + bottomHeightTotal + middleHeightTotal; // Compute the number of copies of the repeat symbol we will need
  7991. var repeatCount = Math.max(0, Math.ceil((heightTotal - minHeight) / (middleFactor * repeatHeightTotal))); // Compute the total height of the delimiter including all the symbols
  7992. var realHeightTotal = minHeight + repeatCount * middleFactor * repeatHeightTotal; // The center of the delimiter is placed at the center of the axis. Note
  7993. // that in this context, "center" means that the delimiter should be
  7994. // centered around the axis in the current style, while normally it is
  7995. // centered around the axis in textstyle.
  7996. var axisHeight = options.fontMetrics().axisHeight;
  7997. if (center) {
  7998. axisHeight *= options.sizeMultiplier;
  7999. } // Calculate the depth
  8000. var depth = realHeightTotal / 2 - axisHeight; // Now, we start building the pieces that will go into the vlist
  8001. // Keep a list of the pieces of the stacked delimiter
  8002. var stack = []; // Add the bottom symbol
  8003. stack.push(makeGlyphSpan(bottom, font, mode));
  8004. stack.push(lap); // overlap
  8005. if (middle === null) {
  8006. // The middle section will be an SVG. Make it an extra 0.016em tall.
  8007. // We'll overlap by 0.008em at top and bottom.
  8008. var innerHeight = realHeightTotal - topHeightTotal - bottomHeightTotal + 2 * lapInEms;
  8009. stack.push(makeInner(repeat, innerHeight, options));
  8010. } else {
  8011. // When there is a middle bit, we need the middle part and two repeated
  8012. // sections
  8013. var _innerHeight = (realHeightTotal - topHeightTotal - bottomHeightTotal - middleHeightTotal) / 2 + 2 * lapInEms;
  8014. stack.push(makeInner(repeat, _innerHeight, options)); // Now insert the middle of the brace.
  8015. stack.push(lap);
  8016. stack.push(makeGlyphSpan(middle, font, mode));
  8017. stack.push(lap);
  8018. stack.push(makeInner(repeat, _innerHeight, options));
  8019. } // Add the top symbol
  8020. stack.push(lap);
  8021. stack.push(makeGlyphSpan(top, font, mode)); // Finally, build the vlist
  8022. var newOptions = options.havingBaseStyle(src_Style.TEXT);
  8023. var inner = buildCommon.makeVList({
  8024. positionType: "bottom",
  8025. positionData: depth,
  8026. children: stack
  8027. }, newOptions);
  8028. return styleWrap(buildCommon.makeSpan(["delimsizing", "mult"], [inner], newOptions), src_Style.TEXT, options, classes);
  8029. }; // All surds have 0.08em padding above the viniculum inside the SVG.
  8030. // That keeps browser span height rounding error from pinching the line.
  8031. var vbPad = 80; // padding above the surd, measured inside the viewBox.
  8032. var emPad = 0.08; // padding, in ems, measured in the document.
  8033. var sqrtSvg = function sqrtSvg(sqrtName, height, viewBoxHeight, extraViniculum, options) {
  8034. var path = sqrtPath(sqrtName, extraViniculum, viewBoxHeight);
  8035. var pathNode = new PathNode(sqrtName, path);
  8036. var svg = new SvgNode([pathNode], {
  8037. // Note: 1000:1 ratio of viewBox to document em width.
  8038. "width": "400em",
  8039. "height": makeEm(height),
  8040. "viewBox": "0 0 400000 " + viewBoxHeight,
  8041. "preserveAspectRatio": "xMinYMin slice"
  8042. });
  8043. return buildCommon.makeSvgSpan(["hide-tail"], [svg], options);
  8044. };
  8045. /**
  8046. * Make a sqrt image of the given height,
  8047. */
  8048. var makeSqrtImage = function makeSqrtImage(height, options) {
  8049. // Define a newOptions that removes the effect of size changes such as \Huge.
  8050. // We don't pick different a height surd for \Huge. For it, we scale up.
  8051. var newOptions = options.havingBaseSizing(); // Pick the desired surd glyph from a sequence of surds.
  8052. var delim = traverseSequence("\\surd", height * newOptions.sizeMultiplier, stackLargeDelimiterSequence, newOptions);
  8053. var sizeMultiplier = newOptions.sizeMultiplier; // default
  8054. // The standard sqrt SVGs each have a 0.04em thick viniculum.
  8055. // If Settings.minRuleThickness is larger than that, we add extraViniculum.
  8056. var extraViniculum = Math.max(0, options.minRuleThickness - options.fontMetrics().sqrtRuleThickness); // Create a span containing an SVG image of a sqrt symbol.
  8057. var span;
  8058. var spanHeight = 0;
  8059. var texHeight = 0;
  8060. var viewBoxHeight = 0;
  8061. var advanceWidth; // We create viewBoxes with 80 units of "padding" above each surd.
  8062. // Then browser rounding error on the parent span height will not
  8063. // encroach on the ink of the viniculum. But that padding is not
  8064. // included in the TeX-like `height` used for calculation of
  8065. // vertical alignment. So texHeight = span.height < span.style.height.
  8066. if (delim.type === "small") {
  8067. // Get an SVG that is derived from glyph U+221A in font KaTeX-Main.
  8068. // 1000 unit normal glyph height.
  8069. viewBoxHeight = 1000 + 1000 * extraViniculum + vbPad;
  8070. if (height < 1.0) {
  8071. sizeMultiplier = 1.0; // mimic a \textfont radical
  8072. } else if (height < 1.4) {
  8073. sizeMultiplier = 0.7; // mimic a \scriptfont radical
  8074. }
  8075. spanHeight = (1.0 + extraViniculum + emPad) / sizeMultiplier;
  8076. texHeight = (1.00 + extraViniculum) / sizeMultiplier;
  8077. span = sqrtSvg("sqrtMain", spanHeight, viewBoxHeight, extraViniculum, options);
  8078. span.style.minWidth = "0.853em";
  8079. advanceWidth = 0.833 / sizeMultiplier; // from the font.
  8080. } else if (delim.type === "large") {
  8081. // These SVGs come from fonts: KaTeX_Size1, _Size2, etc.
  8082. viewBoxHeight = (1000 + vbPad) * sizeToMaxHeight[delim.size];
  8083. texHeight = (sizeToMaxHeight[delim.size] + extraViniculum) / sizeMultiplier;
  8084. spanHeight = (sizeToMaxHeight[delim.size] + extraViniculum + emPad) / sizeMultiplier;
  8085. span = sqrtSvg("sqrtSize" + delim.size, spanHeight, viewBoxHeight, extraViniculum, options);
  8086. span.style.minWidth = "1.02em";
  8087. advanceWidth = 1.0 / sizeMultiplier; // 1.0 from the font.
  8088. } else {
  8089. // Tall sqrt. In TeX, this would be stacked using multiple glyphs.
  8090. // We'll use a single SVG to accomplish the same thing.
  8091. spanHeight = height + extraViniculum + emPad;
  8092. texHeight = height + extraViniculum;
  8093. viewBoxHeight = Math.floor(1000 * height + extraViniculum) + vbPad;
  8094. span = sqrtSvg("sqrtTall", spanHeight, viewBoxHeight, extraViniculum, options);
  8095. span.style.minWidth = "0.742em";
  8096. advanceWidth = 1.056;
  8097. }
  8098. span.height = texHeight;
  8099. span.style.height = makeEm(spanHeight);
  8100. return {
  8101. span: span,
  8102. advanceWidth: advanceWidth,
  8103. // Calculate the actual line width.
  8104. // This actually should depend on the chosen font -- e.g. \boldmath
  8105. // should use the thicker surd symbols from e.g. KaTeX_Main-Bold, and
  8106. // have thicker rules.
  8107. ruleWidth: (options.fontMetrics().sqrtRuleThickness + extraViniculum) * sizeMultiplier
  8108. };
  8109. }; // There are three kinds of delimiters, delimiters that stack when they become
  8110. // too large
  8111. var stackLargeDelimiters = ["(", "\\lparen", ")", "\\rparen", "[", "\\lbrack", "]", "\\rbrack", "\\{", "\\lbrace", "\\}", "\\rbrace", "\\lfloor", "\\rfloor", "\u230A", "\u230B", "\\lceil", "\\rceil", "\u2308", "\u2309", "\\surd"]; // delimiters that always stack
  8112. var stackAlwaysDelimiters = ["\\uparrow", "\\downarrow", "\\updownarrow", "\\Uparrow", "\\Downarrow", "\\Updownarrow", "|", "\\|", "\\vert", "\\Vert", "\\lvert", "\\rvert", "\\lVert", "\\rVert", "\\lgroup", "\\rgroup", "\u27EE", "\u27EF", "\\lmoustache", "\\rmoustache", "\u23B0", "\u23B1"]; // and delimiters that never stack
  8113. var stackNeverDelimiters = ["<", ">", "\\langle", "\\rangle", "/", "\\backslash", "\\lt", "\\gt"]; // Metrics of the different sizes. Found by looking at TeX's output of
  8114. // $\bigl| // \Bigl| \biggl| \Biggl| \showlists$
  8115. // Used to create stacked delimiters of appropriate sizes in makeSizedDelim.
  8116. var sizeToMaxHeight = [0, 1.2, 1.8, 2.4, 3.0];
  8117. /**
  8118. * Used to create a delimiter of a specific size, where `size` is 1, 2, 3, or 4.
  8119. */
  8120. var makeSizedDelim = function makeSizedDelim(delim, size, options, mode, classes) {
  8121. // < and > turn into \langle and \rangle in delimiters
  8122. if (delim === "<" || delim === "\\lt" || delim === "\u27E8") {
  8123. delim = "\\langle";
  8124. } else if (delim === ">" || delim === "\\gt" || delim === "\u27E9") {
  8125. delim = "\\rangle";
  8126. } // Sized delimiters are never centered.
  8127. if (utils.contains(stackLargeDelimiters, delim) || utils.contains(stackNeverDelimiters, delim)) {
  8128. return makeLargeDelim(delim, size, false, options, mode, classes);
  8129. } else if (utils.contains(stackAlwaysDelimiters, delim)) {
  8130. return makeStackedDelim(delim, sizeToMaxHeight[size], false, options, mode, classes);
  8131. } else {
  8132. throw new src_ParseError("Illegal delimiter: '" + delim + "'");
  8133. }
  8134. };
  8135. /**
  8136. * There are three different sequences of delimiter sizes that the delimiters
  8137. * follow depending on the kind of delimiter. This is used when creating custom
  8138. * sized delimiters to decide whether to create a small, large, or stacked
  8139. * delimiter.
  8140. *
  8141. * In real TeX, these sequences aren't explicitly defined, but are instead
  8142. * defined inside the font metrics. Since there are only three sequences that
  8143. * are possible for the delimiters that TeX defines, it is easier to just encode
  8144. * them explicitly here.
  8145. */
  8146. // Delimiters that never stack try small delimiters and large delimiters only
  8147. var stackNeverDelimiterSequence = [{
  8148. type: "small",
  8149. style: src_Style.SCRIPTSCRIPT
  8150. }, {
  8151. type: "small",
  8152. style: src_Style.SCRIPT
  8153. }, {
  8154. type: "small",
  8155. style: src_Style.TEXT
  8156. }, {
  8157. type: "large",
  8158. size: 1
  8159. }, {
  8160. type: "large",
  8161. size: 2
  8162. }, {
  8163. type: "large",
  8164. size: 3
  8165. }, {
  8166. type: "large",
  8167. size: 4
  8168. }]; // Delimiters that always stack try the small delimiters first, then stack
  8169. var stackAlwaysDelimiterSequence = [{
  8170. type: "small",
  8171. style: src_Style.SCRIPTSCRIPT
  8172. }, {
  8173. type: "small",
  8174. style: src_Style.SCRIPT
  8175. }, {
  8176. type: "small",
  8177. style: src_Style.TEXT
  8178. }, {
  8179. type: "stack"
  8180. }]; // Delimiters that stack when large try the small and then large delimiters, and
  8181. // stack afterwards
  8182. var stackLargeDelimiterSequence = [{
  8183. type: "small",
  8184. style: src_Style.SCRIPTSCRIPT
  8185. }, {
  8186. type: "small",
  8187. style: src_Style.SCRIPT
  8188. }, {
  8189. type: "small",
  8190. style: src_Style.TEXT
  8191. }, {
  8192. type: "large",
  8193. size: 1
  8194. }, {
  8195. type: "large",
  8196. size: 2
  8197. }, {
  8198. type: "large",
  8199. size: 3
  8200. }, {
  8201. type: "large",
  8202. size: 4
  8203. }, {
  8204. type: "stack"
  8205. }];
  8206. /**
  8207. * Get the font used in a delimiter based on what kind of delimiter it is.
  8208. * TODO(#963) Use more specific font family return type once that is introduced.
  8209. */
  8210. var delimTypeToFont = function delimTypeToFont(type) {
  8211. if (type.type === "small") {
  8212. return "Main-Regular";
  8213. } else if (type.type === "large") {
  8214. return "Size" + type.size + "-Regular";
  8215. } else if (type.type === "stack") {
  8216. return "Size4-Regular";
  8217. } else {
  8218. throw new Error("Add support for delim type '" + type.type + "' here.");
  8219. }
  8220. };
  8221. /**
  8222. * Traverse a sequence of types of delimiters to decide what kind of delimiter
  8223. * should be used to create a delimiter of the given height+depth.
  8224. */
  8225. var traverseSequence = function traverseSequence(delim, height, sequence, options) {
  8226. // Here, we choose the index we should start at in the sequences. In smaller
  8227. // sizes (which correspond to larger numbers in style.size) we start earlier
  8228. // in the sequence. Thus, scriptscript starts at index 3-3=0, script starts
  8229. // at index 3-2=1, text starts at 3-1=2, and display starts at min(2,3-0)=2
  8230. var start = Math.min(2, 3 - options.style.size);
  8231. for (var i = start; i < sequence.length; i++) {
  8232. if (sequence[i].type === "stack") {
  8233. // This is always the last delimiter, so we just break the loop now.
  8234. break;
  8235. }
  8236. var metrics = getMetrics(delim, delimTypeToFont(sequence[i]), "math");
  8237. var heightDepth = metrics.height + metrics.depth; // Small delimiters are scaled down versions of the same font, so we
  8238. // account for the style change size.
  8239. if (sequence[i].type === "small") {
  8240. var newOptions = options.havingBaseStyle(sequence[i].style);
  8241. heightDepth *= newOptions.sizeMultiplier;
  8242. } // Check if the delimiter at this size works for the given height.
  8243. if (heightDepth > height) {
  8244. return sequence[i];
  8245. }
  8246. } // If we reached the end of the sequence, return the last sequence element.
  8247. return sequence[sequence.length - 1];
  8248. };
  8249. /**
  8250. * Make a delimiter of a given height+depth, with optional centering. Here, we
  8251. * traverse the sequences, and create a delimiter that the sequence tells us to.
  8252. */
  8253. var makeCustomSizedDelim = function makeCustomSizedDelim(delim, height, center, options, mode, classes) {
  8254. if (delim === "<" || delim === "\\lt" || delim === "\u27E8") {
  8255. delim = "\\langle";
  8256. } else if (delim === ">" || delim === "\\gt" || delim === "\u27E9") {
  8257. delim = "\\rangle";
  8258. } // Decide what sequence to use
  8259. var sequence;
  8260. if (utils.contains(stackNeverDelimiters, delim)) {
  8261. sequence = stackNeverDelimiterSequence;
  8262. } else if (utils.contains(stackLargeDelimiters, delim)) {
  8263. sequence = stackLargeDelimiterSequence;
  8264. } else {
  8265. sequence = stackAlwaysDelimiterSequence;
  8266. } // Look through the sequence
  8267. var delimType = traverseSequence(delim, height, sequence, options); // Get the delimiter from font glyphs.
  8268. // Depending on the sequence element we decided on, call the
  8269. // appropriate function.
  8270. if (delimType.type === "small") {
  8271. return makeSmallDelim(delim, delimType.style, center, options, mode, classes);
  8272. } else if (delimType.type === "large") {
  8273. return makeLargeDelim(delim, delimType.size, center, options, mode, classes);
  8274. } else
  8275. /* if (delimType.type === "stack") */
  8276. {
  8277. return makeStackedDelim(delim, height, center, options, mode, classes);
  8278. }
  8279. };
  8280. /**
  8281. * Make a delimiter for use with `\left` and `\right`, given a height and depth
  8282. * of an expression that the delimiters surround.
  8283. */
  8284. var makeLeftRightDelim = function makeLeftRightDelim(delim, height, depth, options, mode, classes) {
  8285. // We always center \left/\right delimiters, so the axis is always shifted
  8286. var axisHeight = options.fontMetrics().axisHeight * options.sizeMultiplier; // Taken from TeX source, tex.web, function make_left_right
  8287. var delimiterFactor = 901;
  8288. var delimiterExtend = 5.0 / options.fontMetrics().ptPerEm;
  8289. var maxDistFromAxis = Math.max(height - axisHeight, depth + axisHeight);
  8290. var totalHeight = Math.max( // In real TeX, calculations are done using integral values which are
  8291. // 65536 per pt, or 655360 per em. So, the division here truncates in
  8292. // TeX but doesn't here, producing different results. If we wanted to
  8293. // exactly match TeX's calculation, we could do
  8294. // Math.floor(655360 * maxDistFromAxis / 500) *
  8295. // delimiterFactor / 655360
  8296. // (To see the difference, compare
  8297. // x^{x^{\left(\rule{0.1em}{0.68em}\right)}}
  8298. // in TeX and KaTeX)
  8299. maxDistFromAxis / 500 * delimiterFactor, 2 * maxDistFromAxis - delimiterExtend); // Finally, we defer to `makeCustomSizedDelim` with our calculated total
  8300. // height
  8301. return makeCustomSizedDelim(delim, totalHeight, true, options, mode, classes);
  8302. };
  8303. /* harmony default export */ var delimiter = ({
  8304. sqrtImage: makeSqrtImage,
  8305. sizedDelim: makeSizedDelim,
  8306. sizeToMaxHeight: sizeToMaxHeight,
  8307. customSizedDelim: makeCustomSizedDelim,
  8308. leftRightDelim: makeLeftRightDelim
  8309. });
  8310. ;// CONCATENATED MODULE: ./src/functions/delimsizing.js
  8311. // Extra data needed for the delimiter handler down below
  8312. var delimiterSizes = {
  8313. "\\bigl": {
  8314. mclass: "mopen",
  8315. size: 1
  8316. },
  8317. "\\Bigl": {
  8318. mclass: "mopen",
  8319. size: 2
  8320. },
  8321. "\\biggl": {
  8322. mclass: "mopen",
  8323. size: 3
  8324. },
  8325. "\\Biggl": {
  8326. mclass: "mopen",
  8327. size: 4
  8328. },
  8329. "\\bigr": {
  8330. mclass: "mclose",
  8331. size: 1
  8332. },
  8333. "\\Bigr": {
  8334. mclass: "mclose",
  8335. size: 2
  8336. },
  8337. "\\biggr": {
  8338. mclass: "mclose",
  8339. size: 3
  8340. },
  8341. "\\Biggr": {
  8342. mclass: "mclose",
  8343. size: 4
  8344. },
  8345. "\\bigm": {
  8346. mclass: "mrel",
  8347. size: 1
  8348. },
  8349. "\\Bigm": {
  8350. mclass: "mrel",
  8351. size: 2
  8352. },
  8353. "\\biggm": {
  8354. mclass: "mrel",
  8355. size: 3
  8356. },
  8357. "\\Biggm": {
  8358. mclass: "mrel",
  8359. size: 4
  8360. },
  8361. "\\big": {
  8362. mclass: "mord",
  8363. size: 1
  8364. },
  8365. "\\Big": {
  8366. mclass: "mord",
  8367. size: 2
  8368. },
  8369. "\\bigg": {
  8370. mclass: "mord",
  8371. size: 3
  8372. },
  8373. "\\Bigg": {
  8374. mclass: "mord",
  8375. size: 4
  8376. }
  8377. };
  8378. var delimiters = ["(", "\\lparen", ")", "\\rparen", "[", "\\lbrack", "]", "\\rbrack", "\\{", "\\lbrace", "\\}", "\\rbrace", "\\lfloor", "\\rfloor", "\u230A", "\u230B", "\\lceil", "\\rceil", "\u2308", "\u2309", "<", ">", "\\langle", "\u27E8", "\\rangle", "\u27E9", "\\lt", "\\gt", "\\lvert", "\\rvert", "\\lVert", "\\rVert", "\\lgroup", "\\rgroup", "\u27EE", "\u27EF", "\\lmoustache", "\\rmoustache", "\u23B0", "\u23B1", "/", "\\backslash", "|", "\\vert", "\\|", "\\Vert", "\\uparrow", "\\Uparrow", "\\downarrow", "\\Downarrow", "\\updownarrow", "\\Updownarrow", "."];
  8379. // Delimiter functions
  8380. function checkDelimiter(delim, context) {
  8381. var symDelim = checkSymbolNodeType(delim);
  8382. if (symDelim && utils.contains(delimiters, symDelim.text)) {
  8383. return symDelim;
  8384. } else if (symDelim) {
  8385. throw new src_ParseError("Invalid delimiter '" + symDelim.text + "' after '" + context.funcName + "'", delim);
  8386. } else {
  8387. throw new src_ParseError("Invalid delimiter type '" + delim.type + "'", delim);
  8388. }
  8389. }
  8390. defineFunction({
  8391. type: "delimsizing",
  8392. names: ["\\bigl", "\\Bigl", "\\biggl", "\\Biggl", "\\bigr", "\\Bigr", "\\biggr", "\\Biggr", "\\bigm", "\\Bigm", "\\biggm", "\\Biggm", "\\big", "\\Big", "\\bigg", "\\Bigg"],
  8393. props: {
  8394. numArgs: 1,
  8395. argTypes: ["primitive"]
  8396. },
  8397. handler: function handler(context, args) {
  8398. var delim = checkDelimiter(args[0], context);
  8399. return {
  8400. type: "delimsizing",
  8401. mode: context.parser.mode,
  8402. size: delimiterSizes[context.funcName].size,
  8403. mclass: delimiterSizes[context.funcName].mclass,
  8404. delim: delim.text
  8405. };
  8406. },
  8407. htmlBuilder: function htmlBuilder(group, options) {
  8408. if (group.delim === ".") {
  8409. // Empty delimiters still count as elements, even though they don't
  8410. // show anything.
  8411. return buildCommon.makeSpan([group.mclass]);
  8412. } // Use delimiter.sizedDelim to generate the delimiter.
  8413. return delimiter.sizedDelim(group.delim, group.size, options, group.mode, [group.mclass]);
  8414. },
  8415. mathmlBuilder: function mathmlBuilder(group) {
  8416. var children = [];
  8417. if (group.delim !== ".") {
  8418. children.push(makeText(group.delim, group.mode));
  8419. }
  8420. var node = new mathMLTree.MathNode("mo", children);
  8421. if (group.mclass === "mopen" || group.mclass === "mclose") {
  8422. // Only some of the delimsizing functions act as fences, and they
  8423. // return "mopen" or "mclose" mclass.
  8424. node.setAttribute("fence", "true");
  8425. } else {
  8426. // Explicitly disable fencing if it's not a fence, to override the
  8427. // defaults.
  8428. node.setAttribute("fence", "false");
  8429. }
  8430. node.setAttribute("stretchy", "true");
  8431. var size = makeEm(delimiter.sizeToMaxHeight[group.size]);
  8432. node.setAttribute("minsize", size);
  8433. node.setAttribute("maxsize", size);
  8434. return node;
  8435. }
  8436. });
  8437. function assertParsed(group) {
  8438. if (!group.body) {
  8439. throw new Error("Bug: The leftright ParseNode wasn't fully parsed.");
  8440. }
  8441. }
  8442. defineFunction({
  8443. type: "leftright-right",
  8444. names: ["\\right"],
  8445. props: {
  8446. numArgs: 1,
  8447. primitive: true
  8448. },
  8449. handler: function handler(context, args) {
  8450. // \left case below triggers parsing of \right in
  8451. // `const right = parser.parseFunction();`
  8452. // uses this return value.
  8453. var color = context.parser.gullet.macros.get("\\current@color");
  8454. if (color && typeof color !== "string") {
  8455. throw new src_ParseError("\\current@color set to non-string in \\right");
  8456. }
  8457. return {
  8458. type: "leftright-right",
  8459. mode: context.parser.mode,
  8460. delim: checkDelimiter(args[0], context).text,
  8461. color: color // undefined if not set via \color
  8462. };
  8463. }
  8464. });
  8465. defineFunction({
  8466. type: "leftright",
  8467. names: ["\\left"],
  8468. props: {
  8469. numArgs: 1,
  8470. primitive: true
  8471. },
  8472. handler: function handler(context, args) {
  8473. var delim = checkDelimiter(args[0], context);
  8474. var parser = context.parser; // Parse out the implicit body
  8475. ++parser.leftrightDepth; // parseExpression stops before '\\right'
  8476. var body = parser.parseExpression(false);
  8477. --parser.leftrightDepth; // Check the next token
  8478. parser.expect("\\right", false);
  8479. var right = assertNodeType(parser.parseFunction(), "leftright-right");
  8480. return {
  8481. type: "leftright",
  8482. mode: parser.mode,
  8483. body: body,
  8484. left: delim.text,
  8485. right: right.delim,
  8486. rightColor: right.color
  8487. };
  8488. },
  8489. htmlBuilder: function htmlBuilder(group, options) {
  8490. assertParsed(group); // Build the inner expression
  8491. var inner = buildExpression(group.body, options, true, ["mopen", "mclose"]);
  8492. var innerHeight = 0;
  8493. var innerDepth = 0;
  8494. var hadMiddle = false; // Calculate its height and depth
  8495. for (var i = 0; i < inner.length; i++) {
  8496. // Property `isMiddle` not defined on `span`. See comment in
  8497. // "middle"'s htmlBuilder.
  8498. // $FlowFixMe
  8499. if (inner[i].isMiddle) {
  8500. hadMiddle = true;
  8501. } else {
  8502. innerHeight = Math.max(inner[i].height, innerHeight);
  8503. innerDepth = Math.max(inner[i].depth, innerDepth);
  8504. }
  8505. } // The size of delimiters is the same, regardless of what style we are
  8506. // in. Thus, to correctly calculate the size of delimiter we need around
  8507. // a group, we scale down the inner size based on the size.
  8508. innerHeight *= options.sizeMultiplier;
  8509. innerDepth *= options.sizeMultiplier;
  8510. var leftDelim;
  8511. if (group.left === ".") {
  8512. // Empty delimiters in \left and \right make null delimiter spaces.
  8513. leftDelim = makeNullDelimiter(options, ["mopen"]);
  8514. } else {
  8515. // Otherwise, use leftRightDelim to generate the correct sized
  8516. // delimiter.
  8517. leftDelim = delimiter.leftRightDelim(group.left, innerHeight, innerDepth, options, group.mode, ["mopen"]);
  8518. } // Add it to the beginning of the expression
  8519. inner.unshift(leftDelim); // Handle middle delimiters
  8520. if (hadMiddle) {
  8521. for (var _i = 1; _i < inner.length; _i++) {
  8522. var middleDelim = inner[_i]; // Property `isMiddle` not defined on `span`. See comment in
  8523. // "middle"'s htmlBuilder.
  8524. // $FlowFixMe
  8525. var isMiddle = middleDelim.isMiddle;
  8526. if (isMiddle) {
  8527. // Apply the options that were active when \middle was called
  8528. inner[_i] = delimiter.leftRightDelim(isMiddle.delim, innerHeight, innerDepth, isMiddle.options, group.mode, []);
  8529. }
  8530. }
  8531. }
  8532. var rightDelim; // Same for the right delimiter, but using color specified by \color
  8533. if (group.right === ".") {
  8534. rightDelim = makeNullDelimiter(options, ["mclose"]);
  8535. } else {
  8536. var colorOptions = group.rightColor ? options.withColor(group.rightColor) : options;
  8537. rightDelim = delimiter.leftRightDelim(group.right, innerHeight, innerDepth, colorOptions, group.mode, ["mclose"]);
  8538. } // Add it to the end of the expression.
  8539. inner.push(rightDelim);
  8540. return buildCommon.makeSpan(["minner"], inner, options);
  8541. },
  8542. mathmlBuilder: function mathmlBuilder(group, options) {
  8543. assertParsed(group);
  8544. var inner = buildMathML_buildExpression(group.body, options);
  8545. if (group.left !== ".") {
  8546. var leftNode = new mathMLTree.MathNode("mo", [makeText(group.left, group.mode)]);
  8547. leftNode.setAttribute("fence", "true");
  8548. inner.unshift(leftNode);
  8549. }
  8550. if (group.right !== ".") {
  8551. var rightNode = new mathMLTree.MathNode("mo", [makeText(group.right, group.mode)]);
  8552. rightNode.setAttribute("fence", "true");
  8553. if (group.rightColor) {
  8554. rightNode.setAttribute("mathcolor", group.rightColor);
  8555. }
  8556. inner.push(rightNode);
  8557. }
  8558. return makeRow(inner);
  8559. }
  8560. });
  8561. defineFunction({
  8562. type: "middle",
  8563. names: ["\\middle"],
  8564. props: {
  8565. numArgs: 1,
  8566. primitive: true
  8567. },
  8568. handler: function handler(context, args) {
  8569. var delim = checkDelimiter(args[0], context);
  8570. if (!context.parser.leftrightDepth) {
  8571. throw new src_ParseError("\\middle without preceding \\left", delim);
  8572. }
  8573. return {
  8574. type: "middle",
  8575. mode: context.parser.mode,
  8576. delim: delim.text
  8577. };
  8578. },
  8579. htmlBuilder: function htmlBuilder(group, options) {
  8580. var middleDelim;
  8581. if (group.delim === ".") {
  8582. middleDelim = makeNullDelimiter(options, []);
  8583. } else {
  8584. middleDelim = delimiter.sizedDelim(group.delim, 1, options, group.mode, []);
  8585. var isMiddle = {
  8586. delim: group.delim,
  8587. options: options
  8588. }; // Property `isMiddle` not defined on `span`. It is only used in
  8589. // this file above.
  8590. // TODO: Fix this violation of the `span` type and possibly rename
  8591. // things since `isMiddle` sounds like a boolean, but is a struct.
  8592. // $FlowFixMe
  8593. middleDelim.isMiddle = isMiddle;
  8594. }
  8595. return middleDelim;
  8596. },
  8597. mathmlBuilder: function mathmlBuilder(group, options) {
  8598. // A Firefox \middle will strech a character vertically only if it
  8599. // is in the fence part of the operator dictionary at:
  8600. // https://www.w3.org/TR/MathML3/appendixc.html.
  8601. // So we need to avoid U+2223 and use plain "|" instead.
  8602. var textNode = group.delim === "\\vert" || group.delim === "|" ? makeText("|", "text") : makeText(group.delim, group.mode);
  8603. var middleNode = new mathMLTree.MathNode("mo", [textNode]);
  8604. middleNode.setAttribute("fence", "true"); // MathML gives 5/18em spacing to each <mo> element.
  8605. // \middle should get delimiter spacing instead.
  8606. middleNode.setAttribute("lspace", "0.05em");
  8607. middleNode.setAttribute("rspace", "0.05em");
  8608. return middleNode;
  8609. }
  8610. });
  8611. ;// CONCATENATED MODULE: ./src/functions/enclose.js
  8612. var enclose_htmlBuilder = function htmlBuilder(group, options) {
  8613. // \cancel, \bcancel, \xcancel, \sout, \fbox, \colorbox, \fcolorbox, \phase
  8614. // Some groups can return document fragments. Handle those by wrapping
  8615. // them in a span.
  8616. var inner = buildCommon.wrapFragment(buildGroup(group.body, options), options);
  8617. var label = group.label.substr(1);
  8618. var scale = options.sizeMultiplier;
  8619. var img;
  8620. var imgShift = 0; // In the LaTeX cancel package, line geometry is slightly different
  8621. // depending on whether the subject is wider than it is tall, or vice versa.
  8622. // We don't know the width of a group, so as a proxy, we test if
  8623. // the subject is a single character. This captures most of the
  8624. // subjects that should get the "tall" treatment.
  8625. var isSingleChar = utils.isCharacterBox(group.body);
  8626. if (label === "sout") {
  8627. img = buildCommon.makeSpan(["stretchy", "sout"]);
  8628. img.height = options.fontMetrics().defaultRuleThickness / scale;
  8629. imgShift = -0.5 * options.fontMetrics().xHeight;
  8630. } else if (label === "phase") {
  8631. // Set a couple of dimensions from the steinmetz package.
  8632. var lineWeight = calculateSize({
  8633. number: 0.6,
  8634. unit: "pt"
  8635. }, options);
  8636. var clearance = calculateSize({
  8637. number: 0.35,
  8638. unit: "ex"
  8639. }, options); // Prevent size changes like \Huge from affecting line thickness
  8640. var newOptions = options.havingBaseSizing();
  8641. scale = scale / newOptions.sizeMultiplier;
  8642. var angleHeight = inner.height + inner.depth + lineWeight + clearance; // Reserve a left pad for the angle.
  8643. inner.style.paddingLeft = makeEm(angleHeight / 2 + lineWeight); // Create an SVG
  8644. var viewBoxHeight = Math.floor(1000 * angleHeight * scale);
  8645. var path = phasePath(viewBoxHeight);
  8646. var svgNode = new SvgNode([new PathNode("phase", path)], {
  8647. "width": "400em",
  8648. "height": makeEm(viewBoxHeight / 1000),
  8649. "viewBox": "0 0 400000 " + viewBoxHeight,
  8650. "preserveAspectRatio": "xMinYMin slice"
  8651. }); // Wrap it in a span with overflow: hidden.
  8652. img = buildCommon.makeSvgSpan(["hide-tail"], [svgNode], options);
  8653. img.style.height = makeEm(angleHeight);
  8654. imgShift = inner.depth + lineWeight + clearance;
  8655. } else {
  8656. // Add horizontal padding
  8657. if (/cancel/.test(label)) {
  8658. if (!isSingleChar) {
  8659. inner.classes.push("cancel-pad");
  8660. }
  8661. } else if (label === "angl") {
  8662. inner.classes.push("anglpad");
  8663. } else {
  8664. inner.classes.push("boxpad");
  8665. } // Add vertical padding
  8666. var topPad = 0;
  8667. var bottomPad = 0;
  8668. var ruleThickness = 0; // ref: cancel package: \advance\totalheight2\p@ % "+2"
  8669. if (/box/.test(label)) {
  8670. ruleThickness = Math.max(options.fontMetrics().fboxrule, // default
  8671. options.minRuleThickness // User override.
  8672. );
  8673. topPad = options.fontMetrics().fboxsep + (label === "colorbox" ? 0 : ruleThickness);
  8674. bottomPad = topPad;
  8675. } else if (label === "angl") {
  8676. ruleThickness = Math.max(options.fontMetrics().defaultRuleThickness, options.minRuleThickness);
  8677. topPad = 4 * ruleThickness; // gap = 3 × line, plus the line itself.
  8678. bottomPad = Math.max(0, 0.25 - inner.depth);
  8679. } else {
  8680. topPad = isSingleChar ? 0.2 : 0;
  8681. bottomPad = topPad;
  8682. }
  8683. img = stretchy.encloseSpan(inner, label, topPad, bottomPad, options);
  8684. if (/fbox|boxed|fcolorbox/.test(label)) {
  8685. img.style.borderStyle = "solid";
  8686. img.style.borderWidth = makeEm(ruleThickness);
  8687. } else if (label === "angl" && ruleThickness !== 0.049) {
  8688. img.style.borderTopWidth = makeEm(ruleThickness);
  8689. img.style.borderRightWidth = makeEm(ruleThickness);
  8690. }
  8691. imgShift = inner.depth + bottomPad;
  8692. if (group.backgroundColor) {
  8693. img.style.backgroundColor = group.backgroundColor;
  8694. if (group.borderColor) {
  8695. img.style.borderColor = group.borderColor;
  8696. }
  8697. }
  8698. }
  8699. var vlist;
  8700. if (group.backgroundColor) {
  8701. vlist = buildCommon.makeVList({
  8702. positionType: "individualShift",
  8703. children: [// Put the color background behind inner;
  8704. {
  8705. type: "elem",
  8706. elem: img,
  8707. shift: imgShift
  8708. }, {
  8709. type: "elem",
  8710. elem: inner,
  8711. shift: 0
  8712. }]
  8713. }, options);
  8714. } else {
  8715. var classes = /cancel|phase/.test(label) ? ["svg-align"] : [];
  8716. vlist = buildCommon.makeVList({
  8717. positionType: "individualShift",
  8718. children: [// Write the \cancel stroke on top of inner.
  8719. {
  8720. type: "elem",
  8721. elem: inner,
  8722. shift: 0
  8723. }, {
  8724. type: "elem",
  8725. elem: img,
  8726. shift: imgShift,
  8727. wrapperClasses: classes
  8728. }]
  8729. }, options);
  8730. }
  8731. if (/cancel/.test(label)) {
  8732. // The cancel package documentation says that cancel lines add their height
  8733. // to the expression, but tests show that isn't how it actually works.
  8734. vlist.height = inner.height;
  8735. vlist.depth = inner.depth;
  8736. }
  8737. if (/cancel/.test(label) && !isSingleChar) {
  8738. // cancel does not create horiz space for its line extension.
  8739. return buildCommon.makeSpan(["mord", "cancel-lap"], [vlist], options);
  8740. } else {
  8741. return buildCommon.makeSpan(["mord"], [vlist], options);
  8742. }
  8743. };
  8744. var enclose_mathmlBuilder = function mathmlBuilder(group, options) {
  8745. var fboxsep = 0;
  8746. var node = new mathMLTree.MathNode(group.label.indexOf("colorbox") > -1 ? "mpadded" : "menclose", [buildMathML_buildGroup(group.body, options)]);
  8747. switch (group.label) {
  8748. case "\\cancel":
  8749. node.setAttribute("notation", "updiagonalstrike");
  8750. break;
  8751. case "\\bcancel":
  8752. node.setAttribute("notation", "downdiagonalstrike");
  8753. break;
  8754. case "\\phase":
  8755. node.setAttribute("notation", "phasorangle");
  8756. break;
  8757. case "\\sout":
  8758. node.setAttribute("notation", "horizontalstrike");
  8759. break;
  8760. case "\\fbox":
  8761. node.setAttribute("notation", "box");
  8762. break;
  8763. case "\\angl":
  8764. node.setAttribute("notation", "actuarial");
  8765. break;
  8766. case "\\fcolorbox":
  8767. case "\\colorbox":
  8768. // <menclose> doesn't have a good notation option. So use <mpadded>
  8769. // instead. Set some attributes that come included with <menclose>.
  8770. fboxsep = options.fontMetrics().fboxsep * options.fontMetrics().ptPerEm;
  8771. node.setAttribute("width", "+" + 2 * fboxsep + "pt");
  8772. node.setAttribute("height", "+" + 2 * fboxsep + "pt");
  8773. node.setAttribute("lspace", fboxsep + "pt"); //
  8774. node.setAttribute("voffset", fboxsep + "pt");
  8775. if (group.label === "\\fcolorbox") {
  8776. var thk = Math.max(options.fontMetrics().fboxrule, // default
  8777. options.minRuleThickness // user override
  8778. );
  8779. node.setAttribute("style", "border: " + thk + "em solid " + String(group.borderColor));
  8780. }
  8781. break;
  8782. case "\\xcancel":
  8783. node.setAttribute("notation", "updiagonalstrike downdiagonalstrike");
  8784. break;
  8785. }
  8786. if (group.backgroundColor) {
  8787. node.setAttribute("mathbackground", group.backgroundColor);
  8788. }
  8789. return node;
  8790. };
  8791. defineFunction({
  8792. type: "enclose",
  8793. names: ["\\colorbox"],
  8794. props: {
  8795. numArgs: 2,
  8796. allowedInText: true,
  8797. argTypes: ["color", "text"]
  8798. },
  8799. handler: function handler(_ref, args, optArgs) {
  8800. var parser = _ref.parser,
  8801. funcName = _ref.funcName;
  8802. var color = assertNodeType(args[0], "color-token").color;
  8803. var body = args[1];
  8804. return {
  8805. type: "enclose",
  8806. mode: parser.mode,
  8807. label: funcName,
  8808. backgroundColor: color,
  8809. body: body
  8810. };
  8811. },
  8812. htmlBuilder: enclose_htmlBuilder,
  8813. mathmlBuilder: enclose_mathmlBuilder
  8814. });
  8815. defineFunction({
  8816. type: "enclose",
  8817. names: ["\\fcolorbox"],
  8818. props: {
  8819. numArgs: 3,
  8820. allowedInText: true,
  8821. argTypes: ["color", "color", "text"]
  8822. },
  8823. handler: function handler(_ref2, args, optArgs) {
  8824. var parser = _ref2.parser,
  8825. funcName = _ref2.funcName;
  8826. var borderColor = assertNodeType(args[0], "color-token").color;
  8827. var backgroundColor = assertNodeType(args[1], "color-token").color;
  8828. var body = args[2];
  8829. return {
  8830. type: "enclose",
  8831. mode: parser.mode,
  8832. label: funcName,
  8833. backgroundColor: backgroundColor,
  8834. borderColor: borderColor,
  8835. body: body
  8836. };
  8837. },
  8838. htmlBuilder: enclose_htmlBuilder,
  8839. mathmlBuilder: enclose_mathmlBuilder
  8840. });
  8841. defineFunction({
  8842. type: "enclose",
  8843. names: ["\\fbox"],
  8844. props: {
  8845. numArgs: 1,
  8846. argTypes: ["hbox"],
  8847. allowedInText: true
  8848. },
  8849. handler: function handler(_ref3, args) {
  8850. var parser = _ref3.parser;
  8851. return {
  8852. type: "enclose",
  8853. mode: parser.mode,
  8854. label: "\\fbox",
  8855. body: args[0]
  8856. };
  8857. }
  8858. });
  8859. defineFunction({
  8860. type: "enclose",
  8861. names: ["\\cancel", "\\bcancel", "\\xcancel", "\\sout", "\\phase"],
  8862. props: {
  8863. numArgs: 1
  8864. },
  8865. handler: function handler(_ref4, args) {
  8866. var parser = _ref4.parser,
  8867. funcName = _ref4.funcName;
  8868. var body = args[0];
  8869. return {
  8870. type: "enclose",
  8871. mode: parser.mode,
  8872. label: funcName,
  8873. body: body
  8874. };
  8875. },
  8876. htmlBuilder: enclose_htmlBuilder,
  8877. mathmlBuilder: enclose_mathmlBuilder
  8878. });
  8879. defineFunction({
  8880. type: "enclose",
  8881. names: ["\\angl"],
  8882. props: {
  8883. numArgs: 1,
  8884. argTypes: ["hbox"],
  8885. allowedInText: false
  8886. },
  8887. handler: function handler(_ref5, args) {
  8888. var parser = _ref5.parser;
  8889. return {
  8890. type: "enclose",
  8891. mode: parser.mode,
  8892. label: "\\angl",
  8893. body: args[0]
  8894. };
  8895. }
  8896. });
  8897. ;// CONCATENATED MODULE: ./src/defineEnvironment.js
  8898. /**
  8899. * All registered environments.
  8900. * `environments.js` exports this same dictionary again and makes it public.
  8901. * `Parser.js` requires this dictionary via `environments.js`.
  8902. */
  8903. var _environments = {};
  8904. function defineEnvironment(_ref) {
  8905. var type = _ref.type,
  8906. names = _ref.names,
  8907. props = _ref.props,
  8908. handler = _ref.handler,
  8909. htmlBuilder = _ref.htmlBuilder,
  8910. mathmlBuilder = _ref.mathmlBuilder;
  8911. // Set default values of environments.
  8912. var data = {
  8913. type: type,
  8914. numArgs: props.numArgs || 0,
  8915. allowedInText: false,
  8916. numOptionalArgs: 0,
  8917. handler: handler
  8918. };
  8919. for (var i = 0; i < names.length; ++i) {
  8920. // TODO: The value type of _environments should be a type union of all
  8921. // possible `EnvSpec<>` possibilities instead of `EnvSpec<*>`, which is
  8922. // an existential type.
  8923. _environments[names[i]] = data;
  8924. }
  8925. if (htmlBuilder) {
  8926. _htmlGroupBuilders[type] = htmlBuilder;
  8927. }
  8928. if (mathmlBuilder) {
  8929. _mathmlGroupBuilders[type] = mathmlBuilder;
  8930. }
  8931. }
  8932. ;// CONCATENATED MODULE: ./src/defineMacro.js
  8933. /**
  8934. * All registered global/built-in macros.
  8935. * `macros.js` exports this same dictionary again and makes it public.
  8936. * `Parser.js` requires this dictionary via `macros.js`.
  8937. */
  8938. var _macros = {}; // This function might one day accept an additional argument and do more things.
  8939. function defineMacro(name, body) {
  8940. _macros[name] = body;
  8941. }
  8942. ;// CONCATENATED MODULE: ./src/SourceLocation.js
  8943. /**
  8944. * Lexing or parsing positional information for error reporting.
  8945. * This object is immutable.
  8946. */
  8947. var SourceLocation = /*#__PURE__*/function () {
  8948. // The + prefix indicates that these fields aren't writeable
  8949. // Lexer holding the input string.
  8950. // Start offset, zero-based inclusive.
  8951. // End offset, zero-based exclusive.
  8952. function SourceLocation(lexer, start, end) {
  8953. this.lexer = void 0;
  8954. this.start = void 0;
  8955. this.end = void 0;
  8956. this.lexer = lexer;
  8957. this.start = start;
  8958. this.end = end;
  8959. }
  8960. /**
  8961. * Merges two `SourceLocation`s from location providers, given they are
  8962. * provided in order of appearance.
  8963. * - Returns the first one's location if only the first is provided.
  8964. * - Returns a merged range of the first and the last if both are provided
  8965. * and their lexers match.
  8966. * - Otherwise, returns null.
  8967. */
  8968. SourceLocation.range = function range(first, second) {
  8969. if (!second) {
  8970. return first && first.loc;
  8971. } else if (!first || !first.loc || !second.loc || first.loc.lexer !== second.loc.lexer) {
  8972. return null;
  8973. } else {
  8974. return new SourceLocation(first.loc.lexer, first.loc.start, second.loc.end);
  8975. }
  8976. };
  8977. return SourceLocation;
  8978. }();
  8979. ;// CONCATENATED MODULE: ./src/Token.js
  8980. /**
  8981. * Interface required to break circular dependency between Token, Lexer, and
  8982. * ParseError.
  8983. */
  8984. /**
  8985. * The resulting token returned from `lex`.
  8986. *
  8987. * It consists of the token text plus some position information.
  8988. * The position information is essentially a range in an input string,
  8989. * but instead of referencing the bare input string, we refer to the lexer.
  8990. * That way it is possible to attach extra metadata to the input string,
  8991. * like for example a file name or similar.
  8992. *
  8993. * The position information is optional, so it is OK to construct synthetic
  8994. * tokens if appropriate. Not providing available position information may
  8995. * lead to degraded error reporting, though.
  8996. */
  8997. var Token = /*#__PURE__*/function () {
  8998. // don't expand the token
  8999. // used in \noexpand
  9000. function Token(text, // the text of this token
  9001. loc) {
  9002. this.text = void 0;
  9003. this.loc = void 0;
  9004. this.noexpand = void 0;
  9005. this.treatAsRelax = void 0;
  9006. this.text = text;
  9007. this.loc = loc;
  9008. }
  9009. /**
  9010. * Given a pair of tokens (this and endToken), compute a `Token` encompassing
  9011. * the whole input range enclosed by these two.
  9012. */
  9013. var _proto = Token.prototype;
  9014. _proto.range = function range(endToken, // last token of the range, inclusive
  9015. text // the text of the newly constructed token
  9016. ) {
  9017. return new Token(text, SourceLocation.range(this, endToken));
  9018. };
  9019. return Token;
  9020. }();
  9021. ;// CONCATENATED MODULE: ./src/environments/array.js
  9022. // Helper functions
  9023. function getHLines(parser) {
  9024. // Return an array. The array length = number of hlines.
  9025. // Each element in the array tells if the line is dashed.
  9026. var hlineInfo = [];
  9027. parser.consumeSpaces();
  9028. var nxt = parser.fetch().text;
  9029. while (nxt === "\\hline" || nxt === "\\hdashline") {
  9030. parser.consume();
  9031. hlineInfo.push(nxt === "\\hdashline");
  9032. parser.consumeSpaces();
  9033. nxt = parser.fetch().text;
  9034. }
  9035. return hlineInfo;
  9036. }
  9037. var validateAmsEnvironmentContext = function validateAmsEnvironmentContext(context) {
  9038. var settings = context.parser.settings;
  9039. if (!settings.displayMode) {
  9040. throw new src_ParseError("{" + context.envName + "} can be used only in" + " display mode.");
  9041. }
  9042. }; // autoTag (an argument to parseArray) can be one of three values:
  9043. // * undefined: Regular (not-top-level) array; no tags on each row
  9044. // * true: Automatic equation numbering, overridable by \tag
  9045. // * false: Tags allowed on each row, but no automatic numbering
  9046. // This function *doesn't* work with the "split" environment name.
  9047. function getAutoTag(name) {
  9048. if (name.indexOf("ed") === -1) {
  9049. return name.indexOf("*") === -1;
  9050. } // return undefined;
  9051. }
  9052. /**
  9053. * Parse the body of the environment, with rows delimited by \\ and
  9054. * columns delimited by &, and create a nested list in row-major order
  9055. * with one group per cell. If given an optional argument style
  9056. * ("text", "display", etc.), then each cell is cast into that style.
  9057. */
  9058. function parseArray(parser, _ref, style) {
  9059. var hskipBeforeAndAfter = _ref.hskipBeforeAndAfter,
  9060. addJot = _ref.addJot,
  9061. cols = _ref.cols,
  9062. arraystretch = _ref.arraystretch,
  9063. colSeparationType = _ref.colSeparationType,
  9064. autoTag = _ref.autoTag,
  9065. singleRow = _ref.singleRow,
  9066. emptySingleRow = _ref.emptySingleRow,
  9067. maxNumCols = _ref.maxNumCols,
  9068. leqno = _ref.leqno;
  9069. parser.gullet.beginGroup();
  9070. if (!singleRow) {
  9071. // \cr is equivalent to \\ without the optional size argument (see below)
  9072. // TODO: provide helpful error when \cr is used outside array environment
  9073. parser.gullet.macros.set("\\cr", "\\\\\\relax");
  9074. } // Get current arraystretch if it's not set by the environment
  9075. if (!arraystretch) {
  9076. var stretch = parser.gullet.expandMacroAsText("\\arraystretch");
  9077. if (stretch == null) {
  9078. // Default \arraystretch from lttab.dtx
  9079. arraystretch = 1;
  9080. } else {
  9081. arraystretch = parseFloat(stretch);
  9082. if (!arraystretch || arraystretch < 0) {
  9083. throw new src_ParseError("Invalid \\arraystretch: " + stretch);
  9084. }
  9085. }
  9086. } // Start group for first cell
  9087. parser.gullet.beginGroup();
  9088. var row = [];
  9089. var body = [row];
  9090. var rowGaps = [];
  9091. var hLinesBeforeRow = [];
  9092. var tags = autoTag != null ? [] : undefined; // amsmath uses \global\@eqnswtrue and \global\@eqnswfalse to represent
  9093. // whether this row should have an equation number. Simulate this with
  9094. // a \@eqnsw macro set to 1 or 0.
  9095. function beginRow() {
  9096. if (autoTag) {
  9097. parser.gullet.macros.set("\\@eqnsw", "1", true);
  9098. }
  9099. }
  9100. function endRow() {
  9101. if (tags) {
  9102. if (parser.gullet.macros.get("\\df@tag")) {
  9103. tags.push(parser.subparse([new Token("\\df@tag")]));
  9104. parser.gullet.macros.set("\\df@tag", undefined, true);
  9105. } else {
  9106. tags.push(Boolean(autoTag) && parser.gullet.macros.get("\\@eqnsw") === "1");
  9107. }
  9108. }
  9109. }
  9110. beginRow(); // Test for \hline at the top of the array.
  9111. hLinesBeforeRow.push(getHLines(parser));
  9112. while (true) {
  9113. // eslint-disable-line no-constant-condition
  9114. // Parse each cell in its own group (namespace)
  9115. var cell = parser.parseExpression(false, singleRow ? "\\end" : "\\\\");
  9116. parser.gullet.endGroup();
  9117. parser.gullet.beginGroup();
  9118. cell = {
  9119. type: "ordgroup",
  9120. mode: parser.mode,
  9121. body: cell
  9122. };
  9123. if (style) {
  9124. cell = {
  9125. type: "styling",
  9126. mode: parser.mode,
  9127. style: style,
  9128. body: [cell]
  9129. };
  9130. }
  9131. row.push(cell);
  9132. var next = parser.fetch().text;
  9133. if (next === "&") {
  9134. if (maxNumCols && row.length === maxNumCols) {
  9135. if (singleRow || colSeparationType) {
  9136. // {equation} or {split}
  9137. throw new src_ParseError("Too many tab characters: &", parser.nextToken);
  9138. } else {
  9139. // {array} environment
  9140. parser.settings.reportNonstrict("textEnv", "Too few columns " + "specified in the {array} column argument.");
  9141. }
  9142. }
  9143. parser.consume();
  9144. } else if (next === "\\end") {
  9145. endRow(); // Arrays terminate newlines with `\crcr` which consumes a `\cr` if
  9146. // the last line is empty. However, AMS environments keep the
  9147. // empty row if it's the only one.
  9148. // NOTE: Currently, `cell` is the last item added into `row`.
  9149. if (row.length === 1 && cell.type === "styling" && cell.body[0].body.length === 0 && (body.length > 1 || !emptySingleRow)) {
  9150. body.pop();
  9151. }
  9152. if (hLinesBeforeRow.length < body.length + 1) {
  9153. hLinesBeforeRow.push([]);
  9154. }
  9155. break;
  9156. } else if (next === "\\\\") {
  9157. parser.consume();
  9158. var size = void 0; // \def\Let@{\let\\\math@cr}
  9159. // \def\math@cr{...\math@cr@}
  9160. // \def\math@cr@{\new@ifnextchar[\math@cr@@{\math@cr@@[\z@]}}
  9161. // \def\math@cr@@[#1]{...\math@cr@@@...}
  9162. // \def\math@cr@@@{\cr}
  9163. if (parser.gullet.future().text !== " ") {
  9164. size = parser.parseSizeGroup(true);
  9165. }
  9166. rowGaps.push(size ? size.value : null);
  9167. endRow(); // check for \hline(s) following the row separator
  9168. hLinesBeforeRow.push(getHLines(parser));
  9169. row = [];
  9170. body.push(row);
  9171. beginRow();
  9172. } else {
  9173. throw new src_ParseError("Expected & or \\\\ or \\cr or \\end", parser.nextToken);
  9174. }
  9175. } // End cell group
  9176. parser.gullet.endGroup(); // End array group defining \cr
  9177. parser.gullet.endGroup();
  9178. return {
  9179. type: "array",
  9180. mode: parser.mode,
  9181. addJot: addJot,
  9182. arraystretch: arraystretch,
  9183. body: body,
  9184. cols: cols,
  9185. rowGaps: rowGaps,
  9186. hskipBeforeAndAfter: hskipBeforeAndAfter,
  9187. hLinesBeforeRow: hLinesBeforeRow,
  9188. colSeparationType: colSeparationType,
  9189. tags: tags,
  9190. leqno: leqno
  9191. };
  9192. } // Decides on a style for cells in an array according to whether the given
  9193. // environment name starts with the letter 'd'.
  9194. function dCellStyle(envName) {
  9195. if (envName.substr(0, 1) === "d") {
  9196. return "display";
  9197. } else {
  9198. return "text";
  9199. }
  9200. }
  9201. var array_htmlBuilder = function htmlBuilder(group, options) {
  9202. var r;
  9203. var c;
  9204. var nr = group.body.length;
  9205. var hLinesBeforeRow = group.hLinesBeforeRow;
  9206. var nc = 0;
  9207. var body = new Array(nr);
  9208. var hlines = [];
  9209. var ruleThickness = Math.max( // From LaTeX \showthe\arrayrulewidth. Equals 0.04 em.
  9210. options.fontMetrics().arrayRuleWidth, options.minRuleThickness // User override.
  9211. ); // Horizontal spacing
  9212. var pt = 1 / options.fontMetrics().ptPerEm;
  9213. var arraycolsep = 5 * pt; // default value, i.e. \arraycolsep in article.cls
  9214. if (group.colSeparationType && group.colSeparationType === "small") {
  9215. // We're in a {smallmatrix}. Default column space is \thickspace,
  9216. // i.e. 5/18em = 0.2778em, per amsmath.dtx for {smallmatrix}.
  9217. // But that needs adjustment because LaTeX applies \scriptstyle to the
  9218. // entire array, including the colspace, but this function applies
  9219. // \scriptstyle only inside each element.
  9220. var localMultiplier = options.havingStyle(src_Style.SCRIPT).sizeMultiplier;
  9221. arraycolsep = 0.2778 * (localMultiplier / options.sizeMultiplier);
  9222. } // Vertical spacing
  9223. var baselineskip = group.colSeparationType === "CD" ? calculateSize({
  9224. number: 3,
  9225. unit: "ex"
  9226. }, options) : 12 * pt; // see size10.clo
  9227. // Default \jot from ltmath.dtx
  9228. // TODO(edemaine): allow overriding \jot via \setlength (#687)
  9229. var jot = 3 * pt;
  9230. var arrayskip = group.arraystretch * baselineskip;
  9231. var arstrutHeight = 0.7 * arrayskip; // \strutbox in ltfsstrc.dtx and
  9232. var arstrutDepth = 0.3 * arrayskip; // \@arstrutbox in lttab.dtx
  9233. var totalHeight = 0; // Set a position for \hline(s) at the top of the array, if any.
  9234. function setHLinePos(hlinesInGap) {
  9235. for (var i = 0; i < hlinesInGap.length; ++i) {
  9236. if (i > 0) {
  9237. totalHeight += 0.25;
  9238. }
  9239. hlines.push({
  9240. pos: totalHeight,
  9241. isDashed: hlinesInGap[i]
  9242. });
  9243. }
  9244. }
  9245. setHLinePos(hLinesBeforeRow[0]);
  9246. for (r = 0; r < group.body.length; ++r) {
  9247. var inrow = group.body[r];
  9248. var height = arstrutHeight; // \@array adds an \@arstrut
  9249. var depth = arstrutDepth; // to each tow (via the template)
  9250. if (nc < inrow.length) {
  9251. nc = inrow.length;
  9252. }
  9253. var outrow = new Array(inrow.length);
  9254. for (c = 0; c < inrow.length; ++c) {
  9255. var elt = buildGroup(inrow[c], options);
  9256. if (depth < elt.depth) {
  9257. depth = elt.depth;
  9258. }
  9259. if (height < elt.height) {
  9260. height = elt.height;
  9261. }
  9262. outrow[c] = elt;
  9263. }
  9264. var rowGap = group.rowGaps[r];
  9265. var gap = 0;
  9266. if (rowGap) {
  9267. gap = calculateSize(rowGap, options);
  9268. if (gap > 0) {
  9269. // \@argarraycr
  9270. gap += arstrutDepth;
  9271. if (depth < gap) {
  9272. depth = gap; // \@xargarraycr
  9273. }
  9274. gap = 0;
  9275. }
  9276. } // In AMS multiline environments such as aligned and gathered, rows
  9277. // correspond to lines that have additional \jot added to the
  9278. // \baselineskip via \openup.
  9279. if (group.addJot) {
  9280. depth += jot;
  9281. }
  9282. outrow.height = height;
  9283. outrow.depth = depth;
  9284. totalHeight += height;
  9285. outrow.pos = totalHeight;
  9286. totalHeight += depth + gap; // \@yargarraycr
  9287. body[r] = outrow; // Set a position for \hline(s), if any.
  9288. setHLinePos(hLinesBeforeRow[r + 1]);
  9289. }
  9290. var offset = totalHeight / 2 + options.fontMetrics().axisHeight;
  9291. var colDescriptions = group.cols || [];
  9292. var cols = [];
  9293. var colSep;
  9294. var colDescrNum;
  9295. var tagSpans = [];
  9296. if (group.tags && group.tags.some(function (tag) {
  9297. return tag;
  9298. })) {
  9299. // An environment with manual tags and/or automatic equation numbers.
  9300. // Create node(s), the latter of which trigger CSS counter increment.
  9301. for (r = 0; r < nr; ++r) {
  9302. var rw = body[r];
  9303. var shift = rw.pos - offset;
  9304. var tag = group.tags[r];
  9305. var tagSpan = void 0;
  9306. if (tag === true) {
  9307. // automatic numbering
  9308. tagSpan = buildCommon.makeSpan(["eqn-num"], [], options);
  9309. } else if (tag === false) {
  9310. // \nonumber/\notag or starred environment
  9311. tagSpan = buildCommon.makeSpan([], [], options);
  9312. } else {
  9313. // manual \tag
  9314. tagSpan = buildCommon.makeSpan([], buildExpression(tag, options, true), options);
  9315. }
  9316. tagSpan.depth = rw.depth;
  9317. tagSpan.height = rw.height;
  9318. tagSpans.push({
  9319. type: "elem",
  9320. elem: tagSpan,
  9321. shift: shift
  9322. });
  9323. }
  9324. }
  9325. for (c = 0, colDescrNum = 0; // Continue while either there are more columns or more column
  9326. // descriptions, so trailing separators don't get lost.
  9327. c < nc || colDescrNum < colDescriptions.length; ++c, ++colDescrNum) {
  9328. var colDescr = colDescriptions[colDescrNum] || {};
  9329. var firstSeparator = true;
  9330. while (colDescr.type === "separator") {
  9331. // If there is more than one separator in a row, add a space
  9332. // between them.
  9333. if (!firstSeparator) {
  9334. colSep = buildCommon.makeSpan(["arraycolsep"], []);
  9335. colSep.style.width = makeEm(options.fontMetrics().doubleRuleSep);
  9336. cols.push(colSep);
  9337. }
  9338. if (colDescr.separator === "|" || colDescr.separator === ":") {
  9339. var lineType = colDescr.separator === "|" ? "solid" : "dashed";
  9340. var separator = buildCommon.makeSpan(["vertical-separator"], [], options);
  9341. separator.style.height = makeEm(totalHeight);
  9342. separator.style.borderRightWidth = makeEm(ruleThickness);
  9343. separator.style.borderRightStyle = lineType;
  9344. separator.style.margin = "0 " + makeEm(-ruleThickness / 2);
  9345. var _shift = totalHeight - offset;
  9346. if (_shift) {
  9347. separator.style.verticalAlign = makeEm(-_shift);
  9348. }
  9349. cols.push(separator);
  9350. } else {
  9351. throw new src_ParseError("Invalid separator type: " + colDescr.separator);
  9352. }
  9353. colDescrNum++;
  9354. colDescr = colDescriptions[colDescrNum] || {};
  9355. firstSeparator = false;
  9356. }
  9357. if (c >= nc) {
  9358. continue;
  9359. }
  9360. var sepwidth = void 0;
  9361. if (c > 0 || group.hskipBeforeAndAfter) {
  9362. sepwidth = utils.deflt(colDescr.pregap, arraycolsep);
  9363. if (sepwidth !== 0) {
  9364. colSep = buildCommon.makeSpan(["arraycolsep"], []);
  9365. colSep.style.width = makeEm(sepwidth);
  9366. cols.push(colSep);
  9367. }
  9368. }
  9369. var col = [];
  9370. for (r = 0; r < nr; ++r) {
  9371. var row = body[r];
  9372. var elem = row[c];
  9373. if (!elem) {
  9374. continue;
  9375. }
  9376. var _shift2 = row.pos - offset;
  9377. elem.depth = row.depth;
  9378. elem.height = row.height;
  9379. col.push({
  9380. type: "elem",
  9381. elem: elem,
  9382. shift: _shift2
  9383. });
  9384. }
  9385. col = buildCommon.makeVList({
  9386. positionType: "individualShift",
  9387. children: col
  9388. }, options);
  9389. col = buildCommon.makeSpan(["col-align-" + (colDescr.align || "c")], [col]);
  9390. cols.push(col);
  9391. if (c < nc - 1 || group.hskipBeforeAndAfter) {
  9392. sepwidth = utils.deflt(colDescr.postgap, arraycolsep);
  9393. if (sepwidth !== 0) {
  9394. colSep = buildCommon.makeSpan(["arraycolsep"], []);
  9395. colSep.style.width = makeEm(sepwidth);
  9396. cols.push(colSep);
  9397. }
  9398. }
  9399. }
  9400. body = buildCommon.makeSpan(["mtable"], cols); // Add \hline(s), if any.
  9401. if (hlines.length > 0) {
  9402. var line = buildCommon.makeLineSpan("hline", options, ruleThickness);
  9403. var dashes = buildCommon.makeLineSpan("hdashline", options, ruleThickness);
  9404. var vListElems = [{
  9405. type: "elem",
  9406. elem: body,
  9407. shift: 0
  9408. }];
  9409. while (hlines.length > 0) {
  9410. var hline = hlines.pop();
  9411. var lineShift = hline.pos - offset;
  9412. if (hline.isDashed) {
  9413. vListElems.push({
  9414. type: "elem",
  9415. elem: dashes,
  9416. shift: lineShift
  9417. });
  9418. } else {
  9419. vListElems.push({
  9420. type: "elem",
  9421. elem: line,
  9422. shift: lineShift
  9423. });
  9424. }
  9425. }
  9426. body = buildCommon.makeVList({
  9427. positionType: "individualShift",
  9428. children: vListElems
  9429. }, options);
  9430. }
  9431. if (tagSpans.length === 0) {
  9432. return buildCommon.makeSpan(["mord"], [body], options);
  9433. } else {
  9434. var eqnNumCol = buildCommon.makeVList({
  9435. positionType: "individualShift",
  9436. children: tagSpans
  9437. }, options);
  9438. eqnNumCol = buildCommon.makeSpan(["tag"], [eqnNumCol], options);
  9439. return buildCommon.makeFragment([body, eqnNumCol]);
  9440. }
  9441. };
  9442. var alignMap = {
  9443. c: "center ",
  9444. l: "left ",
  9445. r: "right "
  9446. };
  9447. var array_mathmlBuilder = function mathmlBuilder(group, options) {
  9448. var tbl = [];
  9449. var glue = new mathMLTree.MathNode("mtd", [], ["mtr-glue"]);
  9450. var tag = new mathMLTree.MathNode("mtd", [], ["mml-eqn-num"]);
  9451. for (var i = 0; i < group.body.length; i++) {
  9452. var rw = group.body[i];
  9453. var row = [];
  9454. for (var j = 0; j < rw.length; j++) {
  9455. row.push(new mathMLTree.MathNode("mtd", [buildMathML_buildGroup(rw[j], options)]));
  9456. }
  9457. if (group.tags && group.tags[i]) {
  9458. row.unshift(glue);
  9459. row.push(glue);
  9460. if (group.leqno) {
  9461. row.unshift(tag);
  9462. } else {
  9463. row.push(tag);
  9464. }
  9465. }
  9466. tbl.push(new mathMLTree.MathNode("mtr", row));
  9467. }
  9468. var table = new mathMLTree.MathNode("mtable", tbl); // Set column alignment, row spacing, column spacing, and
  9469. // array lines by setting attributes on the table element.
  9470. // Set the row spacing. In MathML, we specify a gap distance.
  9471. // We do not use rowGap[] because MathML automatically increases
  9472. // cell height with the height/depth of the element content.
  9473. // LaTeX \arraystretch multiplies the row baseline-to-baseline distance.
  9474. // We simulate this by adding (arraystretch - 1)em to the gap. This
  9475. // does a reasonable job of adjusting arrays containing 1 em tall content.
  9476. // The 0.16 and 0.09 values are found emprically. They produce an array
  9477. // similar to LaTeX and in which content does not interfere with \hines.
  9478. var gap = group.arraystretch === 0.5 ? 0.1 // {smallmatrix}, {subarray}
  9479. : 0.16 + group.arraystretch - 1 + (group.addJot ? 0.09 : 0);
  9480. table.setAttribute("rowspacing", makeEm(gap)); // MathML table lines go only between cells.
  9481. // To place a line on an edge we'll use <menclose>, if necessary.
  9482. var menclose = "";
  9483. var align = "";
  9484. if (group.cols && group.cols.length > 0) {
  9485. // Find column alignment, column spacing, and vertical lines.
  9486. var cols = group.cols;
  9487. var columnLines = "";
  9488. var prevTypeWasAlign = false;
  9489. var iStart = 0;
  9490. var iEnd = cols.length;
  9491. if (cols[0].type === "separator") {
  9492. menclose += "top ";
  9493. iStart = 1;
  9494. }
  9495. if (cols[cols.length - 1].type === "separator") {
  9496. menclose += "bottom ";
  9497. iEnd -= 1;
  9498. }
  9499. for (var _i = iStart; _i < iEnd; _i++) {
  9500. if (cols[_i].type === "align") {
  9501. align += alignMap[cols[_i].align];
  9502. if (prevTypeWasAlign) {
  9503. columnLines += "none ";
  9504. }
  9505. prevTypeWasAlign = true;
  9506. } else if (cols[_i].type === "separator") {
  9507. // MathML accepts only single lines between cells.
  9508. // So we read only the first of consecutive separators.
  9509. if (prevTypeWasAlign) {
  9510. columnLines += cols[_i].separator === "|" ? "solid " : "dashed ";
  9511. prevTypeWasAlign = false;
  9512. }
  9513. }
  9514. }
  9515. table.setAttribute("columnalign", align.trim());
  9516. if (/[sd]/.test(columnLines)) {
  9517. table.setAttribute("columnlines", columnLines.trim());
  9518. }
  9519. } // Set column spacing.
  9520. if (group.colSeparationType === "align") {
  9521. var _cols = group.cols || [];
  9522. var spacing = "";
  9523. for (var _i2 = 1; _i2 < _cols.length; _i2++) {
  9524. spacing += _i2 % 2 ? "0em " : "1em ";
  9525. }
  9526. table.setAttribute("columnspacing", spacing.trim());
  9527. } else if (group.colSeparationType === "alignat" || group.colSeparationType === "gather") {
  9528. table.setAttribute("columnspacing", "0em");
  9529. } else if (group.colSeparationType === "small") {
  9530. table.setAttribute("columnspacing", "0.2778em");
  9531. } else if (group.colSeparationType === "CD") {
  9532. table.setAttribute("columnspacing", "0.5em");
  9533. } else {
  9534. table.setAttribute("columnspacing", "1em");
  9535. } // Address \hline and \hdashline
  9536. var rowLines = "";
  9537. var hlines = group.hLinesBeforeRow;
  9538. menclose += hlines[0].length > 0 ? "left " : "";
  9539. menclose += hlines[hlines.length - 1].length > 0 ? "right " : "";
  9540. for (var _i3 = 1; _i3 < hlines.length - 1; _i3++) {
  9541. rowLines += hlines[_i3].length === 0 ? "none " // MathML accepts only a single line between rows. Read one element.
  9542. : hlines[_i3][0] ? "dashed " : "solid ";
  9543. }
  9544. if (/[sd]/.test(rowLines)) {
  9545. table.setAttribute("rowlines", rowLines.trim());
  9546. }
  9547. if (menclose !== "") {
  9548. table = new mathMLTree.MathNode("menclose", [table]);
  9549. table.setAttribute("notation", menclose.trim());
  9550. }
  9551. if (group.arraystretch && group.arraystretch < 1) {
  9552. // A small array. Wrap in scriptstyle so row gap is not too large.
  9553. table = new mathMLTree.MathNode("mstyle", [table]);
  9554. table.setAttribute("scriptlevel", "1");
  9555. }
  9556. return table;
  9557. }; // Convenience function for align, align*, aligned, alignat, alignat*, alignedat.
  9558. var alignedHandler = function alignedHandler(context, args) {
  9559. if (context.envName.indexOf("ed") === -1) {
  9560. validateAmsEnvironmentContext(context);
  9561. }
  9562. var cols = [];
  9563. var separationType = context.envName.indexOf("at") > -1 ? "alignat" : "align";
  9564. var isSplit = context.envName === "split";
  9565. var res = parseArray(context.parser, {
  9566. cols: cols,
  9567. addJot: true,
  9568. autoTag: isSplit ? undefined : getAutoTag(context.envName),
  9569. emptySingleRow: true,
  9570. colSeparationType: separationType,
  9571. maxNumCols: isSplit ? 2 : undefined,
  9572. leqno: context.parser.settings.leqno
  9573. }, "display"); // Determining number of columns.
  9574. // 1. If the first argument is given, we use it as a number of columns,
  9575. // and makes sure that each row doesn't exceed that number.
  9576. // 2. Otherwise, just count number of columns = maximum number
  9577. // of cells in each row ("aligned" mode -- isAligned will be true).
  9578. //
  9579. // At the same time, prepend empty group {} at beginning of every second
  9580. // cell in each row (starting with second cell) so that operators become
  9581. // binary. This behavior is implemented in amsmath's \start@aligned.
  9582. var numMaths;
  9583. var numCols = 0;
  9584. var emptyGroup = {
  9585. type: "ordgroup",
  9586. mode: context.mode,
  9587. body: []
  9588. };
  9589. if (args[0] && args[0].type === "ordgroup") {
  9590. var arg0 = "";
  9591. for (var i = 0; i < args[0].body.length; i++) {
  9592. var textord = assertNodeType(args[0].body[i], "textord");
  9593. arg0 += textord.text;
  9594. }
  9595. numMaths = Number(arg0);
  9596. numCols = numMaths * 2;
  9597. }
  9598. var isAligned = !numCols;
  9599. res.body.forEach(function (row) {
  9600. for (var _i4 = 1; _i4 < row.length; _i4 += 2) {
  9601. // Modify ordgroup node within styling node
  9602. var styling = assertNodeType(row[_i4], "styling");
  9603. var ordgroup = assertNodeType(styling.body[0], "ordgroup");
  9604. ordgroup.body.unshift(emptyGroup);
  9605. }
  9606. if (!isAligned) {
  9607. // Case 1
  9608. var curMaths = row.length / 2;
  9609. if (numMaths < curMaths) {
  9610. throw new src_ParseError("Too many math in a row: " + ("expected " + numMaths + ", but got " + curMaths), row[0]);
  9611. }
  9612. } else if (numCols < row.length) {
  9613. // Case 2
  9614. numCols = row.length;
  9615. }
  9616. }); // Adjusting alignment.
  9617. // In aligned mode, we add one \qquad between columns;
  9618. // otherwise we add nothing.
  9619. for (var _i5 = 0; _i5 < numCols; ++_i5) {
  9620. var align = "r";
  9621. var pregap = 0;
  9622. if (_i5 % 2 === 1) {
  9623. align = "l";
  9624. } else if (_i5 > 0 && isAligned) {
  9625. // "aligned" mode.
  9626. pregap = 1; // add one \quad
  9627. }
  9628. cols[_i5] = {
  9629. type: "align",
  9630. align: align,
  9631. pregap: pregap,
  9632. postgap: 0
  9633. };
  9634. }
  9635. res.colSeparationType = isAligned ? "align" : "alignat";
  9636. return res;
  9637. }; // Arrays are part of LaTeX, defined in lttab.dtx so its documentation
  9638. // is part of the source2e.pdf file of LaTeX2e source documentation.
  9639. // {darray} is an {array} environment where cells are set in \displaystyle,
  9640. // as defined in nccmath.sty.
  9641. defineEnvironment({
  9642. type: "array",
  9643. names: ["array", "darray"],
  9644. props: {
  9645. numArgs: 1
  9646. },
  9647. handler: function handler(context, args) {
  9648. // Since no types are specified above, the two possibilities are
  9649. // - The argument is wrapped in {} or [], in which case Parser's
  9650. // parseGroup() returns an "ordgroup" wrapping some symbol node.
  9651. // - The argument is a bare symbol node.
  9652. var symNode = checkSymbolNodeType(args[0]);
  9653. var colalign = symNode ? [args[0]] : assertNodeType(args[0], "ordgroup").body;
  9654. var cols = colalign.map(function (nde) {
  9655. var node = assertSymbolNodeType(nde);
  9656. var ca = node.text;
  9657. if ("lcr".indexOf(ca) !== -1) {
  9658. return {
  9659. type: "align",
  9660. align: ca
  9661. };
  9662. } else if (ca === "|") {
  9663. return {
  9664. type: "separator",
  9665. separator: "|"
  9666. };
  9667. } else if (ca === ":") {
  9668. return {
  9669. type: "separator",
  9670. separator: ":"
  9671. };
  9672. }
  9673. throw new src_ParseError("Unknown column alignment: " + ca, nde);
  9674. });
  9675. var res = {
  9676. cols: cols,
  9677. hskipBeforeAndAfter: true,
  9678. // \@preamble in lttab.dtx
  9679. maxNumCols: cols.length
  9680. };
  9681. return parseArray(context.parser, res, dCellStyle(context.envName));
  9682. },
  9683. htmlBuilder: array_htmlBuilder,
  9684. mathmlBuilder: array_mathmlBuilder
  9685. }); // The matrix environments of amsmath builds on the array environment
  9686. // of LaTeX, which is discussed above.
  9687. // The mathtools package adds starred versions of the same environments.
  9688. // These have an optional argument to choose left|center|right justification.
  9689. defineEnvironment({
  9690. type: "array",
  9691. names: ["matrix", "pmatrix", "bmatrix", "Bmatrix", "vmatrix", "Vmatrix", "matrix*", "pmatrix*", "bmatrix*", "Bmatrix*", "vmatrix*", "Vmatrix*"],
  9692. props: {
  9693. numArgs: 0
  9694. },
  9695. handler: function handler(context) {
  9696. var delimiters = {
  9697. "matrix": null,
  9698. "pmatrix": ["(", ")"],
  9699. "bmatrix": ["[", "]"],
  9700. "Bmatrix": ["\\{", "\\}"],
  9701. "vmatrix": ["|", "|"],
  9702. "Vmatrix": ["\\Vert", "\\Vert"]
  9703. }[context.envName.replace("*", "")]; // \hskip -\arraycolsep in amsmath
  9704. var colAlign = "c";
  9705. var payload = {
  9706. hskipBeforeAndAfter: false,
  9707. cols: [{
  9708. type: "align",
  9709. align: colAlign
  9710. }]
  9711. };
  9712. if (context.envName.charAt(context.envName.length - 1) === "*") {
  9713. // It's one of the mathtools starred functions.
  9714. // Parse the optional alignment argument.
  9715. var parser = context.parser;
  9716. parser.consumeSpaces();
  9717. if (parser.fetch().text === "[") {
  9718. parser.consume();
  9719. parser.consumeSpaces();
  9720. colAlign = parser.fetch().text;
  9721. if ("lcr".indexOf(colAlign) === -1) {
  9722. throw new src_ParseError("Expected l or c or r", parser.nextToken);
  9723. }
  9724. parser.consume();
  9725. parser.consumeSpaces();
  9726. parser.expect("]");
  9727. parser.consume();
  9728. payload.cols = [{
  9729. type: "align",
  9730. align: colAlign
  9731. }];
  9732. }
  9733. }
  9734. var res = parseArray(context.parser, payload, dCellStyle(context.envName)); // Populate cols with the correct number of column alignment specs.
  9735. var numCols = Math.max.apply(Math, [0].concat(res.body.map(function (row) {
  9736. return row.length;
  9737. })));
  9738. res.cols = new Array(numCols).fill({
  9739. type: "align",
  9740. align: colAlign
  9741. });
  9742. return delimiters ? {
  9743. type: "leftright",
  9744. mode: context.mode,
  9745. body: [res],
  9746. left: delimiters[0],
  9747. right: delimiters[1],
  9748. rightColor: undefined // \right uninfluenced by \color in array
  9749. } : res;
  9750. },
  9751. htmlBuilder: array_htmlBuilder,
  9752. mathmlBuilder: array_mathmlBuilder
  9753. });
  9754. defineEnvironment({
  9755. type: "array",
  9756. names: ["smallmatrix"],
  9757. props: {
  9758. numArgs: 0
  9759. },
  9760. handler: function handler(context) {
  9761. var payload = {
  9762. arraystretch: 0.5
  9763. };
  9764. var res = parseArray(context.parser, payload, "script");
  9765. res.colSeparationType = "small";
  9766. return res;
  9767. },
  9768. htmlBuilder: array_htmlBuilder,
  9769. mathmlBuilder: array_mathmlBuilder
  9770. });
  9771. defineEnvironment({
  9772. type: "array",
  9773. names: ["subarray"],
  9774. props: {
  9775. numArgs: 1
  9776. },
  9777. handler: function handler(context, args) {
  9778. // Parsing of {subarray} is similar to {array}
  9779. var symNode = checkSymbolNodeType(args[0]);
  9780. var colalign = symNode ? [args[0]] : assertNodeType(args[0], "ordgroup").body;
  9781. var cols = colalign.map(function (nde) {
  9782. var node = assertSymbolNodeType(nde);
  9783. var ca = node.text; // {subarray} only recognizes "l" & "c"
  9784. if ("lc".indexOf(ca) !== -1) {
  9785. return {
  9786. type: "align",
  9787. align: ca
  9788. };
  9789. }
  9790. throw new src_ParseError("Unknown column alignment: " + ca, nde);
  9791. });
  9792. if (cols.length > 1) {
  9793. throw new src_ParseError("{subarray} can contain only one column");
  9794. }
  9795. var res = {
  9796. cols: cols,
  9797. hskipBeforeAndAfter: false,
  9798. arraystretch: 0.5
  9799. };
  9800. res = parseArray(context.parser, res, "script");
  9801. if (res.body.length > 0 && res.body[0].length > 1) {
  9802. throw new src_ParseError("{subarray} can contain only one column");
  9803. }
  9804. return res;
  9805. },
  9806. htmlBuilder: array_htmlBuilder,
  9807. mathmlBuilder: array_mathmlBuilder
  9808. }); // A cases environment (in amsmath.sty) is almost equivalent to
  9809. // \def\arraystretch{1.2}%
  9810. // \left\{\begin{array}{@{}l@{\quad}l@{}} … \end{array}\right.
  9811. // {dcases} is a {cases} environment where cells are set in \displaystyle,
  9812. // as defined in mathtools.sty.
  9813. // {rcases} is another mathtools environment. It's brace is on the right side.
  9814. defineEnvironment({
  9815. type: "array",
  9816. names: ["cases", "dcases", "rcases", "drcases"],
  9817. props: {
  9818. numArgs: 0
  9819. },
  9820. handler: function handler(context) {
  9821. var payload = {
  9822. arraystretch: 1.2,
  9823. cols: [{
  9824. type: "align",
  9825. align: "l",
  9826. pregap: 0,
  9827. // TODO(kevinb) get the current style.
  9828. // For now we use the metrics for TEXT style which is what we were
  9829. // doing before. Before attempting to get the current style we
  9830. // should look at TeX's behavior especially for \over and matrices.
  9831. postgap: 1.0
  9832. /* 1em quad */
  9833. }, {
  9834. type: "align",
  9835. align: "l",
  9836. pregap: 0,
  9837. postgap: 0
  9838. }]
  9839. };
  9840. var res = parseArray(context.parser, payload, dCellStyle(context.envName));
  9841. return {
  9842. type: "leftright",
  9843. mode: context.mode,
  9844. body: [res],
  9845. left: context.envName.indexOf("r") > -1 ? "." : "\\{",
  9846. right: context.envName.indexOf("r") > -1 ? "\\}" : ".",
  9847. rightColor: undefined
  9848. };
  9849. },
  9850. htmlBuilder: array_htmlBuilder,
  9851. mathmlBuilder: array_mathmlBuilder
  9852. }); // In the align environment, one uses ampersands, &, to specify number of
  9853. // columns in each row, and to locate spacing between each column.
  9854. // align gets automatic numbering. align* and aligned do not.
  9855. // The alignedat environment can be used in math mode.
  9856. // Note that we assume \nomallineskiplimit to be zero,
  9857. // so that \strut@ is the same as \strut.
  9858. defineEnvironment({
  9859. type: "array",
  9860. names: ["align", "align*", "aligned", "split"],
  9861. props: {
  9862. numArgs: 0
  9863. },
  9864. handler: alignedHandler,
  9865. htmlBuilder: array_htmlBuilder,
  9866. mathmlBuilder: array_mathmlBuilder
  9867. }); // A gathered environment is like an array environment with one centered
  9868. // column, but where rows are considered lines so get \jot line spacing
  9869. // and contents are set in \displaystyle.
  9870. defineEnvironment({
  9871. type: "array",
  9872. names: ["gathered", "gather", "gather*"],
  9873. props: {
  9874. numArgs: 0
  9875. },
  9876. handler: function handler(context) {
  9877. if (utils.contains(["gather", "gather*"], context.envName)) {
  9878. validateAmsEnvironmentContext(context);
  9879. }
  9880. var res = {
  9881. cols: [{
  9882. type: "align",
  9883. align: "c"
  9884. }],
  9885. addJot: true,
  9886. colSeparationType: "gather",
  9887. autoTag: getAutoTag(context.envName),
  9888. emptySingleRow: true,
  9889. leqno: context.parser.settings.leqno
  9890. };
  9891. return parseArray(context.parser, res, "display");
  9892. },
  9893. htmlBuilder: array_htmlBuilder,
  9894. mathmlBuilder: array_mathmlBuilder
  9895. }); // alignat environment is like an align environment, but one must explicitly
  9896. // specify maximum number of columns in each row, and can adjust spacing between
  9897. // each columns.
  9898. defineEnvironment({
  9899. type: "array",
  9900. names: ["alignat", "alignat*", "alignedat"],
  9901. props: {
  9902. numArgs: 1
  9903. },
  9904. handler: alignedHandler,
  9905. htmlBuilder: array_htmlBuilder,
  9906. mathmlBuilder: array_mathmlBuilder
  9907. });
  9908. defineEnvironment({
  9909. type: "array",
  9910. names: ["equation", "equation*"],
  9911. props: {
  9912. numArgs: 0
  9913. },
  9914. handler: function handler(context) {
  9915. validateAmsEnvironmentContext(context);
  9916. var res = {
  9917. autoTag: getAutoTag(context.envName),
  9918. emptySingleRow: true,
  9919. singleRow: true,
  9920. maxNumCols: 1,
  9921. leqno: context.parser.settings.leqno
  9922. };
  9923. return parseArray(context.parser, res, "display");
  9924. },
  9925. htmlBuilder: array_htmlBuilder,
  9926. mathmlBuilder: array_mathmlBuilder
  9927. });
  9928. defineEnvironment({
  9929. type: "array",
  9930. names: ["CD"],
  9931. props: {
  9932. numArgs: 0
  9933. },
  9934. handler: function handler(context) {
  9935. validateAmsEnvironmentContext(context);
  9936. return parseCD(context.parser);
  9937. },
  9938. htmlBuilder: array_htmlBuilder,
  9939. mathmlBuilder: array_mathmlBuilder
  9940. });
  9941. defineMacro("\\nonumber", "\\gdef\\@eqnsw{0}");
  9942. defineMacro("\\notag", "\\nonumber"); // Catch \hline outside array environment
  9943. defineFunction({
  9944. type: "text",
  9945. // Doesn't matter what this is.
  9946. names: ["\\hline", "\\hdashline"],
  9947. props: {
  9948. numArgs: 0,
  9949. allowedInText: true,
  9950. allowedInMath: true
  9951. },
  9952. handler: function handler(context, args) {
  9953. throw new src_ParseError(context.funcName + " valid only within array environment");
  9954. }
  9955. });
  9956. ;// CONCATENATED MODULE: ./src/environments.js
  9957. var environments = _environments;
  9958. /* harmony default export */ var src_environments = (environments); // All environment definitions should be imported below
  9959. ;// CONCATENATED MODULE: ./src/functions/environment.js
  9960. // Environment delimiters. HTML/MathML rendering is defined in the corresponding
  9961. // defineEnvironment definitions.
  9962. defineFunction({
  9963. type: "environment",
  9964. names: ["\\begin", "\\end"],
  9965. props: {
  9966. numArgs: 1,
  9967. argTypes: ["text"]
  9968. },
  9969. handler: function handler(_ref, args) {
  9970. var parser = _ref.parser,
  9971. funcName = _ref.funcName;
  9972. var nameGroup = args[0];
  9973. if (nameGroup.type !== "ordgroup") {
  9974. throw new src_ParseError("Invalid environment name", nameGroup);
  9975. }
  9976. var envName = "";
  9977. for (var i = 0; i < nameGroup.body.length; ++i) {
  9978. envName += assertNodeType(nameGroup.body[i], "textord").text;
  9979. }
  9980. if (funcName === "\\begin") {
  9981. // begin...end is similar to left...right
  9982. if (!src_environments.hasOwnProperty(envName)) {
  9983. throw new src_ParseError("No such environment: " + envName, nameGroup);
  9984. } // Build the environment object. Arguments and other information will
  9985. // be made available to the begin and end methods using properties.
  9986. var env = src_environments[envName];
  9987. var _parser$parseArgument = parser.parseArguments("\\begin{" + envName + "}", env),
  9988. _args = _parser$parseArgument.args,
  9989. optArgs = _parser$parseArgument.optArgs;
  9990. var context = {
  9991. mode: parser.mode,
  9992. envName: envName,
  9993. parser: parser
  9994. };
  9995. var result = env.handler(context, _args, optArgs);
  9996. parser.expect("\\end", false);
  9997. var endNameToken = parser.nextToken;
  9998. var end = assertNodeType(parser.parseFunction(), "environment");
  9999. if (end.name !== envName) {
  10000. throw new src_ParseError("Mismatch: \\begin{" + envName + "} matched by \\end{" + end.name + "}", endNameToken);
  10001. } // $FlowFixMe, "environment" handler returns an environment ParseNode
  10002. return result;
  10003. }
  10004. return {
  10005. type: "environment",
  10006. mode: parser.mode,
  10007. name: envName,
  10008. nameGroup: nameGroup
  10009. };
  10010. }
  10011. });
  10012. ;// CONCATENATED MODULE: ./src/functions/mclass.js
  10013. var mclass_makeSpan = buildCommon.makeSpan;
  10014. function mclass_htmlBuilder(group, options) {
  10015. var elements = buildExpression(group.body, options, true);
  10016. return mclass_makeSpan([group.mclass], elements, options);
  10017. }
  10018. function mclass_mathmlBuilder(group, options) {
  10019. var node;
  10020. var inner = buildMathML_buildExpression(group.body, options);
  10021. if (group.mclass === "minner") {
  10022. node = new mathMLTree.MathNode("mpadded", inner);
  10023. } else if (group.mclass === "mord") {
  10024. if (group.isCharacterBox) {
  10025. node = inner[0];
  10026. node.type = "mi";
  10027. } else {
  10028. node = new mathMLTree.MathNode("mi", inner);
  10029. }
  10030. } else {
  10031. if (group.isCharacterBox) {
  10032. node = inner[0];
  10033. node.type = "mo";
  10034. } else {
  10035. node = new mathMLTree.MathNode("mo", inner);
  10036. } // Set spacing based on what is the most likely adjacent atom type.
  10037. // See TeXbook p170.
  10038. if (group.mclass === "mbin") {
  10039. node.attributes.lspace = "0.22em"; // medium space
  10040. node.attributes.rspace = "0.22em";
  10041. } else if (group.mclass === "mpunct") {
  10042. node.attributes.lspace = "0em";
  10043. node.attributes.rspace = "0.17em"; // thinspace
  10044. } else if (group.mclass === "mopen" || group.mclass === "mclose") {
  10045. node.attributes.lspace = "0em";
  10046. node.attributes.rspace = "0em";
  10047. } else if (group.mclass === "minner") {
  10048. node.attributes.lspace = "0.0556em"; // 1 mu is the most likely option
  10049. node.attributes.width = "+0.1111em";
  10050. } // MathML <mo> default space is 5/18 em, so <mrel> needs no action.
  10051. // Ref: https://developer.mozilla.org/en-US/docs/Web/MathML/Element/mo
  10052. }
  10053. return node;
  10054. } // Math class commands except \mathop
  10055. defineFunction({
  10056. type: "mclass",
  10057. names: ["\\mathord", "\\mathbin", "\\mathrel", "\\mathopen", "\\mathclose", "\\mathpunct", "\\mathinner"],
  10058. props: {
  10059. numArgs: 1,
  10060. primitive: true
  10061. },
  10062. handler: function handler(_ref, args) {
  10063. var parser = _ref.parser,
  10064. funcName = _ref.funcName;
  10065. var body = args[0];
  10066. return {
  10067. type: "mclass",
  10068. mode: parser.mode,
  10069. mclass: "m" + funcName.substr(5),
  10070. // TODO(kevinb): don't prefix with 'm'
  10071. body: ordargument(body),
  10072. isCharacterBox: utils.isCharacterBox(body)
  10073. };
  10074. },
  10075. htmlBuilder: mclass_htmlBuilder,
  10076. mathmlBuilder: mclass_mathmlBuilder
  10077. });
  10078. var binrelClass = function binrelClass(arg) {
  10079. // \binrel@ spacing varies with (bin|rel|ord) of the atom in the argument.
  10080. // (by rendering separately and with {}s before and after, and measuring
  10081. // the change in spacing). We'll do roughly the same by detecting the
  10082. // atom type directly.
  10083. var atom = arg.type === "ordgroup" && arg.body.length ? arg.body[0] : arg;
  10084. if (atom.type === "atom" && (atom.family === "bin" || atom.family === "rel")) {
  10085. return "m" + atom.family;
  10086. } else {
  10087. return "mord";
  10088. }
  10089. }; // \@binrel{x}{y} renders like y but as mbin/mrel/mord if x is mbin/mrel/mord.
  10090. // This is equivalent to \binrel@{x}\binrel@@{y} in AMSTeX.
  10091. defineFunction({
  10092. type: "mclass",
  10093. names: ["\\@binrel"],
  10094. props: {
  10095. numArgs: 2
  10096. },
  10097. handler: function handler(_ref2, args) {
  10098. var parser = _ref2.parser;
  10099. return {
  10100. type: "mclass",
  10101. mode: parser.mode,
  10102. mclass: binrelClass(args[0]),
  10103. body: ordargument(args[1]),
  10104. isCharacterBox: utils.isCharacterBox(args[1])
  10105. };
  10106. }
  10107. }); // Build a relation or stacked op by placing one symbol on top of another
  10108. defineFunction({
  10109. type: "mclass",
  10110. names: ["\\stackrel", "\\overset", "\\underset"],
  10111. props: {
  10112. numArgs: 2
  10113. },
  10114. handler: function handler(_ref3, args) {
  10115. var parser = _ref3.parser,
  10116. funcName = _ref3.funcName;
  10117. var baseArg = args[1];
  10118. var shiftedArg = args[0];
  10119. var mclass;
  10120. if (funcName !== "\\stackrel") {
  10121. // LaTeX applies \binrel spacing to \overset and \underset.
  10122. mclass = binrelClass(baseArg);
  10123. } else {
  10124. mclass = "mrel"; // for \stackrel
  10125. }
  10126. var baseOp = {
  10127. type: "op",
  10128. mode: baseArg.mode,
  10129. limits: true,
  10130. alwaysHandleSupSub: true,
  10131. parentIsSupSub: false,
  10132. symbol: false,
  10133. suppressBaseShift: funcName !== "\\stackrel",
  10134. body: ordargument(baseArg)
  10135. };
  10136. var supsub = {
  10137. type: "supsub",
  10138. mode: shiftedArg.mode,
  10139. base: baseOp,
  10140. sup: funcName === "\\underset" ? null : shiftedArg,
  10141. sub: funcName === "\\underset" ? shiftedArg : null
  10142. };
  10143. return {
  10144. type: "mclass",
  10145. mode: parser.mode,
  10146. mclass: mclass,
  10147. body: [supsub],
  10148. isCharacterBox: utils.isCharacterBox(supsub)
  10149. };
  10150. },
  10151. htmlBuilder: mclass_htmlBuilder,
  10152. mathmlBuilder: mclass_mathmlBuilder
  10153. });
  10154. ;// CONCATENATED MODULE: ./src/functions/font.js
  10155. // TODO(kevinb): implement \\sl and \\sc
  10156. var font_htmlBuilder = function htmlBuilder(group, options) {
  10157. var font = group.font;
  10158. var newOptions = options.withFont(font);
  10159. return buildGroup(group.body, newOptions);
  10160. };
  10161. var font_mathmlBuilder = function mathmlBuilder(group, options) {
  10162. var font = group.font;
  10163. var newOptions = options.withFont(font);
  10164. return buildMathML_buildGroup(group.body, newOptions);
  10165. };
  10166. var fontAliases = {
  10167. "\\Bbb": "\\mathbb",
  10168. "\\bold": "\\mathbf",
  10169. "\\frak": "\\mathfrak",
  10170. "\\bm": "\\boldsymbol"
  10171. };
  10172. defineFunction({
  10173. type: "font",
  10174. names: [// styles, except \boldsymbol defined below
  10175. "\\mathrm", "\\mathit", "\\mathbf", "\\mathnormal", // families
  10176. "\\mathbb", "\\mathcal", "\\mathfrak", "\\mathscr", "\\mathsf", "\\mathtt", // aliases, except \bm defined below
  10177. "\\Bbb", "\\bold", "\\frak"],
  10178. props: {
  10179. numArgs: 1,
  10180. allowedInArgument: true
  10181. },
  10182. handler: function handler(_ref, args) {
  10183. var parser = _ref.parser,
  10184. funcName = _ref.funcName;
  10185. var body = normalizeArgument(args[0]);
  10186. var func = funcName;
  10187. if (func in fontAliases) {
  10188. func = fontAliases[func];
  10189. }
  10190. return {
  10191. type: "font",
  10192. mode: parser.mode,
  10193. font: func.slice(1),
  10194. body: body
  10195. };
  10196. },
  10197. htmlBuilder: font_htmlBuilder,
  10198. mathmlBuilder: font_mathmlBuilder
  10199. });
  10200. defineFunction({
  10201. type: "mclass",
  10202. names: ["\\boldsymbol", "\\bm"],
  10203. props: {
  10204. numArgs: 1
  10205. },
  10206. handler: function handler(_ref2, args) {
  10207. var parser = _ref2.parser;
  10208. var body = args[0];
  10209. var isCharacterBox = utils.isCharacterBox(body); // amsbsy.sty's \boldsymbol uses \binrel spacing to inherit the
  10210. // argument's bin|rel|ord status
  10211. return {
  10212. type: "mclass",
  10213. mode: parser.mode,
  10214. mclass: binrelClass(body),
  10215. body: [{
  10216. type: "font",
  10217. mode: parser.mode,
  10218. font: "boldsymbol",
  10219. body: body
  10220. }],
  10221. isCharacterBox: isCharacterBox
  10222. };
  10223. }
  10224. }); // Old font changing functions
  10225. defineFunction({
  10226. type: "font",
  10227. names: ["\\rm", "\\sf", "\\tt", "\\bf", "\\it", "\\cal"],
  10228. props: {
  10229. numArgs: 0,
  10230. allowedInText: true
  10231. },
  10232. handler: function handler(_ref3, args) {
  10233. var parser = _ref3.parser,
  10234. funcName = _ref3.funcName,
  10235. breakOnTokenText = _ref3.breakOnTokenText;
  10236. var mode = parser.mode;
  10237. var body = parser.parseExpression(true, breakOnTokenText);
  10238. var style = "math" + funcName.slice(1);
  10239. return {
  10240. type: "font",
  10241. mode: mode,
  10242. font: style,
  10243. body: {
  10244. type: "ordgroup",
  10245. mode: parser.mode,
  10246. body: body
  10247. }
  10248. };
  10249. },
  10250. htmlBuilder: font_htmlBuilder,
  10251. mathmlBuilder: font_mathmlBuilder
  10252. });
  10253. ;// CONCATENATED MODULE: ./src/functions/genfrac.js
  10254. var adjustStyle = function adjustStyle(size, originalStyle) {
  10255. // Figure out what style this fraction should be in based on the
  10256. // function used
  10257. var style = originalStyle;
  10258. if (size === "display") {
  10259. // Get display style as a default.
  10260. // If incoming style is sub/sup, use style.text() to get correct size.
  10261. style = style.id >= src_Style.SCRIPT.id ? style.text() : src_Style.DISPLAY;
  10262. } else if (size === "text" && style.size === src_Style.DISPLAY.size) {
  10263. // We're in a \tfrac but incoming style is displaystyle, so:
  10264. style = src_Style.TEXT;
  10265. } else if (size === "script") {
  10266. style = src_Style.SCRIPT;
  10267. } else if (size === "scriptscript") {
  10268. style = src_Style.SCRIPTSCRIPT;
  10269. }
  10270. return style;
  10271. };
  10272. var genfrac_htmlBuilder = function htmlBuilder(group, options) {
  10273. // Fractions are handled in the TeXbook on pages 444-445, rules 15(a-e).
  10274. var style = adjustStyle(group.size, options.style);
  10275. var nstyle = style.fracNum();
  10276. var dstyle = style.fracDen();
  10277. var newOptions;
  10278. newOptions = options.havingStyle(nstyle);
  10279. var numerm = buildGroup(group.numer, newOptions, options);
  10280. if (group.continued) {
  10281. // \cfrac inserts a \strut into the numerator.
  10282. // Get \strut dimensions from TeXbook page 353.
  10283. var hStrut = 8.5 / options.fontMetrics().ptPerEm;
  10284. var dStrut = 3.5 / options.fontMetrics().ptPerEm;
  10285. numerm.height = numerm.height < hStrut ? hStrut : numerm.height;
  10286. numerm.depth = numerm.depth < dStrut ? dStrut : numerm.depth;
  10287. }
  10288. newOptions = options.havingStyle(dstyle);
  10289. var denomm = buildGroup(group.denom, newOptions, options);
  10290. var rule;
  10291. var ruleWidth;
  10292. var ruleSpacing;
  10293. if (group.hasBarLine) {
  10294. if (group.barSize) {
  10295. ruleWidth = calculateSize(group.barSize, options);
  10296. rule = buildCommon.makeLineSpan("frac-line", options, ruleWidth);
  10297. } else {
  10298. rule = buildCommon.makeLineSpan("frac-line", options);
  10299. }
  10300. ruleWidth = rule.height;
  10301. ruleSpacing = rule.height;
  10302. } else {
  10303. rule = null;
  10304. ruleWidth = 0;
  10305. ruleSpacing = options.fontMetrics().defaultRuleThickness;
  10306. } // Rule 15b
  10307. var numShift;
  10308. var clearance;
  10309. var denomShift;
  10310. if (style.size === src_Style.DISPLAY.size || group.size === "display") {
  10311. numShift = options.fontMetrics().num1;
  10312. if (ruleWidth > 0) {
  10313. clearance = 3 * ruleSpacing;
  10314. } else {
  10315. clearance = 7 * ruleSpacing;
  10316. }
  10317. denomShift = options.fontMetrics().denom1;
  10318. } else {
  10319. if (ruleWidth > 0) {
  10320. numShift = options.fontMetrics().num2;
  10321. clearance = ruleSpacing;
  10322. } else {
  10323. numShift = options.fontMetrics().num3;
  10324. clearance = 3 * ruleSpacing;
  10325. }
  10326. denomShift = options.fontMetrics().denom2;
  10327. }
  10328. var frac;
  10329. if (!rule) {
  10330. // Rule 15c
  10331. var candidateClearance = numShift - numerm.depth - (denomm.height - denomShift);
  10332. if (candidateClearance < clearance) {
  10333. numShift += 0.5 * (clearance - candidateClearance);
  10334. denomShift += 0.5 * (clearance - candidateClearance);
  10335. }
  10336. frac = buildCommon.makeVList({
  10337. positionType: "individualShift",
  10338. children: [{
  10339. type: "elem",
  10340. elem: denomm,
  10341. shift: denomShift
  10342. }, {
  10343. type: "elem",
  10344. elem: numerm,
  10345. shift: -numShift
  10346. }]
  10347. }, options);
  10348. } else {
  10349. // Rule 15d
  10350. var axisHeight = options.fontMetrics().axisHeight;
  10351. if (numShift - numerm.depth - (axisHeight + 0.5 * ruleWidth) < clearance) {
  10352. numShift += clearance - (numShift - numerm.depth - (axisHeight + 0.5 * ruleWidth));
  10353. }
  10354. if (axisHeight - 0.5 * ruleWidth - (denomm.height - denomShift) < clearance) {
  10355. denomShift += clearance - (axisHeight - 0.5 * ruleWidth - (denomm.height - denomShift));
  10356. }
  10357. var midShift = -(axisHeight - 0.5 * ruleWidth);
  10358. frac = buildCommon.makeVList({
  10359. positionType: "individualShift",
  10360. children: [{
  10361. type: "elem",
  10362. elem: denomm,
  10363. shift: denomShift
  10364. }, {
  10365. type: "elem",
  10366. elem: rule,
  10367. shift: midShift
  10368. }, {
  10369. type: "elem",
  10370. elem: numerm,
  10371. shift: -numShift
  10372. }]
  10373. }, options);
  10374. } // Since we manually change the style sometimes (with \dfrac or \tfrac),
  10375. // account for the possible size change here.
  10376. newOptions = options.havingStyle(style);
  10377. frac.height *= newOptions.sizeMultiplier / options.sizeMultiplier;
  10378. frac.depth *= newOptions.sizeMultiplier / options.sizeMultiplier; // Rule 15e
  10379. var delimSize;
  10380. if (style.size === src_Style.DISPLAY.size) {
  10381. delimSize = options.fontMetrics().delim1;
  10382. } else if (style.size === src_Style.SCRIPTSCRIPT.size) {
  10383. delimSize = options.havingStyle(src_Style.SCRIPT).fontMetrics().delim2;
  10384. } else {
  10385. delimSize = options.fontMetrics().delim2;
  10386. }
  10387. var leftDelim;
  10388. var rightDelim;
  10389. if (group.leftDelim == null) {
  10390. leftDelim = makeNullDelimiter(options, ["mopen"]);
  10391. } else {
  10392. leftDelim = delimiter.customSizedDelim(group.leftDelim, delimSize, true, options.havingStyle(style), group.mode, ["mopen"]);
  10393. }
  10394. if (group.continued) {
  10395. rightDelim = buildCommon.makeSpan([]); // zero width for \cfrac
  10396. } else if (group.rightDelim == null) {
  10397. rightDelim = makeNullDelimiter(options, ["mclose"]);
  10398. } else {
  10399. rightDelim = delimiter.customSizedDelim(group.rightDelim, delimSize, true, options.havingStyle(style), group.mode, ["mclose"]);
  10400. }
  10401. return buildCommon.makeSpan(["mord"].concat(newOptions.sizingClasses(options)), [leftDelim, buildCommon.makeSpan(["mfrac"], [frac]), rightDelim], options);
  10402. };
  10403. var genfrac_mathmlBuilder = function mathmlBuilder(group, options) {
  10404. var node = new mathMLTree.MathNode("mfrac", [buildMathML_buildGroup(group.numer, options), buildMathML_buildGroup(group.denom, options)]);
  10405. if (!group.hasBarLine) {
  10406. node.setAttribute("linethickness", "0px");
  10407. } else if (group.barSize) {
  10408. var ruleWidth = calculateSize(group.barSize, options);
  10409. node.setAttribute("linethickness", makeEm(ruleWidth));
  10410. }
  10411. var style = adjustStyle(group.size, options.style);
  10412. if (style.size !== options.style.size) {
  10413. node = new mathMLTree.MathNode("mstyle", [node]);
  10414. var isDisplay = style.size === src_Style.DISPLAY.size ? "true" : "false";
  10415. node.setAttribute("displaystyle", isDisplay);
  10416. node.setAttribute("scriptlevel", "0");
  10417. }
  10418. if (group.leftDelim != null || group.rightDelim != null) {
  10419. var withDelims = [];
  10420. if (group.leftDelim != null) {
  10421. var leftOp = new mathMLTree.MathNode("mo", [new mathMLTree.TextNode(group.leftDelim.replace("\\", ""))]);
  10422. leftOp.setAttribute("fence", "true");
  10423. withDelims.push(leftOp);
  10424. }
  10425. withDelims.push(node);
  10426. if (group.rightDelim != null) {
  10427. var rightOp = new mathMLTree.MathNode("mo", [new mathMLTree.TextNode(group.rightDelim.replace("\\", ""))]);
  10428. rightOp.setAttribute("fence", "true");
  10429. withDelims.push(rightOp);
  10430. }
  10431. return makeRow(withDelims);
  10432. }
  10433. return node;
  10434. };
  10435. defineFunction({
  10436. type: "genfrac",
  10437. names: ["\\dfrac", "\\frac", "\\tfrac", "\\dbinom", "\\binom", "\\tbinom", "\\\\atopfrac", // can’t be entered directly
  10438. "\\\\bracefrac", "\\\\brackfrac" // ditto
  10439. ],
  10440. props: {
  10441. numArgs: 2,
  10442. allowedInArgument: true
  10443. },
  10444. handler: function handler(_ref, args) {
  10445. var parser = _ref.parser,
  10446. funcName = _ref.funcName;
  10447. var numer = args[0];
  10448. var denom = args[1];
  10449. var hasBarLine;
  10450. var leftDelim = null;
  10451. var rightDelim = null;
  10452. var size = "auto";
  10453. switch (funcName) {
  10454. case "\\dfrac":
  10455. case "\\frac":
  10456. case "\\tfrac":
  10457. hasBarLine = true;
  10458. break;
  10459. case "\\\\atopfrac":
  10460. hasBarLine = false;
  10461. break;
  10462. case "\\dbinom":
  10463. case "\\binom":
  10464. case "\\tbinom":
  10465. hasBarLine = false;
  10466. leftDelim = "(";
  10467. rightDelim = ")";
  10468. break;
  10469. case "\\\\bracefrac":
  10470. hasBarLine = false;
  10471. leftDelim = "\\{";
  10472. rightDelim = "\\}";
  10473. break;
  10474. case "\\\\brackfrac":
  10475. hasBarLine = false;
  10476. leftDelim = "[";
  10477. rightDelim = "]";
  10478. break;
  10479. default:
  10480. throw new Error("Unrecognized genfrac command");
  10481. }
  10482. switch (funcName) {
  10483. case "\\dfrac":
  10484. case "\\dbinom":
  10485. size = "display";
  10486. break;
  10487. case "\\tfrac":
  10488. case "\\tbinom":
  10489. size = "text";
  10490. break;
  10491. }
  10492. return {
  10493. type: "genfrac",
  10494. mode: parser.mode,
  10495. continued: false,
  10496. numer: numer,
  10497. denom: denom,
  10498. hasBarLine: hasBarLine,
  10499. leftDelim: leftDelim,
  10500. rightDelim: rightDelim,
  10501. size: size,
  10502. barSize: null
  10503. };
  10504. },
  10505. htmlBuilder: genfrac_htmlBuilder,
  10506. mathmlBuilder: genfrac_mathmlBuilder
  10507. });
  10508. defineFunction({
  10509. type: "genfrac",
  10510. names: ["\\cfrac"],
  10511. props: {
  10512. numArgs: 2
  10513. },
  10514. handler: function handler(_ref2, args) {
  10515. var parser = _ref2.parser,
  10516. funcName = _ref2.funcName;
  10517. var numer = args[0];
  10518. var denom = args[1];
  10519. return {
  10520. type: "genfrac",
  10521. mode: parser.mode,
  10522. continued: true,
  10523. numer: numer,
  10524. denom: denom,
  10525. hasBarLine: true,
  10526. leftDelim: null,
  10527. rightDelim: null,
  10528. size: "display",
  10529. barSize: null
  10530. };
  10531. }
  10532. }); // Infix generalized fractions -- these are not rendered directly, but replaced
  10533. // immediately by one of the variants above.
  10534. defineFunction({
  10535. type: "infix",
  10536. names: ["\\over", "\\choose", "\\atop", "\\brace", "\\brack"],
  10537. props: {
  10538. numArgs: 0,
  10539. infix: true
  10540. },
  10541. handler: function handler(_ref3) {
  10542. var parser = _ref3.parser,
  10543. funcName = _ref3.funcName,
  10544. token = _ref3.token;
  10545. var replaceWith;
  10546. switch (funcName) {
  10547. case "\\over":
  10548. replaceWith = "\\frac";
  10549. break;
  10550. case "\\choose":
  10551. replaceWith = "\\binom";
  10552. break;
  10553. case "\\atop":
  10554. replaceWith = "\\\\atopfrac";
  10555. break;
  10556. case "\\brace":
  10557. replaceWith = "\\\\bracefrac";
  10558. break;
  10559. case "\\brack":
  10560. replaceWith = "\\\\brackfrac";
  10561. break;
  10562. default:
  10563. throw new Error("Unrecognized infix genfrac command");
  10564. }
  10565. return {
  10566. type: "infix",
  10567. mode: parser.mode,
  10568. replaceWith: replaceWith,
  10569. token: token
  10570. };
  10571. }
  10572. });
  10573. var stylArray = ["display", "text", "script", "scriptscript"];
  10574. var delimFromValue = function delimFromValue(delimString) {
  10575. var delim = null;
  10576. if (delimString.length > 0) {
  10577. delim = delimString;
  10578. delim = delim === "." ? null : delim;
  10579. }
  10580. return delim;
  10581. };
  10582. defineFunction({
  10583. type: "genfrac",
  10584. names: ["\\genfrac"],
  10585. props: {
  10586. numArgs: 6,
  10587. allowedInArgument: true,
  10588. argTypes: ["math", "math", "size", "text", "math", "math"]
  10589. },
  10590. handler: function handler(_ref4, args) {
  10591. var parser = _ref4.parser;
  10592. var numer = args[4];
  10593. var denom = args[5]; // Look into the parse nodes to get the desired delimiters.
  10594. var leftNode = normalizeArgument(args[0]);
  10595. var leftDelim = leftNode.type === "atom" && leftNode.family === "open" ? delimFromValue(leftNode.text) : null;
  10596. var rightNode = normalizeArgument(args[1]);
  10597. var rightDelim = rightNode.type === "atom" && rightNode.family === "close" ? delimFromValue(rightNode.text) : null;
  10598. var barNode = assertNodeType(args[2], "size");
  10599. var hasBarLine;
  10600. var barSize = null;
  10601. if (barNode.isBlank) {
  10602. // \genfrac acts differently than \above.
  10603. // \genfrac treats an empty size group as a signal to use a
  10604. // standard bar size. \above would see size = 0 and omit the bar.
  10605. hasBarLine = true;
  10606. } else {
  10607. barSize = barNode.value;
  10608. hasBarLine = barSize.number > 0;
  10609. } // Find out if we want displaystyle, textstyle, etc.
  10610. var size = "auto";
  10611. var styl = args[3];
  10612. if (styl.type === "ordgroup") {
  10613. if (styl.body.length > 0) {
  10614. var textOrd = assertNodeType(styl.body[0], "textord");
  10615. size = stylArray[Number(textOrd.text)];
  10616. }
  10617. } else {
  10618. styl = assertNodeType(styl, "textord");
  10619. size = stylArray[Number(styl.text)];
  10620. }
  10621. return {
  10622. type: "genfrac",
  10623. mode: parser.mode,
  10624. numer: numer,
  10625. denom: denom,
  10626. continued: false,
  10627. hasBarLine: hasBarLine,
  10628. barSize: barSize,
  10629. leftDelim: leftDelim,
  10630. rightDelim: rightDelim,
  10631. size: size
  10632. };
  10633. },
  10634. htmlBuilder: genfrac_htmlBuilder,
  10635. mathmlBuilder: genfrac_mathmlBuilder
  10636. }); // \above is an infix fraction that also defines a fraction bar size.
  10637. defineFunction({
  10638. type: "infix",
  10639. names: ["\\above"],
  10640. props: {
  10641. numArgs: 1,
  10642. argTypes: ["size"],
  10643. infix: true
  10644. },
  10645. handler: function handler(_ref5, args) {
  10646. var parser = _ref5.parser,
  10647. funcName = _ref5.funcName,
  10648. token = _ref5.token;
  10649. return {
  10650. type: "infix",
  10651. mode: parser.mode,
  10652. replaceWith: "\\\\abovefrac",
  10653. size: assertNodeType(args[0], "size").value,
  10654. token: token
  10655. };
  10656. }
  10657. });
  10658. defineFunction({
  10659. type: "genfrac",
  10660. names: ["\\\\abovefrac"],
  10661. props: {
  10662. numArgs: 3,
  10663. argTypes: ["math", "size", "math"]
  10664. },
  10665. handler: function handler(_ref6, args) {
  10666. var parser = _ref6.parser,
  10667. funcName = _ref6.funcName;
  10668. var numer = args[0];
  10669. var barSize = assert(assertNodeType(args[1], "infix").size);
  10670. var denom = args[2];
  10671. var hasBarLine = barSize.number > 0;
  10672. return {
  10673. type: "genfrac",
  10674. mode: parser.mode,
  10675. numer: numer,
  10676. denom: denom,
  10677. continued: false,
  10678. hasBarLine: hasBarLine,
  10679. barSize: barSize,
  10680. leftDelim: null,
  10681. rightDelim: null,
  10682. size: "auto"
  10683. };
  10684. },
  10685. htmlBuilder: genfrac_htmlBuilder,
  10686. mathmlBuilder: genfrac_mathmlBuilder
  10687. });
  10688. ;// CONCATENATED MODULE: ./src/functions/horizBrace.js
  10689. // NOTE: Unlike most `htmlBuilder`s, this one handles not only "horizBrace", but
  10690. // also "supsub" since an over/underbrace can affect super/subscripting.
  10691. var horizBrace_htmlBuilder = function htmlBuilder(grp, options) {
  10692. var style = options.style; // Pull out the `ParseNode<"horizBrace">` if `grp` is a "supsub" node.
  10693. var supSubGroup;
  10694. var group;
  10695. if (grp.type === "supsub") {
  10696. // Ref: LaTeX source2e: }}}}\limits}
  10697. // i.e. LaTeX treats the brace similar to an op and passes it
  10698. // with \limits, so we need to assign supsub style.
  10699. supSubGroup = grp.sup ? buildGroup(grp.sup, options.havingStyle(style.sup()), options) : buildGroup(grp.sub, options.havingStyle(style.sub()), options);
  10700. group = assertNodeType(grp.base, "horizBrace");
  10701. } else {
  10702. group = assertNodeType(grp, "horizBrace");
  10703. } // Build the base group
  10704. var body = buildGroup(group.base, options.havingBaseStyle(src_Style.DISPLAY)); // Create the stretchy element
  10705. var braceBody = stretchy.svgSpan(group, options); // Generate the vlist, with the appropriate kerns ┏━━━━━━━━┓
  10706. // This first vlist contains the content and the brace: equation
  10707. var vlist;
  10708. if (group.isOver) {
  10709. vlist = buildCommon.makeVList({
  10710. positionType: "firstBaseline",
  10711. children: [{
  10712. type: "elem",
  10713. elem: body
  10714. }, {
  10715. type: "kern",
  10716. size: 0.1
  10717. }, {
  10718. type: "elem",
  10719. elem: braceBody
  10720. }]
  10721. }, options); // $FlowFixMe: Replace this with passing "svg-align" into makeVList.
  10722. vlist.children[0].children[0].children[1].classes.push("svg-align");
  10723. } else {
  10724. vlist = buildCommon.makeVList({
  10725. positionType: "bottom",
  10726. positionData: body.depth + 0.1 + braceBody.height,
  10727. children: [{
  10728. type: "elem",
  10729. elem: braceBody
  10730. }, {
  10731. type: "kern",
  10732. size: 0.1
  10733. }, {
  10734. type: "elem",
  10735. elem: body
  10736. }]
  10737. }, options); // $FlowFixMe: Replace this with passing "svg-align" into makeVList.
  10738. vlist.children[0].children[0].children[0].classes.push("svg-align");
  10739. }
  10740. if (supSubGroup) {
  10741. // To write the supsub, wrap the first vlist in another vlist:
  10742. // They can't all go in the same vlist, because the note might be
  10743. // wider than the equation. We want the equation to control the
  10744. // brace width.
  10745. // note long note long note
  10746. // ┏━━━━━━━━┓ or ┏━━━┓ not ┏━━━━━━━━━┓
  10747. // equation eqn eqn
  10748. var vSpan = buildCommon.makeSpan(["mord", group.isOver ? "mover" : "munder"], [vlist], options);
  10749. if (group.isOver) {
  10750. vlist = buildCommon.makeVList({
  10751. positionType: "firstBaseline",
  10752. children: [{
  10753. type: "elem",
  10754. elem: vSpan
  10755. }, {
  10756. type: "kern",
  10757. size: 0.2
  10758. }, {
  10759. type: "elem",
  10760. elem: supSubGroup
  10761. }]
  10762. }, options);
  10763. } else {
  10764. vlist = buildCommon.makeVList({
  10765. positionType: "bottom",
  10766. positionData: vSpan.depth + 0.2 + supSubGroup.height + supSubGroup.depth,
  10767. children: [{
  10768. type: "elem",
  10769. elem: supSubGroup
  10770. }, {
  10771. type: "kern",
  10772. size: 0.2
  10773. }, {
  10774. type: "elem",
  10775. elem: vSpan
  10776. }]
  10777. }, options);
  10778. }
  10779. }
  10780. return buildCommon.makeSpan(["mord", group.isOver ? "mover" : "munder"], [vlist], options);
  10781. };
  10782. var horizBrace_mathmlBuilder = function mathmlBuilder(group, options) {
  10783. var accentNode = stretchy.mathMLnode(group.label);
  10784. return new mathMLTree.MathNode(group.isOver ? "mover" : "munder", [buildMathML_buildGroup(group.base, options), accentNode]);
  10785. }; // Horizontal stretchy braces
  10786. defineFunction({
  10787. type: "horizBrace",
  10788. names: ["\\overbrace", "\\underbrace"],
  10789. props: {
  10790. numArgs: 1
  10791. },
  10792. handler: function handler(_ref, args) {
  10793. var parser = _ref.parser,
  10794. funcName = _ref.funcName;
  10795. return {
  10796. type: "horizBrace",
  10797. mode: parser.mode,
  10798. label: funcName,
  10799. isOver: /^\\over/.test(funcName),
  10800. base: args[0]
  10801. };
  10802. },
  10803. htmlBuilder: horizBrace_htmlBuilder,
  10804. mathmlBuilder: horizBrace_mathmlBuilder
  10805. });
  10806. ;// CONCATENATED MODULE: ./src/functions/href.js
  10807. defineFunction({
  10808. type: "href",
  10809. names: ["\\href"],
  10810. props: {
  10811. numArgs: 2,
  10812. argTypes: ["url", "original"],
  10813. allowedInText: true
  10814. },
  10815. handler: function handler(_ref, args) {
  10816. var parser = _ref.parser;
  10817. var body = args[1];
  10818. var href = assertNodeType(args[0], "url").url;
  10819. if (!parser.settings.isTrusted({
  10820. command: "\\href",
  10821. url: href
  10822. })) {
  10823. return parser.formatUnsupportedCmd("\\href");
  10824. }
  10825. return {
  10826. type: "href",
  10827. mode: parser.mode,
  10828. href: href,
  10829. body: ordargument(body)
  10830. };
  10831. },
  10832. htmlBuilder: function htmlBuilder(group, options) {
  10833. var elements = buildExpression(group.body, options, false);
  10834. return buildCommon.makeAnchor(group.href, [], elements, options);
  10835. },
  10836. mathmlBuilder: function mathmlBuilder(group, options) {
  10837. var math = buildExpressionRow(group.body, options);
  10838. if (!(math instanceof MathNode)) {
  10839. math = new MathNode("mrow", [math]);
  10840. }
  10841. math.setAttribute("href", group.href);
  10842. return math;
  10843. }
  10844. });
  10845. defineFunction({
  10846. type: "href",
  10847. names: ["\\url"],
  10848. props: {
  10849. numArgs: 1,
  10850. argTypes: ["url"],
  10851. allowedInText: true
  10852. },
  10853. handler: function handler(_ref2, args) {
  10854. var parser = _ref2.parser;
  10855. var href = assertNodeType(args[0], "url").url;
  10856. if (!parser.settings.isTrusted({
  10857. command: "\\url",
  10858. url: href
  10859. })) {
  10860. return parser.formatUnsupportedCmd("\\url");
  10861. }
  10862. var chars = [];
  10863. for (var i = 0; i < href.length; i++) {
  10864. var c = href[i];
  10865. if (c === "~") {
  10866. c = "\\textasciitilde";
  10867. }
  10868. chars.push({
  10869. type: "textord",
  10870. mode: "text",
  10871. text: c
  10872. });
  10873. }
  10874. var body = {
  10875. type: "text",
  10876. mode: parser.mode,
  10877. font: "\\texttt",
  10878. body: chars
  10879. };
  10880. return {
  10881. type: "href",
  10882. mode: parser.mode,
  10883. href: href,
  10884. body: ordargument(body)
  10885. };
  10886. }
  10887. });
  10888. ;// CONCATENATED MODULE: ./src/functions/hbox.js
  10889. // \hbox is provided for compatibility with LaTeX \vcenter.
  10890. // In LaTeX, \vcenter can act only on a box, as in
  10891. // \vcenter{\hbox{$\frac{a+b}{\dfrac{c}{d}}$}}
  10892. // This function by itself doesn't do anything but prevent a soft line break.
  10893. defineFunction({
  10894. type: "hbox",
  10895. names: ["\\hbox"],
  10896. props: {
  10897. numArgs: 1,
  10898. argTypes: ["text"],
  10899. allowedInText: true,
  10900. primitive: true
  10901. },
  10902. handler: function handler(_ref, args) {
  10903. var parser = _ref.parser;
  10904. return {
  10905. type: "hbox",
  10906. mode: parser.mode,
  10907. body: ordargument(args[0])
  10908. };
  10909. },
  10910. htmlBuilder: function htmlBuilder(group, options) {
  10911. var elements = buildExpression(group.body, options, false);
  10912. return buildCommon.makeFragment(elements);
  10913. },
  10914. mathmlBuilder: function mathmlBuilder(group, options) {
  10915. return new mathMLTree.MathNode("mrow", buildMathML_buildExpression(group.body, options));
  10916. }
  10917. });
  10918. ;// CONCATENATED MODULE: ./src/functions/html.js
  10919. defineFunction({
  10920. type: "html",
  10921. names: ["\\htmlClass", "\\htmlId", "\\htmlStyle", "\\htmlData"],
  10922. props: {
  10923. numArgs: 2,
  10924. argTypes: ["raw", "original"],
  10925. allowedInText: true
  10926. },
  10927. handler: function handler(_ref, args) {
  10928. var parser = _ref.parser,
  10929. funcName = _ref.funcName,
  10930. token = _ref.token;
  10931. var value = assertNodeType(args[0], "raw").string;
  10932. var body = args[1];
  10933. if (parser.settings.strict) {
  10934. parser.settings.reportNonstrict("htmlExtension", "HTML extension is disabled on strict mode");
  10935. }
  10936. var trustContext;
  10937. var attributes = {};
  10938. switch (funcName) {
  10939. case "\\htmlClass":
  10940. attributes.class = value;
  10941. trustContext = {
  10942. command: "\\htmlClass",
  10943. class: value
  10944. };
  10945. break;
  10946. case "\\htmlId":
  10947. attributes.id = value;
  10948. trustContext = {
  10949. command: "\\htmlId",
  10950. id: value
  10951. };
  10952. break;
  10953. case "\\htmlStyle":
  10954. attributes.style = value;
  10955. trustContext = {
  10956. command: "\\htmlStyle",
  10957. style: value
  10958. };
  10959. break;
  10960. case "\\htmlData":
  10961. {
  10962. var data = value.split(",");
  10963. for (var i = 0; i < data.length; i++) {
  10964. var keyVal = data[i].split("=");
  10965. if (keyVal.length !== 2) {
  10966. throw new src_ParseError("Error parsing key-value for \\htmlData");
  10967. }
  10968. attributes["data-" + keyVal[0].trim()] = keyVal[1].trim();
  10969. }
  10970. trustContext = {
  10971. command: "\\htmlData",
  10972. attributes: attributes
  10973. };
  10974. break;
  10975. }
  10976. default:
  10977. throw new Error("Unrecognized html command");
  10978. }
  10979. if (!parser.settings.isTrusted(trustContext)) {
  10980. return parser.formatUnsupportedCmd(funcName);
  10981. }
  10982. return {
  10983. type: "html",
  10984. mode: parser.mode,
  10985. attributes: attributes,
  10986. body: ordargument(body)
  10987. };
  10988. },
  10989. htmlBuilder: function htmlBuilder(group, options) {
  10990. var elements = buildExpression(group.body, options, false);
  10991. var classes = ["enclosing"];
  10992. if (group.attributes.class) {
  10993. classes.push.apply(classes, group.attributes.class.trim().split(/\s+/));
  10994. }
  10995. var span = buildCommon.makeSpan(classes, elements, options);
  10996. for (var attr in group.attributes) {
  10997. if (attr !== "class" && group.attributes.hasOwnProperty(attr)) {
  10998. span.setAttribute(attr, group.attributes[attr]);
  10999. }
  11000. }
  11001. return span;
  11002. },
  11003. mathmlBuilder: function mathmlBuilder(group, options) {
  11004. return buildExpressionRow(group.body, options);
  11005. }
  11006. });
  11007. ;// CONCATENATED MODULE: ./src/functions/htmlmathml.js
  11008. defineFunction({
  11009. type: "htmlmathml",
  11010. names: ["\\html@mathml"],
  11011. props: {
  11012. numArgs: 2,
  11013. allowedInText: true
  11014. },
  11015. handler: function handler(_ref, args) {
  11016. var parser = _ref.parser;
  11017. return {
  11018. type: "htmlmathml",
  11019. mode: parser.mode,
  11020. html: ordargument(args[0]),
  11021. mathml: ordargument(args[1])
  11022. };
  11023. },
  11024. htmlBuilder: function htmlBuilder(group, options) {
  11025. var elements = buildExpression(group.html, options, false);
  11026. return buildCommon.makeFragment(elements);
  11027. },
  11028. mathmlBuilder: function mathmlBuilder(group, options) {
  11029. return buildExpressionRow(group.mathml, options);
  11030. }
  11031. });
  11032. ;// CONCATENATED MODULE: ./src/functions/includegraphics.js
  11033. var sizeData = function sizeData(str) {
  11034. if (/^[-+]? *(\d+(\.\d*)?|\.\d+)$/.test(str)) {
  11035. // str is a number with no unit specified.
  11036. // default unit is bp, per graphix package.
  11037. return {
  11038. number: +str,
  11039. unit: "bp"
  11040. };
  11041. } else {
  11042. var match = /([-+]?) *(\d+(?:\.\d*)?|\.\d+) *([a-z]{2})/.exec(str);
  11043. if (!match) {
  11044. throw new src_ParseError("Invalid size: '" + str + "' in \\includegraphics");
  11045. }
  11046. var data = {
  11047. number: +(match[1] + match[2]),
  11048. // sign + magnitude, cast to number
  11049. unit: match[3]
  11050. };
  11051. if (!validUnit(data)) {
  11052. throw new src_ParseError("Invalid unit: '" + data.unit + "' in \\includegraphics.");
  11053. }
  11054. return data;
  11055. }
  11056. };
  11057. defineFunction({
  11058. type: "includegraphics",
  11059. names: ["\\includegraphics"],
  11060. props: {
  11061. numArgs: 1,
  11062. numOptionalArgs: 1,
  11063. argTypes: ["raw", "url"],
  11064. allowedInText: false
  11065. },
  11066. handler: function handler(_ref, args, optArgs) {
  11067. var parser = _ref.parser;
  11068. var width = {
  11069. number: 0,
  11070. unit: "em"
  11071. };
  11072. var height = {
  11073. number: 0.9,
  11074. unit: "em"
  11075. }; // sorta character sized.
  11076. var totalheight = {
  11077. number: 0,
  11078. unit: "em"
  11079. };
  11080. var alt = "";
  11081. if (optArgs[0]) {
  11082. var attributeStr = assertNodeType(optArgs[0], "raw").string; // Parser.js does not parse key/value pairs. We get a string.
  11083. var attributes = attributeStr.split(",");
  11084. for (var i = 0; i < attributes.length; i++) {
  11085. var keyVal = attributes[i].split("=");
  11086. if (keyVal.length === 2) {
  11087. var str = keyVal[1].trim();
  11088. switch (keyVal[0].trim()) {
  11089. case "alt":
  11090. alt = str;
  11091. break;
  11092. case "width":
  11093. width = sizeData(str);
  11094. break;
  11095. case "height":
  11096. height = sizeData(str);
  11097. break;
  11098. case "totalheight":
  11099. totalheight = sizeData(str);
  11100. break;
  11101. default:
  11102. throw new src_ParseError("Invalid key: '" + keyVal[0] + "' in \\includegraphics.");
  11103. }
  11104. }
  11105. }
  11106. }
  11107. var src = assertNodeType(args[0], "url").url;
  11108. if (alt === "") {
  11109. // No alt given. Use the file name. Strip away the path.
  11110. alt = src;
  11111. alt = alt.replace(/^.*[\\/]/, '');
  11112. alt = alt.substring(0, alt.lastIndexOf('.'));
  11113. }
  11114. if (!parser.settings.isTrusted({
  11115. command: "\\includegraphics",
  11116. url: src
  11117. })) {
  11118. return parser.formatUnsupportedCmd("\\includegraphics");
  11119. }
  11120. return {
  11121. type: "includegraphics",
  11122. mode: parser.mode,
  11123. alt: alt,
  11124. width: width,
  11125. height: height,
  11126. totalheight: totalheight,
  11127. src: src
  11128. };
  11129. },
  11130. htmlBuilder: function htmlBuilder(group, options) {
  11131. var height = calculateSize(group.height, options);
  11132. var depth = 0;
  11133. if (group.totalheight.number > 0) {
  11134. depth = calculateSize(group.totalheight, options) - height;
  11135. }
  11136. var width = 0;
  11137. if (group.width.number > 0) {
  11138. width = calculateSize(group.width, options);
  11139. }
  11140. var style = {
  11141. height: makeEm(height + depth)
  11142. };
  11143. if (width > 0) {
  11144. style.width = makeEm(width);
  11145. }
  11146. if (depth > 0) {
  11147. style.verticalAlign = makeEm(-depth);
  11148. }
  11149. var node = new Img(group.src, group.alt, style);
  11150. node.height = height;
  11151. node.depth = depth;
  11152. return node;
  11153. },
  11154. mathmlBuilder: function mathmlBuilder(group, options) {
  11155. var node = new mathMLTree.MathNode("mglyph", []);
  11156. node.setAttribute("alt", group.alt);
  11157. var height = calculateSize(group.height, options);
  11158. var depth = 0;
  11159. if (group.totalheight.number > 0) {
  11160. depth = calculateSize(group.totalheight, options) - height;
  11161. node.setAttribute("valign", makeEm(-depth));
  11162. }
  11163. node.setAttribute("height", makeEm(height + depth));
  11164. if (group.width.number > 0) {
  11165. var width = calculateSize(group.width, options);
  11166. node.setAttribute("width", makeEm(width));
  11167. }
  11168. node.setAttribute("src", group.src);
  11169. return node;
  11170. }
  11171. });
  11172. ;// CONCATENATED MODULE: ./src/functions/kern.js
  11173. // Horizontal spacing commands
  11174. // TODO: \hskip and \mskip should support plus and minus in lengths
  11175. defineFunction({
  11176. type: "kern",
  11177. names: ["\\kern", "\\mkern", "\\hskip", "\\mskip"],
  11178. props: {
  11179. numArgs: 1,
  11180. argTypes: ["size"],
  11181. primitive: true,
  11182. allowedInText: true
  11183. },
  11184. handler: function handler(_ref, args) {
  11185. var parser = _ref.parser,
  11186. funcName = _ref.funcName;
  11187. var size = assertNodeType(args[0], "size");
  11188. if (parser.settings.strict) {
  11189. var mathFunction = funcName[1] === 'm'; // \mkern, \mskip
  11190. var muUnit = size.value.unit === 'mu';
  11191. if (mathFunction) {
  11192. if (!muUnit) {
  11193. parser.settings.reportNonstrict("mathVsTextUnits", "LaTeX's " + funcName + " supports only mu units, " + ("not " + size.value.unit + " units"));
  11194. }
  11195. if (parser.mode !== "math") {
  11196. parser.settings.reportNonstrict("mathVsTextUnits", "LaTeX's " + funcName + " works only in math mode");
  11197. }
  11198. } else {
  11199. // !mathFunction
  11200. if (muUnit) {
  11201. parser.settings.reportNonstrict("mathVsTextUnits", "LaTeX's " + funcName + " doesn't support mu units");
  11202. }
  11203. }
  11204. }
  11205. return {
  11206. type: "kern",
  11207. mode: parser.mode,
  11208. dimension: size.value
  11209. };
  11210. },
  11211. htmlBuilder: function htmlBuilder(group, options) {
  11212. return buildCommon.makeGlue(group.dimension, options);
  11213. },
  11214. mathmlBuilder: function mathmlBuilder(group, options) {
  11215. var dimension = calculateSize(group.dimension, options);
  11216. return new mathMLTree.SpaceNode(dimension);
  11217. }
  11218. });
  11219. ;// CONCATENATED MODULE: ./src/functions/lap.js
  11220. // Horizontal overlap functions
  11221. defineFunction({
  11222. type: "lap",
  11223. names: ["\\mathllap", "\\mathrlap", "\\mathclap"],
  11224. props: {
  11225. numArgs: 1,
  11226. allowedInText: true
  11227. },
  11228. handler: function handler(_ref, args) {
  11229. var parser = _ref.parser,
  11230. funcName = _ref.funcName;
  11231. var body = args[0];
  11232. return {
  11233. type: "lap",
  11234. mode: parser.mode,
  11235. alignment: funcName.slice(5),
  11236. body: body
  11237. };
  11238. },
  11239. htmlBuilder: function htmlBuilder(group, options) {
  11240. // mathllap, mathrlap, mathclap
  11241. var inner;
  11242. if (group.alignment === "clap") {
  11243. // ref: https://www.math.lsu.edu/~aperlis/publications/mathclap/
  11244. inner = buildCommon.makeSpan([], [buildGroup(group.body, options)]); // wrap, since CSS will center a .clap > .inner > span
  11245. inner = buildCommon.makeSpan(["inner"], [inner], options);
  11246. } else {
  11247. inner = buildCommon.makeSpan(["inner"], [buildGroup(group.body, options)]);
  11248. }
  11249. var fix = buildCommon.makeSpan(["fix"], []);
  11250. var node = buildCommon.makeSpan([group.alignment], [inner, fix], options); // At this point, we have correctly set horizontal alignment of the
  11251. // two items involved in the lap.
  11252. // Next, use a strut to set the height of the HTML bounding box.
  11253. // Otherwise, a tall argument may be misplaced.
  11254. // This code resolved issue #1153
  11255. var strut = buildCommon.makeSpan(["strut"]);
  11256. strut.style.height = makeEm(node.height + node.depth);
  11257. if (node.depth) {
  11258. strut.style.verticalAlign = makeEm(-node.depth);
  11259. }
  11260. node.children.unshift(strut); // Next, prevent vertical misplacement when next to something tall.
  11261. // This code resolves issue #1234
  11262. node = buildCommon.makeSpan(["thinbox"], [node], options);
  11263. return buildCommon.makeSpan(["mord", "vbox"], [node], options);
  11264. },
  11265. mathmlBuilder: function mathmlBuilder(group, options) {
  11266. // mathllap, mathrlap, mathclap
  11267. var node = new mathMLTree.MathNode("mpadded", [buildMathML_buildGroup(group.body, options)]);
  11268. if (group.alignment !== "rlap") {
  11269. var offset = group.alignment === "llap" ? "-1" : "-0.5";
  11270. node.setAttribute("lspace", offset + "width");
  11271. }
  11272. node.setAttribute("width", "0px");
  11273. return node;
  11274. }
  11275. });
  11276. ;// CONCATENATED MODULE: ./src/functions/math.js
  11277. // Switching from text mode back to math mode
  11278. defineFunction({
  11279. type: "styling",
  11280. names: ["\\(", "$"],
  11281. props: {
  11282. numArgs: 0,
  11283. allowedInText: true,
  11284. allowedInMath: false
  11285. },
  11286. handler: function handler(_ref, args) {
  11287. var funcName = _ref.funcName,
  11288. parser = _ref.parser;
  11289. var outerMode = parser.mode;
  11290. parser.switchMode("math");
  11291. var close = funcName === "\\(" ? "\\)" : "$";
  11292. var body = parser.parseExpression(false, close);
  11293. parser.expect(close);
  11294. parser.switchMode(outerMode);
  11295. return {
  11296. type: "styling",
  11297. mode: parser.mode,
  11298. style: "text",
  11299. body: body
  11300. };
  11301. }
  11302. }); // Check for extra closing math delimiters
  11303. defineFunction({
  11304. type: "text",
  11305. // Doesn't matter what this is.
  11306. names: ["\\)", "\\]"],
  11307. props: {
  11308. numArgs: 0,
  11309. allowedInText: true,
  11310. allowedInMath: false
  11311. },
  11312. handler: function handler(context, args) {
  11313. throw new src_ParseError("Mismatched " + context.funcName);
  11314. }
  11315. });
  11316. ;// CONCATENATED MODULE: ./src/functions/mathchoice.js
  11317. var chooseMathStyle = function chooseMathStyle(group, options) {
  11318. switch (options.style.size) {
  11319. case src_Style.DISPLAY.size:
  11320. return group.display;
  11321. case src_Style.TEXT.size:
  11322. return group.text;
  11323. case src_Style.SCRIPT.size:
  11324. return group.script;
  11325. case src_Style.SCRIPTSCRIPT.size:
  11326. return group.scriptscript;
  11327. default:
  11328. return group.text;
  11329. }
  11330. };
  11331. defineFunction({
  11332. type: "mathchoice",
  11333. names: ["\\mathchoice"],
  11334. props: {
  11335. numArgs: 4,
  11336. primitive: true
  11337. },
  11338. handler: function handler(_ref, args) {
  11339. var parser = _ref.parser;
  11340. return {
  11341. type: "mathchoice",
  11342. mode: parser.mode,
  11343. display: ordargument(args[0]),
  11344. text: ordargument(args[1]),
  11345. script: ordargument(args[2]),
  11346. scriptscript: ordargument(args[3])
  11347. };
  11348. },
  11349. htmlBuilder: function htmlBuilder(group, options) {
  11350. var body = chooseMathStyle(group, options);
  11351. var elements = buildExpression(body, options, false);
  11352. return buildCommon.makeFragment(elements);
  11353. },
  11354. mathmlBuilder: function mathmlBuilder(group, options) {
  11355. var body = chooseMathStyle(group, options);
  11356. return buildExpressionRow(body, options);
  11357. }
  11358. });
  11359. ;// CONCATENATED MODULE: ./src/functions/utils/assembleSupSub.js
  11360. // For an operator with limits, assemble the base, sup, and sub into a span.
  11361. var assembleSupSub = function assembleSupSub(base, supGroup, subGroup, options, style, slant, baseShift) {
  11362. base = buildCommon.makeSpan([], [base]);
  11363. var subIsSingleCharacter = subGroup && utils.isCharacterBox(subGroup);
  11364. var sub;
  11365. var sup; // We manually have to handle the superscripts and subscripts. This,
  11366. // aside from the kern calculations, is copied from supsub.
  11367. if (supGroup) {
  11368. var elem = buildGroup(supGroup, options.havingStyle(style.sup()), options);
  11369. sup = {
  11370. elem: elem,
  11371. kern: Math.max(options.fontMetrics().bigOpSpacing1, options.fontMetrics().bigOpSpacing3 - elem.depth)
  11372. };
  11373. }
  11374. if (subGroup) {
  11375. var _elem = buildGroup(subGroup, options.havingStyle(style.sub()), options);
  11376. sub = {
  11377. elem: _elem,
  11378. kern: Math.max(options.fontMetrics().bigOpSpacing2, options.fontMetrics().bigOpSpacing4 - _elem.height)
  11379. };
  11380. } // Build the final group as a vlist of the possible subscript, base,
  11381. // and possible superscript.
  11382. var finalGroup;
  11383. if (sup && sub) {
  11384. var bottom = options.fontMetrics().bigOpSpacing5 + sub.elem.height + sub.elem.depth + sub.kern + base.depth + baseShift;
  11385. finalGroup = buildCommon.makeVList({
  11386. positionType: "bottom",
  11387. positionData: bottom,
  11388. children: [{
  11389. type: "kern",
  11390. size: options.fontMetrics().bigOpSpacing5
  11391. }, {
  11392. type: "elem",
  11393. elem: sub.elem,
  11394. marginLeft: makeEm(-slant)
  11395. }, {
  11396. type: "kern",
  11397. size: sub.kern
  11398. }, {
  11399. type: "elem",
  11400. elem: base
  11401. }, {
  11402. type: "kern",
  11403. size: sup.kern
  11404. }, {
  11405. type: "elem",
  11406. elem: sup.elem,
  11407. marginLeft: makeEm(slant)
  11408. }, {
  11409. type: "kern",
  11410. size: options.fontMetrics().bigOpSpacing5
  11411. }]
  11412. }, options);
  11413. } else if (sub) {
  11414. var top = base.height - baseShift; // Shift the limits by the slant of the symbol. Note
  11415. // that we are supposed to shift the limits by 1/2 of the slant,
  11416. // but since we are centering the limits adding a full slant of
  11417. // margin will shift by 1/2 that.
  11418. finalGroup = buildCommon.makeVList({
  11419. positionType: "top",
  11420. positionData: top,
  11421. children: [{
  11422. type: "kern",
  11423. size: options.fontMetrics().bigOpSpacing5
  11424. }, {
  11425. type: "elem",
  11426. elem: sub.elem,
  11427. marginLeft: makeEm(-slant)
  11428. }, {
  11429. type: "kern",
  11430. size: sub.kern
  11431. }, {
  11432. type: "elem",
  11433. elem: base
  11434. }]
  11435. }, options);
  11436. } else if (sup) {
  11437. var _bottom = base.depth + baseShift;
  11438. finalGroup = buildCommon.makeVList({
  11439. positionType: "bottom",
  11440. positionData: _bottom,
  11441. children: [{
  11442. type: "elem",
  11443. elem: base
  11444. }, {
  11445. type: "kern",
  11446. size: sup.kern
  11447. }, {
  11448. type: "elem",
  11449. elem: sup.elem,
  11450. marginLeft: makeEm(slant)
  11451. }, {
  11452. type: "kern",
  11453. size: options.fontMetrics().bigOpSpacing5
  11454. }]
  11455. }, options);
  11456. } else {
  11457. // This case probably shouldn't occur (this would mean the
  11458. // supsub was sending us a group with no superscript or
  11459. // subscript) but be safe.
  11460. return base;
  11461. }
  11462. var parts = [finalGroup];
  11463. if (sub && slant !== 0 && !subIsSingleCharacter) {
  11464. // A negative margin-left was applied to the lower limit.
  11465. // Avoid an overlap by placing a spacer on the left on the group.
  11466. var spacer = buildCommon.makeSpan(["mspace"], [], options);
  11467. spacer.style.marginRight = makeEm(slant);
  11468. parts.unshift(spacer);
  11469. }
  11470. return buildCommon.makeSpan(["mop", "op-limits"], parts, options);
  11471. };
  11472. ;// CONCATENATED MODULE: ./src/functions/op.js
  11473. // Limits, symbols
  11474. // Most operators have a large successor symbol, but these don't.
  11475. var noSuccessor = ["\\smallint"]; // NOTE: Unlike most `htmlBuilder`s, this one handles not only "op", but also
  11476. // "supsub" since some of them (like \int) can affect super/subscripting.
  11477. var op_htmlBuilder = function htmlBuilder(grp, options) {
  11478. // Operators are handled in the TeXbook pg. 443-444, rule 13(a).
  11479. var supGroup;
  11480. var subGroup;
  11481. var hasLimits = false;
  11482. var group;
  11483. if (grp.type === "supsub") {
  11484. // If we have limits, supsub will pass us its group to handle. Pull
  11485. // out the superscript and subscript and set the group to the op in
  11486. // its base.
  11487. supGroup = grp.sup;
  11488. subGroup = grp.sub;
  11489. group = assertNodeType(grp.base, "op");
  11490. hasLimits = true;
  11491. } else {
  11492. group = assertNodeType(grp, "op");
  11493. }
  11494. var style = options.style;
  11495. var large = false;
  11496. if (style.size === src_Style.DISPLAY.size && group.symbol && !utils.contains(noSuccessor, group.name)) {
  11497. // Most symbol operators get larger in displaystyle (rule 13)
  11498. large = true;
  11499. }
  11500. var base;
  11501. if (group.symbol) {
  11502. // If this is a symbol, create the symbol.
  11503. var fontName = large ? "Size2-Regular" : "Size1-Regular";
  11504. var stash = "";
  11505. if (group.name === "\\oiint" || group.name === "\\oiiint") {
  11506. // No font glyphs yet, so use a glyph w/o the oval.
  11507. // TODO: When font glyphs are available, delete this code.
  11508. stash = group.name.substr(1);
  11509. group.name = stash === "oiint" ? "\\iint" : "\\iiint";
  11510. }
  11511. base = buildCommon.makeSymbol(group.name, fontName, "math", options, ["mop", "op-symbol", large ? "large-op" : "small-op"]);
  11512. if (stash.length > 0) {
  11513. // We're in \oiint or \oiiint. Overlay the oval.
  11514. // TODO: When font glyphs are available, delete this code.
  11515. var italic = base.italic;
  11516. var oval = buildCommon.staticSvg(stash + "Size" + (large ? "2" : "1"), options);
  11517. base = buildCommon.makeVList({
  11518. positionType: "individualShift",
  11519. children: [{
  11520. type: "elem",
  11521. elem: base,
  11522. shift: 0
  11523. }, {
  11524. type: "elem",
  11525. elem: oval,
  11526. shift: large ? 0.08 : 0
  11527. }]
  11528. }, options);
  11529. group.name = "\\" + stash;
  11530. base.classes.unshift("mop"); // $FlowFixMe
  11531. base.italic = italic;
  11532. }
  11533. } else if (group.body) {
  11534. // If this is a list, compose that list.
  11535. var inner = buildExpression(group.body, options, true);
  11536. if (inner.length === 1 && inner[0] instanceof SymbolNode) {
  11537. base = inner[0];
  11538. base.classes[0] = "mop"; // replace old mclass
  11539. } else {
  11540. base = buildCommon.makeSpan(["mop"], inner, options);
  11541. }
  11542. } else {
  11543. // Otherwise, this is a text operator. Build the text from the
  11544. // operator's name.
  11545. var output = [];
  11546. for (var i = 1; i < group.name.length; i++) {
  11547. output.push(buildCommon.mathsym(group.name[i], group.mode, options));
  11548. }
  11549. base = buildCommon.makeSpan(["mop"], output, options);
  11550. } // If content of op is a single symbol, shift it vertically.
  11551. var baseShift = 0;
  11552. var slant = 0;
  11553. if ((base instanceof SymbolNode || group.name === "\\oiint" || group.name === "\\oiiint") && !group.suppressBaseShift) {
  11554. // We suppress the shift of the base of \overset and \underset. Otherwise,
  11555. // shift the symbol so its center lies on the axis (rule 13). It
  11556. // appears that our fonts have the centers of the symbols already
  11557. // almost on the axis, so these numbers are very small. Note we
  11558. // don't actually apply this here, but instead it is used either in
  11559. // the vlist creation or separately when there are no limits.
  11560. baseShift = (base.height - base.depth) / 2 - options.fontMetrics().axisHeight; // The slant of the symbol is just its italic correction.
  11561. // $FlowFixMe
  11562. slant = base.italic;
  11563. }
  11564. if (hasLimits) {
  11565. return assembleSupSub(base, supGroup, subGroup, options, style, slant, baseShift);
  11566. } else {
  11567. if (baseShift) {
  11568. base.style.position = "relative";
  11569. base.style.top = makeEm(baseShift);
  11570. }
  11571. return base;
  11572. }
  11573. };
  11574. var op_mathmlBuilder = function mathmlBuilder(group, options) {
  11575. var node;
  11576. if (group.symbol) {
  11577. // This is a symbol. Just add the symbol.
  11578. node = new MathNode("mo", [makeText(group.name, group.mode)]);
  11579. if (utils.contains(noSuccessor, group.name)) {
  11580. node.setAttribute("largeop", "false");
  11581. }
  11582. } else if (group.body) {
  11583. // This is an operator with children. Add them.
  11584. node = new MathNode("mo", buildMathML_buildExpression(group.body, options));
  11585. } else {
  11586. // This is a text operator. Add all of the characters from the
  11587. // operator's name.
  11588. node = new MathNode("mi", [new TextNode(group.name.slice(1))]); // Append an <mo>&ApplyFunction;</mo>.
  11589. // ref: https://www.w3.org/TR/REC-MathML/chap3_2.html#sec3.2.4
  11590. var operator = new MathNode("mo", [makeText("\u2061", "text")]);
  11591. if (group.parentIsSupSub) {
  11592. node = new MathNode("mrow", [node, operator]);
  11593. } else {
  11594. node = newDocumentFragment([node, operator]);
  11595. }
  11596. }
  11597. return node;
  11598. };
  11599. var singleCharBigOps = {
  11600. "\u220F": "\\prod",
  11601. "\u2210": "\\coprod",
  11602. "\u2211": "\\sum",
  11603. "\u22C0": "\\bigwedge",
  11604. "\u22C1": "\\bigvee",
  11605. "\u22C2": "\\bigcap",
  11606. "\u22C3": "\\bigcup",
  11607. "\u2A00": "\\bigodot",
  11608. "\u2A01": "\\bigoplus",
  11609. "\u2A02": "\\bigotimes",
  11610. "\u2A04": "\\biguplus",
  11611. "\u2A06": "\\bigsqcup"
  11612. };
  11613. defineFunction({
  11614. type: "op",
  11615. names: ["\\coprod", "\\bigvee", "\\bigwedge", "\\biguplus", "\\bigcap", "\\bigcup", "\\intop", "\\prod", "\\sum", "\\bigotimes", "\\bigoplus", "\\bigodot", "\\bigsqcup", "\\smallint", "\u220F", "\u2210", "\u2211", "\u22C0", "\u22C1", "\u22C2", "\u22C3", "\u2A00", "\u2A01", "\u2A02", "\u2A04", "\u2A06"],
  11616. props: {
  11617. numArgs: 0
  11618. },
  11619. handler: function handler(_ref, args) {
  11620. var parser = _ref.parser,
  11621. funcName = _ref.funcName;
  11622. var fName = funcName;
  11623. if (fName.length === 1) {
  11624. fName = singleCharBigOps[fName];
  11625. }
  11626. return {
  11627. type: "op",
  11628. mode: parser.mode,
  11629. limits: true,
  11630. parentIsSupSub: false,
  11631. symbol: true,
  11632. name: fName
  11633. };
  11634. },
  11635. htmlBuilder: op_htmlBuilder,
  11636. mathmlBuilder: op_mathmlBuilder
  11637. }); // Note: calling defineFunction with a type that's already been defined only
  11638. // works because the same htmlBuilder and mathmlBuilder are being used.
  11639. defineFunction({
  11640. type: "op",
  11641. names: ["\\mathop"],
  11642. props: {
  11643. numArgs: 1,
  11644. primitive: true
  11645. },
  11646. handler: function handler(_ref2, args) {
  11647. var parser = _ref2.parser;
  11648. var body = args[0];
  11649. return {
  11650. type: "op",
  11651. mode: parser.mode,
  11652. limits: false,
  11653. parentIsSupSub: false,
  11654. symbol: false,
  11655. body: ordargument(body)
  11656. };
  11657. },
  11658. htmlBuilder: op_htmlBuilder,
  11659. mathmlBuilder: op_mathmlBuilder
  11660. }); // There are 2 flags for operators; whether they produce limits in
  11661. // displaystyle, and whether they are symbols and should grow in
  11662. // displaystyle. These four groups cover the four possible choices.
  11663. var singleCharIntegrals = {
  11664. "\u222B": "\\int",
  11665. "\u222C": "\\iint",
  11666. "\u222D": "\\iiint",
  11667. "\u222E": "\\oint",
  11668. "\u222F": "\\oiint",
  11669. "\u2230": "\\oiiint"
  11670. }; // No limits, not symbols
  11671. defineFunction({
  11672. type: "op",
  11673. names: ["\\arcsin", "\\arccos", "\\arctan", "\\arctg", "\\arcctg", "\\arg", "\\ch", "\\cos", "\\cosec", "\\cosh", "\\cot", "\\cotg", "\\coth", "\\csc", "\\ctg", "\\cth", "\\deg", "\\dim", "\\exp", "\\hom", "\\ker", "\\lg", "\\ln", "\\log", "\\sec", "\\sin", "\\sinh", "\\sh", "\\tan", "\\tanh", "\\tg", "\\th"],
  11674. props: {
  11675. numArgs: 0
  11676. },
  11677. handler: function handler(_ref3) {
  11678. var parser = _ref3.parser,
  11679. funcName = _ref3.funcName;
  11680. return {
  11681. type: "op",
  11682. mode: parser.mode,
  11683. limits: false,
  11684. parentIsSupSub: false,
  11685. symbol: false,
  11686. name: funcName
  11687. };
  11688. },
  11689. htmlBuilder: op_htmlBuilder,
  11690. mathmlBuilder: op_mathmlBuilder
  11691. }); // Limits, not symbols
  11692. defineFunction({
  11693. type: "op",
  11694. names: ["\\det", "\\gcd", "\\inf", "\\lim", "\\max", "\\min", "\\Pr", "\\sup"],
  11695. props: {
  11696. numArgs: 0
  11697. },
  11698. handler: function handler(_ref4) {
  11699. var parser = _ref4.parser,
  11700. funcName = _ref4.funcName;
  11701. return {
  11702. type: "op",
  11703. mode: parser.mode,
  11704. limits: true,
  11705. parentIsSupSub: false,
  11706. symbol: false,
  11707. name: funcName
  11708. };
  11709. },
  11710. htmlBuilder: op_htmlBuilder,
  11711. mathmlBuilder: op_mathmlBuilder
  11712. }); // No limits, symbols
  11713. defineFunction({
  11714. type: "op",
  11715. names: ["\\int", "\\iint", "\\iiint", "\\oint", "\\oiint", "\\oiiint", "\u222B", "\u222C", "\u222D", "\u222E", "\u222F", "\u2230"],
  11716. props: {
  11717. numArgs: 0
  11718. },
  11719. handler: function handler(_ref5) {
  11720. var parser = _ref5.parser,
  11721. funcName = _ref5.funcName;
  11722. var fName = funcName;
  11723. if (fName.length === 1) {
  11724. fName = singleCharIntegrals[fName];
  11725. }
  11726. return {
  11727. type: "op",
  11728. mode: parser.mode,
  11729. limits: false,
  11730. parentIsSupSub: false,
  11731. symbol: true,
  11732. name: fName
  11733. };
  11734. },
  11735. htmlBuilder: op_htmlBuilder,
  11736. mathmlBuilder: op_mathmlBuilder
  11737. });
  11738. ;// CONCATENATED MODULE: ./src/functions/operatorname.js
  11739. // NOTE: Unlike most `htmlBuilder`s, this one handles not only
  11740. // "operatorname", but also "supsub" since \operatorname* can
  11741. // affect super/subscripting.
  11742. var operatorname_htmlBuilder = function htmlBuilder(grp, options) {
  11743. // Operators are handled in the TeXbook pg. 443-444, rule 13(a).
  11744. var supGroup;
  11745. var subGroup;
  11746. var hasLimits = false;
  11747. var group;
  11748. if (grp.type === "supsub") {
  11749. // If we have limits, supsub will pass us its group to handle. Pull
  11750. // out the superscript and subscript and set the group to the op in
  11751. // its base.
  11752. supGroup = grp.sup;
  11753. subGroup = grp.sub;
  11754. group = assertNodeType(grp.base, "operatorname");
  11755. hasLimits = true;
  11756. } else {
  11757. group = assertNodeType(grp, "operatorname");
  11758. }
  11759. var base;
  11760. if (group.body.length > 0) {
  11761. var body = group.body.map(function (child) {
  11762. // $FlowFixMe: Check if the node has a string `text` property.
  11763. var childText = child.text;
  11764. if (typeof childText === "string") {
  11765. return {
  11766. type: "textord",
  11767. mode: child.mode,
  11768. text: childText
  11769. };
  11770. } else {
  11771. return child;
  11772. }
  11773. }); // Consolidate function names into symbol characters.
  11774. var expression = buildExpression(body, options.withFont("mathrm"), true);
  11775. for (var i = 0; i < expression.length; i++) {
  11776. var child = expression[i];
  11777. if (child instanceof SymbolNode) {
  11778. // Per amsopn package,
  11779. // change minus to hyphen and \ast to asterisk
  11780. child.text = child.text.replace(/\u2212/, "-").replace(/\u2217/, "*");
  11781. }
  11782. }
  11783. base = buildCommon.makeSpan(["mop"], expression, options);
  11784. } else {
  11785. base = buildCommon.makeSpan(["mop"], [], options);
  11786. }
  11787. if (hasLimits) {
  11788. return assembleSupSub(base, supGroup, subGroup, options, options.style, 0, 0);
  11789. } else {
  11790. return base;
  11791. }
  11792. };
  11793. var operatorname_mathmlBuilder = function mathmlBuilder(group, options) {
  11794. // The steps taken here are similar to the html version.
  11795. var expression = buildMathML_buildExpression(group.body, options.withFont("mathrm")); // Is expression a string or has it something like a fraction?
  11796. var isAllString = true; // default
  11797. for (var i = 0; i < expression.length; i++) {
  11798. var node = expression[i];
  11799. if (node instanceof mathMLTree.SpaceNode) {// Do nothing
  11800. } else if (node instanceof mathMLTree.MathNode) {
  11801. switch (node.type) {
  11802. case "mi":
  11803. case "mn":
  11804. case "ms":
  11805. case "mspace":
  11806. case "mtext":
  11807. break;
  11808. // Do nothing yet.
  11809. case "mo":
  11810. {
  11811. var child = node.children[0];
  11812. if (node.children.length === 1 && child instanceof mathMLTree.TextNode) {
  11813. child.text = child.text.replace(/\u2212/, "-").replace(/\u2217/, "*");
  11814. } else {
  11815. isAllString = false;
  11816. }
  11817. break;
  11818. }
  11819. default:
  11820. isAllString = false;
  11821. }
  11822. } else {
  11823. isAllString = false;
  11824. }
  11825. }
  11826. if (isAllString) {
  11827. // Write a single TextNode instead of multiple nested tags.
  11828. var word = expression.map(function (node) {
  11829. return node.toText();
  11830. }).join("");
  11831. expression = [new mathMLTree.TextNode(word)];
  11832. }
  11833. var identifier = new mathMLTree.MathNode("mi", expression);
  11834. identifier.setAttribute("mathvariant", "normal"); // \u2061 is the same as &ApplyFunction;
  11835. // ref: https://www.w3schools.com/charsets/ref_html_entities_a.asp
  11836. var operator = new mathMLTree.MathNode("mo", [makeText("\u2061", "text")]);
  11837. if (group.parentIsSupSub) {
  11838. return new mathMLTree.MathNode("mrow", [identifier, operator]);
  11839. } else {
  11840. return mathMLTree.newDocumentFragment([identifier, operator]);
  11841. }
  11842. }; // \operatorname
  11843. // amsopn.dtx: \mathop{#1\kern\z@\operator@font#3}\newmcodes@
  11844. defineFunction({
  11845. type: "operatorname",
  11846. names: ["\\operatorname@", "\\operatornamewithlimits"],
  11847. props: {
  11848. numArgs: 1
  11849. },
  11850. handler: function handler(_ref, args) {
  11851. var parser = _ref.parser,
  11852. funcName = _ref.funcName;
  11853. var body = args[0];
  11854. return {
  11855. type: "operatorname",
  11856. mode: parser.mode,
  11857. body: ordargument(body),
  11858. alwaysHandleSupSub: funcName === "\\operatornamewithlimits",
  11859. limits: false,
  11860. parentIsSupSub: false
  11861. };
  11862. },
  11863. htmlBuilder: operatorname_htmlBuilder,
  11864. mathmlBuilder: operatorname_mathmlBuilder
  11865. });
  11866. defineMacro("\\operatorname", "\\@ifstar\\operatornamewithlimits\\operatorname@");
  11867. ;// CONCATENATED MODULE: ./src/functions/ordgroup.js
  11868. defineFunctionBuilders({
  11869. type: "ordgroup",
  11870. htmlBuilder: function htmlBuilder(group, options) {
  11871. if (group.semisimple) {
  11872. return buildCommon.makeFragment(buildExpression(group.body, options, false));
  11873. }
  11874. return buildCommon.makeSpan(["mord"], buildExpression(group.body, options, true), options);
  11875. },
  11876. mathmlBuilder: function mathmlBuilder(group, options) {
  11877. return buildExpressionRow(group.body, options, true);
  11878. }
  11879. });
  11880. ;// CONCATENATED MODULE: ./src/functions/overline.js
  11881. defineFunction({
  11882. type: "overline",
  11883. names: ["\\overline"],
  11884. props: {
  11885. numArgs: 1
  11886. },
  11887. handler: function handler(_ref, args) {
  11888. var parser = _ref.parser;
  11889. var body = args[0];
  11890. return {
  11891. type: "overline",
  11892. mode: parser.mode,
  11893. body: body
  11894. };
  11895. },
  11896. htmlBuilder: function htmlBuilder(group, options) {
  11897. // Overlines are handled in the TeXbook pg 443, Rule 9.
  11898. // Build the inner group in the cramped style.
  11899. var innerGroup = buildGroup(group.body, options.havingCrampedStyle()); // Create the line above the body
  11900. var line = buildCommon.makeLineSpan("overline-line", options); // Generate the vlist, with the appropriate kerns
  11901. var defaultRuleThickness = options.fontMetrics().defaultRuleThickness;
  11902. var vlist = buildCommon.makeVList({
  11903. positionType: "firstBaseline",
  11904. children: [{
  11905. type: "elem",
  11906. elem: innerGroup
  11907. }, {
  11908. type: "kern",
  11909. size: 3 * defaultRuleThickness
  11910. }, {
  11911. type: "elem",
  11912. elem: line
  11913. }, {
  11914. type: "kern",
  11915. size: defaultRuleThickness
  11916. }]
  11917. }, options);
  11918. return buildCommon.makeSpan(["mord", "overline"], [vlist], options);
  11919. },
  11920. mathmlBuilder: function mathmlBuilder(group, options) {
  11921. var operator = new mathMLTree.MathNode("mo", [new mathMLTree.TextNode("\u203E")]);
  11922. operator.setAttribute("stretchy", "true");
  11923. var node = new mathMLTree.MathNode("mover", [buildMathML_buildGroup(group.body, options), operator]);
  11924. node.setAttribute("accent", "true");
  11925. return node;
  11926. }
  11927. });
  11928. ;// CONCATENATED MODULE: ./src/functions/phantom.js
  11929. defineFunction({
  11930. type: "phantom",
  11931. names: ["\\phantom"],
  11932. props: {
  11933. numArgs: 1,
  11934. allowedInText: true
  11935. },
  11936. handler: function handler(_ref, args) {
  11937. var parser = _ref.parser;
  11938. var body = args[0];
  11939. return {
  11940. type: "phantom",
  11941. mode: parser.mode,
  11942. body: ordargument(body)
  11943. };
  11944. },
  11945. htmlBuilder: function htmlBuilder(group, options) {
  11946. var elements = buildExpression(group.body, options.withPhantom(), false); // \phantom isn't supposed to affect the elements it contains.
  11947. // See "color" for more details.
  11948. return buildCommon.makeFragment(elements);
  11949. },
  11950. mathmlBuilder: function mathmlBuilder(group, options) {
  11951. var inner = buildMathML_buildExpression(group.body, options);
  11952. return new mathMLTree.MathNode("mphantom", inner);
  11953. }
  11954. });
  11955. defineFunction({
  11956. type: "hphantom",
  11957. names: ["\\hphantom"],
  11958. props: {
  11959. numArgs: 1,
  11960. allowedInText: true
  11961. },
  11962. handler: function handler(_ref2, args) {
  11963. var parser = _ref2.parser;
  11964. var body = args[0];
  11965. return {
  11966. type: "hphantom",
  11967. mode: parser.mode,
  11968. body: body
  11969. };
  11970. },
  11971. htmlBuilder: function htmlBuilder(group, options) {
  11972. var node = buildCommon.makeSpan([], [buildGroup(group.body, options.withPhantom())]);
  11973. node.height = 0;
  11974. node.depth = 0;
  11975. if (node.children) {
  11976. for (var i = 0; i < node.children.length; i++) {
  11977. node.children[i].height = 0;
  11978. node.children[i].depth = 0;
  11979. }
  11980. } // See smash for comment re: use of makeVList
  11981. node = buildCommon.makeVList({
  11982. positionType: "firstBaseline",
  11983. children: [{
  11984. type: "elem",
  11985. elem: node
  11986. }]
  11987. }, options); // For spacing, TeX treats \smash as a math group (same spacing as ord).
  11988. return buildCommon.makeSpan(["mord"], [node], options);
  11989. },
  11990. mathmlBuilder: function mathmlBuilder(group, options) {
  11991. var inner = buildMathML_buildExpression(ordargument(group.body), options);
  11992. var phantom = new mathMLTree.MathNode("mphantom", inner);
  11993. var node = new mathMLTree.MathNode("mpadded", [phantom]);
  11994. node.setAttribute("height", "0px");
  11995. node.setAttribute("depth", "0px");
  11996. return node;
  11997. }
  11998. });
  11999. defineFunction({
  12000. type: "vphantom",
  12001. names: ["\\vphantom"],
  12002. props: {
  12003. numArgs: 1,
  12004. allowedInText: true
  12005. },
  12006. handler: function handler(_ref3, args) {
  12007. var parser = _ref3.parser;
  12008. var body = args[0];
  12009. return {
  12010. type: "vphantom",
  12011. mode: parser.mode,
  12012. body: body
  12013. };
  12014. },
  12015. htmlBuilder: function htmlBuilder(group, options) {
  12016. var inner = buildCommon.makeSpan(["inner"], [buildGroup(group.body, options.withPhantom())]);
  12017. var fix = buildCommon.makeSpan(["fix"], []);
  12018. return buildCommon.makeSpan(["mord", "rlap"], [inner, fix], options);
  12019. },
  12020. mathmlBuilder: function mathmlBuilder(group, options) {
  12021. var inner = buildMathML_buildExpression(ordargument(group.body), options);
  12022. var phantom = new mathMLTree.MathNode("mphantom", inner);
  12023. var node = new mathMLTree.MathNode("mpadded", [phantom]);
  12024. node.setAttribute("width", "0px");
  12025. return node;
  12026. }
  12027. });
  12028. ;// CONCATENATED MODULE: ./src/functions/raisebox.js
  12029. // Box manipulation
  12030. defineFunction({
  12031. type: "raisebox",
  12032. names: ["\\raisebox"],
  12033. props: {
  12034. numArgs: 2,
  12035. argTypes: ["size", "hbox"],
  12036. allowedInText: true
  12037. },
  12038. handler: function handler(_ref, args) {
  12039. var parser = _ref.parser;
  12040. var amount = assertNodeType(args[0], "size").value;
  12041. var body = args[1];
  12042. return {
  12043. type: "raisebox",
  12044. mode: parser.mode,
  12045. dy: amount,
  12046. body: body
  12047. };
  12048. },
  12049. htmlBuilder: function htmlBuilder(group, options) {
  12050. var body = buildGroup(group.body, options);
  12051. var dy = calculateSize(group.dy, options);
  12052. return buildCommon.makeVList({
  12053. positionType: "shift",
  12054. positionData: -dy,
  12055. children: [{
  12056. type: "elem",
  12057. elem: body
  12058. }]
  12059. }, options);
  12060. },
  12061. mathmlBuilder: function mathmlBuilder(group, options) {
  12062. var node = new mathMLTree.MathNode("mpadded", [buildMathML_buildGroup(group.body, options)]);
  12063. var dy = group.dy.number + group.dy.unit;
  12064. node.setAttribute("voffset", dy);
  12065. return node;
  12066. }
  12067. });
  12068. ;// CONCATENATED MODULE: ./src/functions/relax.js
  12069. defineFunction({
  12070. type: "internal",
  12071. names: ["\\relax"],
  12072. props: {
  12073. numArgs: 0,
  12074. allowedInText: true
  12075. },
  12076. handler: function handler(_ref) {
  12077. var parser = _ref.parser;
  12078. return {
  12079. type: "internal",
  12080. mode: parser.mode
  12081. };
  12082. }
  12083. });
  12084. ;// CONCATENATED MODULE: ./src/functions/rule.js
  12085. defineFunction({
  12086. type: "rule",
  12087. names: ["\\rule"],
  12088. props: {
  12089. numArgs: 2,
  12090. numOptionalArgs: 1,
  12091. argTypes: ["size", "size", "size"]
  12092. },
  12093. handler: function handler(_ref, args, optArgs) {
  12094. var parser = _ref.parser;
  12095. var shift = optArgs[0];
  12096. var width = assertNodeType(args[0], "size");
  12097. var height = assertNodeType(args[1], "size");
  12098. return {
  12099. type: "rule",
  12100. mode: parser.mode,
  12101. shift: shift && assertNodeType(shift, "size").value,
  12102. width: width.value,
  12103. height: height.value
  12104. };
  12105. },
  12106. htmlBuilder: function htmlBuilder(group, options) {
  12107. // Make an empty span for the rule
  12108. var rule = buildCommon.makeSpan(["mord", "rule"], [], options); // Calculate the shift, width, and height of the rule, and account for units
  12109. var width = calculateSize(group.width, options);
  12110. var height = calculateSize(group.height, options);
  12111. var shift = group.shift ? calculateSize(group.shift, options) : 0; // Style the rule to the right size
  12112. rule.style.borderRightWidth = makeEm(width);
  12113. rule.style.borderTopWidth = makeEm(height);
  12114. rule.style.bottom = makeEm(shift); // Record the height and width
  12115. rule.width = width;
  12116. rule.height = height + shift;
  12117. rule.depth = -shift; // Font size is the number large enough that the browser will
  12118. // reserve at least `absHeight` space above the baseline.
  12119. // The 1.125 factor was empirically determined
  12120. rule.maxFontSize = height * 1.125 * options.sizeMultiplier;
  12121. return rule;
  12122. },
  12123. mathmlBuilder: function mathmlBuilder(group, options) {
  12124. var width = calculateSize(group.width, options);
  12125. var height = calculateSize(group.height, options);
  12126. var shift = group.shift ? calculateSize(group.shift, options) : 0;
  12127. var color = options.color && options.getColor() || "black";
  12128. var rule = new mathMLTree.MathNode("mspace");
  12129. rule.setAttribute("mathbackground", color);
  12130. rule.setAttribute("width", makeEm(width));
  12131. rule.setAttribute("height", makeEm(height));
  12132. var wrapper = new mathMLTree.MathNode("mpadded", [rule]);
  12133. if (shift >= 0) {
  12134. wrapper.setAttribute("height", makeEm(shift));
  12135. } else {
  12136. wrapper.setAttribute("height", makeEm(shift));
  12137. wrapper.setAttribute("depth", makeEm(-shift));
  12138. }
  12139. wrapper.setAttribute("voffset", makeEm(shift));
  12140. return wrapper;
  12141. }
  12142. });
  12143. ;// CONCATENATED MODULE: ./src/functions/sizing.js
  12144. function sizingGroup(value, options, baseOptions) {
  12145. var inner = buildExpression(value, options, false);
  12146. var multiplier = options.sizeMultiplier / baseOptions.sizeMultiplier; // Add size-resetting classes to the inner list and set maxFontSize
  12147. // manually. Handle nested size changes.
  12148. for (var i = 0; i < inner.length; i++) {
  12149. var pos = inner[i].classes.indexOf("sizing");
  12150. if (pos < 0) {
  12151. Array.prototype.push.apply(inner[i].classes, options.sizingClasses(baseOptions));
  12152. } else if (inner[i].classes[pos + 1] === "reset-size" + options.size) {
  12153. // This is a nested size change: e.g., inner[i] is the "b" in
  12154. // `\Huge a \small b`. Override the old size (the `reset-` class)
  12155. // but not the new size.
  12156. inner[i].classes[pos + 1] = "reset-size" + baseOptions.size;
  12157. }
  12158. inner[i].height *= multiplier;
  12159. inner[i].depth *= multiplier;
  12160. }
  12161. return buildCommon.makeFragment(inner);
  12162. }
  12163. var sizeFuncs = ["\\tiny", "\\sixptsize", "\\scriptsize", "\\footnotesize", "\\small", "\\normalsize", "\\large", "\\Large", "\\LARGE", "\\huge", "\\Huge"];
  12164. var sizing_htmlBuilder = function htmlBuilder(group, options) {
  12165. // Handle sizing operators like \Huge. Real TeX doesn't actually allow
  12166. // these functions inside of math expressions, so we do some special
  12167. // handling.
  12168. var newOptions = options.havingSize(group.size);
  12169. return sizingGroup(group.body, newOptions, options);
  12170. };
  12171. defineFunction({
  12172. type: "sizing",
  12173. names: sizeFuncs,
  12174. props: {
  12175. numArgs: 0,
  12176. allowedInText: true
  12177. },
  12178. handler: function handler(_ref, args) {
  12179. var breakOnTokenText = _ref.breakOnTokenText,
  12180. funcName = _ref.funcName,
  12181. parser = _ref.parser;
  12182. var body = parser.parseExpression(false, breakOnTokenText);
  12183. return {
  12184. type: "sizing",
  12185. mode: parser.mode,
  12186. // Figure out what size to use based on the list of functions above
  12187. size: sizeFuncs.indexOf(funcName) + 1,
  12188. body: body
  12189. };
  12190. },
  12191. htmlBuilder: sizing_htmlBuilder,
  12192. mathmlBuilder: function mathmlBuilder(group, options) {
  12193. var newOptions = options.havingSize(group.size);
  12194. var inner = buildMathML_buildExpression(group.body, newOptions);
  12195. var node = new mathMLTree.MathNode("mstyle", inner); // TODO(emily): This doesn't produce the correct size for nested size
  12196. // changes, because we don't keep state of what style we're currently
  12197. // in, so we can't reset the size to normal before changing it. Now
  12198. // that we're passing an options parameter we should be able to fix
  12199. // this.
  12200. node.setAttribute("mathsize", makeEm(newOptions.sizeMultiplier));
  12201. return node;
  12202. }
  12203. });
  12204. ;// CONCATENATED MODULE: ./src/functions/smash.js
  12205. // smash, with optional [tb], as in AMS
  12206. defineFunction({
  12207. type: "smash",
  12208. names: ["\\smash"],
  12209. props: {
  12210. numArgs: 1,
  12211. numOptionalArgs: 1,
  12212. allowedInText: true
  12213. },
  12214. handler: function handler(_ref, args, optArgs) {
  12215. var parser = _ref.parser;
  12216. var smashHeight = false;
  12217. var smashDepth = false;
  12218. var tbArg = optArgs[0] && assertNodeType(optArgs[0], "ordgroup");
  12219. if (tbArg) {
  12220. // Optional [tb] argument is engaged.
  12221. // ref: amsmath: \renewcommand{\smash}[1][tb]{%
  12222. // def\mb@t{\ht}\def\mb@b{\dp}\def\mb@tb{\ht\z@\z@\dp}%
  12223. var letter = "";
  12224. for (var i = 0; i < tbArg.body.length; ++i) {
  12225. var node = tbArg.body[i]; // $FlowFixMe: Not every node type has a `text` property.
  12226. letter = node.text;
  12227. if (letter === "t") {
  12228. smashHeight = true;
  12229. } else if (letter === "b") {
  12230. smashDepth = true;
  12231. } else {
  12232. smashHeight = false;
  12233. smashDepth = false;
  12234. break;
  12235. }
  12236. }
  12237. } else {
  12238. smashHeight = true;
  12239. smashDepth = true;
  12240. }
  12241. var body = args[0];
  12242. return {
  12243. type: "smash",
  12244. mode: parser.mode,
  12245. body: body,
  12246. smashHeight: smashHeight,
  12247. smashDepth: smashDepth
  12248. };
  12249. },
  12250. htmlBuilder: function htmlBuilder(group, options) {
  12251. var node = buildCommon.makeSpan([], [buildGroup(group.body, options)]);
  12252. if (!group.smashHeight && !group.smashDepth) {
  12253. return node;
  12254. }
  12255. if (group.smashHeight) {
  12256. node.height = 0; // In order to influence makeVList, we have to reset the children.
  12257. if (node.children) {
  12258. for (var i = 0; i < node.children.length; i++) {
  12259. node.children[i].height = 0;
  12260. }
  12261. }
  12262. }
  12263. if (group.smashDepth) {
  12264. node.depth = 0;
  12265. if (node.children) {
  12266. for (var _i = 0; _i < node.children.length; _i++) {
  12267. node.children[_i].depth = 0;
  12268. }
  12269. }
  12270. } // At this point, we've reset the TeX-like height and depth values.
  12271. // But the span still has an HTML line height.
  12272. // makeVList applies "display: table-cell", which prevents the browser
  12273. // from acting on that line height. So we'll call makeVList now.
  12274. var smashedNode = buildCommon.makeVList({
  12275. positionType: "firstBaseline",
  12276. children: [{
  12277. type: "elem",
  12278. elem: node
  12279. }]
  12280. }, options); // For spacing, TeX treats \hphantom as a math group (same spacing as ord).
  12281. return buildCommon.makeSpan(["mord"], [smashedNode], options);
  12282. },
  12283. mathmlBuilder: function mathmlBuilder(group, options) {
  12284. var node = new mathMLTree.MathNode("mpadded", [buildMathML_buildGroup(group.body, options)]);
  12285. if (group.smashHeight) {
  12286. node.setAttribute("height", "0px");
  12287. }
  12288. if (group.smashDepth) {
  12289. node.setAttribute("depth", "0px");
  12290. }
  12291. return node;
  12292. }
  12293. });
  12294. ;// CONCATENATED MODULE: ./src/functions/sqrt.js
  12295. defineFunction({
  12296. type: "sqrt",
  12297. names: ["\\sqrt"],
  12298. props: {
  12299. numArgs: 1,
  12300. numOptionalArgs: 1
  12301. },
  12302. handler: function handler(_ref, args, optArgs) {
  12303. var parser = _ref.parser;
  12304. var index = optArgs[0];
  12305. var body = args[0];
  12306. return {
  12307. type: "sqrt",
  12308. mode: parser.mode,
  12309. body: body,
  12310. index: index
  12311. };
  12312. },
  12313. htmlBuilder: function htmlBuilder(group, options) {
  12314. // Square roots are handled in the TeXbook pg. 443, Rule 11.
  12315. // First, we do the same steps as in overline to build the inner group
  12316. // and line
  12317. var inner = buildGroup(group.body, options.havingCrampedStyle());
  12318. if (inner.height === 0) {
  12319. // Render a small surd.
  12320. inner.height = options.fontMetrics().xHeight;
  12321. } // Some groups can return document fragments. Handle those by wrapping
  12322. // them in a span.
  12323. inner = buildCommon.wrapFragment(inner, options); // Calculate the minimum size for the \surd delimiter
  12324. var metrics = options.fontMetrics();
  12325. var theta = metrics.defaultRuleThickness;
  12326. var phi = theta;
  12327. if (options.style.id < src_Style.TEXT.id) {
  12328. phi = options.fontMetrics().xHeight;
  12329. } // Calculate the clearance between the body and line
  12330. var lineClearance = theta + phi / 4;
  12331. var minDelimiterHeight = inner.height + inner.depth + lineClearance + theta; // Create a sqrt SVG of the required minimum size
  12332. var _delimiter$sqrtImage = delimiter.sqrtImage(minDelimiterHeight, options),
  12333. img = _delimiter$sqrtImage.span,
  12334. ruleWidth = _delimiter$sqrtImage.ruleWidth,
  12335. advanceWidth = _delimiter$sqrtImage.advanceWidth;
  12336. var delimDepth = img.height - ruleWidth; // Adjust the clearance based on the delimiter size
  12337. if (delimDepth > inner.height + inner.depth + lineClearance) {
  12338. lineClearance = (lineClearance + delimDepth - inner.height - inner.depth) / 2;
  12339. } // Shift the sqrt image
  12340. var imgShift = img.height - inner.height - lineClearance - ruleWidth;
  12341. inner.style.paddingLeft = makeEm(advanceWidth); // Overlay the image and the argument.
  12342. var body = buildCommon.makeVList({
  12343. positionType: "firstBaseline",
  12344. children: [{
  12345. type: "elem",
  12346. elem: inner,
  12347. wrapperClasses: ["svg-align"]
  12348. }, {
  12349. type: "kern",
  12350. size: -(inner.height + imgShift)
  12351. }, {
  12352. type: "elem",
  12353. elem: img
  12354. }, {
  12355. type: "kern",
  12356. size: ruleWidth
  12357. }]
  12358. }, options);
  12359. if (!group.index) {
  12360. return buildCommon.makeSpan(["mord", "sqrt"], [body], options);
  12361. } else {
  12362. // Handle the optional root index
  12363. // The index is always in scriptscript style
  12364. var newOptions = options.havingStyle(src_Style.SCRIPTSCRIPT);
  12365. var rootm = buildGroup(group.index, newOptions, options); // The amount the index is shifted by. This is taken from the TeX
  12366. // source, in the definition of `\r@@t`.
  12367. var toShift = 0.6 * (body.height - body.depth); // Build a VList with the superscript shifted up correctly
  12368. var rootVList = buildCommon.makeVList({
  12369. positionType: "shift",
  12370. positionData: -toShift,
  12371. children: [{
  12372. type: "elem",
  12373. elem: rootm
  12374. }]
  12375. }, options); // Add a class surrounding it so we can add on the appropriate
  12376. // kerning
  12377. var rootVListWrap = buildCommon.makeSpan(["root"], [rootVList]);
  12378. return buildCommon.makeSpan(["mord", "sqrt"], [rootVListWrap, body], options);
  12379. }
  12380. },
  12381. mathmlBuilder: function mathmlBuilder(group, options) {
  12382. var body = group.body,
  12383. index = group.index;
  12384. return index ? new mathMLTree.MathNode("mroot", [buildMathML_buildGroup(body, options), buildMathML_buildGroup(index, options)]) : new mathMLTree.MathNode("msqrt", [buildMathML_buildGroup(body, options)]);
  12385. }
  12386. });
  12387. ;// CONCATENATED MODULE: ./src/functions/styling.js
  12388. var styling_styleMap = {
  12389. "display": src_Style.DISPLAY,
  12390. "text": src_Style.TEXT,
  12391. "script": src_Style.SCRIPT,
  12392. "scriptscript": src_Style.SCRIPTSCRIPT
  12393. };
  12394. defineFunction({
  12395. type: "styling",
  12396. names: ["\\displaystyle", "\\textstyle", "\\scriptstyle", "\\scriptscriptstyle"],
  12397. props: {
  12398. numArgs: 0,
  12399. allowedInText: true,
  12400. primitive: true
  12401. },
  12402. handler: function handler(_ref, args) {
  12403. var breakOnTokenText = _ref.breakOnTokenText,
  12404. funcName = _ref.funcName,
  12405. parser = _ref.parser;
  12406. // parse out the implicit body
  12407. var body = parser.parseExpression(true, breakOnTokenText); // TODO: Refactor to avoid duplicating styleMap in multiple places (e.g.
  12408. // here and in buildHTML and de-dupe the enumeration of all the styles).
  12409. // $FlowFixMe: The names above exactly match the styles.
  12410. var style = funcName.slice(1, funcName.length - 5);
  12411. return {
  12412. type: "styling",
  12413. mode: parser.mode,
  12414. // Figure out what style to use by pulling out the style from
  12415. // the function name
  12416. style: style,
  12417. body: body
  12418. };
  12419. },
  12420. htmlBuilder: function htmlBuilder(group, options) {
  12421. // Style changes are handled in the TeXbook on pg. 442, Rule 3.
  12422. var newStyle = styling_styleMap[group.style];
  12423. var newOptions = options.havingStyle(newStyle).withFont('');
  12424. return sizingGroup(group.body, newOptions, options);
  12425. },
  12426. mathmlBuilder: function mathmlBuilder(group, options) {
  12427. // Figure out what style we're changing to.
  12428. var newStyle = styling_styleMap[group.style];
  12429. var newOptions = options.havingStyle(newStyle);
  12430. var inner = buildMathML_buildExpression(group.body, newOptions);
  12431. var node = new mathMLTree.MathNode("mstyle", inner);
  12432. var styleAttributes = {
  12433. "display": ["0", "true"],
  12434. "text": ["0", "false"],
  12435. "script": ["1", "false"],
  12436. "scriptscript": ["2", "false"]
  12437. };
  12438. var attr = styleAttributes[group.style];
  12439. node.setAttribute("scriptlevel", attr[0]);
  12440. node.setAttribute("displaystyle", attr[1]);
  12441. return node;
  12442. }
  12443. });
  12444. ;// CONCATENATED MODULE: ./src/functions/supsub.js
  12445. /**
  12446. * Sometimes, groups perform special rules when they have superscripts or
  12447. * subscripts attached to them. This function lets the `supsub` group know that
  12448. * Sometimes, groups perform special rules when they have superscripts or
  12449. * its inner element should handle the superscripts and subscripts instead of
  12450. * handling them itself.
  12451. */
  12452. var htmlBuilderDelegate = function htmlBuilderDelegate(group, options) {
  12453. var base = group.base;
  12454. if (!base) {
  12455. return null;
  12456. } else if (base.type === "op") {
  12457. // Operators handle supsubs differently when they have limits
  12458. // (e.g. `\displaystyle\sum_2^3`)
  12459. var delegate = base.limits && (options.style.size === src_Style.DISPLAY.size || base.alwaysHandleSupSub);
  12460. return delegate ? op_htmlBuilder : null;
  12461. } else if (base.type === "operatorname") {
  12462. var _delegate = base.alwaysHandleSupSub && (options.style.size === src_Style.DISPLAY.size || base.limits);
  12463. return _delegate ? operatorname_htmlBuilder : null;
  12464. } else if (base.type === "accent") {
  12465. return utils.isCharacterBox(base.base) ? htmlBuilder : null;
  12466. } else if (base.type === "horizBrace") {
  12467. var isSup = !group.sub;
  12468. return isSup === base.isOver ? horizBrace_htmlBuilder : null;
  12469. } else {
  12470. return null;
  12471. }
  12472. }; // Super scripts and subscripts, whose precise placement can depend on other
  12473. // functions that precede them.
  12474. defineFunctionBuilders({
  12475. type: "supsub",
  12476. htmlBuilder: function htmlBuilder(group, options) {
  12477. // Superscript and subscripts are handled in the TeXbook on page
  12478. // 445-446, rules 18(a-f).
  12479. // Here is where we defer to the inner group if it should handle
  12480. // superscripts and subscripts itself.
  12481. var builderDelegate = htmlBuilderDelegate(group, options);
  12482. if (builderDelegate) {
  12483. return builderDelegate(group, options);
  12484. }
  12485. var valueBase = group.base,
  12486. valueSup = group.sup,
  12487. valueSub = group.sub;
  12488. var base = buildGroup(valueBase, options);
  12489. var supm;
  12490. var subm;
  12491. var metrics = options.fontMetrics(); // Rule 18a
  12492. var supShift = 0;
  12493. var subShift = 0;
  12494. var isCharacterBox = valueBase && utils.isCharacterBox(valueBase);
  12495. if (valueSup) {
  12496. var newOptions = options.havingStyle(options.style.sup());
  12497. supm = buildGroup(valueSup, newOptions, options);
  12498. if (!isCharacterBox) {
  12499. supShift = base.height - newOptions.fontMetrics().supDrop * newOptions.sizeMultiplier / options.sizeMultiplier;
  12500. }
  12501. }
  12502. if (valueSub) {
  12503. var _newOptions = options.havingStyle(options.style.sub());
  12504. subm = buildGroup(valueSub, _newOptions, options);
  12505. if (!isCharacterBox) {
  12506. subShift = base.depth + _newOptions.fontMetrics().subDrop * _newOptions.sizeMultiplier / options.sizeMultiplier;
  12507. }
  12508. } // Rule 18c
  12509. var minSupShift;
  12510. if (options.style === src_Style.DISPLAY) {
  12511. minSupShift = metrics.sup1;
  12512. } else if (options.style.cramped) {
  12513. minSupShift = metrics.sup3;
  12514. } else {
  12515. minSupShift = metrics.sup2;
  12516. } // scriptspace is a font-size-independent size, so scale it
  12517. // appropriately for use as the marginRight.
  12518. var multiplier = options.sizeMultiplier;
  12519. var marginRight = makeEm(0.5 / metrics.ptPerEm / multiplier);
  12520. var marginLeft = null;
  12521. if (subm) {
  12522. // Subscripts shouldn't be shifted by the base's italic correction.
  12523. // Account for that by shifting the subscript back the appropriate
  12524. // amount. Note we only do this when the base is a single symbol.
  12525. var isOiint = group.base && group.base.type === "op" && group.base.name && (group.base.name === "\\oiint" || group.base.name === "\\oiiint");
  12526. if (base instanceof SymbolNode || isOiint) {
  12527. // $FlowFixMe
  12528. marginLeft = makeEm(-base.italic);
  12529. }
  12530. }
  12531. var supsub;
  12532. if (supm && subm) {
  12533. supShift = Math.max(supShift, minSupShift, supm.depth + 0.25 * metrics.xHeight);
  12534. subShift = Math.max(subShift, metrics.sub2);
  12535. var ruleWidth = metrics.defaultRuleThickness; // Rule 18e
  12536. var maxWidth = 4 * ruleWidth;
  12537. if (supShift - supm.depth - (subm.height - subShift) < maxWidth) {
  12538. subShift = maxWidth - (supShift - supm.depth) + subm.height;
  12539. var psi = 0.8 * metrics.xHeight - (supShift - supm.depth);
  12540. if (psi > 0) {
  12541. supShift += psi;
  12542. subShift -= psi;
  12543. }
  12544. }
  12545. var vlistElem = [{
  12546. type: "elem",
  12547. elem: subm,
  12548. shift: subShift,
  12549. marginRight: marginRight,
  12550. marginLeft: marginLeft
  12551. }, {
  12552. type: "elem",
  12553. elem: supm,
  12554. shift: -supShift,
  12555. marginRight: marginRight
  12556. }];
  12557. supsub = buildCommon.makeVList({
  12558. positionType: "individualShift",
  12559. children: vlistElem
  12560. }, options);
  12561. } else if (subm) {
  12562. // Rule 18b
  12563. subShift = Math.max(subShift, metrics.sub1, subm.height - 0.8 * metrics.xHeight);
  12564. var _vlistElem = [{
  12565. type: "elem",
  12566. elem: subm,
  12567. marginLeft: marginLeft,
  12568. marginRight: marginRight
  12569. }];
  12570. supsub = buildCommon.makeVList({
  12571. positionType: "shift",
  12572. positionData: subShift,
  12573. children: _vlistElem
  12574. }, options);
  12575. } else if (supm) {
  12576. // Rule 18c, d
  12577. supShift = Math.max(supShift, minSupShift, supm.depth + 0.25 * metrics.xHeight);
  12578. supsub = buildCommon.makeVList({
  12579. positionType: "shift",
  12580. positionData: -supShift,
  12581. children: [{
  12582. type: "elem",
  12583. elem: supm,
  12584. marginRight: marginRight
  12585. }]
  12586. }, options);
  12587. } else {
  12588. throw new Error("supsub must have either sup or sub.");
  12589. } // Wrap the supsub vlist in a span.msupsub to reset text-align.
  12590. var mclass = getTypeOfDomTree(base, "right") || "mord";
  12591. return buildCommon.makeSpan([mclass], [base, buildCommon.makeSpan(["msupsub"], [supsub])], options);
  12592. },
  12593. mathmlBuilder: function mathmlBuilder(group, options) {
  12594. // Is the inner group a relevant horizonal brace?
  12595. var isBrace = false;
  12596. var isOver;
  12597. var isSup;
  12598. if (group.base && group.base.type === "horizBrace") {
  12599. isSup = !!group.sup;
  12600. if (isSup === group.base.isOver) {
  12601. isBrace = true;
  12602. isOver = group.base.isOver;
  12603. }
  12604. }
  12605. if (group.base && (group.base.type === "op" || group.base.type === "operatorname")) {
  12606. group.base.parentIsSupSub = true;
  12607. }
  12608. var children = [buildMathML_buildGroup(group.base, options)];
  12609. if (group.sub) {
  12610. children.push(buildMathML_buildGroup(group.sub, options));
  12611. }
  12612. if (group.sup) {
  12613. children.push(buildMathML_buildGroup(group.sup, options));
  12614. }
  12615. var nodeType;
  12616. if (isBrace) {
  12617. nodeType = isOver ? "mover" : "munder";
  12618. } else if (!group.sub) {
  12619. var base = group.base;
  12620. if (base && base.type === "op" && base.limits && (options.style === src_Style.DISPLAY || base.alwaysHandleSupSub)) {
  12621. nodeType = "mover";
  12622. } else if (base && base.type === "operatorname" && base.alwaysHandleSupSub && (base.limits || options.style === src_Style.DISPLAY)) {
  12623. nodeType = "mover";
  12624. } else {
  12625. nodeType = "msup";
  12626. }
  12627. } else if (!group.sup) {
  12628. var _base = group.base;
  12629. if (_base && _base.type === "op" && _base.limits && (options.style === src_Style.DISPLAY || _base.alwaysHandleSupSub)) {
  12630. nodeType = "munder";
  12631. } else if (_base && _base.type === "operatorname" && _base.alwaysHandleSupSub && (_base.limits || options.style === src_Style.DISPLAY)) {
  12632. nodeType = "munder";
  12633. } else {
  12634. nodeType = "msub";
  12635. }
  12636. } else {
  12637. var _base2 = group.base;
  12638. if (_base2 && _base2.type === "op" && _base2.limits && options.style === src_Style.DISPLAY) {
  12639. nodeType = "munderover";
  12640. } else if (_base2 && _base2.type === "operatorname" && _base2.alwaysHandleSupSub && (options.style === src_Style.DISPLAY || _base2.limits)) {
  12641. nodeType = "munderover";
  12642. } else {
  12643. nodeType = "msubsup";
  12644. }
  12645. }
  12646. return new mathMLTree.MathNode(nodeType, children);
  12647. }
  12648. });
  12649. ;// CONCATENATED MODULE: ./src/functions/symbolsOp.js
  12650. // Operator ParseNodes created in Parser.js from symbol Groups in src/symbols.js.
  12651. defineFunctionBuilders({
  12652. type: "atom",
  12653. htmlBuilder: function htmlBuilder(group, options) {
  12654. return buildCommon.mathsym(group.text, group.mode, options, ["m" + group.family]);
  12655. },
  12656. mathmlBuilder: function mathmlBuilder(group, options) {
  12657. var node = new mathMLTree.MathNode("mo", [makeText(group.text, group.mode)]);
  12658. if (group.family === "bin") {
  12659. var variant = getVariant(group, options);
  12660. if (variant === "bold-italic") {
  12661. node.setAttribute("mathvariant", variant);
  12662. }
  12663. } else if (group.family === "punct") {
  12664. node.setAttribute("separator", "true");
  12665. } else if (group.family === "open" || group.family === "close") {
  12666. // Delims built here should not stretch vertically.
  12667. // See delimsizing.js for stretchy delims.
  12668. node.setAttribute("stretchy", "false");
  12669. }
  12670. return node;
  12671. }
  12672. });
  12673. ;// CONCATENATED MODULE: ./src/functions/symbolsOrd.js
  12674. // "mathord" and "textord" ParseNodes created in Parser.js from symbol Groups in
  12675. // src/symbols.js.
  12676. var defaultVariant = {
  12677. "mi": "italic",
  12678. "mn": "normal",
  12679. "mtext": "normal"
  12680. };
  12681. defineFunctionBuilders({
  12682. type: "mathord",
  12683. htmlBuilder: function htmlBuilder(group, options) {
  12684. return buildCommon.makeOrd(group, options, "mathord");
  12685. },
  12686. mathmlBuilder: function mathmlBuilder(group, options) {
  12687. var node = new mathMLTree.MathNode("mi", [makeText(group.text, group.mode, options)]);
  12688. var variant = getVariant(group, options) || "italic";
  12689. if (variant !== defaultVariant[node.type]) {
  12690. node.setAttribute("mathvariant", variant);
  12691. }
  12692. return node;
  12693. }
  12694. });
  12695. defineFunctionBuilders({
  12696. type: "textord",
  12697. htmlBuilder: function htmlBuilder(group, options) {
  12698. return buildCommon.makeOrd(group, options, "textord");
  12699. },
  12700. mathmlBuilder: function mathmlBuilder(group, options) {
  12701. var text = makeText(group.text, group.mode, options);
  12702. var variant = getVariant(group, options) || "normal";
  12703. var node;
  12704. if (group.mode === 'text') {
  12705. node = new mathMLTree.MathNode("mtext", [text]);
  12706. } else if (/[0-9]/.test(group.text)) {
  12707. node = new mathMLTree.MathNode("mn", [text]);
  12708. } else if (group.text === "\\prime") {
  12709. node = new mathMLTree.MathNode("mo", [text]);
  12710. } else {
  12711. node = new mathMLTree.MathNode("mi", [text]);
  12712. }
  12713. if (variant !== defaultVariant[node.type]) {
  12714. node.setAttribute("mathvariant", variant);
  12715. }
  12716. return node;
  12717. }
  12718. });
  12719. ;// CONCATENATED MODULE: ./src/functions/symbolsSpacing.js
  12720. // A map of CSS-based spacing functions to their CSS class.
  12721. var cssSpace = {
  12722. "\\nobreak": "nobreak",
  12723. "\\allowbreak": "allowbreak"
  12724. }; // A lookup table to determine whether a spacing function/symbol should be
  12725. // treated like a regular space character. If a symbol or command is a key
  12726. // in this table, then it should be a regular space character. Furthermore,
  12727. // the associated value may have a `className` specifying an extra CSS class
  12728. // to add to the created `span`.
  12729. var regularSpace = {
  12730. " ": {},
  12731. "\\ ": {},
  12732. "~": {
  12733. className: "nobreak"
  12734. },
  12735. "\\space": {},
  12736. "\\nobreakspace": {
  12737. className: "nobreak"
  12738. }
  12739. }; // ParseNode<"spacing"> created in Parser.js from the "spacing" symbol Groups in
  12740. // src/symbols.js.
  12741. defineFunctionBuilders({
  12742. type: "spacing",
  12743. htmlBuilder: function htmlBuilder(group, options) {
  12744. if (regularSpace.hasOwnProperty(group.text)) {
  12745. var className = regularSpace[group.text].className || ""; // Spaces are generated by adding an actual space. Each of these
  12746. // things has an entry in the symbols table, so these will be turned
  12747. // into appropriate outputs.
  12748. if (group.mode === "text") {
  12749. var ord = buildCommon.makeOrd(group, options, "textord");
  12750. ord.classes.push(className);
  12751. return ord;
  12752. } else {
  12753. return buildCommon.makeSpan(["mspace", className], [buildCommon.mathsym(group.text, group.mode, options)], options);
  12754. }
  12755. } else if (cssSpace.hasOwnProperty(group.text)) {
  12756. // Spaces based on just a CSS class.
  12757. return buildCommon.makeSpan(["mspace", cssSpace[group.text]], [], options);
  12758. } else {
  12759. throw new src_ParseError("Unknown type of space \"" + group.text + "\"");
  12760. }
  12761. },
  12762. mathmlBuilder: function mathmlBuilder(group, options) {
  12763. var node;
  12764. if (regularSpace.hasOwnProperty(group.text)) {
  12765. node = new mathMLTree.MathNode("mtext", [new mathMLTree.TextNode("\xA0")]);
  12766. } else if (cssSpace.hasOwnProperty(group.text)) {
  12767. // CSS-based MathML spaces (\nobreak, \allowbreak) are ignored
  12768. return new mathMLTree.MathNode("mspace");
  12769. } else {
  12770. throw new src_ParseError("Unknown type of space \"" + group.text + "\"");
  12771. }
  12772. return node;
  12773. }
  12774. });
  12775. ;// CONCATENATED MODULE: ./src/functions/tag.js
  12776. var pad = function pad() {
  12777. var padNode = new mathMLTree.MathNode("mtd", []);
  12778. padNode.setAttribute("width", "50%");
  12779. return padNode;
  12780. };
  12781. defineFunctionBuilders({
  12782. type: "tag",
  12783. mathmlBuilder: function mathmlBuilder(group, options) {
  12784. var table = new mathMLTree.MathNode("mtable", [new mathMLTree.MathNode("mtr", [pad(), new mathMLTree.MathNode("mtd", [buildExpressionRow(group.body, options)]), pad(), new mathMLTree.MathNode("mtd", [buildExpressionRow(group.tag, options)])])]);
  12785. table.setAttribute("width", "100%");
  12786. return table; // TODO: Left-aligned tags.
  12787. // Currently, the group and options passed here do not contain
  12788. // enough info to set tag alignment. `leqno` is in Settings but it is
  12789. // not passed to Options. On the HTML side, leqno is
  12790. // set by a CSS class applied in buildTree.js. That would have worked
  12791. // in MathML if browsers supported <mlabeledtr>. Since they don't, we
  12792. // need to rewrite the way this function is called.
  12793. }
  12794. });
  12795. ;// CONCATENATED MODULE: ./src/functions/text.js
  12796. // Non-mathy text, possibly in a font
  12797. var textFontFamilies = {
  12798. "\\text": undefined,
  12799. "\\textrm": "textrm",
  12800. "\\textsf": "textsf",
  12801. "\\texttt": "texttt",
  12802. "\\textnormal": "textrm"
  12803. };
  12804. var textFontWeights = {
  12805. "\\textbf": "textbf",
  12806. "\\textmd": "textmd"
  12807. };
  12808. var textFontShapes = {
  12809. "\\textit": "textit",
  12810. "\\textup": "textup"
  12811. };
  12812. var optionsWithFont = function optionsWithFont(group, options) {
  12813. var font = group.font; // Checks if the argument is a font family or a font style.
  12814. if (!font) {
  12815. return options;
  12816. } else if (textFontFamilies[font]) {
  12817. return options.withTextFontFamily(textFontFamilies[font]);
  12818. } else if (textFontWeights[font]) {
  12819. return options.withTextFontWeight(textFontWeights[font]);
  12820. } else {
  12821. return options.withTextFontShape(textFontShapes[font]);
  12822. }
  12823. };
  12824. defineFunction({
  12825. type: "text",
  12826. names: [// Font families
  12827. "\\text", "\\textrm", "\\textsf", "\\texttt", "\\textnormal", // Font weights
  12828. "\\textbf", "\\textmd", // Font Shapes
  12829. "\\textit", "\\textup"],
  12830. props: {
  12831. numArgs: 1,
  12832. argTypes: ["text"],
  12833. allowedInArgument: true,
  12834. allowedInText: true
  12835. },
  12836. handler: function handler(_ref, args) {
  12837. var parser = _ref.parser,
  12838. funcName = _ref.funcName;
  12839. var body = args[0];
  12840. return {
  12841. type: "text",
  12842. mode: parser.mode,
  12843. body: ordargument(body),
  12844. font: funcName
  12845. };
  12846. },
  12847. htmlBuilder: function htmlBuilder(group, options) {
  12848. var newOptions = optionsWithFont(group, options);
  12849. var inner = buildExpression(group.body, newOptions, true);
  12850. return buildCommon.makeSpan(["mord", "text"], inner, newOptions);
  12851. },
  12852. mathmlBuilder: function mathmlBuilder(group, options) {
  12853. var newOptions = optionsWithFont(group, options);
  12854. return buildExpressionRow(group.body, newOptions);
  12855. }
  12856. });
  12857. ;// CONCATENATED MODULE: ./src/functions/underline.js
  12858. defineFunction({
  12859. type: "underline",
  12860. names: ["\\underline"],
  12861. props: {
  12862. numArgs: 1,
  12863. allowedInText: true
  12864. },
  12865. handler: function handler(_ref, args) {
  12866. var parser = _ref.parser;
  12867. return {
  12868. type: "underline",
  12869. mode: parser.mode,
  12870. body: args[0]
  12871. };
  12872. },
  12873. htmlBuilder: function htmlBuilder(group, options) {
  12874. // Underlines are handled in the TeXbook pg 443, Rule 10.
  12875. // Build the inner group.
  12876. var innerGroup = buildGroup(group.body, options); // Create the line to go below the body
  12877. var line = buildCommon.makeLineSpan("underline-line", options); // Generate the vlist, with the appropriate kerns
  12878. var defaultRuleThickness = options.fontMetrics().defaultRuleThickness;
  12879. var vlist = buildCommon.makeVList({
  12880. positionType: "top",
  12881. positionData: innerGroup.height,
  12882. children: [{
  12883. type: "kern",
  12884. size: defaultRuleThickness
  12885. }, {
  12886. type: "elem",
  12887. elem: line
  12888. }, {
  12889. type: "kern",
  12890. size: 3 * defaultRuleThickness
  12891. }, {
  12892. type: "elem",
  12893. elem: innerGroup
  12894. }]
  12895. }, options);
  12896. return buildCommon.makeSpan(["mord", "underline"], [vlist], options);
  12897. },
  12898. mathmlBuilder: function mathmlBuilder(group, options) {
  12899. var operator = new mathMLTree.MathNode("mo", [new mathMLTree.TextNode("\u203E")]);
  12900. operator.setAttribute("stretchy", "true");
  12901. var node = new mathMLTree.MathNode("munder", [buildMathML_buildGroup(group.body, options), operator]);
  12902. node.setAttribute("accentunder", "true");
  12903. return node;
  12904. }
  12905. });
  12906. ;// CONCATENATED MODULE: ./src/functions/vcenter.js
  12907. // \vcenter: Vertically center the argument group on the math axis.
  12908. defineFunction({
  12909. type: "vcenter",
  12910. names: ["\\vcenter"],
  12911. props: {
  12912. numArgs: 1,
  12913. argTypes: ["original"],
  12914. // In LaTeX, \vcenter can act only on a box.
  12915. allowedInText: false
  12916. },
  12917. handler: function handler(_ref, args) {
  12918. var parser = _ref.parser;
  12919. return {
  12920. type: "vcenter",
  12921. mode: parser.mode,
  12922. body: args[0]
  12923. };
  12924. },
  12925. htmlBuilder: function htmlBuilder(group, options) {
  12926. var body = buildGroup(group.body, options);
  12927. var axisHeight = options.fontMetrics().axisHeight;
  12928. var dy = 0.5 * (body.height - axisHeight - (body.depth + axisHeight));
  12929. return buildCommon.makeVList({
  12930. positionType: "shift",
  12931. positionData: dy,
  12932. children: [{
  12933. type: "elem",
  12934. elem: body
  12935. }]
  12936. }, options);
  12937. },
  12938. mathmlBuilder: function mathmlBuilder(group, options) {
  12939. // There is no way to do this in MathML.
  12940. // Write a class as a breadcrumb in case some post-processor wants
  12941. // to perform a vcenter adjustment.
  12942. return new mathMLTree.MathNode("mpadded", [buildMathML_buildGroup(group.body, options)], ["vcenter"]);
  12943. }
  12944. });
  12945. ;// CONCATENATED MODULE: ./src/functions/verb.js
  12946. defineFunction({
  12947. type: "verb",
  12948. names: ["\\verb"],
  12949. props: {
  12950. numArgs: 0,
  12951. allowedInText: true
  12952. },
  12953. handler: function handler(context, args, optArgs) {
  12954. // \verb and \verb* are dealt with directly in Parser.js.
  12955. // If we end up here, it's because of a failure to match the two delimiters
  12956. // in the regex in Lexer.js. LaTeX raises the following error when \verb is
  12957. // terminated by end of line (or file).
  12958. throw new src_ParseError("\\verb ended by end of line instead of matching delimiter");
  12959. },
  12960. htmlBuilder: function htmlBuilder(group, options) {
  12961. var text = makeVerb(group);
  12962. var body = []; // \verb enters text mode and therefore is sized like \textstyle
  12963. var newOptions = options.havingStyle(options.style.text());
  12964. for (var i = 0; i < text.length; i++) {
  12965. var c = text[i];
  12966. if (c === '~') {
  12967. c = '\\textasciitilde';
  12968. }
  12969. body.push(buildCommon.makeSymbol(c, "Typewriter-Regular", group.mode, newOptions, ["mord", "texttt"]));
  12970. }
  12971. return buildCommon.makeSpan(["mord", "text"].concat(newOptions.sizingClasses(options)), buildCommon.tryCombineChars(body), newOptions);
  12972. },
  12973. mathmlBuilder: function mathmlBuilder(group, options) {
  12974. var text = new mathMLTree.TextNode(makeVerb(group));
  12975. var node = new mathMLTree.MathNode("mtext", [text]);
  12976. node.setAttribute("mathvariant", "monospace");
  12977. return node;
  12978. }
  12979. });
  12980. /**
  12981. * Converts verb group into body string.
  12982. *
  12983. * \verb* replaces each space with an open box \u2423
  12984. * \verb replaces each space with a no-break space \xA0
  12985. */
  12986. var makeVerb = function makeVerb(group) {
  12987. return group.body.replace(/ /g, group.star ? "\u2423" : '\xA0');
  12988. };
  12989. ;// CONCATENATED MODULE: ./src/functions.js
  12990. /** Include this to ensure that all functions are defined. */
  12991. var functions = _functions;
  12992. /* harmony default export */ var src_functions = (functions); // TODO(kevinb): have functions return an object and call defineFunction with
  12993. // that object in this file instead of relying on side-effects.
  12994. ;// CONCATENATED MODULE: ./src/Lexer.js
  12995. /**
  12996. * The Lexer class handles tokenizing the input in various ways. Since our
  12997. * parser expects us to be able to backtrack, the lexer allows lexing from any
  12998. * given starting point.
  12999. *
  13000. * Its main exposed function is the `lex` function, which takes a position to
  13001. * lex from and a type of token to lex. It defers to the appropriate `_innerLex`
  13002. * function.
  13003. *
  13004. * The various `_innerLex` functions perform the actual lexing of different
  13005. * kinds.
  13006. */
  13007. /* The following tokenRegex
  13008. * - matches typical whitespace (but not NBSP etc.) using its first group
  13009. * - does not match any control character \x00-\x1f except whitespace
  13010. * - does not match a bare backslash
  13011. * - matches any ASCII character except those just mentioned
  13012. * - does not match the BMP private use area \uE000-\uF8FF
  13013. * - does not match bare surrogate code units
  13014. * - matches any BMP character except for those just described
  13015. * - matches any valid Unicode surrogate pair
  13016. * - matches a backslash followed by one or more whitespace characters
  13017. * - matches a backslash followed by one or more letters then whitespace
  13018. * - matches a backslash followed by any BMP character
  13019. * Capturing groups:
  13020. * [1] regular whitespace
  13021. * [2] backslash followed by whitespace
  13022. * [3] anything else, which may include:
  13023. * [4] left character of \verb*
  13024. * [5] left character of \verb
  13025. * [6] backslash followed by word, excluding any trailing whitespace
  13026. * Just because the Lexer matches something doesn't mean it's valid input:
  13027. * If there is no matching function or symbol definition, the Parser will
  13028. * still reject the input.
  13029. */
  13030. var spaceRegexString = "[ \r\n\t]";
  13031. var controlWordRegexString = "\\\\[a-zA-Z@]+";
  13032. var controlSymbolRegexString = "\\\\[^\uD800-\uDFFF]";
  13033. var controlWordWhitespaceRegexString = "(" + controlWordRegexString + ")" + spaceRegexString + "*";
  13034. var controlSpaceRegexString = "\\\\(\n|[ \r\t]+\n?)[ \r\t]*";
  13035. var combiningDiacriticalMarkString = "[\u0300-\u036F]";
  13036. var combiningDiacriticalMarksEndRegex = new RegExp(combiningDiacriticalMarkString + "+$");
  13037. var tokenRegexString = "(" + spaceRegexString + "+)|" + ( // whitespace
  13038. controlSpaceRegexString + "|") + // \whitespace
  13039. "([!-\\[\\]-\u2027\u202A-\uD7FF\uF900-\uFFFF]" + ( // single codepoint
  13040. combiningDiacriticalMarkString + "*") + // ...plus accents
  13041. "|[\uD800-\uDBFF][\uDC00-\uDFFF]" + ( // surrogate pair
  13042. combiningDiacriticalMarkString + "*") + // ...plus accents
  13043. "|\\\\verb\\*([^]).*?\\4" + // \verb*
  13044. "|\\\\verb([^*a-zA-Z]).*?\\5" + ( // \verb unstarred
  13045. "|" + controlWordWhitespaceRegexString) + ( // \macroName + spaces
  13046. "|" + controlSymbolRegexString + ")"); // \\, \', etc.
  13047. /** Main Lexer class */
  13048. var Lexer = /*#__PURE__*/function () {
  13049. // Category codes. The lexer only supports comment characters (14) for now.
  13050. // MacroExpander additionally distinguishes active (13).
  13051. function Lexer(input, settings) {
  13052. this.input = void 0;
  13053. this.settings = void 0;
  13054. this.tokenRegex = void 0;
  13055. this.catcodes = void 0;
  13056. // Separate accents from characters
  13057. this.input = input;
  13058. this.settings = settings;
  13059. this.tokenRegex = new RegExp(tokenRegexString, 'g');
  13060. this.catcodes = {
  13061. "%": 14,
  13062. // comment character
  13063. "~": 13 // active character
  13064. };
  13065. }
  13066. var _proto = Lexer.prototype;
  13067. _proto.setCatcode = function setCatcode(char, code) {
  13068. this.catcodes[char] = code;
  13069. }
  13070. /**
  13071. * This function lexes a single token.
  13072. */
  13073. ;
  13074. _proto.lex = function lex() {
  13075. var input = this.input;
  13076. var pos = this.tokenRegex.lastIndex;
  13077. if (pos === input.length) {
  13078. return new Token("EOF", new SourceLocation(this, pos, pos));
  13079. }
  13080. var match = this.tokenRegex.exec(input);
  13081. if (match === null || match.index !== pos) {
  13082. throw new src_ParseError("Unexpected character: '" + input[pos] + "'", new Token(input[pos], new SourceLocation(this, pos, pos + 1)));
  13083. }
  13084. var text = match[6] || match[3] || (match[2] ? "\\ " : " ");
  13085. if (this.catcodes[text] === 14) {
  13086. // comment character
  13087. var nlIndex = input.indexOf('\n', this.tokenRegex.lastIndex);
  13088. if (nlIndex === -1) {
  13089. this.tokenRegex.lastIndex = input.length; // EOF
  13090. this.settings.reportNonstrict("commentAtEnd", "% comment has no terminating newline; LaTeX would " + "fail because of commenting the end of math mode (e.g. $)");
  13091. } else {
  13092. this.tokenRegex.lastIndex = nlIndex + 1;
  13093. }
  13094. return this.lex();
  13095. }
  13096. return new Token(text, new SourceLocation(this, pos, this.tokenRegex.lastIndex));
  13097. };
  13098. return Lexer;
  13099. }();
  13100. ;// CONCATENATED MODULE: ./src/Namespace.js
  13101. /**
  13102. * A `Namespace` refers to a space of nameable things like macros or lengths,
  13103. * which can be `set` either globally or local to a nested group, using an
  13104. * undo stack similar to how TeX implements this functionality.
  13105. * Performance-wise, `get` and local `set` take constant time, while global
  13106. * `set` takes time proportional to the depth of group nesting.
  13107. */
  13108. var Namespace = /*#__PURE__*/function () {
  13109. /**
  13110. * Both arguments are optional. The first argument is an object of
  13111. * built-in mappings which never change. The second argument is an object
  13112. * of initial (global-level) mappings, which will constantly change
  13113. * according to any global/top-level `set`s done.
  13114. */
  13115. function Namespace(builtins, globalMacros) {
  13116. if (builtins === void 0) {
  13117. builtins = {};
  13118. }
  13119. if (globalMacros === void 0) {
  13120. globalMacros = {};
  13121. }
  13122. this.current = void 0;
  13123. this.builtins = void 0;
  13124. this.undefStack = void 0;
  13125. this.current = globalMacros;
  13126. this.builtins = builtins;
  13127. this.undefStack = [];
  13128. }
  13129. /**
  13130. * Start a new nested group, affecting future local `set`s.
  13131. */
  13132. var _proto = Namespace.prototype;
  13133. _proto.beginGroup = function beginGroup() {
  13134. this.undefStack.push({});
  13135. }
  13136. /**
  13137. * End current nested group, restoring values before the group began.
  13138. */
  13139. ;
  13140. _proto.endGroup = function endGroup() {
  13141. if (this.undefStack.length === 0) {
  13142. throw new src_ParseError("Unbalanced namespace destruction: attempt " + "to pop global namespace; please report this as a bug");
  13143. }
  13144. var undefs = this.undefStack.pop();
  13145. for (var undef in undefs) {
  13146. if (undefs.hasOwnProperty(undef)) {
  13147. if (undefs[undef] == null) {
  13148. delete this.current[undef];
  13149. } else {
  13150. this.current[undef] = undefs[undef];
  13151. }
  13152. }
  13153. }
  13154. }
  13155. /**
  13156. * Ends all currently nested groups (if any), restoring values before the
  13157. * groups began. Useful in case of an error in the middle of parsing.
  13158. */
  13159. ;
  13160. _proto.endGroups = function endGroups() {
  13161. while (this.undefStack.length > 0) {
  13162. this.endGroup();
  13163. }
  13164. }
  13165. /**
  13166. * Detect whether `name` has a definition. Equivalent to
  13167. * `get(name) != null`.
  13168. */
  13169. ;
  13170. _proto.has = function has(name) {
  13171. return this.current.hasOwnProperty(name) || this.builtins.hasOwnProperty(name);
  13172. }
  13173. /**
  13174. * Get the current value of a name, or `undefined` if there is no value.
  13175. *
  13176. * Note: Do not use `if (namespace.get(...))` to detect whether a macro
  13177. * is defined, as the definition may be the empty string which evaluates
  13178. * to `false` in JavaScript. Use `if (namespace.get(...) != null)` or
  13179. * `if (namespace.has(...))`.
  13180. */
  13181. ;
  13182. _proto.get = function get(name) {
  13183. if (this.current.hasOwnProperty(name)) {
  13184. return this.current[name];
  13185. } else {
  13186. return this.builtins[name];
  13187. }
  13188. }
  13189. /**
  13190. * Set the current value of a name, and optionally set it globally too.
  13191. * Local set() sets the current value and (when appropriate) adds an undo
  13192. * operation to the undo stack. Global set() may change the undo
  13193. * operation at every level, so takes time linear in their number.
  13194. * A value of undefined means to delete existing definitions.
  13195. */
  13196. ;
  13197. _proto.set = function set(name, value, global) {
  13198. if (global === void 0) {
  13199. global = false;
  13200. }
  13201. if (global) {
  13202. // Global set is equivalent to setting in all groups. Simulate this
  13203. // by destroying any undos currently scheduled for this name,
  13204. // and adding an undo with the *new* value (in case it later gets
  13205. // locally reset within this environment).
  13206. for (var i = 0; i < this.undefStack.length; i++) {
  13207. delete this.undefStack[i][name];
  13208. }
  13209. if (this.undefStack.length > 0) {
  13210. this.undefStack[this.undefStack.length - 1][name] = value;
  13211. }
  13212. } else {
  13213. // Undo this set at end of this group (possibly to `undefined`),
  13214. // unless an undo is already in place, in which case that older
  13215. // value is the correct one.
  13216. var top = this.undefStack[this.undefStack.length - 1];
  13217. if (top && !top.hasOwnProperty(name)) {
  13218. top[name] = this.current[name];
  13219. }
  13220. }
  13221. if (value == null) {
  13222. delete this.current[name];
  13223. } else {
  13224. this.current[name] = value;
  13225. }
  13226. };
  13227. return Namespace;
  13228. }();
  13229. ;// CONCATENATED MODULE: ./src/macros.js
  13230. /**
  13231. * Predefined macros for KaTeX.
  13232. * This can be used to define some commands in terms of others.
  13233. */
  13234. // Export global macros object from defineMacro
  13235. var macros = _macros;
  13236. /* harmony default export */ var src_macros = (macros);
  13237. //////////////////////////////////////////////////////////////////////
  13238. // macro tools
  13239. defineMacro("\\noexpand", function (context) {
  13240. // The expansion is the token itself; but that token is interpreted
  13241. // as if its meaning were ‘\relax’ if it is a control sequence that
  13242. // would ordinarily be expanded by TeX’s expansion rules.
  13243. var t = context.popToken();
  13244. if (context.isExpandable(t.text)) {
  13245. t.noexpand = true;
  13246. t.treatAsRelax = true;
  13247. }
  13248. return {
  13249. tokens: [t],
  13250. numArgs: 0
  13251. };
  13252. });
  13253. defineMacro("\\expandafter", function (context) {
  13254. // TeX first reads the token that comes immediately after \expandafter,
  13255. // without expanding it; let’s call this token t. Then TeX reads the
  13256. // token that comes after t (and possibly more tokens, if that token
  13257. // has an argument), replacing it by its expansion. Finally TeX puts
  13258. // t back in front of that expansion.
  13259. var t = context.popToken();
  13260. context.expandOnce(true); // expand only an expandable token
  13261. return {
  13262. tokens: [t],
  13263. numArgs: 0
  13264. };
  13265. }); // LaTeX's \@firstoftwo{#1}{#2} expands to #1, skipping #2
  13266. // TeX source: \long\def\@firstoftwo#1#2{#1}
  13267. defineMacro("\\@firstoftwo", function (context) {
  13268. var args = context.consumeArgs(2);
  13269. return {
  13270. tokens: args[0],
  13271. numArgs: 0
  13272. };
  13273. }); // LaTeX's \@secondoftwo{#1}{#2} expands to #2, skipping #1
  13274. // TeX source: \long\def\@secondoftwo#1#2{#2}
  13275. defineMacro("\\@secondoftwo", function (context) {
  13276. var args = context.consumeArgs(2);
  13277. return {
  13278. tokens: args[1],
  13279. numArgs: 0
  13280. };
  13281. }); // LaTeX's \@ifnextchar{#1}{#2}{#3} looks ahead to the next (unexpanded)
  13282. // symbol that isn't a space, consuming any spaces but not consuming the
  13283. // first nonspace character. If that nonspace character matches #1, then
  13284. // the macro expands to #2; otherwise, it expands to #3.
  13285. defineMacro("\\@ifnextchar", function (context) {
  13286. var args = context.consumeArgs(3); // symbol, if, else
  13287. context.consumeSpaces();
  13288. var nextToken = context.future();
  13289. if (args[0].length === 1 && args[0][0].text === nextToken.text) {
  13290. return {
  13291. tokens: args[1],
  13292. numArgs: 0
  13293. };
  13294. } else {
  13295. return {
  13296. tokens: args[2],
  13297. numArgs: 0
  13298. };
  13299. }
  13300. }); // LaTeX's \@ifstar{#1}{#2} looks ahead to the next (unexpanded) symbol.
  13301. // If it is `*`, then it consumes the symbol, and the macro expands to #1;
  13302. // otherwise, the macro expands to #2 (without consuming the symbol).
  13303. // TeX source: \def\@ifstar#1{\@ifnextchar *{\@firstoftwo{#1}}}
  13304. defineMacro("\\@ifstar", "\\@ifnextchar *{\\@firstoftwo{#1}}"); // LaTeX's \TextOrMath{#1}{#2} expands to #1 in text mode, #2 in math mode
  13305. defineMacro("\\TextOrMath", function (context) {
  13306. var args = context.consumeArgs(2);
  13307. if (context.mode === 'text') {
  13308. return {
  13309. tokens: args[0],
  13310. numArgs: 0
  13311. };
  13312. } else {
  13313. return {
  13314. tokens: args[1],
  13315. numArgs: 0
  13316. };
  13317. }
  13318. }); // Lookup table for parsing numbers in base 8 through 16
  13319. var digitToNumber = {
  13320. "0": 0,
  13321. "1": 1,
  13322. "2": 2,
  13323. "3": 3,
  13324. "4": 4,
  13325. "5": 5,
  13326. "6": 6,
  13327. "7": 7,
  13328. "8": 8,
  13329. "9": 9,
  13330. "a": 10,
  13331. "A": 10,
  13332. "b": 11,
  13333. "B": 11,
  13334. "c": 12,
  13335. "C": 12,
  13336. "d": 13,
  13337. "D": 13,
  13338. "e": 14,
  13339. "E": 14,
  13340. "f": 15,
  13341. "F": 15
  13342. }; // TeX \char makes a literal character (catcode 12) using the following forms:
  13343. // (see The TeXBook, p. 43)
  13344. // \char123 -- decimal
  13345. // \char'123 -- octal
  13346. // \char"123 -- hex
  13347. // \char`x -- character that can be written (i.e. isn't active)
  13348. // \char`\x -- character that cannot be written (e.g. %)
  13349. // These all refer to characters from the font, so we turn them into special
  13350. // calls to a function \@char dealt with in the Parser.
  13351. defineMacro("\\char", function (context) {
  13352. var token = context.popToken();
  13353. var base;
  13354. var number = '';
  13355. if (token.text === "'") {
  13356. base = 8;
  13357. token = context.popToken();
  13358. } else if (token.text === '"') {
  13359. base = 16;
  13360. token = context.popToken();
  13361. } else if (token.text === "`") {
  13362. token = context.popToken();
  13363. if (token.text[0] === "\\") {
  13364. number = token.text.charCodeAt(1);
  13365. } else if (token.text === "EOF") {
  13366. throw new src_ParseError("\\char` missing argument");
  13367. } else {
  13368. number = token.text.charCodeAt(0);
  13369. }
  13370. } else {
  13371. base = 10;
  13372. }
  13373. if (base) {
  13374. // Parse a number in the given base, starting with first `token`.
  13375. number = digitToNumber[token.text];
  13376. if (number == null || number >= base) {
  13377. throw new src_ParseError("Invalid base-" + base + " digit " + token.text);
  13378. }
  13379. var digit;
  13380. while ((digit = digitToNumber[context.future().text]) != null && digit < base) {
  13381. number *= base;
  13382. number += digit;
  13383. context.popToken();
  13384. }
  13385. }
  13386. return "\\@char{" + number + "}";
  13387. }); // \newcommand{\macro}[args]{definition}
  13388. // \renewcommand{\macro}[args]{definition}
  13389. // TODO: Optional arguments: \newcommand{\macro}[args][default]{definition}
  13390. var newcommand = function newcommand(context, existsOK, nonexistsOK) {
  13391. var arg = context.consumeArg().tokens;
  13392. if (arg.length !== 1) {
  13393. throw new src_ParseError("\\newcommand's first argument must be a macro name");
  13394. }
  13395. var name = arg[0].text;
  13396. var exists = context.isDefined(name);
  13397. if (exists && !existsOK) {
  13398. throw new src_ParseError("\\newcommand{" + name + "} attempting to redefine " + (name + "; use \\renewcommand"));
  13399. }
  13400. if (!exists && !nonexistsOK) {
  13401. throw new src_ParseError("\\renewcommand{" + name + "} when command " + name + " " + "does not yet exist; use \\newcommand");
  13402. }
  13403. var numArgs = 0;
  13404. arg = context.consumeArg().tokens;
  13405. if (arg.length === 1 && arg[0].text === "[") {
  13406. var argText = '';
  13407. var token = context.expandNextToken();
  13408. while (token.text !== "]" && token.text !== "EOF") {
  13409. // TODO: Should properly expand arg, e.g., ignore {}s
  13410. argText += token.text;
  13411. token = context.expandNextToken();
  13412. }
  13413. if (!argText.match(/^\s*[0-9]+\s*$/)) {
  13414. throw new src_ParseError("Invalid number of arguments: " + argText);
  13415. }
  13416. numArgs = parseInt(argText);
  13417. arg = context.consumeArg().tokens;
  13418. } // Final arg is the expansion of the macro
  13419. context.macros.set(name, {
  13420. tokens: arg,
  13421. numArgs: numArgs
  13422. });
  13423. return '';
  13424. };
  13425. defineMacro("\\newcommand", function (context) {
  13426. return newcommand(context, false, true);
  13427. });
  13428. defineMacro("\\renewcommand", function (context) {
  13429. return newcommand(context, true, false);
  13430. });
  13431. defineMacro("\\providecommand", function (context) {
  13432. return newcommand(context, true, true);
  13433. }); // terminal (console) tools
  13434. defineMacro("\\message", function (context) {
  13435. var arg = context.consumeArgs(1)[0]; // eslint-disable-next-line no-console
  13436. console.log(arg.reverse().map(function (token) {
  13437. return token.text;
  13438. }).join(""));
  13439. return '';
  13440. });
  13441. defineMacro("\\errmessage", function (context) {
  13442. var arg = context.consumeArgs(1)[0]; // eslint-disable-next-line no-console
  13443. console.error(arg.reverse().map(function (token) {
  13444. return token.text;
  13445. }).join(""));
  13446. return '';
  13447. });
  13448. defineMacro("\\show", function (context) {
  13449. var tok = context.popToken();
  13450. var name = tok.text; // eslint-disable-next-line no-console
  13451. console.log(tok, context.macros.get(name), src_functions[name], src_symbols.math[name], src_symbols.text[name]);
  13452. return '';
  13453. }); //////////////////////////////////////////////////////////////////////
  13454. // Grouping
  13455. // \let\bgroup={ \let\egroup=}
  13456. defineMacro("\\bgroup", "{");
  13457. defineMacro("\\egroup", "}"); // Symbols from latex.ltx:
  13458. // \def~{\nobreakspace{}}
  13459. // \def\lq{`}
  13460. // \def\rq{'}
  13461. // \def \aa {\r a}
  13462. // \def \AA {\r A}
  13463. defineMacro("~", "\\nobreakspace");
  13464. defineMacro("\\lq", "`");
  13465. defineMacro("\\rq", "'");
  13466. defineMacro("\\aa", "\\r a");
  13467. defineMacro("\\AA", "\\r A"); // Copyright (C) and registered (R) symbols. Use raw symbol in MathML.
  13468. // \DeclareTextCommandDefault{\textcopyright}{\textcircled{c}}
  13469. // \DeclareTextCommandDefault{\textregistered}{\textcircled{%
  13470. // \check@mathfonts\fontsize\sf@size\z@\math@fontsfalse\selectfont R}}
  13471. // \DeclareRobustCommand{\copyright}{%
  13472. // \ifmmode{\nfss@text{\textcopyright}}\else\textcopyright\fi}
  13473. defineMacro("\\textcopyright", "\\html@mathml{\\textcircled{c}}{\\char`©}");
  13474. defineMacro("\\copyright", "\\TextOrMath{\\textcopyright}{\\text{\\textcopyright}}");
  13475. defineMacro("\\textregistered", "\\html@mathml{\\textcircled{\\scriptsize R}}{\\char`®}"); // Characters omitted from Unicode range 1D400–1D7FF
  13476. defineMacro("\u212C", "\\mathscr{B}"); // script
  13477. defineMacro("\u2130", "\\mathscr{E}");
  13478. defineMacro("\u2131", "\\mathscr{F}");
  13479. defineMacro("\u210B", "\\mathscr{H}");
  13480. defineMacro("\u2110", "\\mathscr{I}");
  13481. defineMacro("\u2112", "\\mathscr{L}");
  13482. defineMacro("\u2133", "\\mathscr{M}");
  13483. defineMacro("\u211B", "\\mathscr{R}");
  13484. defineMacro("\u212D", "\\mathfrak{C}"); // Fraktur
  13485. defineMacro("\u210C", "\\mathfrak{H}");
  13486. defineMacro("\u2128", "\\mathfrak{Z}"); // Define \Bbbk with a macro that works in both HTML and MathML.
  13487. defineMacro("\\Bbbk", "\\Bbb{k}"); // Unicode middle dot
  13488. // The KaTeX fonts do not contain U+00B7. Instead, \cdotp displays
  13489. // the dot at U+22C5 and gives it punct spacing.
  13490. defineMacro("\xB7", "\\cdotp"); // \llap and \rlap render their contents in text mode
  13491. defineMacro("\\llap", "\\mathllap{\\textrm{#1}}");
  13492. defineMacro("\\rlap", "\\mathrlap{\\textrm{#1}}");
  13493. defineMacro("\\clap", "\\mathclap{\\textrm{#1}}"); // \mathstrut from the TeXbook, p 360
  13494. defineMacro("\\mathstrut", "\\vphantom{(}"); // \underbar from TeXbook p 353
  13495. defineMacro("\\underbar", "\\underline{\\text{#1}}"); // \not is defined by base/fontmath.ltx via
  13496. // \DeclareMathSymbol{\not}{\mathrel}{symbols}{"36}
  13497. // It's thus treated like a \mathrel, but defined by a symbol that has zero
  13498. // width but extends to the right. We use \rlap to get that spacing.
  13499. // For MathML we write U+0338 here. buildMathML.js will then do the overlay.
  13500. defineMacro("\\not", '\\html@mathml{\\mathrel{\\mathrlap\\@not}}{\\char"338}'); // Negated symbols from base/fontmath.ltx:
  13501. // \def\neq{\not=} \let\ne=\neq
  13502. // \DeclareRobustCommand
  13503. // \notin{\mathrel{\m@th\mathpalette\c@ncel\in}}
  13504. // \def\c@ncel#1#2{\m@th\ooalign{$\hfil#1\mkern1mu/\hfil$\crcr$#1#2$}}
  13505. defineMacro("\\neq", "\\html@mathml{\\mathrel{\\not=}}{\\mathrel{\\char`≠}}");
  13506. defineMacro("\\ne", "\\neq");
  13507. defineMacro("\u2260", "\\neq");
  13508. defineMacro("\\notin", "\\html@mathml{\\mathrel{{\\in}\\mathllap{/\\mskip1mu}}}" + "{\\mathrel{\\char`∉}}");
  13509. defineMacro("\u2209", "\\notin"); // Unicode stacked relations
  13510. defineMacro("\u2258", "\\html@mathml{" + "\\mathrel{=\\kern{-1em}\\raisebox{0.4em}{$\\scriptsize\\frown$}}" + "}{\\mathrel{\\char`\u2258}}");
  13511. defineMacro("\u2259", "\\html@mathml{\\stackrel{\\tiny\\wedge}{=}}{\\mathrel{\\char`\u2258}}");
  13512. defineMacro("\u225A", "\\html@mathml{\\stackrel{\\tiny\\vee}{=}}{\\mathrel{\\char`\u225A}}");
  13513. defineMacro("\u225B", "\\html@mathml{\\stackrel{\\scriptsize\\star}{=}}" + "{\\mathrel{\\char`\u225B}}");
  13514. defineMacro("\u225D", "\\html@mathml{\\stackrel{\\tiny\\mathrm{def}}{=}}" + "{\\mathrel{\\char`\u225D}}");
  13515. defineMacro("\u225E", "\\html@mathml{\\stackrel{\\tiny\\mathrm{m}}{=}}" + "{\\mathrel{\\char`\u225E}}");
  13516. defineMacro("\u225F", "\\html@mathml{\\stackrel{\\tiny?}{=}}{\\mathrel{\\char`\u225F}}"); // Misc Unicode
  13517. defineMacro("\u27C2", "\\perp");
  13518. defineMacro("\u203C", "\\mathclose{!\\mkern-0.8mu!}");
  13519. defineMacro("\u220C", "\\notni");
  13520. defineMacro("\u231C", "\\ulcorner");
  13521. defineMacro("\u231D", "\\urcorner");
  13522. defineMacro("\u231E", "\\llcorner");
  13523. defineMacro("\u231F", "\\lrcorner");
  13524. defineMacro("\xA9", "\\copyright");
  13525. defineMacro("\xAE", "\\textregistered");
  13526. defineMacro("\uFE0F", "\\textregistered"); // The KaTeX fonts have corners at codepoints that don't match Unicode.
  13527. // For MathML purposes, use the Unicode code point.
  13528. defineMacro("\\ulcorner", "\\html@mathml{\\@ulcorner}{\\mathop{\\char\"231c}}");
  13529. defineMacro("\\urcorner", "\\html@mathml{\\@urcorner}{\\mathop{\\char\"231d}}");
  13530. defineMacro("\\llcorner", "\\html@mathml{\\@llcorner}{\\mathop{\\char\"231e}}");
  13531. defineMacro("\\lrcorner", "\\html@mathml{\\@lrcorner}{\\mathop{\\char\"231f}}"); //////////////////////////////////////////////////////////////////////
  13532. // LaTeX_2ε
  13533. // \vdots{\vbox{\baselineskip4\p@ \lineskiplimit\z@
  13534. // \kern6\p@\hbox{.}\hbox{.}\hbox{.}}}
  13535. // We'll call \varvdots, which gets a glyph from symbols.js.
  13536. // The zero-width rule gets us an equivalent to the vertical 6pt kern.
  13537. defineMacro("\\vdots", "\\mathord{\\varvdots\\rule{0pt}{15pt}}");
  13538. defineMacro("\u22EE", "\\vdots"); //////////////////////////////////////////////////////////////////////
  13539. // amsmath.sty
  13540. // http://mirrors.concertpass.com/tex-archive/macros/latex/required/amsmath/amsmath.pdf
  13541. // Italic Greek capital letters. AMS defines these with \DeclareMathSymbol,
  13542. // but they are equivalent to \mathit{\Letter}.
  13543. defineMacro("\\varGamma", "\\mathit{\\Gamma}");
  13544. defineMacro("\\varDelta", "\\mathit{\\Delta}");
  13545. defineMacro("\\varTheta", "\\mathit{\\Theta}");
  13546. defineMacro("\\varLambda", "\\mathit{\\Lambda}");
  13547. defineMacro("\\varXi", "\\mathit{\\Xi}");
  13548. defineMacro("\\varPi", "\\mathit{\\Pi}");
  13549. defineMacro("\\varSigma", "\\mathit{\\Sigma}");
  13550. defineMacro("\\varUpsilon", "\\mathit{\\Upsilon}");
  13551. defineMacro("\\varPhi", "\\mathit{\\Phi}");
  13552. defineMacro("\\varPsi", "\\mathit{\\Psi}");
  13553. defineMacro("\\varOmega", "\\mathit{\\Omega}"); //\newcommand{\substack}[1]{\subarray{c}#1\endsubarray}
  13554. defineMacro("\\substack", "\\begin{subarray}{c}#1\\end{subarray}"); // \renewcommand{\colon}{\nobreak\mskip2mu\mathpunct{}\nonscript
  13555. // \mkern-\thinmuskip{:}\mskip6muplus1mu\relax}
  13556. defineMacro("\\colon", "\\nobreak\\mskip2mu\\mathpunct{}" + "\\mathchoice{\\mkern-3mu}{\\mkern-3mu}{}{}{:}\\mskip6mu\\relax"); // \newcommand{\boxed}[1]{\fbox{\m@th$\displaystyle#1$}}
  13557. defineMacro("\\boxed", "\\fbox{$\\displaystyle{#1}$}"); // \def\iff{\DOTSB\;\Longleftrightarrow\;}
  13558. // \def\implies{\DOTSB\;\Longrightarrow\;}
  13559. // \def\impliedby{\DOTSB\;\Longleftarrow\;}
  13560. defineMacro("\\iff", "\\DOTSB\\;\\Longleftrightarrow\\;");
  13561. defineMacro("\\implies", "\\DOTSB\\;\\Longrightarrow\\;");
  13562. defineMacro("\\impliedby", "\\DOTSB\\;\\Longleftarrow\\;"); // AMSMath's automatic \dots, based on \mdots@@ macro.
  13563. var dotsByToken = {
  13564. ',': '\\dotsc',
  13565. '\\not': '\\dotsb',
  13566. // \keybin@ checks for the following:
  13567. '+': '\\dotsb',
  13568. '=': '\\dotsb',
  13569. '<': '\\dotsb',
  13570. '>': '\\dotsb',
  13571. '-': '\\dotsb',
  13572. '*': '\\dotsb',
  13573. ':': '\\dotsb',
  13574. // Symbols whose definition starts with \DOTSB:
  13575. '\\DOTSB': '\\dotsb',
  13576. '\\coprod': '\\dotsb',
  13577. '\\bigvee': '\\dotsb',
  13578. '\\bigwedge': '\\dotsb',
  13579. '\\biguplus': '\\dotsb',
  13580. '\\bigcap': '\\dotsb',
  13581. '\\bigcup': '\\dotsb',
  13582. '\\prod': '\\dotsb',
  13583. '\\sum': '\\dotsb',
  13584. '\\bigotimes': '\\dotsb',
  13585. '\\bigoplus': '\\dotsb',
  13586. '\\bigodot': '\\dotsb',
  13587. '\\bigsqcup': '\\dotsb',
  13588. '\\And': '\\dotsb',
  13589. '\\longrightarrow': '\\dotsb',
  13590. '\\Longrightarrow': '\\dotsb',
  13591. '\\longleftarrow': '\\dotsb',
  13592. '\\Longleftarrow': '\\dotsb',
  13593. '\\longleftrightarrow': '\\dotsb',
  13594. '\\Longleftrightarrow': '\\dotsb',
  13595. '\\mapsto': '\\dotsb',
  13596. '\\longmapsto': '\\dotsb',
  13597. '\\hookrightarrow': '\\dotsb',
  13598. '\\doteq': '\\dotsb',
  13599. // Symbols whose definition starts with \mathbin:
  13600. '\\mathbin': '\\dotsb',
  13601. // Symbols whose definition starts with \mathrel:
  13602. '\\mathrel': '\\dotsb',
  13603. '\\relbar': '\\dotsb',
  13604. '\\Relbar': '\\dotsb',
  13605. '\\xrightarrow': '\\dotsb',
  13606. '\\xleftarrow': '\\dotsb',
  13607. // Symbols whose definition starts with \DOTSI:
  13608. '\\DOTSI': '\\dotsi',
  13609. '\\int': '\\dotsi',
  13610. '\\oint': '\\dotsi',
  13611. '\\iint': '\\dotsi',
  13612. '\\iiint': '\\dotsi',
  13613. '\\iiiint': '\\dotsi',
  13614. '\\idotsint': '\\dotsi',
  13615. // Symbols whose definition starts with \DOTSX:
  13616. '\\DOTSX': '\\dotsx'
  13617. };
  13618. defineMacro("\\dots", function (context) {
  13619. // TODO: If used in text mode, should expand to \textellipsis.
  13620. // However, in KaTeX, \textellipsis and \ldots behave the same
  13621. // (in text mode), and it's unlikely we'd see any of the math commands
  13622. // that affect the behavior of \dots when in text mode. So fine for now
  13623. // (until we support \ifmmode ... \else ... \fi).
  13624. var thedots = '\\dotso';
  13625. var next = context.expandAfterFuture().text;
  13626. if (next in dotsByToken) {
  13627. thedots = dotsByToken[next];
  13628. } else if (next.substr(0, 4) === '\\not') {
  13629. thedots = '\\dotsb';
  13630. } else if (next in src_symbols.math) {
  13631. if (utils.contains(['bin', 'rel'], src_symbols.math[next].group)) {
  13632. thedots = '\\dotsb';
  13633. }
  13634. }
  13635. return thedots;
  13636. });
  13637. var spaceAfterDots = {
  13638. // \rightdelim@ checks for the following:
  13639. ')': true,
  13640. ']': true,
  13641. '\\rbrack': true,
  13642. '\\}': true,
  13643. '\\rbrace': true,
  13644. '\\rangle': true,
  13645. '\\rceil': true,
  13646. '\\rfloor': true,
  13647. '\\rgroup': true,
  13648. '\\rmoustache': true,
  13649. '\\right': true,
  13650. '\\bigr': true,
  13651. '\\biggr': true,
  13652. '\\Bigr': true,
  13653. '\\Biggr': true,
  13654. // \extra@ also tests for the following:
  13655. '$': true,
  13656. // \extrap@ checks for the following:
  13657. ';': true,
  13658. '.': true,
  13659. ',': true
  13660. };
  13661. defineMacro("\\dotso", function (context) {
  13662. var next = context.future().text;
  13663. if (next in spaceAfterDots) {
  13664. return "\\ldots\\,";
  13665. } else {
  13666. return "\\ldots";
  13667. }
  13668. });
  13669. defineMacro("\\dotsc", function (context) {
  13670. var next = context.future().text; // \dotsc uses \extra@ but not \extrap@, instead specially checking for
  13671. // ';' and '.', but doesn't check for ','.
  13672. if (next in spaceAfterDots && next !== ',') {
  13673. return "\\ldots\\,";
  13674. } else {
  13675. return "\\ldots";
  13676. }
  13677. });
  13678. defineMacro("\\cdots", function (context) {
  13679. var next = context.future().text;
  13680. if (next in spaceAfterDots) {
  13681. return "\\@cdots\\,";
  13682. } else {
  13683. return "\\@cdots";
  13684. }
  13685. });
  13686. defineMacro("\\dotsb", "\\cdots");
  13687. defineMacro("\\dotsm", "\\cdots");
  13688. defineMacro("\\dotsi", "\\!\\cdots"); // amsmath doesn't actually define \dotsx, but \dots followed by a macro
  13689. // starting with \DOTSX implies \dotso, and then \extra@ detects this case
  13690. // and forces the added `\,`.
  13691. defineMacro("\\dotsx", "\\ldots\\,"); // \let\DOTSI\relax
  13692. // \let\DOTSB\relax
  13693. // \let\DOTSX\relax
  13694. defineMacro("\\DOTSI", "\\relax");
  13695. defineMacro("\\DOTSB", "\\relax");
  13696. defineMacro("\\DOTSX", "\\relax"); // Spacing, based on amsmath.sty's override of LaTeX defaults
  13697. // \DeclareRobustCommand{\tmspace}[3]{%
  13698. // \ifmmode\mskip#1#2\else\kern#1#3\fi\relax}
  13699. defineMacro("\\tmspace", "\\TextOrMath{\\kern#1#3}{\\mskip#1#2}\\relax"); // \renewcommand{\,}{\tmspace+\thinmuskip{.1667em}}
  13700. // TODO: math mode should use \thinmuskip
  13701. defineMacro("\\,", "\\tmspace+{3mu}{.1667em}"); // \let\thinspace\,
  13702. defineMacro("\\thinspace", "\\,"); // \def\>{\mskip\medmuskip}
  13703. // \renewcommand{\:}{\tmspace+\medmuskip{.2222em}}
  13704. // TODO: \> and math mode of \: should use \medmuskip = 4mu plus 2mu minus 4mu
  13705. defineMacro("\\>", "\\mskip{4mu}");
  13706. defineMacro("\\:", "\\tmspace+{4mu}{.2222em}"); // \let\medspace\:
  13707. defineMacro("\\medspace", "\\:"); // \renewcommand{\;}{\tmspace+\thickmuskip{.2777em}}
  13708. // TODO: math mode should use \thickmuskip = 5mu plus 5mu
  13709. defineMacro("\\;", "\\tmspace+{5mu}{.2777em}"); // \let\thickspace\;
  13710. defineMacro("\\thickspace", "\\;"); // \renewcommand{\!}{\tmspace-\thinmuskip{.1667em}}
  13711. // TODO: math mode should use \thinmuskip
  13712. defineMacro("\\!", "\\tmspace-{3mu}{.1667em}"); // \let\negthinspace\!
  13713. defineMacro("\\negthinspace", "\\!"); // \newcommand{\negmedspace}{\tmspace-\medmuskip{.2222em}}
  13714. // TODO: math mode should use \medmuskip
  13715. defineMacro("\\negmedspace", "\\tmspace-{4mu}{.2222em}"); // \newcommand{\negthickspace}{\tmspace-\thickmuskip{.2777em}}
  13716. // TODO: math mode should use \thickmuskip
  13717. defineMacro("\\negthickspace", "\\tmspace-{5mu}{.277em}"); // \def\enspace{\kern.5em }
  13718. defineMacro("\\enspace", "\\kern.5em "); // \def\enskip{\hskip.5em\relax}
  13719. defineMacro("\\enskip", "\\hskip.5em\\relax"); // \def\quad{\hskip1em\relax}
  13720. defineMacro("\\quad", "\\hskip1em\\relax"); // \def\qquad{\hskip2em\relax}
  13721. defineMacro("\\qquad", "\\hskip2em\\relax"); // \tag@in@display form of \tag
  13722. defineMacro("\\tag", "\\@ifstar\\tag@literal\\tag@paren");
  13723. defineMacro("\\tag@paren", "\\tag@literal{({#1})}");
  13724. defineMacro("\\tag@literal", function (context) {
  13725. if (context.macros.get("\\df@tag")) {
  13726. throw new src_ParseError("Multiple \\tag");
  13727. }
  13728. return "\\gdef\\df@tag{\\text{#1}}";
  13729. }); // \renewcommand{\bmod}{\nonscript\mskip-\medmuskip\mkern5mu\mathbin
  13730. // {\operator@font mod}\penalty900
  13731. // \mkern5mu\nonscript\mskip-\medmuskip}
  13732. // \newcommand{\pod}[1]{\allowbreak
  13733. // \if@display\mkern18mu\else\mkern8mu\fi(#1)}
  13734. // \renewcommand{\pmod}[1]{\pod{{\operator@font mod}\mkern6mu#1}}
  13735. // \newcommand{\mod}[1]{\allowbreak\if@display\mkern18mu
  13736. // \else\mkern12mu\fi{\operator@font mod}\,\,#1}
  13737. // TODO: math mode should use \medmuskip = 4mu plus 2mu minus 4mu
  13738. defineMacro("\\bmod", "\\mathchoice{\\mskip1mu}{\\mskip1mu}{\\mskip5mu}{\\mskip5mu}" + "\\mathbin{\\rm mod}" + "\\mathchoice{\\mskip1mu}{\\mskip1mu}{\\mskip5mu}{\\mskip5mu}");
  13739. defineMacro("\\pod", "\\allowbreak" + "\\mathchoice{\\mkern18mu}{\\mkern8mu}{\\mkern8mu}{\\mkern8mu}(#1)");
  13740. defineMacro("\\pmod", "\\pod{{\\rm mod}\\mkern6mu#1}");
  13741. defineMacro("\\mod", "\\allowbreak" + "\\mathchoice{\\mkern18mu}{\\mkern12mu}{\\mkern12mu}{\\mkern12mu}" + "{\\rm mod}\\,\\,#1"); // \pmb -- A simulation of bold.
  13742. // The version in ambsy.sty works by typesetting three copies of the argument
  13743. // with small offsets. We use two copies. We omit the vertical offset because
  13744. // of rendering problems that makeVList encounters in Safari.
  13745. defineMacro("\\pmb", "\\html@mathml{" + "\\@binrel{#1}{\\mathrlap{#1}\\kern0.5px#1}}" + "{\\mathbf{#1}}"); //////////////////////////////////////////////////////////////////////
  13746. // LaTeX source2e
  13747. // \expandafter\let\expandafter\@normalcr
  13748. // \csname\expandafter\@gobble\string\\ \endcsname
  13749. // \DeclareRobustCommand\newline{\@normalcr\relax}
  13750. defineMacro("\\newline", "\\\\\\relax"); // \def\TeX{T\kern-.1667em\lower.5ex\hbox{E}\kern-.125emX\@}
  13751. // TODO: Doesn't normally work in math mode because \@ fails. KaTeX doesn't
  13752. // support \@ yet, so that's omitted, and we add \text so that the result
  13753. // doesn't look funny in math mode.
  13754. defineMacro("\\TeX", "\\textrm{\\html@mathml{" + "T\\kern-.1667em\\raisebox{-.5ex}{E}\\kern-.125emX" + "}{TeX}}"); // \DeclareRobustCommand{\LaTeX}{L\kern-.36em%
  13755. // {\sbox\z@ T%
  13756. // \vbox to\ht\z@{\hbox{\check@mathfonts
  13757. // \fontsize\sf@size\z@
  13758. // \math@fontsfalse\selectfont
  13759. // A}%
  13760. // \vss}%
  13761. // }%
  13762. // \kern-.15em%
  13763. // \TeX}
  13764. // This code aligns the top of the A with the T (from the perspective of TeX's
  13765. // boxes, though visually the A appears to extend above slightly).
  13766. // We compute the corresponding \raisebox when A is rendered in \normalsize
  13767. // \scriptstyle, which has a scale factor of 0.7 (see Options.js).
  13768. var latexRaiseA = makeEm(fontMetricsData["Main-Regular"]["T".charCodeAt(0)][1] - 0.7 * fontMetricsData["Main-Regular"]["A".charCodeAt(0)][1]);
  13769. defineMacro("\\LaTeX", "\\textrm{\\html@mathml{" + ("L\\kern-.36em\\raisebox{" + latexRaiseA + "}{\\scriptstyle A}") + "\\kern-.15em\\TeX}{LaTeX}}"); // New KaTeX logo based on tweaking LaTeX logo
  13770. defineMacro("\\KaTeX", "\\textrm{\\html@mathml{" + ("K\\kern-.17em\\raisebox{" + latexRaiseA + "}{\\scriptstyle A}") + "\\kern-.15em\\TeX}{KaTeX}}"); // \DeclareRobustCommand\hspace{\@ifstar\@hspacer\@hspace}
  13771. // \def\@hspace#1{\hskip #1\relax}
  13772. // \def\@hspacer#1{\vrule \@width\z@\nobreak
  13773. // \hskip #1\hskip \z@skip}
  13774. defineMacro("\\hspace", "\\@ifstar\\@hspacer\\@hspace");
  13775. defineMacro("\\@hspace", "\\hskip #1\\relax");
  13776. defineMacro("\\@hspacer", "\\rule{0pt}{0pt}\\hskip #1\\relax"); //////////////////////////////////////////////////////////////////////
  13777. // mathtools.sty
  13778. //\providecommand\ordinarycolon{:}
  13779. defineMacro("\\ordinarycolon", ":"); //\def\vcentcolon{\mathrel{\mathop\ordinarycolon}}
  13780. //TODO(edemaine): Not yet centered. Fix via \raisebox or #726
  13781. defineMacro("\\vcentcolon", "\\mathrel{\\mathop\\ordinarycolon}"); // \providecommand*\dblcolon{\vcentcolon\mathrel{\mkern-.9mu}\vcentcolon}
  13782. defineMacro("\\dblcolon", "\\html@mathml{" + "\\mathrel{\\vcentcolon\\mathrel{\\mkern-.9mu}\\vcentcolon}}" + "{\\mathop{\\char\"2237}}"); // \providecommand*\coloneqq{\vcentcolon\mathrel{\mkern-1.2mu}=}
  13783. defineMacro("\\coloneqq", "\\html@mathml{" + "\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}=}}" + "{\\mathop{\\char\"2254}}"); // ≔
  13784. // \providecommand*\Coloneqq{\dblcolon\mathrel{\mkern-1.2mu}=}
  13785. defineMacro("\\Coloneqq", "\\html@mathml{" + "\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}=}}" + "{\\mathop{\\char\"2237\\char\"3d}}"); // \providecommand*\coloneq{\vcentcolon\mathrel{\mkern-1.2mu}\mathrel{-}}
  13786. defineMacro("\\coloneq", "\\html@mathml{" + "\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}\\mathrel{-}}}" + "{\\mathop{\\char\"3a\\char\"2212}}"); // \providecommand*\Coloneq{\dblcolon\mathrel{\mkern-1.2mu}\mathrel{-}}
  13787. defineMacro("\\Coloneq", "\\html@mathml{" + "\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}\\mathrel{-}}}" + "{\\mathop{\\char\"2237\\char\"2212}}"); // \providecommand*\eqqcolon{=\mathrel{\mkern-1.2mu}\vcentcolon}
  13788. defineMacro("\\eqqcolon", "\\html@mathml{" + "\\mathrel{=\\mathrel{\\mkern-1.2mu}\\vcentcolon}}" + "{\\mathop{\\char\"2255}}"); // ≕
  13789. // \providecommand*\Eqqcolon{=\mathrel{\mkern-1.2mu}\dblcolon}
  13790. defineMacro("\\Eqqcolon", "\\html@mathml{" + "\\mathrel{=\\mathrel{\\mkern-1.2mu}\\dblcolon}}" + "{\\mathop{\\char\"3d\\char\"2237}}"); // \providecommand*\eqcolon{\mathrel{-}\mathrel{\mkern-1.2mu}\vcentcolon}
  13791. defineMacro("\\eqcolon", "\\html@mathml{" + "\\mathrel{\\mathrel{-}\\mathrel{\\mkern-1.2mu}\\vcentcolon}}" + "{\\mathop{\\char\"2239}}"); // \providecommand*\Eqcolon{\mathrel{-}\mathrel{\mkern-1.2mu}\dblcolon}
  13792. defineMacro("\\Eqcolon", "\\html@mathml{" + "\\mathrel{\\mathrel{-}\\mathrel{\\mkern-1.2mu}\\dblcolon}}" + "{\\mathop{\\char\"2212\\char\"2237}}"); // \providecommand*\colonapprox{\vcentcolon\mathrel{\mkern-1.2mu}\approx}
  13793. defineMacro("\\colonapprox", "\\html@mathml{" + "\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}\\approx}}" + "{\\mathop{\\char\"3a\\char\"2248}}"); // \providecommand*\Colonapprox{\dblcolon\mathrel{\mkern-1.2mu}\approx}
  13794. defineMacro("\\Colonapprox", "\\html@mathml{" + "\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}\\approx}}" + "{\\mathop{\\char\"2237\\char\"2248}}"); // \providecommand*\colonsim{\vcentcolon\mathrel{\mkern-1.2mu}\sim}
  13795. defineMacro("\\colonsim", "\\html@mathml{" + "\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}\\sim}}" + "{\\mathop{\\char\"3a\\char\"223c}}"); // \providecommand*\Colonsim{\dblcolon\mathrel{\mkern-1.2mu}\sim}
  13796. defineMacro("\\Colonsim", "\\html@mathml{" + "\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}\\sim}}" + "{\\mathop{\\char\"2237\\char\"223c}}"); // Some Unicode characters are implemented with macros to mathtools functions.
  13797. defineMacro("\u2237", "\\dblcolon"); // ::
  13798. defineMacro("\u2239", "\\eqcolon"); // -:
  13799. defineMacro("\u2254", "\\coloneqq"); // :=
  13800. defineMacro("\u2255", "\\eqqcolon"); // =:
  13801. defineMacro("\u2A74", "\\Coloneqq"); // ::=
  13802. //////////////////////////////////////////////////////////////////////
  13803. // colonequals.sty
  13804. // Alternate names for mathtools's macros:
  13805. defineMacro("\\ratio", "\\vcentcolon");
  13806. defineMacro("\\coloncolon", "\\dblcolon");
  13807. defineMacro("\\colonequals", "\\coloneqq");
  13808. defineMacro("\\coloncolonequals", "\\Coloneqq");
  13809. defineMacro("\\equalscolon", "\\eqqcolon");
  13810. defineMacro("\\equalscoloncolon", "\\Eqqcolon");
  13811. defineMacro("\\colonminus", "\\coloneq");
  13812. defineMacro("\\coloncolonminus", "\\Coloneq");
  13813. defineMacro("\\minuscolon", "\\eqcolon");
  13814. defineMacro("\\minuscoloncolon", "\\Eqcolon"); // \colonapprox name is same in mathtools and colonequals.
  13815. defineMacro("\\coloncolonapprox", "\\Colonapprox"); // \colonsim name is same in mathtools and colonequals.
  13816. defineMacro("\\coloncolonsim", "\\Colonsim"); // Additional macros, implemented by analogy with mathtools definitions:
  13817. defineMacro("\\simcolon", "\\mathrel{\\sim\\mathrel{\\mkern-1.2mu}\\vcentcolon}");
  13818. defineMacro("\\simcoloncolon", "\\mathrel{\\sim\\mathrel{\\mkern-1.2mu}\\dblcolon}");
  13819. defineMacro("\\approxcolon", "\\mathrel{\\approx\\mathrel{\\mkern-1.2mu}\\vcentcolon}");
  13820. defineMacro("\\approxcoloncolon", "\\mathrel{\\approx\\mathrel{\\mkern-1.2mu}\\dblcolon}"); // Present in newtxmath, pxfonts and txfonts
  13821. defineMacro("\\notni", "\\html@mathml{\\not\\ni}{\\mathrel{\\char`\u220C}}");
  13822. defineMacro("\\limsup", "\\DOTSB\\operatorname*{lim\\,sup}");
  13823. defineMacro("\\liminf", "\\DOTSB\\operatorname*{lim\\,inf}"); //////////////////////////////////////////////////////////////////////
  13824. // From amsopn.sty
  13825. defineMacro("\\injlim", "\\DOTSB\\operatorname*{inj\\,lim}");
  13826. defineMacro("\\projlim", "\\DOTSB\\operatorname*{proj\\,lim}");
  13827. defineMacro("\\varlimsup", "\\DOTSB\\operatorname*{\\overline{lim}}");
  13828. defineMacro("\\varliminf", "\\DOTSB\\operatorname*{\\underline{lim}}");
  13829. defineMacro("\\varinjlim", "\\DOTSB\\operatorname*{\\underrightarrow{lim}}");
  13830. defineMacro("\\varprojlim", "\\DOTSB\\operatorname*{\\underleftarrow{lim}}"); //////////////////////////////////////////////////////////////////////
  13831. // MathML alternates for KaTeX glyphs in the Unicode private area
  13832. defineMacro("\\gvertneqq", "\\html@mathml{\\@gvertneqq}{\u2269}");
  13833. defineMacro("\\lvertneqq", "\\html@mathml{\\@lvertneqq}{\u2268}");
  13834. defineMacro("\\ngeqq", "\\html@mathml{\\@ngeqq}{\u2271}");
  13835. defineMacro("\\ngeqslant", "\\html@mathml{\\@ngeqslant}{\u2271}");
  13836. defineMacro("\\nleqq", "\\html@mathml{\\@nleqq}{\u2270}");
  13837. defineMacro("\\nleqslant", "\\html@mathml{\\@nleqslant}{\u2270}");
  13838. defineMacro("\\nshortmid", "\\html@mathml{\\@nshortmid}{∤}");
  13839. defineMacro("\\nshortparallel", "\\html@mathml{\\@nshortparallel}{∦}");
  13840. defineMacro("\\nsubseteqq", "\\html@mathml{\\@nsubseteqq}{\u2288}");
  13841. defineMacro("\\nsupseteqq", "\\html@mathml{\\@nsupseteqq}{\u2289}");
  13842. defineMacro("\\varsubsetneq", "\\html@mathml{\\@varsubsetneq}{⊊}");
  13843. defineMacro("\\varsubsetneqq", "\\html@mathml{\\@varsubsetneqq}{⫋}");
  13844. defineMacro("\\varsupsetneq", "\\html@mathml{\\@varsupsetneq}{⊋}");
  13845. defineMacro("\\varsupsetneqq", "\\html@mathml{\\@varsupsetneqq}{⫌}");
  13846. defineMacro("\\imath", "\\html@mathml{\\@imath}{\u0131}");
  13847. defineMacro("\\jmath", "\\html@mathml{\\@jmath}{\u0237}"); //////////////////////////////////////////////////////////////////////
  13848. // stmaryrd and semantic
  13849. // The stmaryrd and semantic packages render the next four items by calling a
  13850. // glyph. Those glyphs do not exist in the KaTeX fonts. Hence the macros.
  13851. defineMacro("\\llbracket", "\\html@mathml{" + "\\mathopen{[\\mkern-3.2mu[}}" + "{\\mathopen{\\char`\u27E6}}");
  13852. defineMacro("\\rrbracket", "\\html@mathml{" + "\\mathclose{]\\mkern-3.2mu]}}" + "{\\mathclose{\\char`\u27E7}}");
  13853. defineMacro("\u27E6", "\\llbracket"); // blackboard bold [
  13854. defineMacro("\u27E7", "\\rrbracket"); // blackboard bold ]
  13855. defineMacro("\\lBrace", "\\html@mathml{" + "\\mathopen{\\{\\mkern-3.2mu[}}" + "{\\mathopen{\\char`\u2983}}");
  13856. defineMacro("\\rBrace", "\\html@mathml{" + "\\mathclose{]\\mkern-3.2mu\\}}}" + "{\\mathclose{\\char`\u2984}}");
  13857. defineMacro("\u2983", "\\lBrace"); // blackboard bold {
  13858. defineMacro("\u2984", "\\rBrace"); // blackboard bold }
  13859. // TODO: Create variable sized versions of the last two items. I believe that
  13860. // will require new font glyphs.
  13861. // The stmaryrd function `\minuso` provides a "Plimsoll" symbol that
  13862. // superimposes the characters \circ and \mathminus. Used in chemistry.
  13863. defineMacro("\\minuso", "\\mathbin{\\html@mathml{" + "{\\mathrlap{\\mathchoice{\\kern{0.145em}}{\\kern{0.145em}}" + "{\\kern{0.1015em}}{\\kern{0.0725em}}\\circ}{-}}}" + "{\\char`⦵}}");
  13864. defineMacro("⦵", "\\minuso"); //////////////////////////////////////////////////////////////////////
  13865. // texvc.sty
  13866. // The texvc package contains macros available in mediawiki pages.
  13867. // We omit the functions deprecated at
  13868. // https://en.wikipedia.org/wiki/Help:Displaying_a_formula#Deprecated_syntax
  13869. // We also omit texvc's \O, which conflicts with \text{\O}
  13870. defineMacro("\\darr", "\\downarrow");
  13871. defineMacro("\\dArr", "\\Downarrow");
  13872. defineMacro("\\Darr", "\\Downarrow");
  13873. defineMacro("\\lang", "\\langle");
  13874. defineMacro("\\rang", "\\rangle");
  13875. defineMacro("\\uarr", "\\uparrow");
  13876. defineMacro("\\uArr", "\\Uparrow");
  13877. defineMacro("\\Uarr", "\\Uparrow");
  13878. defineMacro("\\N", "\\mathbb{N}");
  13879. defineMacro("\\R", "\\mathbb{R}");
  13880. defineMacro("\\Z", "\\mathbb{Z}");
  13881. defineMacro("\\alef", "\\aleph");
  13882. defineMacro("\\alefsym", "\\aleph");
  13883. defineMacro("\\Alpha", "\\mathrm{A}");
  13884. defineMacro("\\Beta", "\\mathrm{B}");
  13885. defineMacro("\\bull", "\\bullet");
  13886. defineMacro("\\Chi", "\\mathrm{X}");
  13887. defineMacro("\\clubs", "\\clubsuit");
  13888. defineMacro("\\cnums", "\\mathbb{C}");
  13889. defineMacro("\\Complex", "\\mathbb{C}");
  13890. defineMacro("\\Dagger", "\\ddagger");
  13891. defineMacro("\\diamonds", "\\diamondsuit");
  13892. defineMacro("\\empty", "\\emptyset");
  13893. defineMacro("\\Epsilon", "\\mathrm{E}");
  13894. defineMacro("\\Eta", "\\mathrm{H}");
  13895. defineMacro("\\exist", "\\exists");
  13896. defineMacro("\\harr", "\\leftrightarrow");
  13897. defineMacro("\\hArr", "\\Leftrightarrow");
  13898. defineMacro("\\Harr", "\\Leftrightarrow");
  13899. defineMacro("\\hearts", "\\heartsuit");
  13900. defineMacro("\\image", "\\Im");
  13901. defineMacro("\\infin", "\\infty");
  13902. defineMacro("\\Iota", "\\mathrm{I}");
  13903. defineMacro("\\isin", "\\in");
  13904. defineMacro("\\Kappa", "\\mathrm{K}");
  13905. defineMacro("\\larr", "\\leftarrow");
  13906. defineMacro("\\lArr", "\\Leftarrow");
  13907. defineMacro("\\Larr", "\\Leftarrow");
  13908. defineMacro("\\lrarr", "\\leftrightarrow");
  13909. defineMacro("\\lrArr", "\\Leftrightarrow");
  13910. defineMacro("\\Lrarr", "\\Leftrightarrow");
  13911. defineMacro("\\Mu", "\\mathrm{M}");
  13912. defineMacro("\\natnums", "\\mathbb{N}");
  13913. defineMacro("\\Nu", "\\mathrm{N}");
  13914. defineMacro("\\Omicron", "\\mathrm{O}");
  13915. defineMacro("\\plusmn", "\\pm");
  13916. defineMacro("\\rarr", "\\rightarrow");
  13917. defineMacro("\\rArr", "\\Rightarrow");
  13918. defineMacro("\\Rarr", "\\Rightarrow");
  13919. defineMacro("\\real", "\\Re");
  13920. defineMacro("\\reals", "\\mathbb{R}");
  13921. defineMacro("\\Reals", "\\mathbb{R}");
  13922. defineMacro("\\Rho", "\\mathrm{P}");
  13923. defineMacro("\\sdot", "\\cdot");
  13924. defineMacro("\\sect", "\\S");
  13925. defineMacro("\\spades", "\\spadesuit");
  13926. defineMacro("\\sub", "\\subset");
  13927. defineMacro("\\sube", "\\subseteq");
  13928. defineMacro("\\supe", "\\supseteq");
  13929. defineMacro("\\Tau", "\\mathrm{T}");
  13930. defineMacro("\\thetasym", "\\vartheta"); // TODO: defineMacro("\\varcoppa", "\\\mbox{\\coppa}");
  13931. defineMacro("\\weierp", "\\wp");
  13932. defineMacro("\\Zeta", "\\mathrm{Z}"); //////////////////////////////////////////////////////////////////////
  13933. // statmath.sty
  13934. // https://ctan.math.illinois.edu/macros/latex/contrib/statmath/statmath.pdf
  13935. defineMacro("\\argmin", "\\DOTSB\\operatorname*{arg\\,min}");
  13936. defineMacro("\\argmax", "\\DOTSB\\operatorname*{arg\\,max}");
  13937. defineMacro("\\plim", "\\DOTSB\\mathop{\\operatorname{plim}}\\limits"); //////////////////////////////////////////////////////////////////////
  13938. // braket.sty
  13939. // http://ctan.math.washington.edu/tex-archive/macros/latex/contrib/braket/braket.pdf
  13940. defineMacro("\\bra", "\\mathinner{\\langle{#1}|}");
  13941. defineMacro("\\ket", "\\mathinner{|{#1}\\rangle}");
  13942. defineMacro("\\braket", "\\mathinner{\\langle{#1}\\rangle}");
  13943. defineMacro("\\Bra", "\\left\\langle#1\\right|");
  13944. defineMacro("\\Ket", "\\left|#1\\right\\rangle"); //////////////////////////////////////////////////////////////////////
  13945. // actuarialangle.dtx
  13946. defineMacro("\\angln", "{\\angl n}"); // Custom Khan Academy colors, should be moved to an optional package
  13947. defineMacro("\\blue", "\\textcolor{##6495ed}{#1}");
  13948. defineMacro("\\orange", "\\textcolor{##ffa500}{#1}");
  13949. defineMacro("\\pink", "\\textcolor{##ff00af}{#1}");
  13950. defineMacro("\\red", "\\textcolor{##df0030}{#1}");
  13951. defineMacro("\\green", "\\textcolor{##28ae7b}{#1}");
  13952. defineMacro("\\gray", "\\textcolor{gray}{#1}");
  13953. defineMacro("\\purple", "\\textcolor{##9d38bd}{#1}");
  13954. defineMacro("\\blueA", "\\textcolor{##ccfaff}{#1}");
  13955. defineMacro("\\blueB", "\\textcolor{##80f6ff}{#1}");
  13956. defineMacro("\\blueC", "\\textcolor{##63d9ea}{#1}");
  13957. defineMacro("\\blueD", "\\textcolor{##11accd}{#1}");
  13958. defineMacro("\\blueE", "\\textcolor{##0c7f99}{#1}");
  13959. defineMacro("\\tealA", "\\textcolor{##94fff5}{#1}");
  13960. defineMacro("\\tealB", "\\textcolor{##26edd5}{#1}");
  13961. defineMacro("\\tealC", "\\textcolor{##01d1c1}{#1}");
  13962. defineMacro("\\tealD", "\\textcolor{##01a995}{#1}");
  13963. defineMacro("\\tealE", "\\textcolor{##208170}{#1}");
  13964. defineMacro("\\greenA", "\\textcolor{##b6ffb0}{#1}");
  13965. defineMacro("\\greenB", "\\textcolor{##8af281}{#1}");
  13966. defineMacro("\\greenC", "\\textcolor{##74cf70}{#1}");
  13967. defineMacro("\\greenD", "\\textcolor{##1fab54}{#1}");
  13968. defineMacro("\\greenE", "\\textcolor{##0d923f}{#1}");
  13969. defineMacro("\\goldA", "\\textcolor{##ffd0a9}{#1}");
  13970. defineMacro("\\goldB", "\\textcolor{##ffbb71}{#1}");
  13971. defineMacro("\\goldC", "\\textcolor{##ff9c39}{#1}");
  13972. defineMacro("\\goldD", "\\textcolor{##e07d10}{#1}");
  13973. defineMacro("\\goldE", "\\textcolor{##a75a05}{#1}");
  13974. defineMacro("\\redA", "\\textcolor{##fca9a9}{#1}");
  13975. defineMacro("\\redB", "\\textcolor{##ff8482}{#1}");
  13976. defineMacro("\\redC", "\\textcolor{##f9685d}{#1}");
  13977. defineMacro("\\redD", "\\textcolor{##e84d39}{#1}");
  13978. defineMacro("\\redE", "\\textcolor{##bc2612}{#1}");
  13979. defineMacro("\\maroonA", "\\textcolor{##ffbde0}{#1}");
  13980. defineMacro("\\maroonB", "\\textcolor{##ff92c6}{#1}");
  13981. defineMacro("\\maroonC", "\\textcolor{##ed5fa6}{#1}");
  13982. defineMacro("\\maroonD", "\\textcolor{##ca337c}{#1}");
  13983. defineMacro("\\maroonE", "\\textcolor{##9e034e}{#1}");
  13984. defineMacro("\\purpleA", "\\textcolor{##ddd7ff}{#1}");
  13985. defineMacro("\\purpleB", "\\textcolor{##c6b9fc}{#1}");
  13986. defineMacro("\\purpleC", "\\textcolor{##aa87ff}{#1}");
  13987. defineMacro("\\purpleD", "\\textcolor{##7854ab}{#1}");
  13988. defineMacro("\\purpleE", "\\textcolor{##543b78}{#1}");
  13989. defineMacro("\\mintA", "\\textcolor{##f5f9e8}{#1}");
  13990. defineMacro("\\mintB", "\\textcolor{##edf2df}{#1}");
  13991. defineMacro("\\mintC", "\\textcolor{##e0e5cc}{#1}");
  13992. defineMacro("\\grayA", "\\textcolor{##f6f7f7}{#1}");
  13993. defineMacro("\\grayB", "\\textcolor{##f0f1f2}{#1}");
  13994. defineMacro("\\grayC", "\\textcolor{##e3e5e6}{#1}");
  13995. defineMacro("\\grayD", "\\textcolor{##d6d8da}{#1}");
  13996. defineMacro("\\grayE", "\\textcolor{##babec2}{#1}");
  13997. defineMacro("\\grayF", "\\textcolor{##888d93}{#1}");
  13998. defineMacro("\\grayG", "\\textcolor{##626569}{#1}");
  13999. defineMacro("\\grayH", "\\textcolor{##3b3e40}{#1}");
  14000. defineMacro("\\grayI", "\\textcolor{##21242c}{#1}");
  14001. defineMacro("\\kaBlue", "\\textcolor{##314453}{#1}");
  14002. defineMacro("\\kaGreen", "\\textcolor{##71B307}{#1}");
  14003. ;// CONCATENATED MODULE: ./src/MacroExpander.js
  14004. /**
  14005. * This file contains the gullet where macros are expanded
  14006. * until only non-macro tokens remain.
  14007. */
  14008. // List of commands that act like macros but aren't defined as a macro,
  14009. // function, or symbol. Used in `isDefined`.
  14010. var implicitCommands = {
  14011. "^": true,
  14012. // Parser.js
  14013. "_": true,
  14014. // Parser.js
  14015. "\\limits": true,
  14016. // Parser.js
  14017. "\\nolimits": true // Parser.js
  14018. };
  14019. var MacroExpander = /*#__PURE__*/function () {
  14020. function MacroExpander(input, settings, mode) {
  14021. this.settings = void 0;
  14022. this.expansionCount = void 0;
  14023. this.lexer = void 0;
  14024. this.macros = void 0;
  14025. this.stack = void 0;
  14026. this.mode = void 0;
  14027. this.settings = settings;
  14028. this.expansionCount = 0;
  14029. this.feed(input); // Make new global namespace
  14030. this.macros = new Namespace(src_macros, settings.macros);
  14031. this.mode = mode;
  14032. this.stack = []; // contains tokens in REVERSE order
  14033. }
  14034. /**
  14035. * Feed a new input string to the same MacroExpander
  14036. * (with existing macros etc.).
  14037. */
  14038. var _proto = MacroExpander.prototype;
  14039. _proto.feed = function feed(input) {
  14040. this.lexer = new Lexer(input, this.settings);
  14041. }
  14042. /**
  14043. * Switches between "text" and "math" modes.
  14044. */
  14045. ;
  14046. _proto.switchMode = function switchMode(newMode) {
  14047. this.mode = newMode;
  14048. }
  14049. /**
  14050. * Start a new group nesting within all namespaces.
  14051. */
  14052. ;
  14053. _proto.beginGroup = function beginGroup() {
  14054. this.macros.beginGroup();
  14055. }
  14056. /**
  14057. * End current group nesting within all namespaces.
  14058. */
  14059. ;
  14060. _proto.endGroup = function endGroup() {
  14061. this.macros.endGroup();
  14062. }
  14063. /**
  14064. * Ends all currently nested groups (if any), restoring values before the
  14065. * groups began. Useful in case of an error in the middle of parsing.
  14066. */
  14067. ;
  14068. _proto.endGroups = function endGroups() {
  14069. this.macros.endGroups();
  14070. }
  14071. /**
  14072. * Returns the topmost token on the stack, without expanding it.
  14073. * Similar in behavior to TeX's `\futurelet`.
  14074. */
  14075. ;
  14076. _proto.future = function future() {
  14077. if (this.stack.length === 0) {
  14078. this.pushToken(this.lexer.lex());
  14079. }
  14080. return this.stack[this.stack.length - 1];
  14081. }
  14082. /**
  14083. * Remove and return the next unexpanded token.
  14084. */
  14085. ;
  14086. _proto.popToken = function popToken() {
  14087. this.future(); // ensure non-empty stack
  14088. return this.stack.pop();
  14089. }
  14090. /**
  14091. * Add a given token to the token stack. In particular, this get be used
  14092. * to put back a token returned from one of the other methods.
  14093. */
  14094. ;
  14095. _proto.pushToken = function pushToken(token) {
  14096. this.stack.push(token);
  14097. }
  14098. /**
  14099. * Append an array of tokens to the token stack.
  14100. */
  14101. ;
  14102. _proto.pushTokens = function pushTokens(tokens) {
  14103. var _this$stack;
  14104. (_this$stack = this.stack).push.apply(_this$stack, tokens);
  14105. }
  14106. /**
  14107. * Find an macro argument without expanding tokens and append the array of
  14108. * tokens to the token stack. Uses Token as a container for the result.
  14109. */
  14110. ;
  14111. _proto.scanArgument = function scanArgument(isOptional) {
  14112. var start;
  14113. var end;
  14114. var tokens;
  14115. if (isOptional) {
  14116. this.consumeSpaces(); // \@ifnextchar gobbles any space following it
  14117. if (this.future().text !== "[") {
  14118. return null;
  14119. }
  14120. start = this.popToken(); // don't include [ in tokens
  14121. var _this$consumeArg = this.consumeArg(["]"]);
  14122. tokens = _this$consumeArg.tokens;
  14123. end = _this$consumeArg.end;
  14124. } else {
  14125. var _this$consumeArg2 = this.consumeArg();
  14126. tokens = _this$consumeArg2.tokens;
  14127. start = _this$consumeArg2.start;
  14128. end = _this$consumeArg2.end;
  14129. } // indicate the end of an argument
  14130. this.pushToken(new Token("EOF", end.loc));
  14131. this.pushTokens(tokens);
  14132. return start.range(end, "");
  14133. }
  14134. /**
  14135. * Consume all following space tokens, without expansion.
  14136. */
  14137. ;
  14138. _proto.consumeSpaces = function consumeSpaces() {
  14139. for (;;) {
  14140. var token = this.future();
  14141. if (token.text === " ") {
  14142. this.stack.pop();
  14143. } else {
  14144. break;
  14145. }
  14146. }
  14147. }
  14148. /**
  14149. * Consume an argument from the token stream, and return the resulting array
  14150. * of tokens and start/end token.
  14151. */
  14152. ;
  14153. _proto.consumeArg = function consumeArg(delims) {
  14154. // The argument for a delimited parameter is the shortest (possibly
  14155. // empty) sequence of tokens with properly nested {...} groups that is
  14156. // followed ... by this particular list of non-parameter tokens.
  14157. // The argument for an undelimited parameter is the next nonblank
  14158. // token, unless that token is ‘{’, when the argument will be the
  14159. // entire {...} group that follows.
  14160. var tokens = [];
  14161. var isDelimited = delims && delims.length > 0;
  14162. if (!isDelimited) {
  14163. // Ignore spaces between arguments. As the TeXbook says:
  14164. // "After you have said ‘\def\row#1#2{...}’, you are allowed to
  14165. // put spaces between the arguments (e.g., ‘\row x n’), because
  14166. // TeX doesn’t use single spaces as undelimited arguments."
  14167. this.consumeSpaces();
  14168. }
  14169. var start = this.future();
  14170. var tok;
  14171. var depth = 0;
  14172. var match = 0;
  14173. do {
  14174. tok = this.popToken();
  14175. tokens.push(tok);
  14176. if (tok.text === "{") {
  14177. ++depth;
  14178. } else if (tok.text === "}") {
  14179. --depth;
  14180. if (depth === -1) {
  14181. throw new src_ParseError("Extra }", tok);
  14182. }
  14183. } else if (tok.text === "EOF") {
  14184. throw new src_ParseError("Unexpected end of input in a macro argument" + ", expected '" + (delims && isDelimited ? delims[match] : "}") + "'", tok);
  14185. }
  14186. if (delims && isDelimited) {
  14187. if ((depth === 0 || depth === 1 && delims[match] === "{") && tok.text === delims[match]) {
  14188. ++match;
  14189. if (match === delims.length) {
  14190. // don't include delims in tokens
  14191. tokens.splice(-match, match);
  14192. break;
  14193. }
  14194. } else {
  14195. match = 0;
  14196. }
  14197. }
  14198. } while (depth !== 0 || isDelimited); // If the argument found ... has the form ‘{<nested tokens>}’,
  14199. // ... the outermost braces enclosing the argument are removed
  14200. if (start.text === "{" && tokens[tokens.length - 1].text === "}") {
  14201. tokens.pop();
  14202. tokens.shift();
  14203. }
  14204. tokens.reverse(); // to fit in with stack order
  14205. return {
  14206. tokens: tokens,
  14207. start: start,
  14208. end: tok
  14209. };
  14210. }
  14211. /**
  14212. * Consume the specified number of (delimited) arguments from the token
  14213. * stream and return the resulting array of arguments.
  14214. */
  14215. ;
  14216. _proto.consumeArgs = function consumeArgs(numArgs, delimiters) {
  14217. if (delimiters) {
  14218. if (delimiters.length !== numArgs + 1) {
  14219. throw new src_ParseError("The length of delimiters doesn't match the number of args!");
  14220. }
  14221. var delims = delimiters[0];
  14222. for (var i = 0; i < delims.length; i++) {
  14223. var tok = this.popToken();
  14224. if (delims[i] !== tok.text) {
  14225. throw new src_ParseError("Use of the macro doesn't match its definition", tok);
  14226. }
  14227. }
  14228. }
  14229. var args = [];
  14230. for (var _i = 0; _i < numArgs; _i++) {
  14231. args.push(this.consumeArg(delimiters && delimiters[_i + 1]).tokens);
  14232. }
  14233. return args;
  14234. }
  14235. /**
  14236. * Expand the next token only once if possible.
  14237. *
  14238. * If the token is expanded, the resulting tokens will be pushed onto
  14239. * the stack in reverse order and will be returned as an array,
  14240. * also in reverse order.
  14241. *
  14242. * If not, the next token will be returned without removing it
  14243. * from the stack. This case can be detected by a `Token` return value
  14244. * instead of an `Array` return value.
  14245. *
  14246. * In either case, the next token will be on the top of the stack,
  14247. * or the stack will be empty.
  14248. *
  14249. * Used to implement `expandAfterFuture` and `expandNextToken`.
  14250. *
  14251. * If expandableOnly, only expandable tokens are expanded and
  14252. * an undefined control sequence results in an error.
  14253. */
  14254. ;
  14255. _proto.expandOnce = function expandOnce(expandableOnly) {
  14256. var topToken = this.popToken();
  14257. var name = topToken.text;
  14258. var expansion = !topToken.noexpand ? this._getExpansion(name) : null;
  14259. if (expansion == null || expandableOnly && expansion.unexpandable) {
  14260. if (expandableOnly && expansion == null && name[0] === "\\" && !this.isDefined(name)) {
  14261. throw new src_ParseError("Undefined control sequence: " + name);
  14262. }
  14263. this.pushToken(topToken);
  14264. return topToken;
  14265. }
  14266. this.expansionCount++;
  14267. if (this.expansionCount > this.settings.maxExpand) {
  14268. throw new src_ParseError("Too many expansions: infinite loop or " + "need to increase maxExpand setting");
  14269. }
  14270. var tokens = expansion.tokens;
  14271. var args = this.consumeArgs(expansion.numArgs, expansion.delimiters);
  14272. if (expansion.numArgs) {
  14273. // paste arguments in place of the placeholders
  14274. tokens = tokens.slice(); // make a shallow copy
  14275. for (var i = tokens.length - 1; i >= 0; --i) {
  14276. var tok = tokens[i];
  14277. if (tok.text === "#") {
  14278. if (i === 0) {
  14279. throw new src_ParseError("Incomplete placeholder at end of macro body", tok);
  14280. }
  14281. tok = tokens[--i]; // next token on stack
  14282. if (tok.text === "#") {
  14283. // ## → #
  14284. tokens.splice(i + 1, 1); // drop first #
  14285. } else if (/^[1-9]$/.test(tok.text)) {
  14286. var _tokens;
  14287. // replace the placeholder with the indicated argument
  14288. (_tokens = tokens).splice.apply(_tokens, [i, 2].concat(args[+tok.text - 1]));
  14289. } else {
  14290. throw new src_ParseError("Not a valid argument number", tok);
  14291. }
  14292. }
  14293. }
  14294. } // Concatenate expansion onto top of stack.
  14295. this.pushTokens(tokens);
  14296. return tokens;
  14297. }
  14298. /**
  14299. * Expand the next token only once (if possible), and return the resulting
  14300. * top token on the stack (without removing anything from the stack).
  14301. * Similar in behavior to TeX's `\expandafter\futurelet`.
  14302. * Equivalent to expandOnce() followed by future().
  14303. */
  14304. ;
  14305. _proto.expandAfterFuture = function expandAfterFuture() {
  14306. this.expandOnce();
  14307. return this.future();
  14308. }
  14309. /**
  14310. * Recursively expand first token, then return first non-expandable token.
  14311. */
  14312. ;
  14313. _proto.expandNextToken = function expandNextToken() {
  14314. for (;;) {
  14315. var expanded = this.expandOnce(); // expandOnce returns Token if and only if it's fully expanded.
  14316. if (expanded instanceof Token) {
  14317. // the token after \noexpand is interpreted as if its meaning
  14318. // were ‘\relax’
  14319. if (expanded.treatAsRelax) {
  14320. expanded.text = "\\relax";
  14321. }
  14322. return this.stack.pop(); // === expanded
  14323. }
  14324. } // Flow unable to figure out that this pathway is impossible.
  14325. // https://github.com/facebook/flow/issues/4808
  14326. throw new Error(); // eslint-disable-line no-unreachable
  14327. }
  14328. /**
  14329. * Fully expand the given macro name and return the resulting list of
  14330. * tokens, or return `undefined` if no such macro is defined.
  14331. */
  14332. ;
  14333. _proto.expandMacro = function expandMacro(name) {
  14334. return this.macros.has(name) ? this.expandTokens([new Token(name)]) : undefined;
  14335. }
  14336. /**
  14337. * Fully expand the given token stream and return the resulting list of tokens
  14338. */
  14339. ;
  14340. _proto.expandTokens = function expandTokens(tokens) {
  14341. var output = [];
  14342. var oldStackLength = this.stack.length;
  14343. this.pushTokens(tokens);
  14344. while (this.stack.length > oldStackLength) {
  14345. var expanded = this.expandOnce(true); // expand only expandable tokens
  14346. // expandOnce returns Token if and only if it's fully expanded.
  14347. if (expanded instanceof Token) {
  14348. if (expanded.treatAsRelax) {
  14349. // the expansion of \noexpand is the token itself
  14350. expanded.noexpand = false;
  14351. expanded.treatAsRelax = false;
  14352. }
  14353. output.push(this.stack.pop());
  14354. }
  14355. }
  14356. return output;
  14357. }
  14358. /**
  14359. * Fully expand the given macro name and return the result as a string,
  14360. * or return `undefined` if no such macro is defined.
  14361. */
  14362. ;
  14363. _proto.expandMacroAsText = function expandMacroAsText(name) {
  14364. var tokens = this.expandMacro(name);
  14365. if (tokens) {
  14366. return tokens.map(function (token) {
  14367. return token.text;
  14368. }).join("");
  14369. } else {
  14370. return tokens;
  14371. }
  14372. }
  14373. /**
  14374. * Returns the expanded macro as a reversed array of tokens and a macro
  14375. * argument count. Or returns `null` if no such macro.
  14376. */
  14377. ;
  14378. _proto._getExpansion = function _getExpansion(name) {
  14379. var definition = this.macros.get(name);
  14380. if (definition == null) {
  14381. // mainly checking for undefined here
  14382. return definition;
  14383. } // If a single character has an associated catcode other than 13
  14384. // (active character), then don't expand it.
  14385. if (name.length === 1) {
  14386. var catcode = this.lexer.catcodes[name];
  14387. if (catcode != null && catcode !== 13) {
  14388. return;
  14389. }
  14390. }
  14391. var expansion = typeof definition === "function" ? definition(this) : definition;
  14392. if (typeof expansion === "string") {
  14393. var numArgs = 0;
  14394. if (expansion.indexOf("#") !== -1) {
  14395. var stripped = expansion.replace(/##/g, "");
  14396. while (stripped.indexOf("#" + (numArgs + 1)) !== -1) {
  14397. ++numArgs;
  14398. }
  14399. }
  14400. var bodyLexer = new Lexer(expansion, this.settings);
  14401. var tokens = [];
  14402. var tok = bodyLexer.lex();
  14403. while (tok.text !== "EOF") {
  14404. tokens.push(tok);
  14405. tok = bodyLexer.lex();
  14406. }
  14407. tokens.reverse(); // to fit in with stack using push and pop
  14408. var expanded = {
  14409. tokens: tokens,
  14410. numArgs: numArgs
  14411. };
  14412. return expanded;
  14413. }
  14414. return expansion;
  14415. }
  14416. /**
  14417. * Determine whether a command is currently "defined" (has some
  14418. * functionality), meaning that it's a macro (in the current group),
  14419. * a function, a symbol, or one of the special commands listed in
  14420. * `implicitCommands`.
  14421. */
  14422. ;
  14423. _proto.isDefined = function isDefined(name) {
  14424. return this.macros.has(name) || src_functions.hasOwnProperty(name) || src_symbols.math.hasOwnProperty(name) || src_symbols.text.hasOwnProperty(name) || implicitCommands.hasOwnProperty(name);
  14425. }
  14426. /**
  14427. * Determine whether a command is expandable.
  14428. */
  14429. ;
  14430. _proto.isExpandable = function isExpandable(name) {
  14431. var macro = this.macros.get(name);
  14432. return macro != null ? typeof macro === "string" || typeof macro === "function" || !macro.unexpandable : src_functions.hasOwnProperty(name) && !src_functions[name].primitive;
  14433. };
  14434. return MacroExpander;
  14435. }();
  14436. ;// CONCATENATED MODULE: ./src/Parser.js
  14437. /* eslint no-constant-condition:0 */
  14438. // Pre-evaluate both modules as unicodeSymbols require String.normalize()
  14439. var unicodeAccents = {
  14440. "́": {
  14441. "text": "\\'",
  14442. "math": "\\acute"
  14443. },
  14444. "̀": {
  14445. "text": "\\`",
  14446. "math": "\\grave"
  14447. },
  14448. "̈": {
  14449. "text": "\\\"",
  14450. "math": "\\ddot"
  14451. },
  14452. "̃": {
  14453. "text": "\\~",
  14454. "math": "\\tilde"
  14455. },
  14456. "̄": {
  14457. "text": "\\=",
  14458. "math": "\\bar"
  14459. },
  14460. "̆": {
  14461. "text": "\\u",
  14462. "math": "\\breve"
  14463. },
  14464. "̌": {
  14465. "text": "\\v",
  14466. "math": "\\check"
  14467. },
  14468. "̂": {
  14469. "text": "\\^",
  14470. "math": "\\hat"
  14471. },
  14472. "̇": {
  14473. "text": "\\.",
  14474. "math": "\\dot"
  14475. },
  14476. "̊": {
  14477. "text": "\\r",
  14478. "math": "\\mathring"
  14479. },
  14480. "̋": {
  14481. "text": "\\H"
  14482. },
  14483. "̧": {
  14484. "text": "\\c"
  14485. }
  14486. };
  14487. var unicodeSymbols = {
  14488. "á": "á",
  14489. "à": "à",
  14490. "ä": "ä",
  14491. "ǟ": "ǟ",
  14492. "ã": "ã",
  14493. "ā": "ā",
  14494. "ă": "ă",
  14495. "ắ": "ắ",
  14496. "ằ": "ằ",
  14497. "ẵ": "ẵ",
  14498. "ǎ": "ǎ",
  14499. "â": "â",
  14500. "ấ": "ấ",
  14501. "ầ": "ầ",
  14502. "ẫ": "ẫ",
  14503. "ȧ": "ȧ",
  14504. "ǡ": "ǡ",
  14505. "å": "å",
  14506. "ǻ": "ǻ",
  14507. "ḃ": "ḃ",
  14508. "ć": "ć",
  14509. "ḉ": "ḉ",
  14510. "č": "č",
  14511. "ĉ": "ĉ",
  14512. "ċ": "ċ",
  14513. "ç": "ç",
  14514. "ď": "ď",
  14515. "ḋ": "ḋ",
  14516. "ḑ": "ḑ",
  14517. "é": "é",
  14518. "è": "è",
  14519. "ë": "ë",
  14520. "ẽ": "ẽ",
  14521. "ē": "ē",
  14522. "ḗ": "ḗ",
  14523. "ḕ": "ḕ",
  14524. "ĕ": "ĕ",
  14525. "ḝ": "ḝ",
  14526. "ě": "ě",
  14527. "ê": "ê",
  14528. "ế": "ế",
  14529. "ề": "ề",
  14530. "ễ": "ễ",
  14531. "ė": "ė",
  14532. "ȩ": "ȩ",
  14533. "ḟ": "ḟ",
  14534. "ǵ": "ǵ",
  14535. "ḡ": "ḡ",
  14536. "ğ": "ğ",
  14537. "ǧ": "ǧ",
  14538. "ĝ": "ĝ",
  14539. "ġ": "ġ",
  14540. "ģ": "ģ",
  14541. "ḧ": "ḧ",
  14542. "ȟ": "ȟ",
  14543. "ĥ": "ĥ",
  14544. "ḣ": "ḣ",
  14545. "ḩ": "ḩ",
  14546. "í": "í",
  14547. "ì": "ì",
  14548. "ï": "ï",
  14549. "ḯ": "ḯ",
  14550. "ĩ": "ĩ",
  14551. "ī": "ī",
  14552. "ĭ": "ĭ",
  14553. "ǐ": "ǐ",
  14554. "î": "î",
  14555. "ǰ": "ǰ",
  14556. "ĵ": "ĵ",
  14557. "ḱ": "ḱ",
  14558. "ǩ": "ǩ",
  14559. "ķ": "ķ",
  14560. "ĺ": "ĺ",
  14561. "ľ": "ľ",
  14562. "ļ": "ļ",
  14563. "ḿ": "ḿ",
  14564. "ṁ": "ṁ",
  14565. "ń": "ń",
  14566. "ǹ": "ǹ",
  14567. "ñ": "ñ",
  14568. "ň": "ň",
  14569. "ṅ": "ṅ",
  14570. "ņ": "ņ",
  14571. "ó": "ó",
  14572. "ò": "ò",
  14573. "ö": "ö",
  14574. "ȫ": "ȫ",
  14575. "õ": "õ",
  14576. "ṍ": "ṍ",
  14577. "ṏ": "ṏ",
  14578. "ȭ": "ȭ",
  14579. "ō": "ō",
  14580. "ṓ": "ṓ",
  14581. "ṑ": "ṑ",
  14582. "ŏ": "ŏ",
  14583. "ǒ": "ǒ",
  14584. "ô": "ô",
  14585. "ố": "ố",
  14586. "ồ": "ồ",
  14587. "ỗ": "ỗ",
  14588. "ȯ": "ȯ",
  14589. "ȱ": "ȱ",
  14590. "ő": "ő",
  14591. "ṕ": "ṕ",
  14592. "ṗ": "ṗ",
  14593. "ŕ": "ŕ",
  14594. "ř": "ř",
  14595. "ṙ": "ṙ",
  14596. "ŗ": "ŗ",
  14597. "ś": "ś",
  14598. "ṥ": "ṥ",
  14599. "š": "š",
  14600. "ṧ": "ṧ",
  14601. "ŝ": "ŝ",
  14602. "ṡ": "ṡ",
  14603. "ş": "ş",
  14604. "ẗ": "ẗ",
  14605. "ť": "ť",
  14606. "ṫ": "ṫ",
  14607. "ţ": "ţ",
  14608. "ú": "ú",
  14609. "ù": "ù",
  14610. "ü": "ü",
  14611. "ǘ": "ǘ",
  14612. "ǜ": "ǜ",
  14613. "ǖ": "ǖ",
  14614. "ǚ": "ǚ",
  14615. "ũ": "ũ",
  14616. "ṹ": "ṹ",
  14617. "ū": "ū",
  14618. "ṻ": "ṻ",
  14619. "ŭ": "ŭ",
  14620. "ǔ": "ǔ",
  14621. "û": "û",
  14622. "ů": "ů",
  14623. "ű": "ű",
  14624. "ṽ": "ṽ",
  14625. "ẃ": "ẃ",
  14626. "ẁ": "ẁ",
  14627. "ẅ": "ẅ",
  14628. "ŵ": "ŵ",
  14629. "ẇ": "ẇ",
  14630. "ẘ": "ẘ",
  14631. "ẍ": "ẍ",
  14632. "ẋ": "ẋ",
  14633. "ý": "ý",
  14634. "ỳ": "ỳ",
  14635. "ÿ": "ÿ",
  14636. "ỹ": "ỹ",
  14637. "ȳ": "ȳ",
  14638. "ŷ": "ŷ",
  14639. "ẏ": "ẏ",
  14640. "ẙ": "ẙ",
  14641. "ź": "ź",
  14642. "ž": "ž",
  14643. "ẑ": "ẑ",
  14644. "ż": "ż",
  14645. "Á": "Á",
  14646. "À": "À",
  14647. "Ä": "Ä",
  14648. "Ǟ": "Ǟ",
  14649. "Ã": "Ã",
  14650. "Ā": "Ā",
  14651. "Ă": "Ă",
  14652. "Ắ": "Ắ",
  14653. "Ằ": "Ằ",
  14654. "Ẵ": "Ẵ",
  14655. "Ǎ": "Ǎ",
  14656. "Â": "Â",
  14657. "Ấ": "Ấ",
  14658. "Ầ": "Ầ",
  14659. "Ẫ": "Ẫ",
  14660. "Ȧ": "Ȧ",
  14661. "Ǡ": "Ǡ",
  14662. "Å": "Å",
  14663. "Ǻ": "Ǻ",
  14664. "Ḃ": "Ḃ",
  14665. "Ć": "Ć",
  14666. "Ḉ": "Ḉ",
  14667. "Č": "Č",
  14668. "Ĉ": "Ĉ",
  14669. "Ċ": "Ċ",
  14670. "Ç": "Ç",
  14671. "Ď": "Ď",
  14672. "Ḋ": "Ḋ",
  14673. "Ḑ": "Ḑ",
  14674. "É": "É",
  14675. "È": "È",
  14676. "Ë": "Ë",
  14677. "Ẽ": "Ẽ",
  14678. "Ē": "Ē",
  14679. "Ḗ": "Ḗ",
  14680. "Ḕ": "Ḕ",
  14681. "Ĕ": "Ĕ",
  14682. "Ḝ": "Ḝ",
  14683. "Ě": "Ě",
  14684. "Ê": "Ê",
  14685. "Ế": "Ế",
  14686. "Ề": "Ề",
  14687. "Ễ": "Ễ",
  14688. "Ė": "Ė",
  14689. "Ȩ": "Ȩ",
  14690. "Ḟ": "Ḟ",
  14691. "Ǵ": "Ǵ",
  14692. "Ḡ": "Ḡ",
  14693. "Ğ": "Ğ",
  14694. "Ǧ": "Ǧ",
  14695. "Ĝ": "Ĝ",
  14696. "Ġ": "Ġ",
  14697. "Ģ": "Ģ",
  14698. "Ḧ": "Ḧ",
  14699. "Ȟ": "Ȟ",
  14700. "Ĥ": "Ĥ",
  14701. "Ḣ": "Ḣ",
  14702. "Ḩ": "Ḩ",
  14703. "Í": "Í",
  14704. "Ì": "Ì",
  14705. "Ï": "Ï",
  14706. "Ḯ": "Ḯ",
  14707. "Ĩ": "Ĩ",
  14708. "Ī": "Ī",
  14709. "Ĭ": "Ĭ",
  14710. "Ǐ": "Ǐ",
  14711. "Î": "Î",
  14712. "İ": "İ",
  14713. "Ĵ": "Ĵ",
  14714. "Ḱ": "Ḱ",
  14715. "Ǩ": "Ǩ",
  14716. "Ķ": "Ķ",
  14717. "Ĺ": "Ĺ",
  14718. "Ľ": "Ľ",
  14719. "Ļ": "Ļ",
  14720. "Ḿ": "Ḿ",
  14721. "Ṁ": "Ṁ",
  14722. "Ń": "Ń",
  14723. "Ǹ": "Ǹ",
  14724. "Ñ": "Ñ",
  14725. "Ň": "Ň",
  14726. "Ṅ": "Ṅ",
  14727. "Ņ": "Ņ",
  14728. "Ó": "Ó",
  14729. "Ò": "Ò",
  14730. "Ö": "Ö",
  14731. "Ȫ": "Ȫ",
  14732. "Õ": "Õ",
  14733. "Ṍ": "Ṍ",
  14734. "Ṏ": "Ṏ",
  14735. "Ȭ": "Ȭ",
  14736. "Ō": "Ō",
  14737. "Ṓ": "Ṓ",
  14738. "Ṑ": "Ṑ",
  14739. "Ŏ": "Ŏ",
  14740. "Ǒ": "Ǒ",
  14741. "Ô": "Ô",
  14742. "Ố": "Ố",
  14743. "Ồ": "Ồ",
  14744. "Ỗ": "Ỗ",
  14745. "Ȯ": "Ȯ",
  14746. "Ȱ": "Ȱ",
  14747. "Ő": "Ő",
  14748. "Ṕ": "Ṕ",
  14749. "Ṗ": "Ṗ",
  14750. "Ŕ": "Ŕ",
  14751. "Ř": "Ř",
  14752. "Ṙ": "Ṙ",
  14753. "Ŗ": "Ŗ",
  14754. "Ś": "Ś",
  14755. "Ṥ": "Ṥ",
  14756. "Š": "Š",
  14757. "Ṧ": "Ṧ",
  14758. "Ŝ": "Ŝ",
  14759. "Ṡ": "Ṡ",
  14760. "Ş": "Ş",
  14761. "Ť": "Ť",
  14762. "Ṫ": "Ṫ",
  14763. "Ţ": "Ţ",
  14764. "Ú": "Ú",
  14765. "Ù": "Ù",
  14766. "Ü": "Ü",
  14767. "Ǘ": "Ǘ",
  14768. "Ǜ": "Ǜ",
  14769. "Ǖ": "Ǖ",
  14770. "Ǚ": "Ǚ",
  14771. "Ũ": "Ũ",
  14772. "Ṹ": "Ṹ",
  14773. "Ū": "Ū",
  14774. "Ṻ": "Ṻ",
  14775. "Ŭ": "Ŭ",
  14776. "Ǔ": "Ǔ",
  14777. "Û": "Û",
  14778. "Ů": "Ů",
  14779. "Ű": "Ű",
  14780. "Ṽ": "Ṽ",
  14781. "Ẃ": "Ẃ",
  14782. "Ẁ": "Ẁ",
  14783. "Ẅ": "Ẅ",
  14784. "Ŵ": "Ŵ",
  14785. "Ẇ": "Ẇ",
  14786. "Ẍ": "Ẍ",
  14787. "Ẋ": "Ẋ",
  14788. "Ý": "Ý",
  14789. "Ỳ": "Ỳ",
  14790. "Ÿ": "Ÿ",
  14791. "Ỹ": "Ỹ",
  14792. "Ȳ": "Ȳ",
  14793. "Ŷ": "Ŷ",
  14794. "Ẏ": "Ẏ",
  14795. "Ź": "Ź",
  14796. "Ž": "Ž",
  14797. "Ẑ": "Ẑ",
  14798. "Ż": "Ż",
  14799. "ά": "ά",
  14800. "ὰ": "ὰ",
  14801. "ᾱ": "ᾱ",
  14802. "ᾰ": "ᾰ",
  14803. "έ": "έ",
  14804. "ὲ": "ὲ",
  14805. "ή": "ή",
  14806. "ὴ": "ὴ",
  14807. "ί": "ί",
  14808. "ὶ": "ὶ",
  14809. "ϊ": "ϊ",
  14810. "ΐ": "ΐ",
  14811. "ῒ": "ῒ",
  14812. "ῑ": "ῑ",
  14813. "ῐ": "ῐ",
  14814. "ό": "ό",
  14815. "ὸ": "ὸ",
  14816. "ύ": "ύ",
  14817. "ὺ": "ὺ",
  14818. "ϋ": "ϋ",
  14819. "ΰ": "ΰ",
  14820. "ῢ": "ῢ",
  14821. "ῡ": "ῡ",
  14822. "ῠ": "ῠ",
  14823. "ώ": "ώ",
  14824. "ὼ": "ὼ",
  14825. "Ύ": "Ύ",
  14826. "Ὺ": "Ὺ",
  14827. "Ϋ": "Ϋ",
  14828. "Ῡ": "Ῡ",
  14829. "Ῠ": "Ῠ",
  14830. "Ώ": "Ώ",
  14831. "Ὼ": "Ὼ"
  14832. };
  14833. /**
  14834. * This file contains the parser used to parse out a TeX expression from the
  14835. * input. Since TeX isn't context-free, standard parsers don't work particularly
  14836. * well.
  14837. *
  14838. * The strategy of this parser is as such:
  14839. *
  14840. * The main functions (the `.parse...` ones) take a position in the current
  14841. * parse string to parse tokens from. The lexer (found in Lexer.js, stored at
  14842. * this.gullet.lexer) also supports pulling out tokens at arbitrary places. When
  14843. * individual tokens are needed at a position, the lexer is called to pull out a
  14844. * token, which is then used.
  14845. *
  14846. * The parser has a property called "mode" indicating the mode that
  14847. * the parser is currently in. Currently it has to be one of "math" or
  14848. * "text", which denotes whether the current environment is a math-y
  14849. * one or a text-y one (e.g. inside \text). Currently, this serves to
  14850. * limit the functions which can be used in text mode.
  14851. *
  14852. * The main functions then return an object which contains the useful data that
  14853. * was parsed at its given point, and a new position at the end of the parsed
  14854. * data. The main functions can call each other and continue the parsing by
  14855. * using the returned position as a new starting point.
  14856. *
  14857. * There are also extra `.handle...` functions, which pull out some reused
  14858. * functionality into self-contained functions.
  14859. *
  14860. * The functions return ParseNodes.
  14861. */
  14862. var Parser = /*#__PURE__*/function () {
  14863. function Parser(input, settings) {
  14864. this.mode = void 0;
  14865. this.gullet = void 0;
  14866. this.settings = void 0;
  14867. this.leftrightDepth = void 0;
  14868. this.nextToken = void 0;
  14869. // Start in math mode
  14870. this.mode = "math"; // Create a new macro expander (gullet) and (indirectly via that) also a
  14871. // new lexer (mouth) for this parser (stomach, in the language of TeX)
  14872. this.gullet = new MacroExpander(input, settings, this.mode); // Store the settings for use in parsing
  14873. this.settings = settings; // Count leftright depth (for \middle errors)
  14874. this.leftrightDepth = 0;
  14875. }
  14876. /**
  14877. * Checks a result to make sure it has the right type, and throws an
  14878. * appropriate error otherwise.
  14879. */
  14880. var _proto = Parser.prototype;
  14881. _proto.expect = function expect(text, consume) {
  14882. if (consume === void 0) {
  14883. consume = true;
  14884. }
  14885. if (this.fetch().text !== text) {
  14886. throw new src_ParseError("Expected '" + text + "', got '" + this.fetch().text + "'", this.fetch());
  14887. }
  14888. if (consume) {
  14889. this.consume();
  14890. }
  14891. }
  14892. /**
  14893. * Discards the current lookahead token, considering it consumed.
  14894. */
  14895. ;
  14896. _proto.consume = function consume() {
  14897. this.nextToken = null;
  14898. }
  14899. /**
  14900. * Return the current lookahead token, or if there isn't one (at the
  14901. * beginning, or if the previous lookahead token was consume()d),
  14902. * fetch the next token as the new lookahead token and return it.
  14903. */
  14904. ;
  14905. _proto.fetch = function fetch() {
  14906. if (this.nextToken == null) {
  14907. this.nextToken = this.gullet.expandNextToken();
  14908. }
  14909. return this.nextToken;
  14910. }
  14911. /**
  14912. * Switches between "text" and "math" modes.
  14913. */
  14914. ;
  14915. _proto.switchMode = function switchMode(newMode) {
  14916. this.mode = newMode;
  14917. this.gullet.switchMode(newMode);
  14918. }
  14919. /**
  14920. * Main parsing function, which parses an entire input.
  14921. */
  14922. ;
  14923. _proto.parse = function parse() {
  14924. if (!this.settings.globalGroup) {
  14925. // Create a group namespace for the math expression.
  14926. // (LaTeX creates a new group for every $...$, $$...$$, \[...\].)
  14927. this.gullet.beginGroup();
  14928. } // Use old \color behavior (same as LaTeX's \textcolor) if requested.
  14929. // We do this within the group for the math expression, so it doesn't
  14930. // pollute settings.macros.
  14931. if (this.settings.colorIsTextColor) {
  14932. this.gullet.macros.set("\\color", "\\textcolor");
  14933. }
  14934. try {
  14935. // Try to parse the input
  14936. var parse = this.parseExpression(false); // If we succeeded, make sure there's an EOF at the end
  14937. this.expect("EOF"); // End the group namespace for the expression
  14938. if (!this.settings.globalGroup) {
  14939. this.gullet.endGroup();
  14940. }
  14941. return parse; // Close any leftover groups in case of a parse error.
  14942. } finally {
  14943. this.gullet.endGroups();
  14944. }
  14945. }
  14946. /**
  14947. * Fully parse a separate sequence of tokens as a separate job.
  14948. * Tokens should be specified in reverse order, as in a MacroDefinition.
  14949. */
  14950. ;
  14951. _proto.subparse = function subparse(tokens) {
  14952. // Save the next token from the current job.
  14953. var oldToken = this.nextToken;
  14954. this.consume(); // Run the new job, terminating it with an excess '}'
  14955. this.gullet.pushToken(new Token("}"));
  14956. this.gullet.pushTokens(tokens);
  14957. var parse = this.parseExpression(false);
  14958. this.expect("}"); // Restore the next token from the current job.
  14959. this.nextToken = oldToken;
  14960. return parse;
  14961. };
  14962. /**
  14963. * Parses an "expression", which is a list of atoms.
  14964. *
  14965. * `breakOnInfix`: Should the parsing stop when we hit infix nodes? This
  14966. * happens when functions have higher precendence han infix
  14967. * nodes in implicit parses.
  14968. *
  14969. * `breakOnTokenText`: The text of the token that the expression should end
  14970. * with, or `null` if something else should end the
  14971. * expression.
  14972. */
  14973. _proto.parseExpression = function parseExpression(breakOnInfix, breakOnTokenText) {
  14974. var body = []; // Keep adding atoms to the body until we can't parse any more atoms (either
  14975. // we reached the end, a }, or a \right)
  14976. while (true) {
  14977. // Ignore spaces in math mode
  14978. if (this.mode === "math") {
  14979. this.consumeSpaces();
  14980. }
  14981. var lex = this.fetch();
  14982. if (Parser.endOfExpression.indexOf(lex.text) !== -1) {
  14983. break;
  14984. }
  14985. if (breakOnTokenText && lex.text === breakOnTokenText) {
  14986. break;
  14987. }
  14988. if (breakOnInfix && src_functions[lex.text] && src_functions[lex.text].infix) {
  14989. break;
  14990. }
  14991. var atom = this.parseAtom(breakOnTokenText);
  14992. if (!atom) {
  14993. break;
  14994. } else if (atom.type === "internal") {
  14995. continue;
  14996. }
  14997. body.push(atom);
  14998. }
  14999. if (this.mode === "text") {
  15000. this.formLigatures(body);
  15001. }
  15002. return this.handleInfixNodes(body);
  15003. }
  15004. /**
  15005. * Rewrites infix operators such as \over with corresponding commands such
  15006. * as \frac.
  15007. *
  15008. * There can only be one infix operator per group. If there's more than one
  15009. * then the expression is ambiguous. This can be resolved by adding {}.
  15010. */
  15011. ;
  15012. _proto.handleInfixNodes = function handleInfixNodes(body) {
  15013. var overIndex = -1;
  15014. var funcName;
  15015. for (var i = 0; i < body.length; i++) {
  15016. if (body[i].type === "infix") {
  15017. if (overIndex !== -1) {
  15018. throw new src_ParseError("only one infix operator per group", body[i].token);
  15019. }
  15020. overIndex = i;
  15021. funcName = body[i].replaceWith;
  15022. }
  15023. }
  15024. if (overIndex !== -1 && funcName) {
  15025. var numerNode;
  15026. var denomNode;
  15027. var numerBody = body.slice(0, overIndex);
  15028. var denomBody = body.slice(overIndex + 1);
  15029. if (numerBody.length === 1 && numerBody[0].type === "ordgroup") {
  15030. numerNode = numerBody[0];
  15031. } else {
  15032. numerNode = {
  15033. type: "ordgroup",
  15034. mode: this.mode,
  15035. body: numerBody
  15036. };
  15037. }
  15038. if (denomBody.length === 1 && denomBody[0].type === "ordgroup") {
  15039. denomNode = denomBody[0];
  15040. } else {
  15041. denomNode = {
  15042. type: "ordgroup",
  15043. mode: this.mode,
  15044. body: denomBody
  15045. };
  15046. }
  15047. var node;
  15048. if (funcName === "\\\\abovefrac") {
  15049. node = this.callFunction(funcName, [numerNode, body[overIndex], denomNode], []);
  15050. } else {
  15051. node = this.callFunction(funcName, [numerNode, denomNode], []);
  15052. }
  15053. return [node];
  15054. } else {
  15055. return body;
  15056. }
  15057. }
  15058. /**
  15059. * Handle a subscript or superscript with nice errors.
  15060. */
  15061. ;
  15062. _proto.handleSupSubscript = function handleSupSubscript(name // For error reporting.
  15063. ) {
  15064. var symbolToken = this.fetch();
  15065. var symbol = symbolToken.text;
  15066. this.consume();
  15067. this.consumeSpaces(); // ignore spaces before sup/subscript argument
  15068. var group = this.parseGroup(name);
  15069. if (!group) {
  15070. throw new src_ParseError("Expected group after '" + symbol + "'", symbolToken);
  15071. }
  15072. return group;
  15073. }
  15074. /**
  15075. * Converts the textual input of an unsupported command into a text node
  15076. * contained within a color node whose color is determined by errorColor
  15077. */
  15078. ;
  15079. _proto.formatUnsupportedCmd = function formatUnsupportedCmd(text) {
  15080. var textordArray = [];
  15081. for (var i = 0; i < text.length; i++) {
  15082. textordArray.push({
  15083. type: "textord",
  15084. mode: "text",
  15085. text: text[i]
  15086. });
  15087. }
  15088. var textNode = {
  15089. type: "text",
  15090. mode: this.mode,
  15091. body: textordArray
  15092. };
  15093. var colorNode = {
  15094. type: "color",
  15095. mode: this.mode,
  15096. color: this.settings.errorColor,
  15097. body: [textNode]
  15098. };
  15099. return colorNode;
  15100. }
  15101. /**
  15102. * Parses a group with optional super/subscripts.
  15103. */
  15104. ;
  15105. _proto.parseAtom = function parseAtom(breakOnTokenText) {
  15106. // The body of an atom is an implicit group, so that things like
  15107. // \left(x\right)^2 work correctly.
  15108. var base = this.parseGroup("atom", breakOnTokenText); // In text mode, we don't have superscripts or subscripts
  15109. if (this.mode === "text") {
  15110. return base;
  15111. } // Note that base may be empty (i.e. null) at this point.
  15112. var superscript;
  15113. var subscript;
  15114. while (true) {
  15115. // Guaranteed in math mode, so eat any spaces first.
  15116. this.consumeSpaces(); // Lex the first token
  15117. var lex = this.fetch();
  15118. if (lex.text === "\\limits" || lex.text === "\\nolimits") {
  15119. // We got a limit control
  15120. if (base && base.type === "op") {
  15121. var limits = lex.text === "\\limits";
  15122. base.limits = limits;
  15123. base.alwaysHandleSupSub = true;
  15124. } else if (base && base.type === "operatorname") {
  15125. if (base.alwaysHandleSupSub) {
  15126. base.limits = lex.text === "\\limits";
  15127. }
  15128. } else {
  15129. throw new src_ParseError("Limit controls must follow a math operator", lex);
  15130. }
  15131. this.consume();
  15132. } else if (lex.text === "^") {
  15133. // We got a superscript start
  15134. if (superscript) {
  15135. throw new src_ParseError("Double superscript", lex);
  15136. }
  15137. superscript = this.handleSupSubscript("superscript");
  15138. } else if (lex.text === "_") {
  15139. // We got a subscript start
  15140. if (subscript) {
  15141. throw new src_ParseError("Double subscript", lex);
  15142. }
  15143. subscript = this.handleSupSubscript("subscript");
  15144. } else if (lex.text === "'") {
  15145. // We got a prime
  15146. if (superscript) {
  15147. throw new src_ParseError("Double superscript", lex);
  15148. }
  15149. var prime = {
  15150. type: "textord",
  15151. mode: this.mode,
  15152. text: "\\prime"
  15153. }; // Many primes can be grouped together, so we handle this here
  15154. var primes = [prime];
  15155. this.consume(); // Keep lexing tokens until we get something that's not a prime
  15156. while (this.fetch().text === "'") {
  15157. // For each one, add another prime to the list
  15158. primes.push(prime);
  15159. this.consume();
  15160. } // If there's a superscript following the primes, combine that
  15161. // superscript in with the primes.
  15162. if (this.fetch().text === "^") {
  15163. primes.push(this.handleSupSubscript("superscript"));
  15164. } // Put everything into an ordgroup as the superscript
  15165. superscript = {
  15166. type: "ordgroup",
  15167. mode: this.mode,
  15168. body: primes
  15169. };
  15170. } else {
  15171. // If it wasn't ^, _, or ', stop parsing super/subscripts
  15172. break;
  15173. }
  15174. } // Base must be set if superscript or subscript are set per logic above,
  15175. // but need to check here for type check to pass.
  15176. if (superscript || subscript) {
  15177. // If we got either a superscript or subscript, create a supsub
  15178. return {
  15179. type: "supsub",
  15180. mode: this.mode,
  15181. base: base,
  15182. sup: superscript,
  15183. sub: subscript
  15184. };
  15185. } else {
  15186. // Otherwise return the original body
  15187. return base;
  15188. }
  15189. }
  15190. /**
  15191. * Parses an entire function, including its base and all of its arguments.
  15192. */
  15193. ;
  15194. _proto.parseFunction = function parseFunction(breakOnTokenText, name // For determining its context
  15195. ) {
  15196. var token = this.fetch();
  15197. var func = token.text;
  15198. var funcData = src_functions[func];
  15199. if (!funcData) {
  15200. return null;
  15201. }
  15202. this.consume(); // consume command token
  15203. if (name && name !== "atom" && !funcData.allowedInArgument) {
  15204. throw new src_ParseError("Got function '" + func + "' with no arguments" + (name ? " as " + name : ""), token);
  15205. } else if (this.mode === "text" && !funcData.allowedInText) {
  15206. throw new src_ParseError("Can't use function '" + func + "' in text mode", token);
  15207. } else if (this.mode === "math" && funcData.allowedInMath === false) {
  15208. throw new src_ParseError("Can't use function '" + func + "' in math mode", token);
  15209. }
  15210. var _this$parseArguments = this.parseArguments(func, funcData),
  15211. args = _this$parseArguments.args,
  15212. optArgs = _this$parseArguments.optArgs;
  15213. return this.callFunction(func, args, optArgs, token, breakOnTokenText);
  15214. }
  15215. /**
  15216. * Call a function handler with a suitable context and arguments.
  15217. */
  15218. ;
  15219. _proto.callFunction = function callFunction(name, args, optArgs, token, breakOnTokenText) {
  15220. var context = {
  15221. funcName: name,
  15222. parser: this,
  15223. token: token,
  15224. breakOnTokenText: breakOnTokenText
  15225. };
  15226. var func = src_functions[name];
  15227. if (func && func.handler) {
  15228. return func.handler(context, args, optArgs);
  15229. } else {
  15230. throw new src_ParseError("No function handler for " + name);
  15231. }
  15232. }
  15233. /**
  15234. * Parses the arguments of a function or environment
  15235. */
  15236. ;
  15237. _proto.parseArguments = function parseArguments(func, // Should look like "\name" or "\begin{name}".
  15238. funcData) {
  15239. var totalArgs = funcData.numArgs + funcData.numOptionalArgs;
  15240. if (totalArgs === 0) {
  15241. return {
  15242. args: [],
  15243. optArgs: []
  15244. };
  15245. }
  15246. var args = [];
  15247. var optArgs = [];
  15248. for (var i = 0; i < totalArgs; i++) {
  15249. var argType = funcData.argTypes && funcData.argTypes[i];
  15250. var isOptional = i < funcData.numOptionalArgs;
  15251. if (funcData.primitive && argType == null || // \sqrt expands into primitive if optional argument doesn't exist
  15252. funcData.type === "sqrt" && i === 1 && optArgs[0] == null) {
  15253. argType = "primitive";
  15254. }
  15255. var arg = this.parseGroupOfType("argument to '" + func + "'", argType, isOptional);
  15256. if (isOptional) {
  15257. optArgs.push(arg);
  15258. } else if (arg != null) {
  15259. args.push(arg);
  15260. } else {
  15261. // should be unreachable
  15262. throw new src_ParseError("Null argument, please report this as a bug");
  15263. }
  15264. }
  15265. return {
  15266. args: args,
  15267. optArgs: optArgs
  15268. };
  15269. }
  15270. /**
  15271. * Parses a group when the mode is changing.
  15272. */
  15273. ;
  15274. _proto.parseGroupOfType = function parseGroupOfType(name, type, optional) {
  15275. switch (type) {
  15276. case "color":
  15277. return this.parseColorGroup(optional);
  15278. case "size":
  15279. return this.parseSizeGroup(optional);
  15280. case "url":
  15281. return this.parseUrlGroup(optional);
  15282. case "math":
  15283. case "text":
  15284. return this.parseArgumentGroup(optional, type);
  15285. case "hbox":
  15286. {
  15287. // hbox argument type wraps the argument in the equivalent of
  15288. // \hbox, which is like \text but switching to \textstyle size.
  15289. var group = this.parseArgumentGroup(optional, "text");
  15290. return group != null ? {
  15291. type: "styling",
  15292. mode: group.mode,
  15293. body: [group],
  15294. style: "text" // simulate \textstyle
  15295. } : null;
  15296. }
  15297. case "raw":
  15298. {
  15299. var token = this.parseStringGroup("raw", optional);
  15300. return token != null ? {
  15301. type: "raw",
  15302. mode: "text",
  15303. string: token.text
  15304. } : null;
  15305. }
  15306. case "primitive":
  15307. {
  15308. if (optional) {
  15309. throw new src_ParseError("A primitive argument cannot be optional");
  15310. }
  15311. var _group = this.parseGroup(name);
  15312. if (_group == null) {
  15313. throw new src_ParseError("Expected group as " + name, this.fetch());
  15314. }
  15315. return _group;
  15316. }
  15317. case "original":
  15318. case null:
  15319. case undefined:
  15320. return this.parseArgumentGroup(optional);
  15321. default:
  15322. throw new src_ParseError("Unknown group type as " + name, this.fetch());
  15323. }
  15324. }
  15325. /**
  15326. * Discard any space tokens, fetching the next non-space token.
  15327. */
  15328. ;
  15329. _proto.consumeSpaces = function consumeSpaces() {
  15330. while (this.fetch().text === " ") {
  15331. this.consume();
  15332. }
  15333. }
  15334. /**
  15335. * Parses a group, essentially returning the string formed by the
  15336. * brace-enclosed tokens plus some position information.
  15337. */
  15338. ;
  15339. _proto.parseStringGroup = function parseStringGroup(modeName, // Used to describe the mode in error messages.
  15340. optional) {
  15341. var argToken = this.gullet.scanArgument(optional);
  15342. if (argToken == null) {
  15343. return null;
  15344. }
  15345. var str = "";
  15346. var nextToken;
  15347. while ((nextToken = this.fetch()).text !== "EOF") {
  15348. str += nextToken.text;
  15349. this.consume();
  15350. }
  15351. this.consume(); // consume the end of the argument
  15352. argToken.text = str;
  15353. return argToken;
  15354. }
  15355. /**
  15356. * Parses a regex-delimited group: the largest sequence of tokens
  15357. * whose concatenated strings match `regex`. Returns the string
  15358. * formed by the tokens plus some position information.
  15359. */
  15360. ;
  15361. _proto.parseRegexGroup = function parseRegexGroup(regex, modeName // Used to describe the mode in error messages.
  15362. ) {
  15363. var firstToken = this.fetch();
  15364. var lastToken = firstToken;
  15365. var str = "";
  15366. var nextToken;
  15367. while ((nextToken = this.fetch()).text !== "EOF" && regex.test(str + nextToken.text)) {
  15368. lastToken = nextToken;
  15369. str += lastToken.text;
  15370. this.consume();
  15371. }
  15372. if (str === "") {
  15373. throw new src_ParseError("Invalid " + modeName + ": '" + firstToken.text + "'", firstToken);
  15374. }
  15375. return firstToken.range(lastToken, str);
  15376. }
  15377. /**
  15378. * Parses a color description.
  15379. */
  15380. ;
  15381. _proto.parseColorGroup = function parseColorGroup(optional) {
  15382. var res = this.parseStringGroup("color", optional);
  15383. if (res == null) {
  15384. return null;
  15385. }
  15386. var match = /^(#[a-f0-9]{3}|#?[a-f0-9]{6}|[a-z]+)$/i.exec(res.text);
  15387. if (!match) {
  15388. throw new src_ParseError("Invalid color: '" + res.text + "'", res);
  15389. }
  15390. var color = match[0];
  15391. if (/^[0-9a-f]{6}$/i.test(color)) {
  15392. // We allow a 6-digit HTML color spec without a leading "#".
  15393. // This follows the xcolor package's HTML color model.
  15394. // Predefined color names are all missed by this RegEx pattern.
  15395. color = "#" + color;
  15396. }
  15397. return {
  15398. type: "color-token",
  15399. mode: this.mode,
  15400. color: color
  15401. };
  15402. }
  15403. /**
  15404. * Parses a size specification, consisting of magnitude and unit.
  15405. */
  15406. ;
  15407. _proto.parseSizeGroup = function parseSizeGroup(optional) {
  15408. var res;
  15409. var isBlank = false; // don't expand before parseStringGroup
  15410. this.gullet.consumeSpaces();
  15411. if (!optional && this.gullet.future().text !== "{") {
  15412. res = this.parseRegexGroup(/^[-+]? *(?:$|\d+|\d+\.\d*|\.\d*) *[a-z]{0,2} *$/, "size");
  15413. } else {
  15414. res = this.parseStringGroup("size", optional);
  15415. }
  15416. if (!res) {
  15417. return null;
  15418. }
  15419. if (!optional && res.text.length === 0) {
  15420. // Because we've tested for what is !optional, this block won't
  15421. // affect \kern, \hspace, etc. It will capture the mandatory arguments
  15422. // to \genfrac and \above.
  15423. res.text = "0pt"; // Enable \above{}
  15424. isBlank = true; // This is here specifically for \genfrac
  15425. }
  15426. var match = /([-+]?) *(\d+(?:\.\d*)?|\.\d+) *([a-z]{2})/.exec(res.text);
  15427. if (!match) {
  15428. throw new src_ParseError("Invalid size: '" + res.text + "'", res);
  15429. }
  15430. var data = {
  15431. number: +(match[1] + match[2]),
  15432. // sign + magnitude, cast to number
  15433. unit: match[3]
  15434. };
  15435. if (!validUnit(data)) {
  15436. throw new src_ParseError("Invalid unit: '" + data.unit + "'", res);
  15437. }
  15438. return {
  15439. type: "size",
  15440. mode: this.mode,
  15441. value: data,
  15442. isBlank: isBlank
  15443. };
  15444. }
  15445. /**
  15446. * Parses an URL, checking escaped letters and allowed protocols,
  15447. * and setting the catcode of % as an active character (as in \hyperref).
  15448. */
  15449. ;
  15450. _proto.parseUrlGroup = function parseUrlGroup(optional) {
  15451. this.gullet.lexer.setCatcode("%", 13); // active character
  15452. this.gullet.lexer.setCatcode("~", 12); // other character
  15453. var res = this.parseStringGroup("url", optional);
  15454. this.gullet.lexer.setCatcode("%", 14); // comment character
  15455. this.gullet.lexer.setCatcode("~", 13); // active character
  15456. if (res == null) {
  15457. return null;
  15458. } // hyperref package allows backslashes alone in href, but doesn't
  15459. // generate valid links in such cases; we interpret this as
  15460. // "undefined" behaviour, and keep them as-is. Some browser will
  15461. // replace backslashes with forward slashes.
  15462. var url = res.text.replace(/\\([#$%&~_^{}])/g, '$1');
  15463. return {
  15464. type: "url",
  15465. mode: this.mode,
  15466. url: url
  15467. };
  15468. }
  15469. /**
  15470. * Parses an argument with the mode specified.
  15471. */
  15472. ;
  15473. _proto.parseArgumentGroup = function parseArgumentGroup(optional, mode) {
  15474. var argToken = this.gullet.scanArgument(optional);
  15475. if (argToken == null) {
  15476. return null;
  15477. }
  15478. var outerMode = this.mode;
  15479. if (mode) {
  15480. // Switch to specified mode
  15481. this.switchMode(mode);
  15482. }
  15483. this.gullet.beginGroup();
  15484. var expression = this.parseExpression(false, "EOF"); // TODO: find an alternative way to denote the end
  15485. this.expect("EOF"); // expect the end of the argument
  15486. this.gullet.endGroup();
  15487. var result = {
  15488. type: "ordgroup",
  15489. mode: this.mode,
  15490. loc: argToken.loc,
  15491. body: expression
  15492. };
  15493. if (mode) {
  15494. // Switch mode back
  15495. this.switchMode(outerMode);
  15496. }
  15497. return result;
  15498. }
  15499. /**
  15500. * Parses an ordinary group, which is either a single nucleus (like "x")
  15501. * or an expression in braces (like "{x+y}") or an implicit group, a group
  15502. * that starts at the current position, and ends right before a higher explicit
  15503. * group ends, or at EOF.
  15504. */
  15505. ;
  15506. _proto.parseGroup = function parseGroup(name, // For error reporting.
  15507. breakOnTokenText) {
  15508. var firstToken = this.fetch();
  15509. var text = firstToken.text;
  15510. var result; // Try to parse an open brace or \begingroup
  15511. if (text === "{" || text === "\\begingroup") {
  15512. this.consume();
  15513. var groupEnd = text === "{" ? "}" : "\\endgroup";
  15514. this.gullet.beginGroup(); // If we get a brace, parse an expression
  15515. var expression = this.parseExpression(false, groupEnd);
  15516. var lastToken = this.fetch();
  15517. this.expect(groupEnd); // Check that we got a matching closing brace
  15518. this.gullet.endGroup();
  15519. result = {
  15520. type: "ordgroup",
  15521. mode: this.mode,
  15522. loc: SourceLocation.range(firstToken, lastToken),
  15523. body: expression,
  15524. // A group formed by \begingroup...\endgroup is a semi-simple group
  15525. // which doesn't affect spacing in math mode, i.e., is transparent.
  15526. // https://tex.stackexchange.com/questions/1930/when-should-one-
  15527. // use-begingroup-instead-of-bgroup
  15528. semisimple: text === "\\begingroup" || undefined
  15529. };
  15530. } else {
  15531. // If there exists a function with this name, parse the function.
  15532. // Otherwise, just return a nucleus
  15533. result = this.parseFunction(breakOnTokenText, name) || this.parseSymbol();
  15534. if (result == null && text[0] === "\\" && !implicitCommands.hasOwnProperty(text)) {
  15535. if (this.settings.throwOnError) {
  15536. throw new src_ParseError("Undefined control sequence: " + text, firstToken);
  15537. }
  15538. result = this.formatUnsupportedCmd(text);
  15539. this.consume();
  15540. }
  15541. }
  15542. return result;
  15543. }
  15544. /**
  15545. * Form ligature-like combinations of characters for text mode.
  15546. * This includes inputs like "--", "---", "``" and "''".
  15547. * The result will simply replace multiple textord nodes with a single
  15548. * character in each value by a single textord node having multiple
  15549. * characters in its value. The representation is still ASCII source.
  15550. * The group will be modified in place.
  15551. */
  15552. ;
  15553. _proto.formLigatures = function formLigatures(group) {
  15554. var n = group.length - 1;
  15555. for (var i = 0; i < n; ++i) {
  15556. var a = group[i]; // $FlowFixMe: Not every node type has a `text` property.
  15557. var v = a.text;
  15558. if (v === "-" && group[i + 1].text === "-") {
  15559. if (i + 1 < n && group[i + 2].text === "-") {
  15560. group.splice(i, 3, {
  15561. type: "textord",
  15562. mode: "text",
  15563. loc: SourceLocation.range(a, group[i + 2]),
  15564. text: "---"
  15565. });
  15566. n -= 2;
  15567. } else {
  15568. group.splice(i, 2, {
  15569. type: "textord",
  15570. mode: "text",
  15571. loc: SourceLocation.range(a, group[i + 1]),
  15572. text: "--"
  15573. });
  15574. n -= 1;
  15575. }
  15576. }
  15577. if ((v === "'" || v === "`") && group[i + 1].text === v) {
  15578. group.splice(i, 2, {
  15579. type: "textord",
  15580. mode: "text",
  15581. loc: SourceLocation.range(a, group[i + 1]),
  15582. text: v + v
  15583. });
  15584. n -= 1;
  15585. }
  15586. }
  15587. }
  15588. /**
  15589. * Parse a single symbol out of the string. Here, we handle single character
  15590. * symbols and special functions like \verb.
  15591. */
  15592. ;
  15593. _proto.parseSymbol = function parseSymbol() {
  15594. var nucleus = this.fetch();
  15595. var text = nucleus.text;
  15596. if (/^\\verb[^a-zA-Z]/.test(text)) {
  15597. this.consume();
  15598. var arg = text.slice(5);
  15599. var star = arg.charAt(0) === "*";
  15600. if (star) {
  15601. arg = arg.slice(1);
  15602. } // Lexer's tokenRegex is constructed to always have matching
  15603. // first/last characters.
  15604. if (arg.length < 2 || arg.charAt(0) !== arg.slice(-1)) {
  15605. throw new src_ParseError("\\verb assertion failed --\n please report what input caused this bug");
  15606. }
  15607. arg = arg.slice(1, -1); // remove first and last char
  15608. return {
  15609. type: "verb",
  15610. mode: "text",
  15611. body: arg,
  15612. star: star
  15613. };
  15614. } // At this point, we should have a symbol, possibly with accents.
  15615. // First expand any accented base symbol according to unicodeSymbols.
  15616. if (unicodeSymbols.hasOwnProperty(text[0]) && !src_symbols[this.mode][text[0]]) {
  15617. // This behavior is not strict (XeTeX-compatible) in math mode.
  15618. if (this.settings.strict && this.mode === "math") {
  15619. this.settings.reportNonstrict("unicodeTextInMathMode", "Accented Unicode text character \"" + text[0] + "\" used in " + "math mode", nucleus);
  15620. }
  15621. text = unicodeSymbols[text[0]] + text.substr(1);
  15622. } // Strip off any combining characters
  15623. var match = combiningDiacriticalMarksEndRegex.exec(text);
  15624. if (match) {
  15625. text = text.substring(0, match.index);
  15626. if (text === 'i') {
  15627. text = "\u0131"; // dotless i, in math and text mode
  15628. } else if (text === 'j') {
  15629. text = "\u0237"; // dotless j, in math and text mode
  15630. }
  15631. } // Recognize base symbol
  15632. var symbol;
  15633. if (src_symbols[this.mode][text]) {
  15634. if (this.settings.strict && this.mode === 'math' && extraLatin.indexOf(text) >= 0) {
  15635. this.settings.reportNonstrict("unicodeTextInMathMode", "Latin-1/Unicode text character \"" + text[0] + "\" used in " + "math mode", nucleus);
  15636. }
  15637. var group = src_symbols[this.mode][text].group;
  15638. var loc = SourceLocation.range(nucleus);
  15639. var s;
  15640. if (ATOMS.hasOwnProperty(group)) {
  15641. // $FlowFixMe
  15642. var family = group;
  15643. s = {
  15644. type: "atom",
  15645. mode: this.mode,
  15646. family: family,
  15647. loc: loc,
  15648. text: text
  15649. };
  15650. } else {
  15651. // $FlowFixMe
  15652. s = {
  15653. type: group,
  15654. mode: this.mode,
  15655. loc: loc,
  15656. text: text
  15657. };
  15658. } // $FlowFixMe
  15659. symbol = s;
  15660. } else if (text.charCodeAt(0) >= 0x80) {
  15661. // no symbol for e.g. ^
  15662. if (this.settings.strict) {
  15663. if (!supportedCodepoint(text.charCodeAt(0))) {
  15664. this.settings.reportNonstrict("unknownSymbol", "Unrecognized Unicode character \"" + text[0] + "\"" + (" (" + text.charCodeAt(0) + ")"), nucleus);
  15665. } else if (this.mode === "math") {
  15666. this.settings.reportNonstrict("unicodeTextInMathMode", "Unicode text character \"" + text[0] + "\" used in math mode", nucleus);
  15667. }
  15668. } // All nonmathematical Unicode characters are rendered as if they
  15669. // are in text mode (wrapped in \text) because that's what it
  15670. // takes to render them in LaTeX. Setting `mode: this.mode` is
  15671. // another natural choice (the user requested math mode), but
  15672. // this makes it more difficult for getCharacterMetrics() to
  15673. // distinguish Unicode characters without metrics and those for
  15674. // which we want to simulate the letter M.
  15675. symbol = {
  15676. type: "textord",
  15677. mode: "text",
  15678. loc: SourceLocation.range(nucleus),
  15679. text: text
  15680. };
  15681. } else {
  15682. return null; // EOF, ^, _, {, }, etc.
  15683. }
  15684. this.consume(); // Transform combining characters into accents
  15685. if (match) {
  15686. for (var i = 0; i < match[0].length; i++) {
  15687. var accent = match[0][i];
  15688. if (!unicodeAccents[accent]) {
  15689. throw new src_ParseError("Unknown accent ' " + accent + "'", nucleus);
  15690. }
  15691. var command = unicodeAccents[accent][this.mode] || unicodeAccents[accent].text;
  15692. if (!command) {
  15693. throw new src_ParseError("Accent " + accent + " unsupported in " + this.mode + " mode", nucleus);
  15694. }
  15695. symbol = {
  15696. type: "accent",
  15697. mode: this.mode,
  15698. loc: SourceLocation.range(nucleus),
  15699. label: command,
  15700. isStretchy: false,
  15701. isShifty: true,
  15702. // $FlowFixMe
  15703. base: symbol
  15704. };
  15705. }
  15706. } // $FlowFixMe
  15707. return symbol;
  15708. };
  15709. return Parser;
  15710. }();
  15711. Parser.endOfExpression = ["}", "\\endgroup", "\\end", "\\right", "&"];
  15712. ;// CONCATENATED MODULE: ./src/parseTree.js
  15713. /**
  15714. * Provides a single function for parsing an expression using a Parser
  15715. * TODO(emily): Remove this
  15716. */
  15717. /**
  15718. * Parses an expression using a Parser, then returns the parsed result.
  15719. */
  15720. var parseTree = function parseTree(toParse, settings) {
  15721. if (!(typeof toParse === 'string' || toParse instanceof String)) {
  15722. throw new TypeError('KaTeX can only parse string typed expression');
  15723. }
  15724. var parser = new Parser(toParse, settings); // Blank out any \df@tag to avoid spurious "Duplicate \tag" errors
  15725. delete parser.gullet.macros.current["\\df@tag"];
  15726. var tree = parser.parse(); // Prevent a color definition from persisting between calls to katex.render().
  15727. delete parser.gullet.macros.current["\\current@color"];
  15728. delete parser.gullet.macros.current["\\color"]; // If the input used \tag, it will set the \df@tag macro to the tag.
  15729. // In this case, we separately parse the tag and wrap the tree.
  15730. if (parser.gullet.macros.get("\\df@tag")) {
  15731. if (!settings.displayMode) {
  15732. throw new src_ParseError("\\tag works only in display equations");
  15733. }
  15734. tree = [{
  15735. type: "tag",
  15736. mode: "text",
  15737. body: tree,
  15738. tag: parser.subparse([new Token("\\df@tag")])
  15739. }];
  15740. }
  15741. return tree;
  15742. };
  15743. /* harmony default export */ var src_parseTree = (parseTree);
  15744. ;// CONCATENATED MODULE: ./katex.js
  15745. /* eslint no-console:0 */
  15746. /**
  15747. * This is the main entry point for KaTeX. Here, we expose functions for
  15748. * rendering expressions either to DOM nodes or to markup strings.
  15749. *
  15750. * We also expose the ParseError class to check if errors thrown from KaTeX are
  15751. * errors in the expression, or errors in javascript handling.
  15752. */
  15753. /**
  15754. * Parse and build an expression, and place that expression in the DOM node
  15755. * given.
  15756. */
  15757. var render = function render(expression, baseNode, options) {
  15758. baseNode.textContent = "";
  15759. var node = renderToDomTree(expression, options).toNode();
  15760. baseNode.appendChild(node);
  15761. }; // KaTeX's styles don't work properly in quirks mode. Print out an error, and
  15762. // disable rendering.
  15763. if (typeof document !== "undefined") {
  15764. if (document.compatMode !== "CSS1Compat") {
  15765. typeof console !== "undefined" && console.warn("Warning: KaTeX doesn't work in quirks mode. Make sure your " + "website has a suitable doctype.");
  15766. render = function render() {
  15767. throw new src_ParseError("KaTeX doesn't work in quirks mode.");
  15768. };
  15769. }
  15770. }
  15771. /**
  15772. * Parse and build an expression, and return the markup for that.
  15773. */
  15774. var renderToString = function renderToString(expression, options) {
  15775. var markup = renderToDomTree(expression, options).toMarkup();
  15776. return markup;
  15777. };
  15778. /**
  15779. * Parse an expression and return the parse tree.
  15780. */
  15781. var generateParseTree = function generateParseTree(expression, options) {
  15782. var settings = new Settings(options);
  15783. return src_parseTree(expression, settings);
  15784. };
  15785. /**
  15786. * If the given error is a KaTeX ParseError and options.throwOnError is false,
  15787. * renders the invalid LaTeX as a span with hover title giving the KaTeX
  15788. * error message. Otherwise, simply throws the error.
  15789. */
  15790. var renderError = function renderError(error, expression, options) {
  15791. if (options.throwOnError || !(error instanceof src_ParseError)) {
  15792. throw error;
  15793. }
  15794. var node = buildCommon.makeSpan(["katex-error"], [new SymbolNode(expression)]);
  15795. node.setAttribute("title", error.toString());
  15796. node.setAttribute("style", "color:" + options.errorColor);
  15797. return node;
  15798. };
  15799. /**
  15800. * Generates and returns the katex build tree. This is used for advanced
  15801. * use cases (like rendering to custom output).
  15802. */
  15803. var renderToDomTree = function renderToDomTree(expression, options) {
  15804. var settings = new Settings(options);
  15805. try {
  15806. var tree = src_parseTree(expression, settings);
  15807. return buildTree(tree, expression, settings);
  15808. } catch (error) {
  15809. return renderError(error, expression, settings);
  15810. }
  15811. };
  15812. /**
  15813. * Generates and returns the katex build tree, with just HTML (no MathML).
  15814. * This is used for advanced use cases (like rendering to custom output).
  15815. */
  15816. var renderToHTMLTree = function renderToHTMLTree(expression, options) {
  15817. var settings = new Settings(options);
  15818. try {
  15819. var tree = src_parseTree(expression, settings);
  15820. return buildHTMLTree(tree, expression, settings);
  15821. } catch (error) {
  15822. return renderError(error, expression, settings);
  15823. }
  15824. };
  15825. /* harmony default export */ var katex = ({
  15826. /**
  15827. * Current KaTeX version
  15828. */
  15829. version: "0.15.3",
  15830. /**
  15831. * Renders the given LaTeX into an HTML+MathML combination, and adds
  15832. * it as a child to the specified DOM node.
  15833. */
  15834. render: render,
  15835. /**
  15836. * Renders the given LaTeX into an HTML+MathML combination string,
  15837. * for sending to the client.
  15838. */
  15839. renderToString: renderToString,
  15840. /**
  15841. * KaTeX error, usually during parsing.
  15842. */
  15843. ParseError: src_ParseError,
  15844. /**
  15845. * The shema of Settings
  15846. */
  15847. SETTINGS_SCHEMA: SETTINGS_SCHEMA,
  15848. /**
  15849. * Parses the given LaTeX into KaTeX's internal parse tree structure,
  15850. * without rendering to HTML or MathML.
  15851. *
  15852. * NOTE: This method is not currently recommended for public use.
  15853. * The internal tree representation is unstable and is very likely
  15854. * to change. Use at your own risk.
  15855. */
  15856. __parse: generateParseTree,
  15857. /**
  15858. * Renders the given LaTeX into an HTML+MathML internal DOM tree
  15859. * representation, without flattening that representation to a string.
  15860. *
  15861. * NOTE: This method is not currently recommended for public use.
  15862. * The internal tree representation is unstable and is very likely
  15863. * to change. Use at your own risk.
  15864. */
  15865. __renderToDomTree: renderToDomTree,
  15866. /**
  15867. * Renders the given LaTeX into an HTML internal DOM tree representation,
  15868. * without MathML and without flattening that representation to a string.
  15869. *
  15870. * NOTE: This method is not currently recommended for public use.
  15871. * The internal tree representation is unstable and is very likely
  15872. * to change. Use at your own risk.
  15873. */
  15874. __renderToHTMLTree: renderToHTMLTree,
  15875. /**
  15876. * extends internal font metrics object with a new object
  15877. * each key in the new object represents a font name
  15878. */
  15879. __setFontMetrics: setFontMetrics,
  15880. /**
  15881. * adds a new symbol to builtin symbols table
  15882. */
  15883. __defineSymbol: defineSymbol,
  15884. /**
  15885. * adds a new macro to builtin macro list
  15886. */
  15887. __defineMacro: defineMacro,
  15888. /**
  15889. * Expose the dom tree node types, which can be useful for type checking nodes.
  15890. *
  15891. * NOTE: This method is not currently recommended for public use.
  15892. * The internal tree representation is unstable and is very likely
  15893. * to change. Use at your own risk.
  15894. */
  15895. __domTree: {
  15896. Span: Span,
  15897. Anchor: Anchor,
  15898. SymbolNode: SymbolNode,
  15899. SvgNode: SvgNode,
  15900. PathNode: PathNode,
  15901. LineNode: LineNode
  15902. }
  15903. });
  15904. ;// CONCATENATED MODULE: ./katex.webpack.js
  15905. /**
  15906. * This is the webpack entry point for KaTeX. As ECMAScript, flow[1] and jest[2]
  15907. * doesn't support CSS modules natively, a separate entry point is used and
  15908. * it is not flowtyped.
  15909. *
  15910. * [1] https://gist.github.com/lambdahands/d19e0da96285b749f0ef
  15911. * [2] https://facebook.github.io/jest/docs/en/webpack.html
  15912. */
  15913. /* harmony default export */ var katex_webpack = (katex);
  15914. __webpack_exports__ = __webpack_exports__["default"];
  15915. /******/ return __webpack_exports__;
  15916. /******/ })()
  15917. ;
  15918. });