temml 0.10.16 → 0.10.18

Sign up to get free protection for your applications and to get access to all the features.
package/dist/temml.cjs CHANGED
@@ -1364,7 +1364,7 @@ defineSymbol(math, open, "\u00ac", "\\lnot");
1364
1364
  defineSymbol(math, textord, "\u22a4", "\\top");
1365
1365
  defineSymbol(math, textord, "\u22a5", "\\bot");
1366
1366
  defineSymbol(math, textord, "\u2205", "\\emptyset");
1367
- defineSymbol(math, textord, "\u00f8", "\\varnothing");
1367
+ defineSymbol(math, textord, "\u2300", "\\varnothing");
1368
1368
  defineSymbol(math, mathord, "\u03b1", "\\alpha", true);
1369
1369
  defineSymbol(math, mathord, "\u03b2", "\\beta", true);
1370
1370
  defineSymbol(math, mathord, "\u03b3", "\\gamma", true);
@@ -1425,6 +1425,8 @@ defineSymbol(math, bin, "\u2228", "\\vee", true);
1425
1425
  defineSymbol(math, open, "\u27e6", "\\llbracket", true); // stmaryrd/semantic packages
1426
1426
  defineSymbol(math, close, "\u27e7", "\\rrbracket", true);
1427
1427
  defineSymbol(math, open, "\u27e8", "\\langle", true);
1428
+ defineSymbol(math, open, "\u27ea", "\\lAngle", true);
1429
+ defineSymbol(math, open, "\u2989", "\\llangle", true);
1428
1430
  defineSymbol(math, open, "|", "\\lvert");
1429
1431
  defineSymbol(math, open, "\u2016", "\\lVert");
1430
1432
  defineSymbol(math, textord, "!", "\\oc"); // cmll package
@@ -1436,6 +1438,8 @@ defineSymbol(math, close, "?", "?");
1436
1438
  defineSymbol(math, close, "!", "!");
1437
1439
  defineSymbol(math, close, "‼", "‼");
1438
1440
  defineSymbol(math, close, "\u27e9", "\\rangle", true);
1441
+ defineSymbol(math, close, "\u27eb", "\\rAngle", true);
1442
+ defineSymbol(math, close, "\u298a", "\\rrangle", true);
1439
1443
  defineSymbol(math, close, "|", "\\rvert");
1440
1444
  defineSymbol(math, close, "\u2016", "\\rVert");
1441
1445
  defineSymbol(math, open, "\u2983", "\\lBrace", true); // stmaryrd/semantic packages
@@ -1517,6 +1521,8 @@ defineSymbol(math, close, "]", "\\rbrack", true);
1517
1521
  defineSymbol(text, textord, "]", "\\rbrack", true);
1518
1522
  defineSymbol(math, open, "(", "\\lparen", true);
1519
1523
  defineSymbol(math, close, ")", "\\rparen", true);
1524
+ defineSymbol(math, open, "⦇", "\\llparenthesis", true);
1525
+ defineSymbol(math, close, "⦈", "\\rrparenthesis", true);
1520
1526
  defineSymbol(text, textord, "<", "\\textless", true); // in T1 fontenc
1521
1527
  defineSymbol(text, textord, ">", "\\textgreater", true); // in T1 fontenc
1522
1528
  defineSymbol(math, open, "\u230a", "\\lfloor", true);
@@ -1554,6 +1560,7 @@ defineSymbol(math, op, "\u2211", "\\sum");
1554
1560
  defineSymbol(math, op, "\u2a02", "\\bigotimes");
1555
1561
  defineSymbol(math, op, "\u2a01", "\\bigoplus");
1556
1562
  defineSymbol(math, op, "\u2a00", "\\bigodot");
1563
+ defineSymbol(math, op, "\u2a09", "\\bigtimes");
1557
1564
  defineSymbol(math, op, "\u222e", "\\oint");
1558
1565
  defineSymbol(math, op, "\u222f", "\\oiint");
1559
1566
  defineSymbol(math, op, "\u2230", "\\oiiint");
@@ -1673,6 +1680,8 @@ defineSymbol(text, textord, "\u20ac", "\\euro", true);
1673
1680
  defineSymbol(text, textord, "\u20ac", "\\texteuro");
1674
1681
  defineSymbol(math, textord, "\u00a9", "\\copyright", true);
1675
1682
  defineSymbol(text, textord, "\u00a9", "\\textcopyright");
1683
+ defineSymbol(math, textord, "\u2300", "\\diameter", true);
1684
+ defineSymbol(text, textord, "\u2300", "\\diameter");
1676
1685
 
