temml 0.10.12 → 0.10.13

Sign up to get free protection for your applications and to get access to all the features.
package/dist/temml.cjs CHANGED
@@ -970,6 +970,7 @@ defineSymbol(math, rel, "\u21c1", "\\rightharpoondown", true);
970
970
  defineSymbol(math, rel, "\u2196", "\\nwarrow", true);
971
971
  defineSymbol(math, rel, "\u21cc", "\\rightleftharpoons", true);
972
972
  defineSymbol(math, mathord, "\u21af", "\\lightning", true);
973
+ defineSymbol(math, mathord, "\u220E", "\\QED", true);
973
974
  defineSymbol(math, mathord, "\u2030", "\\permil", true);
974
975
  defineSymbol(text, textord, "\u2030", "\\permil");
975
976
 
@@ -2418,43 +2419,69 @@ const paddedNode = (group, lspace = 0.3, rspace = 0) => {
2418
2419
  return new mathMLTree.MathNode("mrow", row)
2419
2420
  };
2420
2421
 
2421
- const labelSize = (size, scriptLevel) => (size / emScale(scriptLevel)).toFixed(4);
2422
+ const labelSize = (size, scriptLevel) => Number(size) / emScale(scriptLevel);
2422
2423
 
2423
- const munderoverNode = (name, body, below, style) => {
2424
- const arrowNode = stretchy.mathMLnode(name);
2424
+ const munderoverNode = (fName, body, below, style) => {
2425
+ const arrowNode = stretchy.mathMLnode(fName);
2425
2426
  // Is this the short part of a mhchem equilibrium arrow?
2426
- const isEq = name.slice(1, 3) === "eq";
2427
- const minWidth = name.charAt(1) === "x"
2428
- ? "1.75" // mathtools extensible arrows are 1.75em long
2429
- : name.slice(2, 4) === "cd"
2427
+ const isEq = fName.slice(1, 3) === "eq";
2428
+ const minWidth = fName.charAt(1) === "x"
2429
+ ? "1.75" // mathtools extensible arrows are 1.75em long
2430
+ : fName.slice(2, 4) === "cd"
2430
2431
  ? "3.0" // cd package arrows
2431
2432
  : isEq
2432
2433
  ? "1.0" // The shorter harpoon of a mhchem equilibrium arrow
2433
2434
  : "2.0"; // other mhchem arrows
2434
- arrowNode.setAttribute("minsize", String(minWidth) + "em");
2435
+ // TODO: When Firefox supports minsize, use the next line.
2436
+ //arrowNode.setAttribute("minsize", String(minWidth) + "em")
2435
2437
  arrowNode.setAttribute("lspace", "0");
2436
2438
  arrowNode.setAttribute("rspace", (isEq ? "0.5em" : "0"));
2437
2439
 
2438
2440
  // <munderover> upper and lower labels are set to scriptlevel by MathML
2439
- // So we have to adjust our dimensions accordingly.
2441
+ // So we have to adjust our label dimensions accordingly.
2440
2442
  const labelStyle = style.withLevel(style.level < 2 ? 2 : 3);
2441
- const emptyLabelWidth = labelSize(minWidth, labelStyle.level);
2442
- const lspace = labelSize((isEq ? 0 : 0.3), labelStyle.level);
2443
- const rspace = labelSize((isEq ? 0 : 0.3), labelStyle.level);
2444
-
2445
- const upperNode = (body && body.body &&
2443
+ const minArrowWidth = labelSize(minWidth, labelStyle.level);
2444
+ // The dummyNode will be inside a <mover> inside a <mover>
2445
+ // So it will be at scriptlevel 3
2446
+ const dummyWidth = labelSize(minWidth, 3);
2447
+ const emptyLabel = paddedNode(null, minArrowWidth.toFixed(4), 0);
2448
+ const dummyNode = paddedNode(null, dummyWidth.toFixed(4), 0);
2449
+ // The arrow is a little longer than the label. Set a spacer length.
2450
+ const space = labelSize((isEq ? 0 : 0.3), labelStyle.level).toFixed(4);
2451
+ let upperNode;
2452
+ let lowerNode;
2453
+
2454
+ const gotUpper = (body && body.body &&
2446
2455
  // \hphantom visible content
2447
- (body.body.body || body.body.length > 0))
2448
- ? paddedNode(buildGroup$1(body, labelStyle), lspace, rspace)
2449
- // Since Firefox does not recognize minsize set on the arrow,
2450
- // create an upper node w/correct width.
2451
- : paddedNode(null, emptyLabelWidth, 0);
2452
- const lowerNode = (below && below.body &&
2453
- (below.body.body || below.body.length > 0))
2454
- ? paddedNode(buildGroup$1(below, labelStyle), lspace, rspace)
2455
- : paddedNode(null, emptyLabelWidth, 0);
2456
- const node = new mathMLTree.MathNode("munderover", [arrowNode, lowerNode, upperNode]);
2457
- if (minWidth === "3.0") { node.style.height = "1em"; }
2456
+ (body.body.body || body.body.length > 0));
2457
+ if (gotUpper) {
2458
+ let label = buildGroup$1(body, labelStyle);
2459
+ label = paddedNode(label, space, space);
2460
+ // Since Firefox does not support minsize, stack a invisible node
2461
+ // on top of the label. Its width will serve as a min-width.
2462
+ // TODO: Refactor this after Firefox supports minsize.
2463
+ upperNode = new mathMLTree.MathNode("mover", [label, dummyNode]);
2464
+ }
2465
+ const gotLower = (below && below.body &&
2466
+ (below.body.body || below.body.length > 0));
2467
+ if (gotLower) {
2468
+ let label = buildGroup$1(below, labelStyle);
2469
+ label = paddedNode(label, space, space);
2470
+ lowerNode = new mathMLTree.MathNode("munder", [label, dummyNode]);
2471
+ }
2472
+
2473
+ let node;
2474
+ if (!gotUpper && !gotLower) {
2475
+ node = new mathMLTree.MathNode("mover", [arrowNode, emptyLabel]);
2476
+ } else if (gotUpper && gotLower) {
2477
+ node = new mathMLTree.MathNode("munderover", [arrowNode, lowerNode, upperNode]);
2478
+ } else if (gotUpper) {
2479
+ node = new mathMLTree.MathNode("mover", [arrowNode, upperNode]);
2480
+ } else {
2481
+ node = new mathMLTree.MathNode("munder", [arrowNode, lowerNode]);
2482
+ }
2483
+ if (minWidth === "3.0") { node.style.height = "1em"; } // CD environment
2484
+ node.setAttribute("accent", "false"); // Necessary for MS Word
2458
2485
  return node
2459
2486
  };
2460
2487
 
@@ -2533,7 +2560,7 @@ defineFunction({
2533
2560
  "\\xleftrightharpoons", // mathtools
2534
2561
  "\\xrightleftharpoons", // mathtools
2535
2562
  "\\yieldsLeftRight", // mhchem
2536
- "\\equilibrium", // mhchem
2563
+ "\\equilibrium", // mhchem
2537
2564
  "\\equilibriumRight",
2538
2565
  "\\equilibriumLeft"
2539
2566
  ],
@@ -12877,7 +12904,7 @@ class Style {
12877
12904
  * https://mit-license.org/
12878
12905
  */
12879
12906
 
12880
- const version = "0.10.12";
12907
+ const version = "0.10.13";
12881
12908
 
12882
12909
  function postProcess(block) {
12883
12910
  const labelMap = {};
package/dist/temml.js CHANGED
@@ -971,6 +971,7 @@ var temml = (function () {
971
971
  defineSymbol(math, rel, "\u2196", "\\nwarrow", true);
972
972
  defineSymbol(math, rel, "\u21cc", "\\rightleftharpoons", true);
973
973
  defineSymbol(math, mathord, "\u21af", "\\lightning", true);
974
+ defineSymbol(math, mathord, "\u220E", "\\QED", true);
974
975
  defineSymbol(math, mathord, "\u2030", "\\permil", true);
975
976
  defineSymbol(text, textord, "\u2030", "\\permil");
976
977
 
@@ -2419,43 +2420,69 @@ var temml = (function () {
2419
2420
  return new mathMLTree.MathNode("mrow", row)
2420
2421
  };
2421
2422
 
2422
- const labelSize = (size, scriptLevel) => (size / emScale(scriptLevel)).toFixed(4);
2423
+ const labelSize = (size, scriptLevel) => Number(size) / emScale(scriptLevel);
2423
2424
 
2424
- const munderoverNode = (name, body, below, style) => {
2425
- const arrowNode = stretchy.mathMLnode(name);
2425
+ const munderoverNode = (fName, body, below, style) => {
2426
+ const arrowNode = stretchy.mathMLnode(fName);
2426
2427
  // Is this the short part of a mhchem equilibrium arrow?
2427
- const isEq = name.slice(1, 3) === "eq";
2428
- const minWidth = name.charAt(1) === "x"
2429
- ? "1.75" // mathtools extensible arrows are 1.75em long
2430
- : name.slice(2, 4) === "cd"
2428
+ const isEq = fName.slice(1, 3) === "eq";
2429
+ const minWidth = fName.charAt(1) === "x"
2430
+ ? "1.75" // mathtools extensible arrows are 1.75em long
2431
+ : fName.slice(2, 4) === "cd"
2431
2432
  ? "3.0" // cd package arrows
2432
2433
  : isEq
2433
2434
  ? "1.0" // The shorter harpoon of a mhchem equilibrium arrow
2434
2435
  : "2.0"; // other mhchem arrows
2435
- arrowNode.setAttribute("minsize", String(minWidth) + "em");
2436
+ // TODO: When Firefox supports minsize, use the next line.
2437
+ //arrowNode.setAttribute("minsize", String(minWidth) + "em")
2436
2438
  arrowNode.setAttribute("lspace", "0");
2437
2439
  arrowNode.setAttribute("rspace", (isEq ? "0.5em" : "0"));
2438
2440
 
2439
2441
  // <munderover> upper and lower labels are set to scriptlevel by MathML
2440
- // So we have to adjust our dimensions accordingly.
2442
+ // So we have to adjust our label dimensions accordingly.
2441
2443
  const labelStyle = style.withLevel(style.level < 2 ? 2 : 3);
2442
- const emptyLabelWidth = labelSize(minWidth, labelStyle.level);
2443
- const lspace = labelSize((isEq ? 0 : 0.3), labelStyle.level);
2444
- const rspace = labelSize((isEq ? 0 : 0.3), labelStyle.level);
2445
-
2446
- const upperNode = (body && body.body &&
2444
+ const minArrowWidth = labelSize(minWidth, labelStyle.level);
2445
+ // The dummyNode will be inside a <mover> inside a <mover>
2446
+ // So it will be at scriptlevel 3
2447
+ const dummyWidth = labelSize(minWidth, 3);
2448
+ const emptyLabel = paddedNode(null, minArrowWidth.toFixed(4), 0);
2449
+ const dummyNode = paddedNode(null, dummyWidth.toFixed(4), 0);
2450
+ // The arrow is a little longer than the label. Set a spacer length.
2451
+ const space = labelSize((isEq ? 0 : 0.3), labelStyle.level).toFixed(4);
2452
+ let upperNode;
2453
+ let lowerNode;
2454
+
2455
+ const gotUpper = (body && body.body &&
2447
2456
  // \hphantom visible content
2448
- (body.body.body || body.body.length > 0))
2449
- ? paddedNode(buildGroup$1(body, labelStyle), lspace, rspace)
2450
- // Since Firefox does not recognize minsize set on the arrow,
2451
- // create an upper node w/correct width.
2452
- : paddedNode(null, emptyLabelWidth, 0);
2453
- const lowerNode = (below && below.body &&
2454
- (below.body.body || below.body.length > 0))
2455
- ? paddedNode(buildGroup$1(below, labelStyle), lspace, rspace)
2456
- : paddedNode(null, emptyLabelWidth, 0);
2457
- const node = new mathMLTree.MathNode("munderover", [arrowNode, lowerNode, upperNode]);
2458
- if (minWidth === "3.0") { node.style.height = "1em"; }
2457
+ (body.body.body || body.body.length > 0));
2458
+ if (gotUpper) {
2459
+ let label = buildGroup$1(body, labelStyle);
2460
+ label = paddedNode(label, space, space);
2461
+ // Since Firefox does not support minsize, stack a invisible node
2462
+ // on top of the label. Its width will serve as a min-width.
2463
+ // TODO: Refactor this after Firefox supports minsize.
2464
+ upperNode = new mathMLTree.MathNode("mover", [label, dummyNode]);
2465
+ }
2466
+ const gotLower = (below && below.body &&
2467
+ (below.body.body || below.body.length > 0));
2468
+ if (gotLower) {
2469
+ let label = buildGroup$1(below, labelStyle);
2470
+ label = paddedNode(label, space, space);
2471
+ lowerNode = new mathMLTree.MathNode("munder", [label, dummyNode]);
2472
+ }
2473
+
2474
+ let node;
2475
+ if (!gotUpper && !gotLower) {
2476
+ node = new mathMLTree.MathNode("mover", [arrowNode, emptyLabel]);
2477
+ } else if (gotUpper && gotLower) {
2478
+ node = new mathMLTree.MathNode("munderover", [arrowNode, lowerNode, upperNode]);
2479
+ } else if (gotUpper) {
2480
+ node = new mathMLTree.MathNode("mover", [arrowNode, upperNode]);
2481
+ } else {
2482
+ node = new mathMLTree.MathNode("munder", [arrowNode, lowerNode]);
2483
+ }
2484
+ if (minWidth === "3.0") { node.style.height = "1em"; } // CD environment
2485
+ node.setAttribute("accent", "false"); // Necessary for MS Word
2459
2486
  return node
2460
2487
  };
2461
2488
 
@@ -2534,7 +2561,7 @@ var temml = (function () {
2534
2561
  "\\xleftrightharpoons", // mathtools
2535
2562
  "\\xrightleftharpoons", // mathtools
2536
2563
  "\\yieldsLeftRight", // mhchem
2537
- "\\equilibrium", // mhchem
2564
+ "\\equilibrium", // mhchem
2538
2565
  "\\equilibriumRight",
2539
2566
  "\\equilibriumLeft"
2540
2567
  ],
@@ -10978,7 +11005,7 @@ var temml = (function () {
10978
11005
  * https://mit-license.org/
10979
11006
  */
10980
11007
 
10981
- const version = "0.10.12";
11008
+ const version = "0.10.13";
10982
11009
 
10983
11010
  function postProcess(block) {
10984
11011
  const labelMap = {};