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.mjs CHANGED
@@ -607,6 +607,7 @@ class MathNode {
607
607
  this.children = children || [];
608
608
  this.classes = classes || [];
609
609
  this.style = style || {}; // Used for <mstyle> elements
610
+ this.label = "";
610
611
  }
611
612
 
612
613
  /**
@@ -624,6 +625,10 @@ class MathNode {
624
625
  return this.attributes[name];
625
626
  }
626
627
 
628
+ setLabel(value) {
629
+ this.label = value;
630
+ }
631
+
627
632
  /**
628
633
  * Converts the math node into a MathML-namespaced DOM element.
629
634
  */
@@ -1540,7 +1545,7 @@ defineSymbol(math, mathord, "\u03db", "\\stigma", true);
1540
1545
  defineSymbol(math, mathord, "\u2aeb", "\\Bot");
1541
1546
  defineSymbol(math, bin, "\u2217", "\u2217", true);
1542
1547
  defineSymbol(math, bin, "+", "+");
1543
- defineSymbol(math, bin, "*", "*");
1548
+ defineSymbol(math, bin, "\u2217", "*");
1544
1549
  defineSymbol(math, bin, "\u2044", "/", true);
1545
1550
  defineSymbol(math, bin, "\u2044", "\u2044");
1546
1551
  defineSymbol(math, bin, "\u2212", "-", true);
@@ -2339,16 +2344,36 @@ const glue$1 = _ => {
2339
2344
  return new mathMLTree.MathNode("mtd", [], [], { padding: "0", width: "50%" })
2340
2345
  };
2341
2346
 
