temml 0.11.7 → 0.11.9
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 +1 -1
- package/contrib/mhchem/mhchem.js +2 -2
- package/contrib/mhchem/mhchem.min.js +1 -1
- package/dist/Temml-Asana.css +75 -16
- package/dist/Temml-Latin-Modern.css +77 -14
- package/dist/Temml-Libertinus.css +77 -13
- package/dist/Temml-Local.css +79 -11
- package/dist/Temml-NotoSans.css +78 -8
- package/dist/Temml-STIX2.css +77 -13
- package/dist/temml.cjs +194 -71
- package/dist/temml.js +192 -69
- package/dist/temml.min.js +1 -1
- package/dist/temml.mjs +194 -71
- package/dist/temmlPostProcess.js +1 -1
- package/package.json +1 -1
- package/src/environments/borderTree.js +1 -1
- package/src/functions/accent.js +55 -36
- package/src/functions/arrow.js +8 -14
- package/src/functions/delimsizing.js +14 -2
- package/src/functions/enclose.js +2 -1
- package/src/functions/mclass.js +17 -3
- package/src/functions/sfrac.js +68 -0
- package/src/functions/supsub.js +20 -8
- package/src/functions.js +1 -0
- package/src/postProcess.js +1 -1
- package/src/stretchy.js +6 -1
- package/src/symbols.js +3 -3
package/dist/temml.cjs
CHANGED
@@ -836,6 +836,9 @@ const stretchyCodePoint = {
|
|
836
836
|
xtwoheadrightarrow: "\u21a0",
|
837
837
|
xlongequal: "=",
|
838
838
|
xrightleftarrows: "\u21c4",
|
839
|
+
xtofrom: "\u21c4",
|
840
|
+
xleftrightharpoons: "\u21cb",
|
841
|
+
xrightleftharpoons: "\u21cc",
|
839
842
|
yields: "\u2192",
|
840
843
|
yieldsLeft: "\u2190",
|
841
844
|
mesomerism: "\u2194",
|
@@ -845,7 +848,9 @@ const stretchyCodePoint = {
|
|
845
848
|
eqleftharpoondown: "\u21bd",
|
846
849
|
"\\cdrightarrow": "\u2192",
|
847
850
|
"\\cdleftarrow": "\u2190",
|
848
|
-
"\\cdlongequal": "="
|
851
|
+
"\\cdlongequal": "=",
|
852
|
+
yieldsLeftRight: "\u21c4",
|
853
|
+
chemequilibrium: "\u21cc"
|
849
854
|
};
|
850
855
|
|
851
856
|
const mathMLnode = function(label) {
|
@@ -1773,7 +1778,7 @@ defineSymbol(math, inner, "\u22ef", "\\@cdots", true);
|
|
1773
1778
|
defineSymbol(math, inner, "\u22f1", "\\ddots", true);
|
1774
1779
|
defineSymbol(math, textord, "\u22ee", "\\varvdots"); // \vdots is a macro
|
1775
1780
|
defineSymbol(text, textord, "\u22ee", "\\varvdots");
|
1776
|
-
defineSymbol(math, accent, "\
|
1781
|
+
defineSymbol(math, accent, "\u00b4", "\\acute");
|
1777
1782
|
defineSymbol(math, accent, "\u0060", "\\grave");
|
1778
1783
|
defineSymbol(math, accent, "\u00a8", "\\ddot");
|
1779
1784
|
defineSymbol(math, accent, "\u2026", "\\dddot");
|
@@ -1799,7 +1804,7 @@ defineSymbol(math, mathord, "\u00d8", "\\O", true);
|
|
1799
1804
|
defineSymbol(text, accent, "\u02ca", "\\'"); // acute
|
1800
1805
|
defineSymbol(text, accent, "\u02cb", "\\`"); // grave
|
1801
1806
|
defineSymbol(text, accent, "\u02c6", "\\^"); // circumflex
|
1802
|
-
defineSymbol(text, accent, "\
|
1807
|
+
defineSymbol(text, accent, "\u007e", "\\~"); // tilde
|
1803
1808
|
defineSymbol(text, accent, "\u02c9", "\\="); // macron
|
1804
1809
|
defineSymbol(text, accent, "\u02d8", "\\u"); // breve
|
1805
1810
|
defineSymbol(text, accent, "\u02d9", "\\."); // dot above
|
@@ -1811,7 +1816,7 @@ defineSymbol(text, accent, "\u02dd", "\\H"); // double acute
|
|
1811
1816
|
defineSymbol(math, accent, "\u02ca", "\\'"); // acute
|
1812
1817
|
defineSymbol(math, accent, "\u02cb", "\\`"); // grave
|
1813
1818
|
defineSymbol(math, accent, "\u02c6", "\\^"); // circumflex
|
1814
|
-
defineSymbol(math, accent, "\
|
1819
|
+
defineSymbol(math, accent, "\u007e", "\\~"); // tilde
|
1815
1820
|
defineSymbol(math, accent, "\u02c9", "\\="); // macron
|
1816
1821
|
defineSymbol(math, accent, "\u02d8", "\\u"); // breve
|
1817
1822
|
defineSymbol(math, accent, "\u02d9", "\\."); // dot above
|
@@ -2468,46 +2473,61 @@ function buildMathML(tree, texExpression, style, settings) {
|
|
2468
2473
|
return math;
|
2469
2474
|
}
|
2470
2475
|
|
2476
|
+
// Identify letters to which we'll attach a combining accent character
|
2471
2477
|
const smalls = "acegıȷmnopqrsuvwxyzαγεηικμνοπρςστυχωϕ𝐚𝐜𝐞𝐠𝐦𝐧𝐨𝐩𝐪𝐫𝐬𝐮𝐯𝐰𝐱𝐲𝐳";
|
2472
|
-
|
2473
|
-
|
2474
|
-
const
|
2475
|
-
|
2476
|
-
|
2477
|
-
const longTalls = new Set(["\\Gamma", "\\Delta", "\\Sigma", "\\Omega", "\\beta", "\\delta",
|
2478
|
-
"\\lambda", "\\theta", "\\psi"]);
|
2478
|
+
|
2479
|
+
// From the KaTeX font metrics, identify letters whose accents need a italic correction.
|
2480
|
+
const smallNudge = "DHKLUcegorsuvxyzΠΥΨαδηιμνοτυχϵ";
|
2481
|
+
const mediumNudge = "BCEGIMNOPQRSTXZlpqtwΓΘΞΣΦΩβεζθξρςφψϑϕϱ";
|
2482
|
+
const largeNudge = "AFJdfΔΛ";
|
2479
2483
|
|
2480
2484
|
const mathmlBuilder$a = (group, style) => {
|
2481
2485
|
const accentNode = group.isStretchy
|
2482
2486
|
? stretchy.accentNode(group)
|
2483
2487
|
: new mathMLTree.MathNode("mo", [makeText(group.label, group.mode)]);
|
2484
|
-
|
2485
|
-
if (group.label === "\\vec") {
|
2486
|
-
accentNode.style.transform = "scale(0.75) translate(10%, 30%)";
|
2487
|
-
} else {
|
2488
|
-
accentNode.style.mathStyle = "normal";
|
2489
|
-
accentNode.style.mathDepth = "0";
|
2490
|
-
if (needWebkitShift.has(group.label) && utils.isCharacterBox(group.base)) {
|
2491
|
-
let shift = "";
|
2492
|
-
const ch = group.base.text;
|
2493
|
-
if (smalls.indexOf(ch) > -1 || longSmalls.has(ch)) { shift = "tml-xshift"; }
|
2494
|
-
if (talls.indexOf(ch) > -1 || longTalls.has(ch)) { shift = "tml-capshift"; }
|
2495
|
-
if (shift) { accentNode.classes.push(shift); }
|
2496
|
-
}
|
2497
|
-
}
|
2498
2488
|
if (!group.isStretchy) {
|
2499
|
-
accentNode.setAttribute("stretchy", "false");
|
2500
|
-
}
|
2501
|
-
|
2502
|
-
|
2503
|
-
|
2504
|
-
|
2505
|
-
|
2489
|
+
accentNode.setAttribute("stretchy", "false"); // Keep Firefox from stretching \check
|
2490
|
+
}
|
2491
|
+
if (group.label !== "\\vec") {
|
2492
|
+
accentNode.style.mathDepth = "0"; // not scriptstyle
|
2493
|
+
// Don't use attribute accent="true" because MathML Core eliminates a needed space.
|
2494
|
+
}
|
2495
|
+
const tag = group.label === "\\c" ? "munder" : "mover";
|
2496
|
+
const needsWbkVertShift = needsWebkitVerticalShift.has(group.label);
|
2497
|
+
if (tag === "mover" && group.mode === "math" && (!group.isStretchy) && group.base.text
|
2498
|
+
&& group.base.text.length === 1) {
|
2499
|
+
const text = group.base.text;
|
2500
|
+
const isVec = group.label === "\\vec";
|
2501
|
+
const vecPostfix = isVec === "\\vec" ? "-vec" : "";
|
2502
|
+
if (isVec) {
|
2503
|
+
accentNode.classes.push("tml-vec"); // Firefox sizing of \vec arrow
|
2504
|
+
}
|
2505
|
+
const wbkPostfix = isVec ? "-vec" : needsWbkVertShift ? "-acc" : "";
|
2506
|
+
if (smallNudge.indexOf(text) > -1) {
|
2507
|
+
accentNode.classes.push(`chr-sml${vecPostfix}`);
|
2508
|
+
accentNode.classes.push(`wbk-sml${wbkPostfix}`);
|
2509
|
+
} else if (mediumNudge.indexOf(text) > -1) {
|
2510
|
+
accentNode.classes.push(`chr-med${vecPostfix}`);
|
2511
|
+
accentNode.classes.push(`wbk-med${wbkPostfix}`);
|
2512
|
+
} else if (largeNudge.indexOf(text) > -1) {
|
2513
|
+
accentNode.classes.push(`chr-lrg${vecPostfix}`);
|
2514
|
+
accentNode.classes.push(`wbk-lrg${wbkPostfix}`);
|
2515
|
+
} else if (isVec) {
|
2516
|
+
accentNode.classes.push(`wbk-vec`);
|
2517
|
+
} else if (needsWbkVertShift) {
|
2518
|
+
accentNode.classes.push(`wbk-acc`);
|
2519
|
+
}
|
2520
|
+
} else if (needsWbkVertShift) {
|
2521
|
+
// text-mode accents
|
2522
|
+
accentNode.classes.push("wbk-acc");
|
2523
|
+
}
|
2524
|
+
const node = new mathMLTree.MathNode(tag, [buildGroup$1(group.base, style), accentNode]);
|
2506
2525
|
return node;
|
2507
2526
|
};
|
2508
2527
|
|
2509
2528
|
const nonStretchyAccents = new Set([
|
2510
2529
|
"\\acute",
|
2530
|
+
"\\check",
|
2511
2531
|
"\\grave",
|
2512
2532
|
"\\ddot",
|
2513
2533
|
"\\dddot",
|
@@ -2522,7 +2542,7 @@ const nonStretchyAccents = new Set([
|
|
2522
2542
|
"\\mathring"
|
2523
2543
|
]);
|
2524
2544
|
|
2525
|
-
const
|
2545
|
+
const needsWebkitVerticalShift = new Set([
|
2526
2546
|
"\\acute",
|
2527
2547
|
"\\bar",
|
2528
2548
|
"\\breve",
|
@@ -2532,7 +2552,7 @@ const needWebkitShift = new Set([
|
|
2532
2552
|
"\\grave",
|
2533
2553
|
"\\hat",
|
2534
2554
|
"\\mathring",
|
2535
|
-
"
|
2555
|
+
"\\`", "\\'", "\\^", "\\=", "\\u", "\\.", '\\"', "\\r", "\\H", "\\v"
|
2536
2556
|
]);
|
2537
2557
|
|
2538
2558
|
const combiningChar = {
|
@@ -2546,7 +2566,8 @@ const combiningChar = {
|
|
2546
2566
|
'\\"': "\u0308",
|
2547
2567
|
"\\r": "\u030A",
|
2548
2568
|
"\\H": "\u030B",
|
2549
|
-
"\\v": "\u030C"
|
2569
|
+
"\\v": "\u030C",
|
2570
|
+
"\\c": "\u0327"
|
2550
2571
|
};
|
2551
2572
|
|
2552
2573
|
// Accents
|
@@ -2591,8 +2612,8 @@ defineFunction({
|
|
2591
2612
|
type: "accent",
|
2592
2613
|
mode: context.parser.mode,
|
2593
2614
|
label: context.funcName,
|
2594
|
-
isStretchy
|
2595
|
-
base
|
2615
|
+
isStretchy,
|
2616
|
+
base
|
2596
2617
|
};
|
2597
2618
|
},
|
2598
2619
|
mathmlBuilder: mathmlBuilder$a
|
@@ -2619,21 +2640,25 @@ defineFunction({
|
|
2619
2640
|
}
|
2620
2641
|
|
2621
2642
|
if (mode === "text" && base.text && base.text.length === 1
|
2622
|
-
&& context.funcName in combiningChar
|
2643
|
+
&& context.funcName in combiningChar && smalls.indexOf(base.text) > -1) {
|
2623
2644
|
// Return a combining accent character
|
2624
2645
|
return {
|
2625
2646
|
type: "textord",
|
2626
2647
|
mode: "text",
|
2627
2648
|
text: base.text + combiningChar[context.funcName]
|
2628
2649
|
}
|
2650
|
+
} else if (context.funcName === "\\c" && mode === "text" && base.text
|
2651
|
+
&& base.text.length === 1) {
|
2652
|
+
// combining cedilla
|
2653
|
+
return { type: "textord", mode: "text", text: base.text + "\u0327" }
|
2629
2654
|
} else {
|
2630
2655
|
// Build up the accent
|
2631
2656
|
return {
|
2632
2657
|
type: "accent",
|
2633
|
-
mode
|
2658
|
+
mode,
|
2634
2659
|
label: context.funcName,
|
2635
2660
|
isStretchy: false,
|
2636
|
-
base
|
2661
|
+
base
|
2637
2662
|
}
|
2638
2663
|
}
|
2639
2664
|
},
|
@@ -2891,12 +2916,17 @@ defineFunction({
|
|
2891
2916
|
"\\xlongequal",
|
2892
2917
|
"\\xtwoheadrightarrow",
|
2893
2918
|
"\\xtwoheadleftarrow",
|
2894
|
-
//
|
2919
|
+
"\\xtofrom", // expfeil
|
2920
|
+
"\\xleftrightharpoons", // mathtools
|
2921
|
+
"\\xrightleftharpoons", // mathtools
|
2922
|
+
// The next 7 functions are here only to support mhchem
|
2895
2923
|
"\\yields",
|
2896
2924
|
"\\yieldsLeft",
|
2897
2925
|
"\\mesomerism",
|
2898
2926
|
"\\longrightharpoonup",
|
2899
2927
|
"\\longleftharpoondown",
|
2928
|
+
"\\yieldsLeftRight",
|
2929
|
+
"\\chemequilibrium",
|
2900
2930
|
// The next 3 functions are here only to support the {CD} environment.
|
2901
2931
|
"\\\\cdrightarrow",
|
2902
2932
|
"\\\\cdleftarrow",
|
@@ -2927,26 +2957,15 @@ defineFunction({
|
|
2927
2957
|
});
|
2928
2958
|
|
2929
2959
|
const arrowComponent = {
|
2930
|
-
"\\xtofrom": ["\\xrightarrow", "\\xleftarrow"],
|
2931
|
-
"\\xleftrightharpoons": ["\\xleftharpoonup", "\\xrightharpoondown"],
|
2932
|
-
"\\xrightleftharpoons": ["\\xrightharpoonup", "\\xleftharpoondown"],
|
2933
|
-
"\\yieldsLeftRight": ["\\yields", "\\yieldsLeft"],
|
2934
|
-
// The next three all get the same harpoon glyphs. Only the lengths and paddings differ.
|
2935
|
-
"\\equilibrium": ["\\longrightharpoonup", "\\longleftharpoondown"],
|
2936
2960
|
"\\equilibriumRight": ["\\longrightharpoonup", "\\eqleftharpoondown"],
|
2937
2961
|
"\\equilibriumLeft": ["\\eqrightharpoonup", "\\longleftharpoondown"]
|
2938
2962
|
};
|
2939
2963
|
|
2940
|
-
//
|
2941
|
-
// So we stack a pair of single
|
2964
|
+
// Math fonts do not have a single glyph for these two mhchem functions.
|
2965
|
+
// So we stack a pair of single harpoons.
|
2942
2966
|
defineFunction({
|
2943
2967
|
type: "stackedArrow",
|
2944
2968
|
names: [
|
2945
|
-
"\\xtofrom", // expfeil
|
2946
|
-
"\\xleftrightharpoons", // mathtools
|
2947
|
-
"\\xrightleftharpoons", // mathtools
|
2948
|
-
"\\yieldsLeftRight", // mhchem
|
2949
|
-
"\\equilibrium", // mhchem
|
2950
2969
|
"\\equilibriumRight",
|
2951
2970
|
"\\equilibriumLeft"
|
2952
2971
|
],
|
@@ -3453,7 +3472,6 @@ const bordermatrixParseTree = (matrix, delimiters) => {
|
|
3453
3472
|
alwaysHandleSupSub: true,
|
3454
3473
|
parentIsSupSub: true,
|
3455
3474
|
symbol: false,
|
3456
|
-
stack: true,
|
3457
3475
|
suppressBaseShift: true,
|
3458
3476
|
body: [container]
|
3459
3477
|
};
|
@@ -3461,6 +3479,7 @@ const bordermatrixParseTree = (matrix, delimiters) => {
|
|
3461
3479
|
const mover = {
|
3462
3480
|
type: "supsub", // We're using the MathML equivalent
|
3463
3481
|
mode: "math", // of TeX \overset.
|
3482
|
+
stack: true,
|
3464
3483
|
base: base, // That keeps the {pmatrix} aligned with
|
3465
3484
|
sup: topWrapper, // the math centerline.
|
3466
3485
|
sub: null
|
@@ -5924,8 +5943,8 @@ defineMacro("\\tripleDashBetweenDoubleLine", `\\kern0.075em\\mathrlap{\\mathrlap
|
|
5924
5943
|
case "<-": return "\\yieldsLeft";
|
5925
5944
|
case "<->": return "\\mesomerism";
|
5926
5945
|
case "<-->": return "\\yieldsLeftRight";
|
5927
|
-
case "<=>": return "\\
|
5928
|
-
case "\u21CC": return "\\
|
5946
|
+
case "<=>": return "\\chemequilibrium";
|
5947
|
+
case "\u21CC": return "\\chemequilibrium";
|
5929
5948
|
case "<=>>": return "\\equilibriumRight";
|
5930
5949
|
case "<<=>": return "\\equilibriumLeft";
|
5931
5950
|
default:
|
@@ -7946,13 +7965,25 @@ defineFunction({
|
|
7946
7965
|
handler: (context, args) => {
|
7947
7966
|
const delim = checkDelimiter(args[0], context);
|
7948
7967
|
|
7949
|
-
|
7968
|
+
const delimNode = {
|
7950
7969
|
type: "delimsizing",
|
7951
7970
|
mode: context.parser.mode,
|
7952
7971
|
size: delimiterSizes[context.funcName].size,
|
7953
7972
|
mclass: delimiterSizes[context.funcName].mclass,
|
7954
7973
|
delim: delim.text
|
7955
7974
|
};
|
7975
|
+
const nextToken = context.parser.fetch().text;
|
7976
|
+
if (nextToken !== "^" && nextToken !== "_") {
|
7977
|
+
return delimNode
|
7978
|
+
} else {
|
7979
|
+
// Chromium mis-renders a sized delim if it is the base of a supsub.
|
7980
|
+
// So wrap it in a ordgroup.
|
7981
|
+
return {
|
7982
|
+
type: "ordgroup",
|
7983
|
+
mode: "math",
|
7984
|
+
body: [delimNode, { type: "ordgroup", mode: "math", body: [] }]
|
7985
|
+
}
|
7986
|
+
}
|
7956
7987
|
},
|
7957
7988
|
mathmlBuilder: (group) => {
|
7958
7989
|
const children = [];
|
@@ -8188,7 +8219,8 @@ const mathmlBuilder$7 = (group, style) => {
|
|
8188
8219
|
case "\\boxed":
|
8189
8220
|
// \newcommand{\boxed}[1]{\fbox{\m@th$\displaystyle#1$}} from amsmath.sty
|
8190
8221
|
node.setAttribute("notation", "box");
|
8191
|
-
node.
|
8222
|
+
node.style.padding = "padding: 3pt 0 3pt 0";
|
8223
|
+
node.style.border = "1px solid";
|
8192
8224
|
node.setAttribute("scriptlevel", "0");
|
8193
8225
|
node.setAttribute("displaystyle", "true");
|
8194
8226
|
break
|
@@ -9601,7 +9633,9 @@ const binrelClass = (arg) => {
|
|
9601
9633
|
// (by rendering separately and with {}s before and after, and measuring
|
9602
9634
|
// the change in spacing). We'll do roughly the same by detecting the
|
9603
9635
|
// atom type directly.
|
9604
|
-
const atom = arg.type === "ordgroup" && arg.body.length
|
9636
|
+
const atom = arg.type === "ordgroup" && arg.body.length && arg.body.length === 1
|
9637
|
+
? arg.body[0]
|
9638
|
+
: arg;
|
9605
9639
|
if (atom.type === "atom" && (atom.family === "bin" || atom.family === "rel")) {
|
9606
9640
|
return "m" + atom.family;
|
9607
9641
|
} else {
|
@@ -9639,14 +9673,25 @@ defineFunction({
|
|
9639
9673
|
const baseArg = args[1];
|
9640
9674
|
const shiftedArg = args[0];
|
9641
9675
|
|
9676
|
+
let mclass;
|
9677
|
+
if (funcName !== "\\stackrel") {
|
9678
|
+
// LaTeX applies \binrel spacing to \overset and \underset.
|
9679
|
+
mclass = binrelClass(baseArg);
|
9680
|
+
} else {
|
9681
|
+
mclass = "mrel"; // for \stackrel
|
9682
|
+
}
|
9683
|
+
|
9684
|
+
const baseType = mclass === "mrel" || mclass === "mbin"
|
9685
|
+
? "op"
|
9686
|
+
: "ordgroup";
|
9687
|
+
|
9642
9688
|
const baseOp = {
|
9643
|
-
type:
|
9689
|
+
type: baseType,
|
9644
9690
|
mode: baseArg.mode,
|
9645
9691
|
limits: true,
|
9646
9692
|
alwaysHandleSupSub: true,
|
9647
9693
|
parentIsSupSub: false,
|
9648
9694
|
symbol: false,
|
9649
|
-
stack: true,
|
9650
9695
|
suppressBaseShift: funcName !== "\\stackrel",
|
9651
9696
|
body: ordargument(baseArg)
|
9652
9697
|
};
|
@@ -9654,6 +9699,7 @@ defineFunction({
|
|
9654
9699
|
return {
|
9655
9700
|
type: "supsub",
|
9656
9701
|
mode: shiftedArg.mode,
|
9702
|
+
stack: true,
|
9657
9703
|
base: baseOp,
|
9658
9704
|
sup: funcName === "\\underset" ? null : shiftedArg,
|
9659
9705
|
sub: funcName === "\\underset" ? shiftedArg : null
|
@@ -10555,6 +10601,71 @@ defineFunction({
|
|
10555
10601
|
}
|
10556
10602
|
});
|
10557
10603
|
|
10604
|
+
const numRegEx = /^[0-9]$/;
|
10605
|
+
const unicodeNumSubs = {
|
10606
|
+
'0': '₀',
|
10607
|
+
'1': '₁',
|
10608
|
+
'2': '₂',
|
10609
|
+
'3': '₃',
|
10610
|
+
'4': '₄',
|
10611
|
+
'5': '₅',
|
10612
|
+
'6': '₆',
|
10613
|
+
'7': '₇',
|
10614
|
+
'8': '₈',
|
10615
|
+
'9': '₉'
|
10616
|
+
};
|
10617
|
+
const unicodeNumSups = {
|
10618
|
+
'0': '⁰',
|
10619
|
+
'1': '¹',
|
10620
|
+
'2': '²',
|
10621
|
+
'3': '³',
|
10622
|
+
'4': '⁴',
|
10623
|
+
'5': '⁵',
|
10624
|
+
'6': '⁶',
|
10625
|
+
'7': '⁷',
|
10626
|
+
'8': '⁸',
|
10627
|
+
'9': '⁹'
|
10628
|
+
};
|
10629
|
+
|
10630
|
+
defineFunction({
|
10631
|
+
type: "sfrac",
|
10632
|
+
names: ["\\sfrac"],
|
10633
|
+
props: {
|
10634
|
+
numArgs: 2,
|
10635
|
+
allowedInText: true,
|
10636
|
+
allowedInMath: true
|
10637
|
+
},
|
10638
|
+
handler({ parser }, args) {
|
10639
|
+
let numerator = "";
|
10640
|
+
for (const node of args[0].body) {
|
10641
|
+
if (node.type !== "textord" || !numRegEx.test(node.text)) {
|
10642
|
+
throw new ParseError("Numerator must be an integer.", node)
|
10643
|
+
}
|
10644
|
+
numerator += node.text;
|
10645
|
+
}
|
10646
|
+
let denominator = "";
|
10647
|
+
for (const node of args[1].body) {
|
10648
|
+
if (node.type !== "textord" || !numRegEx.test(node.text)) {
|
10649
|
+
throw new ParseError("Denominator must be an integer.", node)
|
10650
|
+
}
|
10651
|
+
denominator += node.text;
|
10652
|
+
}
|
10653
|
+
return {
|
10654
|
+
type: "sfrac",
|
10655
|
+
mode: parser.mode,
|
10656
|
+
numerator,
|
10657
|
+
denominator
|
10658
|
+
};
|
10659
|
+
},
|
10660
|
+
mathmlBuilder(group, style) {
|
10661
|
+
const numerator = group.numerator.split('').map(c => unicodeNumSups[c]).join('');
|
10662
|
+
const denominator = group.denominator.split('').map(c => unicodeNumSubs[c]).join('');
|
10663
|
+
// Use a fraction slash.
|
10664
|
+
const text = new mathMLTree.TextNode(numerator + "\u2044" + denominator, group.mode, style);
|
10665
|
+
return new mathMLTree.MathNode("mn", [text], ["special-fraction"])
|
10666
|
+
}
|
10667
|
+
});
|
10668
|
+
|
10558
10669
|
// The size mappings are taken from TeX with \normalsize=10pt.
|
10559
10670
|
// We don't have to track script level. MathML does that.
|
10560
10671
|
const sizeMap = {
|
@@ -10772,6 +10883,11 @@ defineFunction({
|
|
10772
10883
|
// Helpers
|
10773
10884
|
const symbolRegEx = /^m(over|under|underover)$/;
|
10774
10885
|
|
10886
|
+
// From the KaTeX font metrics, identify letters that encroach on a superscript.
|
10887
|
+
const smallPad = "DHKLUcegorsuvxyzΠΥΨαδηιμνοτυχϵ";
|
10888
|
+
const mediumPad = "BCEFGIMNOPQRSTXZlpqtwΓΘΞΣΦΩβεζθξρςφψϑϕϱ";
|
10889
|
+
const largePad = "AJdfΔΛ";
|
10890
|
+
|
10775
10891
|
// Super scripts and subscripts, whose precise placement can depend on other
|
10776
10892
|
// functions that precede them.
|
10777
10893
|
defineFunctionBuilders({
|
@@ -10793,7 +10909,7 @@ defineFunctionBuilders({
|
|
10793
10909
|
}
|
10794
10910
|
}
|
10795
10911
|
|
10796
|
-
if (group.base && !group.
|
10912
|
+
if (group.base && !group.stack &&
|
10797
10913
|
(group.base.type === "op" || group.base.type === "operatorname")) {
|
10798
10914
|
group.base.parentIsSupSub = true;
|
10799
10915
|
appendApplyFunction = !group.base.symbol;
|
@@ -10801,7 +10917,7 @@ defineFunctionBuilders({
|
|
10801
10917
|
needsLeadingSpace = group.base.needsLeadingSpace;
|
10802
10918
|
}
|
10803
10919
|
|
10804
|
-
const children = group.
|
10920
|
+
const children = group.stack && group.base.body.length === 1
|
10805
10921
|
? [buildGroup$1(group.base.body[0], style)]
|
10806
10922
|
: [buildGroup$1(group.base, style)];
|
10807
10923
|
|
@@ -10821,11 +10937,16 @@ defineFunctionBuilders({
|
|
10821
10937
|
if (group.sup) {
|
10822
10938
|
const sup = buildGroup$1(group.sup, childStyle);
|
10823
10939
|
if (style.level === 3) { sup.setAttribute("scriptlevel", "2"); }
|
10824
|
-
|
10825
|
-
|
10826
|
-
|
10827
|
-
|
10828
|
-
|
10940
|
+
if (group.base && group.base.text && group.base.text.length === 1) {
|
10941
|
+
// Make an italic correction on the superscript.
|
10942
|
+
const text = group.base.text;
|
10943
|
+
if (smallPad.indexOf(text) > -1) {
|
10944
|
+
sup.classes.push("tml-sml-pad");
|
10945
|
+
} else if (mediumPad.indexOf(text) > -1) {
|
10946
|
+
sup.classes.push("tml-med-pad");
|
10947
|
+
} else if (largePad.indexOf(text) > -1) {
|
10948
|
+
sup.classes.push("tml-lrg-pad");
|
10949
|
+
}
|
10829
10950
|
}
|
10830
10951
|
children.push(sup);
|
10831
10952
|
}
|
@@ -10854,7 +10975,9 @@ defineFunctionBuilders({
|
|
10854
10975
|
}
|
10855
10976
|
} else if (!group.sup) {
|
10856
10977
|
const base = group.base;
|
10857
|
-
if (
|
10978
|
+
if (group.stack) {
|
10979
|
+
nodeType = "munder";
|
10980
|
+
} else if (
|
10858
10981
|
base &&
|
10859
10982
|
base.type === "op" &&
|
10860
10983
|
base.limits &&
|
@@ -13899,7 +14022,7 @@ class Style {
|
|
13899
14022
|
* https://mit-license.org/
|
13900
14023
|
*/
|
13901
14024
|
|
13902
|
-
const version = "0.11.
|
14025
|
+
const version = "0.11.09";
|
13903
14026
|
|
13904
14027
|
function postProcess(block) {
|
13905
14028
|
const labelMap = {};
|