jekyll-theme-hydejack 9.0.2 → 9.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (238) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +2 -2
  3. data/_config.yml +5 -4
  4. data/_includes/body/breadcrumbs.html +19 -0
  5. data/_includes/body/footer.html +1 -1
  6. data/_includes/body/index.html +3 -2
  7. data/_includes/body/main.html +1 -0
  8. data/_includes/body/nav.html +3 -3
  9. data/_includes/body/scripts.html +2 -2
  10. data/_includes/body/sidebar.html +1 -1
  11. data/_includes/components/dingbat.html +12 -0
  12. data/_includes/components/hy-img.html +1 -1
  13. data/_includes/components/post.html +35 -9
  14. data/_includes/components/tag-list.html +24 -24
  15. data/_includes/head/links-static.html +3 -2
  16. data/_includes/head/meta-static.html +1 -1
  17. data/_includes/head/scripts.html +7 -2
  18. data/_includes/head/styles-inline.html +1 -1
  19. data/_includes/head/styles-no-inline.html +1 -1
  20. data/_includes/header.txt +1 -1
  21. data/_includes/scripts.html +33 -0
  22. data/_includes/scripts/load-js.min.js +1 -1
  23. data/_includes/scripts/nomodule.min.js +1 -1
  24. data/_includes/smart-url +10 -1
  25. data/_includes/styles/page-style.scss +1 -0
  26. data/_includes/styles/style.scss +1 -0
  27. data/_includes/styles/variables.scss +10 -6
  28. data/_includes/templates/animation.html +1 -0
  29. data/_includes/templates/index.html +20 -2
  30. data/_layouts/about.html +4 -1
  31. data/_layouts/base.html +3 -12
  32. data/_layouts/compress.html +1 -1
  33. data/_layouts/list.html +1 -1
  34. data/_layouts/page.html +4 -2
  35. data/_layouts/plain.html +29 -0
  36. data/_layouts/post.html +6 -1
  37. data/_sass/_mixins.scss +26 -3
  38. data/_sass/_tippy.scss +40 -0
  39. data/_sass/html.scss +1 -7
  40. data/_sass/hydejack/__inline__/_base.scss +23 -4
  41. data/_sass/hydejack/__inline__/_content.scss +8 -5
  42. data/_sass/hydejack/__inline__/_sidebar.scss +18 -4
  43. data/_sass/hydejack/__inline__/_toc.scss +11 -11
  44. data/_sass/hydejack/__inline__/_utilities.scss +25 -0
  45. data/_sass/hydejack/__link__/_base.scss +9 -2
  46. data/_sass/hydejack/__link__/_break-layout.scss +8 -1
  47. data/_sass/hydejack/__link__/_content.scss +10 -4
  48. data/_sass/hydejack/__link__/_images.scss +1 -1
  49. data/_sass/hydejack/__link__/_sidebar.scss +15 -5
  50. data/_sass/hydejack/__link__/_toc.scss +4 -2
  51. data/_sass/hydejack/__link__/_utilities.scss +25 -0
  52. data/_sass/hydejack/_base.pre.scss +38 -8
  53. data/_sass/hydejack/_break-layout.pre.scss +8 -1
  54. data/_sass/hydejack/_content.pre.scss +12 -12
  55. data/_sass/hydejack/_images.pre.scss +1 -1
  56. data/_sass/hydejack/_sidebar.pre.scss +29 -5
  57. data/_sass/hydejack/_toc.pre.scss +14 -14
  58. data/_sass/hydejack/_utilities.pre.scss +25 -0
  59. data/_sass/pooleparty/__inline__/_base.scss +2 -0
  60. data/_sass/pooleparty/__inline__/_code.scss +1 -1
  61. data/_sass/pooleparty/__inline__/_message.scss +2 -2
  62. data/_sass/pooleparty/__inline__/_posts.scss +19 -3
  63. data/_sass/pooleparty/__inline__/_type.scss +4 -2
  64. data/_sass/pooleparty/__link__/_code.scss +138 -27
  65. data/_sass/pooleparty/__link__/_footnotes.scss +2 -1
  66. data/_sass/pooleparty/__link__/_posts.scss +12 -0
  67. data/_sass/pooleparty/__link__/_read-more.scss +1 -0
  68. data/_sass/pooleparty/__link__/_table.scss +30 -36
  69. data/_sass/pooleparty/__link__/_type.scss +4 -2
  70. data/_sass/pooleparty/_base.pre.scss +2 -0
  71. data/_sass/pooleparty/_code.pre.scss +138 -27
  72. data/_sass/pooleparty/_footnotes.pre.scss +2 -1
  73. data/_sass/pooleparty/_message.pre.scss +2 -2
  74. data/_sass/pooleparty/_posts.pre.scss +31 -3
  75. data/_sass/pooleparty/_read-more.pre.scss +1 -0
  76. data/_sass/pooleparty/_table.pre.scss +30 -36
  77. data/_sass/pooleparty/_type.pre.scss +6 -4
  78. data/_sass/tippyjs/_mixins.scss +25 -0
  79. data/_sass/tippyjs/_vars.scss +6 -0
  80. data/_sass/tippyjs/animations/fade.scss +8 -0
  81. data/_sass/tippyjs/index.scss +90 -0
  82. data/assets/bower.json +2 -1
  83. data/assets/bower_components/MathJax/.bower.json +5 -5
  84. data/assets/bower_components/MathJax/es5/a11y/assistive-mml.js +1 -1
  85. data/assets/bower_components/MathJax/es5/a11y/complexity.js +1 -1
  86. data/assets/bower_components/MathJax/es5/a11y/explorer.js +1 -1
  87. data/assets/bower_components/MathJax/es5/a11y/semantic-enrich.js +1 -1
  88. data/assets/bower_components/MathJax/es5/adaptors/liteDOM.js +1 -1
  89. data/assets/bower_components/MathJax/es5/core.js +1 -1
  90. data/assets/bower_components/MathJax/es5/input/asciimath.js +1 -1
  91. data/assets/bower_components/MathJax/es5/input/mml.js +1 -1
  92. data/assets/bower_components/MathJax/es5/input/mml/entities.js +1 -1
  93. data/assets/bower_components/MathJax/es5/input/tex-base.js +1 -1
  94. data/assets/bower_components/MathJax/es5/input/tex-full.js +1 -1
  95. data/assets/bower_components/MathJax/es5/input/tex.js +1 -1
  96. data/assets/bower_components/MathJax/es5/input/tex/extensions/action.js +1 -1
  97. data/assets/bower_components/MathJax/es5/input/tex/extensions/all-packages.js +1 -1
  98. data/assets/bower_components/MathJax/es5/input/tex/extensions/ams.js +1 -1
  99. data/assets/bower_components/MathJax/es5/input/tex/extensions/amscd.js +1 -1
  100. data/assets/bower_components/MathJax/es5/input/tex/extensions/autoload.js +1 -1
  101. data/assets/bower_components/MathJax/es5/input/tex/extensions/bbox.js +1 -1
  102. data/assets/bower_components/MathJax/es5/input/tex/extensions/boldsymbol.js +1 -1
  103. data/assets/bower_components/MathJax/es5/input/tex/extensions/braket.js +1 -1
  104. data/assets/bower_components/MathJax/es5/input/tex/extensions/bussproofs.js +1 -1
  105. data/assets/bower_components/MathJax/es5/input/tex/extensions/cancel.js +1 -1
  106. data/assets/bower_components/MathJax/es5/input/tex/extensions/color.js +1 -1
  107. data/assets/bower_components/MathJax/es5/input/tex/extensions/colorV2.js +1 -1
  108. data/assets/bower_components/MathJax/es5/input/tex/extensions/configMacros.js +1 -1
  109. data/assets/bower_components/MathJax/es5/input/tex/extensions/enclose.js +1 -1
  110. data/assets/bower_components/MathJax/es5/input/tex/extensions/extpfeil.js +1 -1
  111. data/assets/bower_components/MathJax/es5/input/tex/extensions/html.js +1 -1
  112. data/assets/bower_components/MathJax/es5/input/tex/extensions/mhchem.js +1 -1
  113. data/assets/bower_components/MathJax/es5/input/tex/extensions/newcommand.js +1 -1
  114. data/assets/bower_components/MathJax/es5/input/tex/extensions/noerrors.js +1 -1
  115. data/assets/bower_components/MathJax/es5/input/tex/extensions/noundefined.js +1 -1
  116. data/assets/bower_components/MathJax/es5/input/tex/extensions/physics.js +1 -1
  117. data/assets/bower_components/MathJax/es5/input/tex/extensions/require.js +1 -1
  118. data/assets/bower_components/MathJax/es5/input/tex/extensions/tagFormat.js +1 -1
  119. data/assets/bower_components/MathJax/es5/input/tex/extensions/textmacros.js +1 -0
  120. data/assets/bower_components/MathJax/es5/input/tex/extensions/unicode.js +1 -1
  121. data/assets/bower_components/MathJax/es5/input/tex/extensions/verb.js +1 -1
  122. data/assets/bower_components/MathJax/es5/latest.js +1 -1
  123. data/assets/bower_components/MathJax/es5/loader.js +1 -1
  124. data/assets/bower_components/MathJax/es5/mml-chtml.js +1 -1
  125. data/assets/bower_components/MathJax/es5/mml-svg.js +1 -1
  126. data/assets/bower_components/MathJax/es5/node-main.js +1 -1
  127. data/assets/bower_components/MathJax/es5/output/chtml.js +1 -1
  128. data/assets/bower_components/MathJax/es5/output/chtml/fonts/tex.js +1 -1
  129. data/assets/bower_components/MathJax/es5/output/svg.js +1 -1
  130. data/assets/bower_components/MathJax/es5/output/svg/fonts/tex.js +1 -1
  131. data/assets/bower_components/MathJax/es5/sre/mathmaps/de.js +104 -0
  132. data/assets/bower_components/MathJax/es5/sre/mathmaps/en.js +11 -5
  133. data/assets/bower_components/MathJax/es5/sre/mathmaps/es.js +1 -1
  134. data/assets/bower_components/MathJax/es5/sre/mathmaps/mathmaps_ie.js +117 -9
  135. data/assets/bower_components/MathJax/es5/sre/mathmaps/nemeth.js +3 -3
  136. data/assets/bower_components/MathJax/es5/sre/sre-node.js +11 -0
  137. data/assets/bower_components/MathJax/es5/sre/sre_browser.js +1110 -1186
  138. data/assets/bower_components/MathJax/es5/startup.js +1 -1
  139. data/assets/bower_components/MathJax/es5/tex-chtml-full.js +1 -1
  140. data/assets/bower_components/MathJax/es5/tex-chtml.js +1 -1
  141. data/assets/bower_components/MathJax/es5/tex-mml-chtml.js +1 -1
  142. data/assets/bower_components/MathJax/es5/tex-mml-svg.js +1 -1
  143. data/assets/bower_components/MathJax/es5/tex-svg-full.js +1 -1
  144. data/assets/bower_components/MathJax/es5/tex-svg.js +1 -1
  145. data/assets/bower_components/MathJax/es5/ui/menu.js +1 -1
  146. data/assets/bower_components/MathJax/es5/ui/safe.js +1 -0
  147. data/assets/bower_components/MathJax/package.json +3 -3
  148. data/assets/bower_components/katex/.bower.json +7 -6
  149. data/assets/bower_components/katex/dist/contrib/render-a11y-string.js +858 -0
  150. data/assets/bower_components/katex/dist/contrib/render-a11y-string.min.js +1 -0
  151. data/assets/bower_components/katex/dist/contrib/render-a11y-string.mjs +741 -0
  152. data/assets/bower_components/katex/dist/katex.css +1 -10
  153. data/assets/bower_components/katex/dist/katex.js +1228 -612
  154. data/assets/bower_components/katex/dist/katex.min.css +1 -1
  155. data/assets/bower_components/katex/dist/katex.min.js +1 -1
  156. data/assets/bower_components/katex/dist/katex.mjs +1270 -591
  157. data/assets/bower_components/katex/docs/cli.md.template +21 -0
  158. data/assets/bower_components/katex/flow-typed/npm/jest_v24.x.x.js +1201 -0
  159. data/assets/bower_components/katex/yarn.lock +233 -172
  160. data/assets/css/{hydejack-9.0.2.css → hydejack-9.1.2.css} +0 -0
  161. data/assets/icomoon/fonts/icomoon.eot +0 -0
  162. data/assets/icomoon/fonts/icomoon.svg +6 -3
  163. data/assets/icomoon/fonts/icomoon.ttf +0 -0
  164. data/assets/icomoon/fonts/icomoon.woff +0 -0
  165. data/assets/icomoon/selection.json +1 -1
  166. data/assets/icomoon/style.css +17 -8
  167. data/assets/icons/favicon.ico +0 -0
  168. data/assets/icons/icon-128x128.png +0 -0
  169. data/assets/icons/icon-144x144.png +0 -0
  170. data/assets/icons/icon-152x152.png +0 -0
  171. data/assets/icons/icon-192x192.png +0 -0
  172. data/assets/icons/icon-384x384.png +0 -0
  173. data/assets/icons/icon-512x512.png +0 -0
  174. data/assets/icons/icon-72x72.png +0 -0
  175. data/assets/icons/icon-96x96.png +0 -0
  176. data/assets/img/logo.png +0 -0
  177. data/assets/img/sidebar-bg.jpg +0 -0
  178. data/assets/img/swipe.svg +1 -22
  179. data/assets/js/LEGACY-clap-button-hydejack-9.1.2.js +14 -0
  180. data/assets/js/LEGACY-drawer-hydejack-9.1.2.js +14 -0
  181. data/assets/js/{LEGACY-fetch-hydejack-9.0.2.js → LEGACY-fetch-hydejack-9.1.2.js} +2 -2
  182. data/assets/js/LEGACY-hydejack-9.1.2.js +27 -0
  183. data/assets/js/LEGACY-navbar-hydejack-9.1.2.js +14 -0
  184. data/assets/js/LEGACY-push-state-hydejack-9.1.2.js +14 -0
  185. data/assets/js/{resize-observer-hydejack-9.0.2.js → LEGACY-resize-observer-hydejack-9.1.2.js} +2 -2
  186. data/assets/js/{LEGACY-shadydom-hydejack-9.0.2.js → LEGACY-shadydom-hydejack-9.1.2.js} +2 -2
  187. data/assets/js/LEGACY-vendors~clap-button-hydejack-9.1.2.js +182 -0
  188. data/assets/js/LEGACY-vendors~drawer-hydejack-9.1.2.js +48 -0
  189. data/assets/js/LEGACY-vendors~drawer~push-state-hydejack-9.1.2.js +214 -0
  190. data/assets/js/LEGACY-vendors~fetch-hydejack-9.1.2.js +14 -0
  191. data/assets/js/LEGACY-vendors~intersection-observer-hydejack-9.1.2.js +14 -0
  192. data/assets/js/LEGACY-vendors~push-state-hydejack-9.1.2.js +34 -0
  193. data/assets/js/LEGACY-vendors~shadydom-hydejack-9.1.2.js +155 -0
  194. data/assets/js/{LEGACY-vendors~webanimations-hydejack-9.0.2.js → LEGACY-vendors~webanimations-hydejack-9.1.2.js} +2 -2
  195. data/assets/js/{LEGACY-vendors~webcomponents-hydejack-9.0.2.js → LEGACY-vendors~webcomponents-hydejack-9.1.2.js} +4 -4
  196. data/assets/js/{LEGACY-webcomponents-hydejack-9.0.2.js → LEGACY-webcomponents-hydejack-9.1.2.js} +2 -2
  197. data/assets/js/clap-button-hydejack-9.1.2.js +14 -0
  198. data/assets/js/drawer-hydejack-9.1.2.js +14 -0
  199. data/assets/js/{shadydom-hydejack-9.0.2.js → fetch-hydejack-9.1.2.js} +2 -2
  200. data/assets/js/hydejack-9.1.2.js +28 -0
  201. data/assets/js/navbar-hydejack-9.1.2.js +14 -0
  202. data/assets/js/push-state-hydejack-9.1.2.js +14 -0
  203. data/assets/js/{LEGACY-resize-observer-hydejack-9.0.2.js → resize-observer-hydejack-9.1.2.js} +2 -2
  204. data/assets/js/shadydom-hydejack-9.1.2.js +14 -0
  205. data/assets/js/vendors~clap-button-hydejack-9.1.2.js +222 -0
  206. data/assets/js/vendors~drawer-hydejack-9.1.2.js +48 -0
  207. data/assets/js/vendors~drawer~push-state-hydejack-9.1.2.js +163 -0
  208. data/assets/js/vendors~fetch-hydejack-9.1.2.js +14 -0
  209. data/assets/js/vendors~intersection-observer-hydejack-9.1.2.js +14 -0
  210. data/assets/js/vendors~push-state-hydejack-9.1.2.js +34 -0
  211. data/assets/js/vendors~shadydom-hydejack-9.1.2.js +146 -0
  212. data/assets/js/{vendors~webanimations-hydejack-9.0.2.js → vendors~webanimations-hydejack-9.1.2.js} +2 -2
  213. data/assets/js/{webcomponents-hydejack-9.0.2.js → webcomponents-hydejack-9.1.2.js} +2 -2
  214. data/assets/site.webmanifest +1 -1
  215. data/assets/version.json +2 -2
  216. metadata +59 -38
  217. data/_includes/templates/back.html +0 -6
  218. data/_includes/templates/forward.html +0 -6
  219. data/assets/js/LEGACY-drawer-hydejack-9.0.2.js +0 -14
  220. data/assets/js/LEGACY-hydejack-9.0.2.js +0 -28
  221. data/assets/js/LEGACY-navbar-hydejack-9.0.2.js +0 -14
  222. data/assets/js/LEGACY-push-state-hydejack-9.0.2.js +0 -14
  223. data/assets/js/LEGACY-vendors~drawer-hydejack-9.0.2.js +0 -47
  224. data/assets/js/LEGACY-vendors~drawer~push-state-hydejack-9.0.2.js +0 -215
  225. data/assets/js/LEGACY-vendors~fetch-hydejack-9.0.2.js +0 -14
  226. data/assets/js/LEGACY-vendors~intersection-observer-hydejack-9.0.2.js +0 -14
  227. data/assets/js/LEGACY-vendors~push-state-hydejack-9.0.2.js +0 -33
  228. data/assets/js/LEGACY-vendors~shadydom-hydejack-9.0.2.js +0 -155
  229. data/assets/js/drawer-hydejack-9.0.2.js +0 -14
  230. data/assets/js/fetch-hydejack-9.0.2.js +0 -14
  231. data/assets/js/hydejack-9.0.2.js +0 -28
  232. data/assets/js/navbar-hydejack-9.0.2.js +0 -14
  233. data/assets/js/push-state-hydejack-9.0.2.js +0 -14
  234. data/assets/js/vendors~drawer-hydejack-9.0.2.js +0 -47
  235. data/assets/js/vendors~drawer~push-state-hydejack-9.0.2.js +0 -163
  236. data/assets/js/vendors~intersection-observer-hydejack-9.0.2.js +0 -14
  237. data/assets/js/vendors~push-state-hydejack-9.0.2.js +0 -33
  238. data/assets/js/vendors~shadydom-hydejack-9.0.2.js +0 -146
@@ -129,7 +129,7 @@
129
129
  -ms-high-contrast-adjust: none !important;
130
130
  }
131
131
  .katex .katex-version::after {
132
- content: "0.10.2";
132
+ content: "0.11.1";
133
133
  }
134
134
  .katex .katex-mathml {
135
135
  position: absolute;
@@ -333,10 +333,6 @@
333
333
  margin-left: 0.27777778em;
334
334
  margin-right: -0.55555556em;
335
335
  }
336
- .katex .sizing,
337
- .katex .fontsize-ensurer {
338
- display: inline-block;
339
- }
340
336
  .katex .sizing.reset-size1.size1,
341
337
  .katex .fontsize-ensurer.reset-size1.size1 {
342
338
  font-size: 1em;
@@ -872,13 +868,8 @@
872
868
  }
873
869
  .katex .mtable .vertical-separator {
874
870
  display: inline-block;
875
- margin: 0 -0.025em;
876
- border-right: 0.05em solid;
877
871
  min-width: 1px;
878
872
  }
879
- .katex .mtable .vs-dashed {
880
- border-right: 0.05em dashed;
881
- }
882
873
  .katex .mtable .arraycolsep {
883
874
  display: inline-block;
884
875
  }
@@ -362,13 +362,23 @@ var assert = function assert(value) {
362
362
 
363
363
  return value;
364
364
  };
