katex 0.13.20 → 0.13.24

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 (100) hide show
  1. package/README.md +5 -5
  2. package/cli.js +1 -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 +5 -5
  7. package/dist/fonts/KaTeX_AMS-Regular.ttf +0 -0
  8. package/dist/fonts/KaTeX_AMS-Regular.woff +0 -0
  9. package/dist/fonts/KaTeX_AMS-Regular.woff2 +0 -0
  10. package/dist/fonts/KaTeX_Caligraphic-Bold.ttf +0 -0
  11. package/dist/fonts/KaTeX_Caligraphic-Bold.woff +0 -0
  12. package/dist/fonts/KaTeX_Caligraphic-Bold.woff2 +0 -0
  13. package/dist/fonts/KaTeX_Caligraphic-Regular.ttf +0 -0
  14. package/dist/fonts/KaTeX_Caligraphic-Regular.woff +0 -0
  15. package/dist/fonts/KaTeX_Caligraphic-Regular.woff2 +0 -0
  16. package/dist/fonts/KaTeX_Fraktur-Bold.ttf +0 -0
  17. package/dist/fonts/KaTeX_Fraktur-Bold.woff +0 -0
  18. package/dist/fonts/KaTeX_Fraktur-Bold.woff2 +0 -0
  19. package/dist/fonts/KaTeX_Fraktur-Regular.ttf +0 -0
  20. package/dist/fonts/KaTeX_Fraktur-Regular.woff +0 -0
  21. package/dist/fonts/KaTeX_Fraktur-Regular.woff2 +0 -0
  22. package/dist/fonts/KaTeX_Main-Bold.ttf +0 -0
  23. package/dist/fonts/KaTeX_Main-Bold.woff +0 -0
  24. package/dist/fonts/KaTeX_Main-Bold.woff2 +0 -0
  25. package/dist/fonts/KaTeX_Main-BoldItalic.ttf +0 -0
  26. package/dist/fonts/KaTeX_Main-BoldItalic.woff +0 -0
  27. package/dist/fonts/KaTeX_Main-BoldItalic.woff2 +0 -0
  28. package/dist/fonts/KaTeX_Main-Italic.ttf +0 -0
  29. package/dist/fonts/KaTeX_Main-Italic.woff +0 -0
  30. package/dist/fonts/KaTeX_Main-Italic.woff2 +0 -0
  31. package/dist/fonts/KaTeX_Main-Regular.ttf +0 -0
  32. package/dist/fonts/KaTeX_Main-Regular.woff +0 -0
  33. package/dist/fonts/KaTeX_Main-Regular.woff2 +0 -0
  34. package/dist/fonts/KaTeX_Math-BoldItalic.ttf +0 -0
  35. package/dist/fonts/KaTeX_Math-BoldItalic.woff +0 -0
  36. package/dist/fonts/KaTeX_Math-BoldItalic.woff2 +0 -0
  37. package/dist/fonts/KaTeX_Math-Italic.ttf +0 -0
  38. package/dist/fonts/KaTeX_Math-Italic.woff +0 -0
  39. package/dist/fonts/KaTeX_Math-Italic.woff2 +0 -0
  40. package/dist/fonts/KaTeX_SansSerif-Bold.ttf +0 -0
  41. package/dist/fonts/KaTeX_SansSerif-Bold.woff +0 -0
  42. package/dist/fonts/KaTeX_SansSerif-Bold.woff2 +0 -0
  43. package/dist/fonts/KaTeX_SansSerif-Italic.ttf +0 -0
  44. package/dist/fonts/KaTeX_SansSerif-Italic.woff +0 -0
  45. package/dist/fonts/KaTeX_SansSerif-Italic.woff2 +0 -0
  46. package/dist/fonts/KaTeX_SansSerif-Regular.ttf +0 -0
  47. package/dist/fonts/KaTeX_SansSerif-Regular.woff +0 -0
  48. package/dist/fonts/KaTeX_SansSerif-Regular.woff2 +0 -0
  49. package/dist/fonts/KaTeX_Script-Regular.ttf +0 -0
  50. package/dist/fonts/KaTeX_Script-Regular.woff +0 -0
  51. package/dist/fonts/KaTeX_Script-Regular.woff2 +0 -0
  52. package/dist/fonts/KaTeX_Size1-Regular.ttf +0 -0
  53. package/dist/fonts/KaTeX_Size1-Regular.woff +0 -0
  54. package/dist/fonts/KaTeX_Size1-Regular.woff2 +0 -0
  55. package/dist/fonts/KaTeX_Size2-Regular.ttf +0 -0
  56. package/dist/fonts/KaTeX_Size2-Regular.woff +0 -0
  57. package/dist/fonts/KaTeX_Size2-Regular.woff2 +0 -0
  58. package/dist/fonts/KaTeX_Size3-Regular.ttf +0 -0
  59. package/dist/fonts/KaTeX_Size3-Regular.woff +0 -0
  60. package/dist/fonts/KaTeX_Size3-Regular.woff2 +0 -0
  61. package/dist/fonts/KaTeX_Size4-Regular.ttf +0 -0
  62. package/dist/fonts/KaTeX_Size4-Regular.woff +0 -0
  63. package/dist/fonts/KaTeX_Size4-Regular.woff2 +0 -0
  64. package/dist/fonts/KaTeX_Typewriter-Regular.ttf +0 -0
  65. package/dist/fonts/KaTeX_Typewriter-Regular.woff +0 -0
  66. package/dist/fonts/KaTeX_Typewriter-Regular.woff2 +0 -0
  67. package/dist/katex.css +4 -4
  68. package/dist/katex.js +1625 -1602
  69. package/dist/katex.min.css +1 -1
  70. package/dist/katex.min.js +1 -1
  71. package/dist/katex.mjs +2087 -2080
  72. package/package.json +16 -7
  73. package/src/buildCommon.js +12 -12
  74. package/src/buildHTML.js +5 -4
  75. package/src/delimiter.js +11 -10
  76. package/src/domTree.js +2 -1
  77. package/src/environments/array.js +9 -9
  78. package/src/environments/cd.js +2 -1
  79. package/src/fontMetricsData.js +2 -1
  80. package/src/fonts/generate_fonts.py +3 -6
  81. package/src/fonts/makeFF +2 -0
  82. package/src/functions/accent.js +4 -3
  83. package/src/functions/cr.js +3 -3
  84. package/src/functions/delimsizing.js +4 -2
  85. package/src/functions/enclose.js +7 -7
  86. package/src/functions/genfrac.js +2 -2
  87. package/src/functions/includegraphics.js +7 -9
  88. package/src/functions/lap.js +3 -2
  89. package/src/functions/op.js +2 -1
  90. package/src/functions/rule.js +10 -10
  91. package/src/functions/sizing.js +2 -1
  92. package/src/functions/sqrt.js +2 -1
  93. package/src/functions/supsub.js +3 -2
  94. package/src/functions/utils/assembleSupSub.js +6 -5
  95. package/src/katex.less +3 -3
  96. package/src/macros.js +3 -2
  97. package/src/mathMLTree.js +3 -2
  98. package/src/metrics/extract_ttfs.py +3 -0
  99. package/src/stretchy.js +8 -7
  100. package/src/units.js +8 -0
