temml 0.10.33 → 0.10.34

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.js CHANGED
@@ -610,6 +610,7 @@ var temml = (function () {
610
610
  this.children = children || [];
611
611
  this.classes = classes || [];
612
612
  this.style = style || {}; // Used for <mstyle> elements
613
+ this.label = "";
613
614
  }
614
615
 
615
616
  /**
@@ -627,6 +628,10 @@ var temml = (function () {
627
628
  return this.attributes[name];
628
629
  }
629
630
 
631
+ setLabel(value) {
632
+ this.label = value;
633
+ }
634
+
630
635
  /**
631
636
  * Converts the math node into a MathML-namespaced DOM element.
632
637
  */
@@ -1543,7 +1548,7 @@ var temml = (function () {
1543
1548
  defineSymbol(math, mathord, "\u2aeb", "\\Bot");
1544
1549
  defineSymbol(math, bin, "\u2217", "\u2217", true);
1545
1550
  defineSymbol(math, bin, "+", "+");
1546
- defineSymbol(math, bin, "*", "*");
1551
+ defineSymbol(math, bin, "\u2217", "*");
1547
1552
  defineSymbol(math, bin, "\u2044", "/", true);
1548
1553
  defineSymbol(math, bin, "\u2044", "\u2044");
1549
1554
  defineSymbol(math, bin, "\u2212", "-", true);
@@ -2342,16 +2347,36 @@ var temml = (function () {
2342
2347
  return new mathMLTree.MathNode("mtd", [], [], { padding: "0", width: "50%" })
2343
2348
  };
2344
2349
 
2350
+ const labelContainers = ["mrow", "mtd", "mtable", "mtr"];
2351
+ const getLabel = parent => {
2352
+ for (const node of parent.children) {
2353
+ if (node.type && labelContainers.includes(node.type)) {
2354
+ if (node.classes && node.classes[0] === "tml-label") {
2355
+ const label = node.label;
2356
+ return label
2357
+ } else {
2358
+ const label = getLabel(node);
2359
+ if (label) { return label }
2360
+ }
2361
+ } else if (!node.type) {
2362
+ const label = getLabel(node);
2363
+ if (label) { return label }
2364
+ }
2365
+ }
2366
+ };
2367
+
2345
2368
  const taggedExpression = (expression, tag, style, leqno) => {
2346
2369
  tag = buildExpressionRow(tag[0].body, style);
2347
2370
  tag = consolidateText(tag);
2348
2371
  tag.classes.push("tml-tag");
2349
2372
 
2373
+ const label = getLabel(expression); // from a \label{} function.
2350
2374
  expression = new mathMLTree.MathNode("mtd", [expression]);
2351
2375
  const rowArray = [glue$1(), expression, glue$1()];
2352
2376
  rowArray[leqno ? 0 : 2].classes.push(leqno ? "tml-left" : "tml-right");
2353
2377
  rowArray[leqno ? 0 : 2].children.push(tag);
2354
2378
  const mtr = new mathMLTree.MathNode("mtr", rowArray, ["tml-tageqn"]);
2379
+ if (label) { mtr.setAttribute("id", label); }
2355
2380
  const table = new mathMLTree.MathNode("mtable", [mtr]);
2356
2381
  table.style.width = "100%";
2357
2382
  table.setAttribute("displaystyle", "true");
@@ -3182,6 +3207,8 @@ var temml = (function () {
3182
3207
  type: "array",
3183
3208
  mode: "math",
3184
3209
  body,
3210
+ tags: null,
3211
+ labels: new Array(body.length + 1).fill(""),
3185
3212
  envClasses: ["jot", "cd"],
3186
3213
  cols: [],
3187
3214
  hLinesBeforeRow: new Array(body.length + 1).fill([])
@@ -4422,6 +4449,75 @@ var temml = (function () {
4422
4449
  }
4423
4450
  }
4424
4451
 
4452
+ /**
4453
+ * Lexing or parsing positional information for error reporting.
4454
+ * This object is immutable.
4455
+ */
4456
+ class SourceLocation {
4457
+ constructor(lexer, start, end) {
4458
+ this.lexer = lexer; // Lexer holding the input string.
4459
+ this.start = start; // Start offset, zero-based inclusive.
4460
+ this.end = end; // End offset, zero-based exclusive.
4461
+ }
4462
+
4463
+ /**
4464
+ * Merges two `SourceLocation`s from location providers, given they are
4465
+ * provided in order of appearance.
4466
+ * - Returns the first one's location if only the first is provided.
4467
+ * - Returns a merged range of the first and the last if both are provided
4468
+ * and their lexers match.
4469
+ * - Otherwise, returns null.
4470
+ */
4471
+ static range(first, second) {
4472
+ if (!second) {
4473
+ return first && first.loc;
4474
+ } else if (!first || !first.loc || !second.loc || first.loc.lexer !== second.loc.lexer) {
4475
+ return null;
4476
+ } else {
4477
+ return new SourceLocation(first.loc.lexer, first.loc.start, second.loc.end);
4478
+ }
4479
+ }
4480
+ }
4481
+
4482
+ /**
4483
+ * Interface required to break circular dependency between Token, Lexer, and
4484
+ * ParseError.
4485
+ */
4486
+
4487
+ /**
4488
+ * The resulting token returned from `lex`.
4489
+ *
4490
+ * It consists of the token text plus some position information.
4491
+ * The position information is essentially a range in an input string,
4492
+ * but instead of referencing the bare input string, we refer to the lexer.
4493
+ * That way it is possible to attach extra metadata to the input string,
4494
+ * like for example a file name or similar.
4495
+ *
4496
+ * The position information is optional, so it is OK to construct synthetic
4497
+ * tokens if appropriate. Not providing available position information may
4498
+ * lead to degraded error reporting, though.
4499
+ */
4500
+ class Token {
4501
+ constructor(
4502
+ text, // the text of this token
4503
+ loc
4504
+ ) {
4505
+ this.text = text;
4506
+ this.loc = loc;
4507
+ }
4508
+
4509
+ /**
4510
+ * Given a pair of tokens (this and endToken), compute a `Token` encompassing
4511
+ * the whole input range enclosed by these two.
4512
+ */
4513
+ range(
4514
+ endToken, // last token of the range, inclusive
4515
+ text // the text of the newly constructed token
4516
+ ) {
4517
+ return new Token(text, SourceLocation.range(this, endToken));
4518
+ }
4519
+ }
4520
+
4425
4521
  // In TeX, there are actually three sets of dimensions, one for each of
4426
4522
  // textstyle, scriptstyle, and scriptscriptstyle. These are
4427
4523
  // provided in the the arrays below, in that order.
@@ -4906,8 +5002,10 @@ var temml = (function () {
4906
5002
  if (context.macros.get("\\df@tag")) {
4907
5003
  throw new ParseError("Multiple \\tag");
4908
5004
  }
4909
- return "\\def\\df@tag{\\text{#1}}";
5005
+ return "\\gdef\\df@tag{\\text{#1}}";
4910
5006
  });
5007
+ defineMacro("\\notag", "\\nonumber");
5008
+ defineMacro("\\nonumber", "\\gdef\\@eqnsw{0}");
4911
5009
 
4912
5010
  // \renewcommand{\bmod}{\nonscript\mskip-\medmuskip\mkern5mu\mathbin
4913
5011
  // {\operator@font mod}\penalty900
@@ -5197,33 +5295,30 @@ var temml = (function () {
5197
5295
  return [arraystretch, arraycolsep]
5198
5296
  };
5199
5297
 
5200
- const getTag = (group, style, rowNum) => {
5201
- let tag;
5202
- const tagContents = group.tags.shift();
5203
- if (tagContents) {
5204
- // The author has written a \tag or a \notag in this row.
5205
- if (tagContents.body) {
5206
- tag = buildExpressionRow(tagContents.body, style, true);
5207
- tag.classes = ["tml-tag"];
5208
- } else {
5209
- // \notag. Return an empty span.
5210
- tag = new mathMLTree.MathNode("mtext", [], []);
5211
- return tag
5212
- }
5213
- } else if (group.envClasses.includes("multline") &&
5214
- ((group.leqno && rowNum !== 0) || (!group.leqno && rowNum !== group.body.length - 1))) {
5215
- // A multiline that does not receive a tag. Return an empty cell.
5216
- tag = new mathMLTree.MathNode("mtext", [], []);
5217
- return tag
5218
- } else {
5219
- // AMS automatcally numbered equaton.
5220
- // Insert a class so the element can be populated by a CSS counter.
5221
- // WebKit will display the CSS counter only inside a span.
5222
- tag = new mathMLTree.MathNode("mtext", [new Span(["tml-eqn"])]);
5298
+ const checkCellForLabels = cell => {
5299
+ // Check if the author wrote a \tag{} inside this cell.
5300
+ let rowLabel = "";
5301
+ for (let i = 0; i < cell.length; i++) {
5302
+ if (cell[i].type === "label") {
5303
+ if (rowLabel) { throw new ParseError(("Multiple \\labels in one row")) }
5304
+ rowLabel = cell[i].string;
5305
+ }
5223
5306
  }
5224
- return tag
5307
+ return rowLabel
5225
5308
  };
5226
5309
 
5310
+ // autoTag (an argument to parseArray) can be one of three values:
5311
+ // * undefined: Regular (not-top-level) array; no tags on each row
5312
+ // * true: Automatic equation numbering, overridable by \tag
5313
+ // * false: Tags allowed on each row, but no automatic numbering
5314
+ // This function *doesn't* work with the "split" environment name.
5315
+ function getAutoTag(name) {
5316
+ if (name.indexOf("ed") === -1) {
5317
+ return name.indexOf("*") === -1;
5318
+ }
5319
+ // return undefined;
5320
+ }
5321
+
5227
5322
  /**
5228
5323
  * Parse the body of the environment, with rows delimited by \\ and
5229
5324
  * columns delimited by &, and create a nested list in row-major order
@@ -5235,7 +5330,7 @@ var temml = (function () {
5235
5330
  {
5236
5331
  cols, // [{ type: string , align: l|c|r|null }]
5237
5332
  envClasses, // align(ed|at|edat) | array | cases | cd | small | multline
5238
- addEqnNum, // boolean
5333
+ autoTag, // boolean
5239
5334
  singleRow, // boolean
5240
5335
  emptySingleRow, // boolean
5241
5336
  maxNumCols, // number
@@ -5251,13 +5346,6 @@ var temml = (function () {
5251
5346
  // TODO: provide helpful error when \cr is used outside array environment
5252
5347
  parser.gullet.macros.set("\\cr", "\\\\\\relax");
5253
5348
  }
5254
- if (addEqnNum) {
5255
- parser.gullet.macros.set("\\tag", "\\@ifstar\\envtag@literal\\envtag@paren");
5256
- parser.gullet.macros.set("\\envtag@paren", "\\env@tag{{(\\text{#1})}}");
5257
- parser.gullet.macros.set("\\envtag@literal", "\\env@tag{\\text{#1}}");
5258
- parser.gullet.macros.set("\\notag", "\\env@notag");
5259
- parser.gullet.macros.set("\\nonumber", "\\env@notag");
5260
- }
5261
5349
 
5262
5350
  // Start group for first cell
5263
5351
  parser.gullet.beginGroup();
@@ -5265,29 +5353,39 @@ var temml = (function () {
5265
5353
  let row = [];
5266
5354
  const body = [row];
5267
5355
  const rowGaps = [];
5268
- const tags = [];
5269
- let rowTag;
5356
+ const labels = [];
5357
+
5270
5358
  const hLinesBeforeRow = [];
5271
5359
 
5360
+ const tags = (autoTag != null ? [] : undefined);
5361
+
5362
+ // amsmath uses \global\@eqnswtrue and \global\@eqnswfalse to represent
5363
+ // whether this row should have an equation number. Simulate this with
5364
+ // a \@eqnsw macro set to 1 or 0.
5365
+ function beginRow() {
5366
+ if (autoTag) {
5367
+ parser.gullet.macros.set("\\@eqnsw", "1", true);
5368
+ }
5369
+ }
5370
+ function endRow() {
5371
+ if (tags) {
5372
+ if (parser.gullet.macros.get("\\df@tag")) {
5373
+ tags.push(parser.subparse([new Token("\\df@tag")]));
5374
+ parser.gullet.macros.set("\\df@tag", undefined, true);
5375
+ } else {
5376
+ tags.push(Boolean(autoTag) &&
5377
+ parser.gullet.macros.get("\\@eqnsw") === "1");
5378
+ }
5379
+ }
5380
+ }
5381
+ beginRow();
5382
+
5272
5383
  // Test for \hline at the top of the array.
5273
5384
  hLinesBeforeRow.push(getHLines(parser));
5274
5385
 
5275
5386
  while (true) {
5276
5387
  // Parse each cell in its own group (namespace)
5277
5388
  let cell = parser.parseExpression(false, singleRow ? "\\end" : "\\\\");
5278
-
5279
- if (addEqnNum && !rowTag) {
5280
- // Check if the author wrote a \tag{} inside this cell.
5281
- for (let i = 0; i < cell.length; i++) {
5282
- if (cell[i].type === "envTag" || cell[i].type === "noTag") {
5283
- // Get the contents of the \text{} nested inside the \env@Tag{}
5284
- rowTag = cell[i].type === "envTag"
5285
- ? cell.splice(i, 1)[0].body.body[0]
5286
- : { body: null };
5287
- break
5288
- }
5289
- }
5290
- }
5291
5389
  parser.gullet.endGroup();
5292
5390
  parser.gullet.beginGroup();
5293
5391
 
@@ -5316,6 +5414,7 @@ var temml = (function () {
5316
5414
  }
5317
5415
  parser.consume();
5318
5416
  } else if (next === "\\end") {
5417
+ endRow();
5319
5418
  // Arrays terminate newlines with `\crcr` which consumes a `\cr` if
5320
5419
  // the last line is empty. However, AMS environments keep the
5321
5420
  // empty row if it's the only one.
@@ -5323,6 +5422,7 @@ var temml = (function () {
5323
5422
  if (row.length === 1 && cell.body.length === 0 && (body.length > 1 || !emptySingleRow)) {
5324
5423
  body.pop();
5325
5424
  }
5425
+ labels.push(checkCellForLabels(cell.body));
5326
5426
  if (hLinesBeforeRow.length < body.length + 1) {
5327
5427
  hLinesBeforeRow.push([]);
5328
5428
  }
@@ -5339,15 +5439,16 @@ var temml = (function () {
5339
5439
  size = parser.parseSizeGroup(true);
5340
5440
  }
5341
5441
  rowGaps.push(size ? size.value : null);
5442
+ endRow();
5342
5443
 
5343
- tags.push(rowTag);
5444
+ labels.push(checkCellForLabels(cell.body));
5344
5445
 
5345
5446
  // check for \hline(s) following the row separator
5346
5447
  hLinesBeforeRow.push(getHLines(parser));
5347
5448
 
5348
5449
  row = [];
5349
- rowTag = null;
5350
5450
  body.push(row);
5451
+ beginRow();
5351
5452
  } else {
5352
5453
  throw new ParseError("Expected & or \\\\ or \\cr or \\end", parser.nextToken);
5353
5454
  }
@@ -5358,8 +5459,6 @@ var temml = (function () {
5358
5459
  // End array group defining \cr
5359
5460
  parser.gullet.endGroup();
5360
5461
 
5361
- tags.push(rowTag);
5362
-
5363
5462
  return {
5364
5463
  type: "array",
5365
5464
  mode: parser.mode,
@@ -5368,9 +5467,10 @@ var temml = (function () {
5368
5467
  rowGaps,
5369
5468
  hLinesBeforeRow,
5370
5469
  envClasses,
5371
- addEqnNum,
5470
+ autoTag,
5372
5471
  scriptLevel,
5373
5472
  tags,
5473
+ labels,
5374
5474
  leqno,
5375
5475
  arraystretch,
5376
5476
  arraycolsep
@@ -5427,19 +5527,43 @@ var temml = (function () {
5427
5527
  }
5428
5528
  row.push(mtd);
5429
5529
  }
5430
- if (group.addEqnNum) {
5431
- row.unshift(glue(group));
5432
- row.push(glue(group));
5433
- const tag = getTag(group, style.withLevel(cellLevel), i);
5434
- if (group.leqno) {
5435
- row[0].children.push(tag);
5436
- row[0].classes.push("tml-left");
5437
- } else {
5438
- row[row.length - 1].children.push(tag);
5439
- row[row.length - 1].classes.push("tml-right");
5530
+ const numColumns = group.body[0].length;
5531
+ // Fill out a short row with empty <mtd> elements.
5532
+ for (let k = 0; k < numColumns - rw.length; k++) {
5533
+ row.push(new mathMLTree.MathNode("mtd", [], style));
5534
+ }
5535
+ if (group.autoTag) {
5536
+ const tag = group.tags[i];
5537
+ let tagElement;
5538
+ if (tag === true) { // automatic numbering
5539
+ tagElement = new mathMLTree.MathNode("mtext", [new Span(["tml-eqn"])]);
5540
+ } else if (tag === false) {
5541
+ // \nonumber/\notag or starred environment
5542
+ tagElement = new mathMLTree.MathNode("mtext", [], []);
5543
+ } else { // manual \tag
5544
+ tagElement = buildExpressionRow(tag[0].body, style.withLevel(cellLevel), true);
5545
+ tagElement = consolidateText(tagElement);
5546
+ tagElement.classes = ["tml-tag"];
5547
+ }
5548
+ if (tagElement) {
5549
+ row.unshift(glue(group));
5550
+ row.push(glue(group));
5551
+ if (group.leqno) {
5552
+ row[0].children.push(tagElement);
5553
+ row[0].classes.push("tml-left");
5554
+ } else {
5555
+ row[row.length - 1].children.push(tagElement);
5556
+ row[row.length - 1].classes.push("tml-right");
5557
+ }
5440
5558
  }
5441
5559
  }
5442
5560
  const mtr = new mathMLTree.MathNode("mtr", row, []);
5561
+ const label = group.labels.shift();
5562
+ if (label && group.tags && group.tags[i]) {
5563
+ mtr.setAttribute("id", label);
5564
+ if (Array.isArray(group.tags[i])) { mtr.classes.push("tml-tageqn"); }
5565
+ }
5566
+
5443
5567
  // Write horizontal rules
5444
5568
  if (i === 0 && hlines[0].length > 0) {
5445
5569
  if (hlines[0].length === 2) {
@@ -5463,16 +5587,17 @@ var temml = (function () {
5463
5587
  }
5464
5588
 
5465
5589
  if (group.envClasses.length > 0) {
5466
- let pad = group.envClasses.includes("jot")
5467
- ? "0.7" // 0.5ex + 0.09em top & bot padding
5468
- : group.envClasses.includes("small")
5469
- ? "0.35"
5470
- : "0.5"; // 0.5ex default top & bot padding
5471
5590
  if (group.arraystretch && group.arraystretch !== 1) {
5472
5591
  // In LaTeX, \arraystretch is a factor applied to a 12pt strut height.
5473
5592
  // It defines a baseline to baseline distance.
5474
5593
  // Here, we do an approximation of that approach.
5475
- pad = String(1.4 * group.arraystretch - 0.8);
5594
+ const pad = String(1.4 * group.arraystretch - 0.8) + "ex";
5595
+ for (let i = 0; i < tbl.length; i++) {
5596
+ for (let j = 0; j < tbl[i].children.length; j++) {
5597
+ tbl[i].children[j].style.paddingTop = pad;
5598
+ tbl[i].children[j].style.paddingBottom = pad;
5599
+ }
5600
+ }
5476
5601
  }
5477
5602
  let sidePadding = group.envClasses.includes("abut")
5478
5603
  ? "0"
@@ -5486,7 +5611,7 @@ var temml = (function () {
5486
5611
  let sidePadUnit = "em";
5487
5612
  if (group.arraycolsep) {
5488
5613
  const arraySidePad = calculateSize(group.arraycolsep, style);
5489
- sidePadding = arraySidePad.number;
5614
+ sidePadding = arraySidePad.number.toFixed(4);
5490
5615
  sidePadUnit = arraySidePad.unit;
5491
5616
  }
5492
5617
 
@@ -5497,18 +5622,18 @@ var temml = (function () {
5497
5622
  if (j === numCols - 1 && hand === 1) { return "0" }
5498
5623
  if (group.envClasses[0] !== "align") { return sidePadding }
5499
5624
  if (hand === 1) { return "0" }
5500
- if (group.addEqnNum) {
5625
+ if (group.autoTag) {
5501
5626
  return (j % 2) ? "1" : "0"
5502
5627
  } else {
5503
5628
  return (j % 2) ? "0" : "1"
5504
5629
  }
5505
5630
  };
5506
5631
 
5507
- // Padding
5632
+ // Side padding
5508
5633
  for (let i = 0; i < tbl.length; i++) {
5509
5634
  for (let j = 0; j < tbl[i].children.length; j++) {
5510
- tbl[i].children[j].style.padding = `${pad}ex ${sidePad(j, 1)}${sidePadUnit}`
5511
- + ` ${pad}ex ${sidePad(j, 0)}${sidePadUnit}`;
5635
+ tbl[i].children[j].style.paddingLeft = `${sidePad(j, 0)}${sidePadUnit}`;
5636
+ tbl[i].children[j].style.paddingRight = `${sidePad(j, 1)}${sidePadUnit}`;
5512
5637
  }
5513
5638
  }
5514
5639
 
@@ -5522,13 +5647,13 @@ var temml = (function () {
5522
5647
  // TODO: Remove -webkit- when Chromium no longer needs it.
5523
5648
  row.children[j].classes = ["tml-" + (j % 2 ? "left" : "right")];
5524
5649
  }
5525
- if (group.addEqnNum) {
5650
+ if (group.autoTag) {
5526
5651
  const k = group.leqno ? 0 : row.children.length - 1;
5527
5652
  row.children[k].classes = ["tml-" + (group.leqno ? "left" : "right")];
5528
5653
  }
5529
5654
  }
5530
5655
  if (row.children.length > 1 && group.envClasses.includes("cases")) {
5531
- row.children[1].style.padding = row.children[1].style.padding.replace(/0em$/, "1em");
5656
+ row.children[1].style.paddingLeft = "1em";
5532
5657
  }
5533
5658
 
5534
5659
  if (group.envClasses.includes("cases") || group.envClasses.includes("subarray")) {
@@ -5548,9 +5673,17 @@ var temml = (function () {
5548
5673
  }
5549
5674
 
5550
5675
  let table = new mathMLTree.MathNode("mtable", tbl);
5676
+ if (group.envClasses.length > 0) {
5677
+ // Top & bottom padding
5678
+ if (group.envClasses.includes("jot")) {
5679
+ table.classes.push("tml-jot");
5680
+ } else if (group.envClasses.includes("small")) {
5681
+ table.classes.push("tml-small");
5682
+ }
5683
+ }
5551
5684
  if (group.scriptLevel === "display") { table.setAttribute("displaystyle", "true"); }
5552
5685
 
5553
- if (group.addEqnNum || group.envClasses.includes("multline")) {
5686
+ if (group.autoTag || group.envClasses.includes("multline")) {
5554
5687
  table.style.width = "100%";
5555
5688
  }
5556
5689
 
@@ -5580,7 +5713,7 @@ var temml = (function () {
5580
5713
  row.children[0].style.borderLeft = sep;
5581
5714
  }
5582
5715
  }
5583
- let iCol = group.addEqnNum ? 0 : -1;
5716
+ let iCol = group.autoTag ? 0 : -1;
5584
5717
  for (let i = iStart; i < iEnd; i++) {
5585
5718
  if (cols[i].type === "align") {
5586
5719
  const colAlign = alignMap[cols[i].align];
@@ -5622,7 +5755,7 @@ var temml = (function () {
5622
5755
  }
5623
5756
  }
5624
5757
  }
5625
- if (group.addEqnNum) {
5758
+ if (group.autoTag) {
5626
5759
  // allow for glue cells on each side
5627
5760
  align = "left " + (align.length > 0 ? align : "center ") + "right ";
5628
5761
  }
@@ -5646,13 +5779,14 @@ var temml = (function () {
5646
5779
  if (context.envName.indexOf("ed") === -1) {
5647
5780
  validateAmsEnvironmentContext(context);
5648
5781
  }
5782
+ const isSplit = context.envName === "split";
5649
5783
  const cols = [];
5650
5784
  const res = parseArray(
5651
5785
  context.parser,
5652
5786
  {
5653
5787
  cols,
5654
- addEqnNum: context.envName === "align" || context.envName === "alignat",
5655
5788
  emptySingleRow: true,
5789
+ autoTag: isSplit ? undefined : getAutoTag(context.envName),
5656
5790
  envClasses: ["abut", "jot"], // set row spacing & provisional column spacing
5657
5791
  maxNumCols: context.envName === "split" ? 2 : undefined,
5658
5792
  leqno: context.parser.settings.leqno
@@ -5974,7 +6108,7 @@ var temml = (function () {
5974
6108
  const res = {
5975
6109
  cols: [],
5976
6110
  envClasses: ["abut", "jot"],
5977
- addEqnNum: context.envName === "gather",
6111
+ autoTag: getAutoTag(context.envName),
5978
6112
  emptySingleRow: true,
5979
6113
  leqno: context.parser.settings.leqno
5980
6114
  };
@@ -5992,7 +6126,7 @@ var temml = (function () {
5992
6126
  handler(context) {
5993
6127
  validateAmsEnvironmentContext(context);
5994
6128
  const res = {
5995
- addEqnNum: context.envName === "equation",
6129
+ autoTag: getAutoTag(context.envName),
5996
6130
  emptySingleRow: true,
5997
6131
  singleRow: true,
5998
6132
  maxNumCols: 1,
@@ -6013,7 +6147,7 @@ var temml = (function () {
6013
6147
  handler(context) {
6014
6148
  validateAmsEnvironmentContext(context);
6015
6149
  const res = {
6016
- addEqnNum: context.envName === "multline",
6150
+ autoTag: context.envName === "multline",
6017
6151
  maxNumCols: 1,
6018
6152
  envClasses: ["jot", "multline"],
6019
6153
  leqno: context.parser.settings.leqno
@@ -7070,7 +7204,7 @@ var temml = (function () {
7070
7204
  // Return a no-width, no-ink element with an HTML id.
7071
7205
  const node = new mathMLTree.MathNode("mrow", [], ["tml-label"]);
7072
7206
  if (group.string.length > 0) {
7073
- node.setAttribute("id", group.string);
7207
+ node.setLabel(group.string);
7074
7208
  }
7075
7209
  return node
7076
7210
  }
@@ -9333,75 +9467,6 @@ var temml = (function () {
9333
9467
 
9334
9468
  const functions = _functions;
9335
9469
 
9336
- /**
9337
- * Lexing or parsing positional information for error reporting.
9338
- * This object is immutable.
9339
- */
9340
- class SourceLocation {
9341
- constructor(lexer, start, end) {
9342
- this.lexer = lexer; // Lexer holding the input string.
9343
- this.start = start; // Start offset, zero-based inclusive.
9344
- this.end = end; // End offset, zero-based exclusive.
9345
- }
9346
-
9347
- /**
9348
- * Merges two `SourceLocation`s from location providers, given they are
9349
- * provided in order of appearance.
9350
- * - Returns the first one's location if only the first is provided.
9351
- * - Returns a merged range of the first and the last if both are provided
9352
- * and their lexers match.
9353
- * - Otherwise, returns null.
9354
- */
9355
- static range(first, second) {
9356
- if (!second) {
9357
- return first && first.loc;
9358
- } else if (!first || !first.loc || !second.loc || first.loc.lexer !== second.loc.lexer) {
9359
- return null;
9360
- } else {
9361
- return new SourceLocation(first.loc.lexer, first.loc.start, second.loc.end);
9362
- }
9363
- }
9364
- }
9365
-
9366
- /**
9367
- * Interface required to break circular dependency between Token, Lexer, and
9368
- * ParseError.
9369
- */
9370
-
9371
- /**
9372
- * The resulting token returned from `lex`.
9373
- *
9374
- * It consists of the token text plus some position information.
9375
- * The position information is essentially a range in an input string,
9376
- * but instead of referencing the bare input string, we refer to the lexer.
9377
- * That way it is possible to attach extra metadata to the input string,
9378
- * like for example a file name or similar.
9379
- *
9380
- * The position information is optional, so it is OK to construct synthetic
9381
- * tokens if appropriate. Not providing available position information may
9382
- * lead to degraded error reporting, though.
9383
- */
9384
- class Token {
9385
- constructor(
9386
- text, // the text of this token
9387
- loc
9388
- ) {
9389
- this.text = text;
9390
- this.loc = loc;
9391
- }
9392
-
9393
- /**
9394
- * Given a pair of tokens (this and endToken), compute a `Token` encompassing
9395
- * the whole input range enclosed by these two.
9396
- */
9397
- range(
9398
- endToken, // last token of the range, inclusive
9399
- text // the text of the newly constructed token
9400
- ) {
9401
- return new Token(text, SourceLocation.range(this, endToken));
9402
- }
9403
- }
9404
-
9405
9470
  /**
9406
9471
  * The Lexer class handles tokenizing the input in various ways. Since our
9407
9472
  * parser expects us to be able to backtrack, the lexer allows lexing from any
@@ -11699,7 +11764,7 @@ var temml = (function () {
11699
11764
  * https://mit-license.org/
11700
11765
  */
11701
11766
 
11702
- const version = "0.10.33";
11767
+ const version = "0.10.34";
11703
11768
 
11704
11769
  function postProcess(block) {
11705
11770
  const labelMap = {};
@@ -11715,15 +11780,15 @@ var temml = (function () {
11715
11780
  // No need to write a number into the text content of the element.
11716
11781
  // A CSS counter has done that even if this postProcess() function is not used.
11717
11782
 
11718
- // Find any \label that refers to an AMS eqn number.
11783
+ // Find any \label that refers to an AMS automatic eqn number.
11719
11784
  while (true) {
11785
+ if (parent.tagName === "mtable") { break }
11720
11786
  const labels = parent.getElementsByClassName("tml-label");
11721
11787
  if (labels.length > 0) {
11722
- parent.setAttribute("id", labels[0].id);
11723
- labelMap[labels[0].id] = String(i);
11788
+ const id = parent.attributes.id.value;
11789
+ labelMap[id] = String(i);
11724
11790
  break
11725
11791
  } else {
11726
- if (parent.tagName === "mtable") { break }
11727
11792
  parent = parent.parentElement;
11728
11793
  }
11729
11794
  }
@@ -11736,7 +11801,8 @@ var temml = (function () {
11736
11801
  if (labels.length > 0) {
11737
11802
  const tags = parent.getElementsByClassName("tml-tag");
11738
11803
  if (tags.length > 0) {
11739
- labelMap[labels[0].id] = tags[0].textContent;
11804
+ const id = parent.attributes.id.value;
11805
+ labelMap[id] = tags[0].textContent;
11740
11806
  }
11741
11807
  }
11742
11808
  }