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.

874 lines
24 KiB

  1. (function webpackUniversalModuleDefinition(root, factory) {
  2. if(typeof exports === 'object' && typeof module === 'object')
  3. module.exports = factory(require("katex"));
  4. else if(typeof define === 'function' && define.amd)
  5. define(["katex"], factory);
  6. else {
  7. var a = typeof exports === 'object' ? factory(require("katex")) : factory(root["katex"]);
  8. for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];
  9. }
  10. })((typeof self !== 'undefined' ? self : this), function(__WEBPACK_EXTERNAL_MODULE__771__) {
  11. return /******/ (function() { // webpackBootstrap
  12. /******/ "use strict";
  13. /******/ var __webpack_modules__ = ({
  14. /***/ 771:
  15. /***/ (function(module) {
  16. module.exports = __WEBPACK_EXTERNAL_MODULE__771__;
  17. /***/ })
  18. /******/ });
  19. /************************************************************************/
  20. /******/ // The module cache
  21. /******/ var __webpack_module_cache__ = {};
  22. /******/
  23. /******/ // The require function
  24. /******/ function __webpack_require__(moduleId) {
  25. /******/ // Check if module is in cache
  26. /******/ var cachedModule = __webpack_module_cache__[moduleId];
  27. /******/ if (cachedModule !== undefined) {
  28. /******/ return cachedModule.exports;
  29. /******/ }
  30. /******/ // Create a new module (and put it into the cache)
  31. /******/ var module = __webpack_module_cache__[moduleId] = {
  32. /******/ // no module.id needed
  33. /******/ // no module.loaded needed
  34. /******/ exports: {}
  35. /******/ };
  36. /******/
  37. /******/ // Execute the module function
  38. /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
  39. /******/
  40. /******/ // Return the exports of the module
  41. /******/ return module.exports;
  42. /******/ }
  43. /******/
  44. /************************************************************************/
  45. /******/ /* webpack/runtime/compat get default export */
  46. /******/ !function() {
  47. /******/ // getDefaultExport function for compatibility with non-harmony modules
  48. /******/ __webpack_require__.n = function(module) {
  49. /******/ var getter = module && module.__esModule ?
  50. /******/ function() { return module['default']; } :
  51. /******/ function() { return module; };
  52. /******/ __webpack_require__.d(getter, { a: getter });
  53. /******/ return getter;
  54. /******/ };
  55. /******/ }();
  56. /******/
  57. /******/ /* webpack/runtime/define property getters */
  58. /******/ !function() {
  59. /******/ // define getter functions for harmony exports
  60. /******/ __webpack_require__.d = function(exports, definition) {
  61. /******/ for(var key in definition) {
  62. /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
  63. /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
  64. /******/ }
  65. /******/ }
  66. /******/ };
  67. /******/ }();
  68. /******/
  69. /******/ /* webpack/runtime/hasOwnProperty shorthand */
  70. /******/ !function() {
  71. /******/ __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); }
  72. /******/ }();
  73. /******/
  74. /************************************************************************/
  75. var __webpack_exports__ = {};
  76. // This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
  77. !function() {
  78. /* harmony import */ var katex__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(771);
  79. /* harmony import */ var katex__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(katex__WEBPACK_IMPORTED_MODULE_0__);
  80. /**
  81. * renderA11yString returns a readable string.
  82. *
  83. * In some cases the string will have the proper semantic math
  84. * meaning,:
  85. * renderA11yString("\\frac{1}{2}"")
  86. * -> "start fraction, 1, divided by, 2, end fraction"
  87. *
  88. * However, other cases do not:
  89. * renderA11yString("f(x) = x^2")
  90. * -> "f, left parenthesis, x, right parenthesis, equals, x, squared"
  91. *
  92. * The commas in the string aim to increase ease of understanding
  93. * when read by a screenreader.
  94. */
  95. // NOTE: since we're importing types here these files won't actually be
  96. // included in the build.
  97. // $FlowIgnore: we import the types directly anyways
  98. var stringMap = {
  99. "(": "left parenthesis",
  100. ")": "right parenthesis",
  101. "[": "open bracket",
  102. "]": "close bracket",
  103. "\\{": "left brace",
  104. "\\}": "right brace",
  105. "\\lvert": "open vertical bar",
  106. "\\rvert": "close vertical bar",
  107. "|": "vertical bar",
  108. "\\uparrow": "up arrow",
  109. "\\Uparrow": "up arrow",
  110. "\\downarrow": "down arrow",
  111. "\\Downarrow": "down arrow",
  112. "\\updownarrow": "up down arrow",
  113. "\\leftarrow": "left arrow",
  114. "\\Leftarrow": "left arrow",
  115. "\\rightarrow": "right arrow",
  116. "\\Rightarrow": "right arrow",
  117. "\\langle": "open angle",
  118. "\\rangle": "close angle",
  119. "\\lfloor": "open floor",
  120. "\\rfloor": "close floor",
  121. "\\int": "integral",
  122. "\\intop": "integral",
  123. "\\lim": "limit",
  124. "\\ln": "natural log",
  125. "\\log": "log",
  126. "\\sin": "sine",
  127. "\\cos": "cosine",
  128. "\\tan": "tangent",
  129. "\\cot": "cotangent",
  130. "\\sum": "sum",
  131. "/": "slash",
  132. ",": "comma",
  133. ".": "point",
  134. "-": "negative",
  135. "+": "plus",
  136. "~": "tilde",
  137. ":": "colon",
  138. "?": "question mark",
  139. "'": "apostrophe",
  140. "\\%": "percent",
  141. " ": "space",
  142. "\\ ": "space",
  143. "\\$": "dollar sign",
  144. "\\angle": "angle",
  145. "\\degree": "degree",
  146. "\\circ": "circle",
  147. "\\vec": "vector",
  148. "\\triangle": "triangle",
  149. "\\pi": "pi",
  150. "\\prime": "prime",
  151. "\\infty": "infinity",
  152. "\\alpha": "alpha",
  153. "\\beta": "beta",
  154. "\\gamma": "gamma",
  155. "\\omega": "omega",
  156. "\\theta": "theta",
  157. "\\sigma": "sigma",
  158. "\\lambda": "lambda",
  159. "\\tau": "tau",
  160. "\\Delta": "delta",
  161. "\\delta": "delta",
  162. "\\mu": "mu",
  163. "\\rho": "rho",
  164. "\\nabla": "del",
  165. "\\ell": "ell",
  166. "\\ldots": "dots",
  167. // TODO: add entries for all accents
  168. "\\hat": "hat",
  169. "\\acute": "acute"
  170. };
  171. var powerMap = {
  172. "prime": "prime",
  173. "degree": "degrees",
  174. "circle": "degrees",
  175. "2": "squared",
  176. "3": "cubed"
  177. };
  178. var openMap = {
  179. "|": "open vertical bar",
  180. ".": ""
  181. };
  182. var closeMap = {
  183. "|": "close vertical bar",
  184. ".": ""
  185. };
  186. var binMap = {
  187. "+": "plus",
  188. "-": "minus",
  189. "\\pm": "plus minus",
  190. "\\cdot": "dot",
  191. "*": "times",
  192. "/": "divided by",
  193. "\\times": "times",
  194. "\\div": "divided by",
  195. "\\circ": "circle",
  196. "\\bullet": "bullet"
  197. };
  198. var relMap = {
  199. "=": "equals",
  200. "\\approx": "approximately equals",
  201. "≠": "does not equal",
  202. "\\geq": "is greater than or equal to",
  203. "\\ge": "is greater than or equal to",
  204. "\\leq": "is less than or equal to",
  205. "\\le": "is less than or equal to",
  206. ">": "is greater than",
  207. "<": "is less than",
  208. "\\leftarrow": "left arrow",
  209. "\\Leftarrow": "left arrow",
  210. "\\rightarrow": "right arrow",
  211. "\\Rightarrow": "right arrow",
  212. ":": "colon"
  213. };
  214. var accentUnderMap = {
  215. "\\underleftarrow": "left arrow",
  216. "\\underrightarrow": "right arrow",
  217. "\\underleftrightarrow": "left-right arrow",
  218. "\\undergroup": "group",
  219. "\\underlinesegment": "line segment",
  220. "\\utilde": "tilde"
  221. };
  222. var buildString = function buildString(str, type, a11yStrings) {
  223. if (!str) {
  224. return;
  225. }
  226. var ret;
  227. if (type === "open") {
  228. ret = str in openMap ? openMap[str] : stringMap[str] || str;
  229. } else if (type === "close") {
  230. ret = str in closeMap ? closeMap[str] : stringMap[str] || str;
  231. } else if (type === "bin") {
  232. ret = binMap[str] || str;
  233. } else if (type === "rel") {
  234. ret = relMap[str] || str;
  235. } else {
  236. ret = stringMap[str] || str;
  237. } // If the text to add is a number and there is already a string
  238. // in the list and the last string is a number then we should
  239. // combine them into a single number
  240. if (/^\d+$/.test(ret) && a11yStrings.length > 0 && // TODO(kevinb): check that the last item in a11yStrings is a string
  241. // I think we might be able to drop the nested arrays, which would make
  242. // this easier to type
  243. // $FlowFixMe
  244. /^\d+$/.test(a11yStrings[a11yStrings.length - 1])) {
  245. a11yStrings[a11yStrings.length - 1] += ret;
  246. } else if (ret) {
  247. a11yStrings.push(ret);
  248. }
  249. };
  250. var buildRegion = function buildRegion(a11yStrings, callback) {
  251. var regionStrings = [];
  252. a11yStrings.push(regionStrings);
  253. callback(regionStrings);
  254. };
  255. var handleObject = function handleObject(tree, a11yStrings, atomType) {
  256. // Everything else is assumed to be an object...
  257. switch (tree.type) {
  258. case "accent":
  259. {
  260. buildRegion(a11yStrings, function (a11yStrings) {
  261. buildA11yStrings(tree.base, a11yStrings, atomType);
  262. a11yStrings.push("with");
  263. buildString(tree.label, "normal", a11yStrings);
  264. a11yStrings.push("on top");
  265. });
  266. break;
  267. }
  268. case "accentUnder":
  269. {
  270. buildRegion(a11yStrings, function (a11yStrings) {
  271. buildA11yStrings(tree.base, a11yStrings, atomType);
  272. a11yStrings.push("with");
  273. buildString(accentUnderMap[tree.label], "normal", a11yStrings);
  274. a11yStrings.push("underneath");
  275. });
  276. break;
  277. }
  278. case "accent-token":
  279. {
  280. // Used internally by accent symbols.
  281. break;
  282. }
  283. case "atom":
  284. {
  285. var text = tree.text;
  286. switch (tree.family) {
  287. case "bin":
  288. {
  289. buildString(text, "bin", a11yStrings);
  290. break;
  291. }
  292. case "close":
  293. {
  294. buildString(text, "close", a11yStrings);
  295. break;
  296. }
  297. // TODO(kevinb): figure out what should be done for inner
  298. case "inner":
  299. {
  300. buildString(tree.text, "inner", a11yStrings);
  301. break;
  302. }
  303. case "open":
  304. {
  305. buildString(text, "open", a11yStrings);
  306. break;
  307. }
  308. case "punct":
  309. {
  310. buildString(text, "punct", a11yStrings);
  311. break;
  312. }
  313. case "rel":
  314. {
  315. buildString(text, "rel", a11yStrings);
  316. break;
  317. }
  318. default:
  319. {
  320. tree.family;
  321. throw new Error("\"" + tree.family + "\" is not a valid atom type");
  322. }
  323. }
  324. break;
  325. }
  326. case "color":
  327. {
  328. var color = tree.color.replace(/katex-/, "");
  329. buildRegion(a11yStrings, function (regionStrings) {
  330. regionStrings.push("start color " + color);
  331. buildA11yStrings(tree.body, regionStrings, atomType);
  332. regionStrings.push("end color " + color);
  333. });
  334. break;
  335. }
  336. case "color-token":
  337. {
  338. // Used by \color, \colorbox, and \fcolorbox but not directly rendered.
  339. // It's a leaf node and has no children so just break.
  340. break;
  341. }
  342. case "delimsizing":
  343. {
  344. if (tree.delim && tree.delim !== ".") {
  345. buildString(tree.delim, "normal", a11yStrings);
  346. }
  347. break;
  348. }
  349. case "genfrac":
  350. {
  351. buildRegion(a11yStrings, function (regionStrings) {
  352. // genfrac can have unbalanced delimiters
  353. var leftDelim = tree.leftDelim,
  354. rightDelim = tree.rightDelim; // NOTE: Not sure if this is a safe assumption
  355. // hasBarLine true -> fraction, false -> binomial
  356. if (tree.hasBarLine) {
  357. regionStrings.push("start fraction");
  358. leftDelim && buildString(leftDelim, "open", regionStrings);
  359. buildA11yStrings(tree.numer, regionStrings, atomType);
  360. regionStrings.push("divided by");
  361. buildA11yStrings(tree.denom, regionStrings, atomType);
  362. rightDelim && buildString(rightDelim, "close", regionStrings);
  363. regionStrings.push("end fraction");
  364. } else {
  365. regionStrings.push("start binomial");
  366. leftDelim && buildString(leftDelim, "open", regionStrings);
  367. buildA11yStrings(tree.numer, regionStrings, atomType);
  368. regionStrings.push("over");
  369. buildA11yStrings(tree.denom, regionStrings, atomType);
  370. rightDelim && buildString(rightDelim, "close", regionStrings);
  371. regionStrings.push("end binomial");
  372. }
  373. });
  374. break;
  375. }
  376. case "hbox":
  377. {
  378. buildA11yStrings(tree.body, a11yStrings, atomType);
  379. break;
  380. }
  381. case "kern":
  382. {
  383. // No op: we don't attempt to present kerning information
  384. // to the screen reader.
  385. break;
  386. }
  387. case "leftright":
  388. {
  389. buildRegion(a11yStrings, function (regionStrings) {
  390. buildString(tree.left, "open", regionStrings);
  391. buildA11yStrings(tree.body, regionStrings, atomType);
  392. buildString(tree.right, "close", regionStrings);
  393. });
  394. break;
  395. }
  396. case "leftright-right":
  397. {
  398. // TODO: double check that this is a no-op
  399. break;
  400. }
  401. case "lap":
  402. {
  403. buildA11yStrings(tree.body, a11yStrings, atomType);
  404. break;
  405. }
  406. case "mathord":
  407. {
  408. buildString(tree.text, "normal", a11yStrings);
  409. break;
  410. }
  411. case "op":
  412. {
  413. var body = tree.body,
  414. name = tree.name;
  415. if (body) {
  416. buildA11yStrings(body, a11yStrings, atomType);
  417. } else if (name) {
  418. buildString(name, "normal", a11yStrings);
  419. }
  420. break;
  421. }
  422. case "op-token":
  423. {
  424. // Used internally by operator symbols.
  425. buildString(tree.text, atomType, a11yStrings);
  426. break;
  427. }
  428. case "ordgroup":
  429. {
  430. buildA11yStrings(tree.body, a11yStrings, atomType);
  431. break;
  432. }
  433. case "overline":
  434. {
  435. buildRegion(a11yStrings, function (a11yStrings) {
  436. a11yStrings.push("start overline");
  437. buildA11yStrings(tree.body, a11yStrings, atomType);
  438. a11yStrings.push("end overline");
  439. });
  440. break;
  441. }
  442. case "phantom":
  443. {
  444. a11yStrings.push("empty space");
  445. break;
  446. }
  447. case "raisebox":
  448. {
  449. buildA11yStrings(tree.body, a11yStrings, atomType);
  450. break;
  451. }
  452. case "rule":
  453. {
  454. a11yStrings.push("rectangle");
  455. break;
  456. }
  457. case "sizing":
  458. {
  459. buildA11yStrings(tree.body, a11yStrings, atomType);
  460. break;
  461. }
  462. case "spacing":
  463. {
  464. a11yStrings.push("space");
  465. break;
  466. }
  467. case "styling":
  468. {
  469. // We ignore the styling and just pass through the contents
  470. buildA11yStrings(tree.body, a11yStrings, atomType);
  471. break;
  472. }
  473. case "sqrt":
  474. {
  475. buildRegion(a11yStrings, function (regionStrings) {
  476. var body = tree.body,
  477. index = tree.index;
  478. if (index) {
  479. var indexString = flatten(buildA11yStrings(index, [], atomType)).join(",");
  480. if (indexString === "3") {
  481. regionStrings.push("cube root of");
  482. buildA11yStrings(body, regionStrings, atomType);
  483. regionStrings.push("end cube root");
  484. return;
  485. }
  486. regionStrings.push("root");
  487. regionStrings.push("start index");
  488. buildA11yStrings(index, regionStrings, atomType);
  489. regionStrings.push("end index");
  490. return;
  491. }
  492. regionStrings.push("square root of");
  493. buildA11yStrings(body, regionStrings, atomType);
  494. regionStrings.push("end square root");
  495. });
  496. break;
  497. }
  498. case "supsub":
  499. {
  500. var base = tree.base,
  501. sub = tree.sub,
  502. sup = tree.sup;
  503. var isLog = false;
  504. if (base) {
  505. buildA11yStrings(base, a11yStrings, atomType);
  506. isLog = base.type === "op" && base.name === "\\log";
  507. }
  508. if (sub) {
  509. var regionName = isLog ? "base" : "subscript";
  510. buildRegion(a11yStrings, function (regionStrings) {
  511. regionStrings.push("start " + regionName);
  512. buildA11yStrings(sub, regionStrings, atomType);
  513. regionStrings.push("end " + regionName);
  514. });
  515. }
  516. if (sup) {
  517. buildRegion(a11yStrings, function (regionStrings) {
  518. var supString = flatten(buildA11yStrings(sup, [], atomType)).join(",");
  519. if (supString in powerMap) {
  520. regionStrings.push(powerMap[supString]);
  521. return;
  522. }
  523. regionStrings.push("start superscript");
  524. buildA11yStrings(sup, regionStrings, atomType);
  525. regionStrings.push("end superscript");
  526. });
  527. }
  528. break;
  529. }
  530. case "text":
  531. {
  532. // TODO: handle other fonts
  533. if (tree.font === "\\textbf") {
  534. buildRegion(a11yStrings, function (regionStrings) {
  535. regionStrings.push("start bold text");
  536. buildA11yStrings(tree.body, regionStrings, atomType);
  537. regionStrings.push("end bold text");
  538. });
  539. break;
  540. }
  541. buildRegion(a11yStrings, function (regionStrings) {
  542. regionStrings.push("start text");
  543. buildA11yStrings(tree.body, regionStrings, atomType);
  544. regionStrings.push("end text");
  545. });
  546. break;
  547. }
  548. case "textord":
  549. {
  550. buildString(tree.text, atomType, a11yStrings);
  551. break;
  552. }
  553. case "smash":
  554. {
  555. buildA11yStrings(tree.body, a11yStrings, atomType);
  556. break;
  557. }
  558. case "enclose":
  559. {
  560. // TODO: create a map for these.
  561. // TODO: differentiate between a body with a single atom, e.g.
  562. // "cancel a" instead of "start cancel, a, end cancel"
  563. if (/cancel/.test(tree.label)) {
  564. buildRegion(a11yStrings, function (regionStrings) {
  565. regionStrings.push("start cancel");
  566. buildA11yStrings(tree.body, regionStrings, atomType);
  567. regionStrings.push("end cancel");
  568. });
  569. break;
  570. } else if (/box/.test(tree.label)) {
  571. buildRegion(a11yStrings, function (regionStrings) {
  572. regionStrings.push("start box");
  573. buildA11yStrings(tree.body, regionStrings, atomType);
  574. regionStrings.push("end box");
  575. });
  576. break;
  577. } else if (/sout/.test(tree.label)) {
  578. buildRegion(a11yStrings, function (regionStrings) {
  579. regionStrings.push("start strikeout");
  580. buildA11yStrings(tree.body, regionStrings, atomType);
  581. regionStrings.push("end strikeout");
  582. });
  583. break;
  584. } else if (/phase/.test(tree.label)) {
  585. buildRegion(a11yStrings, function (regionStrings) {
  586. regionStrings.push("start phase angle");
  587. buildA11yStrings(tree.body, regionStrings, atomType);
  588. regionStrings.push("end phase angle");
  589. });
  590. break;
  591. }
  592. throw new Error("KaTeX-a11y: enclose node with " + tree.label + " not supported yet");
  593. }
  594. case "vcenter":
  595. {
  596. buildA11yStrings(tree.body, a11yStrings, atomType);
  597. break;
  598. }
  599. case "vphantom":
  600. {
  601. throw new Error("KaTeX-a11y: vphantom not implemented yet");
  602. }
  603. case "hphantom":
  604. {
  605. throw new Error("KaTeX-a11y: hphantom not implemented yet");
  606. }
  607. case "operatorname":
  608. {
  609. buildA11yStrings(tree.body, a11yStrings, atomType);
  610. break;
  611. }
  612. case "array":
  613. {
  614. throw new Error("KaTeX-a11y: array not implemented yet");
  615. }
  616. case "raw":
  617. {
  618. throw new Error("KaTeX-a11y: raw not implemented yet");
  619. }
  620. case "size":
  621. {
  622. // Although there are nodes of type "size" in the parse tree, they have
  623. // no semantic meaning and should be ignored.
  624. break;
  625. }
  626. case "url":
  627. {
  628. throw new Error("KaTeX-a11y: url not implemented yet");
  629. }
  630. case "tag":
  631. {
  632. throw new Error("KaTeX-a11y: tag not implemented yet");
  633. }
  634. case "verb":
  635. {
  636. buildString("start verbatim", "normal", a11yStrings);
  637. buildString(tree.body, "normal", a11yStrings);
  638. buildString("end verbatim", "normal", a11yStrings);
  639. break;
  640. }
  641. case "environment":
  642. {
  643. throw new Error("KaTeX-a11y: environment not implemented yet");
  644. }
  645. case "horizBrace":
  646. {
  647. buildString("start " + tree.label.slice(1), "normal", a11yStrings);
  648. buildA11yStrings(tree.base, a11yStrings, atomType);
  649. buildString("end " + tree.label.slice(1), "normal", a11yStrings);
  650. break;
  651. }
  652. case "infix":
  653. {
  654. // All infix nodes are replace with other nodes.
  655. break;
  656. }
  657. case "includegraphics":
  658. {
  659. throw new Error("KaTeX-a11y: includegraphics not implemented yet");
  660. }
  661. case "font":
  662. {
  663. // TODO: callout the start/end of specific fonts
  664. // TODO: map \BBb{N} to "the naturals" or something like that
  665. buildA11yStrings(tree.body, a11yStrings, atomType);
  666. break;
  667. }
  668. case "href":
  669. {
  670. throw new Error("KaTeX-a11y: href not implemented yet");
  671. }
  672. case "cr":
  673. {
  674. // This is used by environments.
  675. throw new Error("KaTeX-a11y: cr not implemented yet");
  676. }
  677. case "underline":
  678. {
  679. buildRegion(a11yStrings, function (a11yStrings) {
  680. a11yStrings.push("start underline");
  681. buildA11yStrings(tree.body, a11yStrings, atomType);
  682. a11yStrings.push("end underline");
  683. });
  684. break;
  685. }
  686. case "xArrow":
  687. {
  688. throw new Error("KaTeX-a11y: xArrow not implemented yet");
  689. }
  690. case "cdlabel":
  691. {
  692. throw new Error("KaTeX-a11y: cdlabel not implemented yet");
  693. }
  694. case "cdlabelparent":
  695. {
  696. throw new Error("KaTeX-a11y: cdlabelparent not implemented yet");
  697. }
  698. case "mclass":
  699. {
  700. // \neq and \ne are macros so we let "htmlmathml" render the mathmal
  701. // side of things and extract the text from that.
  702. var _atomType = tree.mclass.slice(1); // $FlowFixMe: drop the leading "m" from the values in mclass
  703. buildA11yStrings(tree.body, a11yStrings, _atomType);
  704. break;
  705. }
  706. case "mathchoice":
  707. {
  708. // TODO: track which which style we're using, e.g. dispaly, text, etc.
  709. // default to text style if even that may not be the correct style
  710. buildA11yStrings(tree.text, a11yStrings, atomType);
  711. break;
  712. }
  713. case "htmlmathml":
  714. {
  715. buildA11yStrings(tree.mathml, a11yStrings, atomType);
  716. break;
  717. }
  718. case "middle":
  719. {
  720. buildString(tree.delim, atomType, a11yStrings);
  721. break;
  722. }
  723. case "internal":
  724. {
  725. // internal nodes are never included in the parse tree
  726. break;
  727. }
  728. case "html":
  729. {
  730. buildA11yStrings(tree.body, a11yStrings, atomType);
  731. break;
  732. }
  733. default:
  734. tree.type;
  735. throw new Error("KaTeX a11y un-recognized type: " + tree.type);
  736. }
  737. };
  738. var buildA11yStrings = function buildA11yStrings(tree, a11yStrings, atomType) {
  739. if (a11yStrings === void 0) {
  740. a11yStrings = [];
  741. }
  742. if (tree instanceof Array) {
  743. for (var i = 0; i < tree.length; i++) {
  744. buildA11yStrings(tree[i], a11yStrings, atomType);
  745. }
  746. } else {
  747. handleObject(tree, a11yStrings, atomType);
  748. }
  749. return a11yStrings;
  750. };
  751. var flatten = function flatten(array) {
  752. var result = [];
  753. array.forEach(function (item) {
  754. if (item instanceof Array) {
  755. result = result.concat(flatten(item));
  756. } else {
  757. result.push(item);
  758. }
  759. });
  760. return result;
  761. };
  762. var renderA11yString = function renderA11yString(text, settings) {
  763. var tree = katex__WEBPACK_IMPORTED_MODULE_0___default().__parse(text, settings);
  764. var a11yStrings = buildA11yStrings(tree, [], "normal");
  765. return flatten(a11yStrings).join(", ");
  766. };
  767. /* harmony default export */ __webpack_exports__["default"] = (renderA11yString);
  768. }();
  769. __webpack_exports__ = __webpack_exports__["default"];
  770. /******/ return __webpack_exports__;
  771. /******/ })()
  772. ;
  773. });