temml 0.11.3 → 0.11.5
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 -2
- package/dist/Temml-Latin-Modern.css +5 -2
- package/dist/Temml-Libertinus.css +5 -2
- package/dist/Temml-Local.css +5 -2
- package/dist/Temml-NotoSans.css +5 -2
- package/dist/Temml-STIX2.css +5 -2
- package/dist/temml.cjs +34 -15
- package/dist/temml.js +34 -15
- package/dist/temml.min.js +1 -1
- package/dist/temml.mjs +34 -15
- package/dist/temmlPostProcess.js +1 -1
- package/package.json +1 -1
- package/src/Parser.js +14 -3
- package/src/buildMathML.js +0 -3
- package/src/environments/array.js +7 -3
- package/src/functions/color.js +3 -0
- package/src/functions/font.js +8 -5
- package/src/functions/relax.js +2 -1
- package/src/postProcess.js +1 -1
package/README.md
CHANGED
package/dist/Temml-Asana.css
CHANGED
@@ -36,9 +36,12 @@ math {
|
|
36
36
|
font-family: Asana Math, math;
|
37
37
|
}
|
38
38
|
|
39
|
-
/*
|
39
|
+
/* display: block is necessary in Firefox and Safari.
|
40
40
|
* Not in Chromium, which recognizes display: "block math" written inline. */
|
41
|
-
math.tml-display {
|
41
|
+
math.tml-display {
|
42
|
+
display: block;
|
43
|
+
width: 100%;
|
44
|
+
}
|
42
45
|
|
43
46
|
*.mathcal,
|
44
47
|
mo.tml-prime {
|
@@ -46,9 +46,12 @@ math {
|
|
46
46
|
font-family: "Latin Modern Math", math;
|
47
47
|
}
|
48
48
|
|
49
|
-
/*
|
49
|
+
/* display: block is necessary in Firefox and Safari.
|
50
50
|
* Not in Chromium, which recognizes display: "block math" written inline. */
|
51
|
-
math.tml-display {
|
51
|
+
math.tml-display {
|
52
|
+
display: block;
|
53
|
+
width: 100%;
|
54
|
+
}
|
52
55
|
|
53
56
|
*.mathscr {
|
54
57
|
font-family: "Temml";
|
@@ -44,9 +44,12 @@ math {
|
|
44
44
|
font-family: Libertinus Math, math;
|
45
45
|
}
|
46
46
|
|
47
|
-
/*
|
47
|
+
/* display: block is necessary in Firefox and Safari.
|
48
48
|
* Not in Chromium, which recognizes display: "block math" written inline. */
|
49
|
-
math.tml-display {
|
49
|
+
math.tml-display {
|
50
|
+
display: block;
|
51
|
+
width: 100%;
|
52
|
+
}
|
50
53
|
|
51
54
|
*.mathcal {
|
52
55
|
font-family: "Cambria Math", 'STIXTwoMath-Regular', "Times New Roman", math;
|
package/dist/Temml-Local.css
CHANGED
@@ -30,9 +30,12 @@ math * {
|
|
30
30
|
border-color: currentColor;
|
31
31
|
}
|
32
32
|
|
33
|
-
/*
|
33
|
+
/* display: block is necessary in Firefox and Safari.
|
34
34
|
* Not in Chromium, which recognizes display: "block math" written inline. */
|
35
|
-
math.tml-display {
|
35
|
+
math.tml-display {
|
36
|
+
display: block;
|
37
|
+
width: 100%;
|
38
|
+
}
|
36
39
|
|
37
40
|
*.mathcal {
|
38
41
|
/* NotoSans */
|
package/dist/Temml-NotoSans.css
CHANGED
@@ -32,9 +32,12 @@ math {
|
|
32
32
|
font-family: "NotoSans Math", math;
|
33
33
|
}
|
34
34
|
|
35
|
-
/*
|
35
|
+
/* display: block is necessary in Firefox and Safari.
|
36
36
|
* Not in Chromium, which recognizes display: "block math" written inline. */
|
37
|
-
math.tml-display {
|
37
|
+
math.tml-display {
|
38
|
+
display: block;
|
39
|
+
width: 100%;
|
40
|
+
}
|
38
41
|
|
39
42
|
math .mathscr {
|
40
43
|
font-family: "ssty1";
|
package/dist/Temml-STIX2.css
CHANGED
@@ -30,9 +30,12 @@ math * {
|
|
30
30
|
border-color: currentColor;
|
31
31
|
}
|
32
32
|
|
33
|
-
/*
|
33
|
+
/* display: block is necessary in Firefox and Safari.
|
34
34
|
* Not in Chromium, which recognizes display: "block math" written inline. */
|
35
|
-
math.tml-display {
|
35
|
+
math.tml-display {
|
36
|
+
display: block;
|
37
|
+
width: 100%;
|
38
|
+
}
|
36
39
|
|
37
40
|
math {
|
38
41
|
font-family: STIX2, math;
|
package/dist/temml.cjs
CHANGED
@@ -2456,9 +2456,6 @@ function buildMathML(tree, texExpression, style, settings) {
|
|
2456
2456
|
if (settings.xml) {
|
2457
2457
|
math.setAttribute("xmlns", "http://www.w3.org/1998/Math/MathML");
|
2458
2458
|
}
|
2459
|
-
if (wrapper.style.width) {
|
2460
|
-
math.style.width = "100%";
|
2461
|
-
}
|
2462
2459
|
if (settings.displayMode) {
|
2463
2460
|
math.setAttribute("display", "block");
|
2464
2461
|
math.style.display = "block math"; // necessary in Chromium.
|
@@ -6466,7 +6463,7 @@ const mathmlBuilder$9 = function(group, style) {
|
|
6466
6463
|
const numColumns = group.body[0].length;
|
6467
6464
|
// Fill out a short row with empty <mtd> elements.
|
6468
6465
|
for (let k = 0; k < numColumns - rw.length; k++) {
|
6469
|
-
row.push(new mathMLTree.MathNode("mtd", [], style));
|
6466
|
+
row.push(new mathMLTree.MathNode("mtd", [], [], style));
|
6470
6467
|
}
|
6471
6468
|
if (group.autoTag) {
|
6472
6469
|
const tag = group.tags[i];
|
@@ -6926,7 +6923,9 @@ defineEnvironment({
|
|
6926
6923
|
}
|
6927
6924
|
}
|
6928
6925
|
const res = parseArray(context.parser, payload, "text");
|
6929
|
-
res.cols =
|
6926
|
+
res.cols = res.body.length > 0
|
6927
|
+
? new Array(res.body[0].length).fill({ type: "align", align: colAlign })
|
6928
|
+
: [];
|
6930
6929
|
const [arraystretch, arraycolsep] = arrayGaps(context.parser.gullet.macros);
|
6931
6930
|
res.arraystretch = arraystretch;
|
6932
6931
|
if (arraycolsep && !(arraycolsep === 6 && arraycolsep === "pt")) {
|
@@ -6955,7 +6954,9 @@ defineEnvironment({
|
|
6955
6954
|
handler(context) {
|
6956
6955
|
const payload = { cols: [], envClasses: ["bordermatrix"] };
|
6957
6956
|
const res = parseArray(context.parser, payload, "text");
|
6958
|
-
res.cols =
|
6957
|
+
res.cols = res.body.length > 0
|
6958
|
+
? new Array(res.body[0].length).fill({ type: "align", align: "c" })
|
6959
|
+
: [];
|
6959
6960
|
res.envClasses = [];
|
6960
6961
|
res.arraystretch = 1;
|
6961
6962
|
if (context.envName === "matrix") { return res}
|
@@ -7389,6 +7390,9 @@ const mathmlBuilder$8 = (group, style) => {
|
|
7389
7390
|
// So instead of wrapping the group in an <mstyle>, we apply
|
7390
7391
|
// the color individually to each node and return a document fragment.
|
7391
7392
|
let expr = buildExpression(group.body, style.withColor(group.color));
|
7393
|
+
if (expr.length === 0) {
|
7394
|
+
expr.push(new mathMLTree.MathNode("mrow"));
|
7395
|
+
}
|
7392
7396
|
expr = expr.map(e => {
|
7393
7397
|
e.style.color = group.color;
|
7394
7398
|
return e
|
@@ -8475,17 +8479,20 @@ const mathmlBuilder$6 = (group, style) => {
|
|
8475
8479
|
// Check if it is possible to consolidate elements into a single <mi> element.
|
8476
8480
|
if (isLongVariableName(group, font)) {
|
8477
8481
|
// This is a \mathrm{…} group. It gets special treatment because symbolsOrd.js
|
8478
|
-
// wraps <mi> elements with <
|
8479
|
-
const mi = mathGroup.children[0].children[0]
|
8482
|
+
// wraps <mi> elements with <mpadded>s to work around a Firefox bug.
|
8483
|
+
const mi = mathGroup.children[0].children[0].children
|
8484
|
+
? mathGroup.children[0].children[0]
|
8485
|
+
: mathGroup.children[0];
|
8480
8486
|
delete mi.attributes.mathvariant;
|
8481
8487
|
for (let i = 1; i < mathGroup.children.length; i++) {
|
8482
8488
|
mi.children[0].text += mathGroup.children[i].children[0].children
|
8483
8489
|
? mathGroup.children[i].children[0].children[0].text
|
8484
8490
|
: mathGroup.children[i].children[0].text;
|
8485
8491
|
}
|
8486
|
-
// Wrap in a <
|
8487
|
-
const
|
8488
|
-
|
8492
|
+
// Wrap in a <mpadded> to prevent the same Firefox bug.
|
8493
|
+
const mpadded = new mathMLTree.MathNode("mpadded", [mi]);
|
8494
|
+
mpadded.setAttribute("lspace", "0");
|
8495
|
+
return mpadded
|
8489
8496
|
}
|
8490
8497
|
let canConsolidate = mathGroup.children[0].type === "mo";
|
8491
8498
|
for (let i = 1; i < mathGroup.children.length; i++) {
|
@@ -10560,7 +10567,8 @@ defineFunction({
|
|
10560
10567
|
names: ["\\relax"],
|
10561
10568
|
props: {
|
10562
10569
|
numArgs: 0,
|
10563
|
-
allowedInText: true
|
10570
|
+
allowedInText: true,
|
10571
|
+
allowedInArgument: true
|
10564
10572
|
},
|
10565
10573
|
handler({ parser }) {
|
10566
10574
|
return {
|
@@ -12976,6 +12984,7 @@ class Parser {
|
|
12976
12984
|
if (!atom) {
|
12977
12985
|
break;
|
12978
12986
|
} else if (atom.type === "internal") {
|
12987
|
+
// Internal nodes do not appear in parse tree
|
12979
12988
|
continue;
|
12980
12989
|
}
|
12981
12990
|
body.push(atom);
|
@@ -13050,7 +13059,11 @@ class Parser {
|
|
13050
13059
|
const symbol = symbolToken.text;
|
13051
13060
|
this.consume();
|
13052
13061
|
this.consumeSpaces(); // ignore spaces before sup/subscript argument
|
13053
|
-
|
13062
|
+
// Skip over allowed internal nodes such as \relax
|
13063
|
+
let group;
|
13064
|
+
do {
|
13065
|
+
group = this.parseGroup(name);
|
13066
|
+
} while (group.type && group.type === "internal")
|
13054
13067
|
|
13055
13068
|
if (!group) {
|
13056
13069
|
throw new ParseError("Expected group after '" + symbol + "'", symbolToken);
|
@@ -13094,9 +13107,15 @@ class Parser {
|
|
13094
13107
|
// \left(x\right)^2 work correctly.
|
13095
13108
|
const base = this.parseGroup("atom", breakOnTokenText);
|
13096
13109
|
|
13110
|
+
// Internal nodes (e.g. \relax) cannot support super/subscripts.
|
13111
|
+
// Instead we will pick up super/subscripts with blank base next round.
|
13112
|
+
if (base && base.type === "internal") {
|
13113
|
+
return base
|
13114
|
+
}
|
13115
|
+
|
13097
13116
|
// In text mode, we don't have superscripts or subscripts
|
13098
13117
|
if (this.mode === "text") {
|
13099
|
-
return base
|
13118
|
+
return base
|
13100
13119
|
}
|
13101
13120
|
|
13102
13121
|
// Note that base may be empty (i.e. null) at this point.
|
@@ -13953,7 +13972,7 @@ class Style {
|
|
13953
13972
|
* https://mit-license.org/
|
13954
13973
|
*/
|
13955
13974
|
|
13956
|
-
const version = "0.11.
|
13975
|
+
const version = "0.11.05";
|
13957
13976
|
|
13958
13977
|
function postProcess(block) {
|
13959
13978
|
const labelMap = {};
|
package/dist/temml.js
CHANGED
@@ -2457,9 +2457,6 @@ var temml = (function () {
|
|
2457
2457
|
if (settings.xml) {
|
2458
2458
|
math.setAttribute("xmlns", "http://www.w3.org/1998/Math/MathML");
|
2459
2459
|
}
|
2460
|
-
if (wrapper.style.width) {
|
2461
|
-
math.style.width = "100%";
|
2462
|
-
}
|
2463
2460
|
if (settings.displayMode) {
|
2464
2461
|
math.setAttribute("display", "block");
|
2465
2462
|
math.style.display = "block math"; // necessary in Chromium.
|
@@ -4553,7 +4550,7 @@ var temml = (function () {
|
|
4553
4550
|
const numColumns = group.body[0].length;
|
4554
4551
|
// Fill out a short row with empty <mtd> elements.
|
4555
4552
|
for (let k = 0; k < numColumns - rw.length; k++) {
|
4556
|
-
row.push(new mathMLTree.MathNode("mtd", [], style));
|
4553
|
+
row.push(new mathMLTree.MathNode("mtd", [], [], style));
|
4557
4554
|
}
|
4558
4555
|
if (group.autoTag) {
|
4559
4556
|
const tag = group.tags[i];
|
@@ -5013,7 +5010,9 @@ var temml = (function () {
|
|
5013
5010
|
}
|
5014
5011
|
}
|
5015
5012
|
const res = parseArray(context.parser, payload, "text");
|
5016
|
-
res.cols =
|
5013
|
+
res.cols = res.body.length > 0
|
5014
|
+
? new Array(res.body[0].length).fill({ type: "align", align: colAlign })
|
5015
|
+
: [];
|
5017
5016
|
const [arraystretch, arraycolsep] = arrayGaps(context.parser.gullet.macros);
|
5018
5017
|
res.arraystretch = arraystretch;
|
5019
5018
|
if (arraycolsep && !(arraycolsep === 6 && arraycolsep === "pt")) {
|
@@ -5042,7 +5041,9 @@ var temml = (function () {
|
|
5042
5041
|
handler(context) {
|
5043
5042
|
const payload = { cols: [], envClasses: ["bordermatrix"] };
|
5044
5043
|
const res = parseArray(context.parser, payload, "text");
|
5045
|
-
res.cols =
|
5044
|
+
res.cols = res.body.length > 0
|
5045
|
+
? new Array(res.body[0].length).fill({ type: "align", align: "c" })
|
5046
|
+
: [];
|
5046
5047
|
res.envClasses = [];
|
5047
5048
|
res.arraystretch = 1;
|
5048
5049
|
if (context.envName === "matrix") { return res}
|
@@ -5476,6 +5477,9 @@ var temml = (function () {
|
|
5476
5477
|
// So instead of wrapping the group in an <mstyle>, we apply
|
5477
5478
|
// the color individually to each node and return a document fragment.
|
5478
5479
|
let expr = buildExpression(group.body, style.withColor(group.color));
|
5480
|
+
if (expr.length === 0) {
|
5481
|
+
expr.push(new mathMLTree.MathNode("mrow"));
|
5482
|
+
}
|
5479
5483
|
expr = expr.map(e => {
|
5480
5484
|
e.style.color = group.color;
|
5481
5485
|
return e
|
@@ -6562,17 +6566,20 @@ var temml = (function () {
|
|
6562
6566
|
// Check if it is possible to consolidate elements into a single <mi> element.
|
6563
6567
|
if (isLongVariableName(group, font)) {
|
6564
6568
|
// This is a \mathrm{…} group. It gets special treatment because symbolsOrd.js
|
6565
|
-
// wraps <mi> elements with <
|
6566
|
-
const mi = mathGroup.children[0].children[0]
|
6569
|
+
// wraps <mi> elements with <mpadded>s to work around a Firefox bug.
|
6570
|
+
const mi = mathGroup.children[0].children[0].children
|
6571
|
+
? mathGroup.children[0].children[0]
|
6572
|
+
: mathGroup.children[0];
|
6567
6573
|
delete mi.attributes.mathvariant;
|
6568
6574
|
for (let i = 1; i < mathGroup.children.length; i++) {
|
6569
6575
|
mi.children[0].text += mathGroup.children[i].children[0].children
|
6570
6576
|
? mathGroup.children[i].children[0].children[0].text
|
6571
6577
|
: mathGroup.children[i].children[0].text;
|
6572
6578
|
}
|
6573
|
-
// Wrap in a <
|
6574
|
-
const
|
6575
|
-
|
6579
|
+
// Wrap in a <mpadded> to prevent the same Firefox bug.
|
6580
|
+
const mpadded = new mathMLTree.MathNode("mpadded", [mi]);
|
6581
|
+
mpadded.setAttribute("lspace", "0");
|
6582
|
+
return mpadded
|
6576
6583
|
}
|
6577
6584
|
let canConsolidate = mathGroup.children[0].type === "mo";
|
6578
6585
|
for (let i = 1; i < mathGroup.children.length; i++) {
|
@@ -8647,7 +8654,8 @@ var temml = (function () {
|
|
8647
8654
|
names: ["\\relax"],
|
8648
8655
|
props: {
|
8649
8656
|
numArgs: 0,
|
8650
|
-
allowedInText: true
|
8657
|
+
allowedInText: true,
|
8658
|
+
allowedInArgument: true
|
8651
8659
|
},
|
8652
8660
|
handler({ parser }) {
|
8653
8661
|
return {
|
@@ -11063,6 +11071,7 @@ var temml = (function () {
|
|
11063
11071
|
if (!atom) {
|
11064
11072
|
break;
|
11065
11073
|
} else if (atom.type === "internal") {
|
11074
|
+
// Internal nodes do not appear in parse tree
|
11066
11075
|
continue;
|
11067
11076
|
}
|
11068
11077
|
body.push(atom);
|
@@ -11137,7 +11146,11 @@ var temml = (function () {
|
|
11137
11146
|
const symbol = symbolToken.text;
|
11138
11147
|
this.consume();
|
11139
11148
|
this.consumeSpaces(); // ignore spaces before sup/subscript argument
|
11140
|
-
|
11149
|
+
// Skip over allowed internal nodes such as \relax
|
11150
|
+
let group;
|
11151
|
+
do {
|
11152
|
+
group = this.parseGroup(name);
|
11153
|
+
} while (group.type && group.type === "internal")
|
11141
11154
|
|
11142
11155
|
if (!group) {
|
11143
11156
|
throw new ParseError("Expected group after '" + symbol + "'", symbolToken);
|
@@ -11181,9 +11194,15 @@ var temml = (function () {
|
|
11181
11194
|
// \left(x\right)^2 work correctly.
|
11182
11195
|
const base = this.parseGroup("atom", breakOnTokenText);
|
11183
11196
|
|
11197
|
+
// Internal nodes (e.g. \relax) cannot support super/subscripts.
|
11198
|
+
// Instead we will pick up super/subscripts with blank base next round.
|
11199
|
+
if (base && base.type === "internal") {
|
11200
|
+
return base
|
11201
|
+
}
|
11202
|
+
|
11184
11203
|
// In text mode, we don't have superscripts or subscripts
|
11185
11204
|
if (this.mode === "text") {
|
11186
|
-
return base
|
11205
|
+
return base
|
11187
11206
|
}
|
11188
11207
|
|
11189
11208
|
// Note that base may be empty (i.e. null) at this point.
|
@@ -12040,7 +12059,7 @@ var temml = (function () {
|
|
12040
12059
|
* https://mit-license.org/
|
12041
12060
|
*/
|
12042
12061
|
|
12043
|
-
const version = "0.11.
|
12062
|
+
const version = "0.11.05";
|
12044
12063
|
|
12045
12064
|
function postProcess(block) {
|
12046
12065
|
const labelMap = {};
|