katex 0.11.1 → 0.12.0

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 (116) hide show
  1. package/CHANGELOG.md +44 -0
  2. package/LICENSE +1 -1
  3. package/README.md +5 -5
  4. package/contrib/auto-render/auto-render.js +12 -3
  5. package/contrib/copy-tex/README.md +3 -5
  6. package/contrib/mathtex-script-type/README.md +12 -14
  7. package/contrib/mhchem/README.md +1 -1
  8. package/contrib/render-a11y-string/render-a11y-string.js +10 -0
  9. package/dist/README.md +5 -5
  10. package/dist/contrib/auto-render.js +14 -3
  11. package/dist/contrib/auto-render.min.js +1 -1
  12. package/dist/contrib/auto-render.mjs +14 -3
  13. package/dist/contrib/mhchem.min.js +1 -1
  14. package/dist/contrib/render-a11y-string.js +12 -0
  15. package/dist/contrib/render-a11y-string.min.js +1 -1
  16. package/dist/contrib/render-a11y-string.mjs +12 -0
  17. package/dist/fonts/KaTeX_AMS-Regular.ttf +0 -0
  18. package/dist/fonts/KaTeX_AMS-Regular.woff +0 -0
  19. package/dist/fonts/KaTeX_AMS-Regular.woff2 +0 -0
  20. package/dist/fonts/KaTeX_Caligraphic-Bold.ttf +0 -0
  21. package/dist/fonts/KaTeX_Caligraphic-Bold.woff +0 -0
  22. package/dist/fonts/KaTeX_Caligraphic-Bold.woff2 +0 -0
  23. package/dist/fonts/KaTeX_Caligraphic-Regular.ttf +0 -0
  24. package/dist/fonts/KaTeX_Caligraphic-Regular.woff +0 -0
  25. package/dist/fonts/KaTeX_Caligraphic-Regular.woff2 +0 -0
  26. package/dist/fonts/KaTeX_Fraktur-Bold.ttf +0 -0
  27. package/dist/fonts/KaTeX_Fraktur-Bold.woff +0 -0
  28. package/dist/fonts/KaTeX_Fraktur-Bold.woff2 +0 -0
  29. package/dist/fonts/KaTeX_Fraktur-Regular.ttf +0 -0
  30. package/dist/fonts/KaTeX_Fraktur-Regular.woff +0 -0
  31. package/dist/fonts/KaTeX_Fraktur-Regular.woff2 +0 -0
  32. package/dist/fonts/KaTeX_Main-Bold.ttf +0 -0
  33. package/dist/fonts/KaTeX_Main-Bold.woff +0 -0
  34. package/dist/fonts/KaTeX_Main-Bold.woff2 +0 -0
  35. package/dist/fonts/KaTeX_Main-BoldItalic.ttf +0 -0
  36. package/dist/fonts/KaTeX_Main-BoldItalic.woff +0 -0
  37. package/dist/fonts/KaTeX_Main-BoldItalic.woff2 +0 -0
  38. package/dist/fonts/KaTeX_Main-Italic.ttf +0 -0
  39. package/dist/fonts/KaTeX_Main-Italic.woff +0 -0
  40. package/dist/fonts/KaTeX_Main-Italic.woff2 +0 -0
  41. package/dist/fonts/KaTeX_Main-Regular.ttf +0 -0
  42. package/dist/fonts/KaTeX_Main-Regular.woff +0 -0
  43. package/dist/fonts/KaTeX_Main-Regular.woff2 +0 -0
  44. package/dist/fonts/KaTeX_Math-BoldItalic.ttf +0 -0
  45. package/dist/fonts/KaTeX_Math-BoldItalic.woff +0 -0
  46. package/dist/fonts/KaTeX_Math-BoldItalic.woff2 +0 -0
  47. package/dist/fonts/KaTeX_Math-Italic.ttf +0 -0
  48. package/dist/fonts/KaTeX_Math-Italic.woff +0 -0
  49. package/dist/fonts/KaTeX_Math-Italic.woff2 +0 -0
  50. package/dist/fonts/KaTeX_SansSerif-Bold.ttf +0 -0
  51. package/dist/fonts/KaTeX_SansSerif-Bold.woff +0 -0
  52. package/dist/fonts/KaTeX_SansSerif-Bold.woff2 +0 -0
  53. package/dist/fonts/KaTeX_SansSerif-Italic.ttf +0 -0
  54. package/dist/fonts/KaTeX_SansSerif-Italic.woff +0 -0
  55. package/dist/fonts/KaTeX_SansSerif-Italic.woff2 +0 -0
  56. package/dist/fonts/KaTeX_SansSerif-Regular.ttf +0 -0
  57. package/dist/fonts/KaTeX_SansSerif-Regular.woff +0 -0
  58. package/dist/fonts/KaTeX_SansSerif-Regular.woff2 +0 -0
  59. package/dist/fonts/KaTeX_Script-Regular.ttf +0 -0
  60. package/dist/fonts/KaTeX_Script-Regular.woff +0 -0
  61. package/dist/fonts/KaTeX_Script-Regular.woff2 +0 -0
  62. package/dist/fonts/KaTeX_Size1-Regular.ttf +0 -0
  63. package/dist/fonts/KaTeX_Size1-Regular.woff +0 -0
  64. package/dist/fonts/KaTeX_Size1-Regular.woff2 +0 -0
  65. package/dist/fonts/KaTeX_Size2-Regular.ttf +0 -0
  66. package/dist/fonts/KaTeX_Size2-Regular.woff +0 -0
  67. package/dist/fonts/KaTeX_Size2-Regular.woff2 +0 -0
  68. package/dist/fonts/KaTeX_Size3-Regular.ttf +0 -0
  69. package/dist/fonts/KaTeX_Size3-Regular.woff +0 -0
  70. package/dist/fonts/KaTeX_Size3-Regular.woff2 +0 -0
  71. package/dist/fonts/KaTeX_Size4-Regular.ttf +0 -0
  72. package/dist/fonts/KaTeX_Size4-Regular.woff +0 -0
  73. package/dist/fonts/KaTeX_Size4-Regular.woff2 +0 -0
  74. package/dist/fonts/KaTeX_Typewriter-Regular.ttf +0 -0
  75. package/dist/fonts/KaTeX_Typewriter-Regular.woff +0 -0
  76. package/dist/fonts/KaTeX_Typewriter-Regular.woff2 +0 -0
  77. package/dist/katex.css +25 -2
  78. package/dist/katex.js +1140 -1257
  79. package/dist/katex.min.css +1 -1
  80. package/dist/katex.min.js +1 -1
  81. package/dist/katex.mjs +1119 -1229
  82. package/package.json +9 -9
  83. package/src/MacroExpander.js +39 -10
  84. package/src/Parser.js +28 -24
  85. package/src/Settings.js +19 -0
  86. package/src/Token.js +2 -0
  87. package/src/buildCommon.js +16 -82
  88. package/src/buildHTML.js +29 -30
  89. package/src/buildMathML.js +5 -1
  90. package/src/buildTree.js +3 -2
  91. package/src/defineFunction.js +1 -4
  92. package/src/delimiter.js +14 -3
  93. package/src/environments/array.js +11 -9
  94. package/src/functions/accent.js +6 -7
  95. package/src/functions/accentunder.js +2 -2
  96. package/src/functions/def.js +184 -0
  97. package/src/functions/delimsizing.js +5 -4
  98. package/src/functions/font.js +1 -1
  99. package/src/functions/genfrac.js +8 -15
  100. package/src/functions/horizBrace.js +6 -7
  101. package/src/functions/html.js +102 -0
  102. package/src/functions/lap.js +4 -7
  103. package/src/functions/op.js +5 -6
  104. package/src/functions/operatorname.js +5 -6
  105. package/src/functions/supsub.js +3 -5
  106. package/src/functions/utils/assembleSupSub.js +0 -2
  107. package/src/functions.js +2 -0
  108. package/src/katex.less +29 -1
  109. package/src/macros.js +97 -56
  110. package/src/parseNode.js +14 -56
  111. package/src/svgGeometry.js +4 -0
  112. package/src/symbols.js +36 -53
  113. package/src/unicodeAccents.js +3 -1
  114. package/src/unicodeSymbols.js +30 -321
  115. package/src/wide-character.js +2 -2
  116. package/src/unicodeMake.js +0 -70
package/dist/katex.mjs CHANGED
@@ -56,10 +56,14 @@ class SourceLocation {
56
56
  * lead to degraded error reporting, though.
57
57
  */
58
58
  class Token {
59
+ // don't expand the token
60
+ // used in \noexpand
59
61
  constructor(text, // the text of this token
60
62
  loc) {
61
63
  this.text = void 0;
62
64
  this.loc = void 0;
65
+ this.noexpand = void 0;
66
+ this.treatAsRelax = void 0;
63
67
  this.text = text;
64
68
  this.loc = loc;
65
69
  }
@@ -282,6 +286,7 @@ class Settings {
282
286
  this.trust = void 0;
283
287
  this.maxSize = void 0;
284
288
  this.maxExpand = void 0;
289
+ this.globalGroup = void 0;
285
290
  // allow null options
286
291
  options = options || {};
287
292
  this.displayMode = utils.deflt(options.displayMode, false);
@@ -297,6 +302,7 @@ class Settings {
297
302
  this.trust = utils.deflt(options.trust, false);
298
303
  this.maxSize = Math.max(0, utils.deflt(options.maxSize, Infinity));
299
304
  this.maxExpand = Math.max(0, utils.deflt(options.maxExpand, 1000));
305
+ this.globalGroup = utils.deflt(options.globalGroup, false);
300
306
  }
301
307
  /**
302
308
  * Report nonstrict (non-LaTeX-compatible) input.
@@ -745,6 +751,9 @@ const sqrtPath = function sqrtPath(size, extraViniculum, viewBoxHeight) {
745
751
  return path;
746
752
  };
747
753
  const path = {
754
+ // Two paths that cover gaps in built-up parentheses.
755
+ leftParenInner: `M291 0 H417 V300 H291 z`,
756
+ rightParenInner: `M457 0 H583 V300 H457 z`,
748
757
  // The doubleleftarrow geometry is from glyph U+21D0 in the font KaTeX Main
749
758
  doubleleftarrow: `M262 157
750
759
  l10-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
@@ -1594,6 +1603,7 @@ function assertSpan(group) {
1594
1603
  // This file is GENERATED by buildMetrics.sh. DO NOT MODIFY.
1595
1604
  var metricMap = {
1596
1605
  "AMS-Regular": {
1606
+ "32": [0, 0, 0, 0, 0.25],
1597
1607
  "65": [0, 0.68889, 0, 0, 0.72222],
1598
1608
  "66": [0, 0.68889, 0, 0, 0.66667],
1599
1609
  "67": [0, 0.68889, 0, 0, 0.72222],
@@ -1621,6 +1631,7 @@ var metricMap = {
1621
1631
  "89": [0, 0.68889, 0, 0, 0.72222],
1622
1632
  "90": [0, 0.68889, 0, 0, 0.66667],
1623
1633
  "107": [0, 0.68889, 0, 0, 0.55556],
1634
+ "160": [0, 0, 0, 0, 0.25],
1624
1635
  "165": [0, 0.675, 0.025, 0, 0.75],
1625
1636
  "174": [0.15559, 0.69224, 0, 0, 0.94666],
1626
1637
  "240": [0, 0.68889, 0, 0, 0.55556],
@@ -1851,16 +1862,7 @@ var metricMap = {
1851
1862
  "57371": [0.13597, 0.63597, 0, 0, 0.77778]
1852
1863
  },
1853
1864
  "Caligraphic-Regular": {
1854
- "48": [0, 0.43056, 0, 0, 0.5],
1855
- "49": [0, 0.43056, 0, 0, 0.5],
1856
- "50": [0, 0.43056, 0, 0, 0.5],
1857
- "51": [0.19444, 0.43056, 0, 0, 0.5],
1858
- "52": [0.19444, 0.43056, 0, 0, 0.5],
1859
- "53": [0.19444, 0.43056, 0, 0, 0.5],
1860
- "54": [0, 0.64444, 0, 0, 0.5],
1861
- "55": [0.19444, 0.43056, 0, 0, 0.5],
1862
- "56": [0, 0.64444, 0, 0, 0.5],
1863
- "57": [0.19444, 0.43056, 0, 0, 0.5],
1865
+ "32": [0, 0, 0, 0, 0.25],
1864
1866
  "65": [0, 0.68333, 0, 0.19445, 0.79847],
1865
1867
  "66": [0, 0.68333, 0.03041, 0.13889, 0.65681],
1866
1868
  "67": [0, 0.68333, 0.05834, 0.13889, 0.52653],
@@ -1886,9 +1888,11 @@ var metricMap = {
1886
1888
  "87": [0, 0.68333, 0.08222, 0.08334, 0.98778],
1887
1889
  "88": [0, 0.68333, 0.14643, 0.13889, 0.7133],
1888
1890
  "89": [0.09722, 0.68333, 0.08222, 0.08334, 0.66834],
1889
- "90": [0, 0.68333, 0.07944, 0.13889, 0.72473]
1891
+ "90": [0, 0.68333, 0.07944, 0.13889, 0.72473],
1892
+ "160": [0, 0, 0, 0, 0.25]
1890
1893
  },
1891
1894
  "Fraktur-Regular": {
1895
+ "32": [0, 0, 0, 0, 0.25],
1892
1896
  "33": [0, 0.69141, 0, 0, 0.29574],
1893
1897
  "34": [0, 0.69141, 0, 0, 0.21471],
1894
1898
  "38": [0, 0.69141, 0, 0, 0.73786],
@@ -1970,6 +1974,7 @@ var metricMap = {
1970
1974
  "120": [0.18906, 0.47534, 0, 0, 0.38865],
1971
1975
  "121": [0.18906, 0.47534, 0, 0, 0.49884],
1972
1976
  "122": [0.18906, 0.47534, 0, 0, 0.39054],
1977
+ "160": [0, 0, 0, 0, 0.25],
1973
1978
  "8216": [0, 0.69141, 0, 0, 0.21471],
1974
1979
  "8217": [0, 0.69141, 0, 0, 0.21471],
1975
1980
  "58112": [0, 0.62119, 0, 0, 0.49749],
@@ -1982,6 +1987,7 @@ var metricMap = {
1982
1987
  "58119": [0, 0.47534, 0, 0, 0.50073]
1983
1988
  },
1984
1989
  "Main-Bold": {
1990
+ "32": [0, 0, 0, 0, 0.25],
1985
1991
  "33": [0, 0.69444, 0, 0, 0.35],
1986
1992
  "34": [0, 0.69444, 0, 0, 0.60278],
1987
1993
  "35": [0.19444, 0.69444, 0, 0, 0.95833],
@@ -2075,6 +2081,8 @@ var metricMap = {
2075
2081
  "124": [0.25, 0.75, 0, 0, 0.31944],
2076
2082
  "125": [0.25, 0.75, 0, 0, 0.575],
2077
2083
  "126": [0.35, 0.34444, 0, 0, 0.575],
2084
+ "160": [0, 0, 0, 0, 0.25],
2085
+ "163": [0, 0.69444, 0, 0, 0.86853],
2078
2086
  "168": [0, 0.69444, 0, 0, 0.575],
2079
2087
  "172": [0, 0.44444, 0, 0, 0.76666],
2080
2088
  "176": [0, 0.69444, 0, 0, 0.86944],
@@ -2232,6 +2240,7 @@ var metricMap = {
2232
2240
  "57376": [0.19444, 0.69444, 0, 0, 0]
2233
2241
  },
2234
2242
  "Main-BoldItalic": {
2243
+ "32": [0, 0, 0, 0, 0.25],
2235
2244
  "33": [0, 0.69444, 0.11417, 0, 0.38611],
2236
2245
  "34": [0, 0.69444, 0.07939, 0, 0.62055],
2237
2246
  "35": [0.19444, 0.69444, 0.06833, 0, 0.94444],
@@ -2318,7 +2327,7 @@ var metricMap = {
2318
2327
  "121": [0.19444, 0.44444, 0.105, 0, 0.56166],
2319
2328
  "122": [0, 0.44444, 0.13889, 0, 0.49055],
2320
2329
  "126": [0.35, 0.34444, 0.11472, 0, 0.59111],
2321
- "163": [0, 0.69444, 0, 0, 0.86853],
2330
+ "160": [0, 0, 0, 0, 0.25],
2322
2331
  "168": [0, 0.69444, 0.11473, 0, 0.59111],
2323
2332
  "176": [0, 0.69444, 0, 0, 0.94888],
2324
2333
  "184": [0.17014, 0, 0, 0, 0.53222],
@@ -2360,6 +2369,7 @@ var metricMap = {
2360
2369
  "8221": [0, 0.69444, 0.07939, 0, 0.62055]
2361
2370
  },
2362
2371
  "Main-Italic": {
2372
+ "32": [0, 0, 0, 0, 0.25],
2363
2373
  "33": [0, 0.69444, 0.12417, 0, 0.30667],
2364
2374
  "34": [0, 0.69444, 0.06961, 0, 0.51444],
2365
2375
  "35": [0.19444, 0.69444, 0.06616, 0, 0.81777],
@@ -2446,7 +2456,7 @@ var metricMap = {
2446
2456
  "121": [0.19444, 0.43056, 0.08847, 0, 0.48555],
2447
2457
  "122": [0, 0.43056, 0.12292, 0, 0.40889],
2448
2458
  "126": [0.35, 0.31786, 0.11585, 0, 0.51111],
2449
- "163": [0, 0.69444, 0, 0, 0.76909],
2459
+ "160": [0, 0, 0, 0, 0.25],
2450
2460
  "168": [0, 0.66786, 0.10474, 0, 0.51111],
2451
2461
  "176": [0, 0.69444, 0, 0, 0.83129],
2452
2462
  "184": [0.17014, 0, 0, 0, 0.46],
@@ -2455,10 +2465,8 @@ var metricMap = {
2455
2465
  "223": [0.19444, 0.69444, 0.10514, 0, 0.53666],
2456
2466
  "230": [0, 0.43056, 0.07514, 0, 0.71555],
2457
2467
  "248": [0.09722, 0.52778, 0.09194, 0, 0.51111],
2458
- "305": [0, 0.43056, 0, 0.02778, 0.32246],
2459
2468
  "338": [0, 0.68333, 0.12028, 0, 0.98499],
2460
2469
  "339": [0, 0.43056, 0.07514, 0, 0.71555],
2461
- "567": [0.19444, 0.43056, 0, 0.08334, 0.38403],
2462
2470
  "710": [0, 0.69444, 0.06646, 0, 0.51111],
2463
2471
  "711": [0, 0.62847, 0.08295, 0, 0.51111],
2464
2472
  "713": [0, 0.56167, 0.10333, 0, 0.51111],
@@ -2584,6 +2592,7 @@ var metricMap = {
2584
2592
  "125": [0.25, 0.75, 0, 0, 0.5],
2585
2593
  "126": [0.35, 0.31786, 0, 0, 0.5],
2586
2594
  "160": [0, 0, 0, 0, 0.25],
2595
+ "163": [0, 0.69444, 0, 0, 0.76909],
2587
2596
  "167": [0.19444, 0.69444, 0, 0, 0.44445],
2588
2597
  "168": [0, 0.66786, 0, 0, 0.5],
2589
2598
  "172": [0, 0.43056, 0, 0, 0.66667],
@@ -2766,6 +2775,17 @@ var metricMap = {
2766
2775
  "57376": [0.19444, 0.69444, 0, 0, 0]
2767
2776
  },
2768
2777
  "Math-BoldItalic": {
2778
+ "32": [0, 0, 0, 0, 0.25],
2779
+ "48": [0, 0.44444, 0, 0, 0.575],
2780
+ "49": [0, 0.44444, 0, 0, 0.575],
2781
+ "50": [0, 0.44444, 0, 0, 0.575],
2782
+ "51": [0.19444, 0.44444, 0, 0, 0.575],
2783
+ "52": [0.19444, 0.44444, 0, 0, 0.575],
2784
+ "53": [0.19444, 0.44444, 0, 0, 0.575],
2785
+ "54": [0, 0.64444, 0, 0, 0.575],
2786
+ "55": [0.19444, 0.44444, 0, 0, 0.575],
2787
+ "56": [0, 0.64444, 0, 0, 0.575],
2788
+ "57": [0.19444, 0.44444, 0, 0, 0.575],
2769
2789
  "65": [0, 0.68611, 0, 0, 0.86944],
2770
2790
  "66": [0, 0.68611, 0.04835, 0, 0.8664],
2771
2791
  "67": [0, 0.68611, 0.06979, 0, 0.81694],
@@ -2818,6 +2838,7 @@ var metricMap = {
2818
2838
  "120": [0, 0.44444, 0, 0, 0.65903],
2819
2839
  "121": [0.19444, 0.44444, 0.03704, 0, 0.59028],
2820
2840
  "122": [0, 0.44444, 0.04213, 0, 0.55509],
2841
+ "160": [0, 0, 0, 0, 0.25],
2821
2842
  "915": [0, 0.68611, 0.15972, 0, 0.65694],
2822
2843
  "916": [0, 0.68611, 0, 0, 0.95833],
2823
2844
  "920": [0, 0.68611, 0.03194, 0, 0.86722],
@@ -2858,9 +2879,22 @@ var metricMap = {
2858
2879
  "981": [0.19444, 0.69444, 0, 0, 0.7125],
2859
2880
  "982": [0, 0.44444, 0.03194, 0, 0.975],
2860
2881
  "1009": [0.19444, 0.44444, 0, 0, 0.6118],
2861
- "1013": [0, 0.44444, 0, 0, 0.48333]
2882
+ "1013": [0, 0.44444, 0, 0, 0.48333],
2883
+ "57649": [0, 0.44444, 0, 0, 0.39352],
2884
+ "57911": [0.19444, 0.44444, 0, 0, 0.43889]
2862
2885
  },
2863
2886
  "Math-Italic": {
2887
+ "32": [0, 0, 0, 0, 0.25],
2888
+ "48": [0, 0.43056, 0, 0, 0.5],
2889
+ "49": [0, 0.43056, 0, 0, 0.5],
2890
+ "50": [0, 0.43056, 0, 0, 0.5],
2891
+ "51": [0.19444, 0.43056, 0, 0, 0.5],
2892
+ "52": [0.19444, 0.43056, 0, 0, 0.5],
2893
+ "53": [0.19444, 0.43056, 0, 0, 0.5],
2894
+ "54": [0, 0.64444, 0, 0, 0.5],
2895
+ "55": [0.19444, 0.43056, 0, 0, 0.5],
2896
+ "56": [0, 0.64444, 0, 0, 0.5],
2897
+ "57": [0.19444, 0.43056, 0, 0, 0.5],
2864
2898
  "65": [0, 0.68333, 0, 0.13889, 0.75],
2865
2899
  "66": [0, 0.68333, 0.05017, 0.08334, 0.75851],
2866
2900
  "67": [0, 0.68333, 0.07153, 0.08334, 0.71472],
@@ -2913,6 +2947,7 @@ var metricMap = {
2913
2947
  "120": [0, 0.43056, 0, 0.02778, 0.57153],
2914
2948
  "121": [0.19444, 0.43056, 0.03588, 0.05556, 0.49028],
2915
2949
  "122": [0, 0.43056, 0.04398, 0.05556, 0.46505],
2950
+ "160": [0, 0, 0, 0, 0.25],
2916
2951
  "915": [0, 0.68333, 0.13889, 0.08334, 0.61528],
2917
2952
  "916": [0, 0.68333, 0, 0.16667, 0.83334],
2918
2953
  "920": [0, 0.68333, 0.02778, 0.08334, 0.76278],
@@ -2953,104 +2988,12 @@ var metricMap = {
2953
2988
  "981": [0.19444, 0.69444, 0, 0.08334, 0.59583],
2954
2989
  "982": [0, 0.43056, 0.02778, 0, 0.82813],
2955
2990
  "1009": [0.19444, 0.43056, 0, 0.08334, 0.51702],
2956
- "1013": [0, 0.43056, 0, 0.05556, 0.4059]
2957
- },
2958
- "Math-Regular": {
2959
- "65": [0, 0.68333, 0, 0.13889, 0.75],
2960
- "66": [0, 0.68333, 0.05017, 0.08334, 0.75851],
2961
- "67": [0, 0.68333, 0.07153, 0.08334, 0.71472],
2962
- "68": [0, 0.68333, 0.02778, 0.05556, 0.82792],
2963
- "69": [0, 0.68333, 0.05764, 0.08334, 0.7382],
2964
- "70": [0, 0.68333, 0.13889, 0.08334, 0.64306],
2965
- "71": [0, 0.68333, 0, 0.08334, 0.78625],
2966
- "72": [0, 0.68333, 0.08125, 0.05556, 0.83125],
2967
- "73": [0, 0.68333, 0.07847, 0.11111, 0.43958],
2968
- "74": [0, 0.68333, 0.09618, 0.16667, 0.55451],
2969
- "75": [0, 0.68333, 0.07153, 0.05556, 0.84931],
2970
- "76": [0, 0.68333, 0, 0.02778, 0.68056],
2971
- "77": [0, 0.68333, 0.10903, 0.08334, 0.97014],
2972
- "78": [0, 0.68333, 0.10903, 0.08334, 0.80347],
2973
- "79": [0, 0.68333, 0.02778, 0.08334, 0.76278],
2974
- "80": [0, 0.68333, 0.13889, 0.08334, 0.64201],
2975
- "81": [0.19444, 0.68333, 0, 0.08334, 0.79056],
2976
- "82": [0, 0.68333, 0.00773, 0.08334, 0.75929],
2977
- "83": [0, 0.68333, 0.05764, 0.08334, 0.6132],
2978
- "84": [0, 0.68333, 0.13889, 0.08334, 0.58438],
2979
- "85": [0, 0.68333, 0.10903, 0.02778, 0.68278],
2980
- "86": [0, 0.68333, 0.22222, 0, 0.58333],
2981
- "87": [0, 0.68333, 0.13889, 0, 0.94445],
2982
- "88": [0, 0.68333, 0.07847, 0.08334, 0.82847],
2983
- "89": [0, 0.68333, 0.22222, 0, 0.58056],
2984
- "90": [0, 0.68333, 0.07153, 0.08334, 0.68264],
2985
- "97": [0, 0.43056, 0, 0, 0.52859],
2986
- "98": [0, 0.69444, 0, 0, 0.42917],
2987
- "99": [0, 0.43056, 0, 0.05556, 0.43276],
2988
- "100": [0, 0.69444, 0, 0.16667, 0.52049],
2989
- "101": [0, 0.43056, 0, 0.05556, 0.46563],
2990
- "102": [0.19444, 0.69444, 0.10764, 0.16667, 0.48959],
2991
- "103": [0.19444, 0.43056, 0.03588, 0.02778, 0.47697],
2992
- "104": [0, 0.69444, 0, 0, 0.57616],
2993
- "105": [0, 0.65952, 0, 0, 0.34451],
2994
- "106": [0.19444, 0.65952, 0.05724, 0, 0.41181],
2995
- "107": [0, 0.69444, 0.03148, 0, 0.5206],
2996
- "108": [0, 0.69444, 0.01968, 0.08334, 0.29838],
2997
- "109": [0, 0.43056, 0, 0, 0.87801],
2998
- "110": [0, 0.43056, 0, 0, 0.60023],
2999
- "111": [0, 0.43056, 0, 0.05556, 0.48472],
3000
- "112": [0.19444, 0.43056, 0, 0.08334, 0.50313],
3001
- "113": [0.19444, 0.43056, 0.03588, 0.08334, 0.44641],
3002
- "114": [0, 0.43056, 0.02778, 0.05556, 0.45116],
3003
- "115": [0, 0.43056, 0, 0.05556, 0.46875],
3004
- "116": [0, 0.61508, 0, 0.08334, 0.36111],
3005
- "117": [0, 0.43056, 0, 0.02778, 0.57246],
3006
- "118": [0, 0.43056, 0.03588, 0.02778, 0.48472],
3007
- "119": [0, 0.43056, 0.02691, 0.08334, 0.71592],
3008
- "120": [0, 0.43056, 0, 0.02778, 0.57153],
3009
- "121": [0.19444, 0.43056, 0.03588, 0.05556, 0.49028],
3010
- "122": [0, 0.43056, 0.04398, 0.05556, 0.46505],
3011
- "915": [0, 0.68333, 0.13889, 0.08334, 0.61528],
3012
- "916": [0, 0.68333, 0, 0.16667, 0.83334],
3013
- "920": [0, 0.68333, 0.02778, 0.08334, 0.76278],
3014
- "923": [0, 0.68333, 0, 0.16667, 0.69445],
3015
- "926": [0, 0.68333, 0.07569, 0.08334, 0.74236],
3016
- "928": [0, 0.68333, 0.08125, 0.05556, 0.83125],
3017
- "931": [0, 0.68333, 0.05764, 0.08334, 0.77986],
3018
- "933": [0, 0.68333, 0.13889, 0.05556, 0.58333],
3019
- "934": [0, 0.68333, 0, 0.08334, 0.66667],
3020
- "936": [0, 0.68333, 0.11, 0.05556, 0.61222],
3021
- "937": [0, 0.68333, 0.05017, 0.08334, 0.7724],
3022
- "945": [0, 0.43056, 0.0037, 0.02778, 0.6397],
3023
- "946": [0.19444, 0.69444, 0.05278, 0.08334, 0.56563],
3024
- "947": [0.19444, 0.43056, 0.05556, 0, 0.51773],
3025
- "948": [0, 0.69444, 0.03785, 0.05556, 0.44444],
3026
- "949": [0, 0.43056, 0, 0.08334, 0.46632],
3027
- "950": [0.19444, 0.69444, 0.07378, 0.08334, 0.4375],
3028
- "951": [0.19444, 0.43056, 0.03588, 0.05556, 0.49653],
3029
- "952": [0, 0.69444, 0.02778, 0.08334, 0.46944],
3030
- "953": [0, 0.43056, 0, 0.05556, 0.35394],
3031
- "954": [0, 0.43056, 0, 0, 0.57616],
3032
- "955": [0, 0.69444, 0, 0, 0.58334],
3033
- "956": [0.19444, 0.43056, 0, 0.02778, 0.60255],
3034
- "957": [0, 0.43056, 0.06366, 0.02778, 0.49398],
3035
- "958": [0.19444, 0.69444, 0.04601, 0.11111, 0.4375],
3036
- "959": [0, 0.43056, 0, 0.05556, 0.48472],
3037
- "960": [0, 0.43056, 0.03588, 0, 0.57003],
3038
- "961": [0.19444, 0.43056, 0, 0.08334, 0.51702],
3039
- "962": [0.09722, 0.43056, 0.07986, 0.08334, 0.36285],
3040
- "963": [0, 0.43056, 0.03588, 0, 0.57141],
3041
- "964": [0, 0.43056, 0.1132, 0.02778, 0.43715],
3042
- "965": [0, 0.43056, 0.03588, 0.02778, 0.54028],
3043
- "966": [0.19444, 0.43056, 0, 0.08334, 0.65417],
3044
- "967": [0.19444, 0.43056, 0, 0.05556, 0.62569],
3045
- "968": [0.19444, 0.69444, 0.03588, 0.11111, 0.65139],
3046
- "969": [0, 0.43056, 0.03588, 0, 0.62245],
3047
- "977": [0, 0.69444, 0, 0.08334, 0.59144],
3048
- "981": [0.19444, 0.69444, 0, 0.08334, 0.59583],
3049
- "982": [0, 0.43056, 0.02778, 0, 0.82813],
3050
- "1009": [0.19444, 0.43056, 0, 0.08334, 0.51702],
3051
- "1013": [0, 0.43056, 0, 0.05556, 0.4059]
2991
+ "1013": [0, 0.43056, 0, 0.05556, 0.4059],
2992
+ "57649": [0, 0.43056, 0, 0.02778, 0.32246],
2993
+ "57911": [0.19444, 0.43056, 0, 0.08334, 0.38403]
3052
2994
  },
3053
2995
  "SansSerif-Bold": {
2996
+ "32": [0, 0, 0, 0, 0.25],
3054
2997
  "33": [0, 0.69444, 0, 0, 0.36667],
3055
2998
  "34": [0, 0.69444, 0, 0, 0.55834],
3056
2999
  "35": [0.19444, 0.69444, 0, 0, 0.91667],
@@ -3138,6 +3081,7 @@ var metricMap = {
3138
3081
  "121": [0.19444, 0.45833, 0.01528, 0, 0.5],
3139
3082
  "122": [0, 0.45833, 0, 0, 0.47639],
3140
3083
  "126": [0.35, 0.34444, 0, 0, 0.55],
3084
+ "160": [0, 0, 0, 0, 0.25],
3141
3085
  "168": [0, 0.69444, 0, 0, 0.55],
3142
3086
  "176": [0, 0.69444, 0, 0, 0.73334],
3143
3087
  "180": [0, 0.69444, 0, 0, 0.55],
@@ -3171,6 +3115,7 @@ var metricMap = {
3171
3115
  "8221": [0, 0.69444, 0, 0, 0.55834]
3172
3116
  },
3173
3117
  "SansSerif-Italic": {
3118
+ "32": [0, 0, 0, 0, 0.25],
3174
3119
  "33": [0, 0.69444, 0.05733, 0, 0.31945],
3175
3120
  "34": [0, 0.69444, 0.00316, 0, 0.5],
3176
3121
  "35": [0.19444, 0.69444, 0.05087, 0, 0.83334],
@@ -3258,6 +3203,7 @@ var metricMap = {
3258
3203
  "121": [0.19444, 0.44444, 0.10836, 0, 0.46111],
3259
3204
  "122": [0, 0.44444, 0.08752, 0, 0.43472],
3260
3205
  "126": [0.35, 0.32659, 0.08826, 0, 0.5],
3206
+ "160": [0, 0, 0, 0, 0.25],
3261
3207
  "168": [0, 0.67937, 0.06385, 0, 0.5],
3262
3208
  "176": [0, 0.69444, 0, 0, 0.73752],
3263
3209
  "184": [0.17014, 0, 0, 0, 0.44445],
@@ -3292,6 +3238,7 @@ var metricMap = {
3292
3238
  "8221": [0, 0.69444, 0.00316, 0, 0.5]
3293
3239
  },
3294
3240
  "SansSerif-Regular": {
3241
+ "32": [0, 0, 0, 0, 0.25],
3295
3242
  "33": [0, 0.69444, 0, 0, 0.31945],
3296
3243
  "34": [0, 0.69444, 0, 0, 0.5],
3297
3244
  "35": [0.19444, 0.69444, 0, 0, 0.83334],
@@ -3379,6 +3326,7 @@ var metricMap = {
3379
3326
  "121": [0.19444, 0.44444, 0.01389, 0, 0.46111],
3380
3327
  "122": [0, 0.44444, 0, 0, 0.43472],
3381
3328
  "126": [0.35, 0.32659, 0, 0, 0.5],
3329
+ "160": [0, 0, 0, 0, 0.25],
3382
3330
  "168": [0, 0.67937, 0, 0, 0.5],
3383
3331
  "176": [0, 0.69444, 0, 0, 0.66667],
3384
3332
  "184": [0.17014, 0, 0, 0, 0.44445],
@@ -3413,6 +3361,7 @@ var metricMap = {
3413
3361
  "8221": [0, 0.69444, 0, 0, 0.5]
3414
3362
  },
3415
3363
  "Script-Regular": {
3364
+ "32": [0, 0, 0, 0, 0.25],
3416
3365
  "65": [0, 0.7, 0.22925, 0, 0.80253],
3417
3366
  "66": [0, 0.7, 0.04087, 0, 0.90757],
3418
3367
  "67": [0, 0.7, 0.1689, 0, 0.66619],
@@ -3438,9 +3387,11 @@ var metricMap = {
3438
3387
  "87": [0, 0.7, 0.27523, 0, 0.80532],
3439
3388
  "88": [0, 0.7, 0.26006, 0, 0.94445],
3440
3389
  "89": [0, 0.7, 0.2939, 0, 0.70961],
3441
- "90": [0, 0.7, 0.24037, 0, 0.8212]
3390
+ "90": [0, 0.7, 0.24037, 0, 0.8212],
3391
+ "160": [0, 0, 0, 0, 0.25]
3442
3392
  },
3443
3393
  "Size1-Regular": {
3394
+ "32": [0, 0, 0, 0, 0.25],
3444
3395
  "40": [0.35001, 0.85, 0, 0, 0.45834],
3445
3396
  "41": [0.35001, 0.85, 0, 0, 0.45834],
3446
3397
  "47": [0.35001, 0.85, 0, 0, 0.57778],
@@ -3449,6 +3400,7 @@ var metricMap = {
3449
3400
  "93": [0.35001, 0.85, 0, 0, 0.41667],
3450
3401
  "123": [0.35001, 0.85, 0, 0, 0.58334],
3451
3402
  "125": [0.35001, 0.85, 0, 0, 0.58334],
3403
+ "160": [0, 0, 0, 0, 0.25],
3452
3404
  "710": [0, 0.72222, 0, 0, 0.55556],
3453
3405
  "732": [0, 0.72222, 0, 0, 0.55556],
3454
3406
  "770": [0, 0.72222, 0, 0, 0.55556],
@@ -3486,6 +3438,7 @@ var metricMap = {
3486
3438
  "10758": [0.25001, 0.75, 0, 0, 0.83334]
3487
3439
  },
3488
3440
  "Size2-Regular": {
3441
+ "32": [0, 0, 0, 0, 0.25],
3489
3442
  "40": [0.65002, 1.15, 0, 0, 0.59722],
3490
3443
  "41": [0.65002, 1.15, 0, 0, 0.59722],
3491
3444
  "47": [0.65002, 1.15, 0, 0, 0.81111],
@@ -3494,6 +3447,7 @@ var metricMap = {
3494
3447
  "93": [0.65002, 1.15, 0, 0, 0.47222],
3495
3448
  "123": [0.65002, 1.15, 0, 0, 0.66667],
3496
3449
  "125": [0.65002, 1.15, 0, 0, 0.66667],
3450
+ "160": [0, 0, 0, 0, 0.25],
3497
3451
  "710": [0, 0.75, 0, 0, 1.0],
3498
3452
  "732": [0, 0.75, 0, 0, 1.0],
3499
3453
  "770": [0, 0.75, 0, 0, 1.0],
@@ -3523,6 +3477,7 @@ var metricMap = {
3523
3477
  "10758": [0.55001, 1.05, 0, 0, 1.11111]
3524
3478
  },
3525
3479
  "Size3-Regular": {
3480
+ "32": [0, 0, 0, 0, 0.25],
3526
3481
  "40": [0.95003, 1.45, 0, 0, 0.73611],
3527
3482
  "41": [0.95003, 1.45, 0, 0, 0.73611],
3528
3483
  "47": [0.95003, 1.45, 0, 0, 1.04445],
@@ -3531,6 +3486,7 @@ var metricMap = {
3531
3486
  "93": [0.95003, 1.45, 0, 0, 0.52778],
3532
3487
  "123": [0.95003, 1.45, 0, 0, 0.75],
3533
3488
  "125": [0.95003, 1.45, 0, 0, 0.75],
3489
+ "160": [0, 0, 0, 0, 0.25],
3534
3490
  "710": [0, 0.75, 0, 0, 1.44445],
3535
3491
  "732": [0, 0.75, 0, 0, 1.44445],
3536
3492
  "770": [0, 0.75, 0, 0, 1.44445],
@@ -3544,6 +3500,7 @@ var metricMap = {
3544
3500
  "10217": [0.95003, 1.45, 0, 0, 0.75]
3545
3501
  },
3546
3502
  "Size4-Regular": {
3503
+ "32": [0, 0, 0, 0, 0.25],
3547
3504
  "40": [1.25003, 1.75, 0, 0, 0.79167],
3548
3505
  "41": [1.25003, 1.75, 0, 0, 0.79167],
3549
3506
  "47": [1.25003, 1.75, 0, 0, 1.27778],
@@ -3552,6 +3509,7 @@ var metricMap = {
3552
3509
  "93": [1.25003, 1.75, 0, 0, 0.58334],
3553
3510
  "123": [1.25003, 1.75, 0, 0, 0.80556],
3554
3511
  "125": [1.25003, 1.75, 0, 0, 0.80556],
3512
+ "160": [0, 0, 0, 0, 0.25],
3555
3513
  "710": [0, 0.825, 0, 0, 1.8889],
3556
3514
  "732": [0, 0.825, 0, 0, 1.8889],
3557
3515
  "770": [0, 0.825, 0, 0, 1.8889],
@@ -4256,9 +4214,10 @@ defineSymbol(math, ams, textord, "\u25a0", "\\blacksquare");
4256
4214
  defineSymbol(math, ams, textord, "\u29eb", "\\blacklozenge");
4257
4215
  defineSymbol(math, ams, textord, "\u2605", "\\bigstar");
4258
4216
  defineSymbol(math, ams, textord, "\u2222", "\\sphericalangle", true);
4259
- defineSymbol(math, ams, textord, "\u2201", "\\complement", true); // unicode-math maps U+F0 (ð) to \matheth. We map to AMS function \eth
4217
+ defineSymbol(math, ams, textord, "\u2201", "\\complement", true); // unicode-math maps U+F0 to \matheth. We map to AMS function \eth
4260
4218
 
4261
4219
  defineSymbol(math, ams, textord, "\u00f0", "\\eth", true);
4220
+ defineSymbol(text$1, main, textord, "\u00f0", "\u00f0");
4262
4221
  defineSymbol(math, ams, textord, "\u2571", "\\diagup");
4263
4222
  defineSymbol(math, ams, textord, "\u2572", "\\diagdown");
4264
4223
  defineSymbol(math, ams, textord, "\u25a1", "\\square");
@@ -4277,10 +4236,10 @@ defineSymbol(math, ams, textord, "\u2137", "\\gimel", true); // AMS Greek
4277
4236
  defineSymbol(math, ams, textord, "\u03dd", "\\digamma", true);
4278
4237
  defineSymbol(math, ams, textord, "\u03f0", "\\varkappa"); // AMS Delimiters
4279
4238
 
4280
- defineSymbol(math, ams, open, "\u250c", "\\ulcorner", true);
4281
- defineSymbol(math, ams, close, "\u2510", "\\urcorner", true);
4282
- defineSymbol(math, ams, open, "\u2514", "\\llcorner", true);
4283
- defineSymbol(math, ams, close, "\u2518", "\\lrcorner", true); // AMS Binary Relations
4239
+ defineSymbol(math, ams, open, "\u250c", "\\@ulcorner", true);
4240
+ defineSymbol(math, ams, close, "\u2510", "\\@urcorner", true);
4241
+ defineSymbol(math, ams, open, "\u2514", "\\@llcorner", true);
4242
+ defineSymbol(math, ams, close, "\u2518", "\\@lrcorner", true); // AMS Binary Relations
4284
4243
 
4285
4244
  defineSymbol(math, ams, rel, "\u2266", "\\leqq", true);
4286
4245
  defineSymbol(math, ams, rel, "\u2a7d", "\\leqslant", true);
@@ -4508,28 +4467,22 @@ defineSymbol(math, main, bin, "\u2228", "\\lor");
4508
4467
  defineSymbol(math, main, bin, "\u2227", "\\wedge", true);
4509
4468
  defineSymbol(math, main, bin, "\u2228", "\\vee", true);
4510
4469
  defineSymbol(math, main, textord, "\u221a", "\\surd");
4511
- defineSymbol(math, main, open, "(", "(");
4512
- defineSymbol(math, main, open, "[", "[");
4513
4470
  defineSymbol(math, main, open, "\u27e8", "\\langle", true);
4514
4471
  defineSymbol(math, main, open, "\u2223", "\\lvert");
4515
4472
  defineSymbol(math, main, open, "\u2225", "\\lVert");
4516
- defineSymbol(math, main, close, ")", ")");
4517
- defineSymbol(math, main, close, "]", "]");
4518
4473
  defineSymbol(math, main, close, "?", "?");
4519
4474
  defineSymbol(math, main, close, "!", "!");
4520
4475
  defineSymbol(math, main, close, "\u27e9", "\\rangle", true);
4521
4476
  defineSymbol(math, main, close, "\u2223", "\\rvert");
4522
4477
  defineSymbol(math, main, close, "\u2225", "\\rVert");
4523
4478
  defineSymbol(math, main, rel, "=", "=");
4524
- defineSymbol(math, main, rel, "<", "<");
4525
- defineSymbol(math, main, rel, ">", ">");
4526
4479
  defineSymbol(math, main, rel, ":", ":");
4527
4480
  defineSymbol(math, main, rel, "\u2248", "\\approx", true);
4528
4481
  defineSymbol(math, main, rel, "\u2245", "\\cong", true);
4529
4482
  defineSymbol(math, main, rel, "\u2265", "\\ge");
4530
4483
  defineSymbol(math, main, rel, "\u2265", "\\geq", true);
4531
4484
  defineSymbol(math, main, rel, "\u2190", "\\gets");
4532
- defineSymbol(math, main, rel, ">", "\\gt");
4485
+ defineSymbol(math, main, rel, ">", "\\gt", true);
4533
4486
  defineSymbol(math, main, rel, "\u2208", "\\in", true);
4534
4487
  defineSymbol(math, main, rel, "\ue020", "\\@not");
4535
4488
  defineSymbol(math, main, rel, "\u2282", "\\subset", true);
@@ -4542,7 +4495,7 @@ defineSymbol(math, main, rel, "\u22a8", "\\models");
4542
4495
  defineSymbol(math, main, rel, "\u2190", "\\leftarrow", true);
4543
4496
  defineSymbol(math, main, rel, "\u2264", "\\le");
4544
4497
  defineSymbol(math, main, rel, "\u2264", "\\leq", true);
4545
- defineSymbol(math, main, rel, "<", "\\lt");
4498
+ defineSymbol(math, main, rel, "<", "\\lt", true);
4546
4499
  defineSymbol(math, main, rel, "\u2192", "\\rightarrow", true);
4547
4500
  defineSymbol(math, main, rel, "\u2192", "\\to");
4548
4501
  defineSymbol(math, ams, rel, "\u2271", "\\ngeq", true);
@@ -4553,6 +4506,7 @@ defineSymbol(math, main, spacing, "\u00a0", "\\space"); // Ref: LaTeX Source 2e:
4553
4506
 
4554
4507
  defineSymbol(math, main, spacing, "\u00a0", "\\nobreakspace");
4555
4508
  defineSymbol(text$1, main, spacing, "\u00a0", "\\ ");
4509
+ defineSymbol(text$1, main, spacing, "\u00a0", " ");
4556
4510
  defineSymbol(text$1, main, spacing, "\u00a0", "~");
4557
4511
  defineSymbol(text$1, main, spacing, "\u00a0", "\\space");
4558
4512
  defineSymbol(text$1, main, spacing, "\u00a0", "\\nobreakspace");
@@ -4584,15 +4538,15 @@ defineSymbol(text$1, main, textord, "}", "\\}");
4584
4538
  defineSymbol(text$1, main, textord, "}", "\\textbraceright");
4585
4539
  defineSymbol(math, main, open, "{", "\\lbrace");
4586
4540
  defineSymbol(math, main, close, "}", "\\rbrace");
4587
- defineSymbol(math, main, open, "[", "\\lbrack");
4588
- defineSymbol(text$1, main, textord, "[", "\\lbrack");
4589
- defineSymbol(math, main, close, "]", "\\rbrack");
4590
- defineSymbol(text$1, main, textord, "]", "\\rbrack");
4591
- defineSymbol(math, main, open, "(", "\\lparen");
4592
- defineSymbol(math, main, close, ")", "\\rparen");
4593
- defineSymbol(text$1, main, textord, "<", "\\textless"); // in T1 fontenc
4541
+ defineSymbol(math, main, open, "[", "\\lbrack", true);
4542
+ defineSymbol(text$1, main, textord, "[", "\\lbrack", true);
4543
+ defineSymbol(math, main, close, "]", "\\rbrack", true);
4544
+ defineSymbol(text$1, main, textord, "]", "\\rbrack", true);
4545
+ defineSymbol(math, main, open, "(", "\\lparen", true);
4546
+ defineSymbol(math, main, close, ")", "\\rparen", true);
4547
+ defineSymbol(text$1, main, textord, "<", "\\textless", true); // in T1 fontenc
4594
4548
 
4595
- defineSymbol(text$1, main, textord, ">", "\\textgreater"); // in T1 fontenc
4549
+ defineSymbol(text$1, main, textord, ">", "\\textgreater", true); // in T1 fontenc
4596
4550
 
4597
4551
  defineSymbol(math, main, open, "\u230a", "\\lfloor", true);
4598
4552
  defineSymbol(math, main, close, "\u230b", "\\rfloor", true);
@@ -4601,7 +4555,7 @@ defineSymbol(math, main, close, "\u2309", "\\rceil", true);
4601
4555
  defineSymbol(math, main, textord, "\\", "\\backslash");
4602
4556
  defineSymbol(math, main, textord, "\u2223", "|");
4603
4557
  defineSymbol(math, main, textord, "\u2223", "\\vert");
4604
- defineSymbol(text$1, main, textord, "|", "\\textbar"); // in T1 fontenc
4558
+ defineSymbol(text$1, main, textord, "|", "\\textbar", true); // in T1 fontenc
4605
4559
 
4606
4560
  defineSymbol(math, main, textord, "\u2225", "\\|");
4607
4561
  defineSymbol(math, main, textord, "\u2225", "\\Vert");
@@ -4631,8 +4585,6 @@ defineSymbol(math, main, op, "\u2a02", "\\bigotimes");
4631
4585
  defineSymbol(math, main, op, "\u2a01", "\\bigoplus");
4632
4586
  defineSymbol(math, main, op, "\u2a00", "\\bigodot");
4633
4587
  defineSymbol(math, main, op, "\u222e", "\\oint");
4634
- defineSymbol(math, main, op, "\u222f", "\\oiint");
4635
- defineSymbol(math, main, op, "\u2230", "\\oiiint");
4636
4588
  defineSymbol(math, main, op, "\u2a06", "\\bigsqcup");
4637
4589
  defineSymbol(math, main, op, "\u222b", "\\smallint");
4638
4590
  defineSymbol(text$1, main, inner, "\u2026", "\\textellipsis");
@@ -4653,14 +4605,16 @@ defineSymbol(math, main, accent, "\u02c7", "\\check");
4653
4605
  defineSymbol(math, main, accent, "\u005e", "\\hat");
4654
4606
  defineSymbol(math, main, accent, "\u20d7", "\\vec");
4655
4607
  defineSymbol(math, main, accent, "\u02d9", "\\dot");
4656
- defineSymbol(math, main, accent, "\u02da", "\\mathring");
4657
- defineSymbol(math, main, mathord, "\u0131", "\\imath", true);
4658
- defineSymbol(math, main, mathord, "\u0237", "\\jmath", true);
4608
+ defineSymbol(math, main, accent, "\u02da", "\\mathring"); // \imath and \jmath should be invariant to \mathrm, \mathbf, etc., so use PUA
4609
+
4610
+ defineSymbol(math, main, mathord, "\ue131", "\\@imath");
4611
+ defineSymbol(math, main, mathord, "\ue237", "\\@jmath");
4612
+ defineSymbol(math, main, textord, "\u0131", "\u0131");
4613
+ defineSymbol(math, main, textord, "\u0237", "\u0237");
4659
4614
  defineSymbol(text$1, main, textord, "\u0131", "\\i", true);
4660
4615
  defineSymbol(text$1, main, textord, "\u0237", "\\j", true);
4661
4616
  defineSymbol(text$1, main, textord, "\u00df", "\\ss", true);
4662
4617
  defineSymbol(text$1, main, textord, "\u00e6", "\\ae", true);
4663
- defineSymbol(text$1, main, textord, "\u00e6", "\\ae", true);
4664
4618
  defineSymbol(text$1, main, textord, "\u0153", "\\oe", true);
4665
4619
  defineSymbol(text$1, main, textord, "\u00f8", "\\o", true);
4666
4620
  defineSymbol(text$1, main, textord, "\u00c6", "\\AE", true);
@@ -4697,34 +4651,31 @@ const ligatures = {
4697
4651
  "``": true,
4698
4652
  "''": true
4699
4653
  };
4700
- defineSymbol(text$1, main, textord, "\u2013", "--");
4654
+ defineSymbol(text$1, main, textord, "\u2013", "--", true);
4701
4655
  defineSymbol(text$1, main, textord, "\u2013", "\\textendash");
4702
- defineSymbol(text$1, main, textord, "\u2014", "---");
4656
+ defineSymbol(text$1, main, textord, "\u2014", "---", true);
4703
4657
  defineSymbol(text$1, main, textord, "\u2014", "\\textemdash");
4704
- defineSymbol(text$1, main, textord, "\u2018", "`");
4658
+ defineSymbol(text$1, main, textord, "\u2018", "`", true);
4705
4659
  defineSymbol(text$1, main, textord, "\u2018", "\\textquoteleft");
4706
- defineSymbol(text$1, main, textord, "\u2019", "'");
4660
+ defineSymbol(text$1, main, textord, "\u2019", "'", true);
4707
4661
  defineSymbol(text$1, main, textord, "\u2019", "\\textquoteright");
4708
- defineSymbol(text$1, main, textord, "\u201c", "``");
4662
+ defineSymbol(text$1, main, textord, "\u201c", "``", true);
4709
4663
  defineSymbol(text$1, main, textord, "\u201c", "\\textquotedblleft");
4710
- defineSymbol(text$1, main, textord, "\u201d", "''");
4664
+ defineSymbol(text$1, main, textord, "\u201d", "''", true);
4711
4665
  defineSymbol(text$1, main, textord, "\u201d", "\\textquotedblright"); // \degree from gensymb package
4712
4666
 
4713
4667
  defineSymbol(math, main, textord, "\u00b0", "\\degree", true);
4714
4668
  defineSymbol(text$1, main, textord, "\u00b0", "\\degree"); // \textdegree from inputenc package
4715
4669
 
4716
4670
  defineSymbol(text$1, main, textord, "\u00b0", "\\textdegree", true); // TODO: In LaTeX, \pounds can generate a different character in text and math
4717
- // mode, but among our fonts, only Main-Italic defines this character "163".
4671
+ // mode, but among our fonts, only Main-Regular defines this character "163".
4718
4672
 
4719
- defineSymbol(math, main, mathord, "\u00a3", "\\pounds");
4720
- defineSymbol(math, main, mathord, "\u00a3", "\\mathsterling", true);
4721
- defineSymbol(text$1, main, mathord, "\u00a3", "\\pounds");
4722
- defineSymbol(text$1, main, mathord, "\u00a3", "\\textsterling", true);
4673
+ defineSymbol(math, main, textord, "\u00a3", "\\pounds");
4674
+ defineSymbol(math, main, textord, "\u00a3", "\\mathsterling", true);
4675
+ defineSymbol(text$1, main, textord, "\u00a3", "\\pounds");
4676
+ defineSymbol(text$1, main, textord, "\u00a3", "\\textsterling", true);
4723
4677
  defineSymbol(math, ams, textord, "\u2720", "\\maltese");
4724
- defineSymbol(text$1, ams, textord, "\u2720", "\\maltese");
4725
- defineSymbol(text$1, main, spacing, "\u00a0", "\\ ");
4726
- defineSymbol(text$1, main, spacing, "\u00a0", " ");
4727
- defineSymbol(text$1, main, spacing, "\u00a0", "~"); // There are lots of symbols which are the same, so we add them in afterwards.
4678
+ defineSymbol(text$1, ams, textord, "\u2720", "\\maltese"); // There are lots of symbols which are the same, so we add them in afterwards.
4728
4679
  // All of these are textords in math mode
4729
4680
 
4730
4681
  const mathTextSymbols = "0123456789/@.\"";
@@ -4735,7 +4686,7 @@ for (let i = 0; i < mathTextSymbols.length; i++) {
4735
4686
  } // All of these are textords in text mode
4736
4687
 
4737
4688
 
4738
- const textSymbols = "0123456789!@*()-=+[]<>|\";:?/.,";
4689
+ const textSymbols = "0123456789!@*()-=+\";:?/.,";
4739
4690
 
4740
4691
  for (let i = 0; i < textSymbols.length; i++) {
4741
4692
  const ch = textSymbols.charAt(i);
@@ -4860,7 +4811,7 @@ for (let i = 0; i < 10; i++) {
4860
4811
  // TODO(edemaine): Fix this.
4861
4812
 
4862
4813
 
4863
- const extraLatin = "ÇÐÞçþ";
4814
+ const extraLatin = "\u00c7\u00d0\u00de\u00e7\u00fe";
4864
4815
 
4865
4816
  for (let i = 0; i < extraLatin.length; i++) {
4866
4817
  const ch = extraLatin.charAt(i);
@@ -4868,15 +4819,6 @@ for (let i = 0; i < extraLatin.length; i++) {
4868
4819
  defineSymbol(text$1, main, textord, ch, ch);
4869
4820
  }
4870
4821
 
4871
- defineSymbol(text$1, main, textord, "ð", "ð"); // Unicode versions of existing characters
4872
-
4873
- defineSymbol(text$1, main, textord, "\u2013", "–");
4874
- defineSymbol(text$1, main, textord, "\u2014", "—");
4875
- defineSymbol(text$1, main, textord, "\u2018", "‘");
4876
- defineSymbol(text$1, main, textord, "\u2019", "’");
4877
- defineSymbol(text$1, main, textord, "\u201c", "“");
4878
- defineSymbol(text$1, main, textord, "\u201d", "”");
4879
-
4880
4822
  /**
4881
4823
  * This file provides support for Unicode range U+1D400 to U+1D7FF,
4882
4824
  * Mathematical Alphanumeric Symbols.
@@ -4896,8 +4838,8 @@ defineSymbol(text$1, main, textord, "\u201d", "”");
4896
4838
 
4897
4839
  const wideLatinLetterData = [["mathbf", "textbf", "Main-Bold"], // A-Z bold upright
4898
4840
  ["mathbf", "textbf", "Main-Bold"], // a-z bold upright
4899
- ["mathdefault", "textit", "Math-Italic"], // A-Z italic
4900
- ["mathdefault", "textit", "Math-Italic"], // a-z italic
4841
+ ["mathnormal", "textit", "Math-Italic"], // A-Z italic
4842
+ ["mathnormal", "textit", "Math-Italic"], // a-z italic
4901
4843
  ["boldsymbol", "boldsymbol", "Main-BoldItalic"], // A-Z bold italic
4902
4844
  ["boldsymbol", "boldsymbol", "Main-BoldItalic"], // a-z bold italic
4903
4845
  // Map fancy A-Z letters to script, not calligraphic.
@@ -5378,15 +5320,11 @@ const calculateSize = function calculateSize(sizeValue, options) {
5378
5320
  };
5379
5321
 
5380
5322
  /* eslint no-console:0 */
5381
- // The following have to be loaded from Main-Italic font, using class mathit
5382
- const mathitLetters = ["\\imath", "ı", // dotless i
5383
- "\\jmath", "ȷ", // dotless j
5384
- "\\pounds", "\\mathsterling", "\\textsterling", "£"];
5323
+
5385
5324
  /**
5386
5325
  * Looks up the given symbol in fontMetrics, after applying any symbol
5387
5326
  * replacements defined in symbol.js
5388
5327
  */
5389
-
5390
5328
  const lookupSymbol = function lookupSymbol(value, // TODO(#963): Use a union type for this.
5391
5329
  fontName, mode) {
5392
5330
  // Replace the value with its replaced value from symbol.js
@@ -5473,54 +5411,6 @@ const mathsym = function mathsym(value, mode, options, classes) {
5473
5411
  return makeSymbol(value, "AMS-Regular", mode, options, classes.concat(["amsrm"]));
5474
5412
  }
5475
5413
  };
5476
- /**
5477
- * Determines which of the two font names (Main-Italic and Math-Italic) and
5478
- * corresponding style tags (maindefault or mathit) to use for default math font,
5479
- * depending on the symbol.
5480
- */
5481
-
5482
-
5483
- const mathdefault = function mathdefault(value, mode, options, classes) {
5484
- if (/[0-9]/.test(value.charAt(0)) || // glyphs for \imath and \jmath do not exist in Math-Italic so we
5485
- // need to use Main-Italic instead
5486
- utils.contains(mathitLetters, value)) {
5487
- return {
5488
- fontName: "Main-Italic",
5489
- fontClass: "mathit"
5490
- };
5491
- } else {
5492
- return {
5493
- fontName: "Math-Italic",
5494
- fontClass: "mathdefault"
5495
- };
5496
- }
5497
- };
5498
- /**
5499
- * Determines which of the font names (Main-Italic, Math-Italic, and Caligraphic)
5500
- * and corresponding style tags (mathit, mathdefault, or mathcal) to use for font
5501
- * "mathnormal", depending on the symbol. Use this function instead of fontMap for
5502
- * font "mathnormal".
5503
- */
5504
-
5505
-
5506
- const mathnormal = function mathnormal(value, mode, options, classes) {
5507
- if (utils.contains(mathitLetters, value)) {
5508
- return {
5509
- fontName: "Main-Italic",
5510
- fontClass: "mathit"
5511
- };
5512
- } else if (/[0-9]/.test(value.charAt(0))) {
5513
- return {
5514
- fontName: "Caligraphic-Regular",
5515
- fontClass: "mathcal"
5516
- };
5517
- } else {
5518
- return {
5519
- fontName: "Math-Italic",
5520
- fontClass: "mathdefault"
5521
- };
5522
- }
5523
- };
5524
5414
  /**
5525
5415
  * Determines which of the two font names (Main-Bold and Math-BoldItalic) and
5526
5416
  * corresponding style tags (mathbf or boldsymbol) to use for font "boldsymbol",
@@ -5529,8 +5419,8 @@ const mathnormal = function mathnormal(value, mode, options, classes) {
5529
5419
  */
5530
5420
 
5531
5421
 
5532
- const boldsymbol = function boldsymbol(value, mode, options, classes) {
5533
- if (lookupSymbol(value, "Math-BoldItalic", mode).metrics) {
5422
+ const boldsymbol = function boldsymbol(value, mode, options, classes, type) {
5423
+ if (type !== "textord" && lookupSymbol(value, "Math-BoldItalic", mode).metrics) {
5534
5424
  return {
5535
5425
  fontName: "Math-BoldItalic",
5536
5426
  fontClass: "boldsymbol"
@@ -5568,13 +5458,10 @@ const makeOrd = function makeOrd(group, options, type) {
5568
5458
  let fontName;
5569
5459
  let fontClasses;
5570
5460
 
5571
- if (fontOrFamily === "boldsymbol" || fontOrFamily === "mathnormal") {
5572
- const fontData = fontOrFamily === "boldsymbol" ? boldsymbol(text, mode, options, classes) : mathnormal(text, mode, options, classes);
5461
+ if (fontOrFamily === "boldsymbol") {
5462
+ const fontData = boldsymbol(text, mode, options, classes, type);
5573
5463
  fontName = fontData.fontName;
5574
5464
  fontClasses = [fontData.fontClass];
5575
- } else if (utils.contains(mathitLetters, text)) {
5576
- fontName = "Main-Italic";
5577
- fontClasses = ["mathit"];
5578
5465
  } else if (isFont) {
5579
5466
  fontName = fontMap[fontOrFamily].fontName;
5580
5467
  fontClasses = [fontOrFamily];
@@ -5599,8 +5486,7 @@ const makeOrd = function makeOrd(group, options, type) {
5599
5486
 
5600
5487
 
5601
5488
  if (type === "mathord") {
5602
- const fontLookup = mathdefault(text, mode, options, classes);
5603
- return makeSymbol(text, fontLookup.fontName, mode, options, classes.concat([fontLookup.fontClass]));
5489
+ return makeSymbol(text, "Math-Italic", mode, options, classes.concat(["mathnormal"]));
5604
5490
  } else if (type === "textord") {
5605
5491
  const font = symbols[mode][text] && symbols[mode][text].font;
5606
5492
 
@@ -6012,12 +5898,13 @@ const fontMap = {
6012
5898
  variant: "italic",
6013
5899
  fontName: "Main-Italic"
6014
5900
  },
6015
- // Default math font, "mathnormal" and "boldsymbol" are missing because they
6016
- // require the use of several fonts: Main-Italic and Math-Italic for default
6017
- // math font, Main-Italic, Math-Italic, Caligraphic for "mathnormal", and
6018
- // Math-BoldItalic and Main-Bold for "boldsymbol". This is handled by a
6019
- // special case in makeOrd which ends up calling mathdefault, mathnormal,
6020
- // and boldsymbol.
5901
+ "mathnormal": {
5902
+ variant: "italic",
5903
+ fontName: "Math-Italic"
5904
+ },
5905
+ // "boldsymbol" is missing because they require the use of multiple fonts:
5906
+ // Math-BoldItalic and Main-Bold. This is handled by a special case in
5907
+ // makeOrd which ends up calling boldsymbol.
6021
5908
  // families
6022
5909
  "mathbb": {
6023
5910
  variant: "double-struck",
@@ -6052,7 +5939,9 @@ const svgData = {
6052
5939
  // oval to overlay the integrand
6053
5940
  oiintSize2: ["oiintSize2", 1.472, 0.659],
6054
5941
  oiiintSize1: ["oiiintSize1", 1.304, 0.499],
6055
- oiiintSize2: ["oiiintSize2", 1.98, 0.659]
5942
+ oiiintSize2: ["oiiintSize2", 1.98, 0.659],
5943
+ leftParenInner: ["leftParenInner", 0.875, 0.3],
5944
+ rightParenInner: ["rightParenInner", 0.875, 0.3]
6056
5945
  };
6057
5946
 
6058
5947
  const staticSvg = function staticSvg(value, options) {
@@ -6095,86 +5984,6 @@ var buildCommon = {
6095
5984
  tryCombineChars
6096
5985
  };
6097
5986
 
6098
- /**
6099
- * Asserts that the node is of the given type and returns it with stricter
6100
- * typing. Throws if the node's type does not match.
6101
- */
6102
- function assertNodeType(node, type) {
6103
- const typedNode = checkNodeType(node, type);
6104
-
6105
- if (!typedNode) {
6106
- throw new Error(`Expected node of type ${type}, but got ` + (node ? `node of type ${node.type}` : String(node)));
6107
- } // $FlowFixMe: Unsure why.
6108
-
6109
-
6110
- return typedNode;
6111
- }
6112
- /**
6113
- * Returns the node more strictly typed iff it is of the given type. Otherwise,
6114
- * returns null.
6115
- */
6116
-
6117
- function checkNodeType(node, type) {
6118
- if (node && node.type === type) {
6119
- // The definition of ParseNode<TYPE> doesn't communicate to flow that
6120
- // `type: TYPE` (as that's not explicitly mentioned anywhere), though that
6121
- // happens to be true for all our value types.
6122
- // $FlowFixMe
6123
- return node;
6124
- }
6125
-
6126
- return null;
6127
- }
6128
- /**
6129
- * Asserts that the node is of the given type and returns it with stricter
6130
- * typing. Throws if the node's type does not match.
6131
- */
6132
-
6133
- function assertAtomFamily(node, family) {
6134
- const typedNode = checkAtomFamily(node, family);
6135
-
6136
- if (!typedNode) {
6137
- throw new Error(`Expected node of type "atom" and family "${family}", but got ` + (node ? node.type === "atom" ? `atom of family ${node.family}` : `node of type ${node.type}` : String(node)));
6138
- }
6139
-
6140
- return typedNode;
6141
- }
6142
- /**
6143
- * Returns the node more strictly typed iff it is of the given type. Otherwise,
6144
- * returns null.
6145
- */
6146
-
6147
- function checkAtomFamily(node, family) {
6148
- return node && node.type === "atom" && node.family === family ? node : null;
6149
- }
6150
- /**
6151
- * Returns the node more strictly typed iff it is of the given type. Otherwise,
6152
- * returns null.
6153
- */
6154
-
6155
- function assertSymbolNodeType(node) {
6156
- const typedNode = checkSymbolNodeType(node);
6157
-
6158
- if (!typedNode) {
6159
- throw new Error(`Expected node of symbol group type, but got ` + (node ? `node of type ${node.type}` : String(node)));
6160
- }
6161
-
6162
- return typedNode;
6163
- }
6164
- /**
6165
- * Returns the node more strictly typed iff it is of the given type. Otherwise,
6166
- * returns null.
6167
- */
6168
-
6169
- function checkSymbolNodeType(node) {
6170
- if (node && (node.type === "atom" || NON_ATOMS.hasOwnProperty(node.type))) {
6171
- // $FlowFixMe
6172
- return node;
6173
- }
6174
-
6175
- return null;
6176
- }
6177
-
6178
5987
  /**
6179
5988
  * Describes spaces between different classes of atoms.
6180
5989
  */
@@ -6268,6 +6077,21 @@ const tightSpacings = {
6268
6077
  }
6269
6078
  };
6270
6079
 
6080
+ /** Context provided to function handlers for error messages. */
6081
+ // Note: reverse the order of the return type union will cause a flow error.
6082
+ // See https://github.com/facebook/flow/issues/3663.
6083
+ // More general version of `HtmlBuilder` for nodes (e.g. \sum, accent types)
6084
+ // whose presence impacts super/subscripting. In this case, ParseNode<"supsub">
6085
+ // delegates its HTML building to the HtmlBuilder corresponding to these nodes.
6086
+
6087
+ /**
6088
+ * Final function spec for use at parse time.
6089
+ * This is almost identical to `FunctionPropSpec`, except it
6090
+ * 1. includes the function handler, and
6091
+ * 2. requires all arguments except argTypes.
6092
+ * It is generated by `defineFunction()` below.
6093
+ */
6094
+
6271
6095
  /**
6272
6096
  * All registered functions.
6273
6097
  * `functions.js` just exports this same dictionary again and makes it public.
@@ -6348,8 +6172,7 @@ function defineFunctionBuilders(_ref2) {
6348
6172
  // list of elements, we normalize for different kinds of arguments
6349
6173
 
6350
6174
  const ordargument = function ordargument(arg) {
6351
- const node = checkNodeType(arg, "ordgroup");
6352
- return node ? node.body : [arg];
6175
+ return arg.type === "ordgroup" ? arg.body : [arg];
6353
6176
  };
6354
6177
 
6355
6178
  /**
@@ -6417,9 +6240,9 @@ const buildExpression = function buildExpression(expression, options, isRealGrou
6417
6240
  let glueOptions = options;
6418
6241
 
6419
6242
  if (expression.length === 1) {
6420
- const node = checkNodeType(expression[0], "sizing") || checkNodeType(expression[0], "styling");
6243
+ const node = expression[0];
6421
6244
 
6422
- if (!node) ; else if (node.type === "sizing") {
6245
+ if (node.type === "sizing") {
6423
6246
  glueOptions = options.havingSize(node.size);
6424
6247
  } else if (node.type === "styling") {
6425
6248
  glueOptions = options.havingStyle(styleMap[node.style]);
@@ -6436,6 +6259,7 @@ const buildExpression = function buildExpression(expression, options, isRealGrou
6436
6259
  // Before determining what spaces to insert, perform bin cancellation.
6437
6260
  // Binary operators change to ordinary symbols in some contexts.
6438
6261
 
6262
+ const isRoot = isRealGroup === "root";
6439
6263
  traverseNonSpaceNodes(groups, (node, prev) => {
6440
6264
  const prevType = prev.classes[0];
6441
6265
  const type = node.classes[0];
@@ -6447,7 +6271,7 @@ const buildExpression = function buildExpression(expression, options, isRealGrou
6447
6271
  }
6448
6272
  }, {
6449
6273
  node: dummyPrev
6450
- }, dummyNext);
6274
+ }, dummyNext, isRoot);
6451
6275
  traverseNonSpaceNodes(groups, (node, prev) => {
6452
6276
  const prevType = getTypeOfDomTree(prev);
6453
6277
  const type = getTypeOfDomTree(node); // 'mtight' indicates that the node is script or scriptscript style.
@@ -6460,7 +6284,7 @@ const buildExpression = function buildExpression(expression, options, isRealGrou
6460
6284
  }
6461
6285
  }, {
6462
6286
  node: dummyPrev
6463
- }, dummyNext);
6287
+ }, dummyNext, isRoot);
6464
6288
  return groups;
6465
6289
  }; // Depth-first traverse non-space `nodes`, calling `callback` with the current and
6466
6290
  // previous node as arguments, optionally returning a node to insert after the
@@ -6468,7 +6292,7 @@ const buildExpression = function buildExpression(expression, options, isRealGrou
6468
6292
  // function to insert after it. `next` is a node that will be added to the right.
6469
6293
  // Used for bin cancellation and inserting spacings.
6470
6294
 
6471
- const traverseNonSpaceNodes = function traverseNonSpaceNodes(nodes, callback, prev, next) {
6295
+ const traverseNonSpaceNodes = function traverseNonSpaceNodes(nodes, callback, prev, next, isRoot) {
6472
6296
  if (next) {
6473
6297
  // temporarily append the right node, if exists
6474
6298
  nodes.push(next);
@@ -6483,29 +6307,33 @@ const traverseNonSpaceNodes = function traverseNonSpaceNodes(nodes, callback, pr
6483
6307
  if (partialGroup) {
6484
6308
  // Recursive DFS
6485
6309
  // $FlowFixMe: make nodes a $ReadOnlyArray by returning a new array
6486
- traverseNonSpaceNodes(partialGroup.children, callback, prev);
6310
+ traverseNonSpaceNodes(partialGroup.children, callback, prev, null, isRoot);
6487
6311
  continue;
6488
6312
  } // Ignore explicit spaces (e.g., \;, \,) when determining what implicit
6489
6313
  // spacing should go between atoms of different classes
6490
6314
 
6491
6315
 
6492
- if (node.classes[0] === "mspace") {
6493
- continue;
6494
- }
6316
+ const nonspace = !node.hasClass("mspace");
6495
6317
 
6496
- const result = callback(node, prev.node);
6318
+ if (nonspace) {
6319
+ const result = callback(node, prev.node);
6497
6320
 
6498
- if (result) {
6499
- if (prev.insertAfter) {
6500
- prev.insertAfter(result);
6501
- } else {
6502
- // insert at front
6503
- nodes.unshift(result);
6504
- i++;
6321
+ if (result) {
6322
+ if (prev.insertAfter) {
6323
+ prev.insertAfter(result);
6324
+ } else {
6325
+ // insert at front
6326
+ nodes.unshift(result);
6327
+ i++;
6328
+ }
6505
6329
  }
6506
6330
  }
6507
6331
 
6508
- prev.node = node;
6332
+ if (nonspace) {
6333
+ prev.node = node;
6334
+ } else if (isRoot && node.hasClass("newline")) {
6335
+ prev.node = makeSpan$1(["leftmost"]); // treat like beginning of line
6336
+ }
6509
6337
 
6510
6338
  prev.insertAfter = (index => n => {
6511
6339
  nodes.splice(index + 1, 0, n);
@@ -6520,7 +6348,7 @@ const traverseNonSpaceNodes = function traverseNonSpaceNodes(nodes, callback, pr
6520
6348
 
6521
6349
 
6522
6350
  const checkPartialGroup = function checkPartialGroup(node) {
6523
- if (node instanceof DocumentFragment || node instanceof Anchor) {
6351
+ if (node instanceof DocumentFragment || node instanceof Anchor || node instanceof Span && node.hasClass("enclosing")) {
6524
6352
  return node;
6525
6353
  }
6526
6354
 
@@ -6605,10 +6433,6 @@ function buildHTMLUnbreakable(children, options) {
6605
6433
  const body = makeSpan$1(["base"], children, options); // Add strut, which ensures that the top of the HTML element falls at
6606
6434
  // the height of the expression, and the bottom of the HTML element
6607
6435
  // falls at the depth of the expression.
6608
- // We used to have separate top and bottom struts, where the bottom strut
6609
- // would like to use `vertical-align: top`, but in IE 9 this lowers the
6610
- // baseline of the box to the bottom of this strut (instead of staying in
6611
- // the normal place) so we use an absolute value for vertical-align instead.
6612
6436
 
6613
6437
  const strut = makeSpan$1(["strut"]);
6614
6438
  strut.style.height = body.height + body.depth + "em";
@@ -6632,7 +6456,7 @@ function buildHTML(tree, options) {
6632
6456
  } // Build the expression contained in the tree
6633
6457
 
6634
6458
 
6635
- const expression = buildExpression(tree, options, true);
6459
+ const expression = buildExpression(tree, options, "root");
6636
6460
  const children = []; // Create one base node for each chunk between potential line breaks.
6637
6461
  // The TeXBook [p.173] says "A formula will be broken only after a
6638
6462
  // relation symbol like $=$ or $<$ or $\rightarrow$, or after a binary
@@ -6993,7 +6817,7 @@ const getVariant = function getVariant(group, options) {
6993
6817
  if (font === "mathit") {
6994
6818
  return "italic";
6995
6819
  } else if (font === "boldsymbol") {
6996
- return "bold-italic";
6820
+ return group.type === "textord" ? "bold" : "bold-italic";
6997
6821
  } else if (font === "mathbf") {
6998
6822
  return "bold";
6999
6823
  } else if (font === "mathbb") {
@@ -7124,7 +6948,7 @@ const buildGroup$1 = function buildGroup(group, options) {
7124
6948
  * we can do appropriate styling.
7125
6949
  */
7126
6950
 
7127
- function buildMathML(tree, texExpression, options, forMathmlOnly) {
6951
+ function buildMathML(tree, texExpression, options, isDisplayMode, forMathmlOnly) {
7128
6952
  const expression = buildExpression$1(tree, options); // Wrap up the expression in an mrow so it is presented in the semantics
7129
6953
  // tag correctly, unless it's a single <mrow> or <mtable>.
7130
6954
 
@@ -7141,11 +6965,16 @@ function buildMathML(tree, texExpression, options, forMathmlOnly) {
7141
6965
  annotation.setAttribute("encoding", "application/x-tex");
7142
6966
  const semantics = new mathMLTree.MathNode("semantics", [wrapper, annotation]);
7143
6967
  const math = new mathMLTree.MathNode("math", [semantics]);
7144
- math.setAttribute("xmlns", "http://www.w3.org/1998/Math/MathML"); // You can't style <math> nodes, so we wrap the node in a span.
6968
+ math.setAttribute("xmlns", "http://www.w3.org/1998/Math/MathML");
6969
+
6970
+ if (isDisplayMode) {
6971
+ math.setAttribute("display", "block");
6972
+ } // You can't style <math> nodes, so we wrap the node in a span.
7145
6973
  // NOTE: The span class is not typed to have <math> nodes as children, and
7146
6974
  // we don't want to make the children type more generic since the children
7147
6975
  // of span are expected to have more fields in `buildHtml` contexts.
7148
6976
 
6977
+
7149
6978
  const wrapperClass = forMathmlOnly ? "katex" : "katex-mathml"; // $FlowFixMe
7150
6979
 
7151
6980
  return buildCommon.makeSpan([wrapperClass], [math]);
@@ -7182,12 +7011,12 @@ const buildTree = function buildTree(tree, expression, settings) {
7182
7011
  let katexNode;
7183
7012
 
7184
7013
  if (settings.output === "mathml") {
7185
- return buildMathML(tree, expression, options, true);
7014
+ return buildMathML(tree, expression, options, settings.displayMode, true);
7186
7015
  } else if (settings.output === "html") {
7187
7016
  const htmlNode = buildHTML(tree, options);
7188
7017
  katexNode = buildCommon.makeSpan(["katex"], [htmlNode]);
7189
7018
  } else {
7190
- const mathMLNode = buildMathML(tree, expression, options, false);
7019
+ const mathMLNode = buildMathML(tree, expression, options, settings.displayMode, false);
7191
7020
  const htmlNode = buildHTML(tree, options);
7192
7021
  katexNode = buildCommon.makeSpan(["katex"], [mathMLNode, htmlNode]);
7193
7022
  }
@@ -7537,15 +7366,53 @@ var stretchy = {
7537
7366
  svgSpan
7538
7367
  };
7539
7368
 
7369
+ /**
7370
+ * Asserts that the node is of the given type and returns it with stricter
7371
+ * typing. Throws if the node's type does not match.
7372
+ */
7373
+ function assertNodeType(node, type) {
7374
+ if (!node || node.type !== type) {
7375
+ throw new Error(`Expected node of type ${type}, but got ` + (node ? `node of type ${node.type}` : String(node)));
7376
+ }
7377
+
7378
+ return node;
7379
+ }
7380
+ /**
7381
+ * Returns the node more strictly typed iff it is of the given type. Otherwise,
7382
+ * returns null.
7383
+ */
7384
+
7385
+ function assertSymbolNodeType(node) {
7386
+ const typedNode = checkSymbolNodeType(node);
7387
+
7388
+ if (!typedNode) {
7389
+ throw new Error(`Expected node of symbol group type, but got ` + (node ? `node of type ${node.type}` : String(node)));
7390
+ }
7391
+
7392
+ return typedNode;
7393
+ }
7394
+ /**
7395
+ * Returns the node more strictly typed iff it is of the given type. Otherwise,
7396
+ * returns null.
7397
+ */
7398
+
7399
+ function checkSymbolNodeType(node) {
7400
+ if (node && (node.type === "atom" || NON_ATOMS.hasOwnProperty(node.type))) {
7401
+ // $FlowFixMe
7402
+ return node;
7403
+ }
7404
+
7405
+ return null;
7406
+ }
7407
+
7540
7408
  // NOTE: Unlike most `htmlBuilder`s, this one handles not only "accent", but
7541
7409
  const htmlBuilder = (grp, options) => {
7542
7410
  // Accents are handled in the TeXbook pg. 443, rule 12.
7543
7411
  let base;
7544
7412
  let group;
7545
- const supSub = checkNodeType(grp, "supsub");
7546
7413
  let supSubGroup;
7547
7414
 
7548
- if (supSub) {
7415
+ if (grp && grp.type === "supsub") {
7549
7416
  // If our base is a character box, and we have superscripts and
7550
7417
  // subscripts, the supsub will defer to us. In particular, we want
7551
7418
  // to attach the superscripts and subscripts to the inner body (so
@@ -7554,16 +7421,16 @@ const htmlBuilder = (grp, options) => {
7554
7421
  // sticking the base of the accent into the base of the supsub, and
7555
7422
  // rendering that, while keeping track of where the accent is.
7556
7423
  // The real accent group is the base of the supsub group
7557
- group = assertNodeType(supSub.base, "accent"); // The character box is the base of the accent group
7424
+ group = assertNodeType(grp.base, "accent"); // The character box is the base of the accent group
7558
7425
 
7559
7426
  base = group.base; // Stick the character box into the base of the supsub group
7560
7427
 
7561
- supSub.base = base; // Rerender the supsub group with its new base, and store that
7428
+ grp.base = base; // Rerender the supsub group with its new base, and store that
7562
7429
  // result.
7563
7430
 
7564
- supSubGroup = assertSpan(buildGroup(supSub, options)); // reset original base
7431
+ supSubGroup = assertSpan(buildGroup(grp, options)); // reset original base
7565
7432
 
7566
- supSub.base = group;
7433
+ grp.base = group;
7567
7434
  } else {
7568
7435
  group = assertNodeType(grp, "accent");
7569
7436
  base = group.base;
@@ -7779,8 +7646,8 @@ defineFunction({
7779
7646
  const kern = group.label === "\\utilde" ? 0.12 : 0; // Generate the vlist, with the appropriate kerns
7780
7647
 
7781
7648
  const vlist = buildCommon.makeVList({
7782
- positionType: "bottom",
7783
- positionData: accentBody.height + kern,
7649
+ positionType: "top",
7650
+ positionData: innerGroup.height,
7784
7651
  children: [{
7785
7652
  type: "elem",
7786
7653
  elem: accentBody,
@@ -8075,47 +7942,249 @@ defineFunction({
8075
7942
  }
8076
7943
  }
8077
7944
 
8078
- return {
8079
- type: "cr",
8080
- mode: parser.mode,
8081
- newLine,
8082
- newRow,
8083
- size: size && assertNodeType(size, "size").value
8084
- };
7945
+ return {
7946
+ type: "cr",
7947
+ mode: parser.mode,
7948
+ newLine,
7949
+ newRow,
7950
+ size: size && assertNodeType(size, "size").value
7951
+ };
7952
+ },
7953
+
7954
+ // The following builders are called only at the top level,
7955
+ // not within tabular/array environments.
7956
+ htmlBuilder(group, options) {
7957
+ if (group.newRow) {
7958
+ throw new ParseError("\\cr valid only within a tabular/array environment");
7959
+ }
7960
+
7961
+ const span = buildCommon.makeSpan(["mspace"], [], options);
7962
+
7963
+ if (group.newLine) {
7964
+ span.classes.push("newline");
7965
+
7966
+ if (group.size) {
7967
+ span.style.marginTop = calculateSize(group.size, options) + "em";
7968
+ }
7969
+ }
7970
+
7971
+ return span;
7972
+ },
7973
+
7974
+ mathmlBuilder(group, options) {
7975
+ const node = new mathMLTree.MathNode("mspace");
7976
+
7977
+ if (group.newLine) {
7978
+ node.setAttribute("linebreak", "newline");
7979
+
7980
+ if (group.size) {
7981
+ node.setAttribute("height", calculateSize(group.size, options) + "em");
7982
+ }
7983
+ }
7984
+
7985
+ return node;
7986
+ }
7987
+
7988
+ });
7989
+
7990
+ const globalMap = {
7991
+ "\\global": "\\global",
7992
+ "\\long": "\\\\globallong",
7993
+ "\\\\globallong": "\\\\globallong",
7994
+ "\\def": "\\gdef",
7995
+ "\\gdef": "\\gdef",
7996
+ "\\edef": "\\xdef",
7997
+ "\\xdef": "\\xdef",
7998
+ "\\let": "\\\\globallet",
7999
+ "\\futurelet": "\\\\globalfuture"
8000
+ };
8001
+
8002
+ const checkControlSequence = tok => {
8003
+ const name = tok.text;
8004
+
8005
+ if (/^(?:[\\{}$&#^_]|EOF)$/.test(name)) {
8006
+ throw new ParseError("Expected a control sequence", tok);
8007
+ }
8008
+
8009
+ return name;
8010
+ };
8011
+
8012
+ const getRHS = parser => {
8013
+ let tok = parser.gullet.popToken();
8014
+
8015
+ if (tok.text === "=") {
8016
+ // consume optional equals
8017
+ tok = parser.gullet.popToken();
8018
+
8019
+ if (tok.text === " ") {
8020
+ // consume one optional space
8021
+ tok = parser.gullet.popToken();
8022
+ }
8023
+ }
8024
+
8025
+ return tok;
8026
+ };
8027
+
8028
+ const letCommand = (parser, name, tok, global) => {
8029
+ let macro = parser.gullet.macros.get(tok.text);
8030
+
8031
+ if (macro == null) {
8032
+ // don't expand it later even if a macro with the same name is defined
8033
+ // e.g., \let\foo=\frac \def\frac{\relax} \frac12
8034
+ tok.noexpand = true;
8035
+ macro = {
8036
+ tokens: [tok],
8037
+ numArgs: 0,
8038
+ // reproduce the same behavior in expansion
8039
+ unexpandable: !parser.gullet.isExpandable(tok.text)
8040
+ };
8041
+ }
8042
+
8043
+ parser.gullet.macros.set(name, macro, global);
8044
+ }; // <assignment> -> <non-macro assignment>|<macro assignment>
8045
+ // <non-macro assignment> -> <simple assignment>|\global<non-macro assignment>
8046
+ // <macro assignment> -> <definition>|<prefix><macro assignment>
8047
+ // <prefix> -> \global|\long|\outer
8048
+
8049
+
8050
+ defineFunction({
8051
+ type: "internal",
8052
+ names: ["\\global", "\\long", "\\\\globallong"],
8053
+ props: {
8054
+ numArgs: 0,
8055
+ allowedInText: true
8056
+ },
8057
+
8058
+ handler(_ref) {
8059
+ let parser = _ref.parser,
8060
+ funcName = _ref.funcName;
8061
+ parser.consumeSpaces();
8062
+ const token = parser.fetch();
8063
+
8064
+ if (globalMap[token.text]) {
8065
+ // KaTeX doesn't have \par, so ignore \long
8066
+ if (funcName === "\\global" || funcName === "\\\\globallong") {
8067
+ token.text = globalMap[token.text];
8068
+ }
8069
+
8070
+ return assertNodeType(parser.parseFunction(), "internal");
8071
+ }
8072
+
8073
+ throw new ParseError(`Invalid token after macro prefix`, token);
8074
+ }
8075
+
8076
+ }); // Basic support for macro definitions: \def, \gdef, \edef, \xdef
8077
+ // <definition> -> <def><control sequence><definition text>
8078
+ // <def> -> \def|\gdef|\edef|\xdef
8079
+ // <definition text> -> <parameter text><left brace><balanced text><right brace>
8080
+
8081
+ defineFunction({
8082
+ type: "internal",
8083
+ names: ["\\def", "\\gdef", "\\edef", "\\xdef"],
8084
+ props: {
8085
+ numArgs: 0,
8086
+ allowedInText: true
8085
8087
  },
8086
8088
 
8087
- // The following builders are called only at the top level,
8088
- // not within tabular/array environments.
8089
- htmlBuilder(group, options) {
8090
- if (group.newRow) {
8091
- throw new ParseError("\\cr valid only within a tabular/array environment");
8089
+ handler(_ref2) {
8090
+ let parser = _ref2.parser,
8091
+ funcName = _ref2.funcName;
8092
+ let arg = parser.gullet.consumeArgs(1)[0];
8093
+
8094
+ if (arg.length !== 1) {
8095
+ throw new ParseError("\\gdef's first argument must be a macro name");
8092
8096
  }
8093
8097
 
8094
- const span = buildCommon.makeSpan(["mspace"], [], options);
8098
+ const name = arg[0].text; // Count argument specifiers, and check they are in the order #1 #2 ...
8095
8099
 
8096
- if (group.newLine) {
8097
- span.classes.push("newline");
8100
+ let numArgs = 0;
8101
+ arg = parser.gullet.consumeArgs(1)[0];
8098
8102
 
8099
- if (group.size) {
8100
- span.style.marginTop = calculateSize(group.size, options) + "em";
8103
+ while (arg.length === 1 && arg[0].text === "#") {
8104
+ arg = parser.gullet.consumeArgs(1)[0];
8105
+
8106
+ if (arg.length !== 1) {
8107
+ throw new ParseError(`Invalid argument number length "${arg.length}"`);
8108
+ }
8109
+
8110
+ if (!/^[1-9]$/.test(arg[0].text)) {
8111
+ throw new ParseError(`Invalid argument number "${arg[0].text}"`);
8112
+ }
8113
+
8114
+ numArgs++;
8115
+
8116
+ if (parseInt(arg[0].text) !== numArgs) {
8117
+ throw new ParseError(`Argument number "${arg[0].text}" out of order`);
8101
8118
  }
8119
+
8120
+ arg = parser.gullet.consumeArgs(1)[0];
8102
8121
  }
8103
8122
 
8104
- return span;
8123
+ if (funcName === "\\edef" || funcName === "\\xdef") {
8124
+ arg = parser.gullet.expandTokens(arg);
8125
+ arg.reverse(); // to fit in with stack order
8126
+ } // Final arg is the expansion of the macro
8127
+
8128
+
8129
+ parser.gullet.macros.set(name, {
8130
+ tokens: arg,
8131
+ numArgs
8132
+ }, funcName === globalMap[funcName]);
8133
+ return {
8134
+ type: "internal",
8135
+ mode: parser.mode
8136
+ };
8137
+ }
8138
+
8139
+ }); // <simple assignment> -> <let assignment>
8140
+ // <let assignment> -> \futurelet<control sequence><token><token>
8141
+ // | \let<control sequence><equals><one optional space><token>
8142
+ // <equals> -> <optional spaces>|<optional spaces>=
8143
+
8144
+ defineFunction({
8145
+ type: "internal",
8146
+ names: ["\\let", "\\\\globallet"],
8147
+ props: {
8148
+ numArgs: 0,
8149
+ allowedInText: true
8105
8150
  },
8106
8151
 
8107
- mathmlBuilder(group, options) {
8108
- const node = new mathMLTree.MathNode("mspace");
8152
+ handler(_ref3) {
8153
+ let parser = _ref3.parser,
8154
+ funcName = _ref3.funcName;
8155
+ const name = checkControlSequence(parser.gullet.popToken());
8156
+ parser.gullet.consumeSpaces();
8157
+ const tok = getRHS(parser);
8158
+ letCommand(parser, name, tok, funcName === "\\\\globallet");
8159
+ return {
8160
+ type: "internal",
8161
+ mode: parser.mode
8162
+ };
8163
+ }
8109
8164
 
8110
- if (group.newLine) {
8111
- node.setAttribute("linebreak", "newline");
8165
+ }); // ref: https://www.tug.org/TUGboat/tb09-3/tb22bechtolsheim.pdf
8112
8166
 
8113
- if (group.size) {
8114
- node.setAttribute("height", calculateSize(group.size, options) + "em");
8115
- }
8116
- }
8167
+ defineFunction({
8168
+ type: "internal",
8169
+ names: ["\\futurelet", "\\\\globalfuture"],
8170
+ props: {
8171
+ numArgs: 0,
8172
+ allowedInText: true
8173
+ },
8117
8174
 
8118
- return node;
8175
+ handler(_ref4) {
8176
+ let parser = _ref4.parser,
8177
+ funcName = _ref4.funcName;
8178
+ const name = checkControlSequence(parser.gullet.popToken());
8179
+ const middle = parser.gullet.popToken();
8180
+ const tok = parser.gullet.popToken();
8181
+ letCommand(parser, name, tok, funcName === "\\\\globalfuture");
8182
+ parser.gullet.pushToken(tok);
8183
+ parser.gullet.pushToken(middle);
8184
+ return {
8185
+ type: "internal",
8186
+ mode: parser.mode
8187
+ };
8119
8188
  }
8120
8189
 
8121
8190
  });
@@ -8439,12 +8508,33 @@ const makeStackedDelim = function makeStackedDelim(delim, heightTotal, center, o
8439
8508
  // at a position that juts 0.005 above the bottom of the top element.
8440
8509
 
8441
8510
 
8442
- inners.push({
8443
- type: "kern",
8444
- size: shiftOfExtraElement
8445
- });
8446
- inners.push(makeInner(repeat, font, mode));
8447
- inners.push(lap); // Add the top symbol
8511
+ if ((repeat === "\u239c" || repeat === "\u239f") && repeatCount === 0) {
8512
+ // Parentheses need a short repeat element in order to avoid an overrun.
8513
+ // We'll make a 0.3em tall element from a SVG.
8514
+ const overlap = buildCommon.svgData.leftParenInner[2] / 2;
8515
+ inners.push({
8516
+ type: "kern",
8517
+ size: -overlap
8518
+ });
8519
+ const pathName = repeat === "\u239c" ? "leftParenInner" : "rightParenInner";
8520
+ const innerSpan = buildCommon.staticSvg(pathName, options);
8521
+ inners.push({
8522
+ type: "elem",
8523
+ elem: innerSpan
8524
+ });
8525
+ inners.push({
8526
+ type: "kern",
8527
+ size: -overlap
8528
+ });
8529
+ } else {
8530
+ inners.push({
8531
+ type: "kern",
8532
+ size: shiftOfExtraElement
8533
+ });
8534
+ inners.push(makeInner(repeat, font, mode));
8535
+ inners.push(lap);
8536
+ } // Add the top symbol
8537
+
8448
8538
 
8449
8539
  inners.push(makeInner(top, font, mode)); // Finally, build the vlist
8450
8540
 
@@ -8859,8 +8949,10 @@ function checkDelimiter(delim, context) {
8859
8949
 
8860
8950
  if (symDelim && utils.contains(delimiters, symDelim.text)) {
8861
8951
  return symDelim;
8952
+ } else if (symDelim) {
8953
+ throw new ParseError(`Invalid delimiter '${symDelim.text}' after '${context.funcName}'`, delim);
8862
8954
  } else {
8863
- throw new ParseError("Invalid delimiter: '" + (symDelim ? symDelim.text : JSON.stringify(delim)) + "' after '" + context.funcName + "'", delim);
8955
+ throw new ParseError(`Invalid delimiter type '${delim.type}'`, delim);
8864
8956
  }
8865
8957
  }
8866
8958
 
@@ -9832,7 +9924,7 @@ const mathmlBuilder$3 = function mathmlBuilder(group, options) {
9832
9924
  let menclose = "";
9833
9925
  let align = "";
9834
9926
 
9835
- if (group.cols) {
9927
+ if (group.cols && group.cols.length > 0) {
9836
9928
  // Find column alignment, column spacing, and vertical lines.
9837
9929
  const cols = group.cols;
9838
9930
  let columnLines = "";
@@ -9946,13 +10038,12 @@ const alignedHandler = function alignedHandler(context, args) {
9946
10038
  mode: context.mode,
9947
10039
  body: []
9948
10040
  };
9949
- const ordgroup = checkNodeType(args[0], "ordgroup");
9950
10041
 
9951
- if (ordgroup) {
10042
+ if (args[0] && args[0].type === "ordgroup") {
9952
10043
  let arg0 = "";
9953
10044
 
9954
- for (let i = 0; i < ordgroup.body.length; i++) {
9955
- const textord = assertNodeType(ordgroup.body[i], "textord");
10045
+ for (let i = 0; i < args[0].body.length; i++) {
10046
+ const textord = assertNodeType(args[0].body[i], "textord");
9956
10047
  arg0 += textord.text;
9957
10048
  }
9958
10049
 
@@ -10151,7 +10242,7 @@ defineEnvironment({
10151
10242
  };
10152
10243
  res = parseArray(context.parser, res, "script");
10153
10244
 
10154
- if (res.body[0].length > 1) {
10245
+ if (res.body.length > 0 && res.body[0].length > 1) {
10155
10246
  throw new ParseError("{subarray} can contain only one column");
10156
10247
  }
10157
10248
 
@@ -10165,10 +10256,11 @@ defineEnvironment({
10165
10256
  // \left\{\begin{array}{@{}l@{\quad}l@{}} … \end{array}\right.
10166
10257
  // {dcases} is a {cases} environment where cells are set in \displaystyle,
10167
10258
  // as defined in mathtools.sty.
10259
+ // {rcases} is another mathtools environment. It's brace is on the right side.
10168
10260
 
10169
10261
  defineEnvironment({
10170
10262
  type: "array",
10171
- names: ["cases", "dcases"],
10263
+ names: ["cases", "dcases", "rcases", "drcases"],
10172
10264
  props: {
10173
10265
  numArgs: 0
10174
10266
  },
@@ -10199,8 +10291,8 @@ defineEnvironment({
10199
10291
  type: "leftright",
10200
10292
  mode: context.mode,
10201
10293
  body: [res],
10202
- left: "\\{",
10203
- right: ".",
10294
+ left: context.envName.indexOf("r") > -1 ? "." : "\\{",
10295
+ right: context.envName.indexOf("r") > -1 ? "\\}" : ".",
10204
10296
  rightColor: undefined
10205
10297
  };
10206
10298
  },
@@ -10587,7 +10679,7 @@ defineFunction({
10587
10679
 
10588
10680
  defineFunction({
10589
10681
  type: "font",
10590
- names: ["\\rm", "\\sf", "\\tt", "\\bf", "\\it"],
10682
+ names: ["\\rm", "\\sf", "\\tt", "\\bf", "\\it", "\\cal"],
10591
10683
  props: {
10592
10684
  numArgs: 0,
10593
10685
  allowedInText: true
@@ -10992,20 +11084,8 @@ defineFunction({
10992
11084
  const numer = args[4];
10993
11085
  const denom = args[5]; // Look into the parse nodes to get the desired delimiters.
10994
11086
 
10995
- let leftNode = checkNodeType(args[0], "atom");
10996
-
10997
- if (leftNode) {
10998
- leftNode = assertAtomFamily(args[0], "open");
10999
- }
11000
-
11001
- const leftDelim = leftNode ? delimFromValue(leftNode.text) : null;
11002
- let rightNode = checkNodeType(args[1], "atom");
11003
-
11004
- if (rightNode) {
11005
- rightNode = assertAtomFamily(args[1], "close");
11006
- }
11007
-
11008
- const rightDelim = rightNode ? delimFromValue(rightNode.text) : null;
11087
+ const leftDelim = args[0].type === "atom" && args[0].family === "open" ? delimFromValue(args[0].text) : null;
11088
+ const rightDelim = args[1].type === "atom" && args[1].family === "close" ? delimFromValue(args[1].text) : null;
11009
11089
  const barNode = assertNodeType(args[2], "size");
11010
11090
  let hasBarLine;
11011
11091
  let barSize = null;
@@ -11022,15 +11102,15 @@ defineFunction({
11022
11102
 
11023
11103
 
11024
11104
  let size = "auto";
11025
- let styl = checkNodeType(args[3], "ordgroup");
11105
+ let styl = args[3];
11026
11106
 
11027
- if (styl) {
11107
+ if (styl.type === "ordgroup") {
11028
11108
  if (styl.body.length > 0) {
11029
11109
  const textOrd = assertNodeType(styl.body[0], "textord");
11030
11110
  size = stylArray[Number(textOrd.text)];
11031
11111
  }
11032
11112
  } else {
11033
- styl = assertNodeType(args[3], "textord");
11113
+ styl = assertNodeType(styl, "textord");
11034
11114
  size = stylArray[Number(styl.text)];
11035
11115
  }
11036
11116
 
@@ -11112,14 +11192,13 @@ const htmlBuilder$7 = (grp, options) => {
11112
11192
 
11113
11193
  let supSubGroup;
11114
11194
  let group;
11115
- const supSub = checkNodeType(grp, "supsub");
11116
11195
 
11117
- if (supSub) {
11196
+ if (grp.type === "supsub") {
11118
11197
  // Ref: LaTeX source2e: }}}}\limits}
11119
11198
  // i.e. LaTeX treats the brace similar to an op and passes it
11120
11199
  // with \limits, so we need to assign supsub style.
11121
- supSubGroup = supSub.sup ? buildGroup(supSub.sup, options.havingStyle(style.sup()), options) : buildGroup(supSub.sub, options.havingStyle(style.sub()), options);
11122
- group = assertNodeType(supSub.base, "horizBrace");
11200
+ supSubGroup = grp.sup ? buildGroup(grp.sup, options.havingStyle(style.sup()), options) : buildGroup(grp.sub, options.havingStyle(style.sub()), options);
11201
+ group = assertNodeType(grp.base, "horizBrace");
11123
11202
  } else {
11124
11203
  group = assertNodeType(grp, "horizBrace");
11125
11204
  } // Build the base group
@@ -11333,6 +11412,112 @@ defineFunction({
11333
11412
  }
11334
11413
  });
11335
11414
 
11415
+ defineFunction({
11416
+ type: "html",
11417
+ names: ["\\htmlClass", "\\htmlId", "\\htmlStyle", "\\htmlData"],
11418
+ props: {
11419
+ numArgs: 2,
11420
+ argTypes: ["raw", "original"],
11421
+ allowedInText: true
11422
+ },
11423
+ handler: (_ref, args) => {
11424
+ let parser = _ref.parser,
11425
+ funcName = _ref.funcName,
11426
+ token = _ref.token;
11427
+ const value = assertNodeType(args[0], "raw").string;
11428
+ const body = args[1];
11429
+
11430
+ if (parser.settings.strict) {
11431
+ parser.settings.reportNonstrict("htmlExtension", "HTML extension is disabled on strict mode");
11432
+ }
11433
+
11434
+ let trustContext;
11435
+ const attributes = {};
11436
+
11437
+ switch (funcName) {
11438
+ case "\\htmlClass":
11439
+ attributes.class = value;
11440
+ trustContext = {
11441
+ command: "\\htmlClass",
11442
+ class: value
11443
+ };
11444
+ break;
11445
+
11446
+ case "\\htmlId":
11447
+ attributes.id = value;
11448
+ trustContext = {
11449
+ command: "\\htmlId",
11450
+ id: value
11451
+ };
11452
+ break;
11453
+
11454
+ case "\\htmlStyle":
11455
+ attributes.style = value;
11456
+ trustContext = {
11457
+ command: "\\htmlStyle",
11458
+ style: value
11459
+ };
11460
+ break;
11461
+
11462
+ case "\\htmlData":
11463
+ {
11464
+ const data = value.split(",");
11465
+
11466
+ for (let i = 0; i < data.length; i++) {
11467
+ const keyVal = data[i].split("=");
11468
+
11469
+ if (keyVal.length !== 2) {
11470
+ throw new ParseError("Error parsing key-value for \\htmlData");
11471
+ }
11472
+
11473
+ attributes["data-" + keyVal[0].trim()] = keyVal[1].trim();
11474
+ }
11475
+
11476
+ trustContext = {
11477
+ command: "\\htmlData",
11478
+ attributes
11479
+ };
11480
+ break;
11481
+ }
11482
+
11483
+ default:
11484
+ throw new Error("Unrecognized html command");
11485
+ }
11486
+
11487
+ if (!parser.settings.isTrusted(trustContext)) {
11488
+ return parser.formatUnsupportedCmd(funcName);
11489
+ }
11490
+
11491
+ return {
11492
+ type: "html",
11493
+ mode: parser.mode,
11494
+ attributes,
11495
+ body: ordargument(body)
11496
+ };
11497
+ },
11498
+ htmlBuilder: (group, options) => {
11499
+ const elements = buildExpression(group.body, options, false);
11500
+ const classes = ["enclosing"];
11501
+
11502
+ if (group.attributes.class) {
11503
+ classes.push(...group.attributes.class.trim().split(/\s+/));
11504
+ }
11505
+
11506
+ const span = buildCommon.makeSpan(classes, elements, options);
11507
+
11508
+ for (const attr in group.attributes) {
11509
+ if (attr !== "class" && group.attributes.hasOwnProperty(attr)) {
11510
+ span.setAttribute(attr, group.attributes[attr]);
11511
+ }
11512
+ }
11513
+
11514
+ return span;
11515
+ },
11516
+ mathmlBuilder: (group, options) => {
11517
+ return buildExpressionRow(group.body, options);
11518
+ }
11519
+ });
11520
+
11336
11521
  defineFunction({
11337
11522
  type: "htmlmathml",
11338
11523
  names: ["\\html@mathml"],
@@ -11622,21 +11807,16 @@ defineFunction({
11622
11807
  // two items involved in the lap.
11623
11808
  // Next, use a strut to set the height of the HTML bounding box.
11624
11809
  // Otherwise, a tall argument may be misplaced.
11810
+ // This code resolved issue #1153
11625
11811
 
11626
11812
  const strut = buildCommon.makeSpan(["strut"]);
11627
11813
  strut.style.height = node.height + node.depth + "em";
11628
11814
  strut.style.verticalAlign = -node.depth + "em";
11629
11815
  node.children.unshift(strut); // Next, prevent vertical misplacement when next to something tall.
11816
+ // This code resolves issue #1234
11630
11817
 
11631
- node = buildCommon.makeVList({
11632
- positionType: "firstBaseline",
11633
- children: [{
11634
- type: "elem",
11635
- elem: node
11636
- }]
11637
- }, options); // Get the horizontal spacing correct relative to adjacent items.
11638
-
11639
- return buildCommon.makeSpan(["mord"], [node], options);
11818
+ node = buildCommon.makeSpan(["thinbox"], [node], options);
11819
+ return buildCommon.makeSpan(["mord", "vbox"], [node], options);
11640
11820
  },
11641
11821
  mathmlBuilder: (group, options) => {
11642
11822
  // mathllap, mathrlap, mathclap
@@ -11745,8 +11925,6 @@ defineFunction({
11745
11925
 
11746
11926
  // For an operator with limits, assemble the base, sup, and sub into a span.
11747
11927
  const assembleSupSub = (base, supGroup, subGroup, options, style, slant, baseShift) => {
11748
- // IE 8 clips \int if it is in a display: inline-block. We wrap it
11749
- // in a new span so it is an inline, and works.
11750
11928
  base = buildCommon.makeSpan([], [base]);
11751
11929
  let sub;
11752
11930
  let sup; // We manually have to handle the superscripts and subscripts. This,
@@ -11867,15 +12045,14 @@ const htmlBuilder$8 = (grp, options) => {
11867
12045
  let subGroup;
11868
12046
  let hasLimits = false;
11869
12047
  let group;
11870
- const supSub = checkNodeType(grp, "supsub");
11871
12048
 
11872
- if (supSub) {
12049
+ if (grp.type === "supsub") {
11873
12050
  // If we have limits, supsub will pass us its group to handle. Pull
11874
12051
  // out the superscript and subscript and set the group to the op in
11875
12052
  // its base.
11876
- supGroup = supSub.sup;
11877
- subGroup = supSub.sub;
11878
- group = assertNodeType(supSub.base, "op");
12053
+ supGroup = grp.sup;
12054
+ subGroup = grp.sub;
12055
+ group = assertNodeType(grp.base, "op");
11879
12056
  hasLimits = true;
11880
12057
  } else {
11881
12058
  group = assertNodeType(grp, "op");
@@ -12175,15 +12352,14 @@ const htmlBuilder$9 = (grp, options) => {
12175
12352
  let subGroup;
12176
12353
  let hasLimits = false;
12177
12354
  let group;
12178
- const supSub = checkNodeType(grp, "supsub");
12179
12355
 
12180
- if (supSub) {
12356
+ if (grp.type === "supsub") {
12181
12357
  // If we have limits, supsub will pass us its group to handle. Pull
12182
12358
  // out the superscript and subscript and set the group to the op in
12183
12359
  // its base.
12184
- supGroup = supSub.sup;
12185
- subGroup = supSub.sub;
12186
- group = assertNodeType(supSub.base, "operatorname");
12360
+ supGroup = grp.sup;
12361
+ subGroup = grp.sub;
12362
+ group = assertNodeType(grp.base, "operatorname");
12187
12363
  hasLimits = true;
12188
12364
  } else {
12189
12365
  group = assertNodeType(grp, "operatorname");
@@ -13130,14 +13306,13 @@ defineFunctionBuilders({
13130
13306
  let isBrace = false;
13131
13307
  let isOver;
13132
13308
  let isSup;
13133
- const horizBrace = checkNodeType(group.base, "horizBrace");
13134
13309
 
13135
- if (horizBrace) {
13310
+ if (group.base && group.base.type === "horizBrace") {
13136
13311
  isSup = !!group.sup;
13137
13312
 
13138
- if (isSup === horizBrace.isOver) {
13313
+ if (isSup === group.base.isOver) {
13139
13314
  isBrace = true;
13140
- isOver = horizBrace.isOver;
13315
+ isOver = group.base.isOver;
13141
13316
  }
13142
13317
  }
13143
13318
 
@@ -13801,7 +13976,37 @@ function defineMacro(name, body) {
13801
13976
  builtinMacros[name] = body;
13802
13977
  } //////////////////////////////////////////////////////////////////////
13803
13978
  // macro tools
13804
- // LaTeX's \@firstoftwo{#1}{#2} expands to #1, skipping #2
13979
+
13980
+ defineMacro("\\noexpand", function (context) {
13981
+ // The expansion is the token itself; but that token is interpreted
13982
+ // as if its meaning were ‘\relax’ if it is a control sequence that
13983
+ // would ordinarily be expanded by TeX’s expansion rules.
13984
+ const t = context.popToken();
13985
+
13986
+ if (context.isExpandable(t.text)) {
13987
+ t.noexpand = true;
13988
+ t.treatAsRelax = true;
13989
+ }
13990
+
13991
+ return {
13992
+ tokens: [t],
13993
+ numArgs: 0
13994
+ };
13995
+ });
13996
+ defineMacro("\\expandafter", function (context) {
13997
+ // TeX first reads the token that comes immediately after \expandafter,
13998
+ // without expanding it; let’s call this token t. Then TeX reads the
13999
+ // token that comes after t (and possibly more tokens, if that token
14000
+ // has an argument), replacing it by its expansion. Finally TeX puts
14001
+ // t back in front of that expansion.
14002
+ const t = context.popToken();
14003
+ context.expandOnce(true); // expand only an expandable token
14004
+
14005
+ return {
14006
+ tokens: [t],
14007
+ numArgs: 0
14008
+ };
14009
+ }); // LaTeX's \@firstoftwo{#1}{#2} expands to #1, skipping #2
13805
14010
  // TeX source: \long\def\@firstoftwo#1#2{#1}
13806
14011
 
13807
14012
  defineMacro("\\@firstoftwo", function (context) {
@@ -13820,12 +14025,14 @@ defineMacro("\\@secondoftwo", function (context) {
13820
14025
  numArgs: 0
13821
14026
  };
13822
14027
  }); // LaTeX's \@ifnextchar{#1}{#2}{#3} looks ahead to the next (unexpanded)
13823
- // symbol. If it matches #1, then the macro expands to #2; otherwise, #3.
13824
- // Note, however, that it does not consume the next symbol in either case.
14028
+ // symbol that isn't a space, consuming any spaces but not consuming the
14029
+ // first nonspace character. If that nonspace character matches #1, then
14030
+ // the macro expands to #2; otherwise, it expands to #3.
13825
14031
 
13826
14032
  defineMacro("\\@ifnextchar", function (context) {
13827
14033
  const args = context.consumeArgs(3); // symbol, if, else
13828
14034
 
14035
+ context.consumeSpaces();
13829
14036
  const nextToken = context.future();
13830
14037
 
13831
14038
  if (args[0].length === 1 && args[0][0].text === nextToken.text) {
@@ -13938,70 +14145,6 @@ defineMacro("\\char", function (context) {
13938
14145
  }
13939
14146
 
13940
14147
  return `\\@char{${number}}`;
13941
- }); // Basic support for macro definitions:
13942
- // \def\macro{expansion}
13943
- // \def\macro#1{expansion}
13944
- // \def\macro#1#2{expansion}
13945
- // \def\macro#1#2#3#4#5#6#7#8#9{expansion}
13946
- // Also the \gdef and \global\def equivalents
13947
-
13948
- const def = (context, global) => {
13949
- let arg = context.consumeArgs(1)[0];
13950
-
13951
- if (arg.length !== 1) {
13952
- throw new ParseError("\\gdef's first argument must be a macro name");
13953
- }
13954
-
13955
- const name = arg[0].text; // Count argument specifiers, and check they are in the order #1 #2 ...
13956
-
13957
- let numArgs = 0;
13958
- arg = context.consumeArgs(1)[0];
13959
-
13960
- while (arg.length === 1 && arg[0].text === "#") {
13961
- arg = context.consumeArgs(1)[0];
13962
-
13963
- if (arg.length !== 1) {
13964
- throw new ParseError(`Invalid argument number length "${arg.length}"`);
13965
- }
13966
-
13967
- if (!/^[1-9]$/.test(arg[0].text)) {
13968
- throw new ParseError(`Invalid argument number "${arg[0].text}"`);
13969
- }
13970
-
13971
- numArgs++;
13972
-
13973
- if (parseInt(arg[0].text) !== numArgs) {
13974
- throw new ParseError(`Argument number "${arg[0].text}" out of order`);
13975
- }
13976
-
13977
- arg = context.consumeArgs(1)[0];
13978
- } // Final arg is the expansion of the macro
13979
-
13980
-
13981
- context.macros.set(name, {
13982
- tokens: arg,
13983
- numArgs
13984
- }, global);
13985
- return '';
13986
- };
13987
-
13988
- defineMacro("\\gdef", context => def(context, true));
13989
- defineMacro("\\def", context => def(context, false));
13990
- defineMacro("\\global", context => {
13991
- const next = context.consumeArgs(1)[0];
13992
-
13993
- if (next.length !== 1) {
13994
- throw new ParseError("Invalid command after \\global");
13995
- }
13996
-
13997
- const command = next[0].text; // TODO: Should expand command
13998
-
13999
- if (command === "\\def") {
14000
- // \global\def is equivalent to \gdef
14001
- return def(context, true);
14002
- } else {
14003
- throw new ParseError(`Invalid command '${command}' after \\global`);
14004
- }
14005
14148
  }); // \newcommand{\macro}[args]{definition}
14006
14149
  // \renewcommand{\macro}[args]{definition}
14007
14150
  // TODO: Optional arguments: \newcommand{\macro}[args][default]{definition}
@@ -14055,7 +14198,27 @@ const newcommand = (context, existsOK, nonexistsOK) => {
14055
14198
 
14056
14199
  defineMacro("\\newcommand", context => newcommand(context, false, true));
14057
14200
  defineMacro("\\renewcommand", context => newcommand(context, true, false));
14058
- defineMacro("\\providecommand", context => newcommand(context, true, true)); //////////////////////////////////////////////////////////////////////
14201
+ defineMacro("\\providecommand", context => newcommand(context, true, true)); // terminal (console) tools
14202
+
14203
+ defineMacro("\\message", context => {
14204
+ const arg = context.consumeArgs(1)[0]; // eslint-disable-next-line no-console
14205
+
14206
+ console.log(arg.reverse().map(token => token.text).join(""));
14207
+ return '';
14208
+ });
14209
+ defineMacro("\\errmessage", context => {
14210
+ const arg = context.consumeArgs(1)[0]; // eslint-disable-next-line no-console
14211
+
14212
+ console.error(arg.reverse().map(token => token.text).join(""));
14213
+ return '';
14214
+ });
14215
+ defineMacro("\\show", context => {
14216
+ const tok = context.popToken();
14217
+ const name = tok.text; // eslint-disable-next-line no-console
14218
+
14219
+ console.log(tok, context.macros.get(name), functions[name], symbols.math[name], symbols.text[name]);
14220
+ return '';
14221
+ }); //////////////////////////////////////////////////////////////////////
14059
14222
  // Grouping
14060
14223
  // \let\bgroup={ \let\egroup=}
14061
14224
 
@@ -14137,7 +14300,13 @@ defineMacro("\u231E", "\\llcorner");
14137
14300
  defineMacro("\u231F", "\\lrcorner");
14138
14301
  defineMacro("\u00A9", "\\copyright");
14139
14302
  defineMacro("\u00AE", "\\textregistered");
14140
- defineMacro("\uFE0F", "\\textregistered"); //////////////////////////////////////////////////////////////////////
14303
+ defineMacro("\uFE0F", "\\textregistered"); // The KaTeX fonts have corners at codepoints that don't match Unicode.
14304
+ // For MathML purposes, use the Unicode code point.
14305
+
14306
+ defineMacro("\\ulcorner", "\\html@mathml{\\@ulcorner}{\\mathop{\\char\"231c}}");
14307
+ defineMacro("\\urcorner", "\\html@mathml{\\@urcorner}{\\mathop{\\char\"231d}}");
14308
+ defineMacro("\\llcorner", "\\html@mathml{\\@llcorner}{\\mathop{\\char\"231e}}");
14309
+ defineMacro("\\lrcorner", "\\html@mathml{\\@lrcorner}{\\mathop{\\char\"231f}}"); //////////////////////////////////////////////////////////////////////
14141
14310
  // LaTeX_2ε
14142
14311
  // \vdots{\vbox{\baselineskip4\p@ \lineskiplimit\z@
14143
14312
  // \kern6\p@\hbox{.}\hbox{.}\hbox{.}}}
@@ -14506,7 +14675,9 @@ defineMacro("\\nsupseteqq", "\\html@mathml{\\@nsupseteqq}{\u2289}");
14506
14675
  defineMacro("\\varsubsetneq", "\\html@mathml{\\@varsubsetneq}{⊊}");
14507
14676
  defineMacro("\\varsubsetneqq", "\\html@mathml{\\@varsubsetneqq}{⫋}");
14508
14677
  defineMacro("\\varsupsetneq", "\\html@mathml{\\@varsupsetneq}{⊋}");
14509
- defineMacro("\\varsupsetneqq", "\\html@mathml{\\@varsupsetneqq}{⫌}"); //////////////////////////////////////////////////////////////////////
14678
+ defineMacro("\\varsupsetneqq", "\\html@mathml{\\@varsupsetneqq}{⫌}");
14679
+ defineMacro("\\imath", "\\html@mathml{\\@imath}{\u0131}");
14680
+ defineMacro("\\jmath", "\\html@mathml{\\@jmath}{\u0237}"); //////////////////////////////////////////////////////////////////////
14510
14681
  // stmaryrd and semantic
14511
14682
  // The stmaryrd and semantic packages render the next four items by calling a
14512
14683
  // glyph. Those glyphs do not exist in the KaTeX fonts. Hence the macros.
@@ -14524,7 +14695,11 @@ defineMacro("\u2983", "\\lBrace"); // blackboard bold {
14524
14695
  defineMacro("\u2984", "\\rBrace"); // blackboard bold }
14525
14696
  // TODO: Create variable sized versions of the last two items. I believe that
14526
14697
  // will require new font glyphs.
14527
- //////////////////////////////////////////////////////////////////////
14698
+ // The stmaryrd function `\minuso` provides a "Plimsoll" symbol that
14699
+ // superimposes the characters \circ and \mathminus. Used in chemistry.
14700
+
14701
+ defineMacro("\\minuso", "\\mathbin{\\html@mathml{" + "{\\mathrlap{\\mathchoice{\\kern{0.145em}}{\\kern{0.145em}}" + "{\\kern{0.1015em}}{\\kern{0.0725em}}\\circ}{-}}}" + "{\\char`⦵}}");
14702
+ defineMacro("⦵", "\\minuso"); //////////////////////////////////////////////////////////////////////
14528
14703
  // texvc.sty
14529
14704
  // The texvc package contains macros available in mediawiki pages.
14530
14705
  // We omit the functions deprecated at
@@ -14600,7 +14775,15 @@ defineMacro("\\Zeta", "\\mathrm{Z}"); //////////////////////////////////////////
14600
14775
 
14601
14776
  defineMacro("\\argmin", "\\DOTSB\\operatorname*{arg\\,min}");
14602
14777
  defineMacro("\\argmax", "\\DOTSB\\operatorname*{arg\\,max}");
14603
- defineMacro("\\plim", "\\DOTSB\\mathop{\\operatorname{plim}}\\limits"); // Custom Khan Academy colors, should be moved to an optional package
14778
+ defineMacro("\\plim", "\\DOTSB\\mathop{\\operatorname{plim}}\\limits"); //////////////////////////////////////////////////////////////////////
14779
+ // braket.sty
14780
+ // http://ctan.math.washington.edu/tex-archive/macros/latex/contrib/braket/braket.pdf
14781
+
14782
+ defineMacro("\\bra", "\\mathinner{\\langle{#1}|}");
14783
+ defineMacro("\\ket", "\\mathinner{|{#1}\\rangle}");
14784
+ defineMacro("\\braket", "\\mathinner{\\langle{#1}\\rangle}");
14785
+ defineMacro("\\Bra", "\\left\\langle#1\\right|");
14786
+ defineMacro("\\Ket", "\\left|#1\\right\\rangle"); // Custom Khan Academy colors, should be moved to an optional package
14604
14787
 
14605
14788
  defineMacro("\\blue", "\\textcolor{##6495ed}{#1}");
14606
14789
  defineMacro("\\orange", "\\textcolor{##ffa500}{#1}");
@@ -14846,18 +15029,22 @@ class MacroExpander {
14846
15029
  * At the moment, macro expansion doesn't handle delimited macros,
14847
15030
  * i.e. things like those defined by \def\foo#1\end{…}.
14848
15031
  * See the TeX book page 202ff. for details on how those should behave.
15032
+ *
15033
+ * If expandableOnly, only expandable tokens are expanded and
15034
+ * an undefined control sequence results in an error.
14849
15035
  */
14850
15036
 
14851
15037
 
14852
- expandOnce() {
15038
+ expandOnce(expandableOnly) {
14853
15039
  const topToken = this.popToken();
14854
15040
  const name = topToken.text;
15041
+ const expansion = !topToken.noexpand ? this._getExpansion(name) : null;
14855
15042
 
14856
- const expansion = this._getExpansion(name);
15043
+ if (expansion == null || expandableOnly && expansion.unexpandable) {
15044
+ if (expandableOnly && expansion == null && name[0] === "\\" && !this.isDefined(name)) {
15045
+ throw new ParseError("Undefined control sequence: " + name);
15046
+ }
14857
15047
 
14858
- if (expansion == null) {
14859
- // mainly checking for undefined here
14860
- // Fully expanded
14861
15048
  this.pushToken(topToken);
14862
15049
  return topToken;
14863
15050
  }
@@ -14926,7 +15113,9 @@ class MacroExpander {
14926
15113
  if (expanded instanceof Token) {
14927
15114
  // \relax stops the expansion, but shouldn't get returned (a
14928
15115
  // null return value couldn't get implemented as a function).
14929
- if (expanded.text === "\\relax") {
15116
+ // the token after \noexpand is interpreted as if its meaning
15117
+ // were ‘\relax’
15118
+ if (expanded.text === "\\relax" || expanded.treatAsRelax) {
14930
15119
  this.stack.pop();
14931
15120
  } else {
14932
15121
  return this.stack.pop(); // === expanded
@@ -14945,18 +15134,29 @@ class MacroExpander {
14945
15134
 
14946
15135
 
14947
15136
  expandMacro(name) {
14948
- if (!this.macros.get(name)) {
14949
- return undefined;
14950
- }
15137
+ return this.macros.has(name) ? this.expandTokens([new Token(name)]) : undefined;
15138
+ }
15139
+ /**
15140
+ * Fully expand the given token stream and return the resulting list of tokens
15141
+ */
15142
+
14951
15143
 
15144
+ expandTokens(tokens) {
14952
15145
  const output = [];
14953
15146
  const oldStackLength = this.stack.length;
14954
- this.pushToken(new Token(name));
15147
+ this.pushTokens(tokens);
14955
15148
 
14956
15149
  while (this.stack.length > oldStackLength) {
14957
- const expanded = this.expandOnce(); // expandOnce returns Token if and only if it's fully expanded.
15150
+ const expanded = this.expandOnce(true); // expand only expandable tokens
15151
+ // expandOnce returns Token if and only if it's fully expanded.
14958
15152
 
14959
15153
  if (expanded instanceof Token) {
15154
+ if (expanded.treatAsRelax) {
15155
+ // the expansion of \noexpand is the token itself
15156
+ expanded.noexpand = false;
15157
+ expanded.treatAsRelax = false;
15158
+ }
15159
+
14960
15160
  output.push(this.stack.pop());
14961
15161
  }
14962
15162
  }
@@ -15036,699 +15236,389 @@ class MacroExpander {
15036
15236
  isDefined(name) {
15037
15237
  return this.macros.has(name) || functions.hasOwnProperty(name) || symbols.math.hasOwnProperty(name) || symbols.text.hasOwnProperty(name) || implicitCommands.hasOwnProperty(name);
15038
15238
  }
15239
+ /**
15240
+ * Determine whether a command is expandable.
15241
+ */
15242
+
15243
+
15244
+ isExpandable(name) {
15245
+ const macro = this.macros.get(name);
15246
+ return macro != null ? typeof macro === "string" || typeof macro === "function" || !macro.unexpandable // TODO(ylem): #2085
15247
+ : functions.hasOwnProperty(name)
15248
+ /* && !functions[name].primitive*/
15249
+ ;
15250
+ }
15039
15251
 
15040
15252
  }
15041
15253
 
15042
- // Mapping of Unicode accent characters to their LaTeX equivalent in text and
15043
- // math mode (when they exist).
15044
- var unicodeAccents = {
15045
- '\u0301': {
15046
- text: "\\'",
15047
- math: '\\acute'
15254
+ /* eslint no-constant-condition:0 */
15255
+
15256
+ const unicodeAccents = {
15257
+ "́": {
15258
+ "text": "\\'",
15259
+ "math": "\\acute"
15048
15260
  },
15049
- '\u0300': {
15050
- text: '\\`',
15051
- math: '\\grave'
15261
+ "̀": {
15262
+ "text": "\\`",
15263
+ "math": "\\grave"
15052
15264
  },
15053
- '\u0308': {
15054
- text: '\\"',
15055
- math: '\\ddot'
15265
+ "̈": {
15266
+ "text": "\\\"",
15267
+ "math": "\\ddot"
15056
15268
  },
15057
- '\u0303': {
15058
- text: '\\~',
15059
- math: '\\tilde'
15269
+ "̃": {
15270
+ "text": "\\~",
15271
+ "math": "\\tilde"
15060
15272
  },
15061
- '\u0304': {
15062
- text: '\\=',
15063
- math: '\\bar'
15273
+ "̄": {
15274
+ "text": "\\=",
15275
+ "math": "\\bar"
15064
15276
  },
15065
- '\u0306': {
15066
- text: '\\u',
15067
- math: '\\breve'
15277
+ "̆": {
15278
+ "text": "\\u",
15279
+ "math": "\\breve"
15068
15280
  },
15069
- '\u030c': {
15070
- text: '\\v',
15071
- math: '\\check'
15281
+ "̌": {
15282
+ "text": "\\v",
15283
+ "math": "\\check"
15072
15284
  },
15073
- '\u0302': {
15074
- text: '\\^',
15075
- math: '\\hat'
15285
+ "̂": {
15286
+ "text": "\\^",
15287
+ "math": "\\hat"
15076
15288
  },
15077
- '\u0307': {
15078
- text: '\\.',
15079
- math: '\\dot'
15289
+ "̇": {
15290
+ "text": "\\.",
15291
+ "math": "\\dot"
15080
15292
  },
15081
- '\u030a': {
15082
- text: '\\r',
15083
- math: '\\mathring'
15293
+ "̊": {
15294
+ "text": "\\r",
15295
+ "math": "\\mathring"
15084
15296
  },
15085
- '\u030b': {
15086
- text: '\\H'
15297
+ "̋": {
15298
+ "text": "\\H"
15087
15299
  }
15088
15300
  };
15089
-
15090
- // This file is GENERATED by unicodeMake.js. DO NOT MODIFY.
15091
- var unicodeSymbols = {
15092
- "\u00e1": "\u0061\u0301",
15093
- // á = \'{a}
15094
- "\u00e0": "\u0061\u0300",
15095
- // à = \`{a}
15096
- "\u00e4": "\u0061\u0308",
15097
- // ä = \"{a}
15098
- "\u01df": "\u0061\u0308\u0304",
15099
- // ǟ = \"\={a}
15100
- "\u00e3": "\u0061\u0303",
15101
- // ã = \~{a}
15102
- "\u0101": "\u0061\u0304",
15103
- // ā = \={a}
15104
- "\u0103": "\u0061\u0306",
15105
- // ă = \u{a}
15106
- "\u1eaf": "\u0061\u0306\u0301",
15107
- // ắ = \u\'{a}
15108
- "\u1eb1": "\u0061\u0306\u0300",
15109
- // ằ = \u\`{a}
15110
- "\u1eb5": "\u0061\u0306\u0303",
15111
- // ẵ = \u\~{a}
15112
- "\u01ce": "\u0061\u030c",
15113
- // ǎ = \v{a}
15114
- "\u00e2": "\u0061\u0302",
15115
- // â = \^{a}
15116
- "\u1ea5": "\u0061\u0302\u0301",
15117
- // ấ = \^\'{a}
15118
- "\u1ea7": "\u0061\u0302\u0300",
15119
- // ầ = \^\`{a}
15120
- "\u1eab": "\u0061\u0302\u0303",
15121
- // ẫ = \^\~{a}
15122
- "\u0227": "\u0061\u0307",
15123
- // ȧ = \.{a}
15124
- "\u01e1": "\u0061\u0307\u0304",
15125
- // ǡ = \.\={a}
15126
- "\u00e5": "\u0061\u030a",
15127
- // å = \r{a}
15128
- "\u01fb": "\u0061\u030a\u0301",
15129
- // ǻ = \r\'{a}
15130
- "\u1e03": "\u0062\u0307",
15131
- // ḃ = \.{b}
15132
- "\u0107": "\u0063\u0301",
15133
- // ć = \'{c}
15134
- "\u010d": "\u0063\u030c",
15135
- // č = \v{c}
15136
- "\u0109": "\u0063\u0302",
15137
- // ĉ = \^{c}
15138
- "\u010b": "\u0063\u0307",
15139
- // ċ = \.{c}
15140
- "\u010f": "\u0064\u030c",
15141
- // ď = \v{d}
15142
- "\u1e0b": "\u0064\u0307",
15143
- // ḋ = \.{d}
15144
- "\u00e9": "\u0065\u0301",
15145
- // é = \'{e}
15146
- "\u00e8": "\u0065\u0300",
15147
- // è = \`{e}
15148
- "\u00eb": "\u0065\u0308",
15149
- // ë = \"{e}
15150
- "\u1ebd": "\u0065\u0303",
15151
- // ẽ = \~{e}
15152
- "\u0113": "\u0065\u0304",
15153
- // ē = \={e}
15154
- "\u1e17": "\u0065\u0304\u0301",
15155
- // ḗ = \=\'{e}
15156
- "\u1e15": "\u0065\u0304\u0300",
15157
- // ḕ = \=\`{e}
15158
- "\u0115": "\u0065\u0306",
15159
- // ĕ = \u{e}
15160
- "\u011b": "\u0065\u030c",
15161
- // ě = \v{e}
15162
- "\u00ea": "\u0065\u0302",
15163
- // ê = \^{e}
15164
- "\u1ebf": "\u0065\u0302\u0301",
15165
- // ế = \^\'{e}
15166
- "\u1ec1": "\u0065\u0302\u0300",
15167
- // ề = \^\`{e}
15168
- "\u1ec5": "\u0065\u0302\u0303",
15169
- // ễ = \^\~{e}
15170
- "\u0117": "\u0065\u0307",
15171
- // ė = \.{e}
15172
- "\u1e1f": "\u0066\u0307",
15173
- // ḟ = \.{f}
15174
- "\u01f5": "\u0067\u0301",
15175
- // ǵ = \'{g}
15176
- "\u1e21": "\u0067\u0304",
15177
- // ḡ = \={g}
15178
- "\u011f": "\u0067\u0306",
15179
- // ğ = \u{g}
15180
- "\u01e7": "\u0067\u030c",
15181
- // ǧ = \v{g}
15182
- "\u011d": "\u0067\u0302",
15183
- // ĝ = \^{g}
15184
- "\u0121": "\u0067\u0307",
15185
- // ġ = \.{g}
15186
- "\u1e27": "\u0068\u0308",
15187
- // ḧ = \"{h}
15188
- "\u021f": "\u0068\u030c",
15189
- // ȟ = \v{h}
15190
- "\u0125": "\u0068\u0302",
15191
- // ĥ = \^{h}
15192
- "\u1e23": "\u0068\u0307",
15193
- // ḣ = \.{h}
15194
- "\u00ed": "\u0069\u0301",
15195
- // í = \'{i}
15196
- "\u00ec": "\u0069\u0300",
15197
- // ì = \`{i}
15198
- "\u00ef": "\u0069\u0308",
15199
- // ï = \"{i}
15200
- "\u1e2f": "\u0069\u0308\u0301",
15201
- // ḯ = \"\'{i}
15202
- "\u0129": "\u0069\u0303",
15203
- // ĩ = \~{i}
15204
- "\u012b": "\u0069\u0304",
15205
- // ī = \={i}
15206
- "\u012d": "\u0069\u0306",
15207
- // ĭ = \u{i}
15208
- "\u01d0": "\u0069\u030c",
15209
- // ǐ = \v{i}
15210
- "\u00ee": "\u0069\u0302",
15211
- // î = \^{i}
15212
- "\u01f0": "\u006a\u030c",
15213
- // ǰ = \v{j}
15214
- "\u0135": "\u006a\u0302",
15215
- // ĵ = \^{j}
15216
- "\u1e31": "\u006b\u0301",
15217
- // ḱ = \'{k}
15218
- "\u01e9": "\u006b\u030c",
15219
- // ǩ = \v{k}
15220
- "\u013a": "\u006c\u0301",
15221
- // ĺ = \'{l}
15222
- "\u013e": "\u006c\u030c",
15223
- // ľ = \v{l}
15224
- "\u1e3f": "\u006d\u0301",
15225
- // ḿ = \'{m}
15226
- "\u1e41": "\u006d\u0307",
15227
- // ṁ = \.{m}
15228
- "\u0144": "\u006e\u0301",
15229
- // ń = \'{n}
15230
- "\u01f9": "\u006e\u0300",
15231
- // ǹ = \`{n}
15232
- "\u00f1": "\u006e\u0303",
15233
- // ñ = \~{n}
15234
- "\u0148": "\u006e\u030c",
15235
- // ň = \v{n}
15236
- "\u1e45": "\u006e\u0307",
15237
- // ṅ = \.{n}
15238
- "\u00f3": "\u006f\u0301",
15239
- // ó = \'{o}
15240
- "\u00f2": "\u006f\u0300",
15241
- // ò = \`{o}
15242
- "\u00f6": "\u006f\u0308",
15243
- // ö = \"{o}
15244
- "\u022b": "\u006f\u0308\u0304",
15245
- // ȫ = \"\={o}
15246
- "\u00f5": "\u006f\u0303",
15247
- // õ = \~{o}
15248
- "\u1e4d": "\u006f\u0303\u0301",
15249
- // ṍ = \~\'{o}
15250
- "\u1e4f": "\u006f\u0303\u0308",
15251
- // ṏ = \~\"{o}
15252
- "\u022d": "\u006f\u0303\u0304",
15253
- // ȭ = \~\={o}
15254
- "\u014d": "\u006f\u0304",
15255
- // ō = \={o}
15256
- "\u1e53": "\u006f\u0304\u0301",
15257
- // ṓ = \=\'{o}
15258
- "\u1e51": "\u006f\u0304\u0300",
15259
- // ṑ = \=\`{o}
15260
- "\u014f": "\u006f\u0306",
15261
- // ŏ = \u{o}
15262
- "\u01d2": "\u006f\u030c",
15263
- // ǒ = \v{o}
15264
- "\u00f4": "\u006f\u0302",
15265
- // ô = \^{o}
15266
- "\u1ed1": "\u006f\u0302\u0301",
15267
- // ố = \^\'{o}
15268
- "\u1ed3": "\u006f\u0302\u0300",
15269
- // ồ = \^\`{o}
15270
- "\u1ed7": "\u006f\u0302\u0303",
15271
- // ỗ = \^\~{o}
15272
- "\u022f": "\u006f\u0307",
15273
- // ȯ = \.{o}
15274
- "\u0231": "\u006f\u0307\u0304",
15275
- // ȱ = \.\={o}
15276
- "\u0151": "\u006f\u030b",
15277
- // ő = \H{o}
15278
- "\u1e55": "\u0070\u0301",
15279
- // ṕ = \'{p}
15280
- "\u1e57": "\u0070\u0307",
15281
- // ṗ = \.{p}
15282
- "\u0155": "\u0072\u0301",
15283
- // ŕ = \'{r}
15284
- "\u0159": "\u0072\u030c",
15285
- // ř = \v{r}
15286
- "\u1e59": "\u0072\u0307",
15287
- // ṙ = \.{r}
15288
- "\u015b": "\u0073\u0301",
15289
- // ś = \'{s}
15290
- "\u1e65": "\u0073\u0301\u0307",
15291
- // ṥ = \'\.{s}
15292
- "\u0161": "\u0073\u030c",
15293
- // š = \v{s}
15294
- "\u1e67": "\u0073\u030c\u0307",
15295
- // ṧ = \v\.{s}
15296
- "\u015d": "\u0073\u0302",
15297
- // ŝ = \^{s}
15298
- "\u1e61": "\u0073\u0307",
15299
- // ṡ = \.{s}
15300
- "\u1e97": "\u0074\u0308",
15301
- // ẗ = \"{t}
15302
- "\u0165": "\u0074\u030c",
15303
- // ť = \v{t}
15304
- "\u1e6b": "\u0074\u0307",
15305
- // ṫ = \.{t}
15306
- "\u00fa": "\u0075\u0301",
15307
- // ú = \'{u}
15308
- "\u00f9": "\u0075\u0300",
15309
- // ù = \`{u}
15310
- "\u00fc": "\u0075\u0308",
15311
- // ü = \"{u}
15312
- "\u01d8": "\u0075\u0308\u0301",
15313
- // ǘ = \"\'{u}
15314
- "\u01dc": "\u0075\u0308\u0300",
15315
- // ǜ = \"\`{u}
15316
- "\u01d6": "\u0075\u0308\u0304",
15317
- // ǖ = \"\={u}
15318
- "\u01da": "\u0075\u0308\u030c",
15319
- // ǚ = \"\v{u}
15320
- "\u0169": "\u0075\u0303",
15321
- // ũ = \~{u}
15322
- "\u1e79": "\u0075\u0303\u0301",
15323
- // ṹ = \~\'{u}
15324
- "\u016b": "\u0075\u0304",
15325
- // ū = \={u}
15326
- "\u1e7b": "\u0075\u0304\u0308",
15327
- // ṻ = \=\"{u}
15328
- "\u016d": "\u0075\u0306",
15329
- // ŭ = \u{u}
15330
- "\u01d4": "\u0075\u030c",
15331
- // ǔ = \v{u}
15332
- "\u00fb": "\u0075\u0302",
15333
- // û = \^{u}
15334
- "\u016f": "\u0075\u030a",
15335
- // ů = \r{u}
15336
- "\u0171": "\u0075\u030b",
15337
- // ű = \H{u}
15338
- "\u1e7d": "\u0076\u0303",
15339
- // ṽ = \~{v}
15340
- "\u1e83": "\u0077\u0301",
15341
- // ẃ = \'{w}
15342
- "\u1e81": "\u0077\u0300",
15343
- // ẁ = \`{w}
15344
- "\u1e85": "\u0077\u0308",
15345
- // ẅ = \"{w}
15346
- "\u0175": "\u0077\u0302",
15347
- // ŵ = \^{w}
15348
- "\u1e87": "\u0077\u0307",
15349
- // ẇ = \.{w}
15350
- "\u1e98": "\u0077\u030a",
15351
- // ẘ = \r{w}
15352
- "\u1e8d": "\u0078\u0308",
15353
- // ẍ = \"{x}
15354
- "\u1e8b": "\u0078\u0307",
15355
- // ẋ = \.{x}
15356
- "\u00fd": "\u0079\u0301",
15357
- // ý = \'{y}
15358
- "\u1ef3": "\u0079\u0300",
15359
- // ỳ = \`{y}
15360
- "\u00ff": "\u0079\u0308",
15361
- // ÿ = \"{y}
15362
- "\u1ef9": "\u0079\u0303",
15363
- // ỹ = \~{y}
15364
- "\u0233": "\u0079\u0304",
15365
- // ȳ = \={y}
15366
- "\u0177": "\u0079\u0302",
15367
- // ŷ = \^{y}
15368
- "\u1e8f": "\u0079\u0307",
15369
- // ẏ = \.{y}
15370
- "\u1e99": "\u0079\u030a",
15371
- // ẙ = \r{y}
15372
- "\u017a": "\u007a\u0301",
15373
- // ź = \'{z}
15374
- "\u017e": "\u007a\u030c",
15375
- // ž = \v{z}
15376
- "\u1e91": "\u007a\u0302",
15377
- // ẑ = \^{z}
15378
- "\u017c": "\u007a\u0307",
15379
- // ż = \.{z}
15380
- "\u00c1": "\u0041\u0301",
15381
- // Á = \'{A}
15382
- "\u00c0": "\u0041\u0300",
15383
- // À = \`{A}
15384
- "\u00c4": "\u0041\u0308",
15385
- // Ä = \"{A}
15386
- "\u01de": "\u0041\u0308\u0304",
15387
- // Ǟ = \"\={A}
15388
- "\u00c3": "\u0041\u0303",
15389
- // Ã = \~{A}
15390
- "\u0100": "\u0041\u0304",
15391
- // Ā = \={A}
15392
- "\u0102": "\u0041\u0306",
15393
- // Ă = \u{A}
15394
- "\u1eae": "\u0041\u0306\u0301",
15395
- // Ắ = \u\'{A}
15396
- "\u1eb0": "\u0041\u0306\u0300",
15397
- // Ằ = \u\`{A}
15398
- "\u1eb4": "\u0041\u0306\u0303",
15399
- // Ẵ = \u\~{A}
15400
- "\u01cd": "\u0041\u030c",
15401
- // Ǎ = \v{A}
15402
- "\u00c2": "\u0041\u0302",
15403
- // Â = \^{A}
15404
- "\u1ea4": "\u0041\u0302\u0301",
15405
- // Ấ = \^\'{A}
15406
- "\u1ea6": "\u0041\u0302\u0300",
15407
- // Ầ = \^\`{A}
15408
- "\u1eaa": "\u0041\u0302\u0303",
15409
- // Ẫ = \^\~{A}
15410
- "\u0226": "\u0041\u0307",
15411
- // Ȧ = \.{A}
15412
- "\u01e0": "\u0041\u0307\u0304",
15413
- // Ǡ = \.\={A}
15414
- "\u00c5": "\u0041\u030a",
15415
- // Å = \r{A}
15416
- "\u01fa": "\u0041\u030a\u0301",
15417
- // Ǻ = \r\'{A}
15418
- "\u1e02": "\u0042\u0307",
15419
- // Ḃ = \.{B}
15420
- "\u0106": "\u0043\u0301",
15421
- // Ć = \'{C}
15422
- "\u010c": "\u0043\u030c",
15423
- // Č = \v{C}
15424
- "\u0108": "\u0043\u0302",
15425
- // Ĉ = \^{C}
15426
- "\u010a": "\u0043\u0307",
15427
- // Ċ = \.{C}
15428
- "\u010e": "\u0044\u030c",
15429
- // Ď = \v{D}
15430
- "\u1e0a": "\u0044\u0307",
15431
- // Ḋ = \.{D}
15432
- "\u00c9": "\u0045\u0301",
15433
- // É = \'{E}
15434
- "\u00c8": "\u0045\u0300",
15435
- // È = \`{E}
15436
- "\u00cb": "\u0045\u0308",
15437
- // Ë = \"{E}
15438
- "\u1ebc": "\u0045\u0303",
15439
- // Ẽ = \~{E}
15440
- "\u0112": "\u0045\u0304",
15441
- // Ē = \={E}
15442
- "\u1e16": "\u0045\u0304\u0301",
15443
- // Ḗ = \=\'{E}
15444
- "\u1e14": "\u0045\u0304\u0300",
15445
- // Ḕ = \=\`{E}
15446
- "\u0114": "\u0045\u0306",
15447
- // Ĕ = \u{E}
15448
- "\u011a": "\u0045\u030c",
15449
- // Ě = \v{E}
15450
- "\u00ca": "\u0045\u0302",
15451
- // Ê = \^{E}
15452
- "\u1ebe": "\u0045\u0302\u0301",
15453
- // Ế = \^\'{E}
15454
- "\u1ec0": "\u0045\u0302\u0300",
15455
- // Ề = \^\`{E}
15456
- "\u1ec4": "\u0045\u0302\u0303",
15457
- // Ễ = \^\~{E}
15458
- "\u0116": "\u0045\u0307",
15459
- // Ė = \.{E}
15460
- "\u1e1e": "\u0046\u0307",
15461
- // Ḟ = \.{F}
15462
- "\u01f4": "\u0047\u0301",
15463
- // Ǵ = \'{G}
15464
- "\u1e20": "\u0047\u0304",
15465
- // Ḡ = \={G}
15466
- "\u011e": "\u0047\u0306",
15467
- // Ğ = \u{G}
15468
- "\u01e6": "\u0047\u030c",
15469
- // Ǧ = \v{G}
15470
- "\u011c": "\u0047\u0302",
15471
- // Ĝ = \^{G}
15472
- "\u0120": "\u0047\u0307",
15473
- // Ġ = \.{G}
15474
- "\u1e26": "\u0048\u0308",
15475
- // Ḧ = \"{H}
15476
- "\u021e": "\u0048\u030c",
15477
- // Ȟ = \v{H}
15478
- "\u0124": "\u0048\u0302",
15479
- // Ĥ = \^{H}
15480
- "\u1e22": "\u0048\u0307",
15481
- // Ḣ = \.{H}
15482
- "\u00cd": "\u0049\u0301",
15483
- // Í = \'{I}
15484
- "\u00cc": "\u0049\u0300",
15485
- // Ì = \`{I}
15486
- "\u00cf": "\u0049\u0308",
15487
- // Ï = \"{I}
15488
- "\u1e2e": "\u0049\u0308\u0301",
15489
- // Ḯ = \"\'{I}
15490
- "\u0128": "\u0049\u0303",
15491
- // Ĩ = \~{I}
15492
- "\u012a": "\u0049\u0304",
15493
- // Ī = \={I}
15494
- "\u012c": "\u0049\u0306",
15495
- // Ĭ = \u{I}
15496
- "\u01cf": "\u0049\u030c",
15497
- // Ǐ = \v{I}
15498
- "\u00ce": "\u0049\u0302",
15499
- // Î = \^{I}
15500
- "\u0130": "\u0049\u0307",
15501
- // İ = \.{I}
15502
- "\u0134": "\u004a\u0302",
15503
- // Ĵ = \^{J}
15504
- "\u1e30": "\u004b\u0301",
15505
- // Ḱ = \'{K}
15506
- "\u01e8": "\u004b\u030c",
15507
- // Ǩ = \v{K}
15508
- "\u0139": "\u004c\u0301",
15509
- // Ĺ = \'{L}
15510
- "\u013d": "\u004c\u030c",
15511
- // Ľ = \v{L}
15512
- "\u1e3e": "\u004d\u0301",
15513
- // Ḿ = \'{M}
15514
- "\u1e40": "\u004d\u0307",
15515
- // Ṁ = \.{M}
15516
- "\u0143": "\u004e\u0301",
15517
- // Ń = \'{N}
15518
- "\u01f8": "\u004e\u0300",
15519
- // Ǹ = \`{N}
15520
- "\u00d1": "\u004e\u0303",
15521
- // Ñ = \~{N}
15522
- "\u0147": "\u004e\u030c",
15523
- // Ň = \v{N}
15524
- "\u1e44": "\u004e\u0307",
15525
- // Ṅ = \.{N}
15526
- "\u00d3": "\u004f\u0301",
15527
- // Ó = \'{O}
15528
- "\u00d2": "\u004f\u0300",
15529
- // Ò = \`{O}
15530
- "\u00d6": "\u004f\u0308",
15531
- // Ö = \"{O}
15532
- "\u022a": "\u004f\u0308\u0304",
15533
- // Ȫ = \"\={O}
15534
- "\u00d5": "\u004f\u0303",
15535
- // Õ = \~{O}
15536
- "\u1e4c": "\u004f\u0303\u0301",
15537
- // Ṍ = \~\'{O}
15538
- "\u1e4e": "\u004f\u0303\u0308",
15539
- // Ṏ = \~\"{O}
15540
- "\u022c": "\u004f\u0303\u0304",
15541
- // Ȭ = \~\={O}
15542
- "\u014c": "\u004f\u0304",
15543
- // Ō = \={O}
15544
- "\u1e52": "\u004f\u0304\u0301",
15545
- // Ṓ = \=\'{O}
15546
- "\u1e50": "\u004f\u0304\u0300",
15547
- // Ṑ = \=\`{O}
15548
- "\u014e": "\u004f\u0306",
15549
- // Ŏ = \u{O}
15550
- "\u01d1": "\u004f\u030c",
15551
- // Ǒ = \v{O}
15552
- "\u00d4": "\u004f\u0302",
15553
- // Ô = \^{O}
15554
- "\u1ed0": "\u004f\u0302\u0301",
15555
- // Ố = \^\'{O}
15556
- "\u1ed2": "\u004f\u0302\u0300",
15557
- // Ồ = \^\`{O}
15558
- "\u1ed6": "\u004f\u0302\u0303",
15559
- // Ỗ = \^\~{O}
15560
- "\u022e": "\u004f\u0307",
15561
- // Ȯ = \.{O}
15562
- "\u0230": "\u004f\u0307\u0304",
15563
- // Ȱ = \.\={O}
15564
- "\u0150": "\u004f\u030b",
15565
- // Ő = \H{O}
15566
- "\u1e54": "\u0050\u0301",
15567
- // Ṕ = \'{P}
15568
- "\u1e56": "\u0050\u0307",
15569
- // Ṗ = \.{P}
15570
- "\u0154": "\u0052\u0301",
15571
- // Ŕ = \'{R}
15572
- "\u0158": "\u0052\u030c",
15573
- // Ř = \v{R}
15574
- "\u1e58": "\u0052\u0307",
15575
- // Ṙ = \.{R}
15576
- "\u015a": "\u0053\u0301",
15577
- // Ś = \'{S}
15578
- "\u1e64": "\u0053\u0301\u0307",
15579
- // Ṥ = \'\.{S}
15580
- "\u0160": "\u0053\u030c",
15581
- // Š = \v{S}
15582
- "\u1e66": "\u0053\u030c\u0307",
15583
- // Ṧ = \v\.{S}
15584
- "\u015c": "\u0053\u0302",
15585
- // Ŝ = \^{S}
15586
- "\u1e60": "\u0053\u0307",
15587
- // Ṡ = \.{S}
15588
- "\u0164": "\u0054\u030c",
15589
- // Ť = \v{T}
15590
- "\u1e6a": "\u0054\u0307",
15591
- // Ṫ = \.{T}
15592
- "\u00da": "\u0055\u0301",
15593
- // Ú = \'{U}
15594
- "\u00d9": "\u0055\u0300",
15595
- // Ù = \`{U}
15596
- "\u00dc": "\u0055\u0308",
15597
- // Ü = \"{U}
15598
- "\u01d7": "\u0055\u0308\u0301",
15599
- // Ǘ = \"\'{U}
15600
- "\u01db": "\u0055\u0308\u0300",
15601
- // Ǜ = \"\`{U}
15602
- "\u01d5": "\u0055\u0308\u0304",
15603
- // Ǖ = \"\={U}
15604
- "\u01d9": "\u0055\u0308\u030c",
15605
- // Ǚ = \"\v{U}
15606
- "\u0168": "\u0055\u0303",
15607
- // Ũ = \~{U}
15608
- "\u1e78": "\u0055\u0303\u0301",
15609
- // Ṹ = \~\'{U}
15610
- "\u016a": "\u0055\u0304",
15611
- // Ū = \={U}
15612
- "\u1e7a": "\u0055\u0304\u0308",
15613
- // Ṻ = \=\"{U}
15614
- "\u016c": "\u0055\u0306",
15615
- // Ŭ = \u{U}
15616
- "\u01d3": "\u0055\u030c",
15617
- // Ǔ = \v{U}
15618
- "\u00db": "\u0055\u0302",
15619
- // Û = \^{U}
15620
- "\u016e": "\u0055\u030a",
15621
- // Ů = \r{U}
15622
- "\u0170": "\u0055\u030b",
15623
- // Ű = \H{U}
15624
- "\u1e7c": "\u0056\u0303",
15625
- // Ṽ = \~{V}
15626
- "\u1e82": "\u0057\u0301",
15627
- // Ẃ = \'{W}
15628
- "\u1e80": "\u0057\u0300",
15629
- // Ẁ = \`{W}
15630
- "\u1e84": "\u0057\u0308",
15631
- // Ẅ = \"{W}
15632
- "\u0174": "\u0057\u0302",
15633
- // Ŵ = \^{W}
15634
- "\u1e86": "\u0057\u0307",
15635
- // Ẇ = \.{W}
15636
- "\u1e8c": "\u0058\u0308",
15637
- // Ẍ = \"{X}
15638
- "\u1e8a": "\u0058\u0307",
15639
- // Ẋ = \.{X}
15640
- "\u00dd": "\u0059\u0301",
15641
- // Ý = \'{Y}
15642
- "\u1ef2": "\u0059\u0300",
15643
- // Ỳ = \`{Y}
15644
- "\u0178": "\u0059\u0308",
15645
- // Ÿ = \"{Y}
15646
- "\u1ef8": "\u0059\u0303",
15647
- // Ỹ = \~{Y}
15648
- "\u0232": "\u0059\u0304",
15649
- // Ȳ = \={Y}
15650
- "\u0176": "\u0059\u0302",
15651
- // Ŷ = \^{Y}
15652
- "\u1e8e": "\u0059\u0307",
15653
- // Ẏ = \.{Y}
15654
- "\u0179": "\u005a\u0301",
15655
- // Ź = \'{Z}
15656
- "\u017d": "\u005a\u030c",
15657
- // Ž = \v{Z}
15658
- "\u1e90": "\u005a\u0302",
15659
- // Ẑ = \^{Z}
15660
- "\u017b": "\u005a\u0307",
15661
- // Ż = \.{Z}
15662
- "\u03ac": "\u03b1\u0301",
15663
- // ά = \'{α}
15664
- "\u1f70": "\u03b1\u0300",
15665
- // ὰ = \`{α}
15666
- "\u1fb1": "\u03b1\u0304",
15667
- // ᾱ = \={α}
15668
- "\u1fb0": "\u03b1\u0306",
15669
- // ᾰ = \u{α}
15670
- "\u03ad": "\u03b5\u0301",
15671
- // έ = \'{ε}
15672
- "\u1f72": "\u03b5\u0300",
15673
- // ὲ = \`{ε}
15674
- "\u03ae": "\u03b7\u0301",
15675
- // ή = \'{η}
15676
- "\u1f74": "\u03b7\u0300",
15677
- // ὴ = \`{η}
15678
- "\u03af": "\u03b9\u0301",
15679
- // ί = \'{ι}
15680
- "\u1f76": "\u03b9\u0300",
15681
- // ὶ = \`{ι}
15682
- "\u03ca": "\u03b9\u0308",
15683
- // ϊ = \"{ι}
15684
- "\u0390": "\u03b9\u0308\u0301",
15685
- // ΐ = \"\'{ι}
15686
- "\u1fd2": "\u03b9\u0308\u0300",
15687
- // ῒ = \"\`{ι}
15688
- "\u1fd1": "\u03b9\u0304",
15689
- // ῑ = \={ι}
15690
- "\u1fd0": "\u03b9\u0306",
15691
- // ῐ = \u{ι}
15692
- "\u03cc": "\u03bf\u0301",
15693
- // ό = \'{ο}
15694
- "\u1f78": "\u03bf\u0300",
15695
- // ὸ = \`{ο}
15696
- "\u03cd": "\u03c5\u0301",
15697
- // ύ = \'{υ}
15698
- "\u1f7a": "\u03c5\u0300",
15699
- // ὺ = \`{υ}
15700
- "\u03cb": "\u03c5\u0308",
15701
- // ϋ = \"{υ}
15702
- "\u03b0": "\u03c5\u0308\u0301",
15703
- // ΰ = \"\'{υ}
15704
- "\u1fe2": "\u03c5\u0308\u0300",
15705
- // ῢ = \"\`{υ}
15706
- "\u1fe1": "\u03c5\u0304",
15707
- // ῡ = \={υ}
15708
- "\u1fe0": "\u03c5\u0306",
15709
- // ῠ = \u{υ}
15710
- "\u03ce": "\u03c9\u0301",
15711
- // ώ = \'{ω}
15712
- "\u1f7c": "\u03c9\u0300",
15713
- // ὼ = \`{ω}
15714
- "\u038e": "\u03a5\u0301",
15715
- // Ύ = \'{Υ}
15716
- "\u1fea": "\u03a5\u0300",
15717
- // Ὺ = \`{Υ}
15718
- "\u03ab": "\u03a5\u0308",
15719
- // Ϋ = \"{Υ}
15720
- "\u1fe9": "\u03a5\u0304",
15721
- // Ῡ = \={Υ}
15722
- "\u1fe8": "\u03a5\u0306",
15723
- // Ῠ = \u{Υ}
15724
- "\u038f": "\u03a9\u0301",
15725
- // Ώ = \'{Ω}
15726
- "\u1ffa": "\u03a9\u0300" // Ὼ = \`{Ω}
15727
-
15301
+ const unicodeSymbols = {
15302
+ "á": "á",
15303
+ "à": "à",
15304
+ "ä": "",
15305
+ "ǟ": "ǟ",
15306
+ "ã": "",
15307
+ "ā": "ā",
15308
+ "ă": "",
15309
+ "ắ": "ắ",
15310
+ "": "ằ",
15311
+ "ẵ": "ẵ",
15312
+ "ǎ": "",
15313
+ "â": "â",
15314
+ "": "ấ",
15315
+ "ầ": "ầ",
15316
+ "": "ẫ",
15317
+ "ȧ": "ȧ",
15318
+ "ǡ": "ǡ",
15319
+ "å": "å",
15320
+ "ǻ": "ǻ",
15321
+ "ḃ": "ḃ",
15322
+ "ć": "",
15323
+ "č": "č",
15324
+ "ĉ": "",
15325
+ "ċ": "ċ",
15326
+ "ď": "",
15327
+ "ḋ": "ḋ",
15328
+ "é": "",
15329
+ "è": "è",
15330
+ "ë": "",
15331
+ "ẽ": "ẽ",
15332
+ "ē": "",
15333
+ "ḗ": "ḗ",
15334
+ "": "ḕ",
15335
+ "ĕ": "ĕ",
15336
+ "ě": "",
15337
+ "ê": "ê",
15338
+ "ế": "ế",
15339
+ "ề": "ề",
15340
+ "": "ễ",
15341
+ "ė": "ė",
15342
+ "": "",
15343
+ "ǵ": "ǵ",
15344
+ "": "",
15345
+ "ğ": "ğ",
15346
+ "ǧ": "",
15347
+ "ĝ": "ĝ",
15348
+ "ġ": "",
15349
+ "ḧ": "ḧ",
15350
+ "ȟ": "",
15351
+ "ĥ": "ĥ",
15352
+ "": "",
15353
+ "í": "í",
15354
+ "ì": "",
15355
+ "ï": "ï",
15356
+ "": "ḯ",
15357
+ "ĩ": "ĩ",
15358
+ "ī": "",
15359
+ "ĭ": "ĭ",
15360
+ "ǐ": "",
15361
+ "î": "î",
15362
+ "ǰ": "",
15363
+ "ĵ": "ĵ",
15364
+ "": "",
15365
+ "ǩ": "ǩ",
15366
+ "ĺ": "",
15367
+ "ľ": "ľ",
15368
+ "ḿ": "",
15369
+ "ṁ": "ṁ",
15370
+ "ń": "",
15371
+ "ǹ": "ǹ",
15372
+ "ñ": "",
15373
+ "ň": "ň",
15374
+ "": "",
15375
+ "ó": "ó",
15376
+ "ò": "",
15377
+ "ö": "ö",
15378
+ "ȫ": "ȫ",
15379
+ "õ": "õ",
15380
+ "": "ṍ",
15381
+ "ṏ": "ṏ",
15382
+ "ȭ": "ȭ",
15383
+ "ō": "ō",
15384
+ "": "ṓ",
15385
+ "ṑ": "ṑ",
15386
+ "ŏ": "",
15387
+ "ǒ": "ǒ",
15388
+ "ô": "",
15389
+ "ố": "ố",
15390
+ "": "ồ",
15391
+ "ỗ": "ỗ",
15392
+ "ȯ": "",
15393
+ "ȱ": "ȱ",
15394
+ "ő": "",
15395
+ "ṕ": "ṕ",
15396
+ "": "",
15397
+ "ŕ": "ŕ",
15398
+ "ř": "",
15399
+ "ṙ": "ṙ",
15400
+ "ś": "",
15401
+ "ṥ": "ṥ",
15402
+ "š": "",
15403
+ "ṧ": "ṧ",
15404
+ "ŝ": "",
15405
+ "ṡ": "ṡ",
15406
+ "": "",
15407
+ "ť": "ť",
15408
+ "": "",
15409
+ "ú": "ú",
15410
+ "ù": "",
15411
+ "ü": "ü",
15412
+ "ǘ": "ǘ",
15413
+ "ǜ": "ǜ",
15414
+ "ǖ": "ǖ",
15415
+ "ǚ": "ǚ",
15416
+ "ũ": "",
15417
+ "ṹ": "ṹ",
15418
+ "ū": "",
15419
+ "ṻ": "ṻ",
15420
+ "ŭ": "",
15421
+ "ǔ": "ǔ",
15422
+ "û": "",
15423
+ "ů": "ů",
15424
+ "ű": "",
15425
+ "ṽ": "ṽ",
15426
+ "": "",
15427
+ "ẁ": "ẁ",
15428
+ "": "",
15429
+ "ŵ": "ŵ",
15430
+ "": "",
15431
+ "ẘ": "ẘ",
15432
+ "": "",
15433
+ "ẋ": "ẋ",
15434
+ "ý": "",
15435
+ "ỳ": "ỳ",
15436
+ "ÿ": "",
15437
+ "ỹ": "ỹ",
15438
+ "ȳ": "",
15439
+ "ŷ": "ŷ",
15440
+ "": "",
15441
+ "ẙ": "ẙ",
15442
+ "ź": "",
15443
+ "ž": "ž",
15444
+ "": "",
15445
+ "ż": "ż",
15446
+ "Á": "",
15447
+ "À": "À",
15448
+ "Ä": "",
15449
+ "Ǟ": "Ǟ",
15450
+ "Ã": "",
15451
+ "Ā": "Ā",
15452
+ "Ă": "",
15453
+ "Ắ": "Ắ",
15454
+ "": "Ằ",
15455
+ "Ẵ": "Ẵ",
15456
+ "Ǎ": "",
15457
+ "Â": "Â",
15458
+ "": "Ấ",
15459
+ "Ầ": "Ầ",
15460
+ "": "Ẫ",
15461
+ "Ȧ": "Ȧ",
15462
+ "Ǡ": "Ǡ",
15463
+ "Å": "Å",
15464
+ "Ǻ": "Ǻ",
15465
+ "Ḃ": "Ḃ",
15466
+ "Ć": "",
15467
+ "Č": "Č",
15468
+ "Ĉ": "",
15469
+ "Ċ": "Ċ",
15470
+ "Ď": "",
15471
+ "Ḋ": "Ḋ",
15472
+ "É": "",
15473
+ "È": "È",
15474
+ "Ë": "",
15475
+ "Ẽ": "Ẽ",
15476
+ "Ē": "",
15477
+ "Ḗ": "Ḗ",
15478
+ "": "Ḕ",
15479
+ "Ĕ": "Ĕ",
15480
+ "Ě": "",
15481
+ "Ê": "Ê",
15482
+ "": "Ế",
15483
+ "Ề": "Ề",
15484
+ "": "Ễ",
15485
+ "Ė": "Ė",
15486
+ "": "",
15487
+ "Ǵ": "Ǵ",
15488
+ "": "",
15489
+ "Ğ": "Ğ",
15490
+ "Ǧ": "",
15491
+ "Ĝ": "Ĝ",
15492
+ "Ġ": "",
15493
+ "Ḧ": "Ḧ",
15494
+ "Ȟ": "",
15495
+ "Ĥ": "Ĥ",
15496
+ "": "",
15497
+ "Í": "Í",
15498
+ "Ì": "",
15499
+ "Ï": "Ï",
15500
+ "": "Ḯ",
15501
+ "Ĩ": "Ĩ",
15502
+ "Ī": "",
15503
+ "Ĭ": "Ĭ",
15504
+ "Ǐ": "",
15505
+ "Î": "Î",
15506
+ "İ": "",
15507
+ "Ĵ": "Ĵ",
15508
+ "": "",
15509
+ "Ǩ": "Ǩ",
15510
+ "Ĺ": "",
15511
+ "Ľ": "Ľ",
15512
+ "": "",
15513
+ "Ṁ": "Ṁ",
15514
+ "Ń": "",
15515
+ "Ǹ": "Ǹ",
15516
+ "Ñ": "",
15517
+ "Ň": "Ň",
15518
+ "": "",
15519
+ "Ó": "Ó",
15520
+ "Ò": "",
15521
+ "Ö": "Ö",
15522
+ "Ȫ": "Ȫ",
15523
+ "Õ": "Õ",
15524
+ "": "Ṍ",
15525
+ "Ṏ": "Ṏ",
15526
+ "Ȭ": "Ȭ",
15527
+ "Ō": "Ō",
15528
+ "": "Ṓ",
15529
+ "Ṑ": "Ṑ",
15530
+ "Ŏ": "",
15531
+ "Ǒ": "Ǒ",
15532
+ "Ô": "",
15533
+ "Ố": "Ố",
15534
+ "": "Ồ",
15535
+ "Ỗ": "Ỗ",
15536
+ "Ȯ": "",
15537
+ "Ȱ": "Ȱ",
15538
+ "Ő": "",
15539
+ "Ṕ": "Ṕ",
15540
+ "": "",
15541
+ "Ŕ": "Ŕ",
15542
+ "Ř": "",
15543
+ "Ṙ": "Ṙ",
15544
+ "Ś": "",
15545
+ "Ṥ": "Ṥ",
15546
+ "Š": "",
15547
+ "Ṧ": "Ṧ",
15548
+ "Ŝ": "",
15549
+ "Ṡ": "Ṡ",
15550
+ "Ť": "",
15551
+ "Ṫ": "Ṫ",
15552
+ "Ú": "",
15553
+ "Ù": "Ù",
15554
+ "Ü": "",
15555
+ "Ǘ": "Ǘ",
15556
+ "Ǜ": "Ǜ",
15557
+ "Ǖ": "Ǖ",
15558
+ "Ǚ": "Ǚ",
15559
+ "Ũ": "Ũ",
15560
+ "": "Ṹ",
15561
+ "Ū": "Ū",
15562
+ "": "Ṻ",
15563
+ "Ŭ": "Ŭ",
15564
+ "Ǔ": "",
15565
+ "Û": "Û",
15566
+ "Ů": "",
15567
+ "Ű": "Ű",
15568
+ "": "",
15569
+ "Ẃ": "Ẃ",
15570
+ "": "",
15571
+ "Ẅ": "Ẅ",
15572
+ "Ŵ": "",
15573
+ "Ẇ": "Ẇ",
15574
+ "": "",
15575
+ "Ẋ": "Ẋ",
15576
+ "Ý": "",
15577
+ "Ỳ": "Ỳ",
15578
+ "Ÿ": "",
15579
+ "Ỹ": "Ỹ",
15580
+ "Ȳ": "",
15581
+ "Ŷ": "Ŷ",
15582
+ "": "",
15583
+ "Ź": "Ź",
15584
+ "Ž": "",
15585
+ "Ẑ": "Ẑ",
15586
+ "Ż": "",
15587
+ "ά": "ά",
15588
+ "": "ὰ",
15589
+ "ᾱ": "ᾱ",
15590
+ "": "ᾰ",
15591
+ "έ": "έ",
15592
+ "": "ὲ",
15593
+ "ή": "ή",
15594
+ "": "ὴ",
15595
+ "ί": "ί",
15596
+ "": "ὶ",
15597
+ "ϊ": "ϊ",
15598
+ "ΐ": "ΐ",
15599
+ "ῒ": "ῒ",
15600
+ "": "ῑ",
15601
+ "ῐ": "ῐ",
15602
+ "ό": "ό",
15603
+ "ὸ": "ὸ",
15604
+ "ύ": "ύ",
15605
+ "ὺ": "ὺ",
15606
+ "ϋ": "ϋ",
15607
+ "ΰ": "ΰ",
15608
+ "": "ῢ",
15609
+ "ῡ": "ῡ",
15610
+ "": "ῠ",
15611
+ "ώ": "ώ",
15612
+ "": "ὼ",
15613
+ "Ύ": "Ύ",
15614
+ "": "Ὺ",
15615
+ "Ϋ": "Ϋ",
15616
+ "": "Ῡ",
15617
+ "Ῠ": "Ῠ",
15618
+ "Ώ": "Ώ",
15619
+ "Ὼ": "Ὼ"
15728
15620
  };
15729
15621
 
15730
- /* eslint no-constant-condition:0 */
15731
-
15732
15622
  /**
15733
15623
  * This file contains the parser used to parse out a TeX expression from the
15734
15624
  * input. Since TeX isn't context-free, standard parsers don't work particularly
@@ -15831,12 +15721,15 @@ class Parser {
15831
15721
 
15832
15722
 
15833
15723
  parse() {
15834
- // Create a group namespace for the math expression.
15835
- // (LaTeX creates a new group for every $...$, $$...$$, \[...\].)
15836
- this.gullet.beginGroup(); // Use old \color behavior (same as LaTeX's \textcolor) if requested.
15724
+ if (!this.settings.globalGroup) {
15725
+ // Create a group namespace for the math expression.
15726
+ // (LaTeX creates a new group for every $...$, $$...$$, \[...\].)
15727
+ this.gullet.beginGroup();
15728
+ } // Use old \color behavior (same as LaTeX's \textcolor) if requested.
15837
15729
  // We do this within the group for the math expression, so it doesn't
15838
15730
  // pollute settings.macros.
15839
15731
 
15732
+
15840
15733
  if (this.settings.colorIsTextColor) {
15841
15734
  this.gullet.macros.set("\\color", "\\textcolor");
15842
15735
  } // Try to parse the input
@@ -15846,7 +15739,10 @@ class Parser {
15846
15739
 
15847
15740
  this.expect("EOF"); // End the group namespace for the expression
15848
15741
 
15849
- this.gullet.endGroup();
15742
+ if (!this.settings.globalGroup) {
15743
+ this.gullet.endGroup();
15744
+ }
15745
+
15850
15746
  return parse;
15851
15747
  }
15852
15748
 
@@ -15878,6 +15774,8 @@ class Parser {
15878
15774
 
15879
15775
  if (!atom) {
15880
15776
  break;
15777
+ } else if (atom.type === "internal") {
15778
+ continue;
15881
15779
  }
15882
15780
 
15883
15781
  body.push(atom);
@@ -15903,15 +15801,13 @@ class Parser {
15903
15801
  let funcName;
15904
15802
 
15905
15803
  for (let i = 0; i < body.length; i++) {
15906
- const node = checkNodeType(body[i], "infix");
15907
-
15908
- if (node) {
15804
+ if (body[i].type === "infix") {
15909
15805
  if (overIndex !== -1) {
15910
- throw new ParseError("only one infix operator per group", node.token);
15806
+ throw new ParseError("only one infix operator per group", body[i].token);
15911
15807
  }
15912
15808
 
15913
15809
  overIndex = i;
15914
- funcName = node.replaceWith;
15810
+ funcName = body[i].replaceWith;
15915
15811
  }
15916
15812
  }
15917
15813
 
@@ -16027,21 +15923,15 @@ class Parser {
16027
15923
 
16028
15924
  if (lex.text === "\\limits" || lex.text === "\\nolimits") {
16029
15925
  // We got a limit control
16030
- let opNode = checkNodeType(base, "op");
16031
-
16032
- if (opNode) {
15926
+ if (base && base.type === "op") {
16033
15927
  const limits = lex.text === "\\limits";
16034
- opNode.limits = limits;
16035
- opNode.alwaysHandleSupSub = true;
15928
+ base.limits = limits;
15929
+ base.alwaysHandleSupSub = true;
15930
+ } else if (base && base.type === "operatorname" && base.alwaysHandleSupSub) {
15931
+ const limits = lex.text === "\\limits";
15932
+ base.limits = limits;
16036
15933
  } else {
16037
- opNode = checkNodeType(base, "operatorname");
16038
-
16039
- if (opNode && opNode.alwaysHandleSupSub) {
16040
- const limits = lex.text === "\\limits";
16041
- opNode.limits = limits;
16042
- } else {
16043
- throw new ParseError("Limit controls must follow a math operator", lex);
16044
- }
15934
+ throw new ParseError("Limit controls must follow a math operator", lex);
16045
15935
  }
16046
15936
 
16047
15937
  this.consume();
@@ -16936,7 +16826,7 @@ var katex = {
16936
16826
  /**
16937
16827
  * Current KaTeX version
16938
16828
  */
16939
- version: "0.11.1",
16829
+ version: "0.12.0",
16940
16830
 
16941
16831
  /**
16942
16832
  * Renders the given LaTeX into an HTML+MathML combination, and adds