katex 0.16.36 → 0.16.37

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
@@ -12202,54 +12202,7 @@ defineFunction({
12202
12202
  return new MathNode("mphantom", inner);
12203
12203
  }
12204
12204
  });
12205
- defineFunction({
12206
- type: "hphantom",
12207
- names: ["\\hphantom"],
12208
- props: {
12209
- numArgs: 1,
12210
- allowedInText: true
12211
- },
12212
- handler: (_ref2, args) => {
12213
- var {
12214
- parser
12215
- } = _ref2;
12216
- var body = args[0];
12217
- return {
12218
- type: "hphantom",
12219
- mode: parser.mode,
12220
- body
12221
- };
12222
- },
12223
- htmlBuilder: (group, options) => {
12224
- var node = makeSpan([], [buildGroup$1(group.body, options.withPhantom())]);
12225
- node.height = 0;
12226
- node.depth = 0;
12227
- if (node.children) {
12228
- for (var i = 0; i < node.children.length; i++) {
12229
- node.children[i].height = 0;
12230
- node.children[i].depth = 0;
12231
- }
12232
- }
12233
- // See smash for comment re: use of makeVList
12234
- node = makeVList({
12235
- positionType: "firstBaseline",
12236
- children: [{
12237
- type: "elem",
12238
- elem: node
12239
- }]
12240
- });
12241
- // For spacing, TeX treats \smash as a math group (same spacing as ord).
12242
- return makeSpan(["mord"], [node], options);
12243
- },
12244
- mathmlBuilder: (group, options) => {
12245
- var inner = buildExpression(ordargument(group.body), options);
12246
- var phantom = new MathNode("mphantom", inner);
12247
- var node = new MathNode("mpadded", [phantom]);
12248
- node.setAttribute("height", "0px");
12249
- node.setAttribute("depth", "0px");
12250
- return node;
12251
- }
12252
- });
12205
+ defineMacro("\\hphantom", "\\smash{\\phantom{#1}}");
12253
12206
  defineFunction({
12254
12207
  type: "vphantom",
12255
12208
  names: ["\\vphantom"],
@@ -12257,10 +12210,10 @@ defineFunction({
12257
12210
  numArgs: 1,
12258
12211
  allowedInText: true
12259
12212
  },
12260
- handler: (_ref3, args) => {
12213
+ handler: (_ref2, args) => {
12261
12214
  var {
12262
12215
  parser
12263
- } = _ref3;
12216
+ } = _ref2;
12264
12217
  var body = args[0];
12265
12218
  return {
12266
12219
  type: "vphantom",
@@ -12529,18 +12482,23 @@ defineFunction({
12529
12482
  }
12530
12483
  if (group.smashHeight) {
12531
12484
  node.height = 0;
12532
- // In order to influence makeVList, we have to reset the children.
12533
- if (node.children) {
12534
- for (var i = 0; i < node.children.length; i++) {
12535
- node.children[i].height = 0;
12536
- }
12537
- }
12538
12485
  }
12539
12486
  if (group.smashDepth) {
12540
12487
  node.depth = 0;
12541
- if (node.children) {
12542
- for (var _i = 0; _i < node.children.length; _i++) {
12543
- node.children[_i].depth = 0;
12488
+ }
12489
+ if (group.smashHeight && group.smashDepth) {
12490
+ // Symmetric \smash can stay in inline layout.
12491
+ return makeSpan(["mord", "smash"], [node], options);
12492
+ }
12493
+ // In order to influence makeVList for asymmetric smashing, we have to
12494
+ // reset the children.
12495
+ if (node.children) {
12496
+ for (var i = 0; i < node.children.length; i++) {
12497
+ if (group.smashHeight) {
12498
+ node.children[i].height = 0;
12499
+ }
12500
+ if (group.smashDepth) {
12501
+ node.children[i].depth = 0;
12544
12502
  }
12545
12503
  }
12546
12504
  }
@@ -12555,7 +12513,7 @@ defineFunction({
12555
12513
  elem: node
12556
12514
  }]
12557
12515
  });
12558
- // For spacing, TeX treats \hphantom as a math group (same spacing as ord).
12516
+ // For spacing, TeX treats \smash as a math group (same spacing as ord).
12559
12517
  return makeSpan(["mord"], [smashedNode], options);
12560
12518
  },
12561
12519
  mathmlBuilder: (group, options) => {
@@ -16403,7 +16361,7 @@ var renderToHTMLTree = function renderToHTMLTree(expression, options) {
16403
16361
  return renderError(error, expression, settings);
16404
16362
  }
16405
16363
  };
16406
- var version = "0.16.36";
16364
+ var version = "0.16.37";
16407
16365
  var __domTree = {
16408
16366
  Span,
16409
16367
  Anchor,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "katex",
3
- "version": "0.16.36",
3
+ "version": "0.16.37",
4
4
  "description": "Fast math typesetting for the web.",
5
5
  "main": "dist/katex.js",
6
6
  "types": "types/katex.d.ts",
@@ -1,5 +1,6 @@
1
1
  import defineFunction, {ordargument} from "../defineFunction";
2
- import {makeFragment, makeSpan, makeVList} from "../buildCommon";
2
+ import defineMacro from "../defineMacro";
3
+ import {makeFragment, makeSpan} from "../buildCommon";
3
4
  import {MathNode} from "../mathMLTree";
4
5
 
5
6
  import * as html from "../buildHTML";
@@ -37,51 +38,7 @@ defineFunction({
37
38
  },
38
39
  });
39
40
 
40
- defineFunction({
41
- type: "hphantom",
42
- names: ["\\hphantom"],
43
- props: {
44
- numArgs: 1,
45
- allowedInText: true,
46
- },
47
- handler: ({parser}, args) => {
48
- const body = args[0];
49
- return {
50
- type: "hphantom",
51
- mode: parser.mode,
52
- body,
53
- };
54
- },
55
- htmlBuilder: (group, options) => {
56
- let node = makeSpan(
57
- [], [html.buildGroup(group.body, options.withPhantom())]);
58
- node.height = 0;
59
- node.depth = 0;
60
- if (node.children) {
61
- for (let i = 0; i < node.children.length; i++) {
62
- node.children[i].height = 0;
63
- node.children[i].depth = 0;
64
- }
65
- }
66
-
67
- // See smash for comment re: use of makeVList
68
- node = makeVList({
69
- positionType: "firstBaseline",
70
- children: [{type: "elem", elem: node}],
71
- }, options);
72
-
73
- // For spacing, TeX treats \smash as a math group (same spacing as ord).
74
- return makeSpan(["mord"], [node], options);
75
- },
76
- mathmlBuilder: (group, options) => {
77
- const inner = mml.buildExpression(ordargument(group.body), options);
78
- const phantom = new MathNode("mphantom", inner);
79
- const node = new MathNode("mpadded", [phantom]);
80
- node.setAttribute("height", "0px");
81
- node.setAttribute("depth", "0px");
82
- return node;
83
- },
84
- });
41
+ defineMacro("\\hphantom", "\\smash{\\phantom{#1}}");
85
42
 
86
43
  defineFunction({
87
44
  type: "vphantom",
@@ -61,18 +61,25 @@ defineFunction({
61
61
 
62
62
  if (group.smashHeight) {
63
63
  node.height = 0;
64
- // In order to influence makeVList, we have to reset the children.
65
- if (node.children) {
66
- for (let i = 0; i < node.children.length; i++) {
67
- node.children[i].height = 0;
68
- }
69
- }
70
64
  }
71
65
 
72
66
  if (group.smashDepth) {
73
67
  node.depth = 0;
74
- if (node.children) {
75
- for (let i = 0; i < node.children.length; i++) {
68
+ }
69
+
70
+ if (group.smashHeight && group.smashDepth) {
71
+ // Symmetric \smash can stay in inline layout.
72
+ return makeSpan(["mord", "smash"], [node], options);
73
+ }
74
+
75
+ // In order to influence makeVList for asymmetric smashing, we have to
76
+ // reset the children.
77
+ if (node.children) {
78
+ for (let i = 0; i < node.children.length; i++) {
79
+ if (group.smashHeight) {
80
+ node.children[i].height = 0;
81
+ }
82
+ if (group.smashDepth) {
76
83
  node.children[i].depth = 0;
77
84
  }
78
85
  }
@@ -88,7 +95,7 @@ defineFunction({
88
95
  children: [{type: "elem", elem: node}],
89
96
  }, options);
90
97
 
91
- // For spacing, TeX treats \hphantom as a math group (same spacing as ord).
98
+ // For spacing, TeX treats \smash as a math group (same spacing as ord).
92
99
  return makeSpan(["mord"], [smashedNode], options);
93
100
  },
94
101
  mathmlBuilder: (group, options) => {
package/src/parseNode.ts CHANGED
@@ -401,12 +401,6 @@ type ParseNodeTypes = {
401
401
  loc?: SourceLocation | null | undefined;
402
402
  body: AnyParseNode[];
403
403
  };
404
- "hphantom": {
405
- type: "hphantom";
406
- mode: Mode;
407
- loc?: SourceLocation | null | undefined;
408
- body: AnyParseNode;
409
- };
410
404
  "vphantom": {
411
405
  type: "vphantom";
412
406
  mode: Mode;
@@ -290,6 +290,11 @@ $display-margin: 1em 0 !default;
290
290
  display: inline-block;
291
291
  }
292
292
 
293
+ .smash {
294
+ display: inline;
295
+ line-height: 0;
296
+ }
297
+
293
298
  .llap,
294
299
  .rlap,
295
300
  .clap {