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