katex 0.13.14 → 0.13.19

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 (93) hide show
  1. package/README.md +3 -3
  2. package/cli.js +3 -1
  3. package/contrib/copy-tex/README.md +3 -3
  4. package/contrib/mathtex-script-type/README.md +5 -5
  5. package/contrib/mhchem/README.md +1 -1
  6. package/dist/README.md +3 -3
  7. package/dist/contrib/auto-render.js +5 -5
  8. package/dist/contrib/auto-render.min.js +1 -1
  9. package/dist/contrib/copy-tex.js +1 -1
  10. package/dist/contrib/mathtex-script-type.js +5 -5
  11. package/dist/contrib/mathtex-script-type.min.js +1 -1
  12. package/dist/contrib/mhchem.js +5 -5
  13. package/dist/contrib/mhchem.min.js +1 -1
  14. package/dist/contrib/render-a11y-string.js +5 -5
  15. package/dist/contrib/render-a11y-string.min.js +1 -1
  16. package/dist/fonts/KaTeX_AMS-Regular.ttf +0 -0
  17. package/dist/fonts/KaTeX_AMS-Regular.woff +0 -0
  18. package/dist/fonts/KaTeX_AMS-Regular.woff2 +0 -0
  19. package/dist/fonts/KaTeX_Caligraphic-Bold.ttf +0 -0
  20. package/dist/fonts/KaTeX_Caligraphic-Bold.woff +0 -0
  21. package/dist/fonts/KaTeX_Caligraphic-Bold.woff2 +0 -0
  22. package/dist/fonts/KaTeX_Caligraphic-Regular.ttf +0 -0
  23. package/dist/fonts/KaTeX_Caligraphic-Regular.woff +0 -0
  24. package/dist/fonts/KaTeX_Caligraphic-Regular.woff2 +0 -0
  25. package/dist/fonts/KaTeX_Fraktur-Bold.ttf +0 -0
  26. package/dist/fonts/KaTeX_Fraktur-Bold.woff +0 -0
  27. package/dist/fonts/KaTeX_Fraktur-Bold.woff2 +0 -0
  28. package/dist/fonts/KaTeX_Fraktur-Regular.ttf +0 -0
  29. package/dist/fonts/KaTeX_Fraktur-Regular.woff +0 -0
  30. package/dist/fonts/KaTeX_Fraktur-Regular.woff2 +0 -0
  31. package/dist/fonts/KaTeX_Main-Bold.ttf +0 -0
  32. package/dist/fonts/KaTeX_Main-Bold.woff +0 -0
  33. package/dist/fonts/KaTeX_Main-Bold.woff2 +0 -0
  34. package/dist/fonts/KaTeX_Main-BoldItalic.ttf +0 -0
  35. package/dist/fonts/KaTeX_Main-BoldItalic.woff +0 -0
  36. package/dist/fonts/KaTeX_Main-BoldItalic.woff2 +0 -0
  37. package/dist/fonts/KaTeX_Main-Italic.ttf +0 -0
  38. package/dist/fonts/KaTeX_Main-Italic.woff +0 -0
  39. package/dist/fonts/KaTeX_Main-Italic.woff2 +0 -0
  40. package/dist/fonts/KaTeX_Main-Regular.ttf +0 -0
  41. package/dist/fonts/KaTeX_Main-Regular.woff +0 -0
  42. package/dist/fonts/KaTeX_Main-Regular.woff2 +0 -0
  43. package/dist/fonts/KaTeX_Math-BoldItalic.ttf +0 -0
  44. package/dist/fonts/KaTeX_Math-BoldItalic.woff +0 -0
  45. package/dist/fonts/KaTeX_Math-BoldItalic.woff2 +0 -0
  46. package/dist/fonts/KaTeX_Math-Italic.ttf +0 -0
  47. package/dist/fonts/KaTeX_Math-Italic.woff +0 -0
  48. package/dist/fonts/KaTeX_Math-Italic.woff2 +0 -0
  49. package/dist/fonts/KaTeX_SansSerif-Bold.ttf +0 -0
  50. package/dist/fonts/KaTeX_SansSerif-Bold.woff +0 -0
  51. package/dist/fonts/KaTeX_SansSerif-Bold.woff2 +0 -0
  52. package/dist/fonts/KaTeX_SansSerif-Italic.ttf +0 -0
  53. package/dist/fonts/KaTeX_SansSerif-Italic.woff +0 -0
  54. package/dist/fonts/KaTeX_SansSerif-Italic.woff2 +0 -0
  55. package/dist/fonts/KaTeX_SansSerif-Regular.ttf +0 -0
  56. package/dist/fonts/KaTeX_SansSerif-Regular.woff +0 -0
  57. package/dist/fonts/KaTeX_SansSerif-Regular.woff2 +0 -0
  58. package/dist/fonts/KaTeX_Script-Regular.ttf +0 -0
  59. package/dist/fonts/KaTeX_Script-Regular.woff +0 -0
  60. package/dist/fonts/KaTeX_Script-Regular.woff2 +0 -0
  61. package/dist/fonts/KaTeX_Size1-Regular.ttf +0 -0
  62. package/dist/fonts/KaTeX_Size1-Regular.woff +0 -0
  63. package/dist/fonts/KaTeX_Size1-Regular.woff2 +0 -0
  64. package/dist/fonts/KaTeX_Size2-Regular.ttf +0 -0
  65. package/dist/fonts/KaTeX_Size2-Regular.woff +0 -0
  66. package/dist/fonts/KaTeX_Size2-Regular.woff2 +0 -0
  67. package/dist/fonts/KaTeX_Size3-Regular.ttf +0 -0
  68. package/dist/fonts/KaTeX_Size3-Regular.woff +0 -0
  69. package/dist/fonts/KaTeX_Size3-Regular.woff2 +0 -0
  70. package/dist/fonts/KaTeX_Size4-Regular.ttf +0 -0
  71. package/dist/fonts/KaTeX_Size4-Regular.woff +0 -0
  72. package/dist/fonts/KaTeX_Size4-Regular.woff2 +0 -0
  73. package/dist/fonts/KaTeX_Typewriter-Regular.ttf +0 -0
  74. package/dist/fonts/KaTeX_Typewriter-Regular.woff +0 -0
  75. package/dist/fonts/KaTeX_Typewriter-Regular.woff2 +0 -0
  76. package/dist/katex.css +1 -1
  77. package/dist/katex.js +92 -22
  78. package/dist/katex.min.css +1 -1
  79. package/dist/katex.min.js +1 -1
  80. package/dist/katex.mjs +91 -21
  81. package/package.json +5 -5
  82. package/src/MacroExpander.js +8 -0
  83. package/src/Namespace.js +10 -0
  84. package/src/Parser.js +17 -9
  85. package/src/fontMetrics.js +0 -2
  86. package/src/fonts/Makefile +2 -2
  87. package/src/functions/accent.js +11 -4
  88. package/src/functions/char.js +13 -2
  89. package/src/symbols.js +4 -3
  90. package/src/unicodeAccents.js +1 -0
  91. package/CHANGELOG.md +0 -833
  92. package/src/fonts/.gitignore +0 -9
  93. package/src/metrics/.gitignore +0 -1