365
+ /**
366
+ * Return the protocol of a URL, or "_relative" if the URL does not specify a
367
+ * protocol (and thus is relative).
368
+ */
369
+
370
+ var protocolFromUrl = function protocolFromUrl(url) {
371
+ var protocol = /^\s*([^\\/#]*?)(?::|&#0*58|&#x0*3a)/i.exec(url);
372
+ return protocol != null ? protocol[1] : "_relative";
373
+ };
365
374
  /* harmony default export */ var utils = ({
366
375
  contains: contains,
367
376
  deflt: deflt,
368
377
  escape: utils_escape,
369
378
  hyphenate: hyphenate,
370
379
  getBaseElem: getBaseElem,
371
- isCharacterBox: utils_isCharacterBox
380
+ isCharacterBox: utils_isCharacterBox,
381
+ protocolFromUrl: protocolFromUrl
372
382
  });
373
383
  // CONCATENATED MODULE: ./src/Settings.js
374
384
  /* eslint no-console:0 */
@@ -396,29 +406,33 @@ var Settings_Settings =
396
406
  function () {
397
407
  function Settings(options) {
398
408
  this.displayMode = void 0;
409
+ this.output = void 0;
399
410
  this.leqno = void 0;
400
411
  this.fleqn = void 0;
401
412
  this.throwOnError = void 0;
402
413
  this.errorColor = void 0;
403
414
  this.macros = void 0;
415
+ this.minRuleThickness = void 0;
404
416
  this.colorIsTextColor = void 0;
405
417
  this.strict = void 0;
418
+ this.trust = void 0;
406
419
  this.maxSize = void 0;
407
420
  this.maxExpand = void 0;
408
- this.allowedProtocols = void 0;
409
421
  // allow null options
410
422
  options = options || {};
411
423
  this.displayMode = utils.deflt(options.displayMode, false);
424
+ this.output = utils.deflt(options.output, "htmlAndMathml");
412
425
  this.leqno = utils.deflt(options.leqno, false);
413
426
  this.fleqn = utils.deflt(options.fleqn, false);
414
427
  this.throwOnError = utils.deflt(options.throwOnError, true);
415
428
  this.errorColor = utils.deflt(options.errorColor, "#cc0000");
416
429
  this.macros = options.macros || {};
430
+ this.minRuleThickness = Math.max(0, utils.deflt(options.minRuleThickness, 0));
417
431
  this.colorIsTextColor = utils.deflt(options.colorIsTextColor, false);
418
432
  this.strict = utils.deflt(options.strict, "warn");
433
+ this.trust = utils.deflt(options.trust, false);
419
434
  this.maxSize = Math.max(0, utils.deflt(options.maxSize, Infinity));
420
435
  this.maxExpand = Math.max(0, utils.deflt(options.maxExpand, 1000));
421
- this.allowedProtocols = utils.deflt(options.allowedProtocols, ["http", "https", "mailto", "_relative"]);
422
436
  }
423
437
  /**
424
438
  * Report nonstrict (non-LaTeX-compatible) input.
@@ -485,12 +499,30 @@ function () {
485
499
  typeof console !== "undefined" && console.warn("LaTeX-incompatible input and strict mode is set to " + ("unrecognized '" + strict + "': " + errorMsg + " [" + errorCode + "]"));
486
500
  return false;
487
501
  }
502
+ }
503
+ /**
504
+ * Check whether to test potentially dangerous input, and return
505
+ * `true` (trusted) or `false` (untrusted). The sole argument `context`
506
+ * should be an object with `command` field specifying the relevant LaTeX
507
+ * command (as a string starting with `\`), and any other arguments, etc.
508
+ * If `context` has a `url` field, a `protocol` field will automatically
509
+ * get added by this function (changing the specified object).
510
+ */
511
+ ;
512
+
513
+ _proto.isTrusted = function isTrusted(context) {
514
+ if (context.url && !context.protocol) {
515
+ context.protocol = utils.protocolFromUrl(context.url);
516
+ }
517
+
518
+ var trust = typeof this.trust === "function" ? this.trust(context) : this.trust;
519
+ return Boolean(trust);
488
520
  };
489
521
 
490
522
  return Settings;
491
523
  }();
492
524
 
493
- /* harmony default export */ var src_Settings = (Settings_Settings);
525
+
494
526
  // CONCATENATED MODULE: ./src/Style.js
495
527
  /**
496
528
  * This file contains information and classes for the various kinds of styles
@@ -721,25 +753,97 @@ function supportedCodepoint(codepoint) {
721
753
  }
722
754
  // CONCATENATED MODULE: ./src/svgGeometry.js
723
755
  /**
724
- * This file provides support to domTree.js
756
+ * This file provides support to domTree.js and delimiter.js.
725
757
  * It's a storehouse of path geometry for SVG images.
726
758
  */
727
759
  // In all paths below, the viewBox-to-em scale is 1000:1.
728
- var hLinePad = 80; // padding above a sqrt viniculum.
729
-
730
- var svgGeometry_path = {
760
+ var hLinePad = 80; // padding above a sqrt viniculum. Prevents image cropping.
761
+ // The viniculum of a \sqrt can be made thicker by a KaTeX rendering option.
762
+ // Think of variable extraViniculum as two detours in the SVG path.
763
+ // The detour begins at the lower left of the area labeled extraViniculum below.
764
+ // The detour proceeds one extraViniculum distance up and slightly to the right,
765
+ // displacing the radiused corner between surd and viniculum. The radius is
766
+ // traversed as usual, then the detour resumes. It goes right, to the end of
767
+ // the very long viniculumn, then down one extraViniculum distance,
768
+ // after which it resumes regular path geometry for the radical.
769
+
770
+ /* viniculum
771
+ /
772
+ /▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒←extraViniculum
773
+ / █████████████████████←0.04em (40 unit) std viniculum thickness
774
+ / /
775
+ / /
776
+ / /\
777
+ / / surd
778
+ */
779
+
780
+ var sqrtMain = function sqrtMain(extraViniculum, hLinePad) {
731
781
  // sqrtMain path geometry is from glyph U221A in the font KaTeX Main
732
- // All surds have 80 units padding above the viniculumn.
733
- sqrtMain: "M95," + (622 + hLinePad) + "c-2.7,0,-7.17,-2.7,-13.5,-8c-5.8,-5.3,-9.5,\n-10,-9.5,-14c0,-2,0.3,-3.3,1,-4c1.3,-2.7,23.83,-20.7,67.5,-54c44.2,-33.3,65.8,\n-50.3,66.5,-51c1.3,-1.3,3,-2,5,-2c4.7,0,8.7,3.3,12,10s173,378,173,378c0.7,0,\n35.3,-71,104,-213c68.7,-142,137.5,-285,206.5,-429c69,-144,104.5,-217.7,106.5,\n-221c5.3,-9.3,12,-14,20,-14H400000v40H845.2724s-225.272,467,-225.272,467\ns-235,486,-235,486c-2.7,4.7,-9,7,-19,7c-6,0,-10,-1,-12,-3s-194,-422,-194,-422\ns-65,47,-65,47z M834 " + hLinePad + "H400000v40H845z",
782
+ 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";
783
+ };
784
+
785
+ var sqrtSize1 = function sqrtSize1(extraViniculum, hLinePad) {
734
786
  // size1 is from glyph U221A in the font KaTeX_Size1-Regular
735
- sqrtSize1: "M263," + (601 + hLinePad) + "c0.7,0,18,39.7,52,119c34,79.3,68.167,\n158.7,102.5,238c34.3,79.3,51.8,119.3,52.5,120c340,-704.7,510.7,-1060.3,512,-1067\nc4.7,-7.3,11,-11,19,-11H40000v40H1012.3s-271.3,567,-271.3,567c-38.7,80.7,-84,\n175,-136,283c-52,108,-89.167,185.3,-111.5,232c-22.3,46.7,-33.8,70.3,-34.5,71\nc-4.7,4.7,-12.3,7,-23,7s-12,-1,-12,-1s-109,-253,-109,-253c-72.7,-168,-109.3,\n-252,-110,-252c-10.7,8,-22,16.7,-34,26c-22,17.3,-33.3,26,-34,26s-26,-26,-26,-26\ns76,-59,76,-59s76,-60,76,-60z M1001 " + hLinePad + "H40000v40H1012z",
787
+ 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";
788
+ };
789
+
790
+ var sqrtSize2 = function sqrtSize2(extraViniculum, hLinePad) {
736
791
  // size2 is from glyph U221A in the font KaTeX_Size2-Regular
737
- // The 80 units padding is most obvious here. Note start node at M1001 80.
738
- sqrtSize2: "M1001," + hLinePad + "H400000v40H1013.1s-83.4,268,-264.1,840c-180.7,\n572,-277,876.3,-289,913c-4.7,4.7,-12.7,7,-24,7s-12,0,-12,0c-1.3,-3.3,-3.7,-11.7,\n-7,-25c-35.3,-125.3,-106.7,-373.3,-214,-744c-10,12,-21,25,-33,39s-32,39,-32,39\nc-6,-5.3,-15,-14,-27,-26s25,-30,25,-30c26.7,-32.7,52,-63,76,-91s52,-60,52,-60\ns208,722,208,722c56,-175.3,126.3,-397.3,211,-666c84.7,-268.7,153.8,-488.2,207.5,\n-658.5c53.7,-170.3,84.5,-266.8,92.5,-289.5c4,-6.7,10,-10,18,-10z\nM1001 " + hLinePad + "H400000v40H1013z",
792
+ 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";
793
+ };
794
+
795
+ var sqrtSize3 = function sqrtSize3(extraViniculum, hLinePad) {
739
796
  // size3 is from glyph U221A in the font KaTeX_Size3-Regular
740
- sqrtSize3: "M424," + (2398 + hLinePad) + "c-1.3,-0.7,-38.5,-172,-111.5,-514c-73,\n-342,-109.8,-513.3,-110.5,-514c0,-2,-10.7,14.3,-32,49c-4.7,7.3,-9.8,15.7,-15.5,\n25c-5.7,9.3,-9.8,16,-12.5,20s-5,7,-5,7c-4,-3.3,-8.3,-7.7,-13,-13s-13,-13,-13,\n-13s76,-122,76,-122s77,-121,77,-121s209,968,209,968c0,-2,84.7,-361.7,254,-1079\nc169.3,-717.3,254.7,-1077.7,256,-1081c4,-6.7,10,-10,18,-10H400000v40H1014.6\ns-87.3,378.7,-272.6,1166c-185.3,787.3,-279.3,1182.3,-282,1185c-2,6,-10,9,-24,9\nc-8,0,-12,-0.7,-12,-2z M1001 " + hLinePad + "H400000v40H1014z",
797
+ 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";
798
+ };
799
+
800
+ var sqrtSize4 = function sqrtSize4(extraViniculum, hLinePad) {
741
801
  // size4 is from glyph U221A in the font KaTeX_Size4-Regular
742
- sqrtSize4: "M473," + (2713 + hLinePad) + "c339.3,-1799.3,509.3,-2700,510,-2702\nc3.3,-7.3,9.3,-11,18,-11H400000v40H1017.7s-90.5,478,-276.2,1466c-185.7,988,\n-279.5,1483,-281.5,1485c-2,6,-10,9,-24,9c-8,0,-12,-0.7,-12,-2c0,-1.3,-5.3,-32,\n-16,-92c-50.7,-293.3,-119.7,-693.3,-207,-1200c0,-1.3,-5.3,8.7,-16,30c-10.7,\n21.3,-21.3,42.7,-32,64s-16,33,-16,33s-26,-26,-26,-26s76,-153,76,-153s77,-151,\n77,-151c0.7,0.7,35.7,202,105,604c67.3,400.7,102,602.7,104,606z\nM1001 " + hLinePad + "H400000v40H1017z",
802
+ 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";
803
+ };
804
+
805
+ var sqrtTall = function sqrtTall(extraViniculum, hLinePad, viewBoxHeight) {
806
+ // sqrtTall is from glyph U23B7 in the font KaTeX_Size4-Regular
807
+ // One path edge has a variable length. It runs vertically from the viniculumn
808
+ // to a point near (14 units) the bottom of the surd. The viniculum
809
+ // is normally 40 units thick. So the length of the line in question is:
810
+ var vertSegment = viewBoxHeight - 54 - hLinePad - extraViniculum;
811
+ 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";
812
+ };
813
+
814
+ var sqrtPath = function sqrtPath(size, extraViniculum, viewBoxHeight) {
815
+ extraViniculum = 1000 * extraViniculum; // Convert from document ems to viewBox.
816
+
817
+ var path = "";
818
+
819
+ switch (size) {
820
+ case "sqrtMain":
821
+ path = sqrtMain(extraViniculum, hLinePad);
822
+ break;
823
+
824
+ case "sqrtSize1":
825
+ path = sqrtSize1(extraViniculum, hLinePad);
826
+ break;
827
+
828
+ case "sqrtSize2":
829
+ path = sqrtSize2(extraViniculum, hLinePad);
830
+ break;
831
+
832
+ case "sqrtSize3":
833
+ path = sqrtSize3(extraViniculum, hLinePad);
834
+ break;
835
+
836
+ case "sqrtSize4":
837
+ path = sqrtSize4(extraViniculum, hLinePad);
838
+ break;
839
+
840
+ case "sqrtTall":
841
+ path = sqrtTall(extraViniculum, hLinePad, viewBoxHeight);
842
+ }
843
+
844
+ return path;
845
+ };
846
+ var svgGeometry_path = {
743
847
  // The doubleleftarrow geometry is from glyph U+21D0 in the font KaTeX Main
744
848
  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",
745
849
  // doublerightarrow is from glyph U+21D2 in font KaTeX Main
@@ -817,9 +921,6 @@ var svgGeometry_path = {
817
921
  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",
818
922
  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"
819
923
  };
820
- /* harmony default export */ var svgGeometry = ({
821
- path: svgGeometry_path
822
- });
823
924
  // CONCATENATED MODULE: ./src/tree.js
824
925
 
825
926
 
@@ -1383,7 +1484,7 @@ function () {
1383
1484
  this.pathName = void 0;
1384
1485
  this.alternate = void 0;
1385
1486
  this.pathName = pathName;
1386
- this.alternate = alternate; // Used only for tall \sqrt
1487
+ this.alternate = alternate; // Used only for \sqrt
1387
1488
  }
1388
1489
 
1389
1490
  var _proto6 = PathNode.prototype;
@@ -1395,7 +1496,7 @@ function () {
1395
1496
  if (this.alternate) {
1396
1497
  node.setAttribute("d", this.alternate);
1397
1498
  } else {
1398
- node.setAttribute("d", svgGeometry.path[this.pathName]);
1499
+ node.setAttribute("d", svgGeometry_path[this.pathName]);
1399
1500
  }
1400
1501
 
1401
1502
  return node;
@@ -1405,7 +1506,7 @@ function () {
1405
1506
  if (this.alternate) {
1406
1507
  return "<path d='" + this.alternate + "'/>";
1407
1508
  } else {
1408
- return "<path d='" + svgGeometry.path[this.pathName] + "'/>";
1509
+ return "<path d='" + svgGeometry_path[this.pathName] + "'/>";
1409
1510
  }
1410
1511
  };
1411
1512
 
@@ -3695,7 +3796,15 @@ var sigmasAndXis = {
3695
3796
  ptPerEm: [10.0, 10.0, 10.0],
3696
3797
  // The space between adjacent `|` columns in an array definition. From
3697
3798
  // `\showthe\doublerulesep` in LaTeX. Equals 2.0 / ptPerEm.
3698
- doubleRuleSep: [0.2, 0.2, 0.2]
3799
+ doubleRuleSep: [0.2, 0.2, 0.2],
3800
+ // The width of separator lines in {array} environments. From
3801
+ // `\showthe\arrayrulewidth` in LaTeX. Equals 0.4 / ptPerEm.
3802
+ arrayRuleWidth: [0.04, 0.04, 0.04],
3803
+ // Two values from LaTeX source2e:
3804
+ fboxsep: [0.3, 0.3, 0.3],
3805
+ // 3 pt / ptPerEm
3806
+ fboxrule: [0.04, 0.04, 0.04] // 0.4 pt / ptPerEm
3807
+
3699
3808
  }; // This map contains a mapping from font name and character code to character
3700
3809
  // metrics, including height, depth, italic correction, and skew (kern from the
3701
3810
  // character to the corresponding \skewchar)
@@ -4147,7 +4256,7 @@ defineSymbol(symbols_math, ams, symbols_textord, "\u2136", "\\beth", true);
4147
4256
  defineSymbol(symbols_math, ams, symbols_textord, "\u2138", "\\daleth", true);
4148
4257
  defineSymbol(symbols_math, ams, symbols_textord, "\u2137", "\\gimel", true); // AMS Greek
4149
4258
 
4150
- defineSymbol(symbols_math, ams, symbols_textord, "\u03DD", "\\digamma");
4259
+ defineSymbol(symbols_math, ams, symbols_textord, "\u03DD", "\\digamma", true);
4151
4260
  defineSymbol(symbols_math, ams, symbols_textord, "\u03F0", "\\varkappa"); // AMS Delimiters
4152
4261
 
4153
4262
  defineSymbol(symbols_math, ams, symbols_open, "\u250C", "\\ulcorner", true);
@@ -4895,6 +5004,7 @@ function () {
4895
5004
  this.fontShape = void 0;
4896
5005
  this.sizeMultiplier = void 0;
4897
5006
  this.maxSize = void 0;
5007
+ this.minRuleThickness = void 0;
4898
5008
  this._fontMetrics = void 0;
4899
5009
  this.style = data.style;
4900
5010
  this.color = data.color;
@@ -4907,6 +5017,7 @@ function () {
4907
5017
  this.fontShape = data.fontShape || '';
4908
5018
  this.sizeMultiplier = sizeMultipliers[this.size - 1];
4909
5019
  this.maxSize = data.maxSize;
5020
+ this.minRuleThickness = data.minRuleThickness;
4910
5021
  this._fontMetrics = undefined;
4911
5022
  }
4912
5023
  /**
@@ -4928,7 +5039,8 @@ function () {
4928
5039
  fontFamily: this.fontFamily,
4929
5040
  fontWeight: this.fontWeight,
4930
5041
  fontShape: this.fontShape,
4931
- maxSize: this.maxSize
5042
+ maxSize: this.maxSize,
5043
+ minRuleThickness: this.minRuleThickness
4932
5044
  };
4933
5045
 
4934
5046
  for (var key in extension) {
@@ -5325,7 +5437,7 @@ var buildCommon_makeSymbol = function makeSymbol(value, fontName, mode, options,
5325
5437
  symbolNode = new domTree_SymbolNode(value, metrics.height, metrics.depth, italic, metrics.skew, metrics.width, classes);
5326
5438
  } else {
5327
5439
  // TODO(emily): Figure out a good way to only print this in development
5328
- typeof console !== "undefined" && console.warn("No character metrics for '" + value + "' in style '" + fontName + "'");
5440
+ typeof console !== "undefined" && console.warn("No character metrics " + ("for '" + value + "' in style '" + fontName + "' and mode '" + mode + "'"));
5329
5441
  symbolNode = new domTree_SymbolNode(value, 0, 0, 0, 0, 0, classes);
5330
5442
  }
5331
5443
 
@@ -5348,8 +5460,6 @@ var buildCommon_makeSymbol = function makeSymbol(value, fontName, mode, options,
5348
5460
  /**
5349
5461
  * Makes a symbol in Main-Regular or AMS-Regular.
5350
5462
  * Used for rel, bin, open, close, inner, and punct.
5351
- *
5352
- * TODO(#953): Make `options` mandatory and always pass it in.
5353
5463
  */
5354
5464
 
5355
5465
 
@@ -5365,7 +5475,7 @@ var buildCommon_mathsym = function mathsym(value, mode, options, classes) {
5365
5475
  // text ordinal and is therefore not present as a symbol in the symbols
5366
5476
  // table for text, as well as a special case for boldsymbol because it
5367
5477
  // can be used for bold + and -
5368
- if (options && options.font && options.font === "boldsymbol" && buildCommon_lookupSymbol(value, "Main-Bold", mode).metrics) {
5478
+ if (options.font === "boldsymbol" && buildCommon_lookupSymbol(value, "Main-Bold", mode).metrics) {
5369
5479
  return buildCommon_makeSymbol(value, "Main-Bold", mode, options, classes.concat(["mathbf"]));
5370
5480
  } else if (value === "\\" || src_symbols[mode][value].font === "main") {
5371
5481
  return buildCommon_makeSymbol(value, "Main-Regular", mode, options, classes);
@@ -5629,7 +5739,7 @@ var buildCommon_makeSvgSpan = function makeSvgSpan(classes, children, options, s
5629
5739
 
5630
5740
  var makeLineSpan = function makeLineSpan(className, options, thickness) {
5631
5741
  var line = buildCommon_makeSpan([className], [], options);
5632
- line.height = thickness || options.fontMetrics().defaultRuleThickness;
5742
+ line.height = Math.max(thickness || options.fontMetrics().defaultRuleThickness, options.minRuleThickness);
5633
5743
  line.style.borderBottomWidth = line.height + "em";
5634
5744
  line.maxFontSize = 1.0;
5635
5745
  return line;
@@ -6198,7 +6308,6 @@ var _htmlGroupBuilders = {};
6198
6308
  var _mathmlGroupBuilders = {};
6199
6309
  function defineFunction(_ref) {
6200
6310
  var type = _ref.type,
6201
- nodeType = _ref.nodeType,
6202
6311
  names = _ref.names,
6203
6312
  props = _ref.props,
6204
6313
  handler = _ref.handler,
@@ -6214,15 +6323,10 @@ function defineFunction(_ref) {
6214
6323
  allowedInMath: props.allowedInMath === undefined ? true : props.allowedInMath,
6215
6324
  numOptionalArgs: props.numOptionalArgs || 0,
6216
6325
  infix: !!props.infix,
6217
- consumeMode: props.consumeMode,
6218
6326
  handler: handler
6219
6327
  };
6220
6328
 
6221
6329
  for (var i = 0; i < names.length; ++i) {
6222
- // TODO: The value type of _functions should be a type union of all
6223
- // possible `FunctionSpec<>` possibilities instead of `FunctionSpec<*>`,
6224
- // which is an existential type.
6225
- // $FlowFixMe
6226
6330
  _functions[names[i]] = data;
6227
6331
  }
6228
6332
 
@@ -6287,7 +6391,7 @@ var buildHTML_makeSpan = buildCommon.makeSpan; // Binary atoms (first class `mbi
6287
6391
 
6288
6392
  var binLeftCanceller = ["leftmost", "mbin", "mopen", "mrel", "mop", "mpunct"];
6289
6393
  var binRightCanceller = ["rightmost", "mrel", "mclose", "mpunct"];
6290
- var buildHTML_styleMap = {
6394
+ var styleMap = {
6291
6395
  "display": src_Style.DISPLAY,
6292
6396
  "text": src_Style.TEXT,
6293
6397
  "script": src_Style.SCRIPT,
@@ -6346,7 +6450,7 @@ var buildHTML_buildExpression = function buildExpression(expression, options, is
6346
6450
  } else if (node.type === "sizing") {
6347
6451
  glueOptions = options.havingSize(node.size);
6348
6452
  } else if (node.type === "styling") {
6349
- glueOptions = options.havingStyle(buildHTML_styleMap[node.style]);
6453
+ glueOptions = options.havingStyle(styleMap[node.style]);
6350
6454
  }
6351
6455
  } // Dummy spans for determining spacings between surrounding atoms.
6352
6456
  // If `expression` has no atoms on the left or right, class "leftmost"
@@ -6406,6 +6510,7 @@ var traverseNonSpaceNodes = function traverseNonSpaceNodes(nodes, callback, prev
6406
6510
 
6407
6511
  if (partialGroup) {
6408
6512
  // Recursive DFS
6513
+ // $FlowFixMe: make nodes a $ReadOnlyArray by returning a new array
6409
6514
  traverseNonSpaceNodes(partialGroup.children, callback, prev);
6410
6515
  continue;
6411
6516
  } // Ignore explicit spaces (e.g., \;, \,) when determining what implicit
@@ -6946,6 +7051,19 @@ var buildMathML_getVariant = function getVariant(group, options) {
6946
7051
  return "italic";
6947
7052
  } else if (font === "boldsymbol") {
6948
7053
  return "bold-italic";
7054
+ } else if (font === "mathbf") {
7055
+ return "bold";
7056
+ } else if (font === "mathbb") {
7057
+ return "double-struck";
7058
+ } else if (font === "mathfrak") {
7059
+ return "fraktur";
7060
+ } else if (font === "mathscr" || font === "mathcal") {
7061
+ // MathML makes no distinction between script and caligrahpic
7062
+ return "script";
7063
+ } else if (font === "mathsf") {
7064
+ return "sans-serif";
7065
+ } else if (font === "mathtt") {
7066
+ return "monospace";
6949
7067
  }
6950
7068
 
6951
7069
  var text = group.text;
@@ -6972,42 +7090,55 @@ var buildMathML_getVariant = function getVariant(group, options) {
6972
7090
  * <mtext> tag.
6973
7091
  */
6974
7092
 
6975
- var buildMathML_buildExpression = function buildExpression(expression, options) {
7093
+ var buildMathML_buildExpression = function buildExpression(expression, options, isOrdgroup) {
7094
+ if (expression.length === 1) {
7095
+ var group = buildMathML_buildGroup(expression[0], options);
7096
+
7097
+ if (isOrdgroup && group instanceof mathMLTree_MathNode && group.type === "mo") {
7098
+ // When TeX writers want to suppress spacing on an operator,
7099
+ // they often put the operator by itself inside braces.
7100
+ group.setAttribute("lspace", "0em");
7101
+ group.setAttribute("rspace", "0em");
7102
+ }
7103
+
7104
+ return [group];
7105
+ }
7106
+
6976
7107
  var groups = [];
6977
7108
  var lastGroup;
6978
7109
 
6979
7110
  for (var i = 0; i < expression.length; i++) {
6980
- var group = buildMathML_buildGroup(expression[i], options);
7111
+ var _group = buildMathML_buildGroup(expression[i], options);
6981
7112
 
6982
- if (group instanceof mathMLTree_MathNode && lastGroup instanceof mathMLTree_MathNode) {
7113
+ if (_group instanceof mathMLTree_MathNode && lastGroup instanceof mathMLTree_MathNode) {
6983
7114
  // Concatenate adjacent <mtext>s
6984
- if (group.type === 'mtext' && lastGroup.type === 'mtext' && group.getAttribute('mathvariant') === lastGroup.getAttribute('mathvariant')) {
7115
+ if (_group.type === 'mtext' && lastGroup.type === 'mtext' && _group.getAttribute('mathvariant') === lastGroup.getAttribute('mathvariant')) {
6985
7116
  var _lastGroup$children;
6986
7117
 
6987
- (_lastGroup$children = lastGroup.children).push.apply(_lastGroup$children, group.children);
7118
+ (_lastGroup$children = lastGroup.children).push.apply(_lastGroup$children, _group.children);
6988
7119
 
6989
7120
  continue; // Concatenate adjacent <mn>s
6990
- } else if (group.type === 'mn' && lastGroup.type === 'mn') {
7121
+ } else if (_group.type === 'mn' && lastGroup.type === 'mn') {
6991
7122
  var _lastGroup$children2;
6992
7123
 
6993
- (_lastGroup$children2 = lastGroup.children).push.apply(_lastGroup$children2, group.children);
7124
+ (_lastGroup$children2 = lastGroup.children).push.apply(_lastGroup$children2, _group.children);
6994
7125
 
6995
7126
  continue; // Concatenate <mn>...</mn> followed by <mi>.</mi>
6996
- } else if (group.type === 'mi' && group.children.length === 1 && lastGroup.type === 'mn') {
6997
- var child = group.children[0];
7127
+ } else if (_group.type === 'mi' && _group.children.length === 1 && lastGroup.type === 'mn') {
7128
+ var child = _group.children[0];
6998
7129
 
6999
7130
  if (child instanceof mathMLTree_TextNode && child.text === '.') {
7000
7131
  var _lastGroup$children3;
7001
7132
 
7002
- (_lastGroup$children3 = lastGroup.children).push.apply(_lastGroup$children3, group.children);
7133
+ (_lastGroup$children3 = lastGroup.children).push.apply(_lastGroup$children3, _group.children);
7003
7134
 
7004
7135
  continue;
7005
7136
  }
7006
7137
  } else if (lastGroup.type === 'mi' && lastGroup.children.length === 1) {
7007
7138
  var lastChild = lastGroup.children[0];
7008
7139
 
7009
- if (lastChild instanceof mathMLTree_TextNode && lastChild.text === "\u0338" && (group.type === 'mo' || group.type === 'mi' || group.type === 'mn')) {
7010
- var _child = group.children[0];
7140
+ if (lastChild instanceof mathMLTree_TextNode && lastChild.text === "\u0338" && (_group.type === 'mo' || _group.type === 'mi' || _group.type === 'mn')) {
7141
+ var _child = _group.children[0];
7011
7142
 
7012
7143
  if (_child instanceof mathMLTree_TextNode && _child.text.length > 0) {
7013
7144
  // Overlay with combining character long solidus
@@ -7018,8 +7149,8 @@ var buildMathML_buildExpression = function buildExpression(expression, options)
7018
7149
  }
7019
7150
  }
7020
7151
 
7021
- groups.push(group);
7022
- lastGroup = group;
7152
+ groups.push(_group);
7153
+ lastGroup = _group;
7023
7154
  }
7024
7155
 
7025
7156
  return groups;
@@ -7029,8 +7160,8 @@ var buildMathML_buildExpression = function buildExpression(expression, options)
7029
7160
  * if there's more than one. Returns a single node instead of an array.
7030
7161
  */
7031
7162
 
7032
- var buildExpressionRow = function buildExpressionRow(expression, options) {
7033
- return buildMathML_makeRow(buildMathML_buildExpression(expression, options));
7163
+ var buildExpressionRow = function buildExpressionRow(expression, options, isOrdgroup) {
7164
+ return buildMathML_makeRow(buildMathML_buildExpression(expression, options, isOrdgroup));
7034
7165
  };
7035
7166
  /**
7036
7167
  * Takes a group from the parser and calls the appropriate groupBuilders function
@@ -7059,7 +7190,7 @@ var buildMathML_buildGroup = function buildGroup(group, options) {
7059
7190
  * we can do appropriate styling.
7060
7191
  */
7061
7192
 
7062
- function buildMathML(tree, texExpression, options) {
7193
+ function buildMathML(tree, texExpression, options, forMathmlOnly) {
7063
7194
  var expression = buildMathML_buildExpression(tree, options); // Wrap up the expression in an mrow so it is presented in the semantics
7064
7195
  // tag correctly, unless it's a single <mrow> or <mtable>.
7065
7196
 
@@ -7075,13 +7206,15 @@ function buildMathML(tree, texExpression, options) {
7075
7206
  var annotation = new mathMLTree.MathNode("annotation", [new mathMLTree.TextNode(texExpression)]);
7076
7207
  annotation.setAttribute("encoding", "application/x-tex");
7077
7208
  var semantics = new mathMLTree.MathNode("semantics", [wrapper, annotation]);
7078
- var math = new mathMLTree.MathNode("math", [semantics]); // You can't style <math> nodes, so we wrap the node in a span.
7209
+ var math = new mathMLTree.MathNode("math", [semantics]);
7210
+ math.setAttribute("xmlns", "http://www.w3.org/1998/Math/MathML"); // You can't style <math> nodes, so we wrap the node in a span.
7079
7211
  // NOTE: The span class is not typed to have <math> nodes as children, and
7080
7212
  // we don't want to make the children type more generic since the children
7081
7213
  // of span are expected to have more fields in `buildHtml` contexts.
7082
- // $FlowFixMe
7083
7214
 
7084
- return buildCommon.makeSpan(["katex-mathml"], [math]);
7215
+ var wrapperClass = forMathmlOnly ? "katex" : "katex-mathml"; // $FlowFixMe
7216
+
7217
+ return buildCommon.makeSpan([wrapperClass], [math]);
7085
7218
  }
7086
7219
  // CONCATENATED MODULE: ./src/buildTree.js
7087
7220
 
@@ -7094,7 +7227,8 @@ function buildMathML(tree, texExpression, options) {
7094
7227
  var buildTree_optionsFromSettings = function optionsFromSettings(settings) {
7095
7228
  return new src_Options({
7096
7229
  style: settings.displayMode ? src_Style.DISPLAY : src_Style.TEXT,
7097
- maxSize: settings.maxSize
7230
+ maxSize: settings.maxSize,
7231
+ minRuleThickness: settings.minRuleThickness
7098
7232
  });
7099
7233
  };
7100
7234
 
@@ -7118,9 +7252,21 @@ var buildTree_displayWrap = function displayWrap(node, settings) {
7118
7252
 
7119
7253
  var buildTree_buildTree = function buildTree(tree, expression, settings) {
7120
7254
  var options = buildTree_optionsFromSettings(settings);
7121
- var mathMLNode = buildMathML(tree, expression, options);
7122
- var htmlNode = buildHTML(tree, options);
7123
- var katexNode = buildCommon.makeSpan(["katex"], [mathMLNode, htmlNode]);
7255
+ var katexNode;
7256
+
7257
+ if (settings.output === "mathml") {
7258
+ return buildMathML(tree, expression, options, true);
7259
+ } else if (settings.output === "html") {
7260
+ var htmlNode = buildHTML(tree, options);
7261
+ katexNode = buildCommon.makeSpan(["katex"], [htmlNode]);
7262
+ } else {
7263
+ var mathMLNode = buildMathML(tree, expression, options, false);
7264
+
7265
+ var _htmlNode = buildHTML(tree, options);
7266
+
7267
+ katexNode = buildCommon.makeSpan(["katex"], [mathMLNode, _htmlNode]);
7268
+ }
7269
+
7124
7270
  return buildTree_displayWrap(katexNode, settings);
7125
7271
  };
7126
7272
  var buildTree_buildHTMLTree = function buildHTMLTree(tree, expression, settings) {
@@ -7558,7 +7704,11 @@ var accent_htmlBuilder = function htmlBuilder(grp, options) {
7558
7704
  accent = buildCommon.staticSvg("vec", options);
7559
7705
  width = buildCommon.svgData.vec[1];
7560
7706
  } else {
7561
- accent = buildCommon.makeSymbol(group.label, "Main-Regular", group.mode, options); // Remove the italic correction of the accent, because it only serves to
7707
+ accent = buildCommon.makeOrd({
7708
+ mode: group.mode,
7709
+ text: group.label
7710
+ }, options, "textord");
7711
+ accent = assertSymbolDomNode(accent); // Remove the italic correction of the accent, because it only serves to
7562
7712
  // shift the accent over to a place we don't want.
7563
7713
 
7564
7714
  accent.italic = 0;
@@ -7985,7 +8135,12 @@ defineFunction({
7985
8135
  handler: function handler(_ref2, args) {
7986
8136
  var parser = _ref2.parser,
7987
8137
  breakOnTokenText = _ref2.breakOnTokenText;
7988
- var color = assertNodeType(args[0], "color-token").color; // If we see a styling function, parse out the implicit body
8138
+ var color = assertNodeType(args[0], "color-token").color; // Set macro \current@color in current namespace to store the current
8139
+ // color, mimicking the behavior of color.sty.
8140
+ // This is currently used just to correctly color a \right
8141
+ // that follows a \color command.
8142
+
8143
+ parser.gullet.macros.set("\\current@color", color); // Parse out the implicit body that should be colored.
7989
8144
 
7990
8145
  var body = parser.parseExpression(true, breakOnTokenText);
7991
8146
  return {
@@ -8105,6 +8260,7 @@ defineFunction({
8105
8260
 
8106
8261
 
8107
8262
 
8263
+
8108
8264
  /**
8109
8265
  * Get the metrics for a given symbol and font, after transformation (i.e.
8110
8266
  * after following replacement from symbols.js)
@@ -8208,13 +8364,18 @@ var delimiter_makeInner = function makeInner(symbol, font, mode) {
8208
8364
  type: "elem",
8209
8365
  elem: inner
8210
8366
  };
8367
+ }; // Helper for makeStackedDelim
8368
+
8369
+
8370
+ var lap = {
8371
+ type: "kern",
8372
+ size: -0.005
8211
8373
  };
8212
8374
  /**
8213
8375
  * Make a stacked delimiter out of a given delimiter, with the total height at
8214
8376
  * least `heightTotal`. This routine is mentioned on page 442 of the TeXbook.
8215
8377
  */
8216
8378
 
8217
-
8218
8379
  var delimiter_makeStackedDelim = function makeStackedDelim(delim, heightTotal, center, options, mode, classes) {
8219
8380
  // There are four parts, the top, an optional middle, a repeated part, and a
8220
8381
  // bottom.
@@ -8335,7 +8496,7 @@ var delimiter_makeStackedDelim = function makeStackedDelim(delim, heightTotal, c
8335
8496
 
8336
8497
  var minHeight = topHeightTotal + bottomHeightTotal + middleHeightTotal; // Compute the number of copies of the repeat symbol we will need
8337
8498
 
8338
- var repeatCount = Math.ceil((heightTotal - minHeight) / (middleFactor * repeatHeightTotal)); // Compute the total height of the delimiter including all the symbols
8499
+ var repeatCount = Math.max(0, Math.ceil((heightTotal - minHeight) / (middleFactor * repeatHeightTotal))); // Compute the total height of the delimiter including all the symbols
8339
8500
 
8340
8501
  var realHeightTotal = minHeight + repeatCount * middleFactor * repeatHeightTotal; // The center of the delimiter is placed at the center of the axis. Note
8341
8502
  // that in this context, "center" means that the delimiter should be
@@ -8349,7 +8510,15 @@ var delimiter_makeStackedDelim = function makeStackedDelim(delim, heightTotal, c
8349
8510
  } // Calculate the depth
8350
8511
 
8351
8512
 
8352
- var depth = realHeightTotal / 2 - axisHeight; // Now, we start building the pieces that will go into the vlist
8513
+ var depth = realHeightTotal / 2 - axisHeight; // This function differs from the TeX procedure in one way.
8514
+ // We shift each repeat element downwards by 0.005em, to prevent a gap
8515
+ // due to browser floating point rounding error.
8516
+ // Then, at the last element-to element joint, we add one extra repeat
8517
+ // element to cover the gap created by the shifts.
8518
+ // Find the shift needed to align the upper end of the extra element at a point
8519
+ // 0.005em above the lower end of the top element.
8520
+
8521
+ var shiftOfExtraElement = (repeatCount + 1) * 0.005 - repeatHeightTotal; // Now, we start building the pieces that will go into the vlist
8353
8522
  // Keep a list of the inner pieces
8354
8523
 
8355
8524
  var inners = []; // Add the bottom symbol
@@ -8359,23 +8528,43 @@ var delimiter_makeStackedDelim = function makeStackedDelim(delim, heightTotal, c
8359
8528
  if (middle === null) {
8360
8529
  // Add that many symbols
8361
8530
  for (var i = 0; i < repeatCount; i++) {
8531
+ inners.push(lap); // overlap
8532
+
8362
8533
  inners.push(delimiter_makeInner(repeat, font, mode));
8363
8534
  }
8364
8535
  } else {
8365
8536
  // When there is a middle bit, we need the middle part and two repeated
8366
8537
  // sections
8367
8538
  for (var _i = 0; _i < repeatCount; _i++) {
8539
+ inners.push(lap);
8368
8540
  inners.push(delimiter_makeInner(repeat, font, mode));
8369
- }
8541
+ } // Insert one extra repeat element.
8542
+
8543
+
8544
+ inners.push({
8545
+ type: "kern",
8546
+ size: shiftOfExtraElement
8547
+ });
8548
+ inners.push(delimiter_makeInner(repeat, font, mode));
8549
+ inners.push(lap); // Now insert the middle of the brace.
8370
8550
 
8371
8551
  inners.push(delimiter_makeInner(middle, font, mode));
8372
8552
 
8373
8553
  for (var _i2 = 0; _i2 < repeatCount; _i2++) {
8554
+ inners.push(lap);
8374
8555
  inners.push(delimiter_makeInner(repeat, font, mode));
8375
8556
  }
8376
- } // Add the top symbol
8557
+ } // To cover the gap create by the overlaps, insert one more repeat element,
8558
+ // at a position that juts 0.005 above the bottom of the top element.
8377
8559
 
8378
8560
 
8561
+ inners.push({
8562
+ type: "kern",
8563
+ size: shiftOfExtraElement
8564
+ });
8565
+ inners.push(delimiter_makeInner(repeat, font, mode));
8566
+ inners.push(lap); // Add the top symbol
8567
+
8379
8568
  inners.push(delimiter_makeInner(top, font, mode)); // Finally, build the vlist
8380
8569
 
8381
8570
  var newOptions = options.havingBaseStyle(src_Style.TEXT);
@@ -8393,19 +8582,9 @@ var vbPad = 80; // padding above the surd, measured inside the viewBox.
8393
8582
 
8394
8583
  var emPad = 0.08; // padding, in ems, measured in the document.
8395
8584
 
8396
- var delimiter_sqrtSvg = function sqrtSvg(sqrtName, height, viewBoxHeight, options) {
8397
- var alternate;
8398
-
8399
- if (sqrtName === "sqrtTall") {
8400
- // sqrtTall is from glyph U23B7 in the font KaTeX_Size4-Regular
8401
- // One path edge has a variable length. It runs from the viniculumn
8402
- // to a point near (14 units) the bottom of the surd. The viniculum
8403
- // is 40 units thick. So the length of the line in question is:
8404
- var vertSegment = viewBoxHeight - 54 - vbPad;
8405
- alternate = "M702 " + vbPad + "H400000v40H742v" + vertSegment + "l-4 4-4 4c-.667.7\n-2 1.5-4 2.5s-4.167 1.833-6.5 2.5-5.5 1-9.5 1h-12l-28-84c-16.667-52-96.667\n-294.333-240-727l-212 -643 -85 170c-4-3.333-8.333-7.667-13 -13l-13-13l77-155\n 77-156c66 199.333 139 419.667 219 661 l218 661zM702 " + vbPad + "H400000v40H742z";
8406
- }
8407
-
8408
- var pathNode = new domTree_PathNode(sqrtName, alternate);
8585
+ var delimiter_sqrtSvg = function sqrtSvg(sqrtName, height, viewBoxHeight, extraViniculum, options) {
8586
+ var path = sqrtPath(sqrtName, extraViniculum, viewBoxHeight);
8587
+ var pathNode = new domTree_PathNode(sqrtName, path);
8409
8588
  var svg = new SvgNode([pathNode], {
8410
8589
  // Note: 1000:1 ratio of viewBox to document em width.
8411
8590
  "width": "400em",
@@ -8427,7 +8606,10 @@ var makeSqrtImage = function makeSqrtImage(height, options) {
8427
8606
 
8428
8607
  var delim = traverseSequence("\\surd", height * newOptions.sizeMultiplier, stackLargeDelimiterSequence, newOptions);
8429
8608
  var sizeMultiplier = newOptions.sizeMultiplier; // default
8430
- // Create a span containing an SVG image of a sqrt symbol.
8609
+ // The standard sqrt SVGs each have a 0.04em thick viniculum.
8610
+ // If Settings.minRuleThickness is larger than that, we add extraViniculum.
8611
+
8612
+ var extraViniculum = Math.max(0, options.minRuleThickness - options.fontMetrics().sqrtRuleThickness); // Create a span containing an SVG image of a sqrt symbol.
8431
8613
 
8432
8614
  var span;
8433
8615
  var spanHeight = 0;
@@ -8441,7 +8623,8 @@ var makeSqrtImage = function makeSqrtImage(height, options) {
8441
8623
 
8442
8624
  if (delim.type === "small") {
8443
8625
  // Get an SVG that is derived from glyph U+221A in font KaTeX-Main.
8444
- viewBoxHeight = 1000 + vbPad; // 1000 unit glyph height.
8626
+ // 1000 unit normal glyph height.
8627
+ viewBoxHeight = 1000 + 1000 * extraViniculum + vbPad;
8445
8628
 
8446
8629
  if (height < 1.0) {
8447
8630
  sizeMultiplier = 1.0; // mimic a \textfont radical
@@ -8449,26 +8632,26 @@ var makeSqrtImage = function makeSqrtImage(height, options) {
8449
8632
  sizeMultiplier = 0.7; // mimic a \scriptfont radical
8450
8633
  }
8451
8634
 
8452
- spanHeight = (1.0 + emPad) / sizeMultiplier;
8453
- texHeight = 1.00 / sizeMultiplier;
8454
- span = delimiter_sqrtSvg("sqrtMain", spanHeight, viewBoxHeight, options);
8635
+ spanHeight = (1.0 + extraViniculum + emPad) / sizeMultiplier;
8636
+ texHeight = (1.00 + extraViniculum) / sizeMultiplier;
8637
+ span = delimiter_sqrtSvg("sqrtMain", spanHeight, viewBoxHeight, extraViniculum, options);
8455
8638
  span.style.minWidth = "0.853em";
8456
8639
  advanceWidth = 0.833 / sizeMultiplier; // from the font.
8457
8640
  } else if (delim.type === "large") {
8458
8641
  // These SVGs come from fonts: KaTeX_Size1, _Size2, etc.
8459
8642
  viewBoxHeight = (1000 + vbPad) * sizeToMaxHeight[delim.size];
8460
- texHeight = sizeToMaxHeight[delim.size] / sizeMultiplier;
8461
- spanHeight = (sizeToMaxHeight[delim.size] + emPad) / sizeMultiplier;
8462
- span = delimiter_sqrtSvg("sqrtSize" + delim.size, spanHeight, viewBoxHeight, options);
8643
+ texHeight = (sizeToMaxHeight[delim.size] + extraViniculum) / sizeMultiplier;
8644
+ spanHeight = (sizeToMaxHeight[delim.size] + extraViniculum + emPad) / sizeMultiplier;
8645
+ span = delimiter_sqrtSvg("sqrtSize" + delim.size, spanHeight, viewBoxHeight, extraViniculum, options);
8463
8646
  span.style.minWidth = "1.02em";
8464
8647
  advanceWidth = 1.0 / sizeMultiplier; // 1.0 from the font.
8465
8648
  } else {
8466
8649
  // Tall sqrt. In TeX, this would be stacked using multiple glyphs.
8467
8650
  // We'll use a single SVG to accomplish the same thing.
8468
- spanHeight = height + emPad;
8469
- texHeight = height;
8470
- viewBoxHeight = Math.floor(1000 * height) + vbPad;
8471
- span = delimiter_sqrtSvg("sqrtTall", spanHeight, viewBoxHeight, options);
8651
+ spanHeight = height + extraViniculum + emPad;
8652
+ texHeight = height + extraViniculum;
8653
+ viewBoxHeight = Math.floor(1000 * height + extraViniculum) + vbPad;
8654
+ span = delimiter_sqrtSvg("sqrtTall", spanHeight, viewBoxHeight, extraViniculum, options);
8472
8655
  span.style.minWidth = "0.742em";
8473
8656
  advanceWidth = 1.056;
8474
8657
  }
@@ -8482,7 +8665,7 @@ var makeSqrtImage = function makeSqrtImage(height, options) {
8482
8665
  // This actually should depend on the chosen font -- e.g. \boldmath
8483
8666
  // should use the thicker surd symbols from e.g. KaTeX_Main-Bold, and
8484
8667
  // have thicker rules.
8485
- ruleWidth: options.fontMetrics().sqrtRuleThickness * sizeMultiplier
8668
+ ruleWidth: (options.fontMetrics().sqrtRuleThickness + extraViniculum) * sizeMultiplier
8486
8669
  };
8487
8670
  }; // There are three kinds of delimiters, delimiters that stack when they become
8488
8671
  // too large
@@ -8874,10 +9057,18 @@ defineFunction({
8874
9057
  // \left case below triggers parsing of \right in
8875
9058
  // `const right = parser.parseFunction();`
8876
9059
  // uses this return value.
9060
+ var color = context.parser.gullet.macros.get("\\current@color");
9061
+
9062
+ if (color && typeof color !== "string") {
9063
+ throw new src_ParseError("\\current@color set to non-string in \\right");
9064
+ }
9065
+
8877
9066
  return {
8878
9067
  type: "leftright-right",
8879
9068
  mode: context.parser.mode,
8880
- delim: checkDelimiter(args[0], context).text
9069
+ delim: checkDelimiter(args[0], context).text,
9070
+ color: color // undefined if not set via \color
9071
+
8881
9072
  };
8882
9073
  }
8883
9074
  });
@@ -8903,7 +9094,8 @@ defineFunction({
8903
9094
  mode: parser.mode,
8904
9095
  body: body,
8905
9096
  left: delim.text,
8906
- right: right.delim
9097
+ right: right.delim,
9098
+ rightColor: right.color
8907
9099
  };
8908
9100
  },
8909
9101
  htmlBuilder: function htmlBuilder(group, options) {
@@ -8960,12 +9152,13 @@ defineFunction({
8960
9152
  }
8961
9153
  }
8962
9154
 
8963
- var rightDelim; // Same for the right delimiter
9155
+ var rightDelim; // Same for the right delimiter, but using color specified by \color
8964
9156
 
8965
9157
  if (group.right === ".") {
8966
9158
  rightDelim = makeNullDelimiter(options, ["mclose"]);
8967
9159
  } else {
8968
- rightDelim = delimiter.leftRightDelim(group.right, innerHeight, innerDepth, options, group.mode, ["mclose"]);
9160
+ var colorOptions = group.rightColor ? options.withColor(group.rightColor) : options;
9161
+ rightDelim = delimiter.leftRightDelim(group.right, innerHeight, innerDepth, colorOptions, group.mode, ["mclose"]);
8969
9162
  } // Add it to the end of the expression.
8970
9163
 
8971
9164
 
@@ -8985,6 +9178,11 @@ defineFunction({
8985
9178
  if (group.right !== ".") {
8986
9179
  var rightNode = new mathMLTree.MathNode("mo", [buildMathML_makeText(group.right, group.mode)]);
8987
9180
  rightNode.setAttribute("fence", "true");
9181
+
9182
+ if (group.rightColor) {
9183
+ rightNode.setAttribute("mathcolor", group.rightColor);
9184
+ }
9185
+
8988
9186
  inner.push(rightNode);
8989
9187
  }
8990
9188
 
@@ -9087,16 +9285,25 @@ var enclose_htmlBuilder = function htmlBuilder(group, options) {
9087
9285
  } // Add vertical padding
9088
9286
 
9089
9287
 
9090
- var vertPad = 0; // ref: LaTeX source2e: \fboxsep = 3pt; \fboxrule = .4pt
9091
- // ref: cancel package: \advance\totalheight2\p@ % "+2"
9288
+ var vertPad = 0;
9289
+ var ruleThickness = 0; // ref: cancel package: \advance\totalheight2\p@ % "+2"
9092
9290
 
9093
9291
  if (/box/.test(label)) {
9094
- vertPad = label === "colorbox" ? 0.3 : 0.34;
9292
+ ruleThickness = Math.max(options.fontMetrics().fboxrule, // default
9293
+ options.minRuleThickness // User override.
9294
+ );
9295
+ vertPad = options.fontMetrics().fboxsep + (label === "colorbox" ? 0 : ruleThickness);
9095
9296
  } else {
9096
9297
  vertPad = isSingleChar ? 0.2 : 0;
9097
9298
  }
9098
9299
 
9099
9300
  img = stretchy.encloseSpan(inner, label, vertPad, options);
9301
+
9302
+ if (/fbox|boxed|fcolorbox/.test(label)) {
9303
+ img.style.borderStyle = "solid";
9304
+ img.style.borderWidth = ruleThickness + "em";
9305
+ }
9306
+
9100
9307
  imgShift = inner.depth + vertPad;
9101
9308
 
9102
9309
  if (group.backgroundColor) {
@@ -9157,6 +9364,7 @@ var enclose_htmlBuilder = function htmlBuilder(group, options) {
9157
9364
  };
9158
9365
 
9159
9366
  var enclose_mathmlBuilder = function mathmlBuilder(group, options) {
9367
+ var fboxsep = 0;
9160
9368
  var node = new mathMLTree.MathNode(group.label.indexOf("colorbox") > -1 ? "mpadded" : "menclose", [buildMathML_buildGroup(group.body, options)]);
9161
9369
 
9162
9370
  switch (group.label) {
@@ -9180,14 +9388,17 @@ var enclose_mathmlBuilder = function mathmlBuilder(group, options) {
9180
9388
  case "\\colorbox":
9181
9389
  // <menclose> doesn't have a good notation option. So use <mpadded>
9182
9390
  // instead. Set some attributes that come included with <menclose>.
9183
- node.setAttribute("width", "+6pt");
9184
- node.setAttribute("height", "+6pt");
9185
- node.setAttribute("lspace", "3pt"); // LaTeX source2e: \fboxsep = 3pt
9391
+ fboxsep = options.fontMetrics().fboxsep * options.fontMetrics().ptPerEm;
9392
+ node.setAttribute("width", "+" + 2 * fboxsep + "pt");
9393
+ node.setAttribute("height", "+" + 2 * fboxsep + "pt");
9394
+ node.setAttribute("lspace", fboxsep + "pt"); //
9186
9395
 
9187
- node.setAttribute("voffset", "3pt");
9396
+ node.setAttribute("voffset", fboxsep + "pt");
9188
9397
 
9189
9398
  if (group.label === "\\fcolorbox") {
9190
- var thk = options.fontMetrics().defaultRuleThickness;
9399
+ var thk = Math.max(options.fontMetrics().fboxrule, // default
9400
+ options.minRuleThickness // user override
9401
+ );
9191
9402
  node.setAttribute("style", "border: " + thk + "em solid " + String(group.borderColor));
9192
9403
  }
9193
9404
 
@@ -9262,7 +9473,7 @@ defineFunction({
9262
9473
  names: ["\\fbox"],
9263
9474
  props: {
9264
9475
  numArgs: 1,
9265
- argTypes: ["text"],
9476
+ argTypes: ["hbox"],
9266
9477
  allowedInText: true
9267
9478
  },
9268
9479
  handler: function handler(_ref3, args) {
@@ -9350,18 +9561,19 @@ function defineEnvironment(_ref) {
9350
9561
 
9351
9562
 
9352
9563
 
9564
+
9353
9565
  function getHLines(parser) {
9354
9566
  // Return an array. The array length = number of hlines.
9355
9567
  // Each element in the array tells if the line is dashed.
9356
9568
  var hlineInfo = [];
9357
9569
  parser.consumeSpaces();
9358
- var nxt = parser.nextToken.text;
9570
+ var nxt = parser.fetch().text;
9359
9571
 
9360
9572
  while (nxt === "\\hline" || nxt === "\\hdashline") {
9361
9573
  parser.consume();
9362
9574
  hlineInfo.push(nxt === "\\hdashline");
9363
9575
  parser.consumeSpaces();
9364
- nxt = parser.nextToken.text;
9576
+ nxt = parser.fetch().text;
9365
9577
  }
9366
9578
 
9367
9579
  return hlineInfo;
@@ -9397,8 +9609,10 @@ function parseArray(parser, _ref, style) {
9397
9609
  throw new src_ParseError("Invalid \\arraystretch: " + stretch);
9398
9610
  }
9399
9611
  }
9400
- }
9612
+ } // Start group for first cell
9613
+
9401
9614
 
9615
+ parser.gullet.beginGroup();
9402
9616
  var row = [];
9403
9617
  var body = [row];
9404
9618
  var rowGaps = [];
@@ -9408,7 +9622,10 @@ function parseArray(parser, _ref, style) {
9408
9622
 
9409
9623
  while (true) {
9410
9624
  // eslint-disable-line no-constant-condition
9625
+ // Parse each cell in its own group (namespace)
9411
9626
  var cell = parser.parseExpression(false, "\\cr");
9627
+ parser.gullet.endGroup();
9628
+ parser.gullet.beginGroup();
9412
9629
  cell = {
9413
9630
  type: "ordgroup",
9414
9631
  mode: parser.mode,
@@ -9425,7 +9642,7 @@ function parseArray(parser, _ref, style) {
9425
9642
  }
9426
9643
 
9427
9644
  row.push(cell);
9428
- var next = parser.nextToken.text;
9645
+ var next = parser.fetch().text;
9429
9646
 
9430
9647
  if (next === "&") {
9431
9648
  parser.consume();
@@ -9452,7 +9669,10 @@ function parseArray(parser, _ref, style) {
9452
9669
  } else {
9453
9670
  throw new src_ParseError("Expected & or \\\\ or \\cr or \\end", parser.nextToken);
9454
9671
  }
9455
- }
9672
+ } // End cell group
9673
+
9674
+
9675
+ parser.gullet.endGroup(); // End array group defining \\
9456
9676
 
9457
9677
  parser.gullet.endGroup();
9458
9678
  return {
@@ -9486,11 +9706,24 @@ var array_htmlBuilder = function htmlBuilder(group, options) {
9486
9706
  var hLinesBeforeRow = group.hLinesBeforeRow;
9487
9707
  var nc = 0;
9488
9708
  var body = new Array(nr);
9489
- var hlines = []; // Horizontal spacing
9709
+ var hlines = [];
9710
+ var ruleThickness = Math.max( // From LaTeX \showthe\arrayrulewidth. Equals 0.04 em.
9711
+ options.fontMetrics().arrayRuleWidth, options.minRuleThickness // User override.
9712
+ ); // Horizontal spacing
9490
9713
 
9491
9714
  var pt = 1 / options.fontMetrics().ptPerEm;
9492
- var arraycolsep = 5 * pt; // \arraycolsep in article.cls
9493
- // Vertical spacing
9715
+ var arraycolsep = 5 * pt; // default value, i.e. \arraycolsep in article.cls
9716
+
9717
+ if (group.colSeparationType && group.colSeparationType === "small") {
9718
+ // We're in a {smallmatrix}. Default column space is \thickspace,
9719
+ // i.e. 5/18em = 0.2778em, per amsmath.dtx for {smallmatrix}.
9720
+ // But that needs adjustment because LaTeX applies \scriptstyle to the
9721
+ // entire array, including the colspace, but this function applies
9722
+ // \scriptstyle only inside each element.
9723
+ var localMultiplier = options.havingStyle(src_Style.SCRIPT).sizeMultiplier;
9724
+ arraycolsep = 0.2778 * (localMultiplier / options.sizeMultiplier);
9725
+ } // Vertical spacing
9726
+
9494
9727
 
9495
9728
  var baselineskip = 12 * pt; // see size10.clo
9496
9729
  // Default \jot from ltmath.dtx
@@ -9602,17 +9835,15 @@ var array_htmlBuilder = function htmlBuilder(group, options) {
9602
9835
  cols.push(colSep);
9603
9836
  }
9604
9837
 
9605
- if (colDescr.separator === "|") {
9838
+ if (colDescr.separator === "|" || colDescr.separator === ":") {
9839
+ var lineType = colDescr.separator === "|" ? "solid" : "dashed";
9606
9840
  var separator = buildCommon.makeSpan(["vertical-separator"], [], options);
9607
9841
  separator.style.height = totalHeight + "em";
9842
+ separator.style.borderRightWidth = ruleThickness + "em";
9843
+ separator.style.borderRightStyle = lineType;
9844
+ separator.style.margin = "0 -" + ruleThickness / 2 + "em";
9608
9845
  separator.style.verticalAlign = -(totalHeight - offset) + "em";
9609
9846
  cols.push(separator);
9610
- } else if (colDescr.separator === ":") {
9611
- var _separator = buildCommon.makeSpan(["vertical-separator", "vs-dashed"], [], options);
9612
-
9613
- _separator.style.height = totalHeight + "em";
9614
- _separator.style.verticalAlign = -(totalHeight - offset) + "em";
9615
- cols.push(_separator);
9616
9847
  } else {
9617
9848
  throw new src_ParseError("Invalid separator type: " + colDescr.separator);
9618
9849
  }
@@ -9679,8 +9910,8 @@ var array_htmlBuilder = function htmlBuilder(group, options) {
9679
9910
  body = buildCommon.makeSpan(["mtable"], cols); // Add \hline(s), if any.
9680
9911
 
9681
9912
  if (hlines.length > 0) {
9682
- var line = buildCommon.makeLineSpan("hline", options, 0.05);
9683
- var dashes = buildCommon.makeLineSpan("hdashline", options, 0.05);
9913
+ var line = buildCommon.makeLineSpan("hline", options, ruleThickness);
9914
+ var dashes = buildCommon.makeLineSpan("hdashline", options, ruleThickness);
9684
9915
  var vListElems = [{
9685
9916
  type: "elem",
9686
9917
  elem: body,
@@ -9737,7 +9968,8 @@ var array_mathmlBuilder = function mathmlBuilder(group, options) {
9737
9968
  // The 0.16 and 0.09 values are found emprically. They produce an array
9738
9969
  // similar to LaTeX and in which content does not interfere with \hines.
9739
9970
 
9740
- var gap = 0.16 + group.arraystretch - 1 + (group.addJot ? 0.09 : 0);
9971
+ var gap = group.arraystretch === 0.5 ? 0.1 // {smallmatrix}, {subarray}
9972
+ : 0.16 + group.arraystretch - 1 + (group.addJot ? 0.09 : 0);
9741
9973
  table.setAttribute("rowspacing", gap + "em"); // MathML table lines go only between cells.
9742
9974
  // To place a line on an edge we'll use <menclose>, if necessary.
9743
9975
 
@@ -9801,6 +10033,8 @@ var array_mathmlBuilder = function mathmlBuilder(group, options) {
9801
10033
  table.setAttribute("columnspacing", spacing.trim());
9802
10034
  } else if (group.colSeparationType === "alignat") {
9803
10035
  table.setAttribute("columnspacing", "0em");
10036
+ } else if (group.colSeparationType === "small") {
10037
+ table.setAttribute("columnspacing", "0.2778em");
9804
10038
  } else {
9805
10039
  table.setAttribute("columnspacing", "1em");
9806
10040
  } // Address \hline and \hdashline
@@ -9820,13 +10054,18 @@ var array_mathmlBuilder = function mathmlBuilder(group, options) {
9820
10054
  table.setAttribute("rowlines", rowLines.trim());
9821
10055
  }
9822
10056
 
9823
- if (menclose === "") {
9824
- return table;
9825
- } else {
9826
- var wrapper = new mathMLTree.MathNode("menclose", [table]);
9827
- wrapper.setAttribute("notation", menclose.trim());
9828
- return wrapper;
10057
+ if (menclose !== "") {
10058
+ table = new mathMLTree.MathNode("menclose", [table]);
10059
+ table.setAttribute("notation", menclose.trim());
10060
+ }
10061
+
10062
+ if (group.arraystretch && group.arraystretch < 1) {
10063
+ // A small array. Wrap in scriptstyle so row gap is not too large.
10064
+ table = new mathMLTree.MathNode("mstyle", [table]);
10065
+ table.setAttribute("scriptlevel", "1");
9829
10066
  }
10067
+
10068
+ return table;
9830
10069
  }; // Convenience function for aligned and alignedat environments.
9831
10070
 
9832
10071
 
@@ -9992,11 +10231,74 @@ defineEnvironment({
9992
10231
  mode: context.mode,
9993
10232
  body: [res],
9994
10233
  left: delimiters[0],
9995
- right: delimiters[1]
10234
+ right: delimiters[1],
10235
+ rightColor: undefined // \right uninfluenced by \color in array
10236
+
9996
10237
  } : res;
9997
10238
  },
9998
10239
  htmlBuilder: array_htmlBuilder,
9999
10240
  mathmlBuilder: array_mathmlBuilder
10241
+ });
10242
+ defineEnvironment({
10243
+ type: "array",
10244
+ names: ["smallmatrix"],
10245
+ props: {
10246
+ numArgs: 0
10247
+ },
10248
+ handler: function handler(context) {
10249
+ var payload = {
10250
+ arraystretch: 0.5
10251
+ };
10252
+ var res = parseArray(context.parser, payload, "script");
10253
+ res.colSeparationType = "small";
10254
+ return res;
10255
+ },
10256
+ htmlBuilder: array_htmlBuilder,
10257
+ mathmlBuilder: array_mathmlBuilder
10258
+ });
10259
+ defineEnvironment({
10260
+ type: "array",
10261
+ names: ["subarray"],
10262
+ props: {
10263
+ numArgs: 1
10264
+ },
10265
+ handler: function handler(context, args) {
10266
+ // Parsing of {subarray} is similar to {array}
10267
+ var symNode = checkSymbolNodeType(args[0]);
10268
+ var colalign = symNode ? [args[0]] : assertNodeType(args[0], "ordgroup").body;
10269
+ var cols = colalign.map(function (nde) {
10270
+ var node = assertSymbolNodeType(nde);
10271
+ var ca = node.text; // {subarray} only recognizes "l" & "c"
10272
+
10273
+ if ("lc".indexOf(ca) !== -1) {
10274
+ return {
10275
+ type: "align",
10276
+ align: ca
10277
+ };
10278
+ }
10279
+
10280
+ throw new src_ParseError("Unknown column alignment: " + ca, nde);
10281
+ });
10282
+
10283
+ if (cols.length > 1) {
10284
+ throw new src_ParseError("{subarray} can contain only one column");
10285
+ }
10286
+
10287
+ var res = {
10288
+ cols: cols,
10289
+ hskipBeforeAndAfter: false,
10290
+ arraystretch: 0.5
10291
+ };
10292
+ res = parseArray(context.parser, res, "script");
10293
+
10294
+ if (res.body[0].length > 1) {
10295
+ throw new src_ParseError("{subarray} can contain only one column");
10296
+ }
10297
+
10298
+ return res;
10299
+ },
10300
+ htmlBuilder: array_htmlBuilder,
10301
+ mathmlBuilder: array_mathmlBuilder
10000
10302
  }); // A cases environment (in amsmath.sty) is almost equivalent to
10001
10303
  // \def\arraystretch{1.2}%
10002
10304
  // \left\{\begin{array}{@{}l@{\quad}l@{}} … \end{array}\right.
@@ -10036,7 +10338,8 @@ defineEnvironment({
10036
10338
  mode: context.mode,
10037
10339
  body: [res],
10038
10340
  left: "\\{",
10039
- right: "."
10341
+ right: ".",
10342
+ rightColor: undefined
10040
10343
  };
10041
10344
  },
10042
10345
  htmlBuilder: array_htmlBuilder,
@@ -10189,6 +10492,7 @@ defineFunction({
10189
10492
 
10190
10493
 
10191
10494
 
10495
+
10192
10496
  var mclass_makeSpan = buildCommon.makeSpan;
10193
10497
 
10194
10498
  function mclass_htmlBuilder(group, options) {
@@ -10197,8 +10501,44 @@ function mclass_htmlBuilder(group, options) {
10197
10501
  }
10198
10502
 
10199
10503
  function mclass_mathmlBuilder(group, options) {
10504
+ var node;
10200
10505
  var inner = buildMathML_buildExpression(group.body, options);
10201
- return mathMLTree.newDocumentFragment(inner);
10506
+
10507
+ if (group.mclass === "minner") {
10508
+ return mathMLTree.newDocumentFragment(inner);
10509
+ } else if (group.mclass === "mord") {
10510
+ if (group.isCharacterBox) {
10511
+ node = inner[0];
10512
+ node.type = "mi";
10513
+ } else {
10514
+ node = new mathMLTree.MathNode("mi", inner);
10515
+ }
10516
+ } else {
10517
+ if (group.isCharacterBox) {
10518
+ node = inner[0];
10519
+ node.type = "mo";
10520
+ } else {
10521
+ node = new mathMLTree.MathNode("mo", inner);
10522
+ } // Set spacing based on what is the most likely adjacent atom type.
10523
+ // See TeXbook p170.
10524
+
10525
+
10526
+ if (group.mclass === "mbin") {
10527
+ node.attributes.lspace = "0.22em"; // medium space
10528
+
10529
+ node.attributes.rspace = "0.22em";
10530
+ } else if (group.mclass === "mpunct") {
10531
+ node.attributes.lspace = "0em";
10532
+ node.attributes.rspace = "0.17em"; // thinspace
10533
+ } else if (group.mclass === "mopen" || group.mclass === "mclose") {
10534
+ node.attributes.lspace = "0em";
10535
+ node.attributes.rspace = "0em";
10536
+ } // MathML <mo> default space is 5/18 em, so <mrel> needs no action.
10537
+ // Ref: https://developer.mozilla.org/en-US/docs/Web/MathML/Element/mo
10538
+
10539
+ }
10540
+
10541
+ return node;
10202
10542
  } // Math class commands except \mathop
10203
10543
 
10204
10544
 
@@ -10216,7 +10556,9 @@ defineFunction({
10216
10556
  type: "mclass",
10217
10557
  mode: parser.mode,
10218
10558
  mclass: "m" + funcName.substr(5),
10219
- body: defineFunction_ordargument(body)
10559
+ // TODO(kevinb): don't prefix with 'm'
10560
+ body: defineFunction_ordargument(body),
10561
+ isCharacterBox: utils.isCharacterBox(body)
10220
10562
  };
10221
10563
  },
10222
10564
  htmlBuilder: mclass_htmlBuilder,
@@ -10249,7 +10591,8 @@ defineFunction({
10249
10591
  type: "mclass",
10250
10592
  mode: parser.mode,
10251
10593
  mclass: binrelClass(args[0]),
10252
- body: [args[1]]
10594
+ body: [args[1]],
10595
+ isCharacterBox: utils.isCharacterBox(args[1])
10253
10596
  };
10254
10597
  }
10255
10598
  }); // Build a relation or stacked op by placing one symbol on top of another
@@ -10295,7 +10638,8 @@ defineFunction({
10295
10638
  type: "mclass",
10296
10639
  mode: parser.mode,
10297
10640
  mclass: mclass,
10298
- body: [supsub]
10641
+ body: [supsub],
10642
+ isCharacterBox: utils.isCharacterBox(supsub)
10299
10643
  };
10300
10644
  },
10301
10645
  htmlBuilder: mclass_htmlBuilder,
@@ -10308,6 +10652,7 @@ defineFunction({
10308
10652
 
10309
10653
 
10310
10654
 
10655
+
10311
10656
  var font_htmlBuilder = function htmlBuilder(group, options) {
10312
10657
  var font = group.font;
10313
10658
  var newOptions = options.withFont(font);
@@ -10365,7 +10710,8 @@ defineFunction({
10365
10710
  },
10366
10711
  handler: function handler(_ref2, args) {
10367
10712
  var parser = _ref2.parser;
10368
- var body = args[0]; // amsbsy.sty's \boldsymbol uses \binrel spacing to inherit the
10713
+ var body = args[0];
10714
+ var isCharacterBox = utils.isCharacterBox(body); // amsbsy.sty's \boldsymbol uses \binrel spacing to inherit the
10369
10715
  // argument's bin|rel|ord status
10370
10716
 
10371
10717
  return {
@@ -10377,7 +10723,8 @@ defineFunction({
10377
10723
  mode: parser.mode,
10378
10724
  font: "boldsymbol",
10379
10725
  body: body
10380
- }]
10726
+ }],
10727
+ isCharacterBox: isCharacterBox
10381
10728
  };
10382
10729
  }
10383
10730
  }); // Old font changing functions
@@ -11067,6 +11414,14 @@ defineFunction({
11067
11414
  var parser = _ref.parser;
11068
11415
  var body = args[1];
11069
11416
  var href = assertNodeType(args[0], "url").url;
11417
+
11418
+ if (!parser.settings.isTrusted({
11419
+ command: "\\href",
11420
+ url: href
11421
+ })) {
11422
+ return parser.formatUnsupportedCmd("\\href");
11423
+ }
11424
+
11070
11425
  return {
11071
11426
  type: "href",
11072
11427
  mode: parser.mode,
@@ -11100,6 +11455,14 @@ defineFunction({
11100
11455
  handler: function handler(_ref2, args) {
11101
11456
  var parser = _ref2.parser;
11102
11457
  var href = assertNodeType(args[0], "url").url;
11458
+
11459
+ if (!parser.settings.isTrusted({
11460
+ command: "\\url",
11461
+ url: href
11462
+ })) {
11463
+ return parser.formatUnsupportedCmd("\\url");
11464
+ }
11465
+
11103
11466
  var chars = [];
11104
11467
 
11105
11468
  for (var i = 0; i < href.length; i++) {
@@ -11159,64 +11522,243 @@ defineFunction({
11159
11522
  return buildExpressionRow(group.mathml, options);
11160
11523
  }
11161
11524
  });
11162
- // CONCATENATED MODULE: ./src/functions/kern.js
11163
- // Horizontal spacing commands
11525
+ // CONCATENATED MODULE: ./src/functions/includegraphics.js
11164
11526
 
11165
11527
 
11166
11528
 
11167
11529
 
11168
- // TODO: \hskip and \mskip should support plus and minus in lengths
11530
+
11531
+
11532
+
11533
+ var includegraphics_sizeData = function sizeData(str) {
11534
+ if (/^[-+]? *(\d+(\.\d*)?|\.\d+)$/.test(str)) {
11535
+ // str is a number with no unit specified.
11536
+ // default unit is bp, per graphix package.
11537
+ return {
11538
+ number: +str,
11539
+ unit: "bp"
11540
+ };
11541
+ } else {
11542
+ var match = /([-+]?) *(\d+(?:\.\d*)?|\.\d+) *([a-z]{2})/.exec(str);
11543
+
11544
+ if (!match) {
11545
+ throw new src_ParseError("Invalid size: '" + str + "' in \\includegraphics");
11546
+ }
11547
+
11548
+ var data = {
11549
+ number: +(match[1] + match[2]),
11550
+ // sign + magnitude, cast to number
11551
+ unit: match[3]
11552
+ };
11553
+
11554
+ if (!validUnit(data)) {
11555
+ throw new src_ParseError("Invalid unit: '" + data.unit + "' in \\includegraphics.");
11556
+ }
11557
+
11558
+ return data;
11559
+ }
11560
+ };
11169
11561
 
11170
11562
  defineFunction({
11171
- type: "kern",
11172
- names: ["\\kern", "\\mkern", "\\hskip", "\\mskip"],
11563
+ type: "includegraphics",
11564
+ names: ["\\includegraphics"],
11173
11565
  props: {
11174
11566
  numArgs: 1,
11175
- argTypes: ["size"],
11176
- allowedInText: true
11567
+ numOptionalArgs: 1,
11568
+ argTypes: ["raw", "url"],
11569
+ allowedInText: false
11177
11570
  },
11178
- handler: function handler(_ref, args) {
11179
- var parser = _ref.parser,
11180
- funcName = _ref.funcName;
11181
- var size = assertNodeType(args[0], "size");
11571
+ handler: function handler(_ref, args, optArgs) {
11572
+ var parser = _ref.parser;
11573
+ var width = {
11574
+ number: 0,
11575
+ unit: "em"
11576
+ };
11577
+ var height = {
11578
+ number: 0.9,
11579
+ unit: "em"
11580
+ }; // sorta character sized.
11581
+
11582
+ var totalheight = {
11583
+ number: 0,
11584
+ unit: "em"
11585
+ };
11586
+ var alt = "";
11182
11587
 
11183
- if (parser.settings.strict) {
11184
- var mathFunction = funcName[1] === 'm'; // \mkern, \mskip
11588
+ if (optArgs[0]) {
11589
+ var attributeStr = assertNodeType(optArgs[0], "raw").string; // Parser.js does not parse key/value pairs. We get a string.
11185
11590
 
11186
- var muUnit = size.value.unit === 'mu';
11591
+ var attributes = attributeStr.split(",");
11187
11592
 
11188
- if (mathFunction) {
11189
- if (!muUnit) {
11190
- parser.settings.reportNonstrict("mathVsTextUnits", "LaTeX's " + funcName + " supports only mu units, " + ("not " + size.value.unit + " units"));
11191
- }
11593
+ for (var i = 0; i < attributes.length; i++) {
11594
+ var keyVal = attributes[i].split("=");
11192
11595
 
11193
- if (parser.mode !== "math") {
11194
- parser.settings.reportNonstrict("mathVsTextUnits", "LaTeX's " + funcName + " works only in math mode");
11195
- }
11196
- } else {
11197
- // !mathFunction
11198
- if (muUnit) {
11199
- parser.settings.reportNonstrict("mathVsTextUnits", "LaTeX's " + funcName + " doesn't support mu units");
11596
+ if (keyVal.length === 2) {
11597
+ var str = keyVal[1].trim();
11598
+
11599
+ switch (keyVal[0].trim()) {
11600
+ case "alt":
11601
+ alt = str;
11602
+ break;
11603
+
11604
+ case "width":
11605
+ width = includegraphics_sizeData(str);
11606
+ break;
11607
+
11608
+ case "height":
11609
+ height = includegraphics_sizeData(str);
11610
+ break;
11611
+
11612
+ case "totalheight":
11613
+ totalheight = includegraphics_sizeData(str);
11614
+ break;
11615
+
11616
+ default:
11617
+ throw new src_ParseError("Invalid key: '" + keyVal[0] + "' in \\includegraphics.");
11618
+ }
11200
11619
  }
11201
11620
  }
11202
11621
  }
11203
11622
 
11623
+ var src = assertNodeType(args[0], "url").url;
11624
+
11625
+ if (alt === "") {
11626
+ // No alt given. Use the file name. Strip away the path.
11627
+ alt = src;
11628
+ alt = alt.replace(/^.*[\\/]/, '');
11629
+ alt = alt.substring(0, alt.lastIndexOf('.'));
11630
+ }
11631
+
11632
+ if (!parser.settings.isTrusted({
11633
+ command: "\\includegraphics",
11634
+ url: src
11635
+ })) {
11636
+ return parser.formatUnsupportedCmd("\\includegraphics");
11637
+ }
11638
+
11204
11639
  return {
11205
- type: "kern",
11640
+ type: "includegraphics",
11206
11641
  mode: parser.mode,
11207
- dimension: size.value
11642
+ alt: alt,
11643
+ width: width,
11644
+ height: height,
11645
+ totalheight: totalheight,
11646
+ src: src
11208
11647
  };
11209
11648
  },
11210
11649
  htmlBuilder: function htmlBuilder(group, options) {
11211
- return buildCommon.makeGlue(group.dimension, options);
11212
- },
11213
- mathmlBuilder: function mathmlBuilder(group, options) {
11214
- var dimension = units_calculateSize(group.dimension, options);
11215
- return new mathMLTree.SpaceNode(dimension);
11216
- }
11217
- });
11218
- // CONCATENATED MODULE: ./src/functions/lap.js
11219
- // Horizontal overlap functions
11650
+ var height = units_calculateSize(group.height, options);
11651
+ var depth = 0;
11652
+
11653
+ if (group.totalheight.number > 0) {
11654
+ depth = units_calculateSize(group.totalheight, options) - height;
11655
+ depth = Number(depth.toFixed(2));
11656
+ }
11657
+
11658
+ var width = 0;
11659
+
11660
+ if (group.width.number > 0) {
11661
+ width = units_calculateSize(group.width, options);
11662
+ }
11663
+
11664
+ var style = {
11665
+ height: height + depth + "em"
11666
+ };
11667
+
11668
+ if (width > 0) {
11669
+ style.width = width + "em";
11670
+ }
11671
+
11672
+ if (depth > 0) {
11673
+ style.verticalAlign = -depth + "em";
11674
+ }
11675
+
11676
+ var node = new domTree_Img(group.src, group.alt, style);
11677
+ node.height = height;
11678
+ node.depth = depth;
11679
+ return node;
11680
+ },
11681
+ mathmlBuilder: function mathmlBuilder(group, options) {
11682
+ var node = new mathMLTree.MathNode("mglyph", []);
11683
+ node.setAttribute("alt", group.alt);
11684
+ var height = units_calculateSize(group.height, options);
11685
+ var depth = 0;
11686
+
11687
+ if (group.totalheight.number > 0) {
11688
+ depth = units_calculateSize(group.totalheight, options) - height;
11689
+ depth = depth.toFixed(2);
11690
+ node.setAttribute("valign", "-" + depth + "em");
11691
+ }
11692
+
11693
+ node.setAttribute("height", height + depth + "em");
11694
+
11695
+ if (group.width.number > 0) {
11696
+ var width = units_calculateSize(group.width, options);
11697
+ node.setAttribute("width", width + "em");
11698
+ }
11699
+
11700
+ node.setAttribute("src", group.src);
11701
+ return node;
11702
+ }
11703
+ });
11704
+ // CONCATENATED MODULE: ./src/functions/kern.js
11705
+ // Horizontal spacing commands
11706
+
11707
+
11708
+
11709
+
11710
+ // TODO: \hskip and \mskip should support plus and minus in lengths
11711
+
11712
+ defineFunction({
11713
+ type: "kern",
11714
+ names: ["\\kern", "\\mkern", "\\hskip", "\\mskip"],
11715
+ props: {
11716
+ numArgs: 1,
11717
+ argTypes: ["size"],
11718
+ allowedInText: true
11719
+ },
11720
+ handler: function handler(_ref, args) {
11721
+ var parser = _ref.parser,
11722
+ funcName = _ref.funcName;
11723
+ var size = assertNodeType(args[0], "size");
11724
+
11725
+ if (parser.settings.strict) {
11726
+ var mathFunction = funcName[1] === 'm'; // \mkern, \mskip
11727
+
11728
+ var muUnit = size.value.unit === 'mu';
11729
+
11730
+ if (mathFunction) {
11731
+ if (!muUnit) {
11732
+ parser.settings.reportNonstrict("mathVsTextUnits", "LaTeX's " + funcName + " supports only mu units, " + ("not " + size.value.unit + " units"));
11733
+ }
11734
+
11735
+ if (parser.mode !== "math") {
11736
+ parser.settings.reportNonstrict("mathVsTextUnits", "LaTeX's " + funcName + " works only in math mode");
11737
+ }
11738
+ } else {
11739
+ // !mathFunction
11740
+ if (muUnit) {
11741
+ parser.settings.reportNonstrict("mathVsTextUnits", "LaTeX's " + funcName + " doesn't support mu units");
11742
+ }
11743
+ }
11744
+ }
11745
+
11746
+ return {
11747
+ type: "kern",
11748
+ mode: parser.mode,
11749
+ dimension: size.value
11750
+ };
11751
+ },
11752
+ htmlBuilder: function htmlBuilder(group, options) {
11753
+ return buildCommon.makeGlue(group.dimension, options);
11754
+ },
11755
+ mathmlBuilder: function mathmlBuilder(group, options) {
11756
+ var dimension = units_calculateSize(group.dimension, options);
11757
+ return new mathMLTree.SpaceNode(dimension);
11758
+ }
11759
+ });
11760
+ // CONCATENATED MODULE: ./src/functions/lap.js
11761
+ // Horizontal overlap functions
11220
11762
 
11221
11763
 
11222
11764
 
@@ -11297,8 +11839,7 @@ defineFunction({
11297
11839
  props: {
11298
11840
  numArgs: 0,
11299
11841
  allowedInText: true,
11300
- allowedInMath: false,
11301
- consumeMode: "math"
11842
+ allowedInMath: false
11302
11843
  },
11303
11844
  handler: function handler(_ref, args) {
11304
11845
  var funcName = _ref.funcName,
@@ -11306,12 +11847,9 @@ defineFunction({
11306
11847
  var outerMode = parser.mode;
11307
11848
  parser.switchMode("math");
11308
11849
  var close = funcName === "\\(" ? "\\)" : "$";
11309
- var body = parser.parseExpression(false, close); // We can't expand the next symbol after the closing $ until after
11310
- // switching modes back. So don't consume within expect.
11311
-
11312
- parser.expect(close, false);
11850
+ var body = parser.parseExpression(false, close);
11851
+ parser.expect(close);
11313
11852
  parser.switchMode(outerMode);
11314
- parser.consume();
11315
11853
  return {
11316
11854
  type: "styling",
11317
11855
  mode: parser.mode,
@@ -11387,6 +11925,123 @@ defineFunction({
11387
11925
  return buildExpressionRow(body, options);
11388
11926
  }
11389
11927
  });
11928
+ // CONCATENATED MODULE: ./src/functions/utils/assembleSupSub.js
11929
+
11930
+
11931
+ // For an operator with limits, assemble the base, sup, and sub into a span.
11932
+ var assembleSupSub_assembleSupSub = function assembleSupSub(base, supGroup, subGroup, options, style, slant, baseShift) {
11933
+ // IE 8 clips \int if it is in a display: inline-block. We wrap it
11934
+ // in a new span so it is an inline, and works.
11935
+ base = buildCommon.makeSpan([], [base]);
11936
+ var sub;
11937
+ var sup; // We manually have to handle the superscripts and subscripts. This,
11938
+ // aside from the kern calculations, is copied from supsub.
11939
+
11940
+ if (supGroup) {
11941
+ var elem = buildHTML_buildGroup(supGroup, options.havingStyle(style.sup()), options);
11942
+ sup = {
11943
+ elem: elem,
11944
+ kern: Math.max(options.fontMetrics().bigOpSpacing1, options.fontMetrics().bigOpSpacing3 - elem.depth)
11945
+ };
11946
+ }
11947
+
11948
+ if (subGroup) {
11949
+ var _elem = buildHTML_buildGroup(subGroup, options.havingStyle(style.sub()), options);
11950
+
11951
+ sub = {
11952
+ elem: _elem,
11953
+ kern: Math.max(options.fontMetrics().bigOpSpacing2, options.fontMetrics().bigOpSpacing4 - _elem.height)
11954
+ };
11955
+ } // Build the final group as a vlist of the possible subscript, base,
11956
+ // and possible superscript.
11957
+
11958
+
11959
+ var finalGroup;
11960
+
11961
+ if (sup && sub) {
11962
+ var bottom = options.fontMetrics().bigOpSpacing5 + sub.elem.height + sub.elem.depth + sub.kern + base.depth + baseShift;
11963
+ finalGroup = buildCommon.makeVList({
11964
+ positionType: "bottom",
11965
+ positionData: bottom,
11966
+ children: [{
11967
+ type: "kern",
11968
+ size: options.fontMetrics().bigOpSpacing5
11969
+ }, {
11970
+ type: "elem",
11971
+ elem: sub.elem,
11972
+ marginLeft: -slant + "em"
11973
+ }, {
11974
+ type: "kern",
11975
+ size: sub.kern
11976
+ }, {
11977
+ type: "elem",
11978
+ elem: base
11979
+ }, {
11980
+ type: "kern",
11981
+ size: sup.kern
11982
+ }, {
11983
+ type: "elem",
11984
+ elem: sup.elem,
11985
+ marginLeft: slant + "em"
11986
+ }, {
11987
+ type: "kern",
11988
+ size: options.fontMetrics().bigOpSpacing5
11989
+ }]
11990
+ }, options);
11991
+ } else if (sub) {
11992
+ var top = base.height - baseShift; // Shift the limits by the slant of the symbol. Note
11993
+ // that we are supposed to shift the limits by 1/2 of the slant,
11994
+ // but since we are centering the limits adding a full slant of
11995
+ // margin will shift by 1/2 that.
11996
+
11997
+ finalGroup = buildCommon.makeVList({
11998
+ positionType: "top",
11999
+ positionData: top,
12000
+ children: [{
12001
+ type: "kern",
12002
+ size: options.fontMetrics().bigOpSpacing5
12003
+ }, {
12004
+ type: "elem",
12005
+ elem: sub.elem,
12006
+ marginLeft: -slant + "em"
12007
+ }, {
12008
+ type: "kern",
12009
+ size: sub.kern
12010
+ }, {
12011
+ type: "elem",
12012
+ elem: base
12013
+ }]
12014
+ }, options);
12015
+ } else if (sup) {
12016
+ var _bottom = base.depth + baseShift;
12017
+
12018
+ finalGroup = buildCommon.makeVList({
12019
+ positionType: "bottom",
12020
+ positionData: _bottom,
12021
+ children: [{
12022
+ type: "elem",
12023
+ elem: base
12024
+ }, {
12025
+ type: "kern",
12026
+ size: sup.kern
12027
+ }, {
12028
+ type: "elem",
12029
+ elem: sup.elem,
12030
+ marginLeft: slant + "em"
12031
+ }, {
12032
+ type: "kern",
12033
+ size: options.fontMetrics().bigOpSpacing5
12034
+ }]
12035
+ }, options);
12036
+ } else {
12037
+ // This case probably shouldn't occur (this would mean the
12038
+ // supsub was sending us a group with no superscript or
12039
+ // subscript) but be safe.
12040
+ return base;
12041
+ }
12042
+
12043
+ return buildCommon.makeSpan(["mop", "op-limits"], [finalGroup], options);
12044
+ };
11390
12045
  // CONCATENATED MODULE: ./src/functions/op.js
11391
12046
  // Limits, symbols
11392
12047
 
@@ -11398,6 +12053,7 @@ defineFunction({
11398
12053
 
11399
12054
 
11400
12055
 
12056
+
11401
12057
  // Most operators have a large successor symbol, but these don't.
11402
12058
  var noSuccessor = ["\\smallint"]; // NOTE: Unlike most `htmlBuilder`s, this one handles not only "op", but also
11403
12059
  // "supsub" since some of them (like \int) can affect super/subscripting.
@@ -11488,7 +12144,7 @@ var op_htmlBuilder = function htmlBuilder(grp, options) {
11488
12144
  var output = [];
11489
12145
 
11490
12146
  for (var i = 1; i < group.name.length; i++) {
11491
- output.push(buildCommon.mathsym(group.name[i], group.mode));
12147
+ output.push(buildCommon.mathsym(group.name[i], group.mode, options));
11492
12148
  }
11493
12149
 
11494
12150
  base = buildCommon.makeSpan(["mop"], output, options);
@@ -11512,117 +12168,7 @@ var op_htmlBuilder = function htmlBuilder(grp, options) {
11512
12168
  }
11513
12169
 
11514
12170
  if (hasLimits) {
11515
- // IE 8 clips \int if it is in a display: inline-block. We wrap it
11516
- // in a new span so it is an inline, and works.
11517
- base = buildCommon.makeSpan([], [base]);
11518
- var sub;
11519
- var sup; // We manually have to handle the superscripts and subscripts. This,
11520
- // aside from the kern calculations, is copied from supsub.
11521
-
11522
- if (supGroup) {
11523
- var elem = buildHTML_buildGroup(supGroup, options.havingStyle(style.sup()), options);
11524
- sup = {
11525
- elem: elem,
11526
- kern: Math.max(options.fontMetrics().bigOpSpacing1, options.fontMetrics().bigOpSpacing3 - elem.depth)
11527
- };
11528
- }
11529
-
11530
- if (subGroup) {
11531
- var _elem = buildHTML_buildGroup(subGroup, options.havingStyle(style.sub()), options);
11532
-
11533
- sub = {
11534
- elem: _elem,
11535
- kern: Math.max(options.fontMetrics().bigOpSpacing2, options.fontMetrics().bigOpSpacing4 - _elem.height)
11536
- };
11537
- } // Build the final group as a vlist of the possible subscript, base,
11538
- // and possible superscript.
11539
-
11540
-
11541
- var finalGroup;
11542
-
11543
- if (sup && sub) {
11544
- var bottom = options.fontMetrics().bigOpSpacing5 + sub.elem.height + sub.elem.depth + sub.kern + base.depth + baseShift;
11545
- finalGroup = buildCommon.makeVList({
11546
- positionType: "bottom",
11547
- positionData: bottom,
11548
- children: [{
11549
- type: "kern",
11550
- size: options.fontMetrics().bigOpSpacing5
11551
- }, {
11552
- type: "elem",
11553
- elem: sub.elem,
11554
- marginLeft: -slant + "em"
11555
- }, {
11556
- type: "kern",
11557
- size: sub.kern
11558
- }, {
11559
- type: "elem",
11560
- elem: base
11561
- }, {
11562
- type: "kern",
11563
- size: sup.kern
11564
- }, {
11565
- type: "elem",
11566
- elem: sup.elem,
11567
- marginLeft: slant + "em"
11568
- }, {
11569
- type: "kern",
11570
- size: options.fontMetrics().bigOpSpacing5
11571
- }]
11572
- }, options);
11573
- } else if (sub) {
11574
- var top = base.height - baseShift; // Shift the limits by the slant of the symbol. Note
11575
- // that we are supposed to shift the limits by 1/2 of the slant,
11576
- // but since we are centering the limits adding a full slant of
11577
- // margin will shift by 1/2 that.
11578
-
11579
- finalGroup = buildCommon.makeVList({
11580
- positionType: "top",
11581
- positionData: top,
11582
- children: [{
11583
- type: "kern",
11584
- size: options.fontMetrics().bigOpSpacing5
11585
- }, {
11586
- type: "elem",
11587
- elem: sub.elem,
11588
- marginLeft: -slant + "em"
11589
- }, {
11590
- type: "kern",
11591
- size: sub.kern
11592
- }, {
11593
- type: "elem",
11594
- elem: base
11595
- }]
11596
- }, options);
11597
- } else if (sup) {
11598
- var _bottom = base.depth + baseShift;
11599
-
11600
- finalGroup = buildCommon.makeVList({
11601
- positionType: "bottom",
11602
- positionData: _bottom,
11603
- children: [{
11604
- type: "elem",
11605
- elem: base
11606
- }, {
11607
- type: "kern",
11608
- size: sup.kern
11609
- }, {
11610
- type: "elem",
11611
- elem: sup.elem,
11612
- marginLeft: slant + "em"
11613
- }, {
11614
- type: "kern",
11615
- size: options.fontMetrics().bigOpSpacing5
11616
- }]
11617
- }, options);
11618
- } else {
11619
- // This case probably shouldn't occur (this would mean the
11620
- // supsub was sending us a group with no superscript or
11621
- // subscript) but be safe.
11622
- return base;
11623
- }
11624
-
11625
- return buildCommon.makeSpan(["mop", "op-limits"], [finalGroup], options);
12171
+ return assembleSupSub_assembleSupSub(base, supGroup, subGroup, options, style, slant, baseShift);
11626
12172
  } else {
11627
12173
  if (baseShift) {
11628
12174
  base.style.position = "relative";
@@ -11649,8 +12195,6 @@ var op_mathmlBuilder = function mathmlBuilder(group, options) {
11649
12195
  } else {
11650
12196
  // This is a text operator. Add all of the characters from the
11651
12197
  // operator's name.
11652
- // TODO(emily): Add a space in the middle of some of these
11653
- // operators, like \limsup.
11654
12198
  node = new mathMLTree_MathNode("mi", [new mathMLTree_TextNode(group.name.slice(1))]); // Append an <mo>&ApplyFunction;</mo>.
11655
12199
  // ref: https://www.w3.org/TR/REC-MathML/chap3_2.html#sec3.2.4
11656
12200
 
@@ -11819,114 +12363,158 @@ defineFunction({
11819
12363
 
11820
12364
 
11821
12365
 
11822
- // \operatorname
11823
- // amsopn.dtx: \mathop{#1\kern\z@\operator@font#3}\newmcodes@
11824
12366
 
11825
- defineFunction({
11826
- type: "operatorname",
11827
- names: ["\\operatorname"],
11828
- props: {
11829
- numArgs: 1
11830
- },
11831
- handler: function handler(_ref, args) {
11832
- var parser = _ref.parser;
11833
- var body = args[0];
11834
- return {
11835
- type: "operatorname",
11836
- mode: parser.mode,
11837
- body: defineFunction_ordargument(body)
11838
- };
11839
- },
11840
- htmlBuilder: function htmlBuilder(group, options) {
11841
- if (group.body.length > 0) {
11842
- var body = group.body.map(function (child) {
11843
- // $FlowFixMe: Check if the node has a string `text` property.
11844
- var childText = child.text;
11845
12367
 
11846
- if (typeof childText === "string") {
11847
- return {
11848
- type: "textord",
11849
- mode: child.mode,
11850
- text: childText
11851
- };
11852
- } else {
11853
- return child;
11854
- }
11855
- }); // Consolidate function names into symbol characters.
11856
12368
 
11857
- var expression = buildHTML_buildExpression(body, options.withFont("mathrm"), true);
12369
+ // NOTE: Unlike most `htmlBuilder`s, this one handles not only
12370
+ // "operatorname", but also "supsub" since \operatorname* can
12371
+ var operatorname_htmlBuilder = function htmlBuilder(grp, options) {
12372
+ // Operators are handled in the TeXbook pg. 443-444, rule 13(a).
12373
+ var supGroup;
12374
+ var subGroup;
12375
+ var hasLimits = false;
12376
+ var group;
12377
+ var supSub = checkNodeType(grp, "supsub");
11858
12378
 
11859
- for (var i = 0; i < expression.length; i++) {
11860
- var child = expression[i];
12379
+ if (supSub) {
12380
+ // If we have limits, supsub will pass us its group to handle. Pull
12381
+ // out the superscript and subscript and set the group to the op in
12382
+ // its base.
12383
+ supGroup = supSub.sup;
12384
+ subGroup = supSub.sub;
12385
+ group = assertNodeType(supSub.base, "operatorname");
12386
+ hasLimits = true;
12387
+ } else {
12388
+ group = assertNodeType(grp, "operatorname");
12389
+ }
11861
12390
 
11862
- if (child instanceof domTree_SymbolNode) {
11863
- // Per amsopn package,
11864
- // change minus to hyphen and \ast to asterisk
11865
- child.text = child.text.replace(/\u2212/, "-").replace(/\u2217/, "*");
11866
- }
12391
+ var base;
12392
+
12393
+ if (group.body.length > 0) {
12394
+ var body = group.body.map(function (child) {
12395
+ // $FlowFixMe: Check if the node has a string `text` property.
12396
+ var childText = child.text;
12397
+
12398
+ if (typeof childText === "string") {
12399
+ return {
12400
+ type: "textord",
12401
+ mode: child.mode,
12402
+ text: childText
12403
+ };
12404
+ } else {
12405
+ return child;
11867
12406
  }
12407
+ }); // Consolidate function names into symbol characters.
11868
12408
 
11869
- return buildCommon.makeSpan(["mop"], expression, options);
11870
- } else {
11871
- return buildCommon.makeSpan(["mop"], [], options);
12409
+ var expression = buildHTML_buildExpression(body, options.withFont("mathrm"), true);
12410
+
12411
+ for (var i = 0; i < expression.length; i++) {
12412
+ var child = expression[i];
12413
+
12414
+ if (child instanceof domTree_SymbolNode) {
12415
+ // Per amsopn package,
12416
+ // change minus to hyphen and \ast to asterisk
12417
+ child.text = child.text.replace(/\u2212/, "-").replace(/\u2217/, "*");
12418
+ }
11872
12419
  }
11873
- },
11874
- mathmlBuilder: function mathmlBuilder(group, options) {
11875
- // The steps taken here are similar to the html version.
11876
- var expression = buildMathML_buildExpression(group.body, options.withFont("mathrm")); // Is expression a string or has it something like a fraction?
11877
12420
 
11878
- var isAllString = true; // default
12421
+ base = buildCommon.makeSpan(["mop"], expression, options);
12422
+ } else {
12423
+ base = buildCommon.makeSpan(["mop"], [], options);
12424
+ }
11879
12425
 
11880
- for (var i = 0; i < expression.length; i++) {
11881
- var node = expression[i];
11882
-
11883
- if (node instanceof mathMLTree.SpaceNode) {// Do nothing
11884
- } else if (node instanceof mathMLTree.MathNode) {
11885
- switch (node.type) {
11886
- case "mi":
11887
- case "mn":
11888
- case "ms":
11889
- case "mspace":
11890
- case "mtext":
11891
- break;
11892
- // Do nothing yet.
12426
+ if (hasLimits) {
12427
+ return assembleSupSub_assembleSupSub(base, supGroup, subGroup, options, options.style, 0, 0);
12428
+ } else {
12429
+ return base;
12430
+ }
12431
+ };
11893
12432
 
11894
- case "mo":
11895
- {
11896
- var child = node.children[0];
12433
+ var operatorname_mathmlBuilder = function mathmlBuilder(group, options) {
12434
+ // The steps taken here are similar to the html version.
12435
+ var expression = buildMathML_buildExpression(group.body, options.withFont("mathrm")); // Is expression a string or has it something like a fraction?
11897
12436
 
11898
- if (node.children.length === 1 && child instanceof mathMLTree.TextNode) {
11899
- child.text = child.text.replace(/\u2212/, "-").replace(/\u2217/, "*");
11900
- } else {
11901
- isAllString = false;
11902
- }
12437
+ var isAllString = true; // default
11903
12438
 
11904
- break;
12439
+ for (var i = 0; i < expression.length; i++) {
12440
+ var node = expression[i];
12441
+
12442
+ if (node instanceof mathMLTree.SpaceNode) {// Do nothing
12443
+ } else if (node instanceof mathMLTree.MathNode) {
12444
+ switch (node.type) {
12445
+ case "mi":
12446
+ case "mn":
12447
+ case "ms":
12448
+ case "mspace":
12449
+ case "mtext":
12450
+ break;
12451
+ // Do nothing yet.
12452
+
12453
+ case "mo":
12454
+ {
12455
+ var child = node.children[0];
12456
+
12457
+ if (node.children.length === 1 && child instanceof mathMLTree.TextNode) {
12458
+ child.text = child.text.replace(/\u2212/, "-").replace(/\u2217/, "*");
12459
+ } else {
12460
+ isAllString = false;
11905
12461
  }
11906
12462
 
11907
- default:
11908
- isAllString = false;
11909
- }
11910
- } else {
11911
- isAllString = false;
12463
+ break;
12464
+ }
12465
+
12466
+ default:
12467
+ isAllString = false;
11912
12468
  }
12469
+ } else {
12470
+ isAllString = false;
11913
12471
  }
12472
+ }
11914
12473
 
11915
- if (isAllString) {
11916
- // Write a single TextNode instead of multiple nested tags.
11917
- var word = expression.map(function (node) {
11918
- return node.toText();
11919
- }).join("");
11920
- expression = [new mathMLTree.TextNode(word)];
11921
- }
12474
+ if (isAllString) {
12475
+ // Write a single TextNode instead of multiple nested tags.
12476
+ var word = expression.map(function (node) {
12477
+ return node.toText();
12478
+ }).join("");
12479
+ expression = [new mathMLTree.TextNode(word)];
12480
+ }
12481
+
12482
+ var identifier = new mathMLTree.MathNode("mi", expression);
12483
+ identifier.setAttribute("mathvariant", "normal"); // \u2061 is the same as &ApplyFunction;
12484
+ // ref: https://www.w3schools.com/charsets/ref_html_entities_a.asp
11922
12485
 
11923
- var identifier = new mathMLTree.MathNode("mi", expression);
11924
- identifier.setAttribute("mathvariant", "normal"); // \u2061 is the same as &ApplyFunction;
11925
- // ref: https://www.w3schools.com/charsets/ref_html_entities_a.asp
12486
+ var operator = new mathMLTree.MathNode("mo", [buildMathML_makeText("\u2061", "text")]);
11926
12487
 
11927
- var operator = new mathMLTree.MathNode("mo", [buildMathML_makeText("\u2061", "text")]);
12488
+ if (group.parentIsSupSub) {
12489
+ return new mathMLTree.MathNode("mo", [identifier, operator]);
12490
+ } else {
11928
12491
  return mathMLTree.newDocumentFragment([identifier, operator]);
11929
12492
  }
12493
+ }; // \operatorname
12494
+ // amsopn.dtx: \mathop{#1\kern\z@\operator@font#3}\newmcodes@
12495
+
12496
+
12497
+ defineFunction({
12498
+ type: "operatorname",
12499
+ names: ["\\operatorname", "\\operatorname*"],
12500
+ props: {
12501
+ numArgs: 1
12502
+ },
12503
+ handler: function handler(_ref, args) {
12504
+ var parser = _ref.parser,
12505
+ funcName = _ref.funcName;
12506
+ var body = args[0];
12507
+ return {
12508
+ type: "operatorname",
12509
+ mode: parser.mode,
12510
+ body: defineFunction_ordargument(body),
12511
+ alwaysHandleSupSub: funcName === "\\operatorname*",
12512
+ limits: false,
12513
+ parentIsSupSub: false
12514
+ };
12515
+ },
12516
+ htmlBuilder: operatorname_htmlBuilder,
12517
+ mathmlBuilder: operatorname_mathmlBuilder
11930
12518
  });
11931
12519
  // CONCATENATED MODULE: ./src/functions/ordgroup.js
11932
12520
 
@@ -11943,7 +12531,7 @@ defineFunctionBuilders({
11943
12531
  return buildCommon.makeSpan(["mord"], buildHTML_buildExpression(group.body, options, true), options);
11944
12532
  },
11945
12533
  mathmlBuilder: function mathmlBuilder(group, options) {
11946
- return buildExpressionRow(group.body, options);
12534
+ return buildExpressionRow(group.body, options, true);
11947
12535
  }
11948
12536
  });
11949
12537
  // CONCATENATED MODULE: ./src/functions/overline.js
@@ -11974,6 +12562,7 @@ defineFunction({
11974
12562
 
11975
12563
  var line = buildCommon.makeLineSpan("overline-line", options); // Generate the vlist, with the appropriate kerns
11976
12564
 
12565
+ var defaultRuleThickness = options.fontMetrics().defaultRuleThickness;
11977
12566
  var vlist = buildCommon.makeVList({
11978
12567
  positionType: "firstBaseline",
11979
12568
  children: [{
@@ -11981,13 +12570,13 @@ defineFunction({
11981
12570
  elem: innerGroup
11982
12571
  }, {
11983
12572
  type: "kern",
11984
- size: 3 * line.height
12573
+ size: 3 * defaultRuleThickness
11985
12574
  }, {
11986
12575
  type: "elem",
11987
12576
  elem: line
11988
12577
  }, {
11989
12578
  type: "kern",
11990
- size: line.height
12579
+ size: defaultRuleThickness
11991
12580
  }]
11992
12581
  }, options);
11993
12582
  return buildCommon.makeSpan(["mord", "overline"], [vlist], options);
@@ -12110,77 +12699,6 @@ defineFunction({
12110
12699
  return node;
12111
12700
  }
12112
12701
  });
12113
- // CONCATENATED MODULE: ./src/functions/sizing.js
12114
-
12115
-
12116
-
12117
-
12118
-
12119
- function sizingGroup(value, options, baseOptions) {
12120
- var inner = buildHTML_buildExpression(value, options, false);
12121
- var multiplier = options.sizeMultiplier / baseOptions.sizeMultiplier; // Add size-resetting classes to the inner list and set maxFontSize
12122
- // manually. Handle nested size changes.
12123
-
12124
- for (var i = 0; i < inner.length; i++) {
12125
- var pos = inner[i].classes.indexOf("sizing");
12126
-
12127
- if (pos < 0) {
12128
- Array.prototype.push.apply(inner[i].classes, options.sizingClasses(baseOptions));
12129
- } else if (inner[i].classes[pos + 1] === "reset-size" + options.size) {
12130
- // This is a nested size change: e.g., inner[i] is the "b" in
12131
- // `\Huge a \small b`. Override the old size (the `reset-` class)
12132
- // but not the new size.
12133
- inner[i].classes[pos + 1] = "reset-size" + baseOptions.size;
12134
- }
12135
-
12136
- inner[i].height *= multiplier;
12137
- inner[i].depth *= multiplier;
12138
- }
12139
-
12140
- return buildCommon.makeFragment(inner);
12141
- }
12142
- var sizeFuncs = ["\\tiny", "\\sixptsize", "\\scriptsize", "\\footnotesize", "\\small", "\\normalsize", "\\large", "\\Large", "\\LARGE", "\\huge", "\\Huge"];
12143
- var sizing_htmlBuilder = function htmlBuilder(group, options) {
12144
- // Handle sizing operators like \Huge. Real TeX doesn't actually allow
12145
- // these functions inside of math expressions, so we do some special
12146
- // handling.
12147
- var newOptions = options.havingSize(group.size);
12148
- return sizingGroup(group.body, newOptions, options);
12149
- };
12150
- defineFunction({
12151
- type: "sizing",
12152
- names: sizeFuncs,
12153
- props: {
12154
- numArgs: 0,
12155
- allowedInText: true
12156
- },
12157
- handler: function handler(_ref, args) {
12158
- var breakOnTokenText = _ref.breakOnTokenText,
12159
- funcName = _ref.funcName,
12160
- parser = _ref.parser;
12161
- var body = parser.parseExpression(false, breakOnTokenText);
12162
- return {
12163
- type: "sizing",
12164
- mode: parser.mode,
12165
- // Figure out what size to use based on the list of functions above
12166
- size: sizeFuncs.indexOf(funcName) + 1,
12167
- body: body
12168
- };
12169
- },
12170
- htmlBuilder: sizing_htmlBuilder,
12171
- mathmlBuilder: function mathmlBuilder(group, options) {
12172
- var newOptions = options.havingSize(group.size);
12173
- var inner = buildMathML_buildExpression(group.body, newOptions);
12174
- var node = new mathMLTree.MathNode("mstyle", inner); // TODO(emily): This doesn't produce the correct size for nested size
12175
- // changes, because we don't keep state of what style we're currently
12176
- // in, so we can't reset the size to normal before changing it. Now
12177
- // that we're passing an options parameter we should be able to fix
12178
- // this.
12179
-
12180
- node.setAttribute("mathsize", newOptions.sizeMultiplier + "em");
12181
- return node;
12182
- }
12183
- });
12184
12702
  // CONCATENATED MODULE: ./src/functions/raisebox.js
12185
12703
 
12186
12704
 
@@ -12195,7 +12713,7 @@ defineFunction({
12195
12713
  names: ["\\raisebox"],
12196
12714
  props: {
12197
12715
  numArgs: 2,
12198
- argTypes: ["size", "text"],
12716
+ argTypes: ["size", "hbox"],
12199
12717
  allowedInText: true
12200
12718
  },
12201
12719
  handler: function handler(_ref, args) {
@@ -12210,21 +12728,7 @@ defineFunction({
12210
12728
  };
12211
12729
  },
12212
12730
  htmlBuilder: function htmlBuilder(group, options) {
12213
- var text = {
12214
- type: "text",
12215
- mode: group.mode,
12216
- body: defineFunction_ordargument(group.body),
12217
- font: "mathrm" // simulate \textrm
12218
-
12219
- };
12220
- var sizedText = {
12221
- type: "sizing",
12222
- mode: group.mode,
12223
- body: [text],
12224
- size: 6 // simulate \normalsize
12225
-
12226
- };
12227
- var body = sizing_htmlBuilder(sizedText, options);
12731
+ var body = buildHTML_buildGroup(group.body, options);
12228
12732
  var dy = units_calculateSize(group.dy, options);
12229
12733
  return buildCommon.makeVList({
12230
12734
  positionType: "shift",
@@ -12312,6 +12816,77 @@ defineFunction({
12312
12816
  return wrapper;
12313
12817
  }
12314
12818
  });
12819
+ // CONCATENATED MODULE: ./src/functions/sizing.js
12820
+
12821
+
12822
+
12823
+
12824
+
12825
+ function sizingGroup(value, options, baseOptions) {
12826
+ var inner = buildHTML_buildExpression(value, options, false);
12827
+ var multiplier = options.sizeMultiplier / baseOptions.sizeMultiplier; // Add size-resetting classes to the inner list and set maxFontSize
12828
+ // manually. Handle nested size changes.
12829
+
12830
+ for (var i = 0; i < inner.length; i++) {
12831
+ var pos = inner[i].classes.indexOf("sizing");
12832
+
12833
+ if (pos < 0) {
12834
+ Array.prototype.push.apply(inner[i].classes, options.sizingClasses(baseOptions));
12835
+ } else if (inner[i].classes[pos + 1] === "reset-size" + options.size) {
12836
+ // This is a nested size change: e.g., inner[i] is the "b" in
12837
+ // `\Huge a \small b`. Override the old size (the `reset-` class)
12838
+ // but not the new size.
12839
+ inner[i].classes[pos + 1] = "reset-size" + baseOptions.size;
12840
+ }
12841
+
12842
+ inner[i].height *= multiplier;
12843
+ inner[i].depth *= multiplier;
12844
+ }
12845
+
12846
+ return buildCommon.makeFragment(inner);
12847
+ }
12848
+ var sizeFuncs = ["\\tiny", "\\sixptsize", "\\scriptsize", "\\footnotesize", "\\small", "\\normalsize", "\\large", "\\Large", "\\LARGE", "\\huge", "\\Huge"];
12849
+ var sizing_htmlBuilder = function htmlBuilder(group, options) {
12850
+ // Handle sizing operators like \Huge. Real TeX doesn't actually allow
12851
+ // these functions inside of math expressions, so we do some special
12852
+ // handling.
12853
+ var newOptions = options.havingSize(group.size);
12854
+ return sizingGroup(group.body, newOptions, options);
12855
+ };
12856
+ defineFunction({
12857
+ type: "sizing",
12858
+ names: sizeFuncs,
12859
+ props: {
12860
+ numArgs: 0,
12861
+ allowedInText: true
12862
+ },
12863
+ handler: function handler(_ref, args) {
12864
+ var breakOnTokenText = _ref.breakOnTokenText,
12865
+ funcName = _ref.funcName,
12866
+ parser = _ref.parser;
12867
+ var body = parser.parseExpression(false, breakOnTokenText);
12868
+ return {
12869
+ type: "sizing",
12870
+ mode: parser.mode,
12871
+ // Figure out what size to use based on the list of functions above
12872
+ size: sizeFuncs.indexOf(funcName) + 1,
12873
+ body: body
12874
+ };
12875
+ },
12876
+ htmlBuilder: sizing_htmlBuilder,
12877
+ mathmlBuilder: function mathmlBuilder(group, options) {
12878
+ var newOptions = options.havingSize(group.size);
12879
+ var inner = buildMathML_buildExpression(group.body, newOptions);
12880
+ var node = new mathMLTree.MathNode("mstyle", inner); // TODO(emily): This doesn't produce the correct size for nested size
12881
+ // changes, because we don't keep state of what style we're currently
12882
+ // in, so we can't reset the size to normal before changing it. Now
12883
+ // that we're passing an options parameter we should be able to fix
12884
+ // this.
12885
+
12886
+ node.setAttribute("mathsize", newOptions.sizeMultiplier + "em");
12887
+ return node;
12888
+ }
12889
+ });
12315
12890
  // CONCATENATED MODULE: ./src/functions/smash.js
12316
12891
  // smash, with optional [tb], as in AMS
12317
12892
 
@@ -12587,15 +13162,7 @@ defineFunction({
12587
13162
  },
12588
13163
  mathmlBuilder: function mathmlBuilder(group, options) {
12589
13164
  // Figure out what style we're changing to.
12590
- // TODO(kevinb): dedupe this with buildHTML.js
12591
- // This will be easier of handling of styling nodes is in the same file.
12592
- var styleMap = {
12593
- "display": src_Style.DISPLAY,
12594
- "text": src_Style.TEXT,
12595
- "script": src_Style.SCRIPT,
12596
- "scriptscript": src_Style.SCRIPTSCRIPT
12597
- };
12598
- var newStyle = styleMap[group.style];
13165
+ var newStyle = styling_styleMap[group.style];
12599
13166
  var newOptions = options.havingStyle(newStyle);
12600
13167
  var inner = buildMathML_buildExpression(group.body, newOptions);
12601
13168
  var node = new mathMLTree.MathNode("mstyle", inner);
@@ -12625,6 +13192,7 @@ defineFunction({
12625
13192
 
12626
13193
 
12627
13194
 
13195
+
12628
13196
  /**
12629
13197
  * Sometimes, groups perform special rules when they have superscripts or
12630
13198
  * subscripts attached to them. This function lets the `supsub` group know that
@@ -12642,6 +13210,10 @@ var supsub_htmlBuilderDelegate = function htmlBuilderDelegate(group, options) {
12642
13210
  // (e.g. `\displaystyle\sum_2^3`)
12643
13211
  var delegate = base.limits && (options.style.size === src_Style.DISPLAY.size || base.alwaysHandleSupSub);
12644
13212
  return delegate ? op_htmlBuilder : null;
13213
+ } else if (base.type === "operatorname") {
13214
+ var _delegate = base.alwaysHandleSupSub && (options.style.size === src_Style.DISPLAY.size || base.limits);
13215
+
13216
+ return _delegate ? operatorname_htmlBuilder : null;
12645
13217
  } else if (base.type === "accent") {
12646
13218
  return utils.isCharacterBox(base.base) ? accent_htmlBuilder : null;
12647
13219
  } else if (base.type === "horizBrace") {
@@ -12812,7 +13384,7 @@ defineFunctionBuilders({
12812
13384
  }
12813
13385
  }
12814
13386
 
12815
- if (group.base && group.base.type === "op") {
13387
+ if (group.base && (group.base.type === "op" || group.base.type === "operatorname")) {
12816
13388
  group.base.parentIsSupSub = true;
12817
13389
  }
12818
13390
 
@@ -12835,6 +13407,8 @@ defineFunctionBuilders({
12835
13407
 
12836
13408
  if (base && base.type === "op" && base.limits && (options.style === src_Style.DISPLAY || base.alwaysHandleSupSub)) {
12837
13409
  nodeType = "mover";
13410
+ } else if (base && base.type === "operatorname" && base.alwaysHandleSupSub && (base.limits || options.style === src_Style.DISPLAY)) {
13411
+ nodeType = "mover";
12838
13412
  } else {
12839
13413
  nodeType = "msup";
12840
13414
  }
@@ -12843,6 +13417,8 @@ defineFunctionBuilders({
12843
13417
 
12844
13418
  if (_base && _base.type === "op" && _base.limits && (options.style === src_Style.DISPLAY || _base.alwaysHandleSupSub)) {
12845
13419
  nodeType = "munder";
13420
+ } else if (_base && _base.type === "operatorname" && _base.alwaysHandleSupSub && (_base.limits || options.style === src_Style.DISPLAY)) {
13421
+ nodeType = "munder";
12846
13422
  } else {
12847
13423
  nodeType = "msub";
12848
13424
  }
@@ -12851,6 +13427,8 @@ defineFunctionBuilders({
12851
13427
 
12852
13428
  if (_base2 && _base2.type === "op" && _base2.limits && options.style === src_Style.DISPLAY) {
12853
13429
  nodeType = "munderover";
13430
+ } else if (_base2 && _base2.type === "operatorname" && _base2.alwaysHandleSupSub && (options.style === src_Style.DISPLAY || _base2.limits)) {
13431
+ nodeType = "munderover";
12854
13432
  } else {
12855
13433
  nodeType = "msubsup";
12856
13434
  }
@@ -13083,8 +13661,7 @@ defineFunction({
13083
13661
  numArgs: 1,
13084
13662
  argTypes: ["text"],
13085
13663
  greediness: 2,
13086
- allowedInText: true,
13087
- consumeMode: "text"
13664
+ allowedInText: true
13088
13665
  },
13089
13666
  handler: function handler(_ref, args) {
13090
13667
  var parser = _ref.parser,
@@ -13135,18 +13712,19 @@ defineFunction({
13135
13712
 
13136
13713
  var line = buildCommon.makeLineSpan("underline-line", options); // Generate the vlist, with the appropriate kerns
13137
13714
 
13715
+ var defaultRuleThickness = options.fontMetrics().defaultRuleThickness;
13138
13716
  var vlist = buildCommon.makeVList({
13139
13717
  positionType: "top",
13140
13718
  positionData: innerGroup.height,
13141
13719
  children: [{
13142
13720
  type: "kern",
13143
- size: line.height
13721
+ size: defaultRuleThickness
13144
13722
  }, {
13145
13723
  type: "elem",
13146
13724
  elem: line
13147
13725
  }, {
13148
13726
  type: "kern",
13149
- size: 3 * line.height
13727
+ size: 3 * defaultRuleThickness
13150
13728
  }, {
13151
13729
  type: "elem",
13152
13730
  elem: innerGroup
@@ -13236,8 +13814,7 @@ var functions = _functions;
13236
13814
 
13237
13815
 
13238
13816
 
13239
- // Disabled until https://github.com/KaTeX/KaTeX/pull/1794 is merged.
13240
- // import "./functions/includegraphics";
13817
+
13241
13818
 
13242
13819
 
13243
13820
 
@@ -13308,7 +13885,8 @@ combiningDiacriticalMarkString + "*") + // ...plus accents
13308
13885
  "|[\uD800-\uDBFF][\uDC00-\uDFFF]" + ( // surrogate pair
13309
13886
  combiningDiacriticalMarkString + "*") + // ...plus accents
13310
13887
  "|\\\\verb\\*([^]).*?\\3" + // \verb*
13311
- "|\\\\verb([^*a-zA-Z]).*?\\4" + ( // \verb unstarred
13888
+ "|\\\\verb([^*a-zA-Z]).*?\\4" + // \verb unstarred
13889
+ "|\\\\operatorname\\*" + ( // \operatorname*
13312
13890
  "|" + controlWordWhitespaceRegexString) + ( // \macroName + spaces
13313
13891
  "|" + controlSymbolRegexString + ")"); // \\, \', etc.
13314
13892
 
@@ -13911,7 +14489,9 @@ defineMacro("\\varSigma", "\\mathit{\\Sigma}");
13911
14489
  defineMacro("\\varUpsilon", "\\mathit{\\Upsilon}");
13912
14490
  defineMacro("\\varPhi", "\\mathit{\\Phi}");
13913
14491
  defineMacro("\\varPsi", "\\mathit{\\Psi}");
13914
- defineMacro("\\varOmega", "\\mathit{\\Omega}"); // \renewcommand{\colon}{\nobreak\mskip2mu\mathpunct{}\nonscript
14492
+ defineMacro("\\varOmega", "\\mathit{\\Omega}"); //\newcommand{\substack}[1]{\subarray{c}#1\endsubarray}
14493
+
14494
+ defineMacro("\\substack", "\\begin{subarray}{c}#1\\end{subarray}"); // \renewcommand{\colon}{\nobreak\mskip2mu\mathpunct{}\nonscript
13915
14495
  // \mkern-\thinmuskip{:}\mskip6muplus1mu\relax}
13916
14496
 
13917
14497
  defineMacro("\\colon", "\\nobreak\\mskip2mu\\mathpunct{}" + "\\mathchoice{\\mkern-3mu}{\\mkern-3mu}{}{}{:}\\mskip6mu"); // \newcommand{\boxed}[1]{\fbox{\m@th$\displaystyle#1$}}
@@ -14128,10 +14708,11 @@ defineMacro("\\bmod", "\\mathchoice{\\mskip1mu}{\\mskip1mu}{\\mskip5mu}{\\mskip5
14128
14708
  defineMacro("\\pod", "\\allowbreak" + "\\mathchoice{\\mkern18mu}{\\mkern8mu}{\\mkern8mu}{\\mkern8mu}(#1)");
14129
14709
  defineMacro("\\pmod", "\\pod{{\\rm mod}\\mkern6mu#1}");
14130
14710
  defineMacro("\\mod", "\\allowbreak" + "\\mathchoice{\\mkern18mu}{\\mkern12mu}{\\mkern12mu}{\\mkern12mu}" + "{\\rm mod}\\,\\,#1"); // \pmb -- A simulation of bold.
14131
- // It works by typesetting three copies of the argument with small offsets.
14132
- // Ref: a rather lengthy macro in ambsy.sty
14711
+ // The version in ambsy.sty works by typesetting three copies of the argument
14712
+ // with small offsets. We use two copies. We omit the vertical offset because
14713
+ // of rendering problems that makeVList encounters in Safari.
14133
14714
 
14134
- defineMacro("\\pmb", "\\html@mathml{\\@binrel{#1}{" + "\\mathrlap{#1}" + "\\mathrlap{\\mkern0.4mu\\raisebox{0.4mu}{$#1$}}" + "{\\mkern0.8mu#1}" + "}}{\\mathbf{#1}}"); //////////////////////////////////////////////////////////////////////
14715
+ defineMacro("\\pmb", "\\html@mathml{" + "\\@binrel{#1}{\\mathrlap{#1}\\kern0.5px#1}}" + "{\\mathbf{#1}}"); //////////////////////////////////////////////////////////////////////
14135
14716
  // LaTeX source2e
14136
14717
  // \\ defaults to \newline, but changes to \cr within array environment
14137
14718
 
@@ -14152,13 +14733,13 @@ defineMacro("\\TeX", "\\textrm{\\html@mathml{" + "T\\kern-.1667em\\raisebox{-.5e
14152
14733
  // \TeX}
14153
14734
  // This code aligns the top of the A with the T (from the perspective of TeX's
14154
14735
  // boxes, though visually the A appears to extend above slightly).
14155
- // We compute the corresponding \raisebox when A is rendered at \scriptsize,
14156
- // which is size3, which has a scale factor of 0.7 (see Options.js).
14736
+ // We compute the corresponding \raisebox when A is rendered in \normalsize
14737
+ // \scriptstyle, which has a scale factor of 0.7 (see Options.js).
14157
14738
 
14158
14739
  var latexRaiseA = fontMetricsData['Main-Regular']["T".charCodeAt(0)][1] - 0.7 * fontMetricsData['Main-Regular']["A".charCodeAt(0)][1] + "em";
14159
- defineMacro("\\LaTeX", "\\textrm{\\html@mathml{" + ("L\\kern-.36em\\raisebox{" + latexRaiseA + "}{\\scriptsize A}") + "\\kern-.15em\\TeX}{LaTeX}}"); // New KaTeX logo based on tweaking LaTeX logo
14740
+ defineMacro("\\LaTeX", "\\textrm{\\html@mathml{" + ("L\\kern-.36em\\raisebox{" + latexRaiseA + "}{\\scriptstyle A}") + "\\kern-.15em\\TeX}{LaTeX}}"); // New KaTeX logo based on tweaking LaTeX logo
14160
14741
 
14161
- defineMacro("\\KaTeX", "\\textrm{\\html@mathml{" + ("K\\kern-.17em\\raisebox{" + latexRaiseA + "}{\\scriptsize A}") + "\\kern-.15em\\TeX}{KaTeX}}"); // \DeclareRobustCommand\hspace{\@ifstar\@hspacer\@hspace}
14742
+ defineMacro("\\KaTeX", "\\textrm{\\html@mathml{" + ("K\\kern-.17em\\raisebox{" + latexRaiseA + "}{\\scriptstyle A}") + "\\kern-.15em\\TeX}{KaTeX}}"); // \DeclareRobustCommand\hspace{\@ifstar\@hspacer\@hspace}
14162
14743
  // \def\@hspace#1{\hskip #1\relax}
14163
14744
  // \def\@hspacer#1{\vrule \@width\z@\nobreak
14164
14745
  // \hskip #1\hskip \z@skip}
@@ -14236,8 +14817,8 @@ defineMacro("\\approxcolon", "\\mathrel{\\approx\\mathrel{\\mkern-1.2mu}\\vcentc
14236
14817
  defineMacro("\\approxcoloncolon", "\\mathrel{\\approx\\mathrel{\\mkern-1.2mu}\\dblcolon}"); // Present in newtxmath, pxfonts and txfonts
14237
14818
 
14238
14819
  defineMacro("\\notni", "\\html@mathml{\\not\\ni}{\\mathrel{\\char`\u220C}}");
14239
- defineMacro("\\limsup", "\\DOTSB\\mathop{\\operatorname{lim\\,sup}}\\limits");
14240
- defineMacro("\\liminf", "\\DOTSB\\mathop{\\operatorname{lim\\,inf}}\\limits"); //////////////////////////////////////////////////////////////////////
14820
+ defineMacro("\\limsup", "\\DOTSB\\operatorname*{lim\\,sup}");
14821
+ defineMacro("\\liminf", "\\DOTSB\\operatorname*{lim\\,inf}"); //////////////////////////////////////////////////////////////////////
14241
14822
  // MathML alternates for KaTeX glyphs in the Unicode private area
14242
14823
 
14243
14824
  defineMacro("\\gvertneqq", "\\html@mathml{\\@gvertneqq}{\u2269}");
@@ -14345,15 +14926,16 @@ defineMacro("\\Zeta", "\\mathrm{Z}"); //////////////////////////////////////////
14345
14926
  // statmath.sty
14346
14927
  // https://ctan.math.illinois.edu/macros/latex/contrib/statmath/statmath.pdf
14347
14928
 
14348
- defineMacro("\\argmin", "\\DOTSB\\mathop{\\operatorname{arg\\,min}}\\limits");
14349
- defineMacro("\\argmax", "\\DOTSB\\mathop{\\operatorname{arg\\,max}}\\limits"); // Custom Khan Academy colors, should be moved to an optional package
14929
+ defineMacro("\\argmin", "\\DOTSB\\operatorname*{arg\\,min}");
14930
+ defineMacro("\\argmax", "\\DOTSB\\operatorname*{arg\\,max}");
14931
+ defineMacro("\\plim", "\\DOTSB\\mathop{\\operatorname{plim}}\\limits"); // Custom Khan Academy colors, should be moved to an optional package
14350
14932
 
14351
14933
  defineMacro("\\blue", "\\textcolor{##6495ed}{#1}");
14352
14934
  defineMacro("\\orange", "\\textcolor{##ffa500}{#1}");
14353
14935
  defineMacro("\\pink", "\\textcolor{##ff00af}{#1}");
14354
14936
  defineMacro("\\red", "\\textcolor{##df0030}{#1}");
14355
14937
  defineMacro("\\green", "\\textcolor{##28ae7b}{#1}");
14356
- defineMacro("\\gray", "\\textcolor{gray}{##1}");
14938
+ defineMacro("\\gray", "\\textcolor{gray}{#1}");
14357
14939
  defineMacro("\\purple", "\\textcolor{##9d38bd}{#1}");
14358
14940
  defineMacro("\\blueA", "\\textcolor{##ccfaff}{#1}");
14359
14941
  defineMacro("\\blueB", "\\textcolor{##80f6ff}{#1}");
@@ -15509,7 +16091,6 @@ function () {
15509
16091
 
15510
16092
 
15511
16093
 
15512
-
15513
16094
  /**
15514
16095
  * This file contains the parser used to parse out a TeX expression from the
15515
16096
  * input. Since TeX isn't context-free, standard parsers don't work particularly
@@ -15571,8 +16152,8 @@ function () {
15571
16152
  consume = true;
15572
16153
  }
15573
16154
 
15574
- if (this.nextToken.text !== text) {
15575
- throw new src_ParseError("Expected '" + text + "', got '" + this.nextToken.text + "'", this.nextToken);
16155
+ if (this.fetch().text !== text) {
16156
+ throw new src_ParseError("Expected '" + text + "', got '" + this.fetch().text + "'", this.fetch());
15576
16157
  }
15577
16158
 
15578
16159
  if (consume) {
@@ -15580,13 +16161,26 @@ function () {
15580
16161
  }
15581
16162
  }
15582
16163
  /**
15583
- * Considers the current look ahead token as consumed,
15584
- * and fetches the one after that as the new look ahead.
16164
+ * Discards the current lookahead token, considering it consumed.
15585
16165
  */
15586
16166
  ;
15587
16167
 
15588
16168
  _proto.consume = function consume() {
15589
- this.nextToken = this.gullet.expandNextToken();
16169
+ this.nextToken = null;
16170
+ }
16171
+ /**
16172
+ * Return the current lookahead token, or if there isn't one (at the
16173
+ * beginning, or if the previous lookahead token was consume()d),
16174
+ * fetch the next token as the new lookahead token and return it.
16175
+ */
16176
+ ;
16177
+
16178
+ _proto.fetch = function fetch() {
16179
+ if (this.nextToken == null) {
16180
+ this.nextToken = this.gullet.expandNextToken();
16181
+ }
16182
+
16183
+ return this.nextToken;
15590
16184
  }
15591
16185
  /**
15592
16186
  * Switches between "text" and "math" modes.
@@ -15614,10 +16208,9 @@ function () {
15614
16208
  } // Try to parse the input
15615
16209
 
15616
16210
 
15617
- this.consume();
15618
16211
  var parse = this.parseExpression(false); // If we succeeded, make sure there's an EOF at the end
15619
16212
 
15620
- this.expect("EOF", false); // End the group namespace for the expression
16213
+ this.expect("EOF"); // End the group namespace for the expression
15621
16214
 
15622
16215
  this.gullet.endGroup();
15623
16216
  return parse;
@@ -15633,7 +16226,7 @@ function () {
15633
16226
  this.consumeSpaces();
15634
16227
  }
15635
16228
 
15636
- var lex = this.nextToken;
16229
+ var lex = this.fetch();
15637
16230
 
15638
16231
  if (Parser.endOfExpression.indexOf(lex.text) !== -1) {
15639
16232
  break;
@@ -15733,12 +16326,10 @@ function () {
15733
16326
  * Handle a subscript or superscript with nice errors.
15734
16327
  */
15735
16328
  _proto.handleSupSubscript = function handleSupSubscript(name) {
15736
- var symbolToken = this.nextToken;
16329
+ var symbolToken = this.fetch();
15737
16330
  var symbol = symbolToken.text;
15738
16331
  this.consume();
15739
- this.consumeSpaces(); // ignore spaces before sup/subscript argument
15740
-
15741
- var group = this.parseGroup(name, false, Parser.SUPSUB_GREEDINESS);
16332
+ var group = this.parseGroup(name, false, Parser.SUPSUB_GREEDINESS, undefined, undefined, true); // ignore spaces before sup/subscript argument
15742
16333
 
15743
16334
  if (!group) {
15744
16335
  throw new src_ParseError("Expected group after '" + symbol + "'", symbolToken);
@@ -15752,8 +16343,7 @@ function () {
15752
16343
  */
15753
16344
  ;
15754
16345
 
15755
- _proto.handleUnsupportedCmd = function handleUnsupportedCmd() {
15756
- var text = this.nextToken.text;
16346
+ _proto.formatUnsupportedCmd = function formatUnsupportedCmd(text) {
15757
16347
  var textordArray = [];
15758
16348
 
15759
16349
  for (var i = 0; i < text.length; i++) {
@@ -15775,7 +16365,6 @@ function () {
15775
16365
  color: this.settings.errorColor,
15776
16366
  body: [textNode]
15777
16367
  };
15778
- this.consume();
15779
16368
  return colorNode;
15780
16369
  }
15781
16370
  /**
@@ -15800,7 +16389,7 @@ function () {
15800
16389
  // Guaranteed in math mode, so eat any spaces first.
15801
16390
  this.consumeSpaces(); // Lex the first token
15802
16391
 
15803
- var lex = this.nextToken;
16392
+ var lex = this.fetch();
15804
16393
 
15805
16394
  if (lex.text === "\\limits" || lex.text === "\\nolimits") {
15806
16395
  // We got a limit control
@@ -15811,7 +16400,15 @@ function () {
15811
16400
  opNode.limits = limits;
15812
16401
  opNode.alwaysHandleSupSub = true;
15813
16402
  } else {
15814
- throw new src_ParseError("Limit controls must follow a math operator", lex);
16403
+ opNode = checkNodeType(base, "operatorname");
16404
+
16405
+ if (opNode && opNode.alwaysHandleSupSub) {
16406
+ var _limits = lex.text === "\\limits";
16407
+
16408
+ opNode.limits = _limits;
16409
+ } else {
16410
+ throw new src_ParseError("Limit controls must follow a math operator", lex);
16411
+ }
15815
16412
  }
15816
16413
 
15817
16414
  this.consume();
@@ -15844,7 +16441,7 @@ function () {
15844
16441
  var primes = [prime];
15845
16442
  this.consume(); // Keep lexing tokens until we get something that's not a prime
15846
16443
 
15847
- while (this.nextToken.text === "'") {
16444
+ while (this.fetch().text === "'") {
15848
16445
  // For each one, add another prime to the list
15849
16446
  primes.push(prime);
15850
16447
  this.consume();
@@ -15852,7 +16449,7 @@ function () {
15852
16449
  // superscript in with the primes.
15853
16450
 
15854
16451
 
15855
- if (this.nextToken.text === "^") {
16452
+ if (this.fetch().text === "^") {
15856
16453
  primes.push(this.handleSupSubscript("superscript"));
15857
16454
  } // Put everything into an ordgroup as the superscript
15858
16455
 
@@ -15891,7 +16488,7 @@ function () {
15891
16488
 
15892
16489
  _proto.parseFunction = function parseFunction(breakOnTokenText, name, // For error reporting.
15893
16490
  greediness) {
15894
- var token = this.nextToken;
16491
+ var token = this.fetch();
15895
16492
  var func = token.text;
15896
16493
  var funcData = src_functions[func];
15897
16494
 
@@ -15899,29 +16496,14 @@ function () {
15899
16496
  return null;
15900
16497
  }
15901
16498
 
16499
+ this.consume(); // consume command token
16500
+
15902
16501
  if (greediness != null && funcData.greediness <= greediness) {
15903
16502
  throw new src_ParseError("Got function '" + func + "' with no arguments" + (name ? " as " + name : ""), token);
15904
16503
  } else if (this.mode === "text" && !funcData.allowedInText) {
15905
16504
  throw new src_ParseError("Can't use function '" + func + "' in text mode", token);
15906
16505
  } else if (this.mode === "math" && funcData.allowedInMath === false) {
15907
16506
  throw new src_ParseError("Can't use function '" + func + "' in math mode", token);
15908
- } // hyperref package sets the catcode of % as an active character
15909
-
15910
-
15911
- if (funcData.argTypes && funcData.argTypes[0] === "url") {
15912
- this.gullet.lexer.setCatcode("%", 13);
15913
- } // Consume the command token after possibly switching to the
15914
- // mode specified by the function (for instant mode switching),
15915
- // and then immediately switch back.
15916
-
15917
-
15918
- if (funcData.consumeMode) {
15919
- var oldMode = this.mode;
15920
- this.switchMode(funcData.consumeMode);
15921
- this.consume();
15922
- this.switchMode(oldMode);
15923
- } else {
15924
- this.consume();
15925
16507
  }
15926
16508
 
15927
16509
  var _this$parseArguments = this.parseArguments(func, funcData),
@@ -15977,22 +16559,14 @@ function () {
15977
16559
  // put spaces between the arguments (e.g., ‘\row x n’), because
15978
16560
  // TeX doesn’t use single spaces as undelimited arguments."
15979
16561
 
15980
- if (i > 0 && !isOptional) {
15981
- this.consumeSpaces();
15982
- } // Also consume leading spaces in math mode, as parseSymbol
16562
+ var consumeSpaces = i > 0 && !isOptional || // Also consume leading spaces in math mode, as parseSymbol
15983
16563
  // won't know what to do with them. This can only happen with
15984
16564
  // macros, e.g. \frac\foo\foo where \foo expands to a space symbol.
15985
- // In LaTeX, the \foo's get treated as (blank) arguments).
16565
+ // In LaTeX, the \foo's get treated as (blank) arguments.
15986
16566
  // In KaTeX, for now, both spaces will get consumed.
15987
16567
  // TODO(edemaine)
15988
-
15989
-
15990
- if (i === 0 && !isOptional && this.mode === "math") {
15991
- this.consumeSpaces();
15992
- }
15993
-
15994
- var nextToken = this.nextToken;
15995
- var arg = this.parseGroupOfType("argument to '" + func + "'", argType, isOptional, baseGreediness);
16568
+ i === 0 && !isOptional && this.mode === "math";
16569
+ var arg = this.parseGroupOfType("argument to '" + func + "'", argType, isOptional, baseGreediness, consumeSpaces);
15996
16570
 
15997
16571
  if (!arg) {
15998
16572
  if (isOptional) {
@@ -16000,7 +16574,7 @@ function () {
16000
16574
  continue;
16001
16575
  }
16002
16576
 
16003
- throw new src_ParseError("Expected group after '" + func + "'", nextToken);
16577
+ throw new src_ParseError("Expected group after '" + func + "'", this.fetch());
16004
16578
  }
16005
16579
 
16006
16580
  (isOptional ? optArgs : args).push(arg);
@@ -16016,24 +16590,56 @@ function () {
16016
16590
  */
16017
16591
  ;
16018
16592
 
16019
- _proto.parseGroupOfType = function parseGroupOfType(name, type, optional, greediness) {
16593
+ _proto.parseGroupOfType = function parseGroupOfType(name, type, optional, greediness, consumeSpaces) {
16020
16594
  switch (type) {
16021
16595
  case "color":
16596
+ if (consumeSpaces) {
16597
+ this.consumeSpaces();
16598
+ }
16599
+
16022
16600
  return this.parseColorGroup(optional);
16023
16601
 
16024
16602
  case "size":
16603
+ if (consumeSpaces) {
16604
+ this.consumeSpaces();
16605
+ }
16606
+
16025
16607
  return this.parseSizeGroup(optional);
16026
16608
 
16027
16609
  case "url":
16028
- return this.parseUrlGroup(optional);
16610
+ return this.parseUrlGroup(optional, consumeSpaces);
16029
16611
 
16030
16612
  case "math":
16031
16613
  case "text":
16032
- return this.parseGroup(name, optional, greediness, undefined, type);
16614
+ return this.parseGroup(name, optional, greediness, undefined, type, consumeSpaces);
16615
+
16616
+ case "hbox":
16617
+ {
16618
+ // hbox argument type wraps the argument in the equivalent of
16619
+ // \hbox, which is like \text but switching to \textstyle size.
16620
+ var group = this.parseGroup(name, optional, greediness, undefined, "text", consumeSpaces);
16621
+
16622
+ if (!group) {
16623
+ return group;
16624
+ }
16625
+
16626
+ var styledGroup = {
16627
+ type: "styling",
16628
+ mode: group.mode,
16629
+ body: [group],
16630
+ style: "text" // simulate \textstyle
16631
+
16632
+ };
16633
+ return styledGroup;
16634
+ }
16033
16635
 
16034
16636
  case "raw":
16035
16637
  {
16036
- if (optional && this.nextToken.text === "{") {
16638
+ if (consumeSpaces) {
16639
+ this.consumeSpaces();
16640
+ }
16641
+
16642
+ if (optional && this.fetch().text === "{") {
16037
16643
  return null;
16038
16644
  }
16039
16645
 
@@ -16046,22 +16652,26 @@ function () {
16046
16652
  string: token.text
16047
16653
  };
16048
16654
  } else {
16049
- throw new src_ParseError("Expected raw group", this.nextToken);
16655
+ throw new src_ParseError("Expected raw group", this.fetch());
16050
16656
  }
16051
16657
  }
16052
16658
 
16053
16659
  case "original":
16054
16660
  case null:
16055
16661
  case undefined:
16056
- return this.parseGroup(name, optional, greediness);
16662
+ return this.parseGroup(name, optional, greediness, undefined, undefined, consumeSpaces);
16057
16663
 
16058
16664
  default:
16059
- throw new src_ParseError("Unknown group type as " + name, this.nextToken);
16665
+ throw new src_ParseError("Unknown group type as " + name, this.fetch());
16060
16666
  }
16061
- };
16667
+ }
16668
+ /**
16669
+ * Discard any space tokens, fetching the next non-space token.
16670
+ */
16671
+ ;
16062
16672
 
16063
16673
  _proto.consumeSpaces = function consumeSpaces() {
16064
- while (this.nextToken.text === " ") {
16674
+ while (this.fetch().text === " ") {
16065
16675
  this.consume();
16066
16676
  }
16067
16677
  }
@@ -16075,17 +16685,14 @@ function () {
16075
16685
  optional, raw) {
16076
16686
  var groupBegin = optional ? "[" : "{";
16077
16687
  var groupEnd = optional ? "]" : "}";
16078
- var nextToken = this.nextToken;
16688
+ var beginToken = this.fetch();
16079
16689
 
16080
- if (nextToken.text !== groupBegin) {
16690
+ if (beginToken.text !== groupBegin) {
16081
16691
  if (optional) {
16082
16692
  return null;
16083
- } else if (raw && nextToken.text !== "EOF" && /[^{}[\]]/.test(nextToken.text)) {
16084
- // allow a single character in raw string group
16085
- this.gullet.lexer.setCatcode("%", 14); // reset the catcode of %
16086
-
16693
+ } else if (raw && beginToken.text !== "EOF" && /[^{}[\]]/.test(beginToken.text)) {
16087
16694
  this.consume();
16088
- return nextToken;
16695
+ return beginToken;
16089
16696
  }
16090
16697
  }
16091
16698
 
@@ -16093,13 +16700,14 @@ function () {
16093
16700
  this.mode = "text";
16094
16701
  this.expect(groupBegin);
16095
16702
  var str = "";
16096
- var firstToken = this.nextToken;
16703
+ var firstToken = this.fetch();
16097
16704
  var nested = 0; // allow nested braces in raw string group
16098
16705
 
16099
16706
  var lastToken = firstToken;
16707
+ var nextToken;
16100
16708
 
16101
- while (raw && nested > 0 || this.nextToken.text !== groupEnd) {
16102
- switch (this.nextToken.text) {
16709
+ while ((nextToken = this.fetch()).text !== groupEnd || raw && nested > 0) {
16710
+ switch (nextToken.text) {
16103
16711
  case "EOF":
16104
16712
  throw new src_ParseError("Unexpected end of input in " + modeName, firstToken.range(lastToken, str));
16105
16713
 
@@ -16112,15 +16720,13 @@ function () {
16112
16720
  break;
16113
16721
  }
16114
16722
 
16115
- lastToken = this.nextToken;
16723
+ lastToken = nextToken;
16116
16724
  str += lastToken.text;
16117
16725
  this.consume();
16118
16726
  }
16119
16727
 
16120
- this.mode = outerMode;
16121
- this.gullet.lexer.setCatcode("%", 14); // reset the catcode of %
16122
-
16123
16728
  this.expect(groupEnd);
16729
+ this.mode = outerMode;
16124
16730
  return firstToken.range(lastToken, str);
16125
16731
  }
16126
16732
  /**
@@ -16133,12 +16739,13 @@ function () {
16133
16739
  _proto.parseRegexGroup = function parseRegexGroup(regex, modeName) {
16134
16740
  var outerMode = this.mode;
16135
16741
  this.mode = "text";
16136
- var firstToken = this.nextToken;
16742
+ var firstToken = this.fetch();
16137
16743
  var lastToken = firstToken;
16138
16744
  var str = "";
16745
+ var nextToken;
16139
16746
 
16140
- while (this.nextToken.text !== "EOF" && regex.test(str + this.nextToken.text)) {
16141
- lastToken = this.nextToken;
16747
+ while ((nextToken = this.fetch()).text !== "EOF" && regex.test(str + nextToken.text)) {
16748
+ lastToken = nextToken;
16142
16749
  str += lastToken.text;
16143
16750
  this.consume();
16144
16751
  }
@@ -16192,7 +16799,7 @@ function () {
16192
16799
  var res;
16193
16800
  var isBlank = false;
16194
16801
 
16195
- if (!optional && this.nextToken.text !== "{") {
16802
+ if (!optional && this.fetch().text !== "{") {
16196
16803
  res = this.parseRegexGroup(/^[-+]? *(?:$|\d+|\d+\.\d*|\.\d*) *[a-z]{0,2} *$/, "size");
16197
16804
  } else {
16198
16805
  res = this.parseStringGroup("size", optional);
@@ -16235,13 +16842,18 @@ function () {
16235
16842
  };
16236
16843
  }
16237
16844
  /**
16238
- * Parses an URL, checking escaped letters and allowed protocols.
16845
+ * Parses an URL, checking escaped letters and allowed protocols,
16846
+ * and setting the catcode of % as an active character (as in \hyperref).
16239
16847
  */
16240
16848
  ;
16241
16849
 
16242
- _proto.parseUrlGroup = function parseUrlGroup(optional) {
16850
+ _proto.parseUrlGroup = function parseUrlGroup(optional, consumeSpaces) {
16851
+ this.gullet.lexer.setCatcode("%", 13); // active character
16852
+
16243
16853
  var res = this.parseStringGroup("url", optional, true); // get raw string
16244
16854
 
16855
+ this.gullet.lexer.setCatcode("%", 14); // comment character
16856
+
16245
16857
  if (!res) {
16246
16858
  return null;
16247
16859
  } // hyperref package allows backslashes alone in href, but doesn't
@@ -16251,14 +16863,6 @@ function () {
16251
16863
 
16252
16864
 
16253
16865
  var url = res.text.replace(/\\([#$%&~_^{}])/g, '$1');
16254
- var protocol = /^\s*([^\\/#]*?)(?::|&#0*58|&#x0*3a)/i.exec(url);
16255
- protocol = protocol != null ? protocol[1] : "_relative";
16256
- var allowed = this.settings.allowedProtocols;
16257
-
16258
- if (!utils.contains(allowed, "*") && !utils.contains(allowed, protocol)) {
16259
- throw new src_ParseError("Forbidden protocol '" + protocol + "'", res);
16260
- }
16261
-
16262
16866
  return {
16263
16867
  type: "url",
16264
16868
  mode: this.mode,
@@ -16280,26 +16884,35 @@ function () {
16280
16884
  ;
16281
16885
 
16282
16886
  _proto.parseGroup = function parseGroup(name, // For error reporting.
16283
- optional, greediness, breakOnTokenText, mode) {
16887
+ optional, greediness, breakOnTokenText, mode, consumeSpaces) {
16888
+ // Switch to specified mode
16284
16889
  var outerMode = this.mode;
16285
- var firstToken = this.nextToken;
16286
- var text = firstToken.text; // Switch to specified mode
16287
16890
 
16288
16891
  if (mode) {
16289
16892
  this.switchMode(mode);
16290
- }
16893
+ } // Consume spaces if requested, crucially *after* we switch modes,
16894
+ // so that the next non-space token is parsed in the correct mode.
16895
+
16291
16896
 
16292
- var groupEnd;
16897
+ if (consumeSpaces) {
16898
+ this.consumeSpaces();
16899
+ } // Get first token
16900
+
16901
+
16902
+ var firstToken = this.fetch();
16903
+ var text = firstToken.text;
16293
16904
  var result; // Try to parse an open brace or \begingroup
16294
16905
 
16295
16906
  if (optional ? text === "[" : text === "{" || text === "\\begingroup") {
16296
- groupEnd = Parser.endOfGroup[text]; // Start a new group namespace
16907
+ this.consume();
16908
+ var groupEnd = Parser.endOfGroup[text]; // Start a new group namespace
16297
16909
 
16298
16910
  this.gullet.beginGroup(); // If we get a brace, parse an expression
16299
16911
 
16300
- this.consume();
16301
16912
  var expression = this.parseExpression(false, groupEnd);
16302
- var lastToken = this.nextToken; // End group namespace before consuming symbol after close brace
16913
+ var lastToken = this.fetch(); // Check that we got a matching closing brace
16914
+
16915
+ this.expect(groupEnd); // End group namespace
16303
16916
 
16304
16917
  this.gullet.endGroup();
16305
16918
  result = {
@@ -16326,18 +16939,14 @@ function () {
16326
16939
  throw new src_ParseError("Undefined control sequence: " + text, firstToken);
16327
16940
  }
16328
16941
 
16329
- result = this.handleUnsupportedCmd();
16942
+ result = this.formatUnsupportedCmd(text);
16943
+ this.consume();
16330
16944
  }
16331
16945
  } // Switch mode back
16332
16946
 
16333
16947
 
16334
16948
  if (mode) {
16335
16949
  this.switchMode(outerMode);
16336
- } // Make sure we got a close brace
16337
-
16338
-
16339
- if (groupEnd) {
16340
- this.expect(groupEnd);
16341
16950
  }
16342
16951
 
16343
16952
  return result;
@@ -16393,12 +17002,12 @@ function () {
16393
17002
  }
16394
17003
  /**
16395
17004
  * Parse a single symbol out of the string. Here, we handle single character
16396
- * symbols and special functions like verbatim
17005
+ * symbols and special functions like \verb.
16397
17006
  */
16398
17007
  ;
16399
17008
 
16400
17009
  _proto.parseSymbol = function parseSymbol() {
16401
- var nucleus = this.nextToken;
17010
+ var nucleus = this.fetch();
16402
17011
  var text = nucleus.text;
16403
17012
 
16404
17013
  if (/^\\verb[^a-zA-Z]/.test(text)) {
@@ -16491,11 +17100,18 @@ function () {
16491
17100
  } else if (this.mode === "math") {
16492
17101
  this.settings.reportNonstrict("unicodeTextInMathMode", "Unicode text character \"" + text[0] + "\" used in math mode", nucleus);
16493
17102
  }
16494
- }
17103
+ } // All nonmathematical Unicode characters are rendered as if they
17104
+ // are in text mode (wrapped in \text) because that's what it
17105
+ // takes to render them in LaTeX. Setting `mode: this.mode` is
17106
+ // another natural choice (the user requested math mode), but
17107
+ // this makes it more difficult for getCharacterMetrics() to
17108
+ // distinguish Unicode characters without metrics and those for
17109
+ // which we want to simulate the letter M.
17110
+
16495
17111
 
16496
17112
  symbol = {
16497
17113
  type: "textord",
16498
- mode: this.mode,
17114
+ mode: "text",
16499
17115
  loc: SourceLocation.range(nucleus),
16500
17116
  text: text
16501
17117
  };
@@ -16653,7 +17269,7 @@ var renderToString = function renderToString(expression, options) {
16653
17269
 
16654
17270
 
16655
17271
  var katex_generateParseTree = function generateParseTree(expression, options) {
16656
- var settings = new src_Settings(options);
17272
+ var settings = new Settings_Settings(options);
16657
17273
  return src_parseTree(expression, settings);
16658
17274
  };
16659
17275
  /**
@@ -16680,7 +17296,7 @@ var katex_renderError = function renderError(error, expression, options) {
16680
17296
 
16681
17297
 
16682
17298
  var katex_renderToDomTree = function renderToDomTree(expression, options) {
16683
- var settings = new src_Settings(options);
17299
+ var settings = new Settings_Settings(options);
16684
17300
 
16685
17301
  try {
16686
17302
  var tree = src_parseTree(expression, settings);
@@ -16696,7 +17312,7 @@ var katex_renderToDomTree = function renderToDomTree(expression, options) {
16696
17312
 
16697
17313
 
16698
17314
  var katex_renderToHTMLTree = function renderToHTMLTree(expression, options) {
16699
- var settings = new src_Settings(options);
17315
+ var settings = new Settings_Settings(options);
16700
17316
 
16701
17317
  try {
16702
17318
  var tree = src_parseTree(expression, settings);
@@ -16710,7 +17326,7 @@ var katex_renderToHTMLTree = function renderToHTMLTree(expression, options) {
16710
17326
  /**
16711
17327
  * Current KaTeX version
16712
17328
  */
16713
- version: "0.10.2",
17329
+ version: "0.11.1",
16714
17330
 
16715
17331
  /**
16716
17332
  * Renders the given LaTeX into an HTML+MathML combination, and adds