temml 0.10.14 → 0.10.15
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +1 -1
- package/dist/Temml-Asana.css +0 -146
- package/dist/Temml-Latin-Modern.css +0 -147
- package/dist/Temml-Libertinus.css +0 -147
- package/dist/Temml-Local.css +0 -146
- package/dist/Temml-STIX2.css +0 -146
- package/dist/temml.cjs +126 -25
- package/dist/temml.d.ts +60 -0
- package/dist/temml.js +126 -25
- package/dist/temml.min.js +1 -1
- package/dist/temml.mjs +126 -25
- package/dist/temmlPostProcess.js +1 -1
- package/package.json +4 -2
- package/src/buildMathML.js +1 -3
- package/src/environments/array.js +95 -23
- package/src/functions/enclose.js +24 -3
- package/src/postProcess.js +1 -1
- package/src/symbols.js +4 -0
- package/temml.js +6 -0
package/dist/temml.js
CHANGED
@@ -974,6 +974,10 @@ var temml = (function () {
|
|
974
974
|
defineSymbol(math, mathord, "\u220E", "\\QED", true);
|
975
975
|
defineSymbol(math, mathord, "\u2030", "\\permil", true);
|
976
976
|
defineSymbol(text, textord, "\u2030", "\\permil");
|
977
|
+
defineSymbol(math, mathord, "\u2609", "\\astrosun", true);
|
978
|
+
defineSymbol(math, mathord, "\u263c", "\\sun", true);
|
979
|
+
defineSymbol(math, mathord, "\u263e", "\\leftmoon", true);
|
980
|
+
defineSymbol(math, mathord, "\u263d", "\\rightmoon", true);
|
977
981
|
|
978
982
|
// AMS Negated Binary Relations
|
979
983
|
defineSymbol(math, rel, "\u226e", "\\nless", true);
|
@@ -2132,9 +2136,7 @@ var temml = (function () {
|
|
2132
2136
|
}
|
2133
2137
|
if (settings.displayMode) {
|
2134
2138
|
math.setAttribute("display", "block");
|
2135
|
-
math.style.display = math
|
2136
|
-
? "inline"
|
2137
|
-
: "block math"; // necessary in Chromium.
|
2139
|
+
math.style.display = "block math"; // necessary in Chromium.
|
2138
2140
|
// Firefox and Safari do not recognize display: "block math".
|
2139
2141
|
// Set a class so that the CSS file can set display: block.
|
2140
2142
|
math.classes = ["tml-display"];
|
@@ -3825,10 +3827,20 @@ var temml = (function () {
|
|
3825
3827
|
node.style.borderBottom = "0.065em solid";
|
3826
3828
|
break
|
3827
3829
|
case "\\cancel":
|
3828
|
-
node.
|
3830
|
+
node.style.background = `linear-gradient(to top left,
|
3831
|
+
rgba(0,0,0,0) 0%,
|
3832
|
+
rgba(0,0,0,0) calc(50% - 0.06em),
|
3833
|
+
rgba(0,0,0,1) 50%,
|
3834
|
+
rgba(0,0,0,0) calc(50% + 0.06em),
|
3835
|
+
rgba(0,0,0,0) 100%);`;
|
3829
3836
|
break
|
3830
3837
|
case "\\bcancel":
|
3831
|
-
node.
|
3838
|
+
node.style.background = `linear-gradient(to top right,
|
3839
|
+
rgba(0,0,0,0) 0%,
|
3840
|
+
rgba(0,0,0,0) calc(50% - 0.06em),
|
3841
|
+
rgba(0,0,0,1) 50%,
|
3842
|
+
rgba(0,0,0,0) calc(50% + 0.06em),
|
3843
|
+
rgba(0,0,0,0) 100%);`;
|
3832
3844
|
break
|
3833
3845
|
/*
|
3834
3846
|
case "\\longdiv":
|
@@ -3872,7 +3884,18 @@ var temml = (function () {
|
|
3872
3884
|
break
|
3873
3885
|
}
|
3874
3886
|
case "\\xcancel":
|
3875
|
-
node.
|
3887
|
+
node.style.background = `linear-gradient(to top left,
|
3888
|
+
rgba(0,0,0,0) 0%,
|
3889
|
+
rgba(0,0,0,0) calc(50% - 0.06em),
|
3890
|
+
rgba(0,0,0,1) 50%,
|
3891
|
+
rgba(0,0,0,0) calc(50% + 0.06em),
|
3892
|
+
rgba(0,0,0,0) 100%),
|
3893
|
+
linear-gradient(to top right,
|
3894
|
+
rgba(0,0,0,0) 0%,
|
3895
|
+
rgba(0,0,0,0) calc(50% - 0.06em),
|
3896
|
+
rgba(0,0,0,1) 50%,
|
3897
|
+
rgba(0,0,0,0) calc(50% + 0.06em),
|
3898
|
+
rgba(0,0,0,0) 100%);`;
|
3876
3899
|
break
|
3877
3900
|
}
|
3878
3901
|
if (group.backgroundColor) {
|
@@ -4303,24 +4326,94 @@ var temml = (function () {
|
|
4303
4326
|
// Write horizontal rules
|
4304
4327
|
if (i === 0 && hlines[0].length > 0) {
|
4305
4328
|
if (hlines[0].length === 2) {
|
4306
|
-
mtr.
|
4329
|
+
mtr.children.forEach(cell => { cell.style.borderTop = "0.15em double"; });
|
4307
4330
|
} else {
|
4308
|
-
mtr.
|
4331
|
+
mtr.children.forEach(cell => {
|
4332
|
+
cell.style.borderTop = hlines[0][0] ? "0.06em dashed" : "0.06em solid";
|
4333
|
+
});
|
4309
4334
|
}
|
4310
4335
|
}
|
4311
4336
|
if (hlines[i + 1].length > 0) {
|
4312
4337
|
if (hlines[i + 1].length === 2) {
|
4313
|
-
mtr.
|
4338
|
+
mtr.children.forEach(cell => { cell.style.borderBottom = "0.15em double"; });
|
4314
4339
|
} else {
|
4315
|
-
mtr.
|
4340
|
+
mtr.children.forEach(cell => {
|
4341
|
+
cell.style.borderBottom = hlines[i + 1][0] ? "0.06em dashed" : "0.06em solid";
|
4342
|
+
});
|
4316
4343
|
}
|
4317
4344
|
}
|
4318
4345
|
tbl.push(mtr);
|
4319
4346
|
}
|
4320
|
-
|
4347
|
+
|
4321
4348
|
if (group.envClasses.length > 0) {
|
4322
|
-
|
4349
|
+
const pad = group.envClasses.includes("jot")
|
4350
|
+
? "0.7" // 0.5ex + 0.09em top & bot padding
|
4351
|
+
: group.envClasses.includes("small")
|
4352
|
+
? "0.35"
|
4353
|
+
: "0.5"; // 0.5ex default top & bot padding
|
4354
|
+
const sidePadding = group.envClasses.includes("abut")
|
4355
|
+
? "0"
|
4356
|
+
: group.envClasses.includes("cases")
|
4357
|
+
? "0"
|
4358
|
+
: group.envClasses.includes("small")
|
4359
|
+
? "0.1389"
|
4360
|
+
: group.envClasses.includes("cd")
|
4361
|
+
? "0.25"
|
4362
|
+
: "0.4"; // default side padding
|
4363
|
+
|
4364
|
+
const numCols = tbl.length === 0 ? 0 : tbl[0].children.length;
|
4365
|
+
|
4366
|
+
const sidePad = (j, hand) => {
|
4367
|
+
if (j === 0 && hand === 0) { return "0" }
|
4368
|
+
if (j === numCols - 1 && hand === 1) { return "0" }
|
4369
|
+
if (group.envClasses[0] !== "align") { return sidePadding }
|
4370
|
+
if (hand === 1) { return "0" }
|
4371
|
+
if (group.addEqnNum) {
|
4372
|
+
return (j % 2) ? "1" : "0"
|
4373
|
+
} else {
|
4374
|
+
return (j % 2) ? "0" : "1"
|
4375
|
+
}
|
4376
|
+
};
|
4377
|
+
|
4378
|
+
// Padding
|
4379
|
+
for (let i = 0; i < tbl.length; i++) {
|
4380
|
+
for (let j = 0; j < tbl[i].children.length; j++) {
|
4381
|
+
tbl[i].children[j].style.padding = `${pad}ex ${sidePad(j, 1)}em ${pad}ex ${sidePad(j, 0)}em`;
|
4382
|
+
}
|
4383
|
+
}
|
4384
|
+
|
4385
|
+
// Justification
|
4386
|
+
const align = group.envClasses.includes("align") || group.envClasses.includes("alignat");
|
4387
|
+
for (let i = 0; i < tbl.length; i++) {
|
4388
|
+
const row = tbl[i];
|
4389
|
+
if (align) {
|
4390
|
+
for (let j = 0; j < row.children.length; j++) {
|
4391
|
+
// Chromium does not recognize text-align: left. Use -webkit-
|
4392
|
+
// TODO: Remove -webkit- when Chromium no longer needs it.
|
4393
|
+
row.children[j].style.textAlign = "-webkit-" + (j % 2 ? "left" : "right");
|
4394
|
+
}
|
4395
|
+
}
|
4396
|
+
if (row.children.length > 1 && group.envClasses.includes("cases")) {
|
4397
|
+
row.children[1].style.padding = row.children[1].style.padding.replace(/0em$/, "1em");
|
4398
|
+
}
|
4399
|
+
|
4400
|
+
if (group.envClasses.includes("cases") || group.envClasses.includes("subarray")) {
|
4401
|
+
for (const cell of row.children) {
|
4402
|
+
cell.style.textAlign = "-webkit-" + "left";
|
4403
|
+
}
|
4404
|
+
}
|
4405
|
+
}
|
4406
|
+
} else {
|
4407
|
+
// Set zero padding on side of the matrix
|
4408
|
+
for (let i = 0; i < tbl.length; i++) {
|
4409
|
+
tbl[i].children[0].style.paddingLeft = "0em";
|
4410
|
+
if (tbl[i].children.length === tbl[0].children.length) {
|
4411
|
+
tbl[i].children[tbl[i].children.length - 1].style.paddingRight = "0em";
|
4412
|
+
}
|
4413
|
+
}
|
4323
4414
|
}
|
4415
|
+
|
4416
|
+
let table = new mathMLTree.MathNode("mtable", tbl);
|
4324
4417
|
if (group.scriptLevel === "display") { table.setAttribute("displaystyle", "true"); }
|
4325
4418
|
|
4326
4419
|
if (group.addEqnNum || group.envClasses.includes("multline")) {
|
@@ -4400,6 +4493,8 @@ var temml = (function () {
|
|
4400
4493
|
align = "left " + (align.length > 0 ? align : "center ") + "right ";
|
4401
4494
|
}
|
4402
4495
|
if (align) {
|
4496
|
+
// Firefox reads this attribute, not the -webkit-left|right written above.
|
4497
|
+
// TODO: When Chrome no longer needs "-webkit-", use CSS and delete the next line.
|
4403
4498
|
table.setAttribute("columnalign", align.trim());
|
4404
4499
|
}
|
4405
4500
|
|
@@ -4424,7 +4519,7 @@ var temml = (function () {
|
|
4424
4519
|
cols,
|
4425
4520
|
addEqnNum: context.envName === "align" || context.envName === "alignat",
|
4426
4521
|
emptySingleRow: true,
|
4427
|
-
envClasses: ["
|
4522
|
+
envClasses: ["abut", "jot"], // set row spacing & provisional column spacing
|
4428
4523
|
maxNumCols: context.envName === "split" ? 2 : undefined,
|
4429
4524
|
leqno: context.parser.settings.leqno
|
4430
4525
|
},
|
@@ -4442,18 +4537,22 @@ var temml = (function () {
|
|
4442
4537
|
// binary. This behavior is implemented in amsmath's \start@aligned.
|
4443
4538
|
let numMaths;
|
4444
4539
|
let numCols = 0;
|
4445
|
-
|
4540
|
+
const isAlignedAt = context.envName.indexOf("at") > -1;
|
4541
|
+
if (args[0] && isAlignedAt) {
|
4542
|
+
// alignat environment takes an argument w/ number of columns
|
4446
4543
|
let arg0 = "";
|
4447
4544
|
for (let i = 0; i < args[0].body.length; i++) {
|
4448
4545
|
const textord = assertNodeType(args[0].body[i], "textord");
|
4449
4546
|
arg0 += textord.text;
|
4450
4547
|
}
|
4548
|
+
if (isNaN(arg0)) {
|
4549
|
+
throw new ParseError("The alignat enviroment requires a numeric first argument.")
|
4550
|
+
}
|
4451
4551
|
numMaths = Number(arg0);
|
4452
4552
|
numCols = numMaths * 2;
|
4453
4553
|
}
|
4454
|
-
const isAligned = !numCols;
|
4455
4554
|
res.body.forEach(function(row) {
|
4456
|
-
if (
|
4555
|
+
if (isAlignedAt) {
|
4457
4556
|
// Case 1
|
4458
4557
|
const curMaths = row.length / 2;
|
4459
4558
|
if (numMaths < curMaths) {
|
@@ -4481,14 +4580,10 @@ var temml = (function () {
|
|
4481
4580
|
align: align
|
4482
4581
|
};
|
4483
4582
|
}
|
4484
|
-
if (context.envName === "split") ; else if (
|
4485
|
-
res.envClasses.push("
|
4486
|
-
} else if (isAligned) {
|
4487
|
-
res.envClasses[1] = context.envName === "align*"
|
4488
|
-
? "align-star"
|
4489
|
-
: "align"; // Sets column spacing & justification
|
4583
|
+
if (context.envName === "split") ; else if (isAlignedAt) {
|
4584
|
+
res.envClasses.push("alignat"); // Sets justification
|
4490
4585
|
} else {
|
4491
|
-
res.envClasses
|
4586
|
+
res.envClasses[0] = "align"; // Sets column spacing & justification
|
4492
4587
|
}
|
4493
4588
|
return res;
|
4494
4589
|
};
|
@@ -4738,7 +4833,7 @@ var temml = (function () {
|
|
4738
4833
|
}
|
4739
4834
|
const res = {
|
4740
4835
|
cols: [],
|
4741
|
-
envClasses: ["
|
4836
|
+
envClasses: ["abut", "jot"],
|
4742
4837
|
addEqnNum: context.envName === "gather",
|
4743
4838
|
emptySingleRow: true,
|
4744
4839
|
leqno: context.parser.settings.leqno
|
@@ -11002,7 +11097,7 @@ var temml = (function () {
|
|
11002
11097
|
* https://mit-license.org/
|
11003
11098
|
*/
|
11004
11099
|
|
11005
|
-
const version = "0.10.
|
11100
|
+
const version = "0.10.15";
|
11006
11101
|
|
11007
11102
|
function postProcess(block) {
|
11008
11103
|
const labelMap = {};
|
@@ -11053,6 +11148,7 @@ var temml = (function () {
|
|
11053
11148
|
/* eslint no-console:0 */
|
11054
11149
|
|
11055
11150
|
/**
|
11151
|
+
* @type {import('./temml').render}
|
11056
11152
|
* Parse and build an expression, and place that expression in the DOM node
|
11057
11153
|
* given.
|
11058
11154
|
*/
|
@@ -11090,6 +11186,7 @@ var temml = (function () {
|
|
11090
11186
|
}
|
11091
11187
|
|
11092
11188
|
/**
|
11189
|
+
* @type {import('./temml').renderToString}
|
11093
11190
|
* Parse and build an expression, and return the markup for that.
|
11094
11191
|
*/
|
11095
11192
|
const renderToString = function(expression, options) {
|
@@ -11098,6 +11195,7 @@ var temml = (function () {
|
|
11098
11195
|
};
|
11099
11196
|
|
11100
11197
|
/**
|
11198
|
+
* @type {import('./temml').generateParseTree}
|
11101
11199
|
* Parse an expression and return the parse tree.
|
11102
11200
|
*/
|
11103
11201
|
const generateParseTree = function(expression, options) {
|
@@ -11106,6 +11204,7 @@ var temml = (function () {
|
|
11106
11204
|
};
|
11107
11205
|
|
11108
11206
|
/**
|
11207
|
+
* @type {import('./temml').definePreamble}
|
11109
11208
|
* Take an expression which contains a preamble.
|
11110
11209
|
* Parse it and return the macros.
|
11111
11210
|
*/
|
@@ -11138,6 +11237,7 @@ var temml = (function () {
|
|
11138
11237
|
};
|
11139
11238
|
|
11140
11239
|
/**
|
11240
|
+
* @type {import('./temml').renderToMathMLTree}
|
11141
11241
|
* Generates and returns the Temml build tree. This is used for advanced
|
11142
11242
|
* use cases (like rendering to custom output).
|
11143
11243
|
*/
|
@@ -11155,6 +11255,7 @@ var temml = (function () {
|
|
11155
11255
|
}
|
11156
11256
|
};
|
11157
11257
|
|
11258
|
+
/** @type {import('./temml').default} */
|
11158
11259
|
var temml = {
|
11159
11260
|
/**
|
11160
11261
|
* Current Temml version
|