katex 0.16.21 → 0.16.23

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.
package/dist/katex.mjs CHANGED
@@ -5101,7 +5101,7 @@ defineSymbol(text, main, accent, "\u02da", "\\r"); // ring above
5101
5101
 
5102
5102
  defineSymbol(text, main, accent, "\u02c7", "\\v"); // caron
5103
5103
 
5104
- defineSymbol(text, main, accent, "\u00a8", '\\"'); // diaresis
5104
+ defineSymbol(text, main, accent, "\u00a8", '\\"'); // diaeresis
5105
5105
 
5106
5106
  defineSymbol(text, main, accent, "\u02dd", "\\H"); // double acute
5107
5107
 
@@ -13852,7 +13852,8 @@ defineFunction({
13852
13852
  names: ["\\relax"],
13853
13853
  props: {
13854
13854
  numArgs: 0,
13855
- allowedInText: true
13855
+ allowedInText: true,
13856
+ allowedInArgument: true
13856
13857
  },
13857
13858
 
13858
13859
  handler(_ref) {
@@ -14478,7 +14479,7 @@ defineFunctionBuilders({
14478
14479
  },
14479
14480
 
14480
14481
  mathmlBuilder(group, options) {
14481
- // Is the inner group a relevant horizonal brace?
14482
+ // Is the inner group a relevant horizontal brace?
14482
14483
  var isBrace = false;
14483
14484
  var isOver;
14484
14485
  var isSup;
@@ -16313,7 +16314,7 @@ class MacroExpander {
16313
16314
 
16314
16315
  this.pushToken(new Token("EOF", end.loc));
16315
16316
  this.pushTokens(tokens);
16316
- return start.range(end, "");
16317
+ return new Token("", SourceLocation.range(start, end));
16317
16318
  }
16318
16319
  /**
16319
16320
  * Consume all following space tokens, without expansion.
@@ -17387,6 +17388,7 @@ class Parser {
17387
17388
  if (!atom) {
17388
17389
  break;
17389
17390
  } else if (atom.type === "internal") {
17391
+ // Internal nodes do not appear in parse tree
17390
17392
  continue;
17391
17393
  }
17392
17394
 
@@ -17473,8 +17475,15 @@ class Parser {
17473
17475
  var symbol = symbolToken.text;
17474
17476
  this.consume();
17475
17477
  this.consumeSpaces(); // ignore spaces before sup/subscript argument
17478
+ // Skip over allowed internal nodes such as \relax
17476
17479
 
17477
- var group = this.parseGroup(name);
17480
+ var group;
17481
+
17482
+ do {
17483
+ var _group;
17484
+
17485
+ group = this.parseGroup(name);
17486
+ } while (((_group = group) == null ? void 0 : _group.type) === "internal");
17478
17487
 
17479
17488
  if (!group) {
17480
17489
  throw new ParseError("Expected group after '" + symbol + "'", symbolToken);
@@ -17520,7 +17529,13 @@ class Parser {
17520
17529
  parseAtom(breakOnTokenText) {
17521
17530
  // The body of an atom is an implicit group, so that things like
17522
17531
  // \left(x\right)^2 work correctly.
17523
- var base = this.parseGroup("atom", breakOnTokenText); // In text mode, we don't have superscripts or subscripts
17532
+ var base = this.parseGroup("atom", breakOnTokenText); // Internal nodes (e.g. \relax) cannot support super/subscripts.
17533
+ // Instead we will pick up super/subscripts with blank base next round.
17534
+
17535
+ if ((base == null ? void 0 : base.type) === "internal") {
17536
+ return base;
17537
+ } // In text mode, we don't have superscripts or subscripts
17538
+
17524
17539
 
17525
17540
  if (this.mode === "text") {
17526
17541
  return base;
@@ -17807,13 +17822,13 @@ class Parser {
17807
17822
  throw new ParseError("A primitive argument cannot be optional");
17808
17823
  }
17809
17824
 
17810
- var _group = this.parseGroup(name);
17825
+ var _group2 = this.parseGroup(name);
17811
17826
 
17812
- if (_group == null) {
17827
+ if (_group2 == null) {
17813
17828
  throw new ParseError("Expected group as " + name, this.fetch());
17814
17829
  }
17815
17830
 
17816
- return _group;
17831
+ return _group2;
17817
17832
  }
17818
17833
 
17819
17834
  case "original":
@@ -18430,7 +18445,7 @@ var renderToHTMLTree = function renderToHTMLTree(expression, options) {
18430
18445
  }
18431
18446
  };
18432
18447
 
18433
- var version = "0.16.21";
18448
+ var version = "0.16.23";
18434
18449
  var __domTree = {
18435
18450
  Span,
18436
18451
  Anchor,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "katex",
3
- "version": "0.16.21",
3
+ "version": "0.16.23",
4
4
  "description": "Fast math typesetting for the web.",
5
5
  "main": "dist/katex.js",
6
6
  "exports": {
@@ -10,6 +10,7 @@ import Lexer from "./Lexer";
10
10
  import {Token} from "./Token";
11
11
  import type {Mode} from "./types";
12
12
  import ParseError from "./ParseError";
13
+ import SourceLocation from "./SourceLocation";
13
14
  import Namespace from "./Namespace";
14
15
  import macros from "./macros";
15
16
 
@@ -138,7 +139,7 @@ export default class MacroExpander implements MacroContextInterface {
138
139
  this.pushToken(new Token("EOF", end.loc));
139
140
 
140
141
  this.pushTokens(tokens);
141
- return start.range(end, "");
142
+ return new Token("", SourceLocation.range(start, end));
142
143
  }
143
144
 
144
145
  /**
package/src/Parser.js CHANGED
@@ -211,6 +211,7 @@ export default class Parser {
211
211
  if (!atom) {
212
212
  break;
213
213
  } else if (atom.type === "internal") {
214
+ // Internal nodes do not appear in parse tree
214
215
  continue;
215
216
  }
216
217
  body.push(atom);
@@ -286,7 +287,12 @@ export default class Parser {
286
287
  const symbol = symbolToken.text;
287
288
  this.consume();
288
289
  this.consumeSpaces(); // ignore spaces before sup/subscript argument
289
- const group = this.parseGroup(name);
290
+
291
+ // Skip over allowed internal nodes such as \relax
292
+ let group: ?AnyParseNode;
293
+ do {
294
+ group = this.parseGroup(name);
295
+ } while (group?.type === "internal");
290
296
 
291
297
  if (!group) {
292
298
  throw new ParseError(
@@ -333,6 +339,12 @@ export default class Parser {
333
339
  // \left(x\right)^2 work correctly.
334
340
  const base = this.parseGroup("atom", breakOnTokenText);
335
341
 
342
+ // Internal nodes (e.g. \relax) cannot support super/subscripts.
343
+ // Instead we will pick up super/subscripts with blank base next round.
344
+ if (base?.type === "internal") {
345
+ return base;
346
+ }
347
+
336
348
  // In text mode, we don't have superscripts or subscripts
337
349
  if (this.mode === "text") {
338
350
  return base;
@@ -7,6 +7,7 @@ defineFunction({
7
7
  props: {
8
8
  numArgs: 0,
9
9
  allowedInText: true,
10
+ allowedInArgument: true,
10
11
  },
11
12
  handler({parser}) {
12
13
  return {
@@ -192,7 +192,7 @@ defineFunctionBuilders({
192
192
  options);
193
193
  },
194
194
  mathmlBuilder(group, options) {
195
- // Is the inner group a relevant horizonal brace?
195
+ // Is the inner group a relevant horizontal brace?
196
196
  let isBrace = false;
197
197
  let isOver;
198
198
  let isSup;
package/src/symbols.js CHANGED
@@ -711,7 +711,7 @@ defineSymbol(text, main, accent, "\u02d9", "\\."); // dot above
711
711
  defineSymbol(text, main, accent, "\u00b8", "\\c"); // cedilla
712
712
  defineSymbol(text, main, accent, "\u02da", "\\r"); // ring above
713
713
  defineSymbol(text, main, accent, "\u02c7", "\\v"); // caron
714
- defineSymbol(text, main, accent, "\u00a8", '\\"'); // diaresis
714
+ defineSymbol(text, main, accent, "\u00a8", '\\"'); // diaeresis
715
715
  defineSymbol(text, main, accent, "\u02dd", "\\H"); // double acute
716
716
  defineSymbol(text, main, accent, "\u25ef", "\\textcircled"); // \bigcirc glyph
717
717