temml 0.11.4 → 0.11.5

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
@@ -2454,9 +2454,6 @@ function buildMathML(tree, texExpression, style, settings) {
2454
2454
  if (settings.xml) {
2455
2455
  math.setAttribute("xmlns", "http://www.w3.org/1998/Math/MathML");
2456
2456
  }
2457
- if (wrapper.style.width) {
2458
- math.style.width = "100%";
2459
- }
2460
2457
  if (settings.displayMode) {
2461
2458
  math.setAttribute("display", "block");
2462
2459
  math.style.display = "block math"; // necessary in Chromium.
@@ -10568,7 +10565,8 @@ defineFunction({
10568
10565
  names: ["\\relax"],
10569
10566
  props: {
10570
10567
  numArgs: 0,
10571
- allowedInText: true
10568
+ allowedInText: true,
10569
+ allowedInArgument: true
10572
10570
  },
10573
10571
  handler({ parser }) {
10574
10572
  return {
@@ -12984,6 +12982,7 @@ class Parser {
12984
12982
  if (!atom) {
12985
12983
  break;
12986
12984
  } else if (atom.type === "internal") {
12985
+ // Internal nodes do not appear in parse tree
12987
12986
  continue;
12988
12987
  }
12989
12988
  body.push(atom);
@@ -13058,7 +13057,11 @@ class Parser {
13058
13057
  const symbol = symbolToken.text;
13059
13058
  this.consume();
13060
13059
  this.consumeSpaces(); // ignore spaces before sup/subscript argument
13061
- const group = this.parseGroup(name);
13060
+ // Skip over allowed internal nodes such as \relax
13061
+ let group;
13062
+ do {
13063
+ group = this.parseGroup(name);
13064
+ } while (group.type && group.type === "internal")
13062
13065
 
13063
13066
  if (!group) {
13064
13067
  throw new ParseError("Expected group after '" + symbol + "'", symbolToken);
@@ -13102,9 +13105,15 @@ class Parser {
13102
13105
  // \left(x\right)^2 work correctly.
13103
13106
  const base = this.parseGroup("atom", breakOnTokenText);
13104
13107
 
13108
+ // Internal nodes (e.g. \relax) cannot support super/subscripts.
13109
+ // Instead we will pick up super/subscripts with blank base next round.
13110
+ if (base && base.type === "internal") {
13111
+ return base
13112
+ }
13113
+
13105
13114
  // In text mode, we don't have superscripts or subscripts
13106
13115
  if (this.mode === "text") {
13107
- return base;
13116
+ return base
13108
13117
  }
13109
13118
 
13110
13119
  // Note that base may be empty (i.e. null) at this point.
@@ -13961,7 +13970,7 @@ class Style {
13961
13970
  * https://mit-license.org/
13962
13971
  */
13963
13972
 
13964
- const version = "0.11.04";
13973
+ const version = "0.11.05";
13965
13974
 
13966
13975
  function postProcess(block) {
13967
13976
  const labelMap = {};
@@ -11,7 +11,7 @@
11
11
  * https://mit-license.org/
12
12
  */
13
13
 
14
- const version = "0.11.04";
14
+ const version = "0.11.05";
15
15
 
16
16
  function postProcess(block) {
17
17
  const labelMap = {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "temml",
3
- "version": "0.11.04",
3
+ "version": "0.11.05",
4
4
  "description": "TeX to MathML conversion in JavaScript.",
5
5
  "main": "dist/temml.js",
6
6
  "engines": {
package/src/Parser.js CHANGED
@@ -213,6 +213,7 @@ export default class Parser {
213
213
  if (!atom) {
214
214
  break;
215
215
  } else if (atom.type === "internal") {
216
+ // Internal nodes do not appear in parse tree
216
217
  continue;
217
218
  }
218
219
  body.push(atom);
@@ -287,7 +288,11 @@ export default class Parser {
287
288
  const symbol = symbolToken.text;
288
289
  this.consume();
289
290
  this.consumeSpaces(); // ignore spaces before sup/subscript argument
290
- const group = this.parseGroup(name);
291
+ // Skip over allowed internal nodes such as \relax
292
+ let group
293
+ do {
294
+ group = this.parseGroup(name);
295
+ } while (group.type && group.type === "internal")
291
296
 
292
297
  if (!group) {
293
298
  throw new ParseError("Expected group after '" + symbol + "'", symbolToken);
@@ -329,11 +334,17 @@ export default class Parser {
329
334
  parseAtom(breakOnTokenText) {
330
335
  // The body of an atom is an implicit group, so that things like
331
336
  // \left(x\right)^2 work correctly.
332
- const base = this.parseGroup("atom", breakOnTokenText);
337
+ const base = this.parseGroup("atom", breakOnTokenText)
338
+
339
+ // Internal nodes (e.g. \relax) cannot support super/subscripts.
340
+ // Instead we will pick up super/subscripts with blank base next round.
341
+ if (base && base.type === "internal") {
342
+ return base
343
+ }
333
344
 
334
345
  // In text mode, we don't have superscripts or subscripts
335
346
  if (this.mode === "text") {
336
- return base;
347
+ return base
337
348
  }
338
349
 
339
350
  // Note that base may be empty (i.e. null) at this point.
@@ -341,9 +341,6 @@ export default function buildMathML(tree, texExpression, style, settings) {
341
341
  if (settings.xml) {
342
342
  math.setAttribute("xmlns", "http://www.w3.org/1998/Math/MathML")
343
343
  }
344
- if (wrapper.style.width) {
345
- math.style.width = "100%"
346
- }
347
344
  if (settings.displayMode) {
348
345
  math.setAttribute("display", "block");
349
346
  math.style.display = "block math" // necessary in Chromium.
@@ -5,7 +5,8 @@ defineFunction({
5
5
  names: ["\\relax"],
6
6
  props: {
7
7
  numArgs: 0,
8
- allowedInText: true
8
+ allowedInText: true,
9
+ allowedInArgument: true
9
10
  },
10
11
  handler({ parser }) {
11
12
  return {
@@ -5,7 +5,7 @@
5
5
  * https://mit-license.org/
6
6
  */
7
7
 
8
- export const version = "0.11.04";
8
+ export const version = "0.11.05";
9
9
 
10
10
  export function postProcess(block) {
11
11
  const labelMap = {}