temml 0.10.2 → 0.10.3

Sign up to get free protection for your applications and to get access to all the features.
package/dist/temml.mjs CHANGED
@@ -188,7 +188,7 @@ class Settings {
188
188
  this.leqno = utils.deflt(options.leqno, false); // boolean
189
189
  this.errorColor = utils.deflt(options.errorColor, "#b22222"); // string
190
190
  this.macros = options.macros || {};
191
- this.wrap = utils.deflt(options.wrap, "none"); // "none" | "tex" | "="
191
+ this.wrap = utils.deflt(options.wrap, "tex"); // "tex" | "="
192
192
  this.xml = utils.deflt(options.xml, false); // boolean
193
193
  this.colorIsTextColor = utils.deflt(options.colorIsTextColor, false); // booelean
194
194
  this.strict = utils.deflt(options.strict, false); // boolean
@@ -1747,10 +1747,12 @@ for (let i = 0; i < 10; i++) {
1747
1747
  * Then the top level of a <math> element can be occupied by <mrow> elements, and the browser
1748
1748
  * will break after a <mrow> if the expression extends beyond the container limit.
1749
1749
  *
1750
- * We want the expression to render with soft line breaks after each top-level binary or
1750
+ * The default is for soft line breaks after each top-level binary or
1751
1751
  * relational operator, per TeXbook p. 173. So we gather the expression into <mrow>s so that
1752
1752
  * each <mrow> ends in a binary or relational operator.
1753
1753
  *
1754
+ * An option is for soft line breaks before an "=" sign. That changes the <mrow>s.
1755
+ *
1754
1756
  * Soft line breaks will not work in Chromium and Safari, only Firefox.
1755
1757
  *
1756
1758
  * Hopefully browsers will someday do their own linebreaking and we will be able to delete
@@ -2096,18 +2098,6 @@ function buildMathML(tree, texExpression, style, settings) {
2096
2098
  wrapper = new mathMLTree.MathNode("semantics", [wrapper, annotation]);
2097
2099
  }
2098
2100
 
2099
- if (wrap !== "none" && wrapper.children.length > 1) {
2100
- const maths = [];
2101
- for (let i = 0; i < wrapper.children.length; i++) {
2102
- const math = new mathMLTree.MathNode("math", [wrapper.children[i]]);
2103
- if (settings.xml) {
2104
- math.setAttribute("xmlns", "http://www.w3.org/1998/Math/MathML");
2105
- }
2106
- maths.push(math);
2107
- }
2108
- return mathMLTree.newDocumentFragment(maths)
2109
- }
2110
-
2111
2101
  const math = new mathMLTree.MathNode("math", [wrapper]);
2112
2102
 
2113
2103
  if (settings.xml) {
@@ -2115,6 +2105,9 @@ function buildMathML(tree, texExpression, style, settings) {
2115
2105
  }
2116
2106
  if (settings.displayMode) {
2117
2107
  math.setAttribute("display", "block");
2108
+ math.style.display = math.children.length === 1 && math.children[0].type === "mtable"
2109
+ ? "inline"
2110
+ : "inline-block";
2118
2111
  }
2119
2112
  return math;
2120
2113
  }
@@ -12975,7 +12968,7 @@ class Style {
12975
12968
  * https://mit-license.org/
12976
12969
  */
12977
12970
 
12978
- const version = "0.10.2";
12971
+ const version = "0.10.3";
12979
12972
 
12980
12973
  function postProcess(block) {
12981
12974
  const labelMap = {};
@@ -14,7 +14,7 @@
14
14
  * https://mit-license.org/
15
15
  */
16
16
 
17
- const version = "0.10.2";
17
+ const version = "0.10.3";
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.2",
3
+ "version": "0.10.3",
4
4
  "description": "TeX to MathML conversion in JavaScript.",
5
5
  "main": "dist/temml.js",
6
6
  "homepage": "https://temml.org",
package/src/Settings.js CHANGED
@@ -17,7 +17,7 @@ export default class Settings {
17
17
  this.leqno = utils.deflt(options.leqno, false); // boolean
18
18
  this.errorColor = utils.deflt(options.errorColor, "#b22222"); // string
19
19
  this.macros = options.macros || {};
20
- this.wrap = utils.deflt(options.wrap, "none") // "none" | "tex" | "="
20
+ this.wrap = utils.deflt(options.wrap, "tex") // "tex" | "="
21
21
  this.xml = utils.deflt(options.xml, false); // boolean
22
22
  this.colorIsTextColor = utils.deflt(options.colorIsTextColor, false); // booelean
23
23
  this.strict = utils.deflt(options.strict, false); // boolean
@@ -209,18 +209,6 @@ export default function buildMathML(tree, texExpression, style, settings) {
209
209
  wrapper = new mathMLTree.MathNode("semantics", [wrapper, annotation]);
210
210
  }
211
211
 
212
- if (wrap !== "none" && wrapper.children.length > 1) {
213
- const maths = []
214
- for (let i = 0; i < wrapper.children.length; i++) {
215
- const math = new mathMLTree.MathNode("math", [wrapper.children[i]])
216
- if (settings.xml) {
217
- math.setAttribute("xmlns", "http://www.w3.org/1998/Math/MathML")
218
- }
219
- maths.push(math)
220
- }
221
- return mathMLTree.newDocumentFragment(maths)
222
- }
223
-
224
212
  const math = new mathMLTree.MathNode("math", [wrapper])
225
213
 
226
214
  if (settings.xml) {
@@ -228,6 +216,9 @@ export default function buildMathML(tree, texExpression, style, settings) {
228
216
  }
229
217
  if (settings.displayMode) {
230
218
  math.setAttribute("display", "block");
219
+ math.style.display = math.children.length === 1 && math.children[0].type === "mtable"
220
+ ? "inline"
221
+ : "inline-block"
231
222
  }
232
223
  return math;
233
224
  }
@@ -13,10 +13,12 @@ import mathMLTree from "./mathMLTree"
13
13
  * Then the top level of a <math> element can be occupied by <mrow> elements, and the browser
14
14
  * will break after a <mrow> if the expression extends beyond the container limit.
15
15
  *
16
- * We want the expression to render with soft line breaks after each top-level binary or
16
+ * The default is for soft line breaks after each top-level binary or
17
17
  * relational operator, per TeXbook p. 173. So we gather the expression into <mrow>s so that
18
18
  * each <mrow> ends in a binary or relational operator.
19
19
  *
20
+ * An option is for soft line breaks before an "=" sign. That changes the <mrow>s.
21
+ *
20
22
  * Soft line breaks will not work in Chromium and Safari, only Firefox.
21
23
  *
22
24
  * Hopefully browsers will someday do their own linebreaking and we will be able to delete
@@ -8,7 +8,7 @@
8
8
  * https://mit-license.org/
9
9
  */
10
10
 
11
- export const version = "0.10.2";
11
+ export const version = "0.10.3";
12
12
 
13
13
  export function postProcess(block) {
14
14
  const labelMap = {}