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