2347
+ const labelContainers = ["mrow", "mtd", "mtable", "mtr"];
2348
+ const getLabel = parent => {
2349
+ for (const node of parent.children) {
2350
+ if (node.type && labelContainers.includes(node.type)) {
2351
+ if (node.classes && node.classes[0] === "tml-label") {
2352
+ const label = node.label;
2353
+ return label
2354
+ } else {
2355
+ const label = getLabel(node);
2356
+ if (label) { return label }
2357
+ }
2358
+ } else if (!node.type) {
2359
+ const label = getLabel(node);
2360
+ if (label) { return label }
2361
+ }
2362
+ }
2363
+ };
2364
+
2342
2365
  const taggedExpression = (expression, tag, style, leqno) => {
2343
2366
  tag = buildExpressionRow(tag[0].body, style);
2344
2367
  tag = consolidateText(tag);
2345
2368
  tag.classes.push("tml-tag");
2346
2369
 
2370
+ const label = getLabel(expression); // from a \label{} function.
2347
2371
  expression = new mathMLTree.MathNode("mtd", [expression]);
2348
2372
  const rowArray = [glue$1(), expression, glue$1()];
2349
2373
  rowArray[leqno ? 0 : 2].classes.push(leqno ? "tml-left" : "tml-right");
2350
2374
  rowArray[leqno ? 0 : 2].children.push(tag);
2351
2375
  const mtr = new mathMLTree.MathNode("mtr", rowArray, ["tml-tageqn"]);
2376
+ if (label) { mtr.setAttribute("id", label); }
2352
2377
  const table = new mathMLTree.MathNode("mtable", [mtr]);
2353
2378
  table.style.width = "100%";
2354
2379
  table.setAttribute("displaystyle", "true");
@@ -3179,6 +3204,8 @@ function parseCD(parser) {
3179
3204
  type: "array",
3180
3205
  mode: "math",
3181
3206
  body,
3207
+ tags: null,
3208
+ labels: new Array(body.length + 1).fill(""),
3182
3209
  envClasses: ["jot", "cd"],
3183
3210
  cols: [],
3184
3211
  hLinesBeforeRow: new Array(body.length + 1).fill([])
@@ -4419,6 +4446,75 @@ function defineEnvironment({ type, names, props, handler, mathmlBuilder }) {
4419
4446
  }
4420
4447
  }
4421
4448
 
4449
+ /**
4450
+ * Lexing or parsing positional information for error reporting.
4451
+ * This object is immutable.
4452
+ */
4453
+ class SourceLocation {
4454
+ constructor(lexer, start, end) {
4455
+ this.lexer = lexer; // Lexer holding the input string.
4456
+ this.start = start; // Start offset, zero-based inclusive.
4457
+ this.end = end; // End offset, zero-based exclusive.
4458
+ }
4459
+
4460
+ /**
4461
+ * Merges two `SourceLocation`s from location providers, given they are
4462
+ * provided in order of appearance.
4463
+ * - Returns the first one's location if only the first is provided.
4464
+ * - Returns a merged range of the first and the last if both are provided
4465
+ * and their lexers match.
4466
+ * - Otherwise, returns null.
4467
+ */
4468
+ static range(first, second) {
4469
+ if (!second) {
4470
+ return first && first.loc;
4471
+ } else if (!first || !first.loc || !second.loc || first.loc.lexer !== second.loc.lexer) {
4472
+ return null;
4473
+ } else {
4474
+ return new SourceLocation(first.loc.lexer, first.loc.start, second.loc.end);
4475
+ }
4476
+ }
4477
+ }
4478
+
4479
+ /**
4480
+ * Interface required to break circular dependency between Token, Lexer, and
4481
+ * ParseError.
4482
+ */
4483
+
4484
+ /**
4485
+ * The resulting token returned from `lex`.
4486
+ *
4487
+ * It consists of the token text plus some position information.
4488
+ * The position information is essentially a range in an input string,
4489
+ * but instead of referencing the bare input string, we refer to the lexer.
4490
+ * That way it is possible to attach extra metadata to the input string,
4491
+ * like for example a file name or similar.
4492
+ *
4493
+ * The position information is optional, so it is OK to construct synthetic
4494
+ * tokens if appropriate. Not providing available position information may
4495
+ * lead to degraded error reporting, though.
4496
+ */
4497
+ class Token {
4498
+ constructor(
4499
+ text, // the text of this token
4500
+ loc
4501
+ ) {
4502
+ this.text = text;
4503
+ this.loc = loc;
4504
+ }
4505
+
4506
+ /**
4507
+ * Given a pair of tokens (this and endToken), compute a `Token` encompassing
4508
+ * the whole input range enclosed by these two.
4509
+ */
4510
+ range(
4511
+ endToken, // last token of the range, inclusive
4512
+ text // the text of the newly constructed token
4513
+ ) {
4514
+ return new Token(text, SourceLocation.range(this, endToken));
4515
+ }
4516
+ }
4517
+
4422
4518
  // In TeX, there are actually three sets of dimensions, one for each of
4423
4519
  // textstyle, scriptstyle, and scriptscriptstyle. These are
4424
4520
  // provided in the the arrays below, in that order.
@@ -4903,8 +4999,10 @@ defineMacro("\\tag@literal", (context) => {
4903
4999
  if (context.macros.get("\\df@tag")) {
4904
5000
  throw new ParseError("Multiple \\tag");
4905
5001
  }
4906
- return "\\def\\df@tag{\\text{#1}}";
5002
+ return "\\gdef\\df@tag{\\text{#1}}";
4907
5003
  });
5004
+ defineMacro("\\notag", "\\nonumber");
5005
+ defineMacro("\\nonumber", "\\gdef\\@eqnsw{0}");
4908
5006
 
4909
5007
  // \renewcommand{\bmod}{\nonscript\mskip-\medmuskip\mkern5mu\mathbin
4910
5008
  // {\operator@font mod}\penalty900
@@ -7108,33 +7206,30 @@ const arrayGaps = macros => {
7108
7206
  return [arraystretch, arraycolsep]
7109
7207
  };
7110
7208
 
7111
- const getTag = (group, style, rowNum) => {
7112
- let tag;
7113
- const tagContents = group.tags.shift();
7114
- if (tagContents) {
7115
- // The author has written a \tag or a \notag in this row.
7116
- if (tagContents.body) {
7117
- tag = buildExpressionRow(tagContents.body, style, true);
7118
- tag.classes = ["tml-tag"];
7119
- } else {
7120
- // \notag. Return an empty span.
7121
- tag = new mathMLTree.MathNode("mtext", [], []);
7122
- return tag
7123
- }
7124
- } else if (group.envClasses.includes("multline") &&
7125
- ((group.leqno && rowNum !== 0) || (!group.leqno && rowNum !== group.body.length - 1))) {
7126
- // A multiline that does not receive a tag. Return an empty cell.
7127
- tag = new mathMLTree.MathNode("mtext", [], []);
7128
- return tag
7129
- } else {
7130
- // AMS automatcally numbered equaton.
7131
- // Insert a class so the element can be populated by a CSS counter.
7132
- // WebKit will display the CSS counter only inside a span.
7133
- tag = new mathMLTree.MathNode("mtext", [new Span(["tml-eqn"])]);
7209
+ const checkCellForLabels = cell => {
7210
+ // Check if the author wrote a \tag{} inside this cell.
7211
+ let rowLabel = "";
7212
+ for (let i = 0; i < cell.length; i++) {
7213
+ if (cell[i].type === "label") {
7214
+ if (rowLabel) { throw new ParseError(("Multiple \\labels in one row")) }
7215
+ rowLabel = cell[i].string;
7216
+ }
7134
7217
  }
7135
- return tag
7218
+ return rowLabel
7136
7219
  };
7137
7220
 
7221
+ // autoTag (an argument to parseArray) can be one of three values:
7222
+ // * undefined: Regular (not-top-level) array; no tags on each row
7223
+ // * true: Automatic equation numbering, overridable by \tag
7224
+ // * false: Tags allowed on each row, but no automatic numbering
7225
+ // This function *doesn't* work with the "split" environment name.
7226
+ function getAutoTag(name) {
7227
+ if (name.indexOf("ed") === -1) {
7228
+ return name.indexOf("*") === -1;
7229
+ }
7230
+ // return undefined;
7231
+ }
7232
+
7138
7233
  /**
7139
7234
  * Parse the body of the environment, with rows delimited by \\ and
7140
7235
  * columns delimited by &, and create a nested list in row-major order
@@ -7146,7 +7241,7 @@ function parseArray(
7146
7241
  {
7147
7242
  cols, // [{ type: string , align: l|c|r|null }]
7148
7243
  envClasses, // align(ed|at|edat) | array | cases | cd | small | multline
7149
- addEqnNum, // boolean
7244
+ autoTag, // boolean
7150
7245
  singleRow, // boolean
7151
7246
  emptySingleRow, // boolean
7152
7247
  maxNumCols, // number
@@ -7162,13 +7257,6 @@ function parseArray(
7162
7257
  // TODO: provide helpful error when \cr is used outside array environment
7163
7258
  parser.gullet.macros.set("\\cr", "\\\\\\relax");
7164
7259
  }
7165
- if (addEqnNum) {
7166
- parser.gullet.macros.set("\\tag", "\\@ifstar\\envtag@literal\\envtag@paren");
7167
- parser.gullet.macros.set("\\envtag@paren", "\\env@tag{{(\\text{#1})}}");
7168
- parser.gullet.macros.set("\\envtag@literal", "\\env@tag{\\text{#1}}");
7169
- parser.gullet.macros.set("\\notag", "\\env@notag");
7170
- parser.gullet.macros.set("\\nonumber", "\\env@notag");
7171
- }
7172
7260
 
7173
7261
  // Start group for first cell
7174
7262
  parser.gullet.beginGroup();
@@ -7176,29 +7264,39 @@ function parseArray(
7176
7264
  let row = [];
7177
7265
  const body = [row];
7178
7266
  const rowGaps = [];
7179
- const tags = [];
7180
- let rowTag;
7267
+ const labels = [];
7268
+
7181
7269
  const hLinesBeforeRow = [];
7182
7270
 
7271
+ const tags = (autoTag != null ? [] : undefined);
7272
+
7273
+ // amsmath uses \global\@eqnswtrue and \global\@eqnswfalse to represent
7274
+ // whether this row should have an equation number. Simulate this with
7275
+ // a \@eqnsw macro set to 1 or 0.
7276
+ function beginRow() {
7277
+ if (autoTag) {
7278
+ parser.gullet.macros.set("\\@eqnsw", "1", true);
7279
+ }
7280
+ }
7281
+ function endRow() {
7282
+ if (tags) {
7283
+ if (parser.gullet.macros.get("\\df@tag")) {
7284
+ tags.push(parser.subparse([new Token("\\df@tag")]));
7285
+ parser.gullet.macros.set("\\df@tag", undefined, true);
7286
+ } else {
7287
+ tags.push(Boolean(autoTag) &&
7288
+ parser.gullet.macros.get("\\@eqnsw") === "1");
7289
+ }
7290
+ }
7291
+ }
7292
+ beginRow();
7293
+
7183
7294
  // Test for \hline at the top of the array.
7184
7295
  hLinesBeforeRow.push(getHLines(parser));
7185
7296
 
7186
7297
  while (true) {
7187
7298
  // Parse each cell in its own group (namespace)
7188
7299
  let cell = parser.parseExpression(false, singleRow ? "\\end" : "\\\\");
7189
-
7190
- if (addEqnNum && !rowTag) {
7191
- // Check if the author wrote a \tag{} inside this cell.
7192
- for (let i = 0; i < cell.length; i++) {
7193
- if (cell[i].type === "envTag" || cell[i].type === "noTag") {
7194
- // Get the contents of the \text{} nested inside the \env@Tag{}
7195
- rowTag = cell[i].type === "envTag"
7196
- ? cell.splice(i, 1)[0].body.body[0]
7197
- : { body: null };
7198
- break
7199
- }
7200
- }
7201
- }
7202
7300
  parser.gullet.endGroup();
7203
7301
  parser.gullet.beginGroup();
7204
7302
 
@@ -7227,6 +7325,7 @@ function parseArray(
7227
7325
  }
7228
7326
  parser.consume();
7229
7327
  } else if (next === "\\end") {
7328
+ endRow();
7230
7329
  // Arrays terminate newlines with `\crcr` which consumes a `\cr` if
7231
7330
  // the last line is empty. However, AMS environments keep the
7232
7331
  // empty row if it's the only one.
@@ -7234,6 +7333,7 @@ function parseArray(
7234
7333
  if (row.length === 1 && cell.body.length === 0 && (body.length > 1 || !emptySingleRow)) {
7235
7334
  body.pop();
7236
7335
  }
7336
+ labels.push(checkCellForLabels(cell.body));
7237
7337
  if (hLinesBeforeRow.length < body.length + 1) {
7238
7338
  hLinesBeforeRow.push([]);
7239
7339
  }
@@ -7250,15 +7350,16 @@ function parseArray(
7250
7350
  size = parser.parseSizeGroup(true);
7251
7351
  }
7252
7352
  rowGaps.push(size ? size.value : null);
7353
+ endRow();
7253
7354
 
7254
- tags.push(rowTag);
7355
+ labels.push(checkCellForLabels(cell.body));
7255
7356
 
7256
7357
  // check for \hline(s) following the row separator
7257
7358
  hLinesBeforeRow.push(getHLines(parser));
7258
7359
 
7259
7360
  row = [];
7260
- rowTag = null;
7261
7361
  body.push(row);
7362
+ beginRow();
7262
7363
  } else {
7263
7364
  throw new ParseError("Expected & or \\\\ or \\cr or \\end", parser.nextToken);
7264
7365
  }
@@ -7269,8 +7370,6 @@ function parseArray(
7269
7370
  // End array group defining \cr
7270
7371
  parser.gullet.endGroup();
7271
7372
 
7272
- tags.push(rowTag);
7273
-
7274
7373
  return {
7275
7374
  type: "array",
7276
7375
  mode: parser.mode,
@@ -7279,9 +7378,10 @@ function parseArray(
7279
7378
  rowGaps,
7280
7379
  hLinesBeforeRow,
7281
7380
  envClasses,
7282
- addEqnNum,
7381
+ autoTag,
7283
7382
  scriptLevel,
7284
7383
  tags,
7384
+ labels,
7285
7385
  leqno,
7286
7386
  arraystretch,
7287
7387
  arraycolsep
@@ -7338,19 +7438,43 @@ const mathmlBuilder$7 = function(group, style) {
7338
7438
  }
7339
7439
  row.push(mtd);
7340
7440
  }
7341
- if (group.addEqnNum) {
7342
- row.unshift(glue(group));
7343
- row.push(glue(group));
7344
- const tag = getTag(group, style.withLevel(cellLevel), i);
7345
- if (group.leqno) {
7346
- row[0].children.push(tag);
7347
- row[0].classes.push("tml-left");
7348
- } else {
7349
- row[row.length - 1].children.push(tag);
7350
- row[row.length - 1].classes.push("tml-right");
7441
+ const numColumns = group.body[0].length;
7442
+ // Fill out a short row with empty <mtd> elements.
7443
+ for (let k = 0; k < numColumns - rw.length; k++) {
7444
+ row.push(new mathMLTree.MathNode("mtd", [], style));
7445
+ }
7446
+ if (group.autoTag) {
7447
+ const tag = group.tags[i];
7448
+ let tagElement;
7449
+ if (tag === true) { // automatic numbering
7450
+ tagElement = new mathMLTree.MathNode("mtext", [new Span(["tml-eqn"])]);
7451
+ } else if (tag === false) {
7452
+ // \nonumber/\notag or starred environment
7453
+ tagElement = new mathMLTree.MathNode("mtext", [], []);
7454
+ } else { // manual \tag
7455
+ tagElement = buildExpressionRow(tag[0].body, style.withLevel(cellLevel), true);
7456
+ tagElement = consolidateText(tagElement);
7457
+ tagElement.classes = ["tml-tag"];
7458
+ }
7459
+ if (tagElement) {
7460
+ row.unshift(glue(group));
7461
+ row.push(glue(group));
7462
+ if (group.leqno) {
7463
+ row[0].children.push(tagElement);
7464
+ row[0].classes.push("tml-left");
7465
+ } else {
7466
+ row[row.length - 1].children.push(tagElement);
7467
+ row[row.length - 1].classes.push("tml-right");
7468
+ }
7351
7469
  }
7352
7470
  }
7353
7471
  const mtr = new mathMLTree.MathNode("mtr", row, []);
7472
+ const label = group.labels.shift();
7473
+ if (label && group.tags && group.tags[i]) {
7474
+ mtr.setAttribute("id", label);
7475
+ if (Array.isArray(group.tags[i])) { mtr.classes.push("tml-tageqn"); }
7476
+ }
7477
+
7354
7478
  // Write horizontal rules
7355
7479
  if (i === 0 && hlines[0].length > 0) {
7356
7480
  if (hlines[0].length === 2) {
@@ -7374,16 +7498,17 @@ const mathmlBuilder$7 = function(group, style) {
7374
7498
  }
7375
7499
 
7376
7500
  if (group.envClasses.length > 0) {
7377
- let pad = group.envClasses.includes("jot")
7378
- ? "0.7" // 0.5ex + 0.09em top & bot padding
7379
- : group.envClasses.includes("small")
7380
- ? "0.35"
7381
- : "0.5"; // 0.5ex default top & bot padding
7382
7501
  if (group.arraystretch && group.arraystretch !== 1) {
7383
7502
  // In LaTeX, \arraystretch is a factor applied to a 12pt strut height.
7384
7503
  // It defines a baseline to baseline distance.
7385
7504
  // Here, we do an approximation of that approach.
7386
- pad = String(1.4 * group.arraystretch - 0.8);
7505
+ const pad = String(1.4 * group.arraystretch - 0.8) + "ex";
7506
+ for (let i = 0; i < tbl.length; i++) {
7507
+ for (let j = 0; j < tbl[i].children.length; j++) {
7508
+ tbl[i].children[j].style.paddingTop = pad;
7509
+ tbl[i].children[j].style.paddingBottom = pad;
7510
+ }
7511
+ }
7387
7512
  }
7388
7513
  let sidePadding = group.envClasses.includes("abut")
7389
7514
  ? "0"
@@ -7397,7 +7522,7 @@ const mathmlBuilder$7 = function(group, style) {
7397
7522
  let sidePadUnit = "em";
7398
7523
  if (group.arraycolsep) {
7399
7524
  const arraySidePad = calculateSize(group.arraycolsep, style);
7400
- sidePadding = arraySidePad.number;
7525
+ sidePadding = arraySidePad.number.toFixed(4);
7401
7526
  sidePadUnit = arraySidePad.unit;
7402
7527
  }
7403
7528
 
@@ -7408,18 +7533,18 @@ const mathmlBuilder$7 = function(group, style) {
7408
7533
  if (j === numCols - 1 && hand === 1) { return "0" }
7409
7534
  if (group.envClasses[0] !== "align") { return sidePadding }
7410
7535
  if (hand === 1) { return "0" }
7411
- if (group.addEqnNum) {
7536
+ if (group.autoTag) {
7412
7537
  return (j % 2) ? "1" : "0"
7413
7538
  } else {
7414
7539
  return (j % 2) ? "0" : "1"
7415
7540
  }
7416
7541
  };
7417
7542
 
7418
- // Padding
7543
+ // Side padding
7419
7544
  for (let i = 0; i < tbl.length; i++) {
7420
7545
  for (let j = 0; j < tbl[i].children.length; j++) {
7421
- tbl[i].children[j].style.padding = `${pad}ex ${sidePad(j, 1)}${sidePadUnit}`
7422
- + ` ${pad}ex ${sidePad(j, 0)}${sidePadUnit}`;
7546
+ tbl[i].children[j].style.paddingLeft = `${sidePad(j, 0)}${sidePadUnit}`;
7547
+ tbl[i].children[j].style.paddingRight = `${sidePad(j, 1)}${sidePadUnit}`;
7423
7548
  }
7424
7549
  }
7425
7550
 
@@ -7433,13 +7558,13 @@ const mathmlBuilder$7 = function(group, style) {
7433
7558
  // TODO: Remove -webkit- when Chromium no longer needs it.
7434
7559
  row.children[j].classes = ["tml-" + (j % 2 ? "left" : "right")];
7435
7560
  }
7436
- if (group.addEqnNum) {
7561
+ if (group.autoTag) {
7437
7562
  const k = group.leqno ? 0 : row.children.length - 1;
7438
7563
  row.children[k].classes = ["tml-" + (group.leqno ? "left" : "right")];
7439
7564
  }
7440
7565
  }
7441
7566
  if (row.children.length > 1 && group.envClasses.includes("cases")) {
7442
- row.children[1].style.padding = row.children[1].style.padding.replace(/0em$/, "1em");
7567
+ row.children[1].style.paddingLeft = "1em";
7443
7568
  }
7444
7569
 
7445
7570
  if (group.envClasses.includes("cases") || group.envClasses.includes("subarray")) {
@@ -7459,9 +7584,17 @@ const mathmlBuilder$7 = function(group, style) {
7459
7584
  }
7460
7585
 
7461
7586
  let table = new mathMLTree.MathNode("mtable", tbl);
7587
+ if (group.envClasses.length > 0) {
7588
+ // Top & bottom padding
7589
+ if (group.envClasses.includes("jot")) {
7590
+ table.classes.push("tml-jot");
7591
+ } else if (group.envClasses.includes("small")) {
7592
+ table.classes.push("tml-small");
7593
+ }
7594
+ }
7462
7595
  if (group.scriptLevel === "display") { table.setAttribute("displaystyle", "true"); }
7463
7596
 
7464
- if (group.addEqnNum || group.envClasses.includes("multline")) {
7597
+ if (group.autoTag || group.envClasses.includes("multline")) {
7465
7598
  table.style.width = "100%";
7466
7599
  }
7467
7600
 
@@ -7491,7 +7624,7 @@ const mathmlBuilder$7 = function(group, style) {
7491
7624
  row.children[0].style.borderLeft = sep;
7492
7625
  }
7493
7626
  }
7494
- let iCol = group.addEqnNum ? 0 : -1;
7627
+ let iCol = group.autoTag ? 0 : -1;
7495
7628
  for (let i = iStart; i < iEnd; i++) {
7496
7629
  if (cols[i].type === "align") {
7497
7630
  const colAlign = alignMap[cols[i].align];
@@ -7533,7 +7666,7 @@ const mathmlBuilder$7 = function(group, style) {
7533
7666
  }
7534
7667
  }
7535
7668
  }
7536
- if (group.addEqnNum) {
7669
+ if (group.autoTag) {
7537
7670
  // allow for glue cells on each side
7538
7671
  align = "left " + (align.length > 0 ? align : "center ") + "right ";
7539
7672
  }
@@ -7557,13 +7690,14 @@ const alignedHandler = function(context, args) {
7557
7690
  if (context.envName.indexOf("ed") === -1) {
7558
7691
  validateAmsEnvironmentContext(context);
7559
7692
  }
7693
+ const isSplit = context.envName === "split";
7560
7694
  const cols = [];
7561
7695
  const res = parseArray(
7562
7696
  context.parser,
7563
7697
  {
7564
7698
  cols,
7565
- addEqnNum: context.envName === "align" || context.envName === "alignat",
7566
7699
  emptySingleRow: true,
7700
+ autoTag: isSplit ? undefined : getAutoTag(context.envName),
7567
7701
  envClasses: ["abut", "jot"], // set row spacing & provisional column spacing
7568
7702
  maxNumCols: context.envName === "split" ? 2 : undefined,
7569
7703
  leqno: context.parser.settings.leqno
@@ -7885,7 +8019,7 @@ defineEnvironment({
7885
8019
  const res = {
7886
8020
  cols: [],
7887
8021
  envClasses: ["abut", "jot"],
7888
- addEqnNum: context.envName === "gather",
8022
+ autoTag: getAutoTag(context.envName),
7889
8023
  emptySingleRow: true,
7890
8024
  leqno: context.parser.settings.leqno
7891
8025
  };
@@ -7903,7 +8037,7 @@ defineEnvironment({
7903
8037
  handler(context) {
7904
8038
  validateAmsEnvironmentContext(context);
7905
8039
  const res = {
7906
- addEqnNum: context.envName === "equation",
8040
+ autoTag: getAutoTag(context.envName),
7907
8041
  emptySingleRow: true,
7908
8042
  singleRow: true,
7909
8043
  maxNumCols: 1,
@@ -7924,7 +8058,7 @@ defineEnvironment({
7924
8058
  handler(context) {
7925
8059
  validateAmsEnvironmentContext(context);
7926
8060
  const res = {
7927
- addEqnNum: context.envName === "multline",
8061
+ autoTag: context.envName === "multline",
7928
8062
  maxNumCols: 1,
7929
8063
  envClasses: ["jot", "multline"],
7930
8064
  leqno: context.parser.settings.leqno
@@ -8981,7 +9115,7 @@ defineFunction({
8981
9115
  // Return a no-width, no-ink element with an HTML id.
8982
9116
  const node = new mathMLTree.MathNode("mrow", [], ["tml-label"]);
8983
9117
  if (group.string.length > 0) {
8984
- node.setAttribute("id", group.string);
9118
+ node.setLabel(group.string);
8985
9119
  }
8986
9120
  return node
8987
9121
  }
@@ -11244,75 +11378,6 @@ const makeVerb = (group) => group.body.replace(/ /g, group.star ? "\u2423" : "\x
11244
11378
 
11245
11379
  const functions = _functions;
11246
11380
 
11247
- /**
11248
- * Lexing or parsing positional information for error reporting.
11249
- * This object is immutable.
11250
- */
11251
- class SourceLocation {
11252
- constructor(lexer, start, end) {
11253
- this.lexer = lexer; // Lexer holding the input string.
11254
- this.start = start; // Start offset, zero-based inclusive.
11255
- this.end = end; // End offset, zero-based exclusive.
11256
- }
11257
-
11258
- /**
11259
- * Merges two `SourceLocation`s from location providers, given they are
11260
- * provided in order of appearance.
11261
- * - Returns the first one's location if only the first is provided.
11262
- * - Returns a merged range of the first and the last if both are provided
11263
- * and their lexers match.
11264
- * - Otherwise, returns null.
11265
- */
11266
- static range(first, second) {
11267
- if (!second) {
11268
- return first && first.loc;
11269
- } else if (!first || !first.loc || !second.loc || first.loc.lexer !== second.loc.lexer) {
11270
- return null;
11271
- } else {
11272
- return new SourceLocation(first.loc.lexer, first.loc.start, second.loc.end);
11273
- }
11274
- }
11275
- }
11276
-
11277
- /**
11278
- * Interface required to break circular dependency between Token, Lexer, and
11279
- * ParseError.
11280
- */
11281
-
11282
- /**
11283
- * The resulting token returned from `lex`.
11284
- *
11285
- * It consists of the token text plus some position information.
11286
- * The position information is essentially a range in an input string,
11287
- * but instead of referencing the bare input string, we refer to the lexer.
11288
- * That way it is possible to attach extra metadata to the input string,
11289
- * like for example a file name or similar.
11290
- *
11291
- * The position information is optional, so it is OK to construct synthetic
11292
- * tokens if appropriate. Not providing available position information may
11293
- * lead to degraded error reporting, though.
11294
- */
11295
- class Token {
11296
- constructor(
11297
- text, // the text of this token
11298
- loc
11299
- ) {
11300
- this.text = text;
11301
- this.loc = loc;
11302
- }
11303
-
11304
- /**
11305
- * Given a pair of tokens (this and endToken), compute a `Token` encompassing
11306
- * the whole input range enclosed by these two.
11307
- */
11308
- range(
11309
- endToken, // last token of the range, inclusive
11310
- text // the text of the newly constructed token
11311
- ) {
11312
- return new Token(text, SourceLocation.range(this, endToken));
11313
- }
11314
- }
11315
-
11316
11381
  /**
11317
11382
  * The Lexer class handles tokenizing the input in various ways. Since our
11318
11383
  * parser expects us to be able to backtrack, the lexer allows lexing from any
@@ -13610,7 +13675,7 @@ class Style {
13610
13675
  * https://mit-license.org/
13611
13676
  */
13612
13677
 
13613
- const version = "0.10.33";
13678
+ const version = "0.10.34";
13614
13679
 
13615
13680
  function postProcess(block) {
13616
13681
  const labelMap = {};
@@ -13626,15 +13691,15 @@ function postProcess(block) {
13626
13691
  // No need to write a number into the text content of the element.
13627
13692
  // A CSS counter has done that even if this postProcess() function is not used.
13628
13693
 
13629
- // Find any \label that refers to an AMS eqn number.
13694
+ // Find any \label that refers to an AMS automatic eqn number.
13630
13695
  while (true) {
13696
+ if (parent.tagName === "mtable") { break }
13631
13697
  const labels = parent.getElementsByClassName("tml-label");
13632
13698
  if (labels.length > 0) {
13633
- parent.setAttribute("id", labels[0].id);
13634
- labelMap[labels[0].id] = String(i);
13699
+ const id = parent.attributes.id.value;
13700
+ labelMap[id] = String(i);
13635
13701
  break
13636
13702
  } else {
13637
- if (parent.tagName === "mtable") { break }
13638
13703
  parent = parent.parentElement;
13639
13704
  }
13640
13705
  }
@@ -13647,7 +13712,8 @@ function postProcess(block) {
13647
13712
  if (labels.length > 0) {
13648
13713
  const tags = parent.getElementsByClassName("tml-tag");
13649
13714
  if (tags.length > 0) {
13650
- labelMap[labels[0].id] = tags[0].textContent;
13715
+ const id = parent.attributes.id.value;
13716
+ labelMap[id] = tags[0].textContent;
13651
13717
  }
13652
13718
  }
13653
13719
  }