temml 0.10.14 → 0.10.16

Sign up to get free protection for your applications and to get access to all the features.
package/dist/temml.cjs CHANGED
@@ -478,7 +478,7 @@ class TextNode$1 {
478
478
  }
479
479
  }
480
480
 
481
- /**
481
+ /*
482
482
  * This node represents an image embed (<img>) element.
483
483
  */
484
484
  class Img {
@@ -523,7 +523,7 @@ class Img {
523
523
  markup += ` style="${utils.escape(styles)}"`;
524
524
  }
525
525
 
526
- markup += "/>";
526
+ markup += ">";
527
527
  return markup;
528
528
  }
529
529
  }
@@ -699,6 +699,34 @@ var mathMLTree = {
699
699
  * This file provides support for building horizontal stretchy elements.
700
700
  */
701
701
 
702
+ // TODO: Remove when Chromium stretches \widetilde & \widehat
703
+ const estimatedWidth = node => {
704
+ let width = 0;
705
+ if (node.body) {
706
+ for (const item of node.body) {
707
+ width += estimatedWidth(item);
708
+ }
709
+ } else if (node.type === "supsub") {
710
+ width += estimatedWidth(node.base);
711
+ if (node.sub) { width += 0.7 * estimatedWidth(node.sub); }
712
+ if (node.sup) { width += 0.7 * estimatedWidth(node.sup); }
713
+ } else if (node.type === "mathord" || node.type === "textord") {
714
+ for (const ch of node.text.split('')) {
715
+ const codePoint = ch.codePointAt(0);
716
+ if ((0x60 < codePoint && codePoint < 0x7B) || (0x03B0 < codePoint && codePoint < 0x3CA)) {
717
+ width += 0.56; // lower case latin or greek. Use advance width of letter n
718
+ } else if (0x2F < codePoint && codePoint < 0x3A) {
719
+ width += 0.50; // numerals.
720
+ } else {
721
+ width += 0.92; // advance width of letter M
722
+ }
723
+ }
724
+ } else {
725
+ width += 1.0;
726
+ }
727
+ return width
728
+ };
729
+
702
730
  const stretchyCodePoint = {
703
731
  widehat: "^",
704
732
  widecheck: "ˇ",
@@ -756,8 +784,27 @@ const mathMLnode = function(label) {
756
784
  return node
757
785
  };
758
786
 
787
+ const crookedWides = ["\\widetilde", "\\widehat", "\\widecheck", "\\utilde"];
788
+
789
+ // TODO: Remove when Chromium stretches \widetilde & \widehat
790
+ const accentNode = (group) => {
791
+ const mo = mathMLnode(group.label);
792
+ if (crookedWides.includes(group.label)) {
793
+ const width = estimatedWidth(group.base);
794
+ if (1 < width && width < 1.6) {
795
+ mo.classes.push("tml-crooked-2");
796
+ } else if (1.6 <= width && width < 2.5) {
797
+ mo.classes.push("tml-crooked-3");
798
+ } else if (2.5 <= width) {
799
+ mo.classes.push("tml-crooked-4");
800
+ }
801
+ }
802
+ return mo
803
+ };
804
+
759
805
  var stretchy = {
760
- mathMLnode
806
+ mathMLnode,
807
+ accentNode
761
808
  };
762
809
 
763
810
  /**
@@ -973,6 +1020,10 @@ defineSymbol(math, mathord, "\u21af", "\\lightning", true);
973
1020
  defineSymbol(math, mathord, "\u220E", "\\QED", true);
974
1021
  defineSymbol(math, mathord, "\u2030", "\\permil", true);
975
1022
  defineSymbol(text, textord, "\u2030", "\\permil");
1023
+ defineSymbol(math, mathord, "\u2609", "\\astrosun", true);
1024
+ defineSymbol(math, mathord, "\u263c", "\\sun", true);
1025
+ defineSymbol(math, mathord, "\u263e", "\\leftmoon", true);
1026
+ defineSymbol(math, mathord, "\u263d", "\\rightmoon", true);
976
1027
 
977
1028
  // AMS Negated Binary Relations
978
1029
  defineSymbol(math, rel, "\u226e", "\\nless", true);
@@ -1051,6 +1102,8 @@ defineSymbol(math, textord, "\u2127", "\\mho");
1051
1102
  defineSymbol(math, textord, "\u2132", "\\Finv", true);
1052
1103
  defineSymbol(math, textord, "\u2141", "\\Game", true);
1053
1104
  defineSymbol(math, textord, "\u2035", "\\backprime");
1105
+ defineSymbol(math, textord, "\u2036", "\\backdprime");
1106
+ defineSymbol(math, textord, "\u2037", "\\backtrprime");
1054
1107
  defineSymbol(math, textord, "\u25b2", "\\blacktriangle");
1055
1108
  defineSymbol(math, textord, "\u25bc", "\\blacktriangledown");
1056
1109
  defineSymbol(math, textord, "\u25a0", "\\blacksquare");
@@ -1254,6 +1307,9 @@ defineSymbol(text, textord, "\u2423", "\\textvisiblespace", true);
1254
1307
  defineSymbol(math, textord, "\u2220", "\\angle", true);
1255
1308
  defineSymbol(math, textord, "\u221e", "\\infty", true);
1256
1309
  defineSymbol(math, textord, "\u2032", "\\prime");
1310
+ defineSymbol(math, textord, "\u2033", "\\dprime");
1311
+ defineSymbol(math, textord, "\u2034", "\\trprime");
1312
+ defineSymbol(math, textord, "\u2057", "\\qprime");
1257
1313
  defineSymbol(math, textord, "\u25b3", "\\triangle");
1258
1314
  defineSymbol(text, textord, "\u0391", "\\Alpha", true);
1259
1315
  defineSymbol(text, textord, "\u0392", "\\Beta", true);
@@ -1433,7 +1489,8 @@ defineSymbol(math, punct, ";", ";");
1433
1489
  defineSymbol(math, bin, "\u22bc", "\\barwedge", true);
1434
1490
  defineSymbol(math, bin, "\u22bb", "\\veebar", true);
1435
1491
  defineSymbol(math, bin, "\u2299", "\\odot", true);
1436
- defineSymbol(math, bin, "\u2295", "\\oplus", true);
1492
+ // Firefox turns ⊕ into an emoji. So append \uFE0E. Define Unicode character in macros, not here.
1493
+ defineSymbol(math, bin, "\u2295\uFE0E", "\\oplus");
1437
1494
  defineSymbol(math, bin, "\u2297", "\\otimes", true);
1438
1495
  defineSymbol(math, textord, "\u2202", "\\partial", true);
1439
1496
  defineSymbol(math, bin, "\u2298", "\\oslash", true);
@@ -1664,6 +1721,8 @@ for (let i = 0; i < letters.length; i++) {
1664
1721
  defineSymbol(math, mathord, ch, ch);
1665
1722
  defineSymbol(text, textord, ch, ch);
1666
1723
  }
1724
+ // Prevent Firefox from using a dotless i.
1725
+ defineSymbol(text, textord, "i\uFE0E", "i");
1667
1726
 
1668
1727
  // Some more letters in Unicode Basic Multilingual Plane.
1669
1728
  const narrow = "ÇÐÞçþℂℍℕℙℚℝℤℎℏℊℋℌℐℑℒℓ℘ℛℜℬℰℱℳℭℨ";
@@ -2131,9 +2190,7 @@ function buildMathML(tree, texExpression, style, settings) {
2131
2190
  }
2132
2191
  if (settings.displayMode) {
2133
2192
  math.setAttribute("display", "block");
2134
- math.style.display = math.children.length === 1 && math.children[0].type === "mtable"
2135
- ? "inline"
2136
- : "block math"; // necessary in Chromium.
2193
+ math.style.display = "block math"; // necessary in Chromium.
2137
2194
  // Firefox and Safari do not recognize display: "block math".
2138
2195
  // Set a class so that the CSS file can set display: block.
2139
2196
  math.classes = ["tml-display"];
@@ -2143,7 +2200,7 @@ function buildMathML(tree, texExpression, style, settings) {
2143
2200
 
2144
2201
  const mathmlBuilder$a = (group, style) => {
2145
2202
  const accentNode = group.isStretchy
2146
- ? stretchy.mathMLnode(group.label)
2203
+ ? stretchy.accentNode(group)
2147
2204
  : new mathMLTree.MathNode("mo", [makeText(group.label, group.mode)]);
2148
2205
 
2149
2206
  if (group.label === "\\vec") {
@@ -2163,25 +2220,21 @@ const mathmlBuilder$a = (group, style) => {
2163
2220
  return node;
2164
2221
  };
2165
2222
 
2166
- const NON_STRETCHY_ACCENT_REGEX = new RegExp(
2167
- [
2168
- "\\acute",
2169
- "\\grave",
2170
- "\\ddot",
2171
- "\\dddot",
2172
- "\\ddddot",
2173
- "\\tilde",
2174
- "\\bar",
2175
- "\\breve",
2176
- "\\check",
2177
- "\\hat",
2178
- "\\vec",
2179
- "\\dot",
2180
- "\\mathring"
2181
- ]
2182
- .map((accent) => `\\${accent}`)
2183
- .join("|")
2184
- );
2223
+ const nonStretchyAccents = new Set([
2224
+ "\\acute",
2225
+ "\\grave",
2226
+ "\\ddot",
2227
+ "\\dddot",
2228
+ "\\ddddot",
2229
+ "\\tilde",
2230
+ "\\bar",
2231
+ "\\breve",
2232
+ "\\check",
2233
+ "\\hat",
2234
+ "\\vec",
2235
+ "\\dot",
2236
+ "\\mathring"
2237
+ ]);
2185
2238
 
2186
2239
  // Accents
2187
2240
  defineFunction({
@@ -2219,7 +2272,7 @@ defineFunction({
2219
2272
  handler: (context, args) => {
2220
2273
  const base = normalizeArgument(args[0]);
2221
2274
 
2222
- const isStretchy = !NON_STRETCHY_ACCENT_REGEX.test(context.funcName);
2275
+ const isStretchy = !nonStretchyAccents.has(context.funcName);
2223
2276
 
2224
2277
  return {
2225
2278
  type: "accent",
@@ -2257,7 +2310,6 @@ defineFunction({
2257
2310
  mode: mode,
2258
2311
  label: context.funcName,
2259
2312
  isStretchy: false,
2260
- isShifty: true,
2261
2313
  base: base
2262
2314
  };
2263
2315
  },
@@ -2287,7 +2339,7 @@ defineFunction({
2287
2339
  };
2288
2340
  },
2289
2341
  mathmlBuilder: (group, style) => {
2290
- const accentNode = stretchy.mathMLnode(group.label);
2342
+ const accentNode = stretchy.accentNode(group);
2291
2343
  accentNode.style["math-depth"] = 0;
2292
2344
  const node = new mathMLTree.MathNode("munder", [
2293
2345
  buildGroup$1(group.base, style),
@@ -3824,10 +3876,20 @@ const mathmlBuilder$8 = (group, style) => {
3824
3876
  node.style.borderBottom = "0.065em solid";
3825
3877
  break
3826
3878
  case "\\cancel":
3827
- node.classes.push("cancel");
3879
+ node.style.background = `linear-gradient(to top left,
3880
+ rgba(0,0,0,0) 0%,
3881
+ rgba(0,0,0,0) calc(50% - 0.06em),
3882
+ rgba(0,0,0,1) 50%,
3883
+ rgba(0,0,0,0) calc(50% + 0.06em),
3884
+ rgba(0,0,0,0) 100%);`;
3828
3885
  break
3829
3886
  case "\\bcancel":
3830
- node.classes.push("bcancel");
3887
+ node.style.background = `linear-gradient(to top right,
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%);`;
3831
3893
  break
3832
3894
  /*
3833
3895
  case "\\longdiv":
@@ -3871,7 +3933,18 @@ const mathmlBuilder$8 = (group, style) => {
3871
3933
  break
3872
3934
  }
3873
3935
  case "\\xcancel":
3874
- node.classes.push("xcancel");
3936
+ node.style.background = `linear-gradient(to top left,
3937
+ rgba(0,0,0,0) 0%,
3938
+ rgba(0,0,0,0) calc(50% - 0.06em),
3939
+ rgba(0,0,0,1) 50%,
3940
+ rgba(0,0,0,0) calc(50% + 0.06em),
3941
+ rgba(0,0,0,0) 100%),
3942
+ linear-gradient(to top right,
3943
+ rgba(0,0,0,0) 0%,
3944
+ rgba(0,0,0,0) calc(50% - 0.06em),
3945
+ rgba(0,0,0,1) 50%,
3946
+ rgba(0,0,0,0) calc(50% + 0.06em),
3947
+ rgba(0,0,0,0) 100%);`;
3875
3948
  break
3876
3949
  }
3877
3950
  if (group.backgroundColor) {
@@ -4302,24 +4375,98 @@ const mathmlBuilder$7 = function(group, style) {
4302
4375
  // Write horizontal rules
4303
4376
  if (i === 0 && hlines[0].length > 0) {
4304
4377
  if (hlines[0].length === 2) {
4305
- mtr.classes.push("tml-top-double");
4378
+ mtr.children.forEach(cell => { cell.style.borderTop = "0.15em double"; });
4306
4379
  } else {
4307
- mtr.classes.push(hlines[0][0] ? "tml-top-dashed" : "tml-top-solid");
4380
+ mtr.children.forEach(cell => {
4381
+ cell.style.borderTop = hlines[0][0] ? "0.06em dashed" : "0.06em solid";
4382
+ });
4308
4383
  }
4309
4384
  }
4310
4385
  if (hlines[i + 1].length > 0) {
4311
4386
  if (hlines[i + 1].length === 2) {
4312
- mtr.classes.push("tml-hline-double");
4387
+ mtr.children.forEach(cell => { cell.style.borderBottom = "0.15em double"; });
4313
4388
  } else {
4314
- mtr.classes.push(hlines[i + 1][0] ? "tml-hline-dashed" : "tml-hline-solid");
4389
+ mtr.children.forEach(cell => {
4390
+ cell.style.borderBottom = hlines[i + 1][0] ? "0.06em dashed" : "0.06em solid";
4391
+ });
4315
4392
  }
4316
4393
  }
4317
4394
  tbl.push(mtr);
4318
4395
  }
4319
- let table = new mathMLTree.MathNode("mtable", tbl);
4396
+
4320
4397
  if (group.envClasses.length > 0) {
4321
- table.classes = group.envClasses.map(e => "tml-" + e);
4398
+ const pad = group.envClasses.includes("jot")
4399
+ ? "0.7" // 0.5ex + 0.09em top & bot padding
4400
+ : group.envClasses.includes("small")
4401
+ ? "0.35"
4402
+ : "0.5"; // 0.5ex default top & bot padding
4403
+ const sidePadding = group.envClasses.includes("abut")
4404
+ ? "0"
4405
+ : group.envClasses.includes("cases")
4406
+ ? "0"
4407
+ : group.envClasses.includes("small")
4408
+ ? "0.1389"
4409
+ : group.envClasses.includes("cd")
4410
+ ? "0.25"
4411
+ : "0.4"; // default side padding
4412
+
4413
+ const numCols = tbl.length === 0 ? 0 : tbl[0].children.length;
4414
+
4415
+ const sidePad = (j, hand) => {
4416
+ if (j === 0 && hand === 0) { return "0" }
4417
+ if (j === numCols - 1 && hand === 1) { return "0" }
4418
+ if (group.envClasses[0] !== "align") { return sidePadding }
4419
+ if (hand === 1) { return "0" }
4420
+ if (group.addEqnNum) {
4421
+ return (j % 2) ? "1" : "0"
4422
+ } else {
4423
+ return (j % 2) ? "0" : "1"
4424
+ }
4425
+ };
4426
+
4427
+ // Padding
4428
+ for (let i = 0; i < tbl.length; i++) {
4429
+ for (let j = 0; j < tbl[i].children.length; j++) {
4430
+ tbl[i].children[j].style.padding = `${pad}ex ${sidePad(j, 1)}em ${pad}ex ${sidePad(j, 0)}em`;
4431
+ }
4432
+ }
4433
+
4434
+ // Justification
4435
+ const align = group.envClasses.includes("align") || group.envClasses.includes("alignat");
4436
+ for (let i = 0; i < tbl.length; i++) {
4437
+ const row = tbl[i];
4438
+ if (align) {
4439
+ for (let j = 0; j < row.children.length; j++) {
4440
+ // Chromium does not recognize text-align: left. Use -webkit-
4441
+ // TODO: Remove -webkit- when Chromium no longer needs it.
4442
+ row.children[j].style.textAlign = "-webkit-" + (j % 2 ? "left" : "right");
4443
+ }
4444
+ if (group.addEqnNum) {
4445
+ const k = group.leqno ? 0 : row.children.length - 1;
4446
+ row.children[k].style.textAlign = "-webkit-" + (group.leqno ? "left" : "right");
4447
+ }
4448
+ }
4449
+ if (row.children.length > 1 && group.envClasses.includes("cases")) {
4450
+ row.children[1].style.padding = row.children[1].style.padding.replace(/0em$/, "1em");
4451
+ }
4452
+
4453
+ if (group.envClasses.includes("cases") || group.envClasses.includes("subarray")) {
4454
+ for (const cell of row.children) {
4455
+ cell.style.textAlign = "-webkit-" + "left";
4456
+ }
4457
+ }
4458
+ }
4459
+ } else {
4460
+ // Set zero padding on side of the matrix
4461
+ for (let i = 0; i < tbl.length; i++) {
4462
+ tbl[i].children[0].style.paddingLeft = "0em";
4463
+ if (tbl[i].children.length === tbl[0].children.length) {
4464
+ tbl[i].children[tbl[i].children.length - 1].style.paddingRight = "0em";
4465
+ }
4466
+ }
4322
4467
  }
4468
+
4469
+ let table = new mathMLTree.MathNode("mtable", tbl);
4323
4470
  if (group.scriptLevel === "display") { table.setAttribute("displaystyle", "true"); }
4324
4471
 
4325
4472
  if (group.addEqnNum || group.envClasses.includes("multline")) {
@@ -4399,6 +4546,8 @@ const mathmlBuilder$7 = function(group, style) {
4399
4546
  align = "left " + (align.length > 0 ? align : "center ") + "right ";
4400
4547
  }
4401
4548
  if (align) {
4549
+ // Firefox reads this attribute, not the -webkit-left|right written above.
4550
+ // TODO: When Chrome no longer needs "-webkit-", use CSS and delete the next line.
4402
4551
  table.setAttribute("columnalign", align.trim());
4403
4552
  }
4404
4553
 
@@ -4423,7 +4572,7 @@ const alignedHandler = function(context, args) {
4423
4572
  cols,
4424
4573
  addEqnNum: context.envName === "align" || context.envName === "alignat",
4425
4574
  emptySingleRow: true,
4426
- envClasses: ["jot", "abut"], // set row spacing & provisional column spacing
4575
+ envClasses: ["abut", "jot"], // set row spacing & provisional column spacing
4427
4576
  maxNumCols: context.envName === "split" ? 2 : undefined,
4428
4577
  leqno: context.parser.settings.leqno
4429
4578
  },
@@ -4441,18 +4590,22 @@ const alignedHandler = function(context, args) {
4441
4590
  // binary. This behavior is implemented in amsmath's \start@aligned.
4442
4591
  let numMaths;
4443
4592
  let numCols = 0;
4444
- if (args[0] && args[0].type === "ordgroup") {
4593
+ const isAlignedAt = context.envName.indexOf("at") > -1;
4594
+ if (args[0] && isAlignedAt) {
4595
+ // alignat environment takes an argument w/ number of columns
4445
4596
  let arg0 = "";
4446
4597
  for (let i = 0; i < args[0].body.length; i++) {
4447
4598
  const textord = assertNodeType(args[0].body[i], "textord");
4448
4599
  arg0 += textord.text;
4449
4600
  }
4601
+ if (isNaN(arg0)) {
4602
+ throw new ParseError("The alignat enviroment requires a numeric first argument.")
4603
+ }
4450
4604
  numMaths = Number(arg0);
4451
4605
  numCols = numMaths * 2;
4452
4606
  }
4453
- const isAligned = !numCols;
4454
4607
  res.body.forEach(function(row) {
4455
- if (!isAligned) {
4608
+ if (isAlignedAt) {
4456
4609
  // Case 1
4457
4610
  const curMaths = row.length / 2;
4458
4611
  if (numMaths < curMaths) {
@@ -4480,14 +4633,10 @@ const alignedHandler = function(context, args) {
4480
4633
  align: align
4481
4634
  };
4482
4635
  }
4483
- if (context.envName === "split") ; else if (context.envName.indexOf("ed") > -1) {
4484
- res.envClasses.push("aligned"); // Sets justification
4485
- } else if (isAligned) {
4486
- res.envClasses[1] = context.envName === "align*"
4487
- ? "align-star"
4488
- : "align"; // Sets column spacing & justification
4636
+ if (context.envName === "split") ; else if (isAlignedAt) {
4637
+ res.envClasses.push("alignat"); // Sets justification
4489
4638
  } else {
4490
- res.envClasses.push("aligned"); // Sets justification
4639
+ res.envClasses[0] = "align"; // Sets column spacing & justification
4491
4640
  }
4492
4641
  return res;
4493
4642
  };
@@ -4737,7 +4886,7 @@ defineEnvironment({
4737
4886
  }
4738
4887
  const res = {
4739
4888
  cols: [],
4740
- envClasses: ["jot", "abut"],
4889
+ envClasses: ["abut", "jot"],
4741
4890
  addEqnNum: context.envName === "gather",
4742
4891
  emptySingleRow: true,
4743
4892
  leqno: context.parser.settings.leqno
@@ -7236,7 +7385,14 @@ defineFunctionBuilders({
7236
7385
  }
7237
7386
 
7238
7387
  if (group.sup) {
7239
- children.push(buildGroup$1(group.sup, childStyle));
7388
+ const sup = buildGroup$1(group.sup, childStyle);
7389
+ const testNode = sup.type === "mrow" ? sup.children[0] : sup;
7390
+ if ((testNode.type === "mo" && testNode.classes.includes("tml-prime"))
7391
+ && group.base && group.base.text && group.base.text === "f") {
7392
+ // Chromium does not address italic correction on prime. Prevent f′ from overlapping.
7393
+ testNode.classes.push("prime-pad");
7394
+ }
7395
+ children.push(sup);
7240
7396
  }
7241
7397
 
7242
7398
  let nodeType;
@@ -7702,6 +7858,8 @@ const smallCaps = Object.freeze({
7702
7858
 
7703
7859
  const numberRegEx = /^\d(?:[\d,.]*\d)?$/;
7704
7860
  const latinRegEx = /[A-Ba-z]/;
7861
+ const primes = new Set(["\\prime", "\\dprime", "\\trprime", "\\qprime",
7862
+ "\\backprime", "\\backdprime", "\\backtrprime"]);
7705
7863
 
7706
7864
  const italicNumber = (text, variant, tag) => {
7707
7865
  const mn = new mathMLTree.MathNode(tag, [text]);
@@ -7769,7 +7927,7 @@ defineFunctionBuilders({
7769
7927
  text.text = variantChar(text.text, variant);
7770
7928
  }
7771
7929
  node = new mathMLTree.MathNode("mtext", [text]);
7772
- } else if (group.text === "\\prime") {
7930
+ } else if (primes.has(group.text)) {
7773
7931
  node = new mathMLTree.MathNode("mo", [text]);
7774
7932
  // TODO: If/when Chromium uses ssty variant for prime, remove the next line.
7775
7933
  node.classes.push("tml-prime");
@@ -8423,6 +8581,9 @@ defineMacro("\\char", function(context) {
8423
8581
  // This macro provides a better rendering.
8424
8582
  defineMacro("\\surd", '\\sqrt{\\vphantom{|}}');
8425
8583
 
8584
+ // See comment for \oplus in symbols.js.
8585
+ defineMacro("\u2295", "\\oplus");
8586
+
8426
8587
  defineMacro("\\hbox", "\\text{#1}");
8427
8588
 
8428
8589
  // Per TeXbook p.122, "/" gets zero operator spacing.
@@ -12703,7 +12864,6 @@ class Parser {
12703
12864
  loc: SourceLocation.range(nucleus),
12704
12865
  label: command,
12705
12866
  isStretchy: false,
12706
- isShifty: true,
12707
12867
  base: symbol
12708
12868
  };
12709
12869
  }
@@ -12901,7 +13061,7 @@ class Style {
12901
13061
  * https://mit-license.org/
12902
13062
  */
12903
13063
 
12904
- const version = "0.10.14";
13064
+ const version = "0.10.16";
12905
13065
 
12906
13066
  function postProcess(block) {
12907
13067
  const labelMap = {};
@@ -12952,6 +13112,7 @@ function postProcess(block) {
12952
13112
  /* eslint no-console:0 */
12953
13113
 
12954
13114
  /**
13115
+ * @type {import('./temml').render}
12955
13116
  * Parse and build an expression, and place that expression in the DOM node
12956
13117
  * given.
12957
13118
  */
@@ -12989,6 +13150,7 @@ if (typeof document !== "undefined") {
12989
13150
  }
12990
13151
 
12991
13152
  /**
13153
+ * @type {import('./temml').renderToString}
12992
13154
  * Parse and build an expression, and return the markup for that.
12993
13155
  */
12994
13156
  const renderToString = function(expression, options) {
@@ -12997,6 +13159,7 @@ const renderToString = function(expression, options) {
12997
13159
  };
12998
13160
 
12999
13161
  /**
13162
+ * @type {import('./temml').generateParseTree}
13000
13163
  * Parse an expression and return the parse tree.
13001
13164
  */
13002
13165
  const generateParseTree = function(expression, options) {
@@ -13005,6 +13168,7 @@ const generateParseTree = function(expression, options) {
13005
13168
  };
13006
13169
 
13007
13170
  /**
13171
+ * @type {import('./temml').definePreamble}
13008
13172
  * Take an expression which contains a preamble.
13009
13173
  * Parse it and return the macros.
13010
13174
  */
@@ -13037,6 +13201,7 @@ const renderError = function(error, expression, options) {
13037
13201
  };
13038
13202
 
13039
13203
  /**
13204
+ * @type {import('./temml').renderToMathMLTree}
13040
13205
  * Generates and returns the Temml build tree. This is used for advanced
13041
13206
  * use cases (like rendering to custom output).
13042
13207
  */
@@ -13054,6 +13219,7 @@ const renderToMathMLTree = function(expression, options) {
13054
13219
  }
13055
13220
  };
13056
13221
 
13222
+ /** @type {import('./temml').default} */
13057
13223
  var temml = {
13058
13224
  /**
13059
13225
  * Current Temml version
@@ -0,0 +1,60 @@
1
+ export interface Options {
2
+ displayMode?: boolean;
3
+ annotate?: boolean;
4
+ leqno?: boolean;
5
+ throwOnError?: boolean;
6
+ errorColor?: string;
7
+ macros?: Record<string, string>;
8
+ wrap?: "tex" | "=" | "none";
9
+ xml?: boolean;
10
+ colorIsTextColor?: boolean;
11
+ strict?: boolean;
12
+ trust?: boolean | ((context: any) => boolean);
13
+ maxSize?: [number, number];
14
+ maxExpand?: number;
15
+ }
16
+
17
+ export function render(
18
+ expression: string,
19
+ baseNode: HTMLElement,
20
+ options?: Options,
21
+ ): void;
22
+
23
+ export function renderToString(expression: string, options?: Options): string;
24
+
25
+ export function generateParseTree(expression: string, options?: Options): any;
26
+
27
+ export function definePreamble(expression: string, options?: Options): any;
28
+
29
+ export function renderToMathMLTree(expression: string, options?: Options): any;
30
+
31
+ declare function postProcess(block: any): void;
32
+ declare function defineMacro(name: string, body: any): void;
33
+ declare function defineSymbol(
34
+ mode: string,
35
+ group: string,
36
+ replace: string,
37
+ name: string,
38
+ acceptUnicodeChar: boolean,
39
+ ): void;
40
+ declare class ParseError {
41
+ constructor(
42
+ message: string, // The error message
43
+ token: any, // An object providing position information
44
+ ) {}
45
+ }
46
+
47
+ declare const Temml: {
48
+ version: string;
49
+ render: typeof render;
50
+ renderToString: typeof renderToString;
51
+ postProcess: typeof postProcess;
52
+ ParseError: typeof ParseError;
53
+ definePreamble: typeof definePreamble;
54
+ __parse: typeof generateParseTree;
55
+ __renderToMathMLTree: typeof renderToMathMLTree;
56
+ __defineSymbol: typeof defineSymbol;
57
+ __defineMacro: typeof defineMacro;
58
+ };
59
+
60
+ export default Temml;