temml 0.13.2 → 0.13.3
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 +5 -0
- package/dist/Temml-Latin-Modern.css +5 -0
- package/dist/Temml-Libertinus.css +5 -0
- package/dist/Temml-Local.css +5 -0
- package/dist/Temml-NotoSans.css +5 -0
- package/dist/Temml-STIX2.css +5 -0
- package/dist/temml.cjs +275 -252
- package/dist/temml.js +275 -252
- package/dist/temml.min.js +1 -1
- package/dist/temml.mjs +275 -252
- 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/dist/temml.mjs
CHANGED
|
@@ -6518,9 +6518,9 @@ const mathmlBuilder$9 = function(group, style) {
|
|
|
6518
6518
|
}
|
|
6519
6519
|
if (mustSquashRow) {
|
|
6520
6520
|
// All the cell contents are \hphantom. Squash the cell.
|
|
6521
|
+
// TODO: Remove the next line when Firefox no longer needs it.
|
|
6522
|
+
mtr.classes.push("ff-squash"); // necessary in Firefox only.
|
|
6521
6523
|
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
6524
|
mtr.children[j].style.paddingTop = "0";
|
|
6525
6525
|
mtr.children[j].style.paddingBottom = "0";
|
|
6526
6526
|
}
|
|
@@ -7161,13 +7161,11 @@ defineFunction({
|
|
|
7161
7161
|
},
|
|
7162
7162
|
handler: ({ parser, funcName }, args, optArgs) => {
|
|
7163
7163
|
// Find out if the author has defined custom delimiters
|
|
7164
|
-
let delimiters = ["(", ")"];
|
|
7164
|
+
let delimiters = ["(", ")"]; // default
|
|
7165
7165
|
if (funcName === "\\bordermatrix" && optArgs[0] && optArgs[0].body) {
|
|
7166
7166
|
const body = optArgs[0].body;
|
|
7167
|
-
if (body.length ===
|
|
7168
|
-
|
|
7169
|
-
delimiters = [body[0].text, body[1].text];
|
|
7170
|
-
}
|
|
7167
|
+
if (body.length === 1 && body[0].type === "delimiter") {
|
|
7168
|
+
delimiters = [body[0].left, body[0].right];
|
|
7171
7169
|
}
|
|
7172
7170
|
}
|
|
7173
7171
|
// consume the opening brace
|
|
@@ -8263,17 +8261,14 @@ defineFunction({
|
|
|
8263
8261
|
mathmlBuilder: (group) => {
|
|
8264
8262
|
const textNode = makeText(group.delim, group.mode);
|
|
8265
8263
|
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");
|
|
8264
|
+
middleNode.setAttribute("stretchy", "true");
|
|
8265
|
+
middleNode.setAttribute("form", "infix");
|
|
8266
|
+
if (textNode.text !== "/") {
|
|
8267
|
+
// MathML gives 5/18em spacing to each <mo> element.
|
|
8268
|
+
// \middle should get delimiter spacing instead.
|
|
8269
|
+
middleNode.setAttribute("lspace", "0.05em");
|
|
8270
|
+
middleNode.setAttribute("rspace", "0.05em");
|
|
8271
|
+
}
|
|
8277
8272
|
return middleNode;
|
|
8278
8273
|
}
|
|
8279
8274
|
});
|
|
@@ -8440,7 +8435,7 @@ defineFunction({
|
|
|
8440
8435
|
|
|
8441
8436
|
defineFunction({
|
|
8442
8437
|
type: "enclose",
|
|
8443
|
-
names: ["\\angl", "\\cancel", "\\bcancel", "\\xcancel", "\\
|
|
8438
|
+
names: ["\\angl", "\\cancel", "\\bcancel", "\\xcancel", "\\overline",
|
|
8444
8439
|
"\\boxed", "\\longdiv", "\\phase"],
|
|
8445
8440
|
props: {
|
|
8446
8441
|
numArgs: 1
|
|
@@ -8457,6 +8452,25 @@ defineFunction({
|
|
|
8457
8452
|
mathmlBuilder: mathmlBuilder$7
|
|
8458
8453
|
});
|
|
8459
8454
|
|
|
8455
|
+
defineFunction({
|
|
8456
|
+
type: "enclose",
|
|
8457
|
+
names: ["\\sout"],
|
|
8458
|
+
props: {
|
|
8459
|
+
numArgs: 1,
|
|
8460
|
+
allowedInText: true
|
|
8461
|
+
},
|
|
8462
|
+
handler({ parser, funcName }, args) {
|
|
8463
|
+
const body = args[0];
|
|
8464
|
+
return {
|
|
8465
|
+
type: "enclose",
|
|
8466
|
+
mode: parser.mode,
|
|
8467
|
+
label: funcName,
|
|
8468
|
+
body
|
|
8469
|
+
};
|
|
8470
|
+
},
|
|
8471
|
+
mathmlBuilder: mathmlBuilder$7
|
|
8472
|
+
});
|
|
8473
|
+
|
|
8460
8474
|
defineFunction({
|
|
8461
8475
|
type: "enclose",
|
|
8462
8476
|
names: ["\\underline"],
|
|
@@ -8589,8 +8603,237 @@ defineFunction({
|
|
|
8589
8603
|
}
|
|
8590
8604
|
});
|
|
8591
8605
|
|
|
8606
|
+
// Chromium does not support the MathML `mathvariant` attribute.
|
|
8607
|
+
// Instead, we replace ASCII characters with Unicode characters that
|
|
8608
|
+
// are defined in the font as bold, italic, double-struck, etc.
|
|
8609
|
+
// This module identifies those Unicode code points.
|
|
8610
|
+
|
|
8611
|
+
// First, a few helpers.
|
|
8612
|
+
const script = Object.freeze({
|
|
8613
|
+
B: 0x20EA, // Offset from ASCII B to Unicode script B
|
|
8614
|
+
E: 0x20EB,
|
|
8615
|
+
F: 0x20EB,
|
|
8616
|
+
H: 0x20C3,
|
|
8617
|
+
I: 0x20C7,
|
|
8618
|
+
L: 0x20C6,
|
|
8619
|
+
M: 0x20E6,
|
|
8620
|
+
R: 0x20C9,
|
|
8621
|
+
e: 0x20CA,
|
|
8622
|
+
g: 0x20A3,
|
|
8623
|
+
o: 0x20C5
|
|
8624
|
+
});
|
|
8625
|
+
|
|
8626
|
+
const frak = Object.freeze({
|
|
8627
|
+
C: 0x20EA,
|
|
8628
|
+
H: 0x20C4,
|
|
8629
|
+
I: 0x20C8,
|
|
8630
|
+
R: 0x20CA,
|
|
8631
|
+
Z: 0x20CE
|
|
8632
|
+
});
|
|
8633
|
+
|
|
8634
|
+
const bbb = Object.freeze({
|
|
8635
|
+
C: 0x20BF, // blackboard bold
|
|
8636
|
+
H: 0x20C5,
|
|
8637
|
+
N: 0x20C7,
|
|
8638
|
+
P: 0x20C9,
|
|
8639
|
+
Q: 0x20C9,
|
|
8640
|
+
R: 0x20CB,
|
|
8641
|
+
Z: 0x20CA
|
|
8642
|
+
});
|
|
8643
|
+
|
|
8644
|
+
const bold = Object.freeze({
|
|
8645
|
+
"\u03f5": 0x1D2E7, // lunate epsilon
|
|
8646
|
+
"\u03d1": 0x1D30C, // vartheta
|
|
8647
|
+
"\u03f0": 0x1D2EE, // varkappa
|
|
8648
|
+
"\u03c6": 0x1D319, // varphi
|
|
8649
|
+
"\u03f1": 0x1D2EF, // varrho
|
|
8650
|
+
"\u03d6": 0x1D30B // varpi
|
|
8651
|
+
});
|
|
8652
|
+
|
|
8653
|
+
const boldItalic = Object.freeze({
|
|
8654
|
+
"\u03f5": 0x1D35B, // lunate epsilon
|
|
8655
|
+
"\u03d1": 0x1D380, // vartheta
|
|
8656
|
+
"\u03f0": 0x1D362, // varkappa
|
|
8657
|
+
"\u03c6": 0x1D38D, // varphi
|
|
8658
|
+
"\u03f1": 0x1D363, // varrho
|
|
8659
|
+
"\u03d6": 0x1D37F // varpi
|
|
8660
|
+
});
|
|
8661
|
+
|
|
8662
|
+
const boldsf = Object.freeze({
|
|
8663
|
+
"\u03f5": 0x1D395, // lunate epsilon
|
|
8664
|
+
"\u03d1": 0x1D3BA, // vartheta
|
|
8665
|
+
"\u03f0": 0x1D39C, // varkappa
|
|
8666
|
+
"\u03c6": 0x1D3C7, // varphi
|
|
8667
|
+
"\u03f1": 0x1D39D, // varrho
|
|
8668
|
+
"\u03d6": 0x1D3B9 // varpi
|
|
8669
|
+
});
|
|
8670
|
+
|
|
8671
|
+
const bisf = Object.freeze({
|
|
8672
|
+
"\u03f5": 0x1D3CF, // lunate epsilon
|
|
8673
|
+
"\u03d1": 0x1D3F4, // vartheta
|
|
8674
|
+
"\u03f0": 0x1D3D6, // varkappa
|
|
8675
|
+
"\u03c6": 0x1D401, // varphi
|
|
8676
|
+
"\u03f1": 0x1D3D7, // varrho
|
|
8677
|
+
"\u03d6": 0x1D3F3 // varpi
|
|
8678
|
+
});
|
|
8679
|
+
|
|
8680
|
+
// Code point offsets below are derived from https://www.unicode.org/charts/PDF/U1D400.pdf
|
|
8681
|
+
const offset = Object.freeze({
|
|
8682
|
+
upperCaseLatin: { // A-Z
|
|
8683
|
+
"normal": ch => { return 0 },
|
|
8684
|
+
"bold": ch => { return 0x1D3BF },
|
|
8685
|
+
"italic": ch => { return 0x1D3F3 },
|
|
8686
|
+
"bold-italic": ch => { return 0x1D427 },
|
|
8687
|
+
"script": ch => { return script[ch] || 0x1D45B },
|
|
8688
|
+
"script-bold": ch => { return 0x1D48F },
|
|
8689
|
+
"fraktur": ch => { return frak[ch] || 0x1D4C3 },
|
|
8690
|
+
"fraktur-bold": ch => { return 0x1D52B },
|
|
8691
|
+
"double-struck": ch => { return bbb[ch] || 0x1D4F7 },
|
|
8692
|
+
"sans-serif": ch => { return 0x1D55F },
|
|
8693
|
+
"sans-serif-bold": ch => { return 0x1D593 },
|
|
8694
|
+
"sans-serif-italic": ch => { return 0x1D5C7 },
|
|
8695
|
+
"sans-serif-bold-italic": ch => { return 0x1D63C },
|
|
8696
|
+
"monospace": ch => { return 0x1D62F }
|
|
8697
|
+
},
|
|
8698
|
+
lowerCaseLatin: { // a-z
|
|
8699
|
+
"normal": ch => { return 0 },
|
|
8700
|
+
"bold": ch => { return 0x1D3B9 },
|
|
8701
|
+
"italic": ch => { return ch === "h" ? 0x20A6 : 0x1D3ED },
|
|
8702
|
+
"bold-italic": ch => { return 0x1D421 },
|
|
8703
|
+
"script": ch => { return script[ch] || 0x1D455 },
|
|
8704
|
+
"script-bold": ch => { return 0x1D489 },
|
|
8705
|
+
"fraktur": ch => { return 0x1D4BD },
|
|
8706
|
+
"fraktur-bold": ch => { return 0x1D525 },
|
|
8707
|
+
"double-struck": ch => { return 0x1D4F1 },
|
|
8708
|
+
"sans-serif": ch => { return 0x1D559 },
|
|
8709
|
+
"sans-serif-bold": ch => { return 0x1D58D },
|
|
8710
|
+
"sans-serif-italic": ch => { return 0x1D5C1 },
|
|
8711
|
+
"sans-serif-bold-italic": ch => { return 0x1D5F5 },
|
|
8712
|
+
"monospace": ch => { return 0x1D629 }
|
|
8713
|
+
},
|
|
8714
|
+
upperCaseGreek: { // A-Ω
|
|
8715
|
+
"normal": ch => { return 0 },
|
|
8716
|
+
"bold": ch => { return 0x1D317 },
|
|
8717
|
+
"italic": ch => { return 0x1D351 },
|
|
8718
|
+
// \boldsymbol actually returns upright bold for upperCaseGreek
|
|
8719
|
+
"bold-italic": ch => { return 0x1D317 },
|
|
8720
|
+
"script": ch => { return 0 },
|
|
8721
|
+
"script-bold": ch => { return 0 },
|
|
8722
|
+
"fraktur": ch => { return 0 },
|
|
8723
|
+
"fraktur-bold": ch => { return 0 },
|
|
8724
|
+
"double-struck": ch => { return 0 },
|
|
8725
|
+
// Unicode has no code points for regular-weight san-serif Greek. Use bold.
|
|
8726
|
+
"sans-serif": ch => { return 0x1D3C5 },
|
|
8727
|
+
"sans-serif-bold": ch => { return 0x1D3C5 },
|
|
8728
|
+
"sans-serif-italic": ch => { return 0 },
|
|
8729
|
+
"sans-serif-bold-italic": ch => { return 0x1D3FF },
|
|
8730
|
+
"monospace": ch => { return 0 }
|
|
8731
|
+
},
|
|
8732
|
+
lowerCaseGreek: { // α-ω
|
|
8733
|
+
"normal": ch => { return 0 },
|
|
8734
|
+
"bold": ch => { return 0x1D311 },
|
|
8735
|
+
"italic": ch => { return 0x1D34B },
|
|
8736
|
+
"bold-italic": ch => { return ch === "\u03d5" ? 0x1D37E : 0x1D385 },
|
|
8737
|
+
"script": ch => { return 0 },
|
|
8738
|
+
"script-bold": ch => { return 0 },
|
|
8739
|
+
"fraktur": ch => { return 0 },
|
|
8740
|
+
"fraktur-bold": ch => { return 0 },
|
|
8741
|
+
"double-struck": ch => { return 0 },
|
|
8742
|
+
// Unicode has no code points for regular-weight san-serif Greek. Use bold.
|
|
8743
|
+
"sans-serif": ch => { return 0x1D3BF },
|
|
8744
|
+
"sans-serif-bold": ch => { return 0x1D3BF },
|
|
8745
|
+
"sans-serif-italic": ch => { return 0 },
|
|
8746
|
+
"sans-serif-bold-italic": ch => { return 0x1D3F9 },
|
|
8747
|
+
"monospace": ch => { return 0 }
|
|
8748
|
+
},
|
|
8749
|
+
varGreek: { // \varGamma, etc
|
|
8750
|
+
"normal": ch => { return 0 },
|
|
8751
|
+
"bold": ch => { return bold[ch] || -51 },
|
|
8752
|
+
"italic": ch => { return 0 },
|
|
8753
|
+
"bold-italic": ch => { return boldItalic[ch] || 0x3A },
|
|
8754
|
+
"script": ch => { return 0 },
|
|
8755
|
+
"script-bold": ch => { return 0 },
|
|
8756
|
+
"fraktur": ch => { return 0 },
|
|
8757
|
+
"fraktur-bold": ch => { return 0 },
|
|
8758
|
+
"double-struck": ch => { return 0 },
|
|
8759
|
+
"sans-serif": ch => { return boldsf[ch] || 0x74 },
|
|
8760
|
+
"sans-serif-bold": ch => { return boldsf[ch] || 0x74 },
|
|
8761
|
+
"sans-serif-italic": ch => { return 0 },
|
|
8762
|
+
"sans-serif-bold-italic": ch => { return bisf[ch] || 0xAE },
|
|
8763
|
+
"monospace": ch => { return 0 }
|
|
8764
|
+
},
|
|
8765
|
+
numeral: { // 0-9
|
|
8766
|
+
"normal": ch => { return 0 },
|
|
8767
|
+
"bold": ch => { return 0x1D79E },
|
|
8768
|
+
"italic": ch => { return 0 },
|
|
8769
|
+
"bold-italic": ch => { return 0 },
|
|
8770
|
+
"script": ch => { return 0 },
|
|
8771
|
+
"script-bold": ch => { return 0 },
|
|
8772
|
+
"fraktur": ch => { return 0 },
|
|
8773
|
+
"fraktur-bold": ch => { return 0 },
|
|
8774
|
+
"double-struck": ch => { return 0x1D7A8 },
|
|
8775
|
+
"sans-serif": ch => { return 0x1D7B2 },
|
|
8776
|
+
"sans-serif-bold": ch => { return 0x1D7BC },
|
|
8777
|
+
"sans-serif-italic": ch => { return 0 },
|
|
8778
|
+
"sans-serif-bold-italic": ch => { return 0 },
|
|
8779
|
+
"monospace": ch => { return 0x1D7C6 }
|
|
8780
|
+
}
|
|
8781
|
+
});
|
|
8782
|
+
|
|
8783
|
+
const variantChar = (ch, variant) => {
|
|
8784
|
+
const codePoint = ch.codePointAt(0);
|
|
8785
|
+
const block = 0x40 < codePoint && codePoint < 0x5b
|
|
8786
|
+
? "upperCaseLatin"
|
|
8787
|
+
: 0x60 < codePoint && codePoint < 0x7b
|
|
8788
|
+
? "lowerCaseLatin"
|
|
8789
|
+
: (0x390 < codePoint && codePoint < 0x3AA)
|
|
8790
|
+
? "upperCaseGreek"
|
|
8791
|
+
: 0x3B0 < codePoint && codePoint < 0x3CA || ch === "\u03d5"
|
|
8792
|
+
? "lowerCaseGreek"
|
|
8793
|
+
: 0x1D6E1 < codePoint && codePoint < 0x1D6FC || bold[ch]
|
|
8794
|
+
? "varGreek"
|
|
8795
|
+
: (0x2F < codePoint && codePoint < 0x3A)
|
|
8796
|
+
? "numeral"
|
|
8797
|
+
: "other";
|
|
8798
|
+
return block === "other"
|
|
8799
|
+
? ch
|
|
8800
|
+
: String.fromCodePoint(codePoint + offset[block][variant](ch))
|
|
8801
|
+
};
|
|
8802
|
+
|
|
8803
|
+
const smallCaps = Object.freeze({
|
|
8804
|
+
a: "ᴀ",
|
|
8805
|
+
b: "ʙ",
|
|
8806
|
+
c: "ᴄ",
|
|
8807
|
+
d: "ᴅ",
|
|
8808
|
+
e: "ᴇ",
|
|
8809
|
+
f: "ꜰ",
|
|
8810
|
+
g: "ɢ",
|
|
8811
|
+
h: "ʜ",
|
|
8812
|
+
i: "ɪ",
|
|
8813
|
+
j: "ᴊ",
|
|
8814
|
+
k: "ᴋ",
|
|
8815
|
+
l: "ʟ",
|
|
8816
|
+
m: "ᴍ",
|
|
8817
|
+
n: "ɴ",
|
|
8818
|
+
o: "ᴏ",
|
|
8819
|
+
p: "ᴘ",
|
|
8820
|
+
q: "ǫ",
|
|
8821
|
+
r: "ʀ",
|
|
8822
|
+
s: "s",
|
|
8823
|
+
t: "ᴛ",
|
|
8824
|
+
u: "ᴜ",
|
|
8825
|
+
v: "ᴠ",
|
|
8826
|
+
w: "ᴡ",
|
|
8827
|
+
x: "x",
|
|
8828
|
+
y: "ʏ",
|
|
8829
|
+
z: "ᴢ"
|
|
8830
|
+
});
|
|
8831
|
+
|
|
8832
|
+
const varNameFonts = ["mathrm", "mathit"];
|
|
8833
|
+
|
|
8592
8834
|
const isLongVariableName = (group, font) => {
|
|
8593
|
-
if (font
|
|
8835
|
+
if (!varNameFonts.includes(font) || !group.body || group.body.type !== "ordgroup" ||
|
|
8836
|
+
group.body.body.length === 1) {
|
|
8594
8837
|
return false
|
|
8595
8838
|
}
|
|
8596
8839
|
if (group.body.body[0].type !== "mathord") { return false }
|
|
@@ -8616,8 +8859,7 @@ const mathmlBuilder$6 = (group, style) => {
|
|
|
8616
8859
|
}
|
|
8617
8860
|
// Check if it is possible to consolidate elements into a single <mi> element.
|
|
8618
8861
|
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.
|
|
8862
|
+
// This is a \mathrm{…} or \mathit{…} group. It gets special treatment.
|
|
8621
8863
|
const mi = mathGroup.children[0].children[0].children
|
|
8622
8864
|
? mathGroup.children[0].children[0]
|
|
8623
8865
|
: mathGroup.children[0];
|
|
@@ -8627,7 +8869,14 @@ const mathmlBuilder$6 = (group, style) => {
|
|
|
8627
8869
|
? mathGroup.children[i].children[0].children[0].text
|
|
8628
8870
|
: mathGroup.children[i].children[0].text;
|
|
8629
8871
|
}
|
|
8630
|
-
|
|
8872
|
+
if (font === "mathit") {
|
|
8873
|
+
// Long <mi> elements are normally rendered in upright font.
|
|
8874
|
+
// To get italic, we need to convert each character to the corresponding italic character.
|
|
8875
|
+
mi.children[0].text = mi.children[0].text.split("")
|
|
8876
|
+
.map(c => variantChar(c, "italic")).join("");
|
|
8877
|
+
return mi
|
|
8878
|
+
}
|
|
8879
|
+
// Otherwise, font is "mathrm". Wrap in a <mpadded> to prevent a Firefox spacing bug.
|
|
8631
8880
|
const mpadded = new MathNode("mpadded", [mi]);
|
|
8632
8881
|
mpadded.setAttribute("lspace", "0");
|
|
8633
8882
|
return mpadded
|
|
@@ -10505,7 +10754,7 @@ defineFunction({
|
|
|
10505
10754
|
const inner = buildExpression(ordargument(group.body), style);
|
|
10506
10755
|
const phantom = new MathNode("mphantom", inner);
|
|
10507
10756
|
const node = new MathNode("mpadded", [phantom]);
|
|
10508
|
-
node.setAttribute("width", "
|
|
10757
|
+
node.setAttribute("width", "0.1px");
|
|
10509
10758
|
return node;
|
|
10510
10759
|
}
|
|
10511
10760
|
});
|
|
@@ -11322,232 +11571,6 @@ const getVariant = function(group, style) {
|
|
|
11322
11571
|
return Object.prototype.hasOwnProperty.call(fontMap, font) ? fontMap[font] : null
|
|
11323
11572
|
};
|
|
11324
11573
|
|
|
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
11574
|
// "mathord" and "textord" ParseNodes created in Parser.js from symbol Groups in
|
|
11552
11575
|
// src/symbols.js.
|
|
11553
11576
|
|
|
@@ -12167,7 +12190,7 @@ class MacroExpander {
|
|
|
12167
12190
|
this.pushToken(new Token("EOF", end.loc));
|
|
12168
12191
|
|
|
12169
12192
|
this.pushTokens(tokens);
|
|
12170
|
-
return
|
|
12193
|
+
return new Token("", SourceLocation.range(start, end));
|
|
12171
12194
|
}
|
|
12172
12195
|
|
|
12173
12196
|
/**
|
|
@@ -14172,7 +14195,7 @@ class Style {
|
|
|
14172
14195
|
* https://mit-license.org/
|
|
14173
14196
|
*/
|
|
14174
14197
|
|
|
14175
|
-
const version = "0.13.
|
|
14198
|
+
const version = "0.13.3";
|
|
14176
14199
|
|
|
14177
14200
|
function postProcess(block) {
|
|
14178
14201
|
const labelMap = {};
|
package/dist/temmlPostProcess.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "temml",
|
|
3
|
-
"version": "0.13.
|
|
3
|
+
"version": "0.13.3",
|
|
4
4
|
"description": "TeX to MathML conversion in JavaScript.",
|
|
5
5
|
"main": "dist/temml.js",
|
|
6
6
|
"engines": {
|
|
@@ -34,7 +34,8 @@
|
|
|
34
34
|
"esm": "^3.2.25",
|
|
35
35
|
"globals": "^15.9.0",
|
|
36
36
|
"rollup": "^4.59.0",
|
|
37
|
-
"terser": "^5.34.0"
|
|
37
|
+
"terser": "^5.34.0",
|
|
38
|
+
"ws": "^8.20.0"
|
|
38
39
|
},
|
|
39
40
|
"scripts": {
|
|
40
41
|
"lint": "eslint temml.js src",
|
|
@@ -44,6 +45,7 @@
|
|
|
44
45
|
"minify": "terser test/temml.js -o site/assets/temml.min.js -c -m && terser contrib/mhchem/mhchem.js -o site/assets/mhchem.min.js -c -m",
|
|
45
46
|
"build": "rollup --config ./utils/rollupConfig.mjs && yarn minify && node utils/insertPlugins.js",
|
|
46
47
|
"docs": "node utils/buildDocs.js",
|
|
47
|
-
"dist": "yarn build && node ./utils/copyfiles.js"
|
|
48
|
+
"dist": "yarn build && node ./utils/copyfiles.js",
|
|
49
|
+
"serve": "node utils/server.cjs site/docs/en/mathml-status.html 8000"
|
|
48
50
|
}
|
|
49
51
|
}
|
package/src/MacroExpander.js
CHANGED
|
@@ -9,6 +9,7 @@ import Lexer from "./Lexer";
|
|
|
9
9
|
import { Token } from "./Token";
|
|
10
10
|
|
|
11
11
|
import ParseError from "./ParseError";
|
|
12
|
+
import SourceLocation from "./SourceLocation";
|
|
12
13
|
import Namespace from "./Namespace";
|
|
13
14
|
import macros from "./macros";
|
|
14
15
|
|
|
@@ -118,7 +119,7 @@ export default class MacroExpander {
|
|
|
118
119
|
this.pushToken(new Token("EOF", end.loc));
|
|
119
120
|
|
|
120
121
|
this.pushTokens(tokens);
|
|
121
|
-
return
|
|
122
|
+
return new Token("", SourceLocation.range(start, end));
|
|
122
123
|
}
|
|
123
124
|
|
|
124
125
|
/**
|
|
@@ -358,9 +358,9 @@ const mathmlBuilder = function(group, style) {
|
|
|
358
358
|
}
|
|
359
359
|
if (mustSquashRow) {
|
|
360
360
|
// All the cell contents are \hphantom. Squash the cell.
|
|
361
|
+
// TODO: Remove the next line when Firefox no longer needs it.
|
|
362
|
+
mtr.classes.push("ff-squash") // necessary in Firefox only.
|
|
361
363
|
for (let j = 0; j < mtr.children.length; j++) {
|
|
362
|
-
mtr.children[j].style.display = "block" // necessary in Firefox only
|
|
363
|
-
mtr.children[j].style.height = "0" // necessary in Firefox only
|
|
364
364
|
mtr.children[j].style.paddingTop = "0"
|
|
365
365
|
mtr.children[j].style.paddingBottom = "0"
|
|
366
366
|
}
|