temml 0.12.1 → 0.12.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  | Library | Minified JavaScript + CSS |
4
4
  |:--------------|:-------------------------:|
5
- | Temml | 169 KB |
5
+ | Temml | 170 KB |
6
6
  | MathJax 2.7.5 | 338 KB |
7
7
  | KaTeX | 280 KB |
8
8
  | TeXZilla | 168 KB |
@@ -43,11 +43,39 @@ math.tml-display {
43
43
  width: 100%;
44
44
  }
45
45
 
46
+ /* Cramped superscripts in WebKit */
47
+ mfrac > :nth-child(2),
48
+ msqrt,
49
+ mover > :first-child {
50
+ math-shift: compact
51
+ }
52
+
53
+ .menclose {
54
+ display: inline-block;
55
+ position: relative;
56
+ padding: 0.5ex 0ex;
57
+ }
58
+ .tml-cancelto {
59
+ display: inline-block;
60
+ position: absolute;
61
+ top: 0;
62
+ left: 0;
63
+ padding: 0.5ex 0ex;
64
+ background-image: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg'><defs><marker id='a' markerHeight='5' markerUnits='strokeWidth' markerWidth='7' orient='auto' refX='7' refY='2.5'><path fill='currentColor' d='m0 0 7 2.5L0 5z'/></marker></defs><line x2='100%' y1='100%' stroke='currentColor' stroke-width='.06em' marker-end='url(%23a)' vector-effect='non-scaling-stroke'/></svg>");
65
+ }
66
+
46
67
  @supports (-moz-appearance: none) {
47
68
  /* \vec w/o italic correction for Firefox */
48
69
  .tml-vec {
49
70
  transform: scale(0.75)
50
71
  }
72
+ /* Fix \cancelto in Firefox */
73
+ .ff-narrow {
74
+ width: 0em;
75
+ }
76
+ .ff-nudge-left {
77
+ margin-left: -0.2em;
78
+ }
51
79
  }
52
80
 