1677
1686
  // Italic Greek
1678
1687
  defineSymbol(math, textord, "𝛤", "\\varGamma");
@@ -1721,8 +1730,6 @@ for (let i = 0; i < letters.length; i++) {
1721
1730
  defineSymbol(math, mathord, ch, ch);
1722
1731
  defineSymbol(text, textord, ch, ch);
1723
1732
  }
1724
- // Prevent Firefox from using a dotless i.
1725
- defineSymbol(text, textord, "i\uFE0E", "i");
1726
1733
 
1727
1734
  // Some more letters in Unicode Basic Multilingual Plane.
1728
1735
  const narrow = "ÇÐÞçþℂℍℕℙℚℝℤℎℏℊℋℌℐℑℒℓ℘ℛℜℬℰℱℳℭℨ";
@@ -1966,7 +1973,7 @@ const makeText = function(text, mode, style) {
1966
1973
 
1967
1974
  const consolidateText = mrow => {
1968
1975
  // If possible, consolidate adjacent <mtext> elements into a single element.
1969
- if (mrow.type !== "mrow") { return mrow }
1976
+ if (mrow.type !== "mrow" && mrow.type !== "mstyle") { return mrow }
1970
1977
  if (mrow.children.length === 0) { return mrow } // empty group, e.g., \text{}
1971
1978
  if (!mrow.children[0].attributes || mrow.children[0].type !== "mtext") { return mrow }
1972
1979
  const variant = mrow.children[0].attributes.mathvariant || "";
@@ -2003,6 +2010,9 @@ const consolidateText = mrow => {
2003
2010
  if (L > 0 && mtext.children[0].text.charAt(L - 1) === " ") {
2004
2011
  mtext.children[0].text = mtext.children[0].text.slice(0, -1) + "\u00a0";
2005
2012
  }
2013
+ for (const [key, value] of Object.entries(mrow.attributes)) {
2014
+ mtext.attributes[key] = value;
2015
+ }
2006
2016
  return mtext
2007
2017
  };
2008
2018
 
@@ -2056,6 +2066,14 @@ const makeRow = function(body) {
2056
2066
  if (body.length === 1 && !(body[0] instanceof DocumentFragment)) {
2057
2067
  return body[0];
2058
2068
  } else {
2069
+ // Suppress spacing on <mo> nodes at both ends of the row.
2070
+ if (body[0] instanceof MathNode && body[0].type === "mo" && !body[0].attributes.fence) {
2071
+ body[0].attributes.lspace = "0em";
2072
+ }
2073
+ const end = body.length - 1;
2074
+ if (body[end] instanceof MathNode && body[end].type === "mo" && !body[end].attributes.fence) {
2075
+ body[end].attributes.rspace = "0em";
2076
+ }
2059
2077
  return new mathMLTree.MathNode("mrow", body);
2060
2078
  }
2061
2079
  };
@@ -2137,13 +2155,8 @@ const taggedExpression = (expression, tag, style, leqno) => {
2137
2155
 
2138
2156
  expression = new mathMLTree.MathNode("mtd", [expression]);
2139
2157
  const rowArray = [glue$1(), expression, glue$1()];
2140
- if (leqno) {
2141
- rowArray[0].children.push(tag);
2142
- rowArray[0].style.textAlign = "-webkit-left";
2143
- } else {
2144
- rowArray[2].children.push(tag);
2145
- rowArray[2].style.textAlign = "-webkit-right";
2146
- }
2158
+ rowArray[leqno ? 0 : 2].classes.push(leqno ? "tml-left" : "tml-right");
2159
+ rowArray[leqno ? 0 : 2].children.push(tag);
2147
2160
  const mtr = new mathMLTree.MathNode("mtr", rowArray, ["tml-tageqn"]);
2148
2161
  const table = new mathMLTree.MathNode("mtable", [mtr]);
2149
2162
  table.style.width = "100%";
@@ -2198,6 +2211,15 @@ function buildMathML(tree, texExpression, style, settings) {
2198
2211
  return math;
2199
2212
  }
2200
2213
 
2214
+ const smalls = "acegıȷmnopqrsuvwxyzαγεηικμνοπρςστυχωϕ𝐚𝐜𝐞𝐠𝐦𝐧𝐨𝐩𝐪𝐫𝐬𝐮𝐯𝐰𝐱𝐲𝐳";
2215
+ const talls = "ABCDEFGHIJKLMNOPQRSTUVWXYZbdfhkltΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩβδλζφθψ"
2216
+ + "𝐀𝐁𝐂𝐃𝐄𝐅𝐆𝐇𝐈𝐉𝐊𝐋𝐌𝐍𝐎𝐏𝐐𝐑𝐒𝐓𝐔𝐕𝐖𝐗𝐘𝐙𝐛𝐝𝐟𝐡𝐤𝐥𝐭";
2217
+ const longSmalls = new Set(["\\alpha", "\\gamma", "\\delta", "\\epsilon", "\\eta", "\\iota",
2218
+ "\\kappa", "\\mu", "\\nu", "\\pi", "\\rho", "\\sigma", "\\tau", "\\upsilon", "\\chi", "\\psi",
2219
+ "\\omega", "\\imath", "\\jmath"]);
2220
+ const longTalls = new Set(["\\Gamma", "\\Delta", "\\Sigma", "\\Omega", "\\beta", "\\delta",
2221
+ "\\lambda", "\\theta", "\\psi"]);
2222
+
2201
2223
  const mathmlBuilder$a = (group, style) => {
2202
2224
  const accentNode = group.isStretchy
2203
2225
  ? stretchy.accentNode(group)
@@ -2208,6 +2230,13 @@ const mathmlBuilder$a = (group, style) => {
2208
2230
  } else {
2209
2231
  accentNode.style.mathStyle = "normal";
2210
2232
  accentNode.style.mathDepth = "0";
2233
+ if (needWebkitShift.has(group.label) && utils.isCharacterBox(group.base)) {
2234
+ let shift = "";
2235
+ const ch = group.base.text;
2236
+ if (smalls.indexOf(ch) > -1 || longSmalls.has(ch)) { shift = "tml-xshift"; }
2237
+ if (talls.indexOf(ch) > -1 || longTalls.has(ch)) { shift = "tml-capshift"; }
2238
+ if (shift) { accentNode.classes.push(shift); }
2239
+ }
2211
2240
  }
2212
2241
  if (!group.isStretchy) {
2213
2242
  accentNode.setAttribute("stretchy", "false");
@@ -2236,6 +2265,19 @@ const nonStretchyAccents = new Set([
2236
2265
  "\\mathring"
2237
2266
  ]);
2238
2267
 
2268
+ const needWebkitShift = new Set([
2269
+ "\\acute",
2270
+ "\\bar",
2271
+ "\\breve",
2272
+ "\\check",
2273
+ "\\dot",
2274
+ "\\ddot",
2275
+ "\\grave",
2276
+ "\\hat",
2277
+ "\\mathring",
2278
+ "\\'", "\\^", "\\~", "\\=", "\\u", "\\.", '\\"', "\\r", "\\H", "\\v"
2279
+ ]);
2280
+
2239
2281
  // Accents
2240
2282
  defineFunction({
2241
2283
  type: "accent",
@@ -3577,6 +3619,10 @@ const delimiters = [
3577
3619
  "\\lbrace",
3578
3620
  "\\}",
3579
3621
  "\\rbrace",
3622
+ "⦇",
3623
+ "\\llparenthesis",
3624
+ "⦈",
3625
+ "\\rrparenthesis",
3580
3626
  "\\lfloor",
3581
3627
  "\\rfloor",
3582
3628
  "\u230a",
@@ -3591,6 +3637,14 @@ const delimiters = [
3591
3637
  "\u27e8",
3592
3638
  "\\rangle",
3593
3639
  "\u27e9",
3640
+ "\\lAngle",
3641
+ "\u27ea",
3642
+ "\\rAngle",
3643
+ "\u27eb",
3644
+ "\\llangle",
3645
+ "⦉",
3646
+ "\\rrangle",
3647
+ "⦊",
3594
3648
  "\\lt",
3595
3649
  "\\gt",
3596
3650
  "\\lvert",
@@ -3712,9 +3766,9 @@ defineFunction({
3712
3766
  // defaults.
3713
3767
  node.setAttribute("fence", "false");
3714
3768
  }
3715
- if (group.delim === "\u2216" || group.delim.indexOf("arrow") > -1) {
3716
- // \backslash is not in the operator dictionary,
3717
- // so we have to explicitly set stretchy to true.
3769
+ if (group.delim === "\u2216" || group.delim === "\\vert" ||
3770
+ group.delim === "|" || group.delim.indexOf("arrow") > -1) {
3771
+ // We have to explicitly set stretchy to true.
3718
3772
  node.setAttribute("stretchy", "true");
3719
3773
  }
3720
3774
  node.setAttribute("symmetric", "true"); // Needed for tall arrows in Firefox.
@@ -3905,7 +3959,10 @@ rgba(0,0,0,0) 100%);`;
3905
3959
  node.style.marginRight = "0.03889em";
3906
3960
  break
3907
3961
  case "\\sout":
3908
- node.style["text-decoration"] = "line-through 0.08em solid";
3962
+ node.style.backgroundImage = 'linear-gradient(black, black)';
3963
+ node.style.backgroundRepeat = 'no-repeat';
3964
+ node.style.backgroundSize = '100% 1.5px';
3965
+ node.style.backgroundPosition = '0 center';
3909
3966
  break
3910
3967
  case "\\boxed":
3911
3968
  // \newcommand{\boxed}[1]{\fbox{\m@th$\displaystyle#1$}} from amsmath.sty
@@ -4156,8 +4213,9 @@ const getTag = (group, style, rowNum) => {
4156
4213
  return tag
4157
4214
  } else {
4158
4215
  // AMS automatcally numbered equaton.
4159
- // Insert a class so the element can be populated by a post-processor.
4160
- tag = new mathMLTree.MathNode("mtext", [], ["tml-eqn"]);
4216
+ // Insert a class so the element can be populated by a CSS counter.
4217
+ // WebKit will display the CSS counter only inside a span.
4218
+ tag = new mathMLTree.MathNode("mtext", [new Span(["tml-eqn"])]);
4161
4219
  }
4162
4220
  return tag
4163
4221
  };
@@ -4354,7 +4412,7 @@ const mathmlBuilder$7 = function(group, style) {
4354
4412
  const align = i === 0 ? "left" : i === numRows - 1 ? "right" : "center";
4355
4413
  mtd.setAttribute("columnalign", align);
4356
4414
  if (align !== "center") {
4357
- mtd.style.textAlign = "-webkit-" + align;
4415
+ mtd.classes.push("tml-" + align);
4358
4416
  }
4359
4417
  }
4360
4418
  row.push(mtd);
@@ -4365,10 +4423,10 @@ const mathmlBuilder$7 = function(group, style) {
4365
4423
  const tag = getTag(group, style.withLevel(cellLevel), i);
4366
4424
  if (group.leqno) {
4367
4425
  row[0].children.push(tag);
4368
- row[0].style.textAlign = "-webkit-left";
4426
+ row[0].classes.push("tml-left");
4369
4427
  } else {
4370
4428
  row[row.length - 1].children.push(tag);
4371
- row[row.length - 1].style.textAlign = "-webkit-right";
4429
+ row[row.length - 1].classes.push("tml-right");
4372
4430
  }
4373
4431
  }
4374
4432
  const mtr = new mathMLTree.MathNode("mtr", row, []);
@@ -4439,11 +4497,11 @@ const mathmlBuilder$7 = function(group, style) {
4439
4497
  for (let j = 0; j < row.children.length; j++) {
4440
4498
  // Chromium does not recognize text-align: left. Use -webkit-
4441
4499
  // TODO: Remove -webkit- when Chromium no longer needs it.
4442
- row.children[j].style.textAlign = "-webkit-" + (j % 2 ? "left" : "right");
4500
+ row.children[j].classes = ["tml-" + (j % 2 ? "left" : "right")];
4443
4501
  }
4444
4502
  if (group.addEqnNum) {
4445
4503
  const k = group.leqno ? 0 : row.children.length - 1;
4446
- row.children[k].style.textAlign = "-webkit-" + (group.leqno ? "left" : "right");
4504
+ row.children[k].classes = ["tml-" + (group.leqno ? "left" : "right")];
4447
4505
  }
4448
4506
  }
4449
4507
  if (row.children.length > 1 && group.envClasses.includes("cases")) {
@@ -4452,7 +4510,7 @@ const mathmlBuilder$7 = function(group, style) {
4452
4510
 
4453
4511
  if (group.envClasses.includes("cases") || group.envClasses.includes("subarray")) {
4454
4512
  for (const cell of row.children) {
4455
- cell.style.textAlign = "-webkit-" + "left";
4513
+ cell.classes.push("tml-left");
4456
4514
  }
4457
4515
  }
4458
4516
  }
@@ -4507,7 +4565,7 @@ const mathmlBuilder$7 = function(group, style) {
4507
4565
  iCol += 1;
4508
4566
  for (const row of table.children) {
4509
4567
  if (colAlign.trim() !== "center" && iCol < row.children.length) {
4510
- row.children[iCol].style.textAlign = "-webkit-" + colAlign.trim();
4568
+ row.children[iCol].classes = ["tml-" + colAlign.trim()];
4511
4569
  }
4512
4570
  }
4513
4571
  prevTypeWasAlign = true;
@@ -5500,6 +5558,33 @@ defineFunction({
5500
5558
  mathmlBuilder: mathmlBuilder$5
5501
5559
  });
5502
5560
 
5561
+ // \hbox is provided for compatibility with LaTeX functions that act on a box.
5562
+ // This function by itself doesn't do anything but set scriptlevel to \textstyle
5563
+ // and prevent a soft line break.
5564
+
5565
+ defineFunction({
5566
+ type: "hbox",
5567
+ names: ["\\hbox"],
5568
+ props: {
5569
+ numArgs: 1,
5570
+ argTypes: ["hbox"],
5571
+ allowedInArgument: true,
5572
+ allowedInText: false
5573
+ },
5574
+ handler({ parser }, args) {
5575
+ return {
5576
+ type: "hbox",
5577
+ mode: parser.mode,
5578
+ body: ordargument(args[0])
5579
+ };
5580
+ },
5581
+ mathmlBuilder(group, style) {
5582
+ const newStyle = style.withLevel(StyleLevel.TEXT);
5583
+ const mrow = buildExpressionRow(group.body, newStyle);
5584
+ return consolidateText(mrow)
5585
+ }
5586
+ });
5587
+
5503
5588
  const mathmlBuilder$4 = (group, style) => {
5504
5589
  const accentNode = stretchy.mathMLnode(group.label);
5505
5590
  accentNode.style["math-depth"] = 0;
@@ -6469,7 +6554,8 @@ const singleCharBigOps = {
6469
6554
  "\u2a02": "\\bigotimes",
6470
6555
  "\u2a04": "\\biguplus",
6471
6556
  "\u2a05": "\\bigsqcap",
6472
- "\u2a06": "\\bigsqcup"
6557
+ "\u2a06": "\\bigsqcup",
6558
+ "\u2a09": "\\bigtimes"
6473
6559
  };
6474
6560
 
6475
6561
  defineFunction({
@@ -6489,6 +6575,7 @@ defineFunction({
6489
6575
  "\\bigodot",
6490
6576
  "\\bigsqcap",
6491
6577
  "\\bigsqcup",
6578
+ "\\bigtimes",
6492
6579
  "\\smallint",
6493
6580
  "\u220F",
6494
6581
  "\u2210",
@@ -8584,8 +8671,6 @@ defineMacro("\\surd", '\\sqrt{\\vphantom{|}}');
8584
8671
  // See comment for \oplus in symbols.js.
8585
8672
  defineMacro("\u2295", "\\oplus");
8586
8673
 
8587
- defineMacro("\\hbox", "\\text{#1}");
8588
-
8589
8674
  // Per TeXbook p.122, "/" gets zero operator spacing.
8590
8675
  // And MDN recommends using U+2044 instead of / for inline
8591
8676
  defineMacro("/", "{\u2044}");
@@ -8668,6 +8753,7 @@ const dotsByToken = {
8668
8753
  "\\bigodot": "\\dotsb",
8669
8754
  "\\bigsqcap": "\\dotsb",
8670
8755
  "\\bigsqcup": "\\dotsb",
8756
+ "\\bigtimes": "\\dotsb",
8671
8757
  "\\And": "\\dotsb",
8672
8758
  "\\longrightarrow": "\\dotsb",
8673
8759
  "\\Longrightarrow": "\\dotsb",
@@ -13061,7 +13147,7 @@ class Style {
13061
13147
  * https://mit-license.org/
13062
13148
  */
13063
13149
 
13064
- const version = "0.10.16";
13150
+ const version = "0.10.18";
13065
13151
 
13066
13152
  function postProcess(block) {
13067
13153
  const labelMap = {};
@@ -13116,9 +13202,9 @@ function postProcess(block) {
13116
13202
  * Parse and build an expression, and place that expression in the DOM node
13117
13203
  * given.
13118
13204
  */
13119
- let render = function(expression, baseNode, options) {
13205
+ let render = function(expression, baseNode, options = {}) {
13120
13206
  baseNode.textContent = "";
13121
- const alreadyInMathElement = baseNode.tagName === "MATH";
13207
+ const alreadyInMathElement = baseNode.tagName.toLowerCase() === "math";
13122
13208
  if (alreadyInMathElement) { options.wrap = "none"; }
13123
13209
  const math = renderToMathMLTree(expression, options);
13124
13210
  if (alreadyInMathElement) {