temml 0.13.2 → 0.13.4
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/dist/Temml-Asana.css +22 -3
- package/dist/Temml-Latin-Modern.css +22 -3
- package/dist/Temml-Libertinus.css +22 -4
- package/dist/Temml-Local.css +24 -5
- package/dist/Temml-NotoSans.css +24 -5
- package/dist/Temml-STIX2.css +24 -5
- package/dist/temml.cjs +294 -260
- package/dist/temml.js +294 -260
- package/dist/temml.min.js +1 -1
- package/dist/temml.mjs +294 -260
- package/dist/temmlPostProcess.js +1 -1
- package/package.json +5 -3
- package/src/MacroExpander.js +2 -1
- package/src/environments/array.js +2 -2
- package/src/functions/bordermatrix.js +3 -5
- package/src/functions/delimiter.js +7 -10
- package/src/functions/enclose.js +20 -1
- package/src/functions/font.js +14 -4
- package/src/functions/phantom.js +1 -1
- package/src/postProcess.js +1 -1
- package/src/stretchy.js +18 -7
- package/src/symbols.js +1 -1
package/dist/temml.cjs
CHANGED
|
@@ -787,7 +787,7 @@ const estimatedWidth = node => {
|
|
|
787
787
|
};
|
|
788
788
|
|
|
789
789
|
const stretchyCodePoint = {
|
|
790
|
-
widehat: "
|
|
790
|
+
widehat: "\u02c6", // Shorter than \u005e, which is appropriate for an accent.
|
|
791
791
|
widecheck: "ˇ",
|
|
792
792
|
widetilde: "~",
|
|
793
793
|
wideparen: "⏜", // \u23dc
|
|
@@ -850,19 +850,30 @@ const mathMLnode = function(label) {
|
|
|
850
850
|
return node
|
|
851
851
|
};
|
|
852
852
|
|
|
853
|
-
const
|
|
853
|
+
const wideHats = ["\\widehat", "\\widecheck"];
|
|
854
854
|
|
|
855
|
-
// TODO: Remove when Chromium stretches \widetilde & \widehat
|
|
855
|
+
// TODO: Remove if/when Chromium stretches \widetilde & \widehat
|
|
856
856
|
const accentNode = (group) => {
|
|
857
857
|
const mo = mathMLnode(group.label);
|
|
858
|
-
if (
|
|
858
|
+
if (group.label.indexOf("tilde") > -1) {
|
|
859
859
|
const width = estimatedWidth(group.base);
|
|
860
860
|
if (1 < width && width < 1.6) {
|
|
861
|
-
mo.classes.push("tml-
|
|
861
|
+
mo.classes.push("tml-tilde-2");
|
|
862
|
+
} else if (1.6 <= width && width < 2.5) {
|
|
863
|
+
mo.classes.push("tml-tilde-3");
|
|
864
|
+
} else if (2.5 <= width) {
|
|
865
|
+
mo.classes.push("tml-tilde-4");
|
|
866
|
+
}
|
|
867
|
+
} else if (wideHats.includes(group.label)) {
|
|
868
|
+
const width = estimatedWidth(group.base);
|
|
869
|
+
if (0 < width && width <= 1) {
|
|
870
|
+
mo.classes.push("tml-hat-1");
|
|
871
|
+
} else if (1 < width && width < 1.6) {
|
|
872
|
+
mo.classes.push("tml-hat-2");
|
|
862
873
|
} else if (1.6 <= width && width < 2.5) {
|
|
863
|
-
mo.classes.push("tml-
|
|
874
|
+
mo.classes.push("tml-hat-3");
|
|
864
875
|
} else if (2.5 <= width) {
|
|
865
|
-
mo.classes.push("tml-
|
|
876
|
+
mo.classes.push("tml-hat-4");
|
|
866
877
|
}
|
|
867
878
|
}
|
|
868
879
|
return mo
|
|
@@ -1771,7 +1782,7 @@ defineSymbol(math, accent, "\u007e", "\\tilde");
|
|
|
1771
1782
|
defineSymbol(math, accent, "\u203e", "\\bar");
|
|
1772
1783
|
defineSymbol(math, accent, "\u02d8", "\\breve");
|
|
1773
1784
|
defineSymbol(math, accent, "\u02c7", "\\check");
|
|
1774
|
-
defineSymbol(math, accent, "\
|
|
1785
|
+
defineSymbol(math, accent, "\u02c6", "\\hat");
|
|
1775
1786
|
defineSymbol(math, accent, "\u2192", "\\vec");
|
|
1776
1787
|
defineSymbol(math, accent, "\u02d9", "\\dot");
|
|
1777
1788
|
defineSymbol(math, accent, "\u02da", "\\mathring");
|
|
@@ -6520,9 +6531,9 @@ const mathmlBuilder$9 = function(group, style) {
|
|
|
6520
6531
|
}
|
|
6521
6532
|
if (mustSquashRow) {
|
|
6522
6533
|
// All the cell contents are \hphantom. Squash the cell.
|
|
6534
|
+
// TODO: Remove the next line when Firefox no longer needs it.
|
|
6535
|
+
mtr.classes.push("ff-squash"); // necessary in Firefox only.
|
|
6523
6536
|
for (let j = 0; j < mtr.children.length; j++) {
|
|
6524
|
-
mtr.children[j].style.display = "block"; // necessary in Firefox only
|
|
6525
|
-
mtr.children[j].style.height = "0"; // necessary in Firefox only
|
|
6526
6537
|
mtr.children[j].style.paddingTop = "0";
|
|
6527
6538
|
mtr.children[j].style.paddingBottom = "0";
|
|
6528
6539
|
}
|
|
@@ -7163,13 +7174,11 @@ defineFunction({
|
|
|
7163
7174
|
},
|
|
7164
7175
|
handler: ({ parser, funcName }, args, optArgs) => {
|
|
7165
7176
|
// Find out if the author has defined custom delimiters
|
|
7166
|
-
let delimiters = ["(", ")"];
|
|
7177
|
+
let delimiters = ["(", ")"]; // default
|
|
7167
7178
|
if (funcName === "\\bordermatrix" && optArgs[0] && optArgs[0].body) {
|
|
7168
7179
|
const body = optArgs[0].body;
|
|
7169
|
-
if (body.length ===
|
|
7170
|
-
|
|
7171
|
-
delimiters = [body[0].text, body[1].text];
|
|
7172
|
-
}
|
|
7180
|
+
if (body.length === 1 && body[0].type === "delimiter") {
|
|
7181
|
+
delimiters = [body[0].left, body[0].right];
|
|
7173
7182
|
}
|
|
7174
7183
|
}
|
|
7175
7184
|
// consume the opening brace
|
|
@@ -8265,17 +8274,14 @@ defineFunction({
|
|
|
8265
8274
|
mathmlBuilder: (group) => {
|
|
8266
8275
|
const textNode = makeText(group.delim, group.mode);
|
|
8267
8276
|
const middleNode = new MathNode("mo", [textNode]);
|
|
8268
|
-
middleNode.setAttribute("
|
|
8269
|
-
|
|
8270
|
-
|
|
8271
|
-
|
|
8272
|
-
|
|
8273
|
-
|
|
8274
|
-
|
|
8275
|
-
|
|
8276
|
-
// \middle should get delimiter spacing instead.
|
|
8277
|
-
middleNode.setAttribute("lspace", "0.05em");
|
|
8278
|
-
middleNode.setAttribute("rspace", "0.05em");
|
|
8277
|
+
middleNode.setAttribute("stretchy", "true");
|
|
8278
|
+
middleNode.setAttribute("form", "infix");
|
|
8279
|
+
if (textNode.text !== "/") {
|
|
8280
|
+
// MathML gives 5/18em spacing to each <mo> element.
|
|
8281
|
+
// \middle should get delimiter spacing instead.
|
|
8282
|
+
middleNode.setAttribute("lspace", "0.05em");
|
|
8283
|
+
middleNode.setAttribute("rspace", "0.05em");
|
|
8284
|
+
}
|
|
8279
8285
|
return middleNode;
|
|
8280
8286
|
}
|
|
8281
8287
|
});
|
|
@@ -8442,7 +8448,7 @@ defineFunction({
|
|
|
8442
8448
|
|
|
8443
8449
|
defineFunction({
|
|
8444
8450
|
type: "enclose",
|
|
8445
|
-
names: ["\\angl", "\\cancel", "\\bcancel", "\\xcancel", "\\
|
|
8451
|
+
names: ["\\angl", "\\cancel", "\\bcancel", "\\xcancel", "\\overline",
|
|
8446
8452
|
"\\boxed", "\\longdiv", "\\phase"],
|
|
8447
8453
|
props: {
|
|
8448
8454
|
numArgs: 1
|
|
@@ -8459,6 +8465,25 @@ defineFunction({
|
|
|
8459
8465
|
mathmlBuilder: mathmlBuilder$7
|
|
8460
8466
|
});
|
|
8461
8467
|
|
|
8468
|
+
defineFunction({
|
|
8469
|
+
type: "enclose",
|
|
8470
|
+
names: ["\\sout"],
|
|
8471
|
+
props: {
|
|
8472
|
+
numArgs: 1,
|
|
8473
|
+
allowedInText: true
|
|
8474
|
+
},
|
|
8475
|
+
handler({ parser, funcName }, args) {
|
|
8476
|
+
const body = args[0];
|
|
8477
|
+
return {
|
|
8478
|
+
type: "enclose",
|
|
8479
|
+
mode: parser.mode,
|
|
8480
|
+
label: funcName,
|
|
8481
|
+
body
|
|
8482
|
+
};
|
|
8483
|
+
},
|
|
8484
|
+
mathmlBuilder: mathmlBuilder$7
|
|
8485
|
+
});
|
|
8486
|
+
|
|
8462
8487
|
defineFunction({
|
|
8463
8488
|
type: "enclose",
|
|
8464
8489
|
names: ["\\underline"],
|
|
@@ -8591,8 +8616,237 @@ defineFunction({
|
|
|
8591
8616
|
}
|
|
8592
8617
|
});
|
|
8593
8618
|
|
|
8619
|
+
// Chromium does not support the MathML `mathvariant` attribute.
|
|
8620
|
+
// Instead, we replace ASCII characters with Unicode characters that
|
|
8621
|
+
// are defined in the font as bold, italic, double-struck, etc.
|
|
8622
|
+
// This module identifies those Unicode code points.
|
|
8623
|
+
|
|
8624
|
+
// First, a few helpers.
|
|
8625
|
+
const script = Object.freeze({
|
|
8626
|
+
B: 0x20EA, // Offset from ASCII B to Unicode script B
|
|
8627
|
+
E: 0x20EB,
|
|
8628
|
+
F: 0x20EB,
|
|
8629
|
+
H: 0x20C3,
|
|
8630
|
+
I: 0x20C7,
|
|
8631
|
+
L: 0x20C6,
|
|
8632
|
+
M: 0x20E6,
|
|
8633
|
+
R: 0x20C9,
|
|
8634
|
+
e: 0x20CA,
|
|
8635
|
+
g: 0x20A3,
|
|
8636
|
+
o: 0x20C5
|
|
8637
|
+
});
|
|
8638
|
+
|
|
8639
|
+
const frak = Object.freeze({
|
|
8640
|
+
C: 0x20EA,
|
|
8641
|
+
H: 0x20C4,
|
|
8642
|
+
I: 0x20C8,
|
|
8643
|
+
R: 0x20CA,
|
|
8644
|
+
Z: 0x20CE
|
|
8645
|
+
});
|
|
8646
|
+
|
|
8647
|
+
const bbb = Object.freeze({
|
|
8648
|
+
C: 0x20BF, // blackboard bold
|
|
8649
|
+
H: 0x20C5,
|
|
8650
|
+
N: 0x20C7,
|
|
8651
|
+
P: 0x20C9,
|
|
8652
|
+
Q: 0x20C9,
|
|
8653
|
+
R: 0x20CB,
|
|
8654
|
+
Z: 0x20CA
|
|
8655
|
+
});
|
|
8656
|
+
|
|
8657
|
+
const bold = Object.freeze({
|
|
8658
|
+
"\u03f5": 0x1D2E7, // lunate epsilon
|
|
8659
|
+
"\u03d1": 0x1D30C, // vartheta
|
|
8660
|
+
"\u03f0": 0x1D2EE, // varkappa
|
|
8661
|
+
"\u03c6": 0x1D319, // varphi
|
|
8662
|
+
"\u03f1": 0x1D2EF, // varrho
|
|
8663
|
+
"\u03d6": 0x1D30B // varpi
|
|
8664
|
+
});
|
|
8665
|
+
|
|
8666
|
+
const boldItalic = Object.freeze({
|
|
8667
|
+
"\u03f5": 0x1D35B, // lunate epsilon
|
|
8668
|
+
"\u03d1": 0x1D380, // vartheta
|
|
8669
|
+
"\u03f0": 0x1D362, // varkappa
|
|
8670
|
+
"\u03c6": 0x1D38D, // varphi
|
|
8671
|
+
"\u03f1": 0x1D363, // varrho
|
|
8672
|
+
"\u03d6": 0x1D37F // varpi
|
|
8673
|
+
});
|
|
8674
|
+
|
|
8675
|
+
const boldsf = Object.freeze({
|
|
8676
|
+
"\u03f5": 0x1D395, // lunate epsilon
|
|
8677
|
+
"\u03d1": 0x1D3BA, // vartheta
|
|
8678
|
+
"\u03f0": 0x1D39C, // varkappa
|
|
8679
|
+
"\u03c6": 0x1D3C7, // varphi
|
|
8680
|
+
"\u03f1": 0x1D39D, // varrho
|
|
8681
|
+
"\u03d6": 0x1D3B9 // varpi
|
|
8682
|
+
});
|
|
8683
|
+
|
|
8684
|
+
const bisf = Object.freeze({
|
|
8685
|
+
"\u03f5": 0x1D3CF, // lunate epsilon
|
|
8686
|
+
"\u03d1": 0x1D3F4, // vartheta
|
|
8687
|
+
"\u03f0": 0x1D3D6, // varkappa
|
|
8688
|
+
"\u03c6": 0x1D401, // varphi
|
|
8689
|
+
"\u03f1": 0x1D3D7, // varrho
|
|
8690
|
+
"\u03d6": 0x1D3F3 // varpi
|
|
8691
|
+
});
|
|
8692
|
+
|
|
8693
|
+
// Code point offsets below are derived from https://www.unicode.org/charts/PDF/U1D400.pdf
|
|
8694
|
+
const offset = Object.freeze({
|
|
8695
|
+
upperCaseLatin: { // A-Z
|
|
8696
|
+
"normal": ch => { return 0 },
|
|
8697
|
+
"bold": ch => { return 0x1D3BF },
|
|
8698
|
+
"italic": ch => { return 0x1D3F3 },
|
|
8699
|
+
"bold-italic": ch => { return 0x1D427 },
|
|
8700
|
+
"script": ch => { return script[ch] || 0x1D45B },
|
|
8701
|
+
"script-bold": ch => { return 0x1D48F },
|
|
8702
|
+
"fraktur": ch => { return frak[ch] || 0x1D4C3 },
|
|
8703
|
+
"fraktur-bold": ch => { return 0x1D52B },
|
|
8704
|
+
"double-struck": ch => { return bbb[ch] || 0x1D4F7 },
|
|
8705
|
+
"sans-serif": ch => { return 0x1D55F },
|
|
8706
|
+
"sans-serif-bold": ch => { return 0x1D593 },
|
|
8707
|
+
"sans-serif-italic": ch => { return 0x1D5C7 },
|
|
8708
|
+
"sans-serif-bold-italic": ch => { return 0x1D63C },
|
|
8709
|
+
"monospace": ch => { return 0x1D62F }
|
|
8710
|
+
},
|
|
8711
|
+
lowerCaseLatin: { // a-z
|
|
8712
|
+
"normal": ch => { return 0 },
|
|
8713
|
+
"bold": ch => { return 0x1D3B9 },
|
|
8714
|
+
"italic": ch => { return ch === "h" ? 0x20A6 : 0x1D3ED },
|
|
8715
|
+
"bold-italic": ch => { return 0x1D421 },
|
|
8716
|
+
"script": ch => { return script[ch] || 0x1D455 },
|
|
8717
|
+
"script-bold": ch => { return 0x1D489 },
|
|
8718
|
+
"fraktur": ch => { return 0x1D4BD },
|
|
8719
|
+
"fraktur-bold": ch => { return 0x1D525 },
|
|
8720
|
+
"double-struck": ch => { return 0x1D4F1 },
|
|
8721
|
+
"sans-serif": ch => { return 0x1D559 },
|
|
8722
|
+
"sans-serif-bold": ch => { return 0x1D58D },
|
|
8723
|
+
"sans-serif-italic": ch => { return 0x1D5C1 },
|
|
8724
|
+
"sans-serif-bold-italic": ch => { return 0x1D5F5 },
|
|
8725
|
+
"monospace": ch => { return 0x1D629 }
|
|
8726
|
+
},
|
|
8727
|
+
upperCaseGreek: { // A-Ω
|
|
8728
|
+
"normal": ch => { return 0 },
|
|
8729
|
+
"bold": ch => { return 0x1D317 },
|
|
8730
|
+
"italic": ch => { return 0x1D351 },
|
|
8731
|
+
// \boldsymbol actually returns upright bold for upperCaseGreek
|
|
8732
|
+
"bold-italic": ch => { return 0x1D317 },
|
|
8733
|
+
"script": ch => { return 0 },
|
|
8734
|
+
"script-bold": ch => { return 0 },
|
|
8735
|
+
"fraktur": ch => { return 0 },
|
|
8736
|
+
"fraktur-bold": ch => { return 0 },
|
|
8737
|
+
"double-struck": ch => { return 0 },
|
|
8738
|
+
// Unicode has no code points for regular-weight san-serif Greek. Use bold.
|
|
8739
|
+
"sans-serif": ch => { return 0x1D3C5 },
|
|
8740
|
+
"sans-serif-bold": ch => { return 0x1D3C5 },
|
|
8741
|
+
"sans-serif-italic": ch => { return 0 },
|
|
8742
|
+
"sans-serif-bold-italic": ch => { return 0x1D3FF },
|
|
8743
|
+
"monospace": ch => { return 0 }
|
|
8744
|
+
},
|
|
8745
|
+
lowerCaseGreek: { // α-ω
|
|
8746
|
+
"normal": ch => { return 0 },
|
|
8747
|
+
"bold": ch => { return 0x1D311 },
|
|
8748
|
+
"italic": ch => { return 0x1D34B },
|
|
8749
|
+
"bold-italic": ch => { return ch === "\u03d5" ? 0x1D37E : 0x1D385 },
|
|
8750
|
+
"script": ch => { return 0 },
|
|
8751
|
+
"script-bold": ch => { return 0 },
|
|
8752
|
+
"fraktur": ch => { return 0 },
|
|
8753
|
+
"fraktur-bold": ch => { return 0 },
|
|
8754
|
+
"double-struck": ch => { return 0 },
|
|
8755
|
+
// Unicode has no code points for regular-weight san-serif Greek. Use bold.
|
|
8756
|
+
"sans-serif": ch => { return 0x1D3BF },
|
|
8757
|
+
"sans-serif-bold": ch => { return 0x1D3BF },
|
|
8758
|
+
"sans-serif-italic": ch => { return 0 },
|
|
8759
|
+
"sans-serif-bold-italic": ch => { return 0x1D3F9 },
|
|
8760
|
+
"monospace": ch => { return 0 }
|
|
8761
|
+
},
|
|
8762
|
+
varGreek: { // \varGamma, etc
|
|
8763
|
+
"normal": ch => { return 0 },
|
|
8764
|
+
"bold": ch => { return bold[ch] || -51 },
|
|
8765
|
+
"italic": ch => { return 0 },
|
|
8766
|
+
"bold-italic": ch => { return boldItalic[ch] || 0x3A },
|
|
8767
|
+
"script": ch => { return 0 },
|
|
8768
|
+
"script-bold": ch => { return 0 },
|
|
8769
|
+
"fraktur": ch => { return 0 },
|
|
8770
|
+
"fraktur-bold": ch => { return 0 },
|
|
8771
|
+
"double-struck": ch => { return 0 },
|
|
8772
|
+
"sans-serif": ch => { return boldsf[ch] || 0x74 },
|
|
8773
|
+
"sans-serif-bold": ch => { return boldsf[ch] || 0x74 },
|
|
8774
|
+
"sans-serif-italic": ch => { return 0 },
|
|
8775
|
+
"sans-serif-bold-italic": ch => { return bisf[ch] || 0xAE },
|
|
8776
|
+
"monospace": ch => { return 0 }
|
|
8777
|
+
},
|
|
8778
|
+
numeral: { // 0-9
|
|
8779
|
+
"normal": ch => { return 0 },
|
|
8780
|
+
"bold": ch => { return 0x1D79E },
|
|
8781
|
+
"italic": ch => { return 0 },
|
|
8782
|
+
"bold-italic": ch => { return 0 },
|
|
8783
|
+
"script": ch => { return 0 },
|
|
8784
|
+
"script-bold": ch => { return 0 },
|
|
8785
|
+
"fraktur": ch => { return 0 },
|
|
8786
|
+
"fraktur-bold": ch => { return 0 },
|
|
8787
|
+
"double-struck": ch => { return 0x1D7A8 },
|
|
8788
|
+
"sans-serif": ch => { return 0x1D7B2 },
|
|
8789
|
+
"sans-serif-bold": ch => { return 0x1D7BC },
|
|
8790
|
+
"sans-serif-italic": ch => { return 0 },
|
|
8791
|
+
"sans-serif-bold-italic": ch => { return 0 },
|
|
8792
|
+
"monospace": ch => { return 0x1D7C6 }
|
|
8793
|
+
}
|
|
8794
|
+
});
|
|
8795
|
+
|
|
8796
|
+
const variantChar = (ch, variant) => {
|
|
8797
|
+
const codePoint = ch.codePointAt(0);
|
|
8798
|
+
const block = 0x40 < codePoint && codePoint < 0x5b
|
|
8799
|
+
? "upperCaseLatin"
|
|
8800
|
+
: 0x60 < codePoint && codePoint < 0x7b
|
|
8801
|
+
? "lowerCaseLatin"
|
|
8802
|
+
: (0x390 < codePoint && codePoint < 0x3AA)
|
|
8803
|
+
? "upperCaseGreek"
|
|
8804
|
+
: 0x3B0 < codePoint && codePoint < 0x3CA || ch === "\u03d5"
|
|
8805
|
+
? "lowerCaseGreek"
|
|
8806
|
+
: 0x1D6E1 < codePoint && codePoint < 0x1D6FC || bold[ch]
|
|
8807
|
+
? "varGreek"
|
|
8808
|
+
: (0x2F < codePoint && codePoint < 0x3A)
|
|
8809
|
+
? "numeral"
|
|
8810
|
+
: "other";
|
|
8811
|
+
return block === "other"
|
|
8812
|
+
? ch
|
|
8813
|
+
: String.fromCodePoint(codePoint + offset[block][variant](ch))
|
|
8814
|
+
};
|
|
8815
|
+
|
|
8816
|
+
const smallCaps = Object.freeze({
|
|
8817
|
+
a: "ᴀ",
|
|
8818
|
+
b: "ʙ",
|
|
8819
|
+
c: "ᴄ",
|
|
8820
|
+
d: "ᴅ",
|
|
8821
|
+
e: "ᴇ",
|
|
8822
|
+
f: "ꜰ",
|
|
8823
|
+
g: "ɢ",
|
|
8824
|
+
h: "ʜ",
|
|
8825
|
+
i: "ɪ",
|
|
8826
|
+
j: "ᴊ",
|
|
8827
|
+
k: "ᴋ",
|
|
8828
|
+
l: "ʟ",
|
|
8829
|
+
m: "ᴍ",
|
|
8830
|
+
n: "ɴ",
|
|
8831
|
+
o: "ᴏ",
|
|
8832
|
+
p: "ᴘ",
|
|
8833
|
+
q: "ǫ",
|
|
8834
|
+
r: "ʀ",
|
|
8835
|
+
s: "s",
|
|
8836
|
+
t: "ᴛ",
|
|
8837
|
+
u: "ᴜ",
|
|
8838
|
+
v: "ᴠ",
|
|
8839
|
+
w: "ᴡ",
|
|
8840
|
+
x: "x",
|
|
8841
|
+
y: "ʏ",
|
|
8842
|
+
z: "ᴢ"
|
|
8843
|
+
});
|
|
8844
|
+
|
|
8845
|
+
const varNameFonts = ["mathrm", "mathit"];
|
|
8846
|
+
|
|
8594
8847
|
const isLongVariableName = (group, font) => {
|
|
8595
|
-
if (font
|
|
8848
|
+
if (!varNameFonts.includes(font) || !group.body || group.body.type !== "ordgroup" ||
|
|
8849
|
+
group.body.body.length === 1) {
|
|
8596
8850
|
return false
|
|
8597
8851
|
}
|
|
8598
8852
|
if (group.body.body[0].type !== "mathord") { return false }
|
|
@@ -8618,8 +8872,7 @@ const mathmlBuilder$6 = (group, style) => {
|
|
|
8618
8872
|
}
|
|
8619
8873
|
// Check if it is possible to consolidate elements into a single <mi> element.
|
|
8620
8874
|
if (isLongVariableName(group, font)) {
|
|
8621
|
-
// This is a \mathrm{…} group. It gets special treatment
|
|
8622
|
-
// wraps <mi> elements with <mpadded>s to work around a Firefox bug.
|
|
8875
|
+
// This is a \mathrm{…} or \mathit{…} group. It gets special treatment.
|
|
8623
8876
|
const mi = mathGroup.children[0].children[0].children
|
|
8624
8877
|
? mathGroup.children[0].children[0]
|
|
8625
8878
|
: mathGroup.children[0];
|
|
@@ -8629,7 +8882,14 @@ const mathmlBuilder$6 = (group, style) => {
|
|
|
8629
8882
|
? mathGroup.children[i].children[0].children[0].text
|
|
8630
8883
|
: mathGroup.children[i].children[0].text;
|
|
8631
8884
|
}
|
|
8632
|
-
|
|
8885
|
+
if (font === "mathit") {
|
|
8886
|
+
// Long <mi> elements are normally rendered in upright font.
|
|
8887
|
+
// To get italic, we need to convert each character to the corresponding italic character.
|
|
8888
|
+
mi.children[0].text = mi.children[0].text.split("")
|
|
8889
|
+
.map(c => variantChar(c, "italic")).join("");
|
|
8890
|
+
return mi
|
|
8891
|
+
}
|
|
8892
|
+
// Otherwise, font is "mathrm". Wrap in a <mpadded> to prevent a Firefox spacing bug.
|
|
8633
8893
|
const mpadded = new MathNode("mpadded", [mi]);
|
|
8634
8894
|
mpadded.setAttribute("lspace", "0");
|
|
8635
8895
|
return mpadded
|
|
@@ -10507,7 +10767,7 @@ defineFunction({
|
|
|
10507
10767
|
const inner = buildExpression(ordargument(group.body), style);
|
|
10508
10768
|
const phantom = new MathNode("mphantom", inner);
|
|
10509
10769
|
const node = new MathNode("mpadded", [phantom]);
|
|
10510
|
-
node.setAttribute("width", "
|
|
10770
|
+
node.setAttribute("width", "0.1px");
|
|
10511
10771
|
return node;
|
|
10512
10772
|
}
|
|
10513
10773
|
});
|
|
@@ -11324,232 +11584,6 @@ const getVariant = function(group, style) {
|
|
|
11324
11584
|
return Object.prototype.hasOwnProperty.call(fontMap, font) ? fontMap[font] : null
|
|
11325
11585
|
};
|
|
11326
11586
|
|
|
11327
|
-
// Chromium does not support the MathML `mathvariant` attribute.
|
|
11328
|
-
// Instead, we replace ASCII characters with Unicode characters that
|
|
11329
|
-
// are defined in the font as bold, italic, double-struck, etc.
|
|
11330
|
-
// This module identifies those Unicode code points.
|
|
11331
|
-
|
|
11332
|
-
// First, a few helpers.
|
|
11333
|
-
const script = Object.freeze({
|
|
11334
|
-
B: 0x20EA, // Offset from ASCII B to Unicode script B
|
|
11335
|
-
E: 0x20EB,
|
|
11336
|
-
F: 0x20EB,
|
|
11337
|
-
H: 0x20C3,
|
|
11338
|
-
I: 0x20C7,
|
|
11339
|
-
L: 0x20C6,
|
|
11340
|
-
M: 0x20E6,
|
|
11341
|
-
R: 0x20C9,
|
|
11342
|
-
e: 0x20CA,
|
|
11343
|
-
g: 0x20A3,
|
|
11344
|
-
o: 0x20C5
|
|
11345
|
-
});
|
|
11346
|
-
|
|
11347
|
-
const frak = Object.freeze({
|
|
11348
|
-
C: 0x20EA,
|
|
11349
|
-
H: 0x20C4,
|
|
11350
|
-
I: 0x20C8,
|
|
11351
|
-
R: 0x20CA,
|
|
11352
|
-
Z: 0x20CE
|
|
11353
|
-
});
|
|
11354
|
-
|
|
11355
|
-
const bbb = Object.freeze({
|
|
11356
|
-
C: 0x20BF, // blackboard bold
|
|
11357
|
-
H: 0x20C5,
|
|
11358
|
-
N: 0x20C7,
|
|
11359
|
-
P: 0x20C9,
|
|
11360
|
-
Q: 0x20C9,
|
|
11361
|
-
R: 0x20CB,
|
|
11362
|
-
Z: 0x20CA
|
|
11363
|
-
});
|
|
11364
|
-
|
|
11365
|
-
const bold = Object.freeze({
|
|
11366
|
-
"\u03f5": 0x1D2E7, // lunate epsilon
|
|
11367
|
-
"\u03d1": 0x1D30C, // vartheta
|
|
11368
|
-
"\u03f0": 0x1D2EE, // varkappa
|
|
11369
|
-
"\u03c6": 0x1D319, // varphi
|
|
11370
|
-
"\u03f1": 0x1D2EF, // varrho
|
|
11371
|
-
"\u03d6": 0x1D30B // varpi
|
|
11372
|
-
});
|
|
11373
|
-
|
|
11374
|
-
const boldItalic = Object.freeze({
|
|
11375
|
-
"\u03f5": 0x1D35B, // lunate epsilon
|
|
11376
|
-
"\u03d1": 0x1D380, // vartheta
|
|
11377
|
-
"\u03f0": 0x1D362, // varkappa
|
|
11378
|
-
"\u03c6": 0x1D38D, // varphi
|
|
11379
|
-
"\u03f1": 0x1D363, // varrho
|
|
11380
|
-
"\u03d6": 0x1D37F // varpi
|
|
11381
|
-
});
|
|
11382
|
-
|
|
11383
|
-
const boldsf = Object.freeze({
|
|
11384
|
-
"\u03f5": 0x1D395, // lunate epsilon
|
|
11385
|
-
"\u03d1": 0x1D3BA, // vartheta
|
|
11386
|
-
"\u03f0": 0x1D39C, // varkappa
|
|
11387
|
-
"\u03c6": 0x1D3C7, // varphi
|
|
11388
|
-
"\u03f1": 0x1D39D, // varrho
|
|
11389
|
-
"\u03d6": 0x1D3B9 // varpi
|
|
11390
|
-
});
|
|
11391
|
-
|
|
11392
|
-
const bisf = Object.freeze({
|
|
11393
|
-
"\u03f5": 0x1D3CF, // lunate epsilon
|
|
11394
|
-
"\u03d1": 0x1D3F4, // vartheta
|
|
11395
|
-
"\u03f0": 0x1D3D6, // varkappa
|
|
11396
|
-
"\u03c6": 0x1D401, // varphi
|
|
11397
|
-
"\u03f1": 0x1D3D7, // varrho
|
|
11398
|
-
"\u03d6": 0x1D3F3 // varpi
|
|
11399
|
-
});
|
|
11400
|
-
|
|
11401
|
-
// Code point offsets below are derived from https://www.unicode.org/charts/PDF/U1D400.pdf
|
|
11402
|
-
const offset = Object.freeze({
|
|
11403
|
-
upperCaseLatin: { // A-Z
|
|
11404
|
-
"normal": ch => { return 0 },
|
|
11405
|
-
"bold": ch => { return 0x1D3BF },
|
|
11406
|
-
"italic": ch => { return 0x1D3F3 },
|
|
11407
|
-
"bold-italic": ch => { return 0x1D427 },
|
|
11408
|
-
"script": ch => { return script[ch] || 0x1D45B },
|
|
11409
|
-
"script-bold": ch => { return 0x1D48F },
|
|
11410
|
-
"fraktur": ch => { return frak[ch] || 0x1D4C3 },
|
|
11411
|
-
"fraktur-bold": ch => { return 0x1D52B },
|
|
11412
|
-
"double-struck": ch => { return bbb[ch] || 0x1D4F7 },
|
|
11413
|
-
"sans-serif": ch => { return 0x1D55F },
|
|
11414
|
-
"sans-serif-bold": ch => { return 0x1D593 },
|
|
11415
|
-
"sans-serif-italic": ch => { return 0x1D5C7 },
|
|
11416
|
-
"sans-serif-bold-italic": ch => { return 0x1D63C },
|
|
11417
|
-
"monospace": ch => { return 0x1D62F }
|
|
11418
|
-
},
|
|
11419
|
-
lowerCaseLatin: { // a-z
|
|
11420
|
-
"normal": ch => { return 0 },
|
|
11421
|
-
"bold": ch => { return 0x1D3B9 },
|
|
11422
|
-
"italic": ch => { return ch === "h" ? 0x20A6 : 0x1D3ED },
|
|
11423
|
-
"bold-italic": ch => { return 0x1D421 },
|
|
11424
|
-
"script": ch => { return script[ch] || 0x1D455 },
|
|
11425
|
-
"script-bold": ch => { return 0x1D489 },
|
|
11426
|
-
"fraktur": ch => { return 0x1D4BD },
|
|
11427
|
-
"fraktur-bold": ch => { return 0x1D525 },
|
|
11428
|
-
"double-struck": ch => { return 0x1D4F1 },
|
|
11429
|
-
"sans-serif": ch => { return 0x1D559 },
|
|
11430
|
-
"sans-serif-bold": ch => { return 0x1D58D },
|
|
11431
|
-
"sans-serif-italic": ch => { return 0x1D5C1 },
|
|
11432
|
-
"sans-serif-bold-italic": ch => { return 0x1D5F5 },
|
|
11433
|
-
"monospace": ch => { return 0x1D629 }
|
|
11434
|
-
},
|
|
11435
|
-
upperCaseGreek: { // A-Ω
|
|
11436
|
-
"normal": ch => { return 0 },
|
|
11437
|
-
"bold": ch => { return 0x1D317 },
|
|
11438
|
-
"italic": ch => { return 0x1D351 },
|
|
11439
|
-
// \boldsymbol actually returns upright bold for upperCaseGreek
|
|
11440
|
-
"bold-italic": ch => { return 0x1D317 },
|
|
11441
|
-
"script": ch => { return 0 },
|
|
11442
|
-
"script-bold": ch => { return 0 },
|
|
11443
|
-
"fraktur": ch => { return 0 },
|
|
11444
|
-
"fraktur-bold": ch => { return 0 },
|
|
11445
|
-
"double-struck": ch => { return 0 },
|
|
11446
|
-
// Unicode has no code points for regular-weight san-serif Greek. Use bold.
|
|
11447
|
-
"sans-serif": ch => { return 0x1D3C5 },
|
|
11448
|
-
"sans-serif-bold": ch => { return 0x1D3C5 },
|
|
11449
|
-
"sans-serif-italic": ch => { return 0 },
|
|
11450
|
-
"sans-serif-bold-italic": ch => { return 0x1D3FF },
|
|
11451
|
-
"monospace": ch => { return 0 }
|
|
11452
|
-
},
|
|
11453
|
-
lowerCaseGreek: { // α-ω
|
|
11454
|
-
"normal": ch => { return 0 },
|
|
11455
|
-
"bold": ch => { return 0x1D311 },
|
|
11456
|
-
"italic": ch => { return 0x1D34B },
|
|
11457
|
-
"bold-italic": ch => { return ch === "\u03d5" ? 0x1D37E : 0x1D385 },
|
|
11458
|
-
"script": ch => { return 0 },
|
|
11459
|
-
"script-bold": ch => { return 0 },
|
|
11460
|
-
"fraktur": ch => { return 0 },
|
|
11461
|
-
"fraktur-bold": ch => { return 0 },
|
|
11462
|
-
"double-struck": ch => { return 0 },
|
|
11463
|
-
// Unicode has no code points for regular-weight san-serif Greek. Use bold.
|
|
11464
|
-
"sans-serif": ch => { return 0x1D3BF },
|
|
11465
|
-
"sans-serif-bold": ch => { return 0x1D3BF },
|
|
11466
|
-
"sans-serif-italic": ch => { return 0 },
|
|
11467
|
-
"sans-serif-bold-italic": ch => { return 0x1D3F9 },
|
|
11468
|
-
"monospace": ch => { return 0 }
|
|
11469
|
-
},
|
|
11470
|
-
varGreek: { // \varGamma, etc
|
|
11471
|
-
"normal": ch => { return 0 },
|
|
11472
|
-
"bold": ch => { return bold[ch] || -51 },
|
|
11473
|
-
"italic": ch => { return 0 },
|
|
11474
|
-
"bold-italic": ch => { return boldItalic[ch] || 0x3A },
|
|
11475
|
-
"script": ch => { return 0 },
|
|
11476
|
-
"script-bold": ch => { return 0 },
|
|
11477
|
-
"fraktur": ch => { return 0 },
|
|
11478
|
-
"fraktur-bold": ch => { return 0 },
|
|
11479
|
-
"double-struck": ch => { return 0 },
|
|
11480
|
-
"sans-serif": ch => { return boldsf[ch] || 0x74 },
|
|
11481
|
-
"sans-serif-bold": ch => { return boldsf[ch] || 0x74 },
|
|
11482
|
-
"sans-serif-italic": ch => { return 0 },
|
|
11483
|
-
"sans-serif-bold-italic": ch => { return bisf[ch] || 0xAE },
|
|
11484
|
-
"monospace": ch => { return 0 }
|
|
11485
|
-
},
|
|
11486
|
-
numeral: { // 0-9
|
|
11487
|
-
"normal": ch => { return 0 },
|
|
11488
|
-
"bold": ch => { return 0x1D79E },
|
|
11489
|
-
"italic": ch => { return 0 },
|
|
11490
|
-
"bold-italic": ch => { return 0 },
|
|
11491
|
-
"script": ch => { return 0 },
|
|
11492
|
-
"script-bold": ch => { return 0 },
|
|
11493
|
-
"fraktur": ch => { return 0 },
|
|
11494
|
-
"fraktur-bold": ch => { return 0 },
|
|
11495
|
-
"double-struck": ch => { return 0x1D7A8 },
|
|
11496
|
-
"sans-serif": ch => { return 0x1D7B2 },
|
|
11497
|
-
"sans-serif-bold": ch => { return 0x1D7BC },
|
|
11498
|
-
"sans-serif-italic": ch => { return 0 },
|
|
11499
|
-
"sans-serif-bold-italic": ch => { return 0 },
|
|
11500
|
-
"monospace": ch => { return 0x1D7C6 }
|
|
11501
|
-
}
|
|
11502
|
-
});
|
|
11503
|
-
|
|
11504
|
-
const variantChar = (ch, variant) => {
|
|
11505
|
-
const codePoint = ch.codePointAt(0);
|
|
11506
|
-
const block = 0x40 < codePoint && codePoint < 0x5b
|
|
11507
|
-
? "upperCaseLatin"
|
|
11508
|
-
: 0x60 < codePoint && codePoint < 0x7b
|
|
11509
|
-
? "lowerCaseLatin"
|
|
11510
|
-
: (0x390 < codePoint && codePoint < 0x3AA)
|
|
11511
|
-
? "upperCaseGreek"
|
|
11512
|
-
: 0x3B0 < codePoint && codePoint < 0x3CA || ch === "\u03d5"
|
|
11513
|
-
? "lowerCaseGreek"
|
|
11514
|
-
: 0x1D6E1 < codePoint && codePoint < 0x1D6FC || bold[ch]
|
|
11515
|
-
? "varGreek"
|
|
11516
|
-
: (0x2F < codePoint && codePoint < 0x3A)
|
|
11517
|
-
? "numeral"
|
|
11518
|
-
: "other";
|
|
11519
|
-
return block === "other"
|
|
11520
|
-
? ch
|
|
11521
|
-
: String.fromCodePoint(codePoint + offset[block][variant](ch))
|
|
11522
|
-
};
|
|
11523
|
-
|
|
11524
|
-
const smallCaps = Object.freeze({
|
|
11525
|
-
a: "ᴀ",
|
|
11526
|
-
b: "ʙ",
|
|
11527
|
-
c: "ᴄ",
|
|
11528
|
-
d: "ᴅ",
|
|
11529
|
-
e: "ᴇ",
|
|
11530
|
-
f: "ꜰ",
|
|
11531
|
-
g: "ɢ",
|
|
11532
|
-
h: "ʜ",
|
|
11533
|
-
i: "ɪ",
|
|
11534
|
-
j: "ᴊ",
|
|
11535
|
-
k: "ᴋ",
|
|
11536
|
-
l: "ʟ",
|
|
11537
|
-
m: "ᴍ",
|
|
11538
|
-
n: "ɴ",
|
|
11539
|
-
o: "ᴏ",
|
|
11540
|
-
p: "ᴘ",
|
|
11541
|
-
q: "ǫ",
|
|
11542
|
-
r: "ʀ",
|
|
11543
|
-
s: "s",
|
|
11544
|
-
t: "ᴛ",
|
|
11545
|
-
u: "ᴜ",
|
|
11546
|
-
v: "ᴠ",
|
|
11547
|
-
w: "ᴡ",
|
|
11548
|
-
x: "x",
|
|
11549
|
-
y: "ʏ",
|
|
11550
|
-
z: "ᴢ"
|
|
11551
|
-
});
|
|
11552
|
-
|
|
11553
11587
|
// "mathord" and "textord" ParseNodes created in Parser.js from symbol Groups in
|
|
11554
11588
|
// src/symbols.js.
|
|
11555
11589
|
|
|
@@ -12169,7 +12203,7 @@ class MacroExpander {
|
|
|
12169
12203
|
this.pushToken(new Token("EOF", end.loc));
|
|
12170
12204
|
|
|
12171
12205
|
this.pushTokens(tokens);
|
|
12172
|
-
return
|
|
12206
|
+
return new Token("", SourceLocation.range(start, end));
|
|
12173
12207
|
}
|
|
12174
12208
|
|
|
12175
12209
|
/**
|
|
@@ -14174,7 +14208,7 @@ class Style {
|
|
|
14174
14208
|
* https://mit-license.org/
|
|
14175
14209
|
*/
|
|
14176
14210
|
|
|
14177
|
-
const version = "0.13.
|
|
14211
|
+
const version = "0.13.4";
|
|
14178
14212
|
|
|
14179
14213
|
function postProcess(block) {
|
|
14180
14214
|
const labelMap = {};
|