53
81
  @supports (not (-moz-appearance: none)) {
@@ -57,11 +57,39 @@ math {
57
57
  font-family: "Temml";
58
58
  }
59
59
 
60
+ /* Cramped superscripts in WebKit */
61
+ mfrac > :nth-child(2),
62
+ msqrt,
63
+ mover > :first-child {
64
+ math-shift: compact
65
+ }
66
+
67
+ .menclose {
68
+ display: inline-block;
69
+ position: relative;
70
+ padding: 0.5ex 0ex;
71
+ }
72
+ .tml-cancelto {
73
+ display: inline-block;
74
+ position: absolute;
75
+ top: 0;
76
+ left: 0;
77
+ padding: 0.5ex 0ex;
78
+ background-image: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg'><defs><marker id='a' markerHeight='5' markerUnits='strokeWidth' markerWidth='7' orient='auto' refX='7' refY='2.5'><path fill='currentColor' d='m0 0 7 2.5L0 5z'/></marker></defs><line x2='100%' y1='100%' stroke='currentColor' stroke-width='.06em' marker-end='url(%23a)' vector-effect='non-scaling-stroke'/></svg>");
79
+ }
80
+
60
81
  @supports (-moz-appearance: none) {
61
82
  /* \vec w/o italic correction for Firefox */
62
83
  .tml-vec {
63
84
  transform: scale(0.75)
64
85
  }
86
+ /* Fix \cancelto in Firefox */
87
+ .ff-narrow {
88
+ width: 0em;
89
+ }
90
+ .ff-nudge-left {
91
+ margin-left: -0.2em;
92
+ }
65
93
  }
66
94
 
67
95
  @supports (not (-moz-appearance: none)) {
@@ -166,7 +194,7 @@ menclose {
166
194
  padding: 0.5ex 0ex;
167
195
  }
168
196
 
169
- .tml-overline {
197
+ .tml-overline {
170
198
  padding: 0.1em 0 0 0;
171
199
  border-top: 0.065em solid;
172
200
  }
@@ -59,11 +59,39 @@ mo.tml-prime {
59
59
  font-feature-settings: 'ssty';
60
60
  }
61
61
 
62
+ /* Cramped superscripts in WebKit */
63
+ mfrac > :nth-child(2),
64
+ msqrt,
65
+ mover > :first-child {
66
+ math-shift: compact
67
+ }
68
+
69
+ .menclose {
70
+ display: inline-block;
71
+ position: relative;
72
+ padding: 0.5ex 0ex;
73
+ }
74
+ .tml-cancelto {
75
+ display: inline-block;
76
+ position: absolute;
77
+ top: 0;
78
+ left: 0;
79
+ padding: 0.5ex 0ex;
80
+ background-image: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg'><defs><marker id='a' markerHeight='5' markerUnits='strokeWidth' markerWidth='7' orient='auto' refX='7' refY='2.5'><path fill='currentColor' d='m0 0 7 2.5L0 5z'/></marker></defs><line x2='100%' y1='100%' stroke='currentColor' stroke-width='.06em' marker-end='url(%23a)' vector-effect='non-scaling-stroke'/></svg>");
81
+ }
82
+
62
83
  @supports (-moz-appearance: none) {
63
84
  /* \vec w/o italic correction for Firefox */
64
85
  .tml-vec {
65
86
  transform: scale(0.75)
66
87
  }
88
+ /* Fix \cancelto in Firefox */
89
+ .ff-narrow {
90
+ width: 0em;
91
+ }
92
+ .ff-nudge-left {
93
+ margin-left: -0.2em;
94
+ }
67
95
  }
68
96
 
69
97
  @supports (not (-moz-appearance: none)) {
@@ -50,11 +50,39 @@ mo.tml-prime {
50
50
  font-family: Temml;
51
51
  }
52
52
 
53
+ /* Cramped superscripts in WebKit */
54
+ mfrac > :nth-child(2),
55
+ msqrt,
56
+ mover > :first-child {
57
+ math-shift: compact
58
+ }
59
+
60
+ .menclose {
61
+ display: inline-block;
62
+ position: relative;
63
+ padding: 0.5ex 0ex;
64
+ }
65
+ .tml-cancelto {
66
+ display: inline-block;
67
+ position: absolute;
68
+ top: 0;
69
+ left: 0;
70
+ padding: 0.5ex 0ex;
71
+ background-image: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg'><defs><marker id='a' markerHeight='5' markerUnits='strokeWidth' markerWidth='7' orient='auto' refX='7' refY='2.5'><path fill='currentColor' d='m0 0 7 2.5L0 5z'/></marker></defs><line x2='100%' y1='100%' stroke='currentColor' stroke-width='.06em' marker-end='url(%23a)' vector-effect='non-scaling-stroke'/></svg>");
72
+ }
73
+
53
74
  @supports (-moz-appearance: none) {
54
75
  /* \vec w/o italic correction for Firefox */
55
76
  .tml-vec {
56
77
  transform: scale(0.75)
57
78
  }
79
+ /* Fix \cancelto in Firefox */
80
+ .ff-narrow {
81
+ width: 0em;
82
+ }
83
+ .ff-nudge-left {
84
+ margin-left: -0.2em;
85
+ }
58
86
  }
59
87
 
60
88
  @supports (not (-moz-appearance: none)) {
@@ -52,11 +52,39 @@ mo.tml-prime {
52
52
  font-feature-settings: 'ssty';
53
53
  }
54
54
 
55
+ /* Cramped superscripts in WebKit */
56
+ mfrac > :nth-child(2),
57
+ msqrt,
58
+ mover > :first-child {
59
+ math-shift: compact
60
+ }
61
+
62
+ .menclose {
63
+ display: inline-block;
64
+ position: relative;
65
+ padding: 0.5ex 0ex;
66
+ }
67
+ .tml-cancelto {
68
+ display: inline-block;
69
+ position: absolute;
70
+ top: 0;
71
+ left: 0;
72
+ padding: 0.5ex 0ex;
73
+ background-image: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg'><defs><marker id='a' markerHeight='5' markerUnits='strokeWidth' markerWidth='7' orient='auto' refX='7' refY='2.5'><path fill='currentColor' d='m0 0 7 2.5L0 5z'/></marker></defs><line x2='100%' y1='100%' stroke='currentColor' stroke-width='.06em' marker-end='url(%23a)' vector-effect='non-scaling-stroke'/></svg>");
74
+ }
75
+
55
76
  @supports (-moz-appearance: none) {
56
77
  /* \vec w/o italic correction for Firefox */
57
78
  .tml-vec {
58
79
  transform: scale(0.75)
59
80
  }
81
+ /* Fix \cancelto in Firefox */
82
+ .ff-narrow {
83
+ width: 0em;
84
+ }
85
+ .ff-nudge-left {
86
+ margin-left: -0.2em;
87
+ }
60
88
  }
61
89
 
62
90
  @supports (not (-moz-appearance: none)) {
@@ -49,11 +49,39 @@ mo.tml-prime {
49
49
  font-feature-settings: 'ss04';
50
50
  }
51
51
 
52
+ /* Cramped superscripts in WebKit */
53
+ mfrac > :nth-child(2),
54
+ msqrt,
55
+ mover > :first-child {
56
+ math-shift: compact
57
+ }
58
+
59
+ .menclose {
60
+ display: inline-block;
61
+ position: relative;
62
+ padding: 0.5ex 0ex;
63
+ }
64
+ .tml-cancelto {
65
+ display: inline-block;
66
+ position: absolute;
67
+ top: 0;
68
+ left: 0;
69
+ padding: 0.5ex 0ex;
70
+ background-image: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg'><defs><marker id='a' markerHeight='5' markerUnits='strokeWidth' markerWidth='7' orient='auto' refX='7' refY='2.5'><path fill='currentColor' d='m0 0 7 2.5L0 5z'/></marker></defs><line x2='100%' y1='100%' stroke='currentColor' stroke-width='.06em' marker-end='url(%23a)' vector-effect='non-scaling-stroke'/></svg>");
71
+ }
72
+
52
73
  @supports (-moz-appearance: none) {
53
74
  /* \vec w/o italic correction for Firefox */
54
75
  .tml-vec {
55
76
  transform: scale(0.75)
56
77
  }
78
+ /* Fix \cancelto in Firefox */
79
+ .ff-narrow {
80
+ width: 0em;
81
+ }
82
+ .ff-nudge-left {
83
+ margin-left: -0.2em;
84
+ }
57
85
  }
58
86
 
59
87
  @supports (not (-moz-appearance: none)) {
package/dist/temml.cjs CHANGED
@@ -181,6 +181,9 @@ const round = function(n) {
181
181
  return +n.toFixed(4);
182
182
  };
183
183
 
184
+ // Identify short letters. Used for accents and \cancelto.
185
+ const smalls = "acegıȷmnopqrsuvwxyzαγεηικμνοπρςστυχωϕ𝐚𝐜𝐞𝐠𝐦𝐧𝐨𝐩𝐪𝐫𝐬𝐮𝐯𝐰𝐱𝐲𝐳";
186
+
184
187
  /**
185
188
  * This is a module for storing settings passed into Temml. It correctly handles
186
189
  * default settings.
@@ -796,6 +799,8 @@ const stretchyCodePoint = {
796
799
  xrightarrow: "\u2192",
797
800
  underbrace: "\u23df",
798
801
  overbrace: "\u23de",
802
+ overbracket: "\u23b4",
803
+ underbracket: "\u23b5",
799
804
  overgroup: "\u23e0",
800
805
  overparen: "⏜",
801
806
  undergroup: "\u23e1",
@@ -2451,9 +2456,6 @@ function buildMathML(tree, texExpression, style, settings) {
2451
2456
  return math;
2452
2457
  }
2453
2458
 
2454
- // Identify letters to which we'll attach a combining accent character
2455
- const smalls = "acegıȷmnopqrsuvwxyzαγεηικμνοπρςστυχωϕ𝐚𝐜𝐞𝐠𝐦𝐧𝐨𝐩𝐪𝐫𝐬𝐮𝐯𝐰𝐱𝐲𝐳";
2456
-
2457
2459
  // From the KaTeX font metrics, identify letters whose accents need a italic correction.
2458
2460
  const smallNudge = "DHKLUcegorsuvxyzΠΥΨαδηιμνοτυχϵ";
2459
2461
  const mediumNudge = "BCEGIMNOPQRSTXZlpqtwΓΘΞΣΦΩβεζθξρςφψϑϕϱ";
@@ -6434,6 +6436,7 @@ const mathmlBuilder$9 = function(group, style) {
6434
6436
  const tbl = [];
6435
6437
  const numRows = group.body.length;
6436
6438
  const hlines = group.hLinesBeforeRow;
6439
+ const tagIsPresent = (group.tags && group.tags.some((tag) => tag));
6437
6440
 
6438
6441
  for (let i = 0; i < numRows; i++) {
6439
6442
  const rw = group.body[i];
@@ -6463,7 +6466,7 @@ const mathmlBuilder$9 = function(group, style) {
6463
6466
  for (let k = 0; k < numColumns - rw.length; k++) {
6464
6467
  row.push(new MathNode("mtd", [], [], style));
6465
6468
  }
6466
- if (group.autoTag) {
6469
+ if (tagIsPresent) {
6467
6470
  const tag = group.tags[i];
6468
6471
  let tagElement;
6469
6472
  if (tag === true) { // automatic numbering
@@ -6575,7 +6578,7 @@ const mathmlBuilder$9 = function(group, style) {
6575
6578
  if (j === numCols - 1 && hand === 1) { return "0" }
6576
6579
  if (group.envClasses[0] !== "align") { return sidePadding }
6577
6580
  if (hand === 1) { return "0" }
6578
- if (group.autoTag) {
6581
+ if (tagIsPresent) {
6579
6582
  return (j % 2) ? "1" : "0"
6580
6583
  } else {
6581
6584
  return (j % 2) ? "0" : "1"
@@ -6611,7 +6614,7 @@ const mathmlBuilder$9 = function(group, style) {
6611
6614
  // TODO: Remove -webkit- when Chromium no longer needs it.
6612
6615
  row.children[j].classes = ["tml-" + (j % 2 ? "left" : "right")];
6613
6616
  }
6614
- if (group.autoTag) {
6617
+ if (tagIsPresent) {
6615
6618
  const k = group.leqno ? 0 : row.children.length - 1;
6616
6619
  row.children[k].classes = []; // Default is center.
6617
6620
  }
@@ -6668,7 +6671,7 @@ const mathmlBuilder$9 = function(group, style) {
6668
6671
  row.children[0].style.borderLeft = sep;
6669
6672
  }
6670
6673
  }
6671
- let iCol = group.autoTag ? 0 : -1;
6674
+ let iCol = tagIsPresent ? 0 : -1;
6672
6675
  for (let i = iStart; i < iEnd; i++) {
6673
6676
  if (cols[i].type === "align") {
6674
6677
  const colAlign = alignMap[cols[i].align];
@@ -7194,6 +7197,78 @@ defineFunction({
7194
7197
  }
7195
7198
  });
7196
7199
 
7200
+ defineFunction({
7201
+ type: "cancelto",
7202
+ names: ["\\cancelto"],
7203
+ props: {
7204
+ numArgs: 2
7205
+ },
7206
+ handler({ parser }, args) {
7207
+ const to = args[0];
7208
+ const body = args[1];
7209
+ return {
7210
+ type: "cancelto",
7211
+ mode: parser.mode,
7212
+ body,
7213
+ to,
7214
+ isCharacterBox: isCharacterBox(body)
7215
+ };
7216
+ },
7217
+ mathmlBuilder(group, style) {
7218
+ const fromNode = new MathNode(
7219
+ "mrow",
7220
+ [buildGroup$1(group.body, style)],
7221
+ ["ff-narrow"] // A zero-width mrow.
7222
+ );
7223
+ // Write the arrow in a node written after the content.
7224
+ // That way, the arrow will be an overlay on the content.
7225
+ const phantom = new MathNode("mphantom", [buildGroup$1(group.body, style)]);
7226
+ const arrow = new MathNode("mrow", [phantom], ["tml-cancelto"]);
7227
+ if (group.isCharacterBox && smalls.indexOf(group.body.body[0].text) > -1) {
7228
+ arrow.style.left = "0.1em";
7229
+ arrow.style.width = "90%";
7230
+ }
7231
+ const node = new MathNode("mrow", [fromNode, arrow], ["menclose"]);
7232
+ if (!group.isCharacterBox || /[f∫∑]/.test(group.body.body[0].text)) {
7233
+ // Add 0.2em space to right of content to make room for the arrowhead.
7234
+ phantom.style.paddingRight = "0.2em";
7235
+ } else {
7236
+ phantom.style.padding = "0.5ex 0.1em 0 0";
7237
+ const strut = new MathNode('mspace', []);
7238
+ strut.setAttribute('height', "0.85em");
7239
+ fromNode.children.push(strut);
7240
+ }
7241
+
7242
+ // Create the "to" value above and to the right of the arrow.
7243
+ // First, we want a dummy node with the same height as the `from` content.
7244
+ // We'll place the `to` node above the dummy to get the correct vertical alignment.
7245
+ let dummyNode;
7246
+ if (group.isCharacterBox) {
7247
+ dummyNode = new MathNode('mspace', []);
7248
+ dummyNode.setAttribute('height', "1em");
7249
+ } else {
7250
+ // Create a phantom node with the same content as the body.
7251
+ const inner = buildGroup$1(group.body, style);
7252
+ // The phantom node will be zero-width, so it won't affect horizontal spacing.
7253
+ const zeroWidthNode = new MathNode("mpadded", [inner]);
7254
+ zeroWidthNode.setAttribute("width", "0.1px"); // Don't use 0. WebKit would omit it.
7255
+ dummyNode = new MathNode("mphantom", [zeroWidthNode]); // Hide it.
7256
+ }
7257
+ const toNode = buildGroup$1(group.to, style);
7258
+ const zeroWidthToNode = new MathNode("mpadded", [toNode]);
7259
+ if (!group.isCharacterBox || /[f∫∑]/.test(group.body.body[0].text)) {
7260
+ const w = new MathNode("mspace", []);
7261
+ w.setAttribute('width', "0.2em");
7262
+ zeroWidthToNode.children.unshift(w);
7263
+ }
7264
+ zeroWidthToNode.setAttribute("width", "0.1px"); // Don't use 0. WebKit would hide it.
7265
+ const mover = new MathNode("mover", [dummyNode, zeroWidthToNode]);
7266
+ // Fix Firefox positioning.
7267
+ const nudgeLeft = new MathNode('mrow', [], ["ff-nudge-left"]);
7268
+ return newDocumentFragment([makeRow([node, mover]), nudgeLeft])
7269
+ }
7270
+ });
7271
+
7197
7272
  // \@char is an internal function that takes a grouped decimal argument like
7198
7273
  // {123} and converts into symbol with code 123. It is used by the *macro*
7199
7274
  // \char defined in macros.js.
@@ -8120,8 +8195,10 @@ defineFunction({
8120
8195
  }
8121
8196
  });
8122
8197
 
8198
+ const boxTags = ["\\boxed", "\\fcolorbox", "\\colorbox"];
8199
+
8123
8200
  const mathmlBuilder$7 = (group, style) => {
8124
- const tag = group.label === "\\boxed" ? "mrow" : "menclose";
8201
+ const tag = boxTags.includes(group.label) ? "mrow" : "menclose";
8125
8202
  const node = new MathNode(tag, [buildGroup$1(group.body, style)]);
8126
8203
  switch (group.label) {
8127
8204
  case "\\overline":
@@ -8148,6 +8225,7 @@ const mathmlBuilder$7 = (group, style) => {
8148
8225
  node.setAttribute("notation", "updiagonalstrike downdiagonalstrike");
8149
8226
  node.classes.push("tml-xcancel");
8150
8227
  break
8228
+ // cancelto is handled in cancelto.js
8151
8229
  case "\\longdiv":
8152
8230
  node.setAttribute("notation", "longdiv");
8153
8231
  node.classes.push("longdiv-top");
@@ -8180,13 +8258,8 @@ const mathmlBuilder$7 = (group, style) => {
8180
8258
  break
8181
8259
  case "\\fcolorbox":
8182
8260
  case "\\colorbox": {
8183
- // <menclose> doesn't have a good notation option for \colorbox.
8184
- // So use <mpadded> instead. Set some attributes that come
8185
- // included with <menclose>.
8186
- //const fboxsep = 3; // 3 pt from LaTeX source2e
8187
- //node.setAttribute("height", `+${2 * fboxsep}pt`)
8188
- //node.setAttribute("voffset", `${fboxsep}pt`)
8189
- node.style.padding = "3pt";
8261
+ // Don't use <menclose>. WebKit would show a radical.
8262
+ node.style.padding = "0.3em"; // 3 pt from LaTeX source2e for a 10pt font
8190
8263
  if (group.label === "\\fcolorbox") {
8191
8264
  node.style.border = "0.0667em solid " + String(group.borderColor);
8192
8265
  }
@@ -8955,16 +9028,16 @@ const mathmlBuilder$4 = (group, style) => {
8955
9028
  ]);
8956
9029
  };
8957
9030
 
8958
- // Horizontal stretchy braces
9031
+ // Horizontal stretchy brackets
8959
9032
  defineFunction({
8960
- type: "horizBrace",
8961
- names: ["\\overbrace", "\\underbrace"],
9033
+ type: "horizBracket",
9034
+ names: ["\\overbrace", "\\underbrace", "\\overbracket", "\\underbracket"],
8962
9035
  props: {
8963
9036
  numArgs: 1
8964
9037
  },
8965
9038
  handler({ parser, funcName }, args) {
8966
9039
  return {
8967
- type: "horizBrace",
9040
+ type: "horizBracket",
8968
9041
  mode: parser.mode,
8969
9042
  label: funcName,
8970
9043
  isOver: /^\\over/.test(funcName),
@@ -10120,7 +10193,8 @@ defineFunction({
10120
10193
  "\u2a1a"
10121
10194
  ],
10122
10195
  props: {
10123
- numArgs: 0
10196
+ numArgs: 0,
10197
+ allowedInArgument: true
10124
10198
  },
10125
10199
  handler({ parser, funcName }) {
10126
10200
  let fName = funcName;
@@ -10860,18 +10934,18 @@ const largePad = "AJdfΔΛ";
10860
10934
  defineFunctionBuilders({
10861
10935
  type: "supsub",
10862
10936
  mathmlBuilder(group, style) {
10863
- // Is the inner group a relevant horizontal brace?
10864
- let isBrace = false;
10937
+ // Is the inner group a relevant horizontal brace or bracket?
10938
+ let isBracket = false;
10865
10939
  let isOver;
10866
10940
  let isSup;
10867
10941
  let appendApplyFunction = false;
10868
10942
  let appendSpace = false;
10869
10943
  let needsLeadingSpace = false;
10870
10944
 
10871
- if (group.base && group.base.type === "horizBrace") {
10945
+ if (group.base && group.base.type === "horizBracket") {
10872
10946
  isSup = !!group.sup;
10873
10947
  if (isSup === group.base.isOver) {
10874
- isBrace = true;
10948
+ isBracket = true;
10875
10949
  isOver = group.base.isOver;
10876
10950
  }
10877
10951
  }
@@ -10919,7 +10993,7 @@ defineFunctionBuilders({
10919
10993
  }
10920
10994
 
10921
10995
  let nodeType;
10922
- if (isBrace) {
10996
+ if (isBracket) {
10923
10997
  nodeType = isOver ? "mover" : "munder";
10924
10998
  } else if (!group.sub) {
10925
10999
  const base = group.base;
@@ -13989,7 +14063,7 @@ class Style {
13989
14063
  * https://mit-license.org/
13990
14064
  */
13991
14065
 
13992
- const version = "0.12.01";
14066
+ const version = "0.12.02";
13993
14067
 
13994
14068
  function postProcess(block) {
13995
14069
  const labelMap = {};