@@ -3,7 +3,7 @@ import buildCommon from "../buildCommon";
3
3
  import defineFunction from "../defineFunction";
4
4
  import mathMLTree from "../mathMLTree";
5
5
  import {assertNodeType} from "../parseNode";
6
- import {calculateSize} from "../units";
6
+ import {calculateSize, makeEm} from "../units";
7
7
 
8
8
  defineFunction({
9
9
  type: "rule",
@@ -35,9 +35,9 @@ defineFunction({
35
35
  const shift = (group.shift) ? calculateSize(group.shift, options) : 0;
36
36
 
37
37
  // Style the rule to the right size
38
- rule.style.borderRightWidth = width + "em";
39
- rule.style.borderTopWidth = height + "em";
40
- rule.style.bottom = shift + "em";
38
+ rule.style.borderRightWidth = makeEm(width);
39
+ rule.style.borderTopWidth = makeEm(height);
40
+ rule.style.bottom = makeEm(shift);
41
41
 
42
42
  // Record the height and width
43
43
  rule.width = width;
@@ -58,17 +58,17 @@ defineFunction({
58
58
 
59
59
  const rule = new mathMLTree.MathNode("mspace");
60
60
  rule.setAttribute("mathbackground", color);
61
- rule.setAttribute("width", width + "em");
62
- rule.setAttribute("height", height + "em");
61
+ rule.setAttribute("width", makeEm(width));
62
+ rule.setAttribute("height", makeEm(height));
63
63
 
64
64
  const wrapper = new mathMLTree.MathNode("mpadded", [rule]);
65
65
  if (shift >= 0) {
66
- wrapper.setAttribute("height", "+" + shift + "em");
66
+ wrapper.setAttribute("height", makeEm(shift));
67
67
  } else {
68
- wrapper.setAttribute("height", shift + "em");
69
- wrapper.setAttribute("depth", "+" + (-shift) + "em");
68
+ wrapper.setAttribute("height", makeEm(shift));
69
+ wrapper.setAttribute("depth", makeEm(-shift));
70
70
  }
71
- wrapper.setAttribute("voffset", shift + "em");
71
+ wrapper.setAttribute("voffset", makeEm(shift));
72
72
 
73
73
  return wrapper;
74
74
  },
@@ -2,6 +2,7 @@
2
2
  import buildCommon from "../buildCommon";
3
3
  import defineFunction from "../defineFunction";
4
4
  import mathMLTree from "../mathMLTree";
5
+ import {makeEm} from "../units";
5
6
 
6
7
  import * as html from "../buildHTML";
7
8
  import * as mml from "../buildMathML";
@@ -83,7 +84,7 @@ defineFunction({
83
84
  // in, so we can't reset the size to normal before changing it. Now
84
85
  // that we're passing an options parameter we should be able to fix
85
86
  // this.
86
- node.setAttribute("mathsize", newOptions.sizeMultiplier + "em");
87
+ node.setAttribute("mathsize", makeEm(newOptions.sizeMultiplier));
87
88
 
88
89
  return node;
89
90
  },
@@ -4,6 +4,7 @@ import buildCommon from "../buildCommon";
4
4
  import mathMLTree from "../mathMLTree";
5
5
  import delimiter from "../delimiter";
6
6
  import Style from "../Style";
7
+ import {makeEm} from "../units";
7
8
 
8
9
  import * as html from "../buildHTML";
9
10
  import * as mml from "../buildMathML";
@@ -70,7 +71,7 @@ defineFunction({
70
71
  // Shift the sqrt image
71
72
  const imgShift = img.height - inner.height - lineClearance - ruleWidth;
72
73
 
73
- inner.style.paddingLeft = advanceWidth + "em";
74
+ inner.style.paddingLeft = makeEm(advanceWidth);
74
75
 
75
76
  // Overlay the image and the argument.
76
77
  const body = buildCommon.makeVList({
@@ -4,6 +4,7 @@ import buildCommon from "../buildCommon";
4
4
  import {SymbolNode} from "../domTree";
5
5
  import mathMLTree from "../mathMLTree";
6
6
  import utils from "../utils";
7
+ import {makeEm} from "../units";
7
8
  import Style from "../Style";
8
9
 
9
10
  import * as html from "../buildHTML";
@@ -111,7 +112,7 @@ defineFunctionBuilders({
111
112
  // scriptspace is a font-size-independent size, so scale it
112
113
  // appropriately for use as the marginRight.
113
114
  const multiplier = options.sizeMultiplier;
114
- const marginRight = (0.5 / metrics.ptPerEm) / multiplier + "em";
115
+ const marginRight = makeEm((0.5 / metrics.ptPerEm) / multiplier);
115
116
 
116
117
  let marginLeft = null;
117
118
  if (subm) {
@@ -123,7 +124,7 @@ defineFunctionBuilders({
123
124
  (group.base.name === "\\oiint" || group.base.name === "\\oiiint");
124
125
  if (base instanceof SymbolNode || isOiint) {
125
126
  // $FlowFixMe
126
- marginLeft = -base.italic + "em";
127
+ marginLeft = makeEm(-base.italic);
127
128
  }
128
129
  }
129
130
 
@@ -6,6 +6,7 @@ import type {StyleInterface} from "../../Style";
6
6
  import type Options from "../../Options";
7
7
  import type {DomSpan, SymbolNode} from "../../domTree";
8
8
  import type {AnyParseNode} from "../../parseNode";
9
+ import {makeEm} from "../../units";
9
10
 
10
11
  // For an operator with limits, assemble the base, sup, and sub into a span.
11
12
 
@@ -62,11 +63,11 @@ export const assembleSupSub = (
62
63
  positionData: bottom,
63
64
  children: [
64
65
  {type: "kern", size: options.fontMetrics().bigOpSpacing5},
65
- {type: "elem", elem: sub.elem, marginLeft: -slant + "em"},
66
+ {type: "elem", elem: sub.elem, marginLeft: makeEm(-slant)},
66
67
  {type: "kern", size: sub.kern},
67
68
  {type: "elem", elem: base},
68
69
  {type: "kern", size: sup.kern},
69
- {type: "elem", elem: sup.elem, marginLeft: slant + "em"},
70
+ {type: "elem", elem: sup.elem, marginLeft: makeEm(slant)},
70
71
  {type: "kern", size: options.fontMetrics().bigOpSpacing5},
71
72
  ],
72
73
  }, options);
@@ -82,7 +83,7 @@ export const assembleSupSub = (
82
83
  positionData: top,
83
84
  children: [
84
85
  {type: "kern", size: options.fontMetrics().bigOpSpacing5},
85
- {type: "elem", elem: sub.elem, marginLeft: -slant + "em"},
86
+ {type: "elem", elem: sub.elem, marginLeft: makeEm(-slant)},
86
87
  {type: "kern", size: sub.kern},
87
88
  {type: "elem", elem: base},
88
89
  ],
@@ -96,7 +97,7 @@ export const assembleSupSub = (
96
97
  children: [
97
98
  {type: "elem", elem: base},
98
99
  {type: "kern", size: sup.kern},
99
- {type: "elem", elem: sup.elem, marginLeft: slant + "em"},
100
+ {type: "elem", elem: sup.elem, marginLeft: makeEm(slant)},
100
101
  {type: "kern", size: options.fontMetrics().bigOpSpacing5},
101
102
  ],
102
103
  }, options);
@@ -112,7 +113,7 @@ export const assembleSupSub = (
112
113
  // A negative margin-left was applied to the lower limit.
113
114
  // Avoid an overlap by placing a spacer on the left on the group.
114
115
  const spacer = buildCommon.makeSpan(["mspace"], [], options);
115
- spacer.style.marginRight = `${slant}em`;
116
+ spacer.style.marginRight = makeEm(slant);
116
117
  parts.unshift(spacer);
117
118
  }
118
119
  return buildCommon.makeSpan(["mop", "op-limits"], parts, options);
package/src/katex.less CHANGED
@@ -568,7 +568,7 @@
568
568
  }
569
569
 
570
570
  .boxpad {
571
- padding: 0 0.3em 0 0.3em; // \fboxsep = 3pt
571
+ padding: 0 0.3em; // \fboxsep = 3pt
572
572
  }
573
573
 
574
574
  .fbox,
@@ -578,7 +578,7 @@
578
578
  }
579
579
 
580
580
  .cancel-pad {
581
- padding: 0 0.2em 0 0.2em; // ref: cancel package \advance\dimen@ 2\p@ % "+2"
581
+ padding: 0 0.2em; // ref: cancel package \advance\dimen@ 2\p@ % "+2"
582
582
  }
583
583
 
584
584
  .cancel-lap {
@@ -600,7 +600,7 @@
600
600
  }
601
601
 
602
602
  .anglpad {
603
- padding: 0 0.03889em 0 0.03889em; // pad 1mu left and right (in scriptstyle)
603
+ padding: 0 0.03889em; // pad 1mu left and right (in scriptstyle)
604
604
  }
605
605
 
606
606
  .eqn-num::before {
package/src/macros.js CHANGED
@@ -13,6 +13,7 @@ import fontMetricsData from "./fontMetricsData";
13
13
  import functions from "./functions";
14
14
  import symbols from "./symbols";
15
15
  import utils from "./utils";
16
+ import {makeEm} from "./units";
16
17
  import ParseError from "./ParseError";
17
18
 
18
19
 
@@ -634,8 +635,8 @@ defineMacro("\\TeX", "\\textrm{\\html@mathml{" +
634
635
  // boxes, though visually the A appears to extend above slightly).
635
636
  // We compute the corresponding \raisebox when A is rendered in \normalsize
636
637
  // \scriptstyle, which has a scale factor of 0.7 (see Options.js).
637
- const latexRaiseA = fontMetricsData['Main-Regular']["T".charCodeAt(0)][1] -
638
- 0.7 * fontMetricsData['Main-Regular']["A".charCodeAt(0)][1] + "em";
638
+ const latexRaiseA = makeEm(fontMetricsData['Main-Regular']["T".charCodeAt(0)][1] -
639
+ 0.7 * fontMetricsData['Main-Regular']["A".charCodeAt(0)][1]);
639
640
  defineMacro("\\LaTeX", "\\textrm{\\html@mathml{" +
640
641
  `L\\kern-.36em\\raisebox{${latexRaiseA}}{\\scriptstyle A}` +
641
642
  "\\kern-.15em\\TeX}{LaTeX}}");
package/src/mathMLTree.js CHANGED
@@ -12,6 +12,7 @@
12
12
  import utils from "./utils";
13
13
  import {DocumentFragment} from "./tree";
14
14
  import {createClass} from "./domTree";
15
+ import {makeEm} from "./units";
15
16
 
16
17
  import type {VirtualNode} from "./tree";
17
18
 
@@ -219,7 +220,7 @@ class SpaceNode implements MathDomNode {
219
220
  } else {
220
221
  const node = document.createElementNS(
221
222
  "http://www.w3.org/1998/Math/MathML", "mspace");
222
- node.setAttribute("width", this.width + "em");
223
+ node.setAttribute("width", makeEm(this.width));
223
224
  return node;
224
225
  }
225
226
  }
@@ -231,7 +232,7 @@ class SpaceNode implements MathDomNode {
231
232
  if (this.character) {
232
233
  return `<mtext>${this.character}</mtext>`;
233
234
  } else {
234
- return `<mspace width="${this.width}em"/>`;
235
+ return `<mspace width="${makeEm(this.width)}"/>`;
235
236
  }
236
237
  }
237
238
 
@@ -44,6 +44,9 @@ metrics_to_extract = {
44
44
  u"\u21aa": None, # \hookrightarrow
45
45
  u"\u21cc": None, # \rightleftharpoons
46
46
  },
47
+ "Main-Bold": {
48
+ u"\u2245": None, # \cong
49
+ },
47
50
  "Size1-Regular": {
48
51
  u"\u222c": u"\u222b", # \iint, based on \int
49
52
  u"\u222d": u"\u222b", # \iiint, based on \int
package/src/stretchy.js CHANGED
@@ -9,6 +9,7 @@ import {LineNode, PathNode, SvgNode} from "./domTree";
9
9
  import buildCommon from "./buildCommon";
10
10
  import mathMLTree from "./mathMLTree";
11
11
  import utils from "./utils";
12
+ import {makeEm} from "./units";
12
13
 
13
14
  import type Options from "./Options";
14
15
  import type {ParseNode, AnyParseNode} from "./parseNode";
@@ -233,7 +234,7 @@ const svgSpan = function(
233
234
  const path = new PathNode(pathName);
234
235
  const svgNode = new SvgNode([path], {
235
236
  "width": "100%",
236
- "height": height + "em",
237
+ "height": makeEm(height),
237
238
  "viewBox": `0 0 ${viewBoxWidth} ${viewBoxHeight}`,
238
239
  "preserveAspectRatio": "none",
239
240
  });
@@ -274,7 +275,7 @@ const svgSpan = function(
274
275
 
275
276
  const svgNode = new SvgNode([path], {
276
277
  "width": "400em",
277
- "height": height + "em",
278
+ "height": makeEm(height),
278
279
  "viewBox": `0 0 ${viewBoxWidth} ${viewBoxHeight}`,
279
280
  "preserveAspectRatio": aligns[i] + " slice",
280
281
  });
@@ -284,7 +285,7 @@ const svgSpan = function(
284
285
  if (numSvgChildren === 1) {
285
286
  return {span, minWidth, height};
286
287
  } else {
287
- span.style.height = height + "em";
288
+ span.style.height = makeEm(height);
288
289
  spans.push(span);
289
290
  }
290
291
  }
@@ -301,9 +302,9 @@ const svgSpan = function(
301
302
  // Note that we are returning span.depth = 0.
302
303
  // Any adjustments relative to the baseline must be done in buildHTML.
303
304
  span.height = height;
304
- span.style.height = height + "em";
305
+ span.style.height = makeEm(height);
305
306
  if (minWidth > 0) {
306
- span.style.minWidth = minWidth + "em";
307
+ span.style.minWidth = makeEm(minWidth);
307
308
  }
308
309
 
309
310
  return span;
@@ -358,14 +359,14 @@ const encloseSpan = function(
358
359
 
359
360
  const svgNode = new SvgNode(lines, {
360
361
  "width": "100%",
361
- "height": totalHeight + "em",
362
+ "height": makeEm(totalHeight),
362
363
  });
363
364
 
364
365
  img = buildCommon.makeSvgSpan([], [svgNode], options);
365
366
  }
366
367
 
367
368
  img.height = totalHeight;
368
- img.style.height = totalHeight + "em";
369
+ img.style.height = makeEm(totalHeight);
369
370
 
370
371
  return img;
371
372
  };
package/src/units.js CHANGED
@@ -96,3 +96,11 @@ export const calculateSize = function(
96
96
  }
97
97
  return Math.min(sizeValue.number * scale, options.maxSize);
98
98
  };
99
+
100
+ /**
101
+ * Round `n` to 4 decimal places, or to the nearest 1/10,000th em. See
102
+ * https://github.com/KaTeX/KaTeX/pull/2460.
103
+ */
104
+ export const makeEm = function(n: number): string {
105
+ return +n.toFixed(4) + "em";
106
+ };