temml 0.11.6 → 0.11.8
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 +193 -157
- package/dist/temml.js +191 -155
- package/dist/temml.min.js +1 -1
- package/dist/temml.mjs +193 -157
- 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/enclose.js +2 -1
- package/src/functions/kern.js +12 -5
- 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 -1
- package/src/postProcess.js +1 -1
- package/src/stretchy.js +6 -1
- package/src/symbols.js +3 -3
- package/src/functions/href.js +0 -88
package/dist/temml.js
CHANGED
@@ -837,6 +837,9 @@ var temml = (function () {
|
|
837
837
|
xtwoheadrightarrow: "\u21a0",
|
838
838
|
xlongequal: "=",
|
839
839
|
xrightleftarrows: "\u21c4",
|
840
|
+
xtofrom: "\u21c4",
|
841
|
+
xleftrightharpoons: "\u21cb",
|
842
|
+
xrightleftharpoons: "\u21cc",
|
840
843
|
yields: "\u2192",
|
841
844
|
yieldsLeft: "\u2190",
|
842
845
|
mesomerism: "\u2194",
|
@@ -846,7 +849,9 @@ var temml = (function () {
|
|
846
849
|
eqleftharpoondown: "\u21bd",
|
847
850
|
"\\cdrightarrow": "\u2192",
|
848
851
|
"\\cdleftarrow": "\u2190",
|
849
|
-
"\\cdlongequal": "="
|
852
|
+
"\\cdlongequal": "=",
|
853
|
+
yieldsLeftRight: "\u21c4",
|
854
|
+
chemequilibrium: "\u21cc"
|
850
855
|
};
|
851
856
|
|
852
857
|
const mathMLnode = function(label) {
|
@@ -1774,7 +1779,7 @@ var temml = (function () {
|
|
1774
1779
|
defineSymbol(math, inner, "\u22f1", "\\ddots", true);
|
1775
1780
|
defineSymbol(math, textord, "\u22ee", "\\varvdots"); // \vdots is a macro
|
1776
1781
|
defineSymbol(text, textord, "\u22ee", "\\varvdots");
|
1777
|
-
defineSymbol(math, accent, "\
|
1782
|
+
defineSymbol(math, accent, "\u00b4", "\\acute");
|
1778
1783
|
defineSymbol(math, accent, "\u0060", "\\grave");
|
1779
1784
|
defineSymbol(math, accent, "\u00a8", "\\ddot");
|
1780
1785
|
defineSymbol(math, accent, "\u2026", "\\dddot");
|
@@ -1800,7 +1805,7 @@ var temml = (function () {
|
|
1800
1805
|
defineSymbol(text, accent, "\u02ca", "\\'"); // acute
|
1801
1806
|
defineSymbol(text, accent, "\u02cb", "\\`"); // grave
|
1802
1807
|
defineSymbol(text, accent, "\u02c6", "\\^"); // circumflex
|
1803
|
-
defineSymbol(text, accent, "\
|
1808
|
+
defineSymbol(text, accent, "\u007e", "\\~"); // tilde
|
1804
1809
|
defineSymbol(text, accent, "\u02c9", "\\="); // macron
|
1805
1810
|
defineSymbol(text, accent, "\u02d8", "\\u"); // breve
|
1806
1811
|
defineSymbol(text, accent, "\u02d9", "\\."); // dot above
|
@@ -1812,7 +1817,7 @@ var temml = (function () {
|
|
1812
1817
|
defineSymbol(math, accent, "\u02ca", "\\'"); // acute
|
1813
1818
|
defineSymbol(math, accent, "\u02cb", "\\`"); // grave
|
1814
1819
|
defineSymbol(math, accent, "\u02c6", "\\^"); // circumflex
|
1815
|
-
defineSymbol(math, accent, "\
|
1820
|
+
defineSymbol(math, accent, "\u007e", "\\~"); // tilde
|
1816
1821
|
defineSymbol(math, accent, "\u02c9", "\\="); // macron
|
1817
1822
|
defineSymbol(math, accent, "\u02d8", "\\u"); // breve
|
1818
1823
|
defineSymbol(math, accent, "\u02d9", "\\."); // dot above
|
@@ -2469,46 +2474,61 @@ var temml = (function () {
|
|
2469
2474
|
return math;
|
2470
2475
|
}
|
2471
2476
|
|
2477
|
+
// Identify letters to which we'll attach a combining accent character
|
2472
2478
|
const smalls = "acegıȷmnopqrsuvwxyzαγεηικμνοπρςστυχωϕ𝐚𝐜𝐞𝐠𝐦𝐧𝐨𝐩𝐪𝐫𝐬𝐮𝐯𝐰𝐱𝐲𝐳";
|
2473
|
-
|
2474
|
-
|
2475
|
-
const
|
2476
|
-
|
2477
|
-
|
2478
|
-
const longTalls = new Set(["\\Gamma", "\\Delta", "\\Sigma", "\\Omega", "\\beta", "\\delta",
|
2479
|
-
"\\lambda", "\\theta", "\\psi"]);
|
2479
|
+
|
2480
|
+
// From the KaTeX font metrics, identify letters whose accents need a italic correction.
|
2481
|
+
const smallNudge = "DHKLUcegorsuvxyzΠΥΨαδηιμνοτυχϵ";
|
2482
|
+
const mediumNudge = "BCEGIMNOPQRSTXZlpqtwΓΘΞΣΦΩβεζθξρςφψϑϕϱ";
|
2483
|
+
const largeNudge = "AFJdfΔΛ";
|
2480
2484
|
|
2481
2485
|
const mathmlBuilder$a = (group, style) => {
|
2482
2486
|
const accentNode = group.isStretchy
|
2483
2487
|
? stretchy.accentNode(group)
|
2484
2488
|
: new mathMLTree.MathNode("mo", [makeText(group.label, group.mode)]);
|
2485
|
-
|
2486
|
-
if (group.label === "\\vec") {
|
2487
|
-
accentNode.style.transform = "scale(0.75) translate(10%, 30%)";
|
2488
|
-
} else {
|
2489
|
-
accentNode.style.mathStyle = "normal";
|
2490
|
-
accentNode.style.mathDepth = "0";
|
2491
|
-
if (needWebkitShift.has(group.label) && utils.isCharacterBox(group.base)) {
|
2492
|
-
let shift = "";
|
2493
|
-
const ch = group.base.text;
|
2494
|
-
if (smalls.indexOf(ch) > -1 || longSmalls.has(ch)) { shift = "tml-xshift"; }
|
2495
|
-
if (talls.indexOf(ch) > -1 || longTalls.has(ch)) { shift = "tml-capshift"; }
|
2496
|
-
if (shift) { accentNode.classes.push(shift); }
|
2497
|
-
}
|
2498
|
-
}
|
2499
2489
|
if (!group.isStretchy) {
|
2500
|
-
accentNode.setAttribute("stretchy", "false");
|
2501
|
-
}
|
2502
|
-
|
2503
|
-
|
2504
|
-
|
2505
|
-
|
2506
|
-
|
2490
|
+
accentNode.setAttribute("stretchy", "false"); // Keep Firefox from stretching \check
|
2491
|
+
}
|
2492
|
+
if (group.label !== "\\vec") {
|
2493
|
+
accentNode.style.mathDepth = "0"; // not scriptstyle
|
2494
|
+
// Don't use attribute accent="true" because MathML Core eliminates a needed space.
|
2495
|
+
}
|
2496
|
+
const tag = group.label === "\\c" ? "munder" : "mover";
|
2497
|
+
const needsWbkVertShift = needsWebkitVerticalShift.has(group.label);
|
2498
|
+
if (tag === "mover" && group.mode === "math" && (!group.isStretchy) && group.base.text
|
2499
|
+
&& group.base.text.length === 1) {
|
2500
|
+
const text = group.base.text;
|
2501
|
+
const isVec = group.label === "\\vec";
|
2502
|
+
const vecPostfix = isVec === "\\vec" ? "-vec" : "";
|
2503
|
+
if (isVec) {
|
2504
|
+
accentNode.classes.push("tml-vec"); // Firefox sizing of \vec arrow
|
2505
|
+
}
|
2506
|
+
const wbkPostfix = isVec ? "-vec" : needsWbkVertShift ? "-acc" : "";
|
2507
|
+
if (smallNudge.indexOf(text) > -1) {
|
2508
|
+
accentNode.classes.push(`chr-sml${vecPostfix}`);
|
2509
|
+
accentNode.classes.push(`wbk-sml${wbkPostfix}`);
|
2510
|
+
} else if (mediumNudge.indexOf(text) > -1) {
|
2511
|
+
accentNode.classes.push(`chr-med${vecPostfix}`);
|
2512
|
+
accentNode.classes.push(`wbk-med${wbkPostfix}`);
|
2513
|
+
} else if (largeNudge.indexOf(text) > -1) {
|
2514
|
+
accentNode.classes.push(`chr-lrg${vecPostfix}`);
|
2515
|
+
accentNode.classes.push(`wbk-lrg${wbkPostfix}`);
|
2516
|
+
} else if (isVec) {
|
2517
|
+
accentNode.classes.push(`wbk-vec`);
|
2518
|
+
} else if (needsWbkVertShift) {
|
2519
|
+
accentNode.classes.push(`wbk-acc`);
|
2520
|
+
}
|
2521
|
+
} else if (needsWbkVertShift) {
|
2522
|
+
// text-mode accents
|
2523
|
+
accentNode.classes.push("wbk-acc");
|
2524
|
+
}
|
2525
|
+
const node = new mathMLTree.MathNode(tag, [buildGroup$1(group.base, style), accentNode]);
|
2507
2526
|
return node;
|
2508
2527
|
};
|
2509
2528
|
|
2510
2529
|
const nonStretchyAccents = new Set([
|
2511
2530
|
"\\acute",
|
2531
|
+
"\\check",
|
2512
2532
|
"\\grave",
|
2513
2533
|
"\\ddot",
|
2514
2534
|
"\\dddot",
|
@@ -2523,7 +2543,7 @@ var temml = (function () {
|
|
2523
2543
|
"\\mathring"
|
2524
2544
|
]);
|
2525
2545
|
|
2526
|
-
const
|
2546
|
+
const needsWebkitVerticalShift = new Set([
|
2527
2547
|
"\\acute",
|
2528
2548
|
"\\bar",
|
2529
2549
|
"\\breve",
|
@@ -2533,7 +2553,7 @@ var temml = (function () {
|
|
2533
2553
|
"\\grave",
|
2534
2554
|
"\\hat",
|
2535
2555
|
"\\mathring",
|
2536
|
-
"
|
2556
|
+
"\\`", "\\'", "\\^", "\\=", "\\u", "\\.", '\\"', "\\r", "\\H", "\\v"
|
2537
2557
|
]);
|
2538
2558
|
|
2539
2559
|
const combiningChar = {
|
@@ -2547,7 +2567,8 @@ var temml = (function () {
|
|
2547
2567
|
'\\"': "\u0308",
|
2548
2568
|
"\\r": "\u030A",
|
2549
2569
|
"\\H": "\u030B",
|
2550
|
-
"\\v": "\u030C"
|
2570
|
+
"\\v": "\u030C",
|
2571
|
+
"\\c": "\u0327"
|
2551
2572
|
};
|
2552
2573
|
|
2553
2574
|
// Accents
|
@@ -2592,8 +2613,8 @@ var temml = (function () {
|
|
2592
2613
|
type: "accent",
|
2593
2614
|
mode: context.parser.mode,
|
2594
2615
|
label: context.funcName,
|
2595
|
-
isStretchy
|
2596
|
-
base
|
2616
|
+
isStretchy,
|
2617
|
+
base
|
2597
2618
|
};
|
2598
2619
|
},
|
2599
2620
|
mathmlBuilder: mathmlBuilder$a
|
@@ -2620,21 +2641,25 @@ var temml = (function () {
|
|
2620
2641
|
}
|
2621
2642
|
|
2622
2643
|
if (mode === "text" && base.text && base.text.length === 1
|
2623
|
-
&& context.funcName in combiningChar
|
2644
|
+
&& context.funcName in combiningChar && smalls.indexOf(base.text) > -1) {
|
2624
2645
|
// Return a combining accent character
|
2625
2646
|
return {
|
2626
2647
|
type: "textord",
|
2627
2648
|
mode: "text",
|
2628
2649
|
text: base.text + combiningChar[context.funcName]
|
2629
2650
|
}
|
2651
|
+
} else if (context.funcName === "\\c" && mode === "text" && base.text
|
2652
|
+
&& base.text.length === 1) {
|
2653
|
+
// combining cedilla
|
2654
|
+
return { type: "textord", mode: "text", text: base.text + "\u0327" }
|
2630
2655
|
} else {
|
2631
2656
|
// Build up the accent
|
2632
2657
|
return {
|
2633
2658
|
type: "accent",
|
2634
|
-
mode
|
2659
|
+
mode,
|
2635
2660
|
label: context.funcName,
|
2636
2661
|
isStretchy: false,
|
2637
|
-
base
|
2662
|
+
base
|
2638
2663
|
}
|
2639
2664
|
}
|
2640
2665
|
},
|
@@ -2892,12 +2917,17 @@ var temml = (function () {
|
|
2892
2917
|
"\\xlongequal",
|
2893
2918
|
"\\xtwoheadrightarrow",
|
2894
2919
|
"\\xtwoheadleftarrow",
|
2895
|
-
//
|
2920
|
+
"\\xtofrom", // expfeil
|
2921
|
+
"\\xleftrightharpoons", // mathtools
|
2922
|
+
"\\xrightleftharpoons", // mathtools
|
2923
|
+
// The next 7 functions are here only to support mhchem
|
2896
2924
|
"\\yields",
|
2897
2925
|
"\\yieldsLeft",
|
2898
2926
|
"\\mesomerism",
|
2899
2927
|
"\\longrightharpoonup",
|
2900
2928
|
"\\longleftharpoondown",
|
2929
|
+
"\\yieldsLeftRight",
|
2930
|
+
"\\chemequilibrium",
|
2901
2931
|
// The next 3 functions are here only to support the {CD} environment.
|
2902
2932
|
"\\\\cdrightarrow",
|
2903
2933
|
"\\\\cdleftarrow",
|
@@ -2928,26 +2958,15 @@ var temml = (function () {
|
|
2928
2958
|
});
|
2929
2959
|
|
2930
2960
|
const arrowComponent = {
|
2931
|
-
"\\xtofrom": ["\\xrightarrow", "\\xleftarrow"],
|
2932
|
-
"\\xleftrightharpoons": ["\\xleftharpoonup", "\\xrightharpoondown"],
|
2933
|
-
"\\xrightleftharpoons": ["\\xrightharpoonup", "\\xleftharpoondown"],
|
2934
|
-
"\\yieldsLeftRight": ["\\yields", "\\yieldsLeft"],
|
2935
|
-
// The next three all get the same harpoon glyphs. Only the lengths and paddings differ.
|
2936
|
-
"\\equilibrium": ["\\longrightharpoonup", "\\longleftharpoondown"],
|
2937
2961
|
"\\equilibriumRight": ["\\longrightharpoonup", "\\eqleftharpoondown"],
|
2938
2962
|
"\\equilibriumLeft": ["\\eqrightharpoonup", "\\longleftharpoondown"]
|
2939
2963
|
};
|
2940
2964
|
|
2941
|
-
//
|
2942
|
-
// So we stack a pair of single
|
2965
|
+
// Math fonts do not have a single glyph for these two mhchem functions.
|
2966
|
+
// So we stack a pair of single harpoons.
|
2943
2967
|
defineFunction({
|
2944
2968
|
type: "stackedArrow",
|
2945
2969
|
names: [
|
2946
|
-
"\\xtofrom", // expfeil
|
2947
|
-
"\\xleftrightharpoons", // mathtools
|
2948
|
-
"\\xrightleftharpoons", // mathtools
|
2949
|
-
"\\yieldsLeftRight", // mhchem
|
2950
|
-
"\\equilibrium", // mhchem
|
2951
2970
|
"\\equilibriumRight",
|
2952
2971
|
"\\equilibriumLeft"
|
2953
2972
|
],
|
@@ -3454,7 +3473,6 @@ var temml = (function () {
|
|
3454
3473
|
alwaysHandleSupSub: true,
|
3455
3474
|
parentIsSupSub: true,
|
3456
3475
|
symbol: false,
|
3457
|
-
stack: true,
|
3458
3476
|
suppressBaseShift: true,
|
3459
3477
|
body: [container]
|
3460
3478
|
};
|
@@ -3462,6 +3480,7 @@ var temml = (function () {
|
|
3462
3480
|
const mover = {
|
3463
3481
|
type: "supsub", // We're using the MathML equivalent
|
3464
3482
|
mode: "math", // of TeX \overset.
|
3483
|
+
stack: true,
|
3465
3484
|
base: base, // That keeps the {pmatrix} aligned with
|
3466
3485
|
sup: topWrapper, // the math centerline.
|
3467
3486
|
sub: null
|
@@ -6275,7 +6294,8 @@ var temml = (function () {
|
|
6275
6294
|
case "\\boxed":
|
6276
6295
|
// \newcommand{\boxed}[1]{\fbox{\m@th$\displaystyle#1$}} from amsmath.sty
|
6277
6296
|
node.setAttribute("notation", "box");
|
6278
|
-
node.
|
6297
|
+
node.style.padding = "padding: 3pt 0 3pt 0";
|
6298
|
+
node.style.border = "1px solid";
|
6279
6299
|
node.setAttribute("scriptlevel", "0");
|
6280
6300
|
node.setAttribute("displaystyle", "true");
|
6281
6301
|
break
|
@@ -7081,88 +7101,6 @@ var temml = (function () {
|
|
7081
7101
|
mathmlBuilder: mathmlBuilder$4
|
7082
7102
|
});
|
7083
7103
|
|
7084
|
-
defineFunction({
|
7085
|
-
type: "href",
|
7086
|
-
names: ["\\href"],
|
7087
|
-
props: {
|
7088
|
-
numArgs: 2,
|
7089
|
-
argTypes: ["url", "original"],
|
7090
|
-
allowedInText: true
|
7091
|
-
},
|
7092
|
-
handler: ({ parser, token }, args) => {
|
7093
|
-
const body = args[1];
|
7094
|
-
const href = assertNodeType(args[0], "url").url;
|
7095
|
-
|
7096
|
-
if (
|
7097
|
-
!parser.settings.isTrusted({
|
7098
|
-
command: "\\href",
|
7099
|
-
url: href
|
7100
|
-
})
|
7101
|
-
) {
|
7102
|
-
throw new ParseError(`Function "\\href" is not trusted`, token)
|
7103
|
-
}
|
7104
|
-
|
7105
|
-
return {
|
7106
|
-
type: "href",
|
7107
|
-
mode: parser.mode,
|
7108
|
-
href,
|
7109
|
-
body: ordargument(body)
|
7110
|
-
};
|
7111
|
-
},
|
7112
|
-
mathmlBuilder: (group, style) => {
|
7113
|
-
const math = new MathNode("math", [buildExpressionRow(group.body, style)]);
|
7114
|
-
const anchorNode = new AnchorNode(group.href, [], [math]);
|
7115
|
-
return anchorNode
|
7116
|
-
}
|
7117
|
-
});
|
7118
|
-
|
7119
|
-
defineFunction({
|
7120
|
-
type: "href",
|
7121
|
-
names: ["\\url"],
|
7122
|
-
props: {
|
7123
|
-
numArgs: 1,
|
7124
|
-
argTypes: ["url"],
|
7125
|
-
allowedInText: true
|
7126
|
-
},
|
7127
|
-
handler: ({ parser, token }, args) => {
|
7128
|
-
const href = assertNodeType(args[0], "url").url;
|
7129
|
-
|
7130
|
-
if (
|
7131
|
-
!parser.settings.isTrusted({
|
7132
|
-
command: "\\url",
|
7133
|
-
url: href
|
7134
|
-
})
|
7135
|
-
) {
|
7136
|
-
throw new ParseError(`Function "\\url" is not trusted`, token)
|
7137
|
-
}
|
7138
|
-
|
7139
|
-
const chars = [];
|
7140
|
-
for (let i = 0; i < href.length; i++) {
|
7141
|
-
let c = href[i];
|
7142
|
-
if (c === "~") {
|
7143
|
-
c = "\\textasciitilde";
|
7144
|
-
}
|
7145
|
-
chars.push({
|
7146
|
-
type: "textord",
|
7147
|
-
mode: "text",
|
7148
|
-
text: c
|
7149
|
-
});
|
7150
|
-
}
|
7151
|
-
const body = {
|
7152
|
-
type: "text",
|
7153
|
-
mode: parser.mode,
|
7154
|
-
font: "\\texttt",
|
7155
|
-
body: chars
|
7156
|
-
};
|
7157
|
-
return {
|
7158
|
-
type: "href",
|
7159
|
-
mode: parser.mode,
|
7160
|
-
href,
|
7161
|
-
body: ordargument(body)
|
7162
|
-
};
|
7163
|
-
}
|
7164
|
-
});
|
7165
|
-
|
7166
7104
|
defineFunction({
|
7167
7105
|
type: "html",
|
7168
7106
|
names: ["\\class", "\\id", "\\style", "\\data"],
|
@@ -7420,17 +7358,24 @@ var temml = (function () {
|
|
7420
7358
|
},
|
7421
7359
|
mathmlBuilder(group, style) {
|
7422
7360
|
const dimension = calculateSize(group.dimension, style);
|
7423
|
-
const ch = dimension.
|
7361
|
+
const ch = dimension.number > 0 && dimension.unit === "em"
|
7362
|
+
? spaceCharacter(dimension.number)
|
7363
|
+
: "";
|
7424
7364
|
if (group.mode === "text" && ch.length > 0) {
|
7425
7365
|
const character = new mathMLTree.TextNode(ch);
|
7426
7366
|
return new mathMLTree.MathNode("mtext", [character]);
|
7427
7367
|
} else {
|
7428
|
-
|
7429
|
-
|
7430
|
-
|
7368
|
+
if (dimension.number >= 0) {
|
7369
|
+
const node = new mathMLTree.MathNode("mspace");
|
7370
|
+
node.setAttribute("width", dimension.number + dimension.unit);
|
7371
|
+
return node
|
7372
|
+
} else {
|
7373
|
+
// Don't use <mspace> or <mpadded> because
|
7374
|
+
// WebKit recognizes negative left margin only on a <mrow> element
|
7375
|
+
const node = new mathMLTree.MathNode("mrow");
|
7431
7376
|
node.style.marginLeft = dimension.number + dimension.unit;
|
7377
|
+
return node
|
7432
7378
|
}
|
7433
|
-
return node;
|
7434
7379
|
}
|
7435
7380
|
}
|
7436
7381
|
});
|
@@ -7763,7 +7708,9 @@ var temml = (function () {
|
|
7763
7708
|
// (by rendering separately and with {}s before and after, and measuring
|
7764
7709
|
// the change in spacing). We'll do roughly the same by detecting the
|
7765
7710
|
// atom type directly.
|
7766
|
-
const atom = arg.type === "ordgroup" && arg.body.length
|
7711
|
+
const atom = arg.type === "ordgroup" && arg.body.length && arg.body.length === 1
|
7712
|
+
? arg.body[0]
|
7713
|
+
: arg;
|
7767
7714
|
if (atom.type === "atom" && (atom.family === "bin" || atom.family === "rel")) {
|
7768
7715
|
return "m" + atom.family;
|
7769
7716
|
} else {
|
@@ -7801,14 +7748,25 @@ var temml = (function () {
|
|
7801
7748
|
const baseArg = args[1];
|
7802
7749
|
const shiftedArg = args[0];
|
7803
7750
|
|
7751
|
+
let mclass;
|
7752
|
+
if (funcName !== "\\stackrel") {
|
7753
|
+
// LaTeX applies \binrel spacing to \overset and \underset.
|
7754
|
+
mclass = binrelClass(baseArg);
|
7755
|
+
} else {
|
7756
|
+
mclass = "mrel"; // for \stackrel
|
7757
|
+
}
|
7758
|
+
|
7759
|
+
const baseType = mclass === "mrel" || mclass === "mbin"
|
7760
|
+
? "op"
|
7761
|
+
: "ordgroup";
|
7762
|
+
|
7804
7763
|
const baseOp = {
|
7805
|
-
type:
|
7764
|
+
type: baseType,
|
7806
7765
|
mode: baseArg.mode,
|
7807
7766
|
limits: true,
|
7808
7767
|
alwaysHandleSupSub: true,
|
7809
7768
|
parentIsSupSub: false,
|
7810
7769
|
symbol: false,
|
7811
|
-
stack: true,
|
7812
7770
|
suppressBaseShift: funcName !== "\\stackrel",
|
7813
7771
|
body: ordargument(baseArg)
|
7814
7772
|
};
|
@@ -7816,6 +7774,7 @@ var temml = (function () {
|
|
7816
7774
|
return {
|
7817
7775
|
type: "supsub",
|
7818
7776
|
mode: shiftedArg.mode,
|
7777
|
+
stack: true,
|
7819
7778
|
base: baseOp,
|
7820
7779
|
sup: funcName === "\\underset" ? null : shiftedArg,
|
7821
7780
|
sub: funcName === "\\underset" ? shiftedArg : null
|
@@ -8717,6 +8676,71 @@ var temml = (function () {
|
|
8717
8676
|
}
|
8718
8677
|
});
|
8719
8678
|
|
8679
|
+
const numRegEx = /^[0-9]$/;
|
8680
|
+
const unicodeNumSubs = {
|
8681
|
+
'0': '₀',
|
8682
|
+
'1': '₁',
|
8683
|
+
'2': '₂',
|
8684
|
+
'3': '₃',
|
8685
|
+
'4': '₄',
|
8686
|
+
'5': '₅',
|
8687
|
+
'6': '₆',
|
8688
|
+
'7': '₇',
|
8689
|
+
'8': '₈',
|
8690
|
+
'9': '₉'
|
8691
|
+
};
|
8692
|
+
const unicodeNumSups = {
|
8693
|
+
'0': '⁰',
|
8694
|
+
'1': '¹',
|
8695
|
+
'2': '²',
|
8696
|
+
'3': '³',
|
8697
|
+
'4': '⁴',
|
8698
|
+
'5': '⁵',
|
8699
|
+
'6': '⁶',
|
8700
|
+
'7': '⁷',
|
8701
|
+
'8': '⁸',
|
8702
|
+
'9': '⁹'
|
8703
|
+
};
|
8704
|
+
|
8705
|
+
defineFunction({
|
8706
|
+
type: "sfrac",
|
8707
|
+
names: ["\\sfrac"],
|
8708
|
+
props: {
|
8709
|
+
numArgs: 2,
|
8710
|
+
allowedInText: true,
|
8711
|
+
allowedInMath: true
|
8712
|
+
},
|
8713
|
+
handler({ parser }, args) {
|
8714
|
+
let numerator = "";
|
8715
|
+
for (const node of args[0].body) {
|
8716
|
+
if (node.type !== "textord" || !numRegEx.test(node.text)) {
|
8717
|
+
throw new ParseError("Numerator must be an integer.", node)
|
8718
|
+
}
|
8719
|
+
numerator += node.text;
|
8720
|
+
}
|
8721
|
+
let denominator = "";
|
8722
|
+
for (const node of args[1].body) {
|
8723
|
+
if (node.type !== "textord" || !numRegEx.test(node.text)) {
|
8724
|
+
throw new ParseError("Denominator must be an integer.", node)
|
8725
|
+
}
|
8726
|
+
denominator += node.text;
|
8727
|
+
}
|
8728
|
+
return {
|
8729
|
+
type: "sfrac",
|
8730
|
+
mode: parser.mode,
|
8731
|
+
numerator,
|
8732
|
+
denominator
|
8733
|
+
};
|
8734
|
+
},
|
8735
|
+
mathmlBuilder(group, style) {
|
8736
|
+
const numerator = group.numerator.split('').map(c => unicodeNumSups[c]).join('');
|
8737
|
+
const denominator = group.denominator.split('').map(c => unicodeNumSubs[c]).join('');
|
8738
|
+
// Use a fraction slash.
|
8739
|
+
const text = new mathMLTree.TextNode(numerator + "\u2044" + denominator, group.mode, style);
|
8740
|
+
return new mathMLTree.MathNode("mn", [text], ["special-fraction"])
|
8741
|
+
}
|
8742
|
+
});
|
8743
|
+
|
8720
8744
|
// The size mappings are taken from TeX with \normalsize=10pt.
|
8721
8745
|
// We don't have to track script level. MathML does that.
|
8722
8746
|
const sizeMap = {
|
@@ -8934,6 +8958,11 @@ var temml = (function () {
|
|
8934
8958
|
// Helpers
|
8935
8959
|
const symbolRegEx = /^m(over|under|underover)$/;
|
8936
8960
|
|
8961
|
+
// From the KaTeX font metrics, identify letters that encroach on a superscript.
|
8962
|
+
const smallPad = "DHKLUcegorsuvxyzΠΥΨαδηιμνοτυχϵ";
|
8963
|
+
const mediumPad = "BCEFGIMNOPQRSTXZlpqtwΓΘΞΣΦΩβεζθξρςφψϑϕϱ";
|
8964
|
+
const largePad = "AJdfΔΛ";
|
8965
|
+
|
8937
8966
|
// Super scripts and subscripts, whose precise placement can depend on other
|
8938
8967
|
// functions that precede them.
|
8939
8968
|
defineFunctionBuilders({
|
@@ -8955,7 +8984,7 @@ var temml = (function () {
|
|
8955
8984
|
}
|
8956
8985
|
}
|
8957
8986
|
|
8958
|
-
if (group.base && !group.
|
8987
|
+
if (group.base && !group.stack &&
|
8959
8988
|
(group.base.type === "op" || group.base.type === "operatorname")) {
|
8960
8989
|
group.base.parentIsSupSub = true;
|
8961
8990
|
appendApplyFunction = !group.base.symbol;
|
@@ -8963,7 +8992,7 @@ var temml = (function () {
|
|
8963
8992
|
needsLeadingSpace = group.base.needsLeadingSpace;
|
8964
8993
|
}
|
8965
8994
|
|
8966
|
-
const children = group.
|
8995
|
+
const children = group.stack && group.base.body.length === 1
|
8967
8996
|
? [buildGroup$1(group.base.body[0], style)]
|
8968
8997
|
: [buildGroup$1(group.base, style)];
|
8969
8998
|
|
@@ -8983,11 +9012,16 @@ var temml = (function () {
|
|
8983
9012
|
if (group.sup) {
|
8984
9013
|
const sup = buildGroup$1(group.sup, childStyle);
|
8985
9014
|
if (style.level === 3) { sup.setAttribute("scriptlevel", "2"); }
|
8986
|
-
|
8987
|
-
|
8988
|
-
|
8989
|
-
|
8990
|
-
|
9015
|
+
if (group.base && group.base.text && group.base.text.length === 1) {
|
9016
|
+
// Make an italic correction on the superscript.
|
9017
|
+
const text = group.base.text;
|
9018
|
+
if (smallPad.indexOf(text) > -1) {
|
9019
|
+
sup.classes.push("tml-sml-pad");
|
9020
|
+
} else if (mediumPad.indexOf(text) > -1) {
|
9021
|
+
sup.classes.push("tml-med-pad");
|
9022
|
+
} else if (largePad.indexOf(text) > -1) {
|
9023
|
+
sup.classes.push("tml-lrg-pad");
|
9024
|
+
}
|
8991
9025
|
}
|
8992
9026
|
children.push(sup);
|
8993
9027
|
}
|
@@ -9016,7 +9050,9 @@ var temml = (function () {
|
|
9016
9050
|
}
|
9017
9051
|
} else if (!group.sup) {
|
9018
9052
|
const base = group.base;
|
9019
|
-
if (
|
9053
|
+
if (group.stack) {
|
9054
|
+
nodeType = "munder";
|
9055
|
+
} else if (
|
9020
9056
|
base &&
|
9021
9057
|
base.type === "op" &&
|
9022
9058
|
base.limits &&
|
@@ -12061,7 +12097,7 @@ var temml = (function () {
|
|
12061
12097
|
* https://mit-license.org/
|
12062
12098
|
*/
|
12063
12099
|
|
12064
|
-
const version = "0.11.
|
12100
|
+
const version = "0.11.08";
|
12065
12101
|
|
12066
12102
|
function postProcess(block) {
|
12067
12103
|
const labelMap = {};
|