katex 0.16.0 → 0.16.1
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/copy-tex/README.md +2 -2
- package/contrib/mathtex-script-type/README.md +5 -5
- package/contrib/mhchem/README.md +1 -1
- package/dist/README.md +3 -3
- package/dist/katex.css +1 -1
- package/dist/katex.js +107 -21
- package/dist/katex.min.css +1 -1
- package/dist/katex.min.js +1 -1
- package/dist/katex.mjs +107 -21
- package/package.json +2 -2
- package/src/delimiter.js +68 -25
- package/src/svgGeometry.js +56 -0
package/dist/katex.mjs
CHANGED
|
@@ -941,6 +941,43 @@ var path = {
|
|
|
941
941
|
shortbaraboveleftharpoon: "M7,435c-4,4,-6.3,8.7,-7,14c0,5.3,0.7,9,2,11\nc1.3,2,5.3,5.3,12,10c90.7,54,156,130,196,228c3.3,10.7,6.3,16.3,9,17c2,0.7,5,1,9,\n1c0,0,5,0,5,0c10.7,0,16.7,-2,18,-6c2,-2.7,1,-9.7,-3,-21c-32,-87.3,-82.7,-157.7,\n-152,-211c0,0,-3,-3,-3,-3l399907,0l0,-40c-399126,0,-399993,0,-399993,0z\nM93 435 v40 H400000 v-40z M500 241 v40 H400000 v-40z M500 241 v40 H400000 v-40z",
|
|
942
942
|
shortrightharpoonabovebar: "M53,241l0,40c398570,0,399437,0,399437,0\nc4.7,-4.7,7,-9.3,7,-14c0,-9.3,-3.7,-15.3,-11,-18c-92.7,-56.7,-159,-133.7,-199,\n-231c-3.3,-9.3,-6,-14.7,-8,-16c-2,-1.3,-7,-2,-15,-2c-10.7,0,-16.7,2,-18,6\nc-2,2.7,-1,9.7,3,21c15.3,42,36.7,81.8,64,119.5c27.3,37.7,58,69.2,92,94.5z\nM500 241 v40 H399408 v-40z M500 435 v40 H400000 v-40z"
|
|
943
943
|
};
|
|
944
|
+
var tallDelim = function tallDelim(label, midHeight) {
|
|
945
|
+
switch (label) {
|
|
946
|
+
case "lbrack":
|
|
947
|
+
return "M403 1759 V84 H666 V0 H319 V1759 v" + midHeight + " v1759 h347 v-84\nH403z M403 1759 V0 H319 V1759 v" + midHeight + " v1759 h84z";
|
|
948
|
+
|
|
949
|
+
case "rbrack":
|
|
950
|
+
return "M347 1759 V0 H0 V84 H263 V1759 v" + midHeight + " v1759 H0 v84 H347z\nM347 1759 V0 H263 V1759 v" + midHeight + " v1759 h84z";
|
|
951
|
+
|
|
952
|
+
case "vert":
|
|
953
|
+
return "M145 15 v585 v" + midHeight + " v585 c2.667,10,9.667,15,21,15\nc10,0,16.667,-5,20,-15 v-585 v" + -midHeight + " v-585 c-2.667,-10,-9.667,-15,-21,-15\nc-10,0,-16.667,5,-20,15z M188 15 H145 v585 v" + midHeight + " v585 h43z";
|
|
954
|
+
|
|
955
|
+
case "doublevert":
|
|
956
|
+
return "M145 15 v585 v" + midHeight + " v585 c2.667,10,9.667,15,21,15\nc10,0,16.667,-5,20,-15 v-585 v" + -midHeight + " v-585 c-2.667,-10,-9.667,-15,-21,-15\nc-10,0,-16.667,5,-20,15z M188 15 H145 v585 v" + midHeight + " v585 h43z\nM367 15 v585 v" + midHeight + " v585 c2.667,10,9.667,15,21,15\nc10,0,16.667,-5,20,-15 v-585 v" + -midHeight + " v-585 c-2.667,-10,-9.667,-15,-21,-15\nc-10,0,-16.667,5,-20,15z M410 15 H367 v585 v" + midHeight + " v585 h43z";
|
|
957
|
+
|
|
958
|
+
case "lfloor":
|
|
959
|
+
return "M319 602 V0 H403 V602 v" + midHeight + " v1715 h263 v84 H319z\nMM319 602 V0 H403 V602 v" + midHeight + " v1715 H319z";
|
|
960
|
+
|
|
961
|
+
case "rfloor":
|
|
962
|
+
return "M319 602 V0 H403 V602 v" + midHeight + " v1799 H0 v-84 H319z\nMM319 602 V0 H403 V602 v" + midHeight + " v1715 H319z";
|
|
963
|
+
|
|
964
|
+
case "lceil":
|
|
965
|
+
return "M403 1759 V84 H666 V0 H319 V1759 v" + midHeight + " v602 h84z\nM403 1759 V0 H319 V1759 v" + midHeight + " v602 h84z";
|
|
966
|
+
|
|
967
|
+
case "rceil":
|
|
968
|
+
return "M347 1759 V0 H0 V84 H263 V1759 v" + midHeight + " v602 h84z\nM347 1759 V0 h-84 V1759 v" + midHeight + " v602 h84z";
|
|
969
|
+
|
|
970
|
+
case "lparen":
|
|
971
|
+
return "M863,9c0,-2,-2,-5,-6,-9c0,0,-17,0,-17,0c-12.7,0,-19.3,0.3,-20,1\nc-5.3,5.3,-10.3,11,-15,17c-242.7,294.7,-395.3,682,-458,1162c-21.3,163.3,-33.3,349,\n-36,557 l0," + (midHeight + 84) + "c0.2,6,0,26,0,60c2,159.3,10,310.7,24,454c53.3,528,210,\n949.7,470,1265c4.7,6,9.7,11.7,15,17c0.7,0.7,7,1,19,1c0,0,18,0,18,0c4,-4,6,-7,6,-9\nc0,-2.7,-3.3,-8.7,-10,-18c-135.3,-192.7,-235.5,-414.3,-300.5,-665c-65,-250.7,-102.5,\n-544.7,-112.5,-882c-2,-104,-3,-167,-3,-189\nl0,-" + (midHeight + 92) + "c0,-162.7,5.7,-314,17,-454c20.7,-272,63.7,-513,129,-723c65.3,\n-210,155.3,-396.3,270,-559c6.7,-9.3,10,-15.3,10,-18z";
|
|
972
|
+
|
|
973
|
+
case "rparen":
|
|
974
|
+
return "M76,0c-16.7,0,-25,3,-25,9c0,2,2,6.3,6,13c21.3,28.7,42.3,60.3,\n63,95c96.7,156.7,172.8,332.5,228.5,527.5c55.7,195,92.8,416.5,111.5,664.5\nc11.3,139.3,17,290.7,17,454c0,28,1.7,43,3.3,45l0," + (midHeight + 9) + "\nc-3,4,-3.3,16.7,-3.3,38c0,162,-5.7,313.7,-17,455c-18.7,248,-55.8,469.3,-111.5,664\nc-55.7,194.7,-131.8,370.3,-228.5,527c-20.7,34.7,-41.7,66.3,-63,95c-2,3.3,-4,7,-6,11\nc0,7.3,5.7,11,17,11c0,0,11,0,11,0c9.3,0,14.3,-0.3,15,-1c5.3,-5.3,10.3,-11,15,-17\nc242.7,-294.7,395.3,-681.7,458,-1161c21.3,-164.7,33.3,-350.7,36,-558\nl0,-" + (midHeight + 144) + "c-2,-159.3,-10,-310.7,-24,-454c-53.3,-528,-210,-949.7,\n-470,-1265c-4.7,-6,-9.7,-11.7,-15,-17c-0.7,-0.7,-6.7,-1,-18,-1z";
|
|
975
|
+
|
|
976
|
+
default:
|
|
977
|
+
// We should not ever get here.
|
|
978
|
+
throw new Error("Unknown stretchy delimiter.");
|
|
979
|
+
}
|
|
980
|
+
};
|
|
944
981
|
|
|
945
982
|
/**
|
|
946
983
|
* This node represents a document fragment, which contains elements, but when
|
|
@@ -8762,6 +8799,8 @@ var makeStackedDelim = function makeStackedDelim(delim, heightTotal, center, opt
|
|
|
8762
8799
|
var middle;
|
|
8763
8800
|
var repeat;
|
|
8764
8801
|
var bottom;
|
|
8802
|
+
var svgLabel = "";
|
|
8803
|
+
var viewBoxWidth = 0;
|
|
8765
8804
|
top = repeat = bottom = delim;
|
|
8766
8805
|
middle = null; // Also keep track of what font the delimiters are in
|
|
8767
8806
|
|
|
@@ -8787,44 +8826,64 @@ var makeStackedDelim = function makeStackedDelim(delim, heightTotal, center, opt
|
|
|
8787
8826
|
bottom = "\\Downarrow";
|
|
8788
8827
|
} else if (utils.contains(verts, delim)) {
|
|
8789
8828
|
repeat = "\u2223";
|
|
8829
|
+
svgLabel = "vert";
|
|
8830
|
+
viewBoxWidth = 333;
|
|
8790
8831
|
} else if (utils.contains(doubleVerts, delim)) {
|
|
8791
8832
|
repeat = "\u2225";
|
|
8833
|
+
svgLabel = "doublevert";
|
|
8834
|
+
viewBoxWidth = 556;
|
|
8792
8835
|
} else if (delim === "[" || delim === "\\lbrack") {
|
|
8793
8836
|
top = "\u23a1";
|
|
8794
8837
|
repeat = "\u23a2";
|
|
8795
8838
|
bottom = "\u23a3";
|
|
8796
8839
|
font = "Size4-Regular";
|
|
8840
|
+
svgLabel = "lbrack";
|
|
8841
|
+
viewBoxWidth = 667;
|
|
8797
8842
|
} else if (delim === "]" || delim === "\\rbrack") {
|
|
8798
8843
|
top = "\u23a4";
|
|
8799
8844
|
repeat = "\u23a5";
|
|
8800
8845
|
bottom = "\u23a6";
|
|
8801
8846
|
font = "Size4-Regular";
|
|
8847
|
+
svgLabel = "rbrack";
|
|
8848
|
+
viewBoxWidth = 667;
|
|
8802
8849
|
} else if (delim === "\\lfloor" || delim === "\u230a") {
|
|
8803
8850
|
repeat = top = "\u23a2";
|
|
8804
8851
|
bottom = "\u23a3";
|
|
8805
8852
|
font = "Size4-Regular";
|
|
8853
|
+
svgLabel = "lfloor";
|
|
8854
|
+
viewBoxWidth = 667;
|
|
8806
8855
|
} else if (delim === "\\lceil" || delim === "\u2308") {
|
|
8807
8856
|
top = "\u23a1";
|
|
8808
8857
|
repeat = bottom = "\u23a2";
|
|
8809
8858
|
font = "Size4-Regular";
|
|
8859
|
+
svgLabel = "lceil";
|
|
8860
|
+
viewBoxWidth = 667;
|
|
8810
8861
|
} else if (delim === "\\rfloor" || delim === "\u230b") {
|
|
8811
8862
|
repeat = top = "\u23a5";
|
|
8812
8863
|
bottom = "\u23a6";
|
|
8813
8864
|
font = "Size4-Regular";
|
|
8865
|
+
svgLabel = "rfloor";
|
|
8866
|
+
viewBoxWidth = 667;
|
|
8814
8867
|
} else if (delim === "\\rceil" || delim === "\u2309") {
|
|
8815
8868
|
top = "\u23a4";
|
|
8816
8869
|
repeat = bottom = "\u23a5";
|
|
8817
8870
|
font = "Size4-Regular";
|
|
8871
|
+
svgLabel = "rceil";
|
|
8872
|
+
viewBoxWidth = 667;
|
|
8818
8873
|
} else if (delim === "(" || delim === "\\lparen") {
|
|
8819
8874
|
top = "\u239b";
|
|
8820
8875
|
repeat = "\u239c";
|
|
8821
8876
|
bottom = "\u239d";
|
|
8822
8877
|
font = "Size4-Regular";
|
|
8878
|
+
svgLabel = "lparen";
|
|
8879
|
+
viewBoxWidth = 875;
|
|
8823
8880
|
} else if (delim === ")" || delim === "\\rparen") {
|
|
8824
8881
|
top = "\u239e";
|
|
8825
8882
|
repeat = "\u239f";
|
|
8826
8883
|
bottom = "\u23a0";
|
|
8827
8884
|
font = "Size4-Regular";
|
|
8885
|
+
svgLabel = "rparen";
|
|
8886
|
+
viewBoxWidth = 875;
|
|
8828
8887
|
} else if (delim === "\\{" || delim === "\\lbrace") {
|
|
8829
8888
|
top = "\u23a7";
|
|
8830
8889
|
middle = "\u23a8";
|
|
@@ -8896,32 +8955,59 @@ var makeStackedDelim = function makeStackedDelim(delim, heightTotal, center, opt
|
|
|
8896
8955
|
var depth = realHeightTotal / 2 - axisHeight; // Now, we start building the pieces that will go into the vlist
|
|
8897
8956
|
// Keep a list of the pieces of the stacked delimiter
|
|
8898
8957
|
|
|
8899
|
-
var stack = [];
|
|
8958
|
+
var stack = [];
|
|
8959
|
+
|
|
8960
|
+
if (svgLabel.length > 0) {
|
|
8961
|
+
// Instead of stacking glyphs, create a single SVG.
|
|
8962
|
+
// This evades browser problems with imprecise positioning of spans.
|
|
8963
|
+
var midHeight = realHeightTotal - topHeightTotal - bottomHeightTotal;
|
|
8964
|
+
var viewBoxHeight = Math.round(realHeightTotal * 1000);
|
|
8965
|
+
var pathStr = tallDelim(svgLabel, Math.round(midHeight * 1000));
|
|
8966
|
+
var path = new PathNode(svgLabel, pathStr);
|
|
8967
|
+
var width = (viewBoxWidth / 1000).toFixed(3) + "em";
|
|
8968
|
+
var height = (viewBoxHeight / 1000).toFixed(3) + "em";
|
|
8969
|
+
var svg = new SvgNode([path], {
|
|
8970
|
+
"width": width,
|
|
8971
|
+
"height": height,
|
|
8972
|
+
"viewBox": "0 0 " + viewBoxWidth + " " + viewBoxHeight
|
|
8973
|
+
});
|
|
8974
|
+
var wrapper = buildCommon.makeSvgSpan([], [svg], options);
|
|
8975
|
+
wrapper.height = viewBoxHeight / 1000;
|
|
8976
|
+
wrapper.style.width = width;
|
|
8977
|
+
wrapper.style.height = height;
|
|
8978
|
+
stack.push({
|
|
8979
|
+
type: "elem",
|
|
8980
|
+
elem: wrapper
|
|
8981
|
+
});
|
|
8982
|
+
} else {
|
|
8983
|
+
// Stack glyphs
|
|
8984
|
+
// Start by adding the bottom symbol
|
|
8985
|
+
stack.push(makeGlyphSpan(bottom, font, mode));
|
|
8986
|
+
stack.push(lap); // overlap
|
|
8987
|
+
|
|
8988
|
+
if (middle === null) {
|
|
8989
|
+
// The middle section will be an SVG. Make it an extra 0.016em tall.
|
|
8990
|
+
// We'll overlap by 0.008em at top and bottom.
|
|
8991
|
+
var innerHeight = realHeightTotal - topHeightTotal - bottomHeightTotal + 2 * lapInEms;
|
|
8992
|
+
stack.push(makeInner(repeat, innerHeight, options));
|
|
8993
|
+
} else {
|
|
8994
|
+
// When there is a middle bit, we need the middle part and two repeated
|
|
8995
|
+
// sections
|
|
8996
|
+
var _innerHeight = (realHeightTotal - topHeightTotal - bottomHeightTotal - middleHeightTotal) / 2 + 2 * lapInEms;
|
|
8900
8997
|
|
|
8901
|
-
|
|
8902
|
-
stack.push(lap); // overlap
|
|
8998
|
+
stack.push(makeInner(repeat, _innerHeight, options)); // Now insert the middle of the brace.
|
|
8903
8999
|
|
|
8904
|
-
|
|
8905
|
-
|
|
8906
|
-
|
|
8907
|
-
|
|
8908
|
-
|
|
8909
|
-
} else {
|
|
8910
|
-
// When there is a middle bit, we need the middle part and two repeated
|
|
8911
|
-
// sections
|
|
8912
|
-
var _innerHeight = (realHeightTotal - topHeightTotal - bottomHeightTotal - middleHeightTotal) / 2 + 2 * lapInEms;
|
|
9000
|
+
stack.push(lap);
|
|
9001
|
+
stack.push(makeGlyphSpan(middle, font, mode));
|
|
9002
|
+
stack.push(lap);
|
|
9003
|
+
stack.push(makeInner(repeat, _innerHeight, options));
|
|
9004
|
+
} // Add the top symbol
|
|
8913
9005
|
|
|
8914
|
-
stack.push(makeInner(repeat, _innerHeight, options)); // Now insert the middle of the brace.
|
|
8915
9006
|
|
|
8916
9007
|
stack.push(lap);
|
|
8917
|
-
stack.push(makeGlyphSpan(
|
|
8918
|
-
|
|
8919
|
-
stack.push(makeInner(repeat, _innerHeight, options));
|
|
8920
|
-
} // Add the top symbol
|
|
8921
|
-
|
|
9008
|
+
stack.push(makeGlyphSpan(top, font, mode));
|
|
9009
|
+
} // Finally, build the vlist
|
|
8922
9010
|
|
|
8923
|
-
stack.push(lap);
|
|
8924
|
-
stack.push(makeGlyphSpan(top, font, mode)); // Finally, build the vlist
|
|
8925
9011
|
|
|
8926
9012
|
var newOptions = options.havingBaseStyle(Style$1.TEXT);
|
|
8927
9013
|
var inner = buildCommon.makeVList({
|
|
@@ -18168,7 +18254,7 @@ var katex = {
|
|
|
18168
18254
|
/**
|
|
18169
18255
|
* Current KaTeX version
|
|
18170
18256
|
*/
|
|
18171
|
-
version: "0.16.
|
|
18257
|
+
version: "0.16.1",
|
|
18172
18258
|
|
|
18173
18259
|
/**
|
|
18174
18260
|
* Renders the given LaTeX into an HTML+MathML combination, and adds
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "katex",
|
|
3
|
-
"version": "0.16.
|
|
3
|
+
"version": "0.16.1",
|
|
4
4
|
"description": "Fast math typesetting for the web.",
|
|
5
5
|
"main": "dist/katex.js",
|
|
6
6
|
"exports": {
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"dist/"
|
|
48
48
|
],
|
|
49
49
|
"license": "MIT",
|
|
50
|
-
"packageManager": "yarn@3.2.
|
|
50
|
+
"packageManager": "yarn@3.2.2",
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"@babel/core": "^7.10.4",
|
|
53
53
|
"@babel/eslint-parser": "^7.15.0",
|
package/src/delimiter.js
CHANGED
|
@@ -25,7 +25,7 @@ import ParseError from "./ParseError";
|
|
|
25
25
|
import Style from "./Style";
|
|
26
26
|
|
|
27
27
|
import {PathNode, SvgNode, SymbolNode} from "./domTree";
|
|
28
|
-
import {sqrtPath, innerPath} from "./svgGeometry";
|
|
28
|
+
import {sqrtPath, innerPath, tallDelim} from "./svgGeometry";
|
|
29
29
|
import buildCommon from "./buildCommon";
|
|
30
30
|
import {getCharacterMetrics} from "./fontMetrics";
|
|
31
31
|
import symbols from "./symbols";
|
|
@@ -229,6 +229,8 @@ const makeStackedDelim = function(
|
|
|
229
229
|
let middle;
|
|
230
230
|
let repeat;
|
|
231
231
|
let bottom;
|
|
232
|
+
let svgLabel = "";
|
|
233
|
+
let viewBoxWidth = 0;
|
|
232
234
|
top = repeat = bottom = delim;
|
|
233
235
|
middle = null;
|
|
234
236
|
// Also keep track of what font the delimiters are in
|
|
@@ -255,44 +257,64 @@ const makeStackedDelim = function(
|
|
|
255
257
|
bottom = "\\Downarrow";
|
|
256
258
|
} else if (utils.contains(verts, delim)) {
|
|
257
259
|
repeat = "\u2223";
|
|
260
|
+
svgLabel = "vert";
|
|
261
|
+
viewBoxWidth = 333;
|
|
258
262
|
} else if (utils.contains(doubleVerts, delim)) {
|
|
259
263
|
repeat = "\u2225";
|
|
264
|
+
svgLabel = "doublevert";
|
|
265
|
+
viewBoxWidth = 556;
|
|
260
266
|
} else if (delim === "[" || delim === "\\lbrack") {
|
|
261
267
|
top = "\u23a1";
|
|
262
268
|
repeat = "\u23a2";
|
|
263
269
|
bottom = "\u23a3";
|
|
264
270
|
font = "Size4-Regular";
|
|
271
|
+
svgLabel = "lbrack";
|
|
272
|
+
viewBoxWidth = 667;
|
|
265
273
|
} else if (delim === "]" || delim === "\\rbrack") {
|
|
266
274
|
top = "\u23a4";
|
|
267
275
|
repeat = "\u23a5";
|
|
268
276
|
bottom = "\u23a6";
|
|
269
277
|
font = "Size4-Regular";
|
|
278
|
+
svgLabel = "rbrack";
|
|
279
|
+
viewBoxWidth = 667;
|
|
270
280
|
} else if (delim === "\\lfloor" || delim === "\u230a") {
|
|
271
281
|
repeat = top = "\u23a2";
|
|
272
282
|
bottom = "\u23a3";
|
|
273
283
|
font = "Size4-Regular";
|
|
284
|
+
svgLabel = "lfloor";
|
|
285
|
+
viewBoxWidth = 667;
|
|
274
286
|
} else if (delim === "\\lceil" || delim === "\u2308") {
|
|
275
287
|
top = "\u23a1";
|
|
276
288
|
repeat = bottom = "\u23a2";
|
|
277
289
|
font = "Size4-Regular";
|
|
290
|
+
svgLabel = "lceil";
|
|
291
|
+
viewBoxWidth = 667;
|
|
278
292
|
} else if (delim === "\\rfloor" || delim === "\u230b") {
|
|
279
293
|
repeat = top = "\u23a5";
|
|
280
294
|
bottom = "\u23a6";
|
|
281
295
|
font = "Size4-Regular";
|
|
296
|
+
svgLabel = "rfloor";
|
|
297
|
+
viewBoxWidth = 667;
|
|
282
298
|
} else if (delim === "\\rceil" || delim === "\u2309") {
|
|
283
299
|
top = "\u23a4";
|
|
284
300
|
repeat = bottom = "\u23a5";
|
|
285
301
|
font = "Size4-Regular";
|
|
302
|
+
svgLabel = "rceil";
|
|
303
|
+
viewBoxWidth = 667;
|
|
286
304
|
} else if (delim === "(" || delim === "\\lparen") {
|
|
287
305
|
top = "\u239b";
|
|
288
306
|
repeat = "\u239c";
|
|
289
307
|
bottom = "\u239d";
|
|
290
308
|
font = "Size4-Regular";
|
|
309
|
+
svgLabel = "lparen";
|
|
310
|
+
viewBoxWidth = 875;
|
|
291
311
|
} else if (delim === ")" || delim === "\\rparen") {
|
|
292
312
|
top = "\u239e";
|
|
293
313
|
repeat = "\u239f";
|
|
294
314
|
bottom = "\u23a0";
|
|
295
315
|
font = "Size4-Regular";
|
|
316
|
+
svgLabel = "rparen";
|
|
317
|
+
viewBoxWidth = 875;
|
|
296
318
|
} else if (delim === "\\{" || delim === "\\lbrace") {
|
|
297
319
|
top = "\u23a7";
|
|
298
320
|
middle = "\u23a8";
|
|
@@ -365,38 +387,59 @@ const makeStackedDelim = function(
|
|
|
365
387
|
// Calculate the depth
|
|
366
388
|
const depth = realHeightTotal / 2 - axisHeight;
|
|
367
389
|
|
|
368
|
-
|
|
369
390
|
// Now, we start building the pieces that will go into the vlist
|
|
370
391
|
// Keep a list of the pieces of the stacked delimiter
|
|
371
392
|
const stack = [];
|
|
372
393
|
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
const
|
|
381
|
-
|
|
382
|
-
|
|
394
|
+
if (svgLabel.length > 0) {
|
|
395
|
+
// Instead of stacking glyphs, create a single SVG.
|
|
396
|
+
// This evades browser problems with imprecise positioning of spans.
|
|
397
|
+
const midHeight = realHeightTotal - topHeightTotal - bottomHeightTotal;
|
|
398
|
+
const viewBoxHeight = Math.round(realHeightTotal * 1000);
|
|
399
|
+
const pathStr = tallDelim(svgLabel, Math.round(midHeight * 1000));
|
|
400
|
+
const path = new PathNode(svgLabel, pathStr);
|
|
401
|
+
const width = (viewBoxWidth / 1000).toFixed(3) + "em";
|
|
402
|
+
const height = (viewBoxHeight / 1000).toFixed(3) + "em";
|
|
403
|
+
const svg = new SvgNode([path], {
|
|
404
|
+
"width": width,
|
|
405
|
+
"height": height,
|
|
406
|
+
"viewBox": `0 0 ${viewBoxWidth} ${viewBoxHeight}`,
|
|
407
|
+
});
|
|
408
|
+
const wrapper = buildCommon.makeSvgSpan([], [svg], options);
|
|
409
|
+
wrapper.height = viewBoxHeight / 1000;
|
|
410
|
+
wrapper.style.width = width;
|
|
411
|
+
wrapper.style.height = height;
|
|
412
|
+
stack.push({type: "elem", elem: wrapper});
|
|
383
413
|
} else {
|
|
384
|
-
//
|
|
385
|
-
//
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
414
|
+
// Stack glyphs
|
|
415
|
+
// Start by adding the bottom symbol
|
|
416
|
+
stack.push(makeGlyphSpan(bottom, font, mode));
|
|
417
|
+
stack.push(lap); // overlap
|
|
418
|
+
|
|
419
|
+
if (middle === null) {
|
|
420
|
+
// The middle section will be an SVG. Make it an extra 0.016em tall.
|
|
421
|
+
// We'll overlap by 0.008em at top and bottom.
|
|
422
|
+
const innerHeight = realHeightTotal - topHeightTotal - bottomHeightTotal
|
|
423
|
+
+ 2 * lapInEms;
|
|
424
|
+
stack.push(makeInner(repeat, innerHeight, options));
|
|
425
|
+
} else {
|
|
426
|
+
// When there is a middle bit, we need the middle part and two repeated
|
|
427
|
+
// sections
|
|
428
|
+
const innerHeight = (realHeightTotal - topHeightTotal -
|
|
429
|
+
bottomHeightTotal - middleHeightTotal) / 2 + 2 * lapInEms;
|
|
430
|
+
stack.push(makeInner(repeat, innerHeight, options));
|
|
431
|
+
// Now insert the middle of the brace.
|
|
432
|
+
stack.push(lap);
|
|
433
|
+
stack.push(makeGlyphSpan(middle, font, mode));
|
|
434
|
+
stack.push(lap);
|
|
435
|
+
stack.push(makeInner(repeat, innerHeight, options));
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
// Add the top symbol
|
|
392
439
|
stack.push(lap);
|
|
393
|
-
stack.push(
|
|
440
|
+
stack.push(makeGlyphSpan(top, font, mode));
|
|
394
441
|
}
|
|
395
442
|
|
|
396
|
-
// Add the top symbol
|
|
397
|
-
stack.push(lap);
|
|
398
|
-
stack.push(makeGlyphSpan(top, font, mode));
|
|
399
|
-
|
|
400
443
|
// Finally, build the vlist
|
|
401
444
|
const newOptions = options.havingBaseStyle(Style.TEXT);
|
|
402
445
|
const inner = buildCommon.makeVList({
|
package/src/svgGeometry.js
CHANGED
|
@@ -487,3 +487,59 @@ c4.7,-4.7,7,-9.3,7,-14c0,-9.3,-3.7,-15.3,-11,-18c-92.7,-56.7,-159,-133.7,-199,
|
|
|
487
487
|
c-2,2.7,-1,9.7,3,21c15.3,42,36.7,81.8,64,119.5c27.3,37.7,58,69.2,92,94.5z
|
|
488
488
|
M500 241 v40 H399408 v-40z M500 435 v40 H400000 v-40z`,
|
|
489
489
|
};
|
|
490
|
+
|
|
491
|
+
export const tallDelim = function(label: string, midHeight: number): string {
|
|
492
|
+
switch (label) {
|
|
493
|
+
case "lbrack":
|
|
494
|
+
return `M403 1759 V84 H666 V0 H319 V1759 v${midHeight} v1759 h347 v-84
|
|
495
|
+
H403z M403 1759 V0 H319 V1759 v${midHeight} v1759 h84z`;
|
|
496
|
+
case "rbrack":
|
|
497
|
+
return `M347 1759 V0 H0 V84 H263 V1759 v${midHeight} v1759 H0 v84 H347z
|
|
498
|
+
M347 1759 V0 H263 V1759 v${midHeight} v1759 h84z`;
|
|
499
|
+
case "vert":
|
|
500
|
+
return `M145 15 v585 v${midHeight} v585 c2.667,10,9.667,15,21,15
|
|
501
|
+
c10,0,16.667,-5,20,-15 v-585 v${-midHeight} v-585 c-2.667,-10,-9.667,-15,-21,-15
|
|
502
|
+
c-10,0,-16.667,5,-20,15z M188 15 H145 v585 v${midHeight} v585 h43z`;
|
|
503
|
+
case "doublevert":
|
|
504
|
+
return `M145 15 v585 v${midHeight} v585 c2.667,10,9.667,15,21,15
|
|
505
|
+
c10,0,16.667,-5,20,-15 v-585 v${-midHeight} v-585 c-2.667,-10,-9.667,-15,-21,-15
|
|
506
|
+
c-10,0,-16.667,5,-20,15z M188 15 H145 v585 v${midHeight} v585 h43z
|
|
507
|
+
M367 15 v585 v${midHeight} v585 c2.667,10,9.667,15,21,15
|
|
508
|
+
c10,0,16.667,-5,20,-15 v-585 v${-midHeight} v-585 c-2.667,-10,-9.667,-15,-21,-15
|
|
509
|
+
c-10,0,-16.667,5,-20,15z M410 15 H367 v585 v${midHeight} v585 h43z`;
|
|
510
|
+
case "lfloor":
|
|
511
|
+
return `M319 602 V0 H403 V602 v${midHeight} v1715 h263 v84 H319z
|
|
512
|
+
MM319 602 V0 H403 V602 v${midHeight} v1715 H319z`;
|
|
513
|
+
case "rfloor":
|
|
514
|
+
return `M319 602 V0 H403 V602 v${midHeight} v1799 H0 v-84 H319z
|
|
515
|
+
MM319 602 V0 H403 V602 v${midHeight} v1715 H319z`;
|
|
516
|
+
case "lceil":
|
|
517
|
+
return `M403 1759 V84 H666 V0 H319 V1759 v${midHeight} v602 h84z
|
|
518
|
+
M403 1759 V0 H319 V1759 v${midHeight} v602 h84z`;
|
|
519
|
+
case "rceil":
|
|
520
|
+
return `M347 1759 V0 H0 V84 H263 V1759 v${midHeight} v602 h84z
|
|
521
|
+
M347 1759 V0 h-84 V1759 v${midHeight} v602 h84z`;
|
|
522
|
+
case "lparen":
|
|
523
|
+
return `M863,9c0,-2,-2,-5,-6,-9c0,0,-17,0,-17,0c-12.7,0,-19.3,0.3,-20,1
|
|
524
|
+
c-5.3,5.3,-10.3,11,-15,17c-242.7,294.7,-395.3,682,-458,1162c-21.3,163.3,-33.3,349,
|
|
525
|
+
-36,557 l0,${midHeight + 84}c0.2,6,0,26,0,60c2,159.3,10,310.7,24,454c53.3,528,210,
|
|
526
|
+
949.7,470,1265c4.7,6,9.7,11.7,15,17c0.7,0.7,7,1,19,1c0,0,18,0,18,0c4,-4,6,-7,6,-9
|
|
527
|
+
c0,-2.7,-3.3,-8.7,-10,-18c-135.3,-192.7,-235.5,-414.3,-300.5,-665c-65,-250.7,-102.5,
|
|
528
|
+
-544.7,-112.5,-882c-2,-104,-3,-167,-3,-189
|
|
529
|
+
l0,-${midHeight + 92}c0,-162.7,5.7,-314,17,-454c20.7,-272,63.7,-513,129,-723c65.3,
|
|
530
|
+
-210,155.3,-396.3,270,-559c6.7,-9.3,10,-15.3,10,-18z`;
|
|
531
|
+
case "rparen":
|
|
532
|
+
return `M76,0c-16.7,0,-25,3,-25,9c0,2,2,6.3,6,13c21.3,28.7,42.3,60.3,
|
|
533
|
+
63,95c96.7,156.7,172.8,332.5,228.5,527.5c55.7,195,92.8,416.5,111.5,664.5
|
|
534
|
+
c11.3,139.3,17,290.7,17,454c0,28,1.7,43,3.3,45l0,${midHeight + 9}
|
|
535
|
+
c-3,4,-3.3,16.7,-3.3,38c0,162,-5.7,313.7,-17,455c-18.7,248,-55.8,469.3,-111.5,664
|
|
536
|
+
c-55.7,194.7,-131.8,370.3,-228.5,527c-20.7,34.7,-41.7,66.3,-63,95c-2,3.3,-4,7,-6,11
|
|
537
|
+
c0,7.3,5.7,11,17,11c0,0,11,0,11,0c9.3,0,14.3,-0.3,15,-1c5.3,-5.3,10.3,-11,15,-17
|
|
538
|
+
c242.7,-294.7,395.3,-681.7,458,-1161c21.3,-164.7,33.3,-350.7,36,-558
|
|
539
|
+
l0,-${midHeight + 144}c-2,-159.3,-10,-310.7,-24,-454c-53.3,-528,-210,-949.7,
|
|
540
|
+
-470,-1265c-4.7,-6,-9.7,-11.7,-15,-17c-0.7,-0.7,-6.7,-1,-18,-1z`;
|
|
541
|
+
default:
|
|
542
|
+
// We should not ever get here.
|
|
543
|
+
throw new Error("Unknown stretchy delimiter.");
|
|
544
|
+
}
|
|
545
|
+
};
|