katex 0.16.5 → 0.16.6
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 +3 -3
- package/contrib/auto-render/test/auto-render-spec.js +1 -1
- package/contrib/copy-tex/README.md +2 -2
- package/contrib/mathtex-script-type/README.md +5 -5
- package/contrib/mhchem/README.md +1 -1
- package/contrib/mhchem/mhchem.js +2 -2
- package/contrib/render-a11y-string/render-a11y-string.js +1 -1
- package/dist/README.md +3 -3
- package/dist/contrib/mhchem.js +2 -2
- package/dist/contrib/mhchem.mjs +1 -1
- package/dist/contrib/render-a11y-string.js +1 -1
- package/dist/contrib/render-a11y-string.mjs +1 -1
- package/dist/katex.css +1 -1
- package/dist/katex.js +91 -90
- package/dist/katex.min.css +1 -1
- package/dist/katex.min.js +1 -1
- package/dist/katex.mjs +91 -90
- package/package.json +1 -1
- package/src/MacroExpander.js +21 -22
- package/src/Parser.js +1 -1
- package/src/buildMathML.js +2 -2
- package/src/defineEnvironment.js +1 -1
- package/src/defineMacro.js +1 -1
- package/src/delimiter.js +20 -20
- package/src/environments/array.js +2 -2
- package/src/fontMetrics.js +4 -4
- package/src/functions/arrow.js +1 -1
- package/src/functions/delimsizing.js +1 -1
- package/src/katex.less +1 -1
- package/src/mathMLTree.js +2 -2
- package/src/parseNode.js +1 -1
- package/src/svgGeometry.js +51 -51
package/dist/katex.mjs
CHANGED
|
@@ -737,49 +737,49 @@ function supportedCodepoint(codepoint) {
|
|
|
737
737
|
* It's a storehouse of path geometry for SVG images.
|
|
738
738
|
*/
|
|
739
739
|
// In all paths below, the viewBox-to-em scale is 1000:1.
|
|
740
|
-
var hLinePad = 80; // padding above a sqrt
|
|
741
|
-
// The
|
|
742
|
-
// Think of variable
|
|
743
|
-
// The detour begins at the lower left of the area labeled
|
|
744
|
-
// The detour proceeds one
|
|
745
|
-
// displacing the radiused corner between surd and
|
|
740
|
+
var hLinePad = 80; // padding above a sqrt vinculum. Prevents image cropping.
|
|
741
|
+
// The vinculum of a \sqrt can be made thicker by a KaTeX rendering option.
|
|
742
|
+
// Think of variable extraVinculum as two detours in the SVG path.
|
|
743
|
+
// The detour begins at the lower left of the area labeled extraVinculum below.
|
|
744
|
+
// The detour proceeds one extraVinculum distance up and slightly to the right,
|
|
745
|
+
// displacing the radiused corner between surd and vinculum. The radius is
|
|
746
746
|
// traversed as usual, then the detour resumes. It goes right, to the end of
|
|
747
|
-
// the very long
|
|
747
|
+
// the very long vinculum, then down one extraVinculum distance,
|
|
748
748
|
// after which it resumes regular path geometry for the radical.
|
|
749
749
|
|
|
750
|
-
/*
|
|
750
|
+
/* vinculum
|
|
751
751
|
/
|
|
752
|
-
/▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒←
|
|
753
|
-
/ █████████████████████←0.04em (40 unit) std
|
|
752
|
+
/▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒←extraVinculum
|
|
753
|
+
/ █████████████████████←0.04em (40 unit) std vinculum thickness
|
|
754
754
|
/ /
|
|
755
755
|
/ /
|
|
756
756
|
/ /\
|
|
757
757
|
/ / surd
|
|
758
758
|
*/
|
|
759
759
|
|
|
760
|
-
var sqrtMain = function sqrtMain(
|
|
760
|
+
var sqrtMain = function sqrtMain(extraVinculum, hLinePad) {
|
|
761
761
|
// sqrtMain path geometry is from glyph U221A in the font KaTeX Main
|
|
762
|
-
return "M95," + (622 +
|
|
762
|
+
return "M95," + (622 + extraVinculum + hLinePad) + "\nc-2.7,0,-7.17,-2.7,-13.5,-8c-5.8,-5.3,-9.5,-10,-9.5,-14\nc0,-2,0.3,-3.3,1,-4c1.3,-2.7,23.83,-20.7,67.5,-54\nc44.2,-33.3,65.8,-50.3,66.5,-51c1.3,-1.3,3,-2,5,-2c4.7,0,8.7,3.3,12,10\ns173,378,173,378c0.7,0,35.3,-71,104,-213c68.7,-142,137.5,-285,206.5,-429\nc69,-144,104.5,-217.7,106.5,-221\nl" + extraVinculum / 2.075 + " -" + extraVinculum + "\nc5.3,-9.3,12,-14,20,-14\nH400000v" + (40 + extraVinculum) + "H845.2724\ns-225.272,467,-225.272,467s-235,486,-235,486c-2.7,4.7,-9,7,-19,7\nc-6,0,-10,-1,-12,-3s-194,-422,-194,-422s-65,47,-65,47z\nM" + (834 + extraVinculum) + " " + hLinePad + "h400000v" + (40 + extraVinculum) + "h-400000z";
|
|
763
763
|
};
|
|
764
764
|
|
|
765
|
-
var sqrtSize1 = function sqrtSize1(
|
|
765
|
+
var sqrtSize1 = function sqrtSize1(extraVinculum, hLinePad) {
|
|
766
766
|
// size1 is from glyph U221A in the font KaTeX_Size1-Regular
|
|
767
|
-
return "M263," + (601 +
|
|
767
|
+
return "M263," + (601 + extraVinculum + hLinePad) + "c0.7,0,18,39.7,52,119\nc34,79.3,68.167,158.7,102.5,238c34.3,79.3,51.8,119.3,52.5,120\nc340,-704.7,510.7,-1060.3,512,-1067\nl" + extraVinculum / 2.084 + " -" + extraVinculum + "\nc4.7,-7.3,11,-11,19,-11\nH40000v" + (40 + extraVinculum) + "H1012.3\ns-271.3,567,-271.3,567c-38.7,80.7,-84,175,-136,283c-52,108,-89.167,185.3,-111.5,232\nc-22.3,46.7,-33.8,70.3,-34.5,71c-4.7,4.7,-12.3,7,-23,7s-12,-1,-12,-1\ns-109,-253,-109,-253c-72.7,-168,-109.3,-252,-110,-252c-10.7,8,-22,16.7,-34,26\nc-22,17.3,-33.3,26,-34,26s-26,-26,-26,-26s76,-59,76,-59s76,-60,76,-60z\nM" + (1001 + extraVinculum) + " " + hLinePad + "h400000v" + (40 + extraVinculum) + "h-400000z";
|
|
768
768
|
};
|
|
769
769
|
|
|
770
|
-
var sqrtSize2 = function sqrtSize2(
|
|
770
|
+
var sqrtSize2 = function sqrtSize2(extraVinculum, hLinePad) {
|
|
771
771
|
// size2 is from glyph U221A in the font KaTeX_Size2-Regular
|
|
772
|
-
return "M983 " + (10 +
|
|
772
|
+
return "M983 " + (10 + extraVinculum + hLinePad) + "\nl" + extraVinculum / 3.13 + " -" + extraVinculum + "\nc4,-6.7,10,-10,18,-10 H400000v" + (40 + extraVinculum) + "\nH1013.1s-83.4,268,-264.1,840c-180.7,572,-277,876.3,-289,913c-4.7,4.7,-12.7,7,-24,7\ns-12,0,-12,0c-1.3,-3.3,-3.7,-11.7,-7,-25c-35.3,-125.3,-106.7,-373.3,-214,-744\nc-10,12,-21,25,-33,39s-32,39,-32,39c-6,-5.3,-15,-14,-27,-26s25,-30,25,-30\nc26.7,-32.7,52,-63,76,-91s52,-60,52,-60s208,722,208,722\nc56,-175.3,126.3,-397.3,211,-666c84.7,-268.7,153.8,-488.2,207.5,-658.5\nc53.7,-170.3,84.5,-266.8,92.5,-289.5z\nM" + (1001 + extraVinculum) + " " + hLinePad + "h400000v" + (40 + extraVinculum) + "h-400000z";
|
|
773
773
|
};
|
|
774
774
|
|
|
775
|
-
var sqrtSize3 = function sqrtSize3(
|
|
775
|
+
var sqrtSize3 = function sqrtSize3(extraVinculum, hLinePad) {
|
|
776
776
|
// size3 is from glyph U221A in the font KaTeX_Size3-Regular
|
|
777
|
-
return "M424," + (2398 +
|
|
777
|
+
return "M424," + (2398 + extraVinculum + hLinePad) + "\nc-1.3,-0.7,-38.5,-172,-111.5,-514c-73,-342,-109.8,-513.3,-110.5,-514\nc0,-2,-10.7,14.3,-32,49c-4.7,7.3,-9.8,15.7,-15.5,25c-5.7,9.3,-9.8,16,-12.5,20\ns-5,7,-5,7c-4,-3.3,-8.3,-7.7,-13,-13s-13,-13,-13,-13s76,-122,76,-122s77,-121,77,-121\ns209,968,209,968c0,-2,84.7,-361.7,254,-1079c169.3,-717.3,254.7,-1077.7,256,-1081\nl" + extraVinculum / 4.223 + " -" + extraVinculum + "c4,-6.7,10,-10,18,-10 H400000\nv" + (40 + extraVinculum) + "H1014.6\ns-87.3,378.7,-272.6,1166c-185.3,787.3,-279.3,1182.3,-282,1185\nc-2,6,-10,9,-24,9\nc-8,0,-12,-0.7,-12,-2z M" + (1001 + extraVinculum) + " " + hLinePad + "\nh400000v" + (40 + extraVinculum) + "h-400000z";
|
|
778
778
|
};
|
|
779
779
|
|
|
780
|
-
var sqrtSize4 = function sqrtSize4(
|
|
780
|
+
var sqrtSize4 = function sqrtSize4(extraVinculum, hLinePad) {
|
|
781
781
|
// size4 is from glyph U221A in the font KaTeX_Size4-Regular
|
|
782
|
-
return "M473," + (2713 +
|
|
782
|
+
return "M473," + (2713 + extraVinculum + hLinePad) + "\nc339.3,-1799.3,509.3,-2700,510,-2702 l" + extraVinculum / 5.298 + " -" + extraVinculum + "\nc3.3,-7.3,9.3,-11,18,-11 H400000v" + (40 + extraVinculum) + "H1017.7\ns-90.5,478,-276.2,1466c-185.7,988,-279.5,1483,-281.5,1485c-2,6,-10,9,-24,9\nc-8,0,-12,-0.7,-12,-2c0,-1.3,-5.3,-32,-16,-92c-50.7,-293.3,-119.7,-693.3,-207,-1200\nc0,-1.3,-5.3,8.7,-16,30c-10.7,21.3,-21.3,42.7,-32,64s-16,33,-16,33s-26,-26,-26,-26\ns76,-153,76,-153s77,-151,77,-151c0.7,0.7,35.7,202,105,604c67.3,400.7,102,602.7,104,\n606zM" + (1001 + extraVinculum) + " " + hLinePad + "h400000v" + (40 + extraVinculum) + "H1017.7z";
|
|
783
783
|
};
|
|
784
784
|
|
|
785
785
|
var phasePath = function phasePath(y) {
|
|
@@ -788,43 +788,43 @@ var phasePath = function phasePath(y) {
|
|
|
788
788
|
return "M400000 " + y + " H0 L" + x + " 0 l65 45 L145 " + (y - 80) + " H400000z";
|
|
789
789
|
};
|
|
790
790
|
|
|
791
|
-
var sqrtTall = function sqrtTall(
|
|
791
|
+
var sqrtTall = function sqrtTall(extraVinculum, hLinePad, viewBoxHeight) {
|
|
792
792
|
// sqrtTall is from glyph U23B7 in the font KaTeX_Size4-Regular
|
|
793
|
-
// One path edge has a variable length. It runs vertically from the
|
|
794
|
-
// to a point near (14 units) the bottom of the surd. The
|
|
793
|
+
// One path edge has a variable length. It runs vertically from the vinculum
|
|
794
|
+
// to a point near (14 units) the bottom of the surd. The vinculum
|
|
795
795
|
// is normally 40 units thick. So the length of the line in question is:
|
|
796
|
-
var vertSegment = viewBoxHeight - 54 - hLinePad -
|
|
797
|
-
return "M702 " + (
|
|
796
|
+
var vertSegment = viewBoxHeight - 54 - hLinePad - extraVinculum;
|
|
797
|
+
return "M702 " + (extraVinculum + hLinePad) + "H400000" + (40 + extraVinculum) + "\nH742v" + vertSegment + "l-4 4-4 4c-.667.7 -2 1.5-4 2.5s-4.167 1.833-6.5 2.5-5.5 1-9.5 1\nh-12l-28-84c-16.667-52-96.667 -294.333-240-727l-212 -643 -85 170\nc-4-3.333-8.333-7.667-13 -13l-13-13l77-155 77-156c66 199.333 139 419.667\n219 661 l218 661zM702 " + hLinePad + "H400000v" + (40 + extraVinculum) + "H742z";
|
|
798
798
|
};
|
|
799
799
|
|
|
800
|
-
var sqrtPath = function sqrtPath(size,
|
|
801
|
-
|
|
800
|
+
var sqrtPath = function sqrtPath(size, extraVinculum, viewBoxHeight) {
|
|
801
|
+
extraVinculum = 1000 * extraVinculum; // Convert from document ems to viewBox.
|
|
802
802
|
|
|
803
803
|
var path = "";
|
|
804
804
|
|
|
805
805
|
switch (size) {
|
|
806
806
|
case "sqrtMain":
|
|
807
|
-
path = sqrtMain(
|
|
807
|
+
path = sqrtMain(extraVinculum, hLinePad);
|
|
808
808
|
break;
|
|
809
809
|
|
|
810
810
|
case "sqrtSize1":
|
|
811
|
-
path = sqrtSize1(
|
|
811
|
+
path = sqrtSize1(extraVinculum, hLinePad);
|
|
812
812
|
break;
|
|
813
813
|
|
|
814
814
|
case "sqrtSize2":
|
|
815
|
-
path = sqrtSize2(
|
|
815
|
+
path = sqrtSize2(extraVinculum, hLinePad);
|
|
816
816
|
break;
|
|
817
817
|
|
|
818
818
|
case "sqrtSize3":
|
|
819
|
-
path = sqrtSize3(
|
|
819
|
+
path = sqrtSize3(extraVinculum, hLinePad);
|
|
820
820
|
break;
|
|
821
821
|
|
|
822
822
|
case "sqrtSize4":
|
|
823
|
-
path = sqrtSize4(
|
|
823
|
+
path = sqrtSize4(extraVinculum, hLinePad);
|
|
824
824
|
break;
|
|
825
825
|
|
|
826
826
|
case "sqrtTall":
|
|
827
|
-
path = sqrtTall(
|
|
827
|
+
path = sqrtTall(extraVinculum, hLinePad, viewBoxHeight);
|
|
828
828
|
}
|
|
829
829
|
|
|
830
830
|
return path;
|
|
@@ -930,7 +930,7 @@ var path = {
|
|
|
930
930
|
widecheck4: "M1181,340h2l1171,-296c6,0,10,-5,10,-11l-2,-23c-1,-6,-5,-10,\n-11,-10h-1l-1168,273l-1167,-273h-1c-6,0,-10,4,-11,10l-2,23c-1,6,4,11,10,11z",
|
|
931
931
|
// The next ten paths support reaction arrows from the mhchem package.
|
|
932
932
|
// Arrows for \ce{<-->} are offset from xAxis by 0.22ex, per mhchem in LaTeX
|
|
933
|
-
// baraboveleftarrow is mostly from
|
|
933
|
+
// baraboveleftarrow is mostly from glyph U+2190 in font KaTeX Main
|
|
934
934
|
baraboveleftarrow: "M400000 620h-399890l3 -3c68.7 -52.7 113.7 -120 135 -202\nc4 -14.7 6 -23 6 -25c0 -7.3 -7 -11 -21 -11c-8 0 -13.2 0.8 -15.5 2.5\nc-2.3 1.7 -4.2 5.8 -5.5 12.5c-1.3 4.7 -2.7 10.3 -4 17c-12 48.7 -34.8 92 -68.5 130\ns-74.2 66.3 -121.5 85c-10 4 -16 7.7 -18 11c0 8.7 6 14.3 18 17c47.3 18.7 87.8 47\n121.5 85s56.5 81.3 68.5 130c0.7 2 1.3 5 2 9s1.2 6.7 1.5 8c0.3 1.3 1 3.3 2 6\ns2.2 4.5 3.5 5.5c1.3 1 3.3 1.8 6 2.5s6 1 10 1c14 0 21 -3.7 21 -11\nc0 -2 -2 -10.3 -6 -25c-20 -79.3 -65 -146.7 -135 -202l-3 -3h399890z\nM100 620v40h399900v-40z M0 241v40h399900v-40zM0 241v40h399900v-40z",
|
|
935
935
|
// rightarrowabovebar is mostly from glyph U+2192, KaTeX Main
|
|
936
936
|
rightarrowabovebar: "M0 241v40h399891c-47.3 35.3-84 78-110 128-16.7 32\n-27.7 63.7-33 95 0 1.3-.2 2.7-.5 4-.3 1.3-.5 2.3-.5 3 0 7.3 6.7 11 20 11 8 0\n13.2-.8 15.5-2.5 2.3-1.7 4.2-5.5 5.5-11.5 2-13.3 5.7-27 11-41 14.7-44.7 39\n-84.5 73-119.5s73.7-60.2 119-75.5c6-2 9-5.7 9-11s-3-9-9-11c-45.3-15.3-85-40.5\n-119-75.5s-58.3-74.8-73-119.5c-4.7-14-8.3-27.3-11-40-1.3-6.7-3.2-10.8-5.5\n-12.5-2.3-1.7-7.5-2.5-15.5-2.5-14 0-21 3.7-21 11 0 2 2 10.3 6 25 20.7 83.3 67\n151.7 139 205zm96 379h399894v40H0zm0 0h399904v40H0z",
|
|
@@ -3133,9 +3133,9 @@ var fontMetricsData = {
|
|
|
3133
3133
|
// In TeX, there are actually three sets of dimensions, one for each of
|
|
3134
3134
|
// textstyle (size index 5 and higher: >=9pt), scriptstyle (size index 3 and 4:
|
|
3135
3135
|
// 7-8pt), and scriptscriptstyle (size index 1 and 2: 5-6pt). These are
|
|
3136
|
-
// provided in the
|
|
3136
|
+
// provided in the arrays below, in that order.
|
|
3137
3137
|
//
|
|
3138
|
-
// The font metrics are stored in fonts cmsy10, cmsy7, and cmsy5
|
|
3138
|
+
// The font metrics are stored in fonts cmsy10, cmsy7, and cmsy5 respectively.
|
|
3139
3139
|
// This was determined by running the following script:
|
|
3140
3140
|
//
|
|
3141
3141
|
// latex -interaction=nonstopmode \
|
|
@@ -3145,7 +3145,7 @@ var fontMetricsData = {
|
|
|
3145
3145
|
// '\expandafter\show\the\scriptscriptfont2' \
|
|
3146
3146
|
// '\stop'
|
|
3147
3147
|
//
|
|
3148
|
-
// The metrics themselves were
|
|
3148
|
+
// The metrics themselves were retrieved using the following commands:
|
|
3149
3149
|
//
|
|
3150
3150
|
// tftopl cmsy10
|
|
3151
3151
|
// tftopl cmsy7
|
|
@@ -3352,7 +3352,7 @@ function getCharacterMetrics(character, font, mode) {
|
|
|
3352
3352
|
// So if the character is in a script we support but we
|
|
3353
3353
|
// don't have metrics for it, just use the metrics for
|
|
3354
3354
|
// the Latin capital letter M. This is close enough because
|
|
3355
|
-
// we (currently) only care about the height of the
|
|
3355
|
+
// we (currently) only care about the height of the glyph
|
|
3356
3356
|
// not its width.
|
|
3357
3357
|
if (supportedCodepoint(ch)) {
|
|
3358
3358
|
metrics = fontMetricsData[font][77]; // 77 is the charcode for 'M'
|
|
@@ -6563,7 +6563,7 @@ function buildHTML(tree, options) {
|
|
|
6563
6563
|
* since we're mainly using MathML to improve accessibility, we don't manage
|
|
6564
6564
|
* any of the styling state that the plain DOM nodes do.
|
|
6565
6565
|
*
|
|
6566
|
-
* The `toNode` and `toMarkup` functions work
|
|
6566
|
+
* The `toNode` and `toMarkup` functions work similarly to how they do in
|
|
6567
6567
|
* domTree.js, creating namespaced DOM nodes and HTML text markup respectively.
|
|
6568
6568
|
*/
|
|
6569
6569
|
function newDocumentFragment(children) {
|
|
@@ -6694,7 +6694,7 @@ class TextNode {
|
|
|
6694
6694
|
}
|
|
6695
6695
|
/**
|
|
6696
6696
|
* Converts the text node into a string
|
|
6697
|
-
* (representing the text
|
|
6697
|
+
* (representing the text itself).
|
|
6698
6698
|
*/
|
|
6699
6699
|
|
|
6700
6700
|
|
|
@@ -6789,7 +6789,7 @@ var mathMLTree = {
|
|
|
6789
6789
|
};
|
|
6790
6790
|
|
|
6791
6791
|
/**
|
|
6792
|
-
* This file converts a parse tree into a
|
|
6792
|
+
* This file converts a parse tree into a corresponding MathML tree. The main
|
|
6793
6793
|
* entry point is the `buildMathML` function, which takes a parse tree from the
|
|
6794
6794
|
* parser.
|
|
6795
6795
|
*/
|
|
@@ -6864,7 +6864,7 @@ var getVariant = function getVariant(group, options) {
|
|
|
6864
6864
|
} else if (font === "mathfrak") {
|
|
6865
6865
|
return "fraktur";
|
|
6866
6866
|
} else if (font === "mathscr" || font === "mathcal") {
|
|
6867
|
-
// MathML makes no distinction between script and
|
|
6867
|
+
// MathML makes no distinction between script and calligraphic
|
|
6868
6868
|
return "script";
|
|
6869
6869
|
} else if (font === "mathsf") {
|
|
6870
6870
|
return "sans-serif";
|
|
@@ -7780,7 +7780,7 @@ defineFunction({
|
|
|
7780
7780
|
},
|
|
7781
7781
|
|
|
7782
7782
|
// Flow is unable to correctly infer the type of `group`, even though it's
|
|
7783
|
-
//
|
|
7783
|
+
// unambiguously determined from the passed-in `type` above.
|
|
7784
7784
|
htmlBuilder(group, options) {
|
|
7785
7785
|
var style = options.style; // Build the argument groups in the appropriate style.
|
|
7786
7786
|
// Ref: amsmath.dtx: \hbox{$\scriptstyle\mkern#3mu{#6}\mkern#4mu$}%
|
|
@@ -9142,7 +9142,7 @@ var makeStackedDelim = function makeStackedDelim(delim, heightTotal, center, opt
|
|
|
9142
9142
|
var middleMetrics = getMetrics(middle, font, mode);
|
|
9143
9143
|
middleHeightTotal = middleMetrics.height + middleMetrics.depth;
|
|
9144
9144
|
middleFactor = 2; // repeat symmetrically above and below middle
|
|
9145
|
-
} //
|
|
9145
|
+
} // Calculate the minimal height that the delimiter can have.
|
|
9146
9146
|
// It is at least the size of the top, bottom, and optional middle combined.
|
|
9147
9147
|
|
|
9148
9148
|
|
|
@@ -9226,7 +9226,7 @@ var makeStackedDelim = function makeStackedDelim(delim, heightTotal, center, opt
|
|
|
9226
9226
|
children: stack
|
|
9227
9227
|
}, newOptions);
|
|
9228
9228
|
return styleWrap(buildCommon.makeSpan(["delimsizing", "mult"], [inner], newOptions), Style$1.TEXT, options, classes);
|
|
9229
|
-
}; // All surds have 0.08em padding above the
|
|
9229
|
+
}; // All surds have 0.08em padding above the vinculum inside the SVG.
|
|
9230
9230
|
// That keeps browser span height rounding error from pinching the line.
|
|
9231
9231
|
|
|
9232
9232
|
|
|
@@ -9234,8 +9234,8 @@ var vbPad = 80; // padding above the surd, measured inside the viewBox.
|
|
|
9234
9234
|
|
|
9235
9235
|
var emPad = 0.08; // padding, in ems, measured in the document.
|
|
9236
9236
|
|
|
9237
|
-
var sqrtSvg = function sqrtSvg(sqrtName, height, viewBoxHeight,
|
|
9238
|
-
var path = sqrtPath(sqrtName,
|
|
9237
|
+
var sqrtSvg = function sqrtSvg(sqrtName, height, viewBoxHeight, extraVinculum, options) {
|
|
9238
|
+
var path = sqrtPath(sqrtName, extraVinculum, viewBoxHeight);
|
|
9239
9239
|
var pathNode = new PathNode(sqrtName, path);
|
|
9240
9240
|
var svg = new SvgNode([pathNode], {
|
|
9241
9241
|
// Note: 1000:1 ratio of viewBox to document em width.
|
|
@@ -9258,10 +9258,10 @@ var makeSqrtImage = function makeSqrtImage(height, options) {
|
|
|
9258
9258
|
|
|
9259
9259
|
var delim = traverseSequence("\\surd", height * newOptions.sizeMultiplier, stackLargeDelimiterSequence, newOptions);
|
|
9260
9260
|
var sizeMultiplier = newOptions.sizeMultiplier; // default
|
|
9261
|
-
// The standard sqrt SVGs each have a 0.04em thick
|
|
9262
|
-
// If Settings.minRuleThickness is larger than that, we add
|
|
9261
|
+
// The standard sqrt SVGs each have a 0.04em thick vinculum.
|
|
9262
|
+
// If Settings.minRuleThickness is larger than that, we add extraVinculum.
|
|
9263
9263
|
|
|
9264
|
-
var
|
|
9264
|
+
var extraVinculum = Math.max(0, options.minRuleThickness - options.fontMetrics().sqrtRuleThickness); // Create a span containing an SVG image of a sqrt symbol.
|
|
9265
9265
|
|
|
9266
9266
|
var span;
|
|
9267
9267
|
var spanHeight = 0;
|
|
@@ -9269,14 +9269,14 @@ var makeSqrtImage = function makeSqrtImage(height, options) {
|
|
|
9269
9269
|
var viewBoxHeight = 0;
|
|
9270
9270
|
var advanceWidth; // We create viewBoxes with 80 units of "padding" above each surd.
|
|
9271
9271
|
// Then browser rounding error on the parent span height will not
|
|
9272
|
-
// encroach on the ink of the
|
|
9272
|
+
// encroach on the ink of the vinculum. But that padding is not
|
|
9273
9273
|
// included in the TeX-like `height` used for calculation of
|
|
9274
9274
|
// vertical alignment. So texHeight = span.height < span.style.height.
|
|
9275
9275
|
|
|
9276
9276
|
if (delim.type === "small") {
|
|
9277
9277
|
// Get an SVG that is derived from glyph U+221A in font KaTeX-Main.
|
|
9278
9278
|
// 1000 unit normal glyph height.
|
|
9279
|
-
viewBoxHeight = 1000 + 1000 *
|
|
9279
|
+
viewBoxHeight = 1000 + 1000 * extraVinculum + vbPad;
|
|
9280
9280
|
|
|
9281
9281
|
if (height < 1.0) {
|
|
9282
9282
|
sizeMultiplier = 1.0; // mimic a \textfont radical
|
|
@@ -9284,26 +9284,26 @@ var makeSqrtImage = function makeSqrtImage(height, options) {
|
|
|
9284
9284
|
sizeMultiplier = 0.7; // mimic a \scriptfont radical
|
|
9285
9285
|
}
|
|
9286
9286
|
|
|
9287
|
-
spanHeight = (1.0 +
|
|
9288
|
-
texHeight = (1.00 +
|
|
9289
|
-
span = sqrtSvg("sqrtMain", spanHeight, viewBoxHeight,
|
|
9287
|
+
spanHeight = (1.0 + extraVinculum + emPad) / sizeMultiplier;
|
|
9288
|
+
texHeight = (1.00 + extraVinculum) / sizeMultiplier;
|
|
9289
|
+
span = sqrtSvg("sqrtMain", spanHeight, viewBoxHeight, extraVinculum, options);
|
|
9290
9290
|
span.style.minWidth = "0.853em";
|
|
9291
9291
|
advanceWidth = 0.833 / sizeMultiplier; // from the font.
|
|
9292
9292
|
} else if (delim.type === "large") {
|
|
9293
9293
|
// These SVGs come from fonts: KaTeX_Size1, _Size2, etc.
|
|
9294
9294
|
viewBoxHeight = (1000 + vbPad) * sizeToMaxHeight[delim.size];
|
|
9295
|
-
texHeight = (sizeToMaxHeight[delim.size] +
|
|
9296
|
-
spanHeight = (sizeToMaxHeight[delim.size] +
|
|
9297
|
-
span = sqrtSvg("sqrtSize" + delim.size, spanHeight, viewBoxHeight,
|
|
9295
|
+
texHeight = (sizeToMaxHeight[delim.size] + extraVinculum) / sizeMultiplier;
|
|
9296
|
+
spanHeight = (sizeToMaxHeight[delim.size] + extraVinculum + emPad) / sizeMultiplier;
|
|
9297
|
+
span = sqrtSvg("sqrtSize" + delim.size, spanHeight, viewBoxHeight, extraVinculum, options);
|
|
9298
9298
|
span.style.minWidth = "1.02em";
|
|
9299
9299
|
advanceWidth = 1.0 / sizeMultiplier; // 1.0 from the font.
|
|
9300
9300
|
} else {
|
|
9301
9301
|
// Tall sqrt. In TeX, this would be stacked using multiple glyphs.
|
|
9302
9302
|
// We'll use a single SVG to accomplish the same thing.
|
|
9303
|
-
spanHeight = height +
|
|
9304
|
-
texHeight = height +
|
|
9305
|
-
viewBoxHeight = Math.floor(1000 * height +
|
|
9306
|
-
span = sqrtSvg("sqrtTall", spanHeight, viewBoxHeight,
|
|
9303
|
+
spanHeight = height + extraVinculum + emPad;
|
|
9304
|
+
texHeight = height + extraVinculum;
|
|
9305
|
+
viewBoxHeight = Math.floor(1000 * height + extraVinculum) + vbPad;
|
|
9306
|
+
span = sqrtSvg("sqrtTall", spanHeight, viewBoxHeight, extraVinculum, options);
|
|
9307
9307
|
span.style.minWidth = "0.742em";
|
|
9308
9308
|
advanceWidth = 1.056;
|
|
9309
9309
|
}
|
|
@@ -9317,7 +9317,7 @@ var makeSqrtImage = function makeSqrtImage(height, options) {
|
|
|
9317
9317
|
// This actually should depend on the chosen font -- e.g. \boldmath
|
|
9318
9318
|
// should use the thicker surd symbols from e.g. KaTeX_Main-Bold, and
|
|
9319
9319
|
// have thicker rules.
|
|
9320
|
-
ruleWidth: (options.fontMetrics().sqrtRuleThickness +
|
|
9320
|
+
ruleWidth: (options.fontMetrics().sqrtRuleThickness + extraVinculum) * sizeMultiplier
|
|
9321
9321
|
};
|
|
9322
9322
|
}; // There are three kinds of delimiters, delimiters that stack when they become
|
|
9323
9323
|
// too large
|
|
@@ -9884,7 +9884,7 @@ defineFunction({
|
|
|
9884
9884
|
return middleDelim;
|
|
9885
9885
|
},
|
|
9886
9886
|
mathmlBuilder: (group, options) => {
|
|
9887
|
-
// A Firefox \middle will
|
|
9887
|
+
// A Firefox \middle will stretch a character vertically only if it
|
|
9888
9888
|
// is in the fence part of the operator dictionary at:
|
|
9889
9889
|
// https://www.w3.org/TR/MathML3/appendixc.html.
|
|
9890
9890
|
// So we need to avoid U+2223 and use plain "|" instead.
|
|
@@ -10853,8 +10853,8 @@ var mathmlBuilder$5 = function mathmlBuilder(group, options) {
|
|
|
10853
10853
|
// LaTeX \arraystretch multiplies the row baseline-to-baseline distance.
|
|
10854
10854
|
// We simulate this by adding (arraystretch - 1)em to the gap. This
|
|
10855
10855
|
// does a reasonable job of adjusting arrays containing 1 em tall content.
|
|
10856
|
-
// The 0.16 and 0.09 values are found
|
|
10857
|
-
// similar to LaTeX and in which content does not interfere with \
|
|
10856
|
+
// The 0.16 and 0.09 values are found empirically. They produce an array
|
|
10857
|
+
// similar to LaTeX and in which content does not interfere with \hlines.
|
|
10858
10858
|
|
|
10859
10859
|
var gap = group.arraystretch === 0.5 ? 0.1 // {smallmatrix}, {subarray}
|
|
10860
10860
|
: 0.16 + group.arraystretch - 1 + (group.addJot ? 0.09 : 0);
|
|
@@ -16316,15 +16316,15 @@ class MacroExpander {
|
|
|
16316
16316
|
* Expand the next token only once if possible.
|
|
16317
16317
|
*
|
|
16318
16318
|
* If the token is expanded, the resulting tokens will be pushed onto
|
|
16319
|
-
* the stack in reverse order and
|
|
16320
|
-
*
|
|
16319
|
+
* the stack in reverse order, and the number of such tokens will be
|
|
16320
|
+
* returned. This number might be zero or positive.
|
|
16321
16321
|
*
|
|
16322
|
-
* If not, the
|
|
16323
|
-
*
|
|
16324
|
-
* instead of an `Array` return value.
|
|
16322
|
+
* If not, the return value is `false`, and the next token remains at the
|
|
16323
|
+
* top of the stack.
|
|
16325
16324
|
*
|
|
16326
16325
|
* In either case, the next token will be on the top of the stack,
|
|
16327
|
-
* or the stack will be empty
|
|
16326
|
+
* or the stack will be empty (in case of empty expansion
|
|
16327
|
+
* and no other tokens).
|
|
16328
16328
|
*
|
|
16329
16329
|
* Used to implement `expandAfterFuture` and `expandNextToken`.
|
|
16330
16330
|
*
|
|
@@ -16344,7 +16344,7 @@ class MacroExpander {
|
|
|
16344
16344
|
}
|
|
16345
16345
|
|
|
16346
16346
|
this.pushToken(topToken);
|
|
16347
|
-
return
|
|
16347
|
+
return false;
|
|
16348
16348
|
}
|
|
16349
16349
|
|
|
16350
16350
|
this.expansionCount++;
|
|
@@ -16385,7 +16385,7 @@ class MacroExpander {
|
|
|
16385
16385
|
|
|
16386
16386
|
|
|
16387
16387
|
this.pushTokens(tokens);
|
|
16388
|
-
return tokens;
|
|
16388
|
+
return tokens.length;
|
|
16389
16389
|
}
|
|
16390
16390
|
/**
|
|
16391
16391
|
* Expand the next token only once (if possible), and return the resulting
|
|
@@ -16406,16 +16406,16 @@ class MacroExpander {
|
|
|
16406
16406
|
|
|
16407
16407
|
expandNextToken() {
|
|
16408
16408
|
for (;;) {
|
|
16409
|
-
|
|
16410
|
-
|
|
16411
|
-
|
|
16412
|
-
// the token after \noexpand is interpreted as if its meaning
|
|
16409
|
+
if (this.expandOnce() === false) {
|
|
16410
|
+
// fully expanded
|
|
16411
|
+
var token = this.stack.pop(); // the token after \noexpand is interpreted as if its meaning
|
|
16413
16412
|
// were ‘\relax’
|
|
16414
|
-
|
|
16415
|
-
|
|
16413
|
+
|
|
16414
|
+
if (token.treatAsRelax) {
|
|
16415
|
+
token.text = "\\relax";
|
|
16416
16416
|
}
|
|
16417
16417
|
|
|
16418
|
-
return
|
|
16418
|
+
return token;
|
|
16419
16419
|
}
|
|
16420
16420
|
} // Flow unable to figure out that this pathway is impossible.
|
|
16421
16421
|
// https://github.com/facebook/flow/issues/4808
|
|
@@ -16445,17 +16445,18 @@ class MacroExpander {
|
|
|
16445
16445
|
this.pushTokens(tokens);
|
|
16446
16446
|
|
|
16447
16447
|
while (this.stack.length > oldStackLength) {
|
|
16448
|
-
|
|
16449
|
-
|
|
16448
|
+
// Expand only expandable tokens
|
|
16449
|
+
if (this.expandOnce(true) === false) {
|
|
16450
|
+
// fully expanded
|
|
16451
|
+
var token = this.stack.pop();
|
|
16450
16452
|
|
|
16451
|
-
|
|
16452
|
-
if (expanded.treatAsRelax) {
|
|
16453
|
+
if (token.treatAsRelax) {
|
|
16453
16454
|
// the expansion of \noexpand is the token itself
|
|
16454
|
-
|
|
16455
|
-
|
|
16455
|
+
token.noexpand = false;
|
|
16456
|
+
token.treatAsRelax = false;
|
|
16456
16457
|
}
|
|
16457
16458
|
|
|
16458
|
-
output.push(
|
|
16459
|
+
output.push(token);
|
|
16459
16460
|
}
|
|
16460
16461
|
}
|
|
16461
16462
|
|
|
@@ -17214,7 +17215,7 @@ class Parser {
|
|
|
17214
17215
|
* Parses an "expression", which is a list of atoms.
|
|
17215
17216
|
*
|
|
17216
17217
|
* `breakOnInfix`: Should the parsing stop when we hit infix nodes? This
|
|
17217
|
-
* happens when functions have higher
|
|
17218
|
+
* happens when functions have higher precedence han infix
|
|
17218
17219
|
* nodes in implicit parses.
|
|
17219
17220
|
*
|
|
17220
17221
|
* `breakOnTokenText`: The text of the token that the expression should end
|
|
@@ -18296,7 +18297,7 @@ var katex = {
|
|
|
18296
18297
|
/**
|
|
18297
18298
|
* Current KaTeX version
|
|
18298
18299
|
*/
|
|
18299
|
-
version: "0.16.
|
|
18300
|
+
version: "0.16.6",
|
|
18300
18301
|
|
|
18301
18302
|
/**
|
|
18302
18303
|
* Renders the given LaTeX into an HTML+MathML combination, and adds
|
package/package.json
CHANGED
package/src/MacroExpander.js
CHANGED
|
@@ -249,22 +249,22 @@ export default class MacroExpander implements MacroContextInterface {
|
|
|
249
249
|
* Expand the next token only once if possible.
|
|
250
250
|
*
|
|
251
251
|
* If the token is expanded, the resulting tokens will be pushed onto
|
|
252
|
-
* the stack in reverse order and
|
|
253
|
-
*
|
|
252
|
+
* the stack in reverse order, and the number of such tokens will be
|
|
253
|
+
* returned. This number might be zero or positive.
|
|
254
254
|
*
|
|
255
|
-
* If not, the
|
|
256
|
-
*
|
|
257
|
-
* instead of an `Array` return value.
|
|
255
|
+
* If not, the return value is `false`, and the next token remains at the
|
|
256
|
+
* top of the stack.
|
|
258
257
|
*
|
|
259
258
|
* In either case, the next token will be on the top of the stack,
|
|
260
|
-
* or the stack will be empty
|
|
259
|
+
* or the stack will be empty (in case of empty expansion
|
|
260
|
+
* and no other tokens).
|
|
261
261
|
*
|
|
262
262
|
* Used to implement `expandAfterFuture` and `expandNextToken`.
|
|
263
263
|
*
|
|
264
264
|
* If expandableOnly, only expandable tokens are expanded and
|
|
265
265
|
* an undefined control sequence results in an error.
|
|
266
266
|
*/
|
|
267
|
-
expandOnce(expandableOnly?: boolean):
|
|
267
|
+
expandOnce(expandableOnly?: boolean): number | boolean {
|
|
268
268
|
const topToken = this.popToken();
|
|
269
269
|
const name = topToken.text;
|
|
270
270
|
const expansion = !topToken.noexpand ? this._getExpansion(name) : null;
|
|
@@ -274,7 +274,7 @@ export default class MacroExpander implements MacroContextInterface {
|
|
|
274
274
|
throw new ParseError("Undefined control sequence: " + name);
|
|
275
275
|
}
|
|
276
276
|
this.pushToken(topToken);
|
|
277
|
-
return
|
|
277
|
+
return false;
|
|
278
278
|
}
|
|
279
279
|
this.expansionCount++;
|
|
280
280
|
if (this.expansionCount > this.settings.maxExpand) {
|
|
@@ -310,7 +310,7 @@ export default class MacroExpander implements MacroContextInterface {
|
|
|
310
310
|
}
|
|
311
311
|
// Concatenate expansion onto top of stack.
|
|
312
312
|
this.pushTokens(tokens);
|
|
313
|
-
return tokens;
|
|
313
|
+
return tokens.length;
|
|
314
314
|
}
|
|
315
315
|
|
|
316
316
|
/**
|
|
@@ -329,15 +329,14 @@ export default class MacroExpander implements MacroContextInterface {
|
|
|
329
329
|
*/
|
|
330
330
|
expandNextToken(): Token {
|
|
331
331
|
for (;;) {
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
if (expanded instanceof Token) {
|
|
332
|
+
if (this.expandOnce() === false) { // fully expanded
|
|
333
|
+
const token = this.stack.pop();
|
|
335
334
|
// the token after \noexpand is interpreted as if its meaning
|
|
336
335
|
// were ‘\relax’
|
|
337
|
-
if (
|
|
338
|
-
|
|
336
|
+
if (token.treatAsRelax) {
|
|
337
|
+
token.text = "\\relax";
|
|
339
338
|
}
|
|
340
|
-
return
|
|
339
|
+
return token;
|
|
341
340
|
}
|
|
342
341
|
}
|
|
343
342
|
|
|
@@ -365,15 +364,15 @@ export default class MacroExpander implements MacroContextInterface {
|
|
|
365
364
|
const oldStackLength = this.stack.length;
|
|
366
365
|
this.pushTokens(tokens);
|
|
367
366
|
while (this.stack.length > oldStackLength) {
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
if (
|
|
367
|
+
// Expand only expandable tokens
|
|
368
|
+
if (this.expandOnce(true) === false) { // fully expanded
|
|
369
|
+
const token = this.stack.pop();
|
|
370
|
+
if (token.treatAsRelax) {
|
|
372
371
|
// the expansion of \noexpand is the token itself
|
|
373
|
-
|
|
374
|
-
|
|
372
|
+
token.noexpand = false;
|
|
373
|
+
token.treatAsRelax = false;
|
|
375
374
|
}
|
|
376
|
-
output.push(
|
|
375
|
+
output.push(token);
|
|
377
376
|
}
|
|
378
377
|
}
|
|
379
378
|
return output;
|
package/src/Parser.js
CHANGED
|
@@ -178,7 +178,7 @@ export default class Parser {
|
|
|
178
178
|
* Parses an "expression", which is a list of atoms.
|
|
179
179
|
*
|
|
180
180
|
* `breakOnInfix`: Should the parsing stop when we hit infix nodes? This
|
|
181
|
-
* happens when functions have higher
|
|
181
|
+
* happens when functions have higher precedence han infix
|
|
182
182
|
* nodes in implicit parses.
|
|
183
183
|
*
|
|
184
184
|
* `breakOnTokenText`: The text of the token that the expression should end
|
package/src/buildMathML.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// @flow
|
|
2
2
|
/**
|
|
3
|
-
* This file converts a parse tree into a
|
|
3
|
+
* This file converts a parse tree into a corresponding MathML tree. The main
|
|
4
4
|
* entry point is the `buildMathML` function, which takes a parse tree from the
|
|
5
5
|
* parser.
|
|
6
6
|
*/
|
|
@@ -101,7 +101,7 @@ export const getVariant = function(
|
|
|
101
101
|
} else if (font === "mathfrak") {
|
|
102
102
|
return "fraktur";
|
|
103
103
|
} else if (font === "mathscr" || font === "mathcal") {
|
|
104
|
-
// MathML makes no distinction between script and
|
|
104
|
+
// MathML makes no distinction between script and calligraphic
|
|
105
105
|
return "script";
|
|
106
106
|
} else if (font === "mathsf") {
|
|
107
107
|
return "sans-serif";
|
package/src/defineEnvironment.js
CHANGED
|
@@ -42,7 +42,7 @@ type EnvProps = {
|
|
|
42
42
|
};
|
|
43
43
|
|
|
44
44
|
/**
|
|
45
|
-
* Final
|
|
45
|
+
* Final environment spec for use at parse time.
|
|
46
46
|
* This is almost identical to `EnvDefSpec`, except it
|
|
47
47
|
* 1. includes the function handler
|
|
48
48
|
* 2. requires all arguments except argType
|
package/src/defineMacro.js
CHANGED
|
@@ -35,7 +35,7 @@ export interface MacroContextInterface {
|
|
|
35
35
|
/**
|
|
36
36
|
* Expand the next token only once if possible.
|
|
37
37
|
*/
|
|
38
|
-
expandOnce(expandableOnly?: boolean):
|
|
38
|
+
expandOnce(expandableOnly?: boolean): number | boolean;
|
|
39
39
|
|
|
40
40
|
/**
|
|
41
41
|
* Expand the next token only once (if possible), and return the resulting
|