temml 0.10.14 → 0.10.15

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/dist/temml.mjs CHANGED
@@ -971,6 +971,10 @@ defineSymbol(math, mathord, "\u21af", "\\lightning", true);
971
971
  defineSymbol(math, mathord, "\u220E", "\\QED", true);
972
972
  defineSymbol(math, mathord, "\u2030", "\\permil", true);
973
973
  defineSymbol(text, textord, "\u2030", "\\permil");
974
+ defineSymbol(math, mathord, "\u2609", "\\astrosun", true);
975
+ defineSymbol(math, mathord, "\u263c", "\\sun", true);
976
+ defineSymbol(math, mathord, "\u263e", "\\leftmoon", true);
977
+ defineSymbol(math, mathord, "\u263d", "\\rightmoon", true);
974
978
 
975
979
  // AMS Negated Binary Relations
976
980
  defineSymbol(math, rel, "\u226e", "\\nless", true);
@@ -2129,9 +2133,7 @@ function buildMathML(tree, texExpression, style, settings) {
2129
2133
  }
2130
2134
  if (settings.displayMode) {
2131
2135
  math.setAttribute("display", "block");
2132
- math.style.display = math.children.length === 1 && math.children[0].type === "mtable"
2133
- ? "inline"
2134
- : "block math"; // necessary in Chromium.
2136
+ math.style.display = "block math"; // necessary in Chromium.
2135
2137
  // Firefox and Safari do not recognize display: "block math".
2136
2138
  // Set a class so that the CSS file can set display: block.
2137
2139
  math.classes = ["tml-display"];
@@ -3822,10 +3824,20 @@ const mathmlBuilder$8 = (group, style) => {
3822
3824
  node.style.borderBottom = "0.065em solid";
3823
3825
  break
3824
3826
  case "\\cancel":
3825
- node.classes.push("cancel");
3827
+ node.style.background = `linear-gradient(to top left,
3828
+ rgba(0,0,0,0) 0%,
3829
+ rgba(0,0,0,0) calc(50% - 0.06em),
3830
+ rgba(0,0,0,1) 50%,
3831
+ rgba(0,0,0,0) calc(50% + 0.06em),
3832
+ rgba(0,0,0,0) 100%);`;
3826
3833
  break
3827
3834
  case "\\bcancel":
3828
- node.classes.push("bcancel");
3835
+ node.style.background = `linear-gradient(to top right,
3836
+ rgba(0,0,0,0) 0%,
3837
+ rgba(0,0,0,0) calc(50% - 0.06em),
3838
+ rgba(0,0,0,1) 50%,
3839
+ rgba(0,0,0,0) calc(50% + 0.06em),
3840
+ rgba(0,0,0,0) 100%);`;
3829
3841
  break
3830
3842
  /*
3831
3843
  case "\\longdiv":
@@ -3869,7 +3881,18 @@ const mathmlBuilder$8 = (group, style) => {
3869
3881
  break
3870
3882
  }
3871
3883
  case "\\xcancel":
3872
- node.classes.push("xcancel");
3884
+ node.style.background = `linear-gradient(to top left,
3885
+ rgba(0,0,0,0) 0%,
3886
+ rgba(0,0,0,0) calc(50% - 0.06em),
3887
+ rgba(0,0,0,1) 50%,
3888
+ rgba(0,0,0,0) calc(50% + 0.06em),
3889
+ rgba(0,0,0,0) 100%),
3890
+ linear-gradient(to top right,
3891
+ rgba(0,0,0,0) 0%,
3892
+ rgba(0,0,0,0) calc(50% - 0.06em),
3893
+ rgba(0,0,0,1) 50%,
3894
+ rgba(0,0,0,0) calc(50% + 0.06em),
3895
+ rgba(0,0,0,0) 100%);`;
3873
3896
  break
3874
3897
  }
3875
3898
  if (group.backgroundColor) {
@@ -4300,24 +4323,94 @@ const mathmlBuilder$7 = function(group, style) {
4300
4323
  // Write horizontal rules
4301
4324
  if (i === 0 && hlines[0].length > 0) {
4302
4325
  if (hlines[0].length === 2) {
4303
- mtr.classes.push("tml-top-double");
4326
+ mtr.children.forEach(cell => { cell.style.borderTop = "0.15em double"; });
4304
4327
  } else {
4305
- mtr.classes.push(hlines[0][0] ? "tml-top-dashed" : "tml-top-solid");
4328
+ mtr.children.forEach(cell => {
4329
+ cell.style.borderTop = hlines[0][0] ? "0.06em dashed" : "0.06em solid";
4330
+ });
4306
4331
  }
4307
4332
  }
4308
4333
  if (hlines[i + 1].length > 0) {
4309
4334
  if (hlines[i + 1].length === 2) {
4310
- mtr.classes.push("tml-hline-double");
4335
+ mtr.children.forEach(cell => { cell.style.borderBottom = "0.15em double"; });
4311
4336
  } else {
4312
- mtr.classes.push(hlines[i + 1][0] ? "tml-hline-dashed" : "tml-hline-solid");
4337
+ mtr.children.forEach(cell => {
4338
+ cell.style.borderBottom = hlines[i + 1][0] ? "0.06em dashed" : "0.06em solid";
4339
+ });
4313
4340
  }
4314
4341
  }
4315
4342
  tbl.push(mtr);
4316
4343
  }
4317
- let table = new mathMLTree.MathNode("mtable", tbl);
4344
+
4318
4345
  if (group.envClasses.length > 0) {
4319
- table.classes = group.envClasses.map(e => "tml-" + e);
4346
+ const pad = group.envClasses.includes("jot")
4347
+ ? "0.7" // 0.5ex + 0.09em top & bot padding
4348
+ : group.envClasses.includes("small")
4349
+ ? "0.35"
4350
+ : "0.5"; // 0.5ex default top & bot padding
4351
+ const sidePadding = group.envClasses.includes("abut")
4352
+ ? "0"
4353
+ : group.envClasses.includes("cases")
4354
+ ? "0"
4355
+ : group.envClasses.includes("small")
4356
+ ? "0.1389"
4357
+ : group.envClasses.includes("cd")
4358
+ ? "0.25"
4359
+ : "0.4"; // default side padding
4360
+
4361
+ const numCols = tbl.length === 0 ? 0 : tbl[0].children.length;
4362
+
4363
+ const sidePad = (j, hand) => {
4364
+ if (j === 0 && hand === 0) { return "0" }
4365
+ if (j === numCols - 1 && hand === 1) { return "0" }
4366
+ if (group.envClasses[0] !== "align") { return sidePadding }
4367
+ if (hand === 1) { return "0" }
4368
+ if (group.addEqnNum) {
4369
+ return (j % 2) ? "1" : "0"
4370
+ } else {
4371
+ return (j % 2) ? "0" : "1"
4372
+ }
4373
+ };
4374
+
4375
+ // Padding
4376
+ for (let i = 0; i < tbl.length; i++) {
4377
+ for (let j = 0; j < tbl[i].children.length; j++) {
4378
+ tbl[i].children[j].style.padding = `${pad}ex ${sidePad(j, 1)}em ${pad}ex ${sidePad(j, 0)}em`;
4379
+ }
4380
+ }
4381
+
4382
+ // Justification
4383
+ const align = group.envClasses.includes("align") || group.envClasses.includes("alignat");
4384
+ for (let i = 0; i < tbl.length; i++) {
4385
+ const row = tbl[i];
4386
+ if (align) {
4387
+ for (let j = 0; j < row.children.length; j++) {
4388
+ // Chromium does not recognize text-align: left. Use -webkit-
4389
+ // TODO: Remove -webkit- when Chromium no longer needs it.
4390
+ row.children[j].style.textAlign = "-webkit-" + (j % 2 ? "left" : "right");
4391
+ }
4392
+ }
4393
+ if (row.children.length > 1 && group.envClasses.includes("cases")) {
4394
+ row.children[1].style.padding = row.children[1].style.padding.replace(/0em$/, "1em");
4395
+ }
4396
+
4397
+ if (group.envClasses.includes("cases") || group.envClasses.includes("subarray")) {
4398
+ for (const cell of row.children) {
4399
+ cell.style.textAlign = "-webkit-" + "left";
4400
+ }
4401
+ }
4402
+ }
4403
+ } else {
4404
+ // Set zero padding on side of the matrix
4405
+ for (let i = 0; i < tbl.length; i++) {
4406
+ tbl[i].children[0].style.paddingLeft = "0em";
4407
+ if (tbl[i].children.length === tbl[0].children.length) {
4408
+ tbl[i].children[tbl[i].children.length - 1].style.paddingRight = "0em";
4409
+ }
4410
+ }
4320
4411
  }
4412
+
4413
+ let table = new mathMLTree.MathNode("mtable", tbl);
4321
4414
  if (group.scriptLevel === "display") { table.setAttribute("displaystyle", "true"); }
4322
4415
 
4323
4416
  if (group.addEqnNum || group.envClasses.includes("multline")) {
@@ -4397,6 +4490,8 @@ const mathmlBuilder$7 = function(group, style) {
4397
4490
  align = "left " + (align.length > 0 ? align : "center ") + "right ";
4398
4491
  }
4399
4492
  if (align) {
4493
+ // Firefox reads this attribute, not the -webkit-left|right written above.
4494
+ // TODO: When Chrome no longer needs "-webkit-", use CSS and delete the next line.
4400
4495
  table.setAttribute("columnalign", align.trim());
4401
4496
  }
4402
4497
 
@@ -4421,7 +4516,7 @@ const alignedHandler = function(context, args) {
4421
4516
  cols,
4422
4517
  addEqnNum: context.envName === "align" || context.envName === "alignat",
4423
4518
  emptySingleRow: true,
4424
- envClasses: ["jot", "abut"], // set row spacing & provisional column spacing
4519
+ envClasses: ["abut", "jot"], // set row spacing & provisional column spacing
4425
4520
  maxNumCols: context.envName === "split" ? 2 : undefined,
4426
4521
  leqno: context.parser.settings.leqno
4427
4522
  },
@@ -4439,18 +4534,22 @@ const alignedHandler = function(context, args) {
4439
4534
  // binary. This behavior is implemented in amsmath's \start@aligned.
4440
4535
  let numMaths;
4441
4536
  let numCols = 0;
4442
- if (args[0] && args[0].type === "ordgroup") {
4537
+ const isAlignedAt = context.envName.indexOf("at") > -1;
4538
+ if (args[0] && isAlignedAt) {
4539
+ // alignat environment takes an argument w/ number of columns
4443
4540
  let arg0 = "";
4444
4541
  for (let i = 0; i < args[0].body.length; i++) {
4445
4542
  const textord = assertNodeType(args[0].body[i], "textord");
4446
4543
  arg0 += textord.text;
4447
4544
  }
4545
+ if (isNaN(arg0)) {
4546
+ throw new ParseError("The alignat enviroment requires a numeric first argument.")
4547
+ }
4448
4548
  numMaths = Number(arg0);
4449
4549
  numCols = numMaths * 2;
4450
4550
  }
4451
- const isAligned = !numCols;
4452
4551
  res.body.forEach(function(row) {
4453
- if (!isAligned) {
4552
+ if (isAlignedAt) {
4454
4553
  // Case 1
4455
4554
  const curMaths = row.length / 2;
4456
4555
  if (numMaths < curMaths) {
@@ -4478,14 +4577,10 @@ const alignedHandler = function(context, args) {
4478
4577
  align: align
4479
4578
  };
4480
4579
  }
4481
- if (context.envName === "split") ; else if (context.envName.indexOf("ed") > -1) {
4482
- res.envClasses.push("aligned"); // Sets justification
4483
- } else if (isAligned) {
4484
- res.envClasses[1] = context.envName === "align*"
4485
- ? "align-star"
4486
- : "align"; // Sets column spacing & justification
4580
+ if (context.envName === "split") ; else if (isAlignedAt) {
4581
+ res.envClasses.push("alignat"); // Sets justification
4487
4582
  } else {
4488
- res.envClasses.push("aligned"); // Sets justification
4583
+ res.envClasses[0] = "align"; // Sets column spacing & justification
4489
4584
  }
4490
4585
  return res;
4491
4586
  };
@@ -4735,7 +4830,7 @@ defineEnvironment({
4735
4830
  }
4736
4831
  const res = {
4737
4832
  cols: [],
4738
- envClasses: ["jot", "abut"],
4833
+ envClasses: ["abut", "jot"],
4739
4834
  addEqnNum: context.envName === "gather",
4740
4835
  emptySingleRow: true,
4741
4836
  leqno: context.parser.settings.leqno
@@ -12899,7 +12994,7 @@ class Style {
12899
12994
  * https://mit-license.org/
12900
12995
  */
12901
12996
 
12902
- const version = "0.10.14";
12997
+ const version = "0.10.15";
12903
12998
 
12904
12999
  function postProcess(block) {
12905
13000
  const labelMap = {};
@@ -12950,6 +13045,7 @@ function postProcess(block) {
12950
13045
  /* eslint no-console:0 */
12951
13046
 
12952
13047
  /**
13048
+ * @type {import('./temml').render}
12953
13049
  * Parse and build an expression, and place that expression in the DOM node
12954
13050
  * given.
12955
13051
  */
@@ -12987,6 +13083,7 @@ if (typeof document !== "undefined") {
12987
13083
  }
12988
13084
 
12989
13085
  /**
13086
+ * @type {import('./temml').renderToString}
12990
13087
  * Parse and build an expression, and return the markup for that.
12991
13088
  */
12992
13089
  const renderToString = function(expression, options) {
@@ -12995,6 +13092,7 @@ const renderToString = function(expression, options) {
12995
13092
  };
12996
13093
 
12997
13094
  /**
13095
+ * @type {import('./temml').generateParseTree}
12998
13096
  * Parse an expression and return the parse tree.
12999
13097
  */
13000
13098
  const generateParseTree = function(expression, options) {
@@ -13003,6 +13101,7 @@ const generateParseTree = function(expression, options) {
13003
13101
  };
13004
13102
 
13005
13103
  /**
13104
+ * @type {import('./temml').definePreamble}
13006
13105
  * Take an expression which contains a preamble.
13007
13106
  * Parse it and return the macros.
13008
13107
  */
@@ -13035,6 +13134,7 @@ const renderError = function(error, expression, options) {
13035
13134
  };
13036
13135
 
13037
13136
  /**
13137
+ * @type {import('./temml').renderToMathMLTree}
13038
13138
  * Generates and returns the Temml build tree. This is used for advanced
13039
13139
  * use cases (like rendering to custom output).
13040
13140
  */
@@ -13052,6 +13152,7 @@ const renderToMathMLTree = function(expression, options) {
13052
13152
  }
13053
13153
  };
13054
13154
 
13155
+ /** @type {import('./temml').default} */
13055
13156
  var temml = {
13056
13157
  /**
13057
13158
  * Current Temml version
@@ -14,7 +14,7 @@
14
14
  * https://mit-license.org/
15
15
  */
16
16
 
17
- const version = "0.10.14";
17
+ const version = "0.10.15";
18
18
 
19
19
  function postProcess(block) {
20
20
  const labelMap = {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "temml",
3
- "version": "0.10.14",
3
+ "version": "0.10.15",
4
4
  "description": "TeX to MathML conversion in JavaScript.",
5
5
  "main": "dist/temml.js",
6
6
  "engines": {
@@ -8,7 +8,9 @@
8
8
  },
9
9
  "exports": {
10
10
  ".": {
11
- "require": "./dist/temml.cjs"
11
+ "require": "./dist/temml.cjs",
12
+ "import": "./dist/temml.mjs",
13
+ "types": "./dist/temml.d.ts"
12
14
  },
13
15
  "./*": "./*"
14
16
  },
@@ -260,9 +260,7 @@ export default function buildMathML(tree, texExpression, style, settings) {
260
260
  }
261
261
  if (settings.displayMode) {
262
262
  math.setAttribute("display", "block");
263
- math.style.display = math.children.length === 1 && math.children[0].type === "mtable"
264
- ? "inline"
265
- : "block math" // necessary in Chromium.
263
+ math.style.display = "block math" // necessary in Chromium.
266
264
  // Firefox and Safari do not recognize display: "block math".
267
265
  // Set a class so that the CSS file can set display: block.
268
266
  math.classes = ["tml-display"]
@@ -276,24 +276,94 @@ const mathmlBuilder = function(group, style) {
276
276
  // Write horizontal rules
277
277
  if (i === 0 && hlines[0].length > 0) {
278
278
  if (hlines[0].length === 2) {
279
- mtr.classes.push("tml-top-double")
279
+ mtr.children.forEach(cell => { cell.style.borderTop = "0.15em double" })
280
280
  } else {
281
- mtr.classes.push(hlines[0][0] ? "tml-top-dashed" : "tml-top-solid")
281
+ mtr.children.forEach(cell => {
282
+ cell.style.borderTop = hlines[0][0] ? "0.06em dashed" : "0.06em solid"
283
+ })
282
284
  }
283
285
  }
284
286
  if (hlines[i + 1].length > 0) {
285
287
  if (hlines[i + 1].length === 2) {
286
- mtr.classes.push("tml-hline-double")
288
+ mtr.children.forEach(cell => { cell.style.borderBottom = "0.15em double" })
287
289
  } else {
288
- mtr.classes.push(hlines[i + 1][0] ? "tml-hline-dashed" : "tml-hline-solid")
290
+ mtr.children.forEach(cell => {
291
+ cell.style.borderBottom = hlines[i + 1][0] ? "0.06em dashed" : "0.06em solid"
292
+ })
289
293
  }
290
294
  }
291
295
  tbl.push(mtr);
292
296
  }
293
- let table = new mathMLTree.MathNode("mtable", tbl)
297
+
294
298
  if (group.envClasses.length > 0) {
295
- table.classes = group.envClasses.map(e => "tml-" + e)
299
+ const pad = group.envClasses.includes("jot")
300
+ ? "0.7" // 0.5ex + 0.09em top & bot padding
301
+ : group.envClasses.includes("small")
302
+ ? "0.35"
303
+ : "0.5" // 0.5ex default top & bot padding
304
+ const sidePadding = group.envClasses.includes("abut")
305
+ ? "0"
306
+ : group.envClasses.includes("cases")
307
+ ? "0"
308
+ : group.envClasses.includes("small")
309
+ ? "0.1389"
310
+ : group.envClasses.includes("cd")
311
+ ? "0.25"
312
+ : "0.4" // default side padding
313
+
314
+ const numCols = tbl.length === 0 ? 0 : tbl[0].children.length
315
+
316
+ const sidePad = (j, hand) => {
317
+ if (j === 0 && hand === 0) { return "0" }
318
+ if (j === numCols - 1 && hand === 1) { return "0" }
319
+ if (group.envClasses[0] !== "align") { return sidePadding }
320
+ if (hand === 1) { return "0" }
321
+ if (group.addEqnNum) {
322
+ return (j % 2) ? "1" : "0"
323
+ } else {
324
+ return (j % 2) ? "0" : "1"
325
+ }
326
+ }
327
+
328
+ // Padding
329
+ for (let i = 0; i < tbl.length; i++) {
330
+ for (let j = 0; j < tbl[i].children.length; j++) {
331
+ tbl[i].children[j].style.padding = `${pad}ex ${sidePad(j, 1)}em ${pad}ex ${sidePad(j, 0)}em`
332
+ }
333
+ }
334
+
335
+ // Justification
336
+ const align = group.envClasses.includes("align") || group.envClasses.includes("alignat")
337
+ for (let i = 0; i < tbl.length; i++) {
338
+ const row = tbl[i];
339
+ if (align) {
340
+ for (let j = 0; j < row.children.length; j++) {
341
+ // Chromium does not recognize text-align: left. Use -webkit-
342
+ // TODO: Remove -webkit- when Chromium no longer needs it.
343
+ row.children[j].style.textAlign = "-webkit-" + (j % 2 ? "left" : "right")
344
+ }
345
+ }
346
+ if (row.children.length > 1 && group.envClasses.includes("cases")) {
347
+ row.children[1].style.padding = row.children[1].style.padding.replace(/0em$/, "1em")
348
+ }
349
+
350
+ if (group.envClasses.includes("cases") || group.envClasses.includes("subarray")) {
351
+ for (const cell of row.children) {
352
+ cell.style.textAlign = "-webkit-" + "left"
353
+ }
354
+ }
355
+ }
356
+ } else {
357
+ // Set zero padding on side of the matrix
358
+ for (let i = 0; i < tbl.length; i++) {
359
+ tbl[i].children[0].style.paddingLeft = "0em"
360
+ if (tbl[i].children.length === tbl[0].children.length) {
361
+ tbl[i].children[tbl[i].children.length - 1].style.paddingRight = "0em"
362
+ }
363
+ }
296
364
  }
365
+
366
+ let table = new mathMLTree.MathNode("mtable", tbl)
297
367
  if (group.scriptLevel === "display") { table.setAttribute("displaystyle", "true") }
298
368
 
299
369
  if (group.addEqnNum || group.envClasses.includes("multline")) {
@@ -373,6 +443,8 @@ const mathmlBuilder = function(group, style) {
373
443
  align = "left " + (align.length > 0 ? align : "center ") + "right "
374
444
  }
375
445
  if (align) {
446
+ // Firefox reads this attribute, not the -webkit-left|right written above.
447
+ // TODO: When Chrome no longer needs "-webkit-", use CSS and delete the next line.
376
448
  table.setAttribute("columnalign", align.trim())
377
449
  }
378
450
 
@@ -397,7 +469,7 @@ const alignedHandler = function(context, args) {
397
469
  cols,
398
470
  addEqnNum: context.envName === "align" || context.envName === "alignat",
399
471
  emptySingleRow: true,
400
- envClasses: ["jot", "abut"], // set row spacing & provisional column spacing
472
+ envClasses: ["abut", "jot"], // set row spacing & provisional column spacing
401
473
  maxNumCols: context.envName === "split" ? 2 : undefined,
402
474
  leqno: context.parser.settings.leqno
403
475
  },
@@ -415,18 +487,22 @@ const alignedHandler = function(context, args) {
415
487
  // binary. This behavior is implemented in amsmath's \start@aligned.
416
488
  let numMaths;
417
489
  let numCols = 0;
418
- if (args[0] && args[0].type === "ordgroup") {
419
- let arg0 = "";
490
+ const isAlignedAt = context.envName.indexOf("at") > -1
491
+ if (args[0] && isAlignedAt) {
492
+ // alignat environment takes an argument w/ number of columns
493
+ let arg0 = ""
420
494
  for (let i = 0; i < args[0].body.length; i++) {
421
- const textord = assertNodeType(args[0].body[i], "textord");
422
- arg0 += textord.text;
495
+ const textord = assertNodeType(args[0].body[i], "textord")
496
+ arg0 += textord.text
497
+ }
498
+ if (isNaN(arg0)) {
499
+ throw new ParseError("The alignat enviroment requires a numeric first argument.")
423
500
  }
424
- numMaths = Number(arg0);
425
- numCols = numMaths * 2;
501
+ numMaths = Number(arg0)
502
+ numCols = numMaths * 2
426
503
  }
427
- const isAligned = !numCols;
428
504
  res.body.forEach(function(row) {
429
- if (!isAligned) {
505
+ if (isAlignedAt) {
430
506
  // Case 1
431
507
  const curMaths = row.length / 2;
432
508
  if (numMaths < curMaths) {
@@ -456,14 +532,10 @@ const alignedHandler = function(context, args) {
456
532
  }
457
533
  if (context.envName === "split") {
458
534
  // Append no more classes
459
- } else if (context.envName.indexOf("ed") > -1) {
460
- res.envClasses.push("aligned") // Sets justification
461
- } else if (isAligned) {
462
- res.envClasses[1] = context.envName === "align*"
463
- ? "align-star"
464
- : "align" // Sets column spacing & justification
535
+ } else if (isAlignedAt) {
536
+ res.envClasses.push("alignat") // Sets justification
465
537
  } else {
466
- res.envClasses.push("aligned") // Sets justification
538
+ res.envClasses[0] = "align" // Sets column spacing & justification
467
539
  }
468
540
  return res;
469
541
  };
@@ -713,7 +785,7 @@ defineEnvironment({
713
785
  }
714
786
  const res = {
715
787
  cols: [],
716
- envClasses: ["jot", "abut"],
788
+ envClasses: ["abut", "jot"],
717
789
  addEqnNum: context.envName === "gather",
718
790
  emptySingleRow: true,
719
791
  leqno: context.parser.settings.leqno
@@ -34,10 +34,20 @@ const mathmlBuilder = (group, style) => {
34
34
  node.style.borderBottom = "0.065em solid"
35
35
  break
36
36
  case "\\cancel":
37
- node.classes.push("cancel")
37
+ node.style.background = `linear-gradient(to top left,
38
+ rgba(0,0,0,0) 0%,
39
+ rgba(0,0,0,0) calc(50% - 0.06em),
40
+ rgba(0,0,0,1) 50%,
41
+ rgba(0,0,0,0) calc(50% + 0.06em),
42
+ rgba(0,0,0,0) 100%);`
38
43
  break
39
44
  case "\\bcancel":
40
- node.classes.push("bcancel")
45
+ node.style.background = `linear-gradient(to top right,
46
+ rgba(0,0,0,0) 0%,
47
+ rgba(0,0,0,0) calc(50% - 0.06em),
48
+ rgba(0,0,0,1) 50%,
49
+ rgba(0,0,0,0) calc(50% + 0.06em),
50
+ rgba(0,0,0,0) 100%);`
41
51
  break
42
52
  /*
43
53
  case "\\longdiv":
@@ -81,7 +91,18 @@ const mathmlBuilder = (group, style) => {
81
91
  break
82
92
  }
83
93
  case "\\xcancel":
84
- node.classes.push("xcancel")
94
+ node.style.background = `linear-gradient(to top left,
95
+ rgba(0,0,0,0) 0%,
96
+ rgba(0,0,0,0) calc(50% - 0.06em),
97
+ rgba(0,0,0,1) 50%,
98
+ rgba(0,0,0,0) calc(50% + 0.06em),
99
+ rgba(0,0,0,0) 100%),
100
+ linear-gradient(to top right,
101
+ rgba(0,0,0,0) 0%,
102
+ rgba(0,0,0,0) calc(50% - 0.06em),
103
+ rgba(0,0,0,1) 50%,
104
+ rgba(0,0,0,0) calc(50% + 0.06em),
105
+ rgba(0,0,0,0) 100%);`
85
106
  break
86
107
  }
87
108
  if (group.backgroundColor) {
@@ -8,7 +8,7 @@
8
8
  * https://mit-license.org/
9
9
  */
10
10
 
11
- export const version = "0.10.14";
11
+ export const version = "0.10.15";
12
12
 
13
13
  export function postProcess(block) {
14
14
  const labelMap = {}
package/src/symbols.js CHANGED
@@ -212,6 +212,10 @@ defineSymbol(math, mathord, "\u21af", "\\lightning", true);
212
212
  defineSymbol(math, mathord, "\u220E", "\\QED", true);
213
213
  defineSymbol(math, mathord, "\u2030", "\\permil", true);
214
214
  defineSymbol(text, textord, "\u2030", "\\permil");
215
+ defineSymbol(math, mathord, "\u2609", "\\astrosun", true);
216
+ defineSymbol(math, mathord, "\u263c", "\\sun", true);
217
+ defineSymbol(math, mathord, "\u263e", "\\leftmoon", true);
218
+ defineSymbol(math, mathord, "\u263d", "\\rightmoon", true);
215
219
 
216
220
  // AMS Negated Binary Relations
217
221
  defineSymbol(math, rel, "\u226e", "\\nless", true);
package/temml.js CHANGED
@@ -21,6 +21,7 @@ import defineMacro from "./src/defineMacro";
21
21
  import { postProcess, version } from "./src/postProcess";
22
22
 
23
23
  /**
24
+ * @type {import('./temml').render}
24
25
  * Parse and build an expression, and place that expression in the DOM node
25
26
  * given.
26
27
  */
@@ -58,6 +59,7 @@ if (typeof document !== "undefined") {
58
59
  }
59
60
 
60
61
  /**
62
+ * @type {import('./temml').renderToString}
61
63
  * Parse and build an expression, and return the markup for that.
62
64
  */
63
65
  const renderToString = function(expression, options) {
@@ -66,6 +68,7 @@ const renderToString = function(expression, options) {
66
68
  };
67
69
 
68
70
  /**
71
+ * @type {import('./temml').generateParseTree}
69
72
  * Parse an expression and return the parse tree.
70
73
  */
71
74
  const generateParseTree = function(expression, options) {
@@ -74,6 +77,7 @@ const generateParseTree = function(expression, options) {
74
77
  };
75
78
 
76
79
  /**
80
+ * @type {import('./temml').definePreamble}
77
81
  * Take an expression which contains a preamble.
78
82
  * Parse it and return the macros.
79
83
  */
@@ -106,6 +110,7 @@ const renderError = function(error, expression, options) {
106
110
  };
107
111
 
108
112
  /**
113
+ * @type {import('./temml').renderToMathMLTree}
109
114
  * Generates and returns the Temml build tree. This is used for advanced
110
115
  * use cases (like rendering to custom output).
111
116
  */
@@ -123,6 +128,7 @@ const renderToMathMLTree = function(expression, options) {
123
128
  }
124
129
  };
125
130
 
131
+ /** @type {import('./temml').default} */
126
132
  export default {
127
133
  /**
128
134
  * Current Temml version