katex 0.13.23 → 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.
- package/README.md +5 -5
- package/contrib/copy-tex/README.md +3 -3
- package/contrib/mathtex-script-type/README.md +5 -5
- package/contrib/mhchem/README.md +1 -1
- package/dist/README.md +5 -5
- package/dist/katex.css +1 -1
- package/dist/katex.js +1623 -1601
- package/dist/katex.min.css +1 -1
- package/dist/katex.min.js +1 -1
- package/dist/katex.mjs +2085 -2079
- package/package.json +7 -1
- package/src/buildCommon.js +12 -12
- package/src/buildHTML.js +5 -4
- package/src/delimiter.js +11 -10
- package/src/domTree.js +2 -1
- package/src/environments/array.js +9 -9
- package/src/environments/cd.js +2 -1
- package/src/functions/accent.js +4 -3
- package/src/functions/cr.js +3 -3
- package/src/functions/delimsizing.js +4 -2
- package/src/functions/enclose.js +7 -7
- package/src/functions/genfrac.js +2 -2
- package/src/functions/includegraphics.js +7 -9
- package/src/functions/lap.js +3 -2
- package/src/functions/op.js +2 -1
- package/src/functions/rule.js +10 -10
- package/src/functions/sizing.js +2 -1
- package/src/functions/sqrt.js +2 -1
- package/src/functions/supsub.js +3 -2
- package/src/functions/utils/assembleSupSub.js +6 -5
- package/src/macros.js +3 -2
- package/src/mathMLTree.js +3 -2
- package/src/stretchy.js +8 -7
- package/src/units.js +8 -0
|
@@ -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
|
|
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
|
|
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
|
|
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
|
|
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 =
|
|
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/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]
|
|
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
|
|
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}
|
|
235
|
+
return `<mspace width="${makeEm(this.width)}"/>`;
|
|
235
236
|
}
|
|
236
237
|
}
|
|
237
238
|
|
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
|
|
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
|
|
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
|
|
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
|
|
305
|
+
span.style.height = makeEm(height);
|
|
305
306
|
if (minWidth > 0) {
|
|
306
|
-
span.style.minWidth = minWidth
|
|
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
|
|
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
|
|
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
|
+
};
|