package/dist/katex.mjs CHANGED
@@ -3616,11 +3616,9 @@ var sigmasAndXis = {
3616
3616
  var extraCharacterMap = {
3617
3617
  // Latin-1
3618
3618
  'Å': 'A',
3619
- 'Ç': 'C',
3620
3619
  'Ð': 'D',
3621
3620
  'Þ': 'o',
3622
3621
  'å': 'a',
3623
- 'ç': 'c',
3624
3622
  'ð': 'd',
3625
3623
  'þ': 'o',
3626
3624
  // Cyrillic
@@ -4275,9 +4273,9 @@ defineSymbol(math, main, mathord, "\u03d6", "\\varpi", true);
4275
4273
  defineSymbol(math, main, mathord, "\u03f1", "\\varrho", true);
4276
4274
  defineSymbol(math, main, mathord, "\u03c2", "\\varsigma", true);
4277
4275
  defineSymbol(math, main, mathord, "\u03c6", "\\varphi", true);
4278
- defineSymbol(math, main, bin, "\u2217", "*");
4276
+ defineSymbol(math, main, bin, "\u2217", "*", true);
4279
4277
  defineSymbol(math, main, bin, "+", "+");
4280
- defineSymbol(math, main, bin, "\u2212", "-");
4278
+ defineSymbol(math, main, bin, "\u2212", "-", true);
4281
4279
  defineSymbol(math, main, bin, "\u22c5", "\\cdot", true);
4282
4280
  defineSymbol(math, main, bin, "\u2218", "\\circ");
4283
4281
  defineSymbol(math, main, bin, "\u00f7", "\\div", true);
@@ -4458,6 +4456,8 @@ defineSymbol(text, main, accent, "\u02d8", "\\u"); // breve
4458
4456
 
4459
4457
  defineSymbol(text, main, accent, "\u02d9", "\\."); // dot above
4460
4458
 
4459
+ defineSymbol(text, main, accent, "\u00b8", "\\c"); // cedilla
4460
+
4461
4461
  defineSymbol(text, main, accent, "\u02da", "\\r"); // ring above
4462
4462
 
4463
4463
  defineSymbol(text, main, accent, "\u02c7", "\\v"); // caron
@@ -4639,7 +4639,7 @@ for (var _i4 = 0; _i4 < 10; _i4++) {
4639
4639
  // TODO(edemaine): Fix this.
4640
4640
 
4641
4641
 
4642
- var extraLatin = "\u00c7\u00d0\u00de\u00e7\u00fe";
4642
+ var extraLatin = "\u00d0\u00de\u00fe";
4643
4643
 
4644
4644
  for (var _i5 = 0; _i5 < extraLatin.length; _i5++) {
4645
4645
  var _ch5 = extraLatin.charAt(_i5);
@@ -7347,10 +7347,11 @@ var htmlBuilder$a = (grp, options) => {
7347
7347
  // removed with getBaseElem might contain things like \color which
7348
7348
  // we can't get rid of.
7349
7349
  // TODO(emily): Find a better way to get the skew
7350
- } // calculate the amount of space between the body and the accent
7350
+ }
7351
7351
 
7352
+ var accentBelow = group.label === "\\c"; // calculate the amount of space between the body and the accent
7352
7353
 
7353
- var clearance = Math.min(body.height, options.fontMetrics().xHeight); // Build the accent
7354
+ var clearance = accentBelow ? body.height + body.depth : Math.min(body.height, options.fontMetrics().xHeight); // Build the accent
7354
7355
 
7355
7356
  var accentBody;
7356
7357
 
@@ -7376,6 +7377,10 @@ var htmlBuilder$a = (grp, options) => {
7376
7377
 
7377
7378
  accent.italic = 0;
7378
7379
  width = accent.width;
7380
+
7381
+ if (accentBelow) {
7382
+ clearance += accent.depth;
7383
+ }
7379
7384
  }
7380
7385
 
7381
7386
  accentBody = buildCommon.makeSpan(["accent-body"], [accent]); // "Full" accents expand the width of the resulting symbol to be
@@ -7489,7 +7494,7 @@ defineFunction({
7489
7494
 
7490
7495
  defineFunction({
7491
7496
  type: "accent",
7492
- names: ["\\'", "\\`", "\\^", "\\~", "\\=", "\\u", "\\.", '\\"', "\\r", "\\H", "\\v", "\\textcircled"],
7497
+ names: ["\\'", "\\`", "\\^", "\\~", "\\=", "\\u", "\\.", '\\"', "\\c", "\\r", "\\H", "\\v", "\\textcircled"],
7493
7498
  props: {
7494
7499
  numArgs: 1,
7495
7500
  allowedInText: true,
@@ -8056,15 +8061,25 @@ defineFunction({
8056
8061
  }
8057
8062
 
8058
8063
  var code = parseInt(number);
8064
+ var text;
8059
8065
 
8060
8066
  if (isNaN(code)) {
8061
- throw new ParseError("\\@char has non-numeric argument " + number);
8067
+ throw new ParseError("\\@char has non-numeric argument " + number); // If we drop IE support, the following code could be replaced with
8068
+ // text = String.fromCodePoint(code)
8069
+ } else if (code < 0 || code >= 0x10ffff) {
8070
+ throw new ParseError("\\@char with invalid code point " + number);
8071
+ } else if (code <= 0xffff) {
8072
+ text = String.fromCharCode(code);
8073
+ } else {
8074
+ // Astral code point; split into surrogate halves
8075
+ code -= 0x10000;
8076
+ text = String.fromCharCode((code >> 10) + 0xd800, (code & 0x3ff) + 0xdc00);
8062
8077
  }
8063
8078
 
8064
8079
  return {
8065
8080
  type: "textord",
8066
8081
  mode: parser.mode,
8067
- text: String.fromCharCode(code)
8082
+ text: text
8068
8083
  };
8069
8084
  }
8070
8085
 
@@ -10023,7 +10038,8 @@ var htmlBuilder$7 = function htmlBuilder(group, options) {
10023
10038
  var nc = 0;
10024
10039
  var body = new Array(nr);
10025
10040
  var hlines = [];
10026
- var ruleThickness = Math.max(options.fontMetrics().arrayRuleWidth, options.minRuleThickness // User override.
10041
+ var ruleThickness = Math.max( // From LaTeX \showthe\arrayrulewidth. Equals 0.04 em.
10042
+ options.fontMetrics().arrayRuleWidth, options.minRuleThickness // User override.
10027
10043
  ); // Horizontal spacing
10028
10044
 
10029
10045
  var pt = 1 / options.fontMetrics().ptPerEm;
@@ -14643,6 +14659,17 @@ class Namespace {
14643
14659
  }
14644
14660
  }
14645
14661
  }
14662
+ /**
14663
+ * Ends all currently nested groups (if any), restoring values before the
14664
+ * groups began. Useful in case of an error in the middle of parsing.
14665
+ */
14666
+
14667
+
14668
+ endGroups() {
14669
+ while (this.undefStack.length > 0) {
14670
+ this.endGroup();
14671
+ }
14672
+ }
14646
14673
  /**
14647
14674
  * Detect whether `name` has a definition. Equivalent to
14648
14675
  * `get(name) != null`.
@@ -15668,6 +15695,15 @@ class MacroExpander {
15668
15695
  endGroup() {
15669
15696
  this.macros.endGroup();
15670
15697
  }
15698
+ /**
15699
+ * Ends all currently nested groups (if any), restoring values before the
15700
+ * groups began. Useful in case of an error in the middle of parsing.
15701
+ */
15702
+
15703
+
15704
+ endGroups() {
15705
+ this.macros.endGroups();
15706
+ }
15671
15707
  /**
15672
15708
  * Returns the topmost token on the stack, without expanding it.
15673
15709
  * Similar in behavior to TeX's `\futurelet`.
@@ -16156,6 +16192,9 @@ var unicodeAccents = {
16156
16192
  },
16157
16193
  "̋": {
16158
16194
  "text": "\\H"
16195
+ },
16196
+ "̧": {
16197
+ "text": "\\c"
16159
16198
  }
16160
16199
  };
16161
16200
  var unicodeSymbols = {
@@ -16180,11 +16219,14 @@ var unicodeSymbols = {
16180
16219
  "ǻ": "ǻ",
16181
16220
  "ḃ": "ḃ",
16182
16221
  "ć": "ć",
16222
+ "ḉ": "ḉ",
16183
16223
  "č": "č",
16184
16224
  "ĉ": "ĉ",
16185
16225
  "ċ": "ċ",
16226
+ "ç": "ç",
16186
16227
  "ď": "ď",
16187
16228
  "ḋ": "ḋ",
16229
+ "ḑ": "ḑ",
16188
16230
  "é": "é",
16189
16231
  "è": "è",
16190
16232
  "ë": "ë",
@@ -16193,12 +16235,14 @@ var unicodeSymbols = {
16193
16235
  "ḗ": "ḗ",
16194
16236
  "ḕ": "ḕ",
16195
16237
  "ĕ": "ĕ",
16238
+ "ḝ": "ḝ",
16196
16239
  "ě": "ě",
16197
16240
  "ê": "ê",
16198
16241
  "ế": "ế",
16199
16242
  "ề": "ề",
16200
16243
  "ễ": "ễ",
16201
16244
  "ė": "ė",
16245
+ "ȩ": "ȩ",
16202
16246
  "ḟ": "ḟ",
16203
16247
  "ǵ": "ǵ",
16204
16248
  "ḡ": "ḡ",
@@ -16206,10 +16250,12 @@ var unicodeSymbols = {
16206
16250
  "ǧ": "ǧ",
16207
16251
  "ĝ": "ĝ",
16208
16252
  "ġ": "ġ",
16253
+ "ģ": "ģ",
16209
16254
  "ḧ": "ḧ",
16210
16255
  "ȟ": "ȟ",
16211
16256
  "ĥ": "ĥ",
16212
16257
  "ḣ": "ḣ",
16258
+ "ḩ": "ḩ",
16213
16259
  "í": "í",
16214
16260
  "ì": "ì",
16215
16261
  "ï": "ï",
@@ -16223,8 +16269,10 @@ var unicodeSymbols = {
16223
16269
  "ĵ": "ĵ",
16224
16270
  "ḱ": "ḱ",
16225
16271
  "ǩ": "ǩ",
16272
+ "ķ": "ķ",
16226
16273
  "ĺ": "ĺ",
16227
16274
  "ľ": "ľ",
16275
+ "ļ": "ļ",
16228
16276
  "ḿ": "ḿ",
16229
16277
  "ṁ": "ṁ",
16230
16278
  "ń": "ń",
@@ -16232,6 +16280,7 @@ var unicodeSymbols = {
16232
16280
  "ñ": "ñ",
16233
16281
  "ň": "ň",
16234
16282
  "ṅ": "ṅ",
16283
+ "ņ": "ņ",
16235
16284
  "ó": "ó",
16236
16285
  "ò": "ò",
16237
16286
  "ö": "ö",
@@ -16257,15 +16306,18 @@ var unicodeSymbols = {
16257
16306
  "ŕ": "ŕ",
16258
16307
  "ř": "ř",
16259
16308
  "ṙ": "ṙ",
16309
+ "ŗ": "ŗ",
16260
16310
  "ś": "ś",
16261
16311
  "ṥ": "ṥ",
16262
16312
  "š": "š",
16263
16313
  "ṧ": "ṧ",
16264
16314
  "ŝ": "ŝ",
16265
16315
  "ṡ": "ṡ",
16316
+ "ş": "ş",
16266
16317
  "ẗ": "ẗ",
16267
16318
  "ť": "ť",
16268
16319
  "ṫ": "ṫ",
16320
+ "ţ": "ţ",
16269
16321
  "ú": "ú",
16270
16322
  "ù": "ù",
16271
16323
  "ü": "ü",
@@ -16324,11 +16376,14 @@ var unicodeSymbols = {
16324
16376
  "Ǻ": "Ǻ",
16325
16377
  "Ḃ": "Ḃ",
16326
16378
  "Ć": "Ć",
16379
+ "Ḉ": "Ḉ",
16327
16380
  "Č": "Č",
16328
16381
  "Ĉ": "Ĉ",
16329
16382
  "Ċ": "Ċ",
16383
+ "Ç": "Ç",
16330
16384
  "Ď": "Ď",
16331
16385
  "Ḋ": "Ḋ",
16386
+ "Ḑ": "Ḑ",
16332
16387
  "É": "É",
16333
16388
  "È": "È",
16334
16389
  "Ë": "Ë",
@@ -16337,12 +16392,14 @@ var unicodeSymbols = {
16337
16392
  "Ḗ": "Ḗ",
16338
16393
  "Ḕ": "Ḕ",
16339
16394
  "Ĕ": "Ĕ",
16395
+ "Ḝ": "Ḝ",
16340
16396
  "Ě": "Ě",
16341
16397
  "Ê": "Ê",
16342
16398
  "Ế": "Ế",
16343
16399
  "Ề": "Ề",
16344
16400
  "Ễ": "Ễ",
16345
16401
  "Ė": "Ė",
16402
+ "Ȩ": "Ȩ",
16346
16403
  "Ḟ": "Ḟ",
16347
16404
  "Ǵ": "Ǵ",
16348
16405
  "Ḡ": "Ḡ",
@@ -16350,10 +16407,12 @@ var unicodeSymbols = {
16350
16407
  "Ǧ": "Ǧ",
16351
16408
  "Ĝ": "Ĝ",
16352
16409
  "Ġ": "Ġ",
16410
+ "Ģ": "Ģ",
16353
16411
  "Ḧ": "Ḧ",
16354
16412
  "Ȟ": "Ȟ",
16355
16413
  "Ĥ": "Ĥ",
16356
16414
  "Ḣ": "Ḣ",
16415
+ "Ḩ": "Ḩ",
16357
16416
  "Í": "Í",
16358
16417
  "Ì": "Ì",
16359
16418
  "Ï": "Ï",
@@ -16367,8 +16426,10 @@ var unicodeSymbols = {
16367
16426
  "Ĵ": "Ĵ",
16368
16427
  "Ḱ": "Ḱ",
16369
16428
  "Ǩ": "Ǩ",
16429
+ "Ķ": "Ķ",
16370
16430
  "Ĺ": "Ĺ",
16371
16431
  "Ľ": "Ľ",
16432
+ "Ļ": "Ļ",
16372
16433
  "Ḿ": "Ḿ",
16373
16434
  "Ṁ": "Ṁ",
16374
16435
  "Ń": "Ń",
@@ -16376,6 +16437,7 @@ var unicodeSymbols = {
16376
16437
  "Ñ": "Ñ",
16377
16438
  "Ň": "Ň",
16378
16439
  "Ṅ": "Ṅ",
16440
+ "Ņ": "Ņ",
16379
16441
  "Ó": "Ó",
16380
16442
  "Ò": "Ò",
16381
16443
  "Ö": "Ö",
@@ -16401,14 +16463,17 @@ var unicodeSymbols = {
16401
16463
  "Ŕ": "Ŕ",
16402
16464
  "Ř": "Ř",
16403
16465
  "Ṙ": "Ṙ",
16466
+ "Ŗ": "Ŗ",
16404
16467
  "Ś": "Ś",
16405
16468
  "Ṥ": "Ṥ",
16406
16469
  "Š": "Š",
16407
16470
  "Ṧ": "Ṧ",
16408
16471
  "Ŝ": "Ŝ",
16409
16472
  "Ṡ": "Ṡ",
16473
+ "Ş": "Ş",
16410
16474
  "Ť": "Ť",
16411
16475
  "Ṫ": "Ṫ",
16476
+ "Ţ": "Ţ",
16412
16477
  "Ú": "Ú",
16413
16478
  "Ù": "Ù",
16414
16479
  "Ü": "Ü",
@@ -16592,18 +16657,22 @@ class Parser {
16592
16657
 
16593
16658
  if (this.settings.colorIsTextColor) {
16594
16659
  this.gullet.macros.set("\\color", "\\textcolor");
16595
- } // Try to parse the input
16660
+ }
16596
16661
 
16662
+ try {
16663
+ // Try to parse the input
16664
+ var parse = this.parseExpression(false); // If we succeeded, make sure there's an EOF at the end
16597
16665
 
16598
- var parse = this.parseExpression(false); // If we succeeded, make sure there's an EOF at the end
16666
+ this.expect("EOF"); // End the group namespace for the expression
16599
16667
 
16600
- this.expect("EOF"); // End the group namespace for the expression
16668
+ if (!this.settings.globalGroup) {
16669
+ this.gullet.endGroup();
16670
+ }
16601
16671
 
16602
- if (!this.settings.globalGroup) {
16603
- this.gullet.endGroup();
16672
+ return parse; // Close any leftover groups in case of a parse error.
16673
+ } finally {
16674
+ this.gullet.endGroups();
16604
16675
  }
16605
-
16606
- return parse;
16607
16676
  }
16608
16677
 
16609
16678
  /**
@@ -16953,7 +17022,8 @@ class Parser {
16953
17022
  var argType = funcData.argTypes && funcData.argTypes[i];
16954
17023
  var isOptional = i < funcData.numOptionalArgs;
16955
17024
 
16956
- if (funcData.primitive && argType == null || funcData.type === "sqrt" && i === 1 && optArgs[0] == null) {
17025
+ if (funcData.primitive && argType == null || // \sqrt expands into primitive if optional argument doesn't exist
17026
+ funcData.type === "sqrt" && i === 1 && optArgs[0] == null) {
16957
17027
  argType = "primitive";
16958
17028
  }
16959
17029
 
@@ -17492,7 +17562,7 @@ class Parser {
17492
17562
  throw new ParseError("Unknown accent ' " + accent + "'", nucleus);
17493
17563
  }
17494
17564
 
17495
- var command = unicodeAccents[accent][this.mode];
17565
+ var command = unicodeAccents[accent][this.mode] || unicodeAccents[accent].text;
17496
17566
 
17497
17567
  if (!command) {
17498
17568
  throw new ParseError("Accent " + accent + " unsupported in " + this.mode + " mode", nucleus);
@@ -17652,7 +17722,7 @@ var katex = {
17652
17722
  /**
17653
17723
  * Current KaTeX version
17654
17724
  */
17655
- version: "0.13.14",
17725
+ version: "0.13.19",
17656
17726
 
17657
17727
  /**
17658
17728
  * Renders the given LaTeX into an HTML+MathML combination, and adds
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "katex",
3
- "version": "0.13.14",
3
+ "version": "0.13.19",
4
4
  "description": "Fast math typesetting for the web.",
5
5
  "main": "dist/katex.js",
6
6
  "homepage": "https://katex.org",
@@ -29,8 +29,8 @@
29
29
  "@babel/runtime": "^7.10.4",
30
30
  "@rollup/plugin-alias": "^3.1.1",
31
31
  "@rollup/plugin-babel": "^5.0.4",
32
- "@semantic-release/changelog": "^5.0.1",
33
- "@semantic-release/git": "^9.0.0",
32
+ "@semantic-release/changelog": "^6.0.0",
33
+ "@semantic-release/git": "^10.0.0",
34
34
  "babel-jest": "^27.0.0",
35
35
  "babel-loader": "^8.0.5",
36
36
  "babel-plugin-istanbul": "^6.0.0",
@@ -44,7 +44,7 @@
44
44
  "cssnano": "^5.0.0-rc.1",
45
45
  "eslint": "^7.4.0",
46
46
  "eslint-plugin-actions": "^1.0.1",
47
- "eslint-plugin-flowtype": "^5.2.0",
47
+ "eslint-plugin-flowtype": "^6.0.0",
48
48
  "eslint-plugin-react": "^7.20.3",
49
49
  "flow-bin": "^0.135.0",
50
50
  "fs-extra": "^10.0.0",
@@ -75,7 +75,7 @@
75
75
  "rimraf": "^3.0.2",
76
76
  "rollup": "^2.21.0",
77
77
  "selenium-webdriver": "^4.0.0-beta.4",
78
- "semantic-release": "^17.4.1",
78
+ "semantic-release": "^18.0.0",
79
79
  "sri-toolbox": "^0.2.0",
80
80
  "style-loader": "^3.0.0",
81
81
  "stylelint": "^13.6.1",
@@ -74,6 +74,14 @@ export default class MacroExpander implements MacroContextInterface {
74
74
  this.macros.endGroup();
75
75
  }
76
76
 
77
+ /**
78
+ * Ends all currently nested groups (if any), restoring values before the
79
+ * groups began. Useful in case of an error in the middle of parsing.
80
+ */
81
+ endGroups() {
82
+ this.macros.endGroups();
83
+ }
84
+
77
85
  /**
78
86
  * Returns the topmost token on the stack, without expanding it.
79
87
  * Similar in behavior to TeX's `\futurelet`.
package/src/Namespace.js CHANGED
@@ -57,6 +57,16 @@ export default class Namespace<Value> {
57
57
  }
58
58
  }
59
59
 
60
+ /**
61
+ * Ends all currently nested groups (if any), restoring values before the
62
+ * groups began. Useful in case of an error in the middle of parsing.
63
+ */
64
+ endGroups() {
65
+ while (this.undefStack.length > 0) {
66
+ this.endGroup();
67
+ }
68
+ }
69
+
60
70
  /**
61
71
  * Detect whether `name` has a definition. Equivalent to
62
72
  * `get(name) != null`.
package/src/Parser.js CHANGED
@@ -130,17 +130,24 @@ export default class Parser {
130
130
  this.gullet.macros.set("\\color", "\\textcolor");
131
131
  }
132
132
 
133
- // Try to parse the input
134
- const parse = this.parseExpression(false);
133
+ try {
134
+ // Try to parse the input
135
+ const parse = this.parseExpression(false);
135
136
 
136
- // If we succeeded, make sure there's an EOF at the end
137
- this.expect("EOF");
137
+ // If we succeeded, make sure there's an EOF at the end
138
+ this.expect("EOF");
138
139
 
139
- // End the group namespace for the expression
140
- if (!this.settings.globalGroup) {
141
- this.gullet.endGroup();
140
+ // End the group namespace for the expression
141
+ if (!this.settings.globalGroup) {
142
+ this.gullet.endGroup();
143
+ }
144
+
145
+ return parse;
146
+
147
+ // Close any leftover groups in case of a parse error.
148
+ } finally {
149
+ this.gullet.endGroups();
142
150
  }
143
- return parse;
144
151
  }
145
152
 
146
153
  static endOfExpression: string[] = ["}", "\\endgroup", "\\end", "\\right", "&"];
@@ -951,7 +958,8 @@ export default class Parser {
951
958
  if (!unicodeAccents[accent]) {
952
959
  throw new ParseError(`Unknown accent ' ${accent}'`, nucleus);
953
960
  }
954
- const command = unicodeAccents[accent][this.mode];
961
+ const command = unicodeAccents[accent][this.mode] ||
962
+ unicodeAccents[accent].text;
955
963
  if (!command) {
956
964
  throw new ParseError(
957
965
  `Accent ${accent} unsupported in ${this.mode} mode`,
@@ -108,11 +108,9 @@ import metricMap from "./fontMetricsData";
108
108
  const extraCharacterMap = {
109
109
  // Latin-1
110
110
  'Å': 'A',
111
- 'Ç': 'C',
112
111
  'Ð': 'D',
113
112
  'Þ': 'o',
114
113
  'å': 'a',
115
- 'ç': 'c',
116
114
  'ð': 'd',
117
115
  'þ': 'o',
118
116
 
@@ -123,9 +123,9 @@ fonts: ff
123
123
  \
124
124
  echo "Hinting $$file"; \
125
125
  if echo "$$file" | $(GREP) -q -e "Size[1-4]" -e "Typewriter"; then \
126
- $(TTFAUTOHINT) --windows-compatibility --symbol ttf/$$file.ttf ttf/$$file.ttf.hinted; \
126
+ $(TTFAUTOHINT) -f none -S --windows-compatibility --symbol ttf/$$file.ttf ttf/$$file.ttf.hinted; \
127
127
  else \
128
- $(TTFAUTOHINT) --windows-compatibility ttf/$$file.ttf ttf/$$file.ttf.hinted; \
128
+ $(TTFAUTOHINT) -f none -S --windows-compatibility ttf/$$file.ttf ttf/$$file.ttf.hinted; \
129
129
  fi; \
130
130
  mv ttf/$$file.ttf.hinted ttf/$$file.ttf; \
131
131
  \
@@ -74,10 +74,14 @@ export const htmlBuilder: HtmlBuilderSupSub<"accent"> = (grp, options) => {
74
74
  // TODO(emily): Find a better way to get the skew
75
75
  }
76
76
 
77
+ const accentBelow = group.label === "\\c";
78
+
77
79
  // calculate the amount of space between the body and the accent
78
- let clearance = Math.min(
79
- body.height,
80
- options.fontMetrics().xHeight);
80
+ let clearance = accentBelow
81
+ ? body.height + body.depth
82
+ : Math.min(
83
+ body.height,
84
+ options.fontMetrics().xHeight);
81
85
 
82
86
  // Build the accent
83
87
  let accentBody;
@@ -100,6 +104,9 @@ export const htmlBuilder: HtmlBuilderSupSub<"accent"> = (grp, options) => {
100
104
  // shift the accent over to a place we don't want.
101
105
  accent.italic = 0;
102
106
  width = accent.width;
107
+ if (accentBelow) {
108
+ clearance += accent.depth;
109
+ }
103
110
  }
104
111
 
105
112
  accentBody = buildCommon.makeSpan(["accent-body"], [accent]);
@@ -244,7 +251,7 @@ defineFunction({
244
251
  type: "accent",
245
252
  names: [
246
253
  "\\'", "\\`", "\\^", "\\~", "\\=", "\\u", "\\.", '\\"',
247
- "\\r", "\\H", "\\v", "\\textcircled",
254
+ "\\c", "\\r", "\\H", "\\v", "\\textcircled",
248
255
  ],
249
256
  props: {
250
257
  numArgs: 1,
@@ -21,14 +21,25 @@ defineFunction({
21
21
  const node = assertNodeType(group[i], "textord");
22
22
  number += node.text;
23
23
  }
24
- const code = parseInt(number);
24
+ let code = parseInt(number);
25
+ let text;
25
26
  if (isNaN(code)) {
26
27
  throw new ParseError(`\\@char has non-numeric argument ${number}`);
28
+ // If we drop IE support, the following code could be replaced with
29
+ // text = String.fromCodePoint(code)
30
+ } else if (code < 0 || code >= 0x10ffff) {
31
+ throw new ParseError(`\\@char with invalid code point ${number}`);
32
+ } else if (code <= 0xffff) {
33
+ text = String.fromCharCode(code);
34
+ } else { // Astral code point; split into surrogate halves
35
+ code -= 0x10000;
36
+ text = String.fromCharCode((code >> 10) + 0xd800,
37
+ (code & 0x3ff) + 0xdc00);
27
38
  }
28
39
  return {
29
40
  type: "textord",
30
41
  mode: parser.mode,
31
- text: String.fromCharCode(code),
42
+ text: text,
32
43
  };
33
44
  },
34
45
  });
package/src/symbols.js CHANGED
@@ -534,9 +534,9 @@ defineSymbol(math, main, mathord, "\u03d6", "\\varpi", true);
534
534
  defineSymbol(math, main, mathord, "\u03f1", "\\varrho", true);
535
535
  defineSymbol(math, main, mathord, "\u03c2", "\\varsigma", true);
536
536
  defineSymbol(math, main, mathord, "\u03c6", "\\varphi", true);
537
- defineSymbol(math, main, bin, "\u2217", "*");
537
+ defineSymbol(math, main, bin, "\u2217", "*", true);
538
538
  defineSymbol(math, main, bin, "+", "+");
539
- defineSymbol(math, main, bin, "\u2212", "-");
539
+ defineSymbol(math, main, bin, "\u2212", "-", true);
540
540
  defineSymbol(math, main, bin, "\u22c5", "\\cdot", true);
541
541
  defineSymbol(math, main, bin, "\u2218", "\\circ");
542
542
  defineSymbol(math, main, bin, "\u00f7", "\\div", true);
@@ -706,6 +706,7 @@ defineSymbol(text, main, accent, "\u02dc", "\\~"); // tilde
706
706
  defineSymbol(text, main, accent, "\u02c9", "\\="); // macron
707
707
  defineSymbol(text, main, accent, "\u02d8", "\\u"); // breve
708
708
  defineSymbol(text, main, accent, "\u02d9", "\\."); // dot above
709
+ defineSymbol(text, main, accent, "\u00b8", "\\c"); // cedilla
709
710
  defineSymbol(text, main, accent, "\u02da", "\\r"); // ring above
710
711
  defineSymbol(text, main, accent, "\u02c7", "\\v"); // caron
711
712
  defineSymbol(text, main, accent, "\u00a8", '\\"'); // diaresis
@@ -875,7 +876,7 @@ for (let i = 0; i < 10; i++) {
875
876
  // but they are not actually in the font, nor are they supported by the
876
877
  // Unicode accent mechanism, so they fall back to Times font and look ugly.
877
878
  // TODO(edemaine): Fix this.
878
- export const extraLatin = "\u00c7\u00d0\u00de\u00e7\u00fe";
879
+ export const extraLatin = "\u00d0\u00de\u00fe";
879
880
  for (let i = 0; i < extraLatin.length; i++) {
880
881
  const ch = extraLatin.charAt(i);
881
882
  defineSymbol(math, main, mathord, ch, ch);
@@ -14,4 +14,5 @@ module.exports = {
14
14
  '\u0307': {text: '\\.', math: '\\dot'},
15
15
  '\u030a': {text: '\\r', math: '\\mathring'},
16
16
  '\u030b': {text: '\\H'},
17
+ '\u0327': {text: '\\c'},
17
18
  };