temml 0.10.4 → 0.10.6
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.cjs +73 -92
- package/dist/temml.js +73 -92
- package/dist/temml.min.js +1 -1
- package/dist/temml.mjs +73 -92
- package/dist/temmlPostProcess.js +1 -1
- package/package.json +1 -1
- package/src/buildMathML.js +4 -2
- package/src/functions/color.js +11 -7
- package/src/functions/delimsizing.js +1 -1
- package/src/functions/font.js +0 -1
- package/src/linebreaking.js +60 -82
- package/src/postProcess.js +1 -1
package/dist/temml.mjs
CHANGED
@@ -1759,125 +1759,102 @@ for (let i = 0; i < 10; i++) {
|
|
1759
1759
|
* much of this module.
|
1760
1760
|
*/
|
1761
1761
|
|
1762
|
-
function setLineBreaks(expression, wrapMode, isDisplayMode
|
1763
|
-
if (color === undefined && wrapMode !== "none") {
|
1764
|
-
// First, make one pass through the expression and split any color nodes.
|
1765
|
-
const upperLimit = expression.length - 1;
|
1766
|
-
for (let i = upperLimit; i >= 0; i--) {
|
1767
|
-
const node = expression[i];
|
1768
|
-
if (node.type === "mstyle" && node.attributes.mathcolor) {
|
1769
|
-
const color = node.attributes.mathcolor;
|
1770
|
-
const fragment = setLineBreaks(node.children, wrapMode, isDisplayMode, color);
|
1771
|
-
if (!(fragment.type && fragment.type !== "mtable")) {
|
1772
|
-
expression.splice(i, 1, ...fragment.children);
|
1773
|
-
}
|
1774
|
-
}
|
1775
|
-
}
|
1776
|
-
}
|
1777
|
-
|
1778
|
-
const tagName = color ? "mstyle" : "mrow";
|
1779
|
-
|
1762
|
+
function setLineBreaks(expression, wrapMode, isDisplayMode) {
|
1780
1763
|
const mtrs = [];
|
1781
1764
|
let mrows = [];
|
1782
1765
|
let block = [];
|
1783
1766
|
let numTopLevelEquals = 0;
|
1784
1767
|
let canBeBIN = false; // The first node cannot be an infix binary operator.
|
1785
|
-
|
1786
|
-
|
1787
|
-
|
1788
|
-
|
1789
|
-
// Start a new block. (Insert a soft linebreak.)
|
1790
|
-
mrows.push(new mathMLTree.MathNode(tagName, block));
|
1791
|
-
}
|
1792
|
-
// Insert the mstyle
|
1793
|
-
mrows.push(node);
|
1794
|
-
block = [];
|
1795
|
-
continue
|
1768
|
+
let i = 0;
|
1769
|
+
while (i < expression.length) {
|
1770
|
+
while (expression[i] instanceof DocumentFragment) {
|
1771
|
+
expression.splice(i, 1, ...expression[i].children); // Expand the fragment.
|
1796
1772
|
}
|
1773
|
+
const node = expression[i];
|
1797
1774
|
if (node.attributes && node.attributes.linebreak &&
|
1798
1775
|
node.attributes.linebreak === "newline") {
|
1799
1776
|
// A hard line break. Create a <mtr> for the current block.
|
1800
1777
|
if (block.length > 0) {
|
1801
|
-
|
1802
|
-
if (color) { element.setAttribute("mathcolor", color); }
|
1803
|
-
mrows.push(new mathMLTree.MathNode(tagName, block));
|
1778
|
+
mrows.push(new mathMLTree.MathNode("mrow", block));
|
1804
1779
|
}
|
1805
1780
|
mrows.push(node);
|
1806
1781
|
block = [];
|
1807
1782
|
const mtd = new mathMLTree.MathNode("mtd", mrows);
|
1783
|
+
mtd.style.textAlign = "left";
|
1808
1784
|
mtrs.push(new mathMLTree.MathNode("mtr", [mtd]));
|
1809
1785
|
mrows = [];
|
1786
|
+
i += 1;
|
1810
1787
|
continue
|
1811
1788
|
}
|
1812
1789
|
block.push(node);
|
1813
|
-
if (node.type && node.type === "mo" &&
|
1814
|
-
if (
|
1790
|
+
if (node.type && node.type === "mo" && node.children.length === 1) {
|
1791
|
+
if (wrapMode === "=" && node.children[0].text === "=") {
|
1815
1792
|
numTopLevelEquals += 1;
|
1816
1793
|
if (numTopLevelEquals > 1) {
|
1817
1794
|
block.pop();
|
1818
1795
|
// Start a new block. (Insert a soft linebreak.)
|
1819
|
-
const element = new mathMLTree.MathNode(
|
1820
|
-
if (color) { element.setAttribute("mathcolor", color); }
|
1796
|
+
const element = new mathMLTree.MathNode("mrow", block);
|
1821
1797
|
mrows.push(element);
|
1822
1798
|
block = [node];
|
1823
1799
|
}
|
1824
|
-
}
|
1825
|
-
|
1826
|
-
|
1827
|
-
|
1828
|
-
|
1829
|
-
|
1830
|
-
|
1831
|
-
|
1832
|
-
|
1833
|
-
|
1834
|
-
|
1835
|
-
|
1836
|
-
|
1837
|
-
)
|
1838
|
-
|
1839
|
-
|
1840
|
-
|
1841
|
-
|
1842
|
-
const nd = expression[j];
|
1843
|
-
if (
|
1844
|
-
nd.type &&
|
1845
|
-
nd.type === "mspace" &&
|
1846
|
-
!(nd.attributes.linebreak && nd.attributes.linebreak === "newline")
|
1847
|
-
) {
|
1848
|
-
block.push(nd);
|
1849
|
-
i += 1;
|
1800
|
+
} else if (wrapMode === "tex") {
|
1801
|
+
// This may be a place for a soft line break.
|
1802
|
+
if (canBeBIN && !node.attributes.form) {
|
1803
|
+
// Check if the following node is a \nobreak text node, e.g. "~""
|
1804
|
+
const next = i < expression.length - 1 ? expression[i + 1] : null;
|
1805
|
+
let glueIsFreeOfNobreak = true;
|
1806
|
+
if (
|
1807
|
+
!(
|
1808
|
+
next &&
|
1809
|
+
next.type === "mtext" &&
|
1810
|
+
next.attributes.linebreak &&
|
1811
|
+
next.attributes.linebreak === "nobreak"
|
1812
|
+
)
|
1813
|
+
) {
|
1814
|
+
// We may need to start a new block.
|
1815
|
+
// First, put any post-operator glue on same line as operator.
|
1816
|
+
for (let j = i + 1; j < expression.length; j++) {
|
1817
|
+
const nd = expression[j];
|
1850
1818
|
if (
|
1851
|
-
nd.
|
1852
|
-
nd.
|
1853
|
-
nd.attributes.linebreak === "
|
1819
|
+
nd.type &&
|
1820
|
+
nd.type === "mspace" &&
|
1821
|
+
!(nd.attributes.linebreak && nd.attributes.linebreak === "newline")
|
1854
1822
|
) {
|
1855
|
-
|
1823
|
+
block.push(nd);
|
1824
|
+
i += 1;
|
1825
|
+
if (
|
1826
|
+
nd.attributes &&
|
1827
|
+
nd.attributes.linebreak &&
|
1828
|
+
nd.attributes.linebreak === "nobreak"
|
1829
|
+
) {
|
1830
|
+
glueIsFreeOfNobreak = false;
|
1831
|
+
}
|
1832
|
+
} else {
|
1833
|
+
break;
|
1856
1834
|
}
|
1857
|
-
} else {
|
1858
|
-
break;
|
1859
1835
|
}
|
1860
1836
|
}
|
1837
|
+
if (glueIsFreeOfNobreak) {
|
1838
|
+
// Start a new block. (Insert a soft linebreak.)
|
1839
|
+
const element = new mathMLTree.MathNode("mrow", block);
|
1840
|
+
mrows.push(element);
|
1841
|
+
block = [];
|
1842
|
+
}
|
1843
|
+
canBeBIN = false;
|
1861
1844
|
}
|
1862
|
-
|
1863
|
-
|
1864
|
-
|
1865
|
-
|
1866
|
-
|
1867
|
-
block = [];
|
1868
|
-
}
|
1869
|
-
canBeBIN = false;
|
1845
|
+
const isOpenDelimiter = node.attributes.form && node.attributes.form === "prefix";
|
1846
|
+
// Any operator that follows an open delimiter is unary.
|
1847
|
+
canBeBIN = !(node.attributes.separator || isOpenDelimiter);
|
1848
|
+
} else {
|
1849
|
+
canBeBIN = true;
|
1870
1850
|
}
|
1871
|
-
const isOpenDelimiter = node.attributes.form && node.attributes.form === "prefix";
|
1872
|
-
// Any operator that follows an open delimiter is unary.
|
1873
|
-
canBeBIN = !(node.attributes.separator || isOpenDelimiter);
|
1874
1851
|
} else {
|
1875
1852
|
canBeBIN = true;
|
1876
1853
|
}
|
1854
|
+
i += 1;
|
1877
1855
|
}
|
1878
1856
|
if (block.length > 0) {
|
1879
|
-
const element = new mathMLTree.MathNode(
|
1880
|
-
if (color) { element.setAttribute("mathcolor", color); }
|
1857
|
+
const element = new mathMLTree.MathNode("mrow", block);
|
1881
1858
|
mrows.push(element);
|
1882
1859
|
}
|
1883
1860
|
if (mtrs.length > 0) {
|
@@ -2012,7 +1989,9 @@ const consolidateNumbers = expression => {
|
|
2012
1989
|
*/
|
2013
1990
|
const makeRow = function(body) {
|
2014
1991
|
if (body.length === 1) {
|
2015
|
-
return body[0]
|
1992
|
+
return body[0] instanceof DocumentFragment
|
1993
|
+
? body[0]
|
1994
|
+
: new mathMLTree.MathNode("mrow", body);
|
2016
1995
|
} else {
|
2017
1996
|
return new mathMLTree.MathNode("mrow", body);
|
2018
1997
|
}
|
@@ -2126,7 +2105,6 @@ function buildMathML(tree, texExpression, style, settings) {
|
|
2126
2105
|
|
2127
2106
|
const n1 = expression.length === 0 ? null : expression[0];
|
2128
2107
|
let wrapper = expression.length === 1 && tag === null && (n1 instanceof MathNode)
|
2129
|
-
&& !(n1.type === "mstyle" && n1.attributes.mathcolor)
|
2130
2108
|
? expression[0]
|
2131
2109
|
: setLineBreaks(expression, wrap, settings.displayMode);
|
2132
2110
|
|
@@ -3053,7 +3031,7 @@ const colorFromSpec = (model, spec) => {
|
|
3053
3031
|
spec.split(",").map(e => {
|
3054
3032
|
const num = Number(e.trim());
|
3055
3033
|
if (num > 1) { throw new ParseError("Color rgb input must be < 1.") }
|
3056
|
-
color += toHex((num * 255));
|
3034
|
+
color += toHex(Number((num * 255).toFixed(0)));
|
3057
3035
|
});
|
3058
3036
|
}
|
3059
3037
|
if (color.charAt(0) !== "#") { color = "#" + color; }
|
@@ -3080,11 +3058,15 @@ const validateColor = (color, macros, token) => {
|
|
3080
3058
|
};
|
3081
3059
|
|
3082
3060
|
const mathmlBuilder$9 = (group, style) => {
|
3083
|
-
|
3084
|
-
//
|
3085
|
-
|
3086
|
-
|
3087
|
-
|
3061
|
+
// In LaTeX, color is not supposed to change the spacing of any node.
|
3062
|
+
// So instead of wrapping the group in an <mstyle>, we apply
|
3063
|
+
// the color individually to each node and return a document fragment.
|
3064
|
+
let expr = buildExpression(group.body, style.withColor(group.color));
|
3065
|
+
expr = expr.map(e => {
|
3066
|
+
e.style.color = group.color;
|
3067
|
+
return e
|
3068
|
+
});
|
3069
|
+
return mathMLTree.newDocumentFragment(expr)
|
3088
3070
|
};
|
3089
3071
|
|
3090
3072
|
defineFunction({
|
@@ -3736,7 +3718,7 @@ defineFunction({
|
|
3736
3718
|
if (group.right === "\u2216" || group.right.indexOf("arrow") > -1) {
|
3737
3719
|
rightNode.setAttribute("stretchy", "true");
|
3738
3720
|
}
|
3739
|
-
if (group.rightColor) { rightNode.
|
3721
|
+
if (group.rightColor) { rightNode.style.color = group.rightColor; }
|
3740
3722
|
inner.push(rightNode);
|
3741
3723
|
|
3742
3724
|
return makeRow(inner);
|
@@ -4920,7 +4902,6 @@ const mathmlBuilder$6 = (group, style) => {
|
|
4920
4902
|
for (let i = 1; i < mathGroup.children.length; i++) {
|
4921
4903
|
mi.children.push(mathGroup.children[i].children[0]);
|
4922
4904
|
}
|
4923
|
-
if (mathGroup.attributes.mathcolor) { mi.attributes.mathcolor = mathGroup.attributes.mathcolor; }
|
4924
4905
|
if (mi.attributes.mathvariant && mi.attributes.mathvariant === "normal") {
|
4925
4906
|
// Workaround for a Firefox bug that renders spurious space around
|
4926
4907
|
// a <mi mathvariant="normal">
|
@@ -12995,7 +12976,7 @@ class Style {
|
|
12995
12976
|
* https://mit-license.org/
|
12996
12977
|
*/
|
12997
12978
|
|
12998
|
-
const version = "0.10.
|
12979
|
+
const version = "0.10.6";
|
12999
12980
|
|
13000
12981
|
function postProcess(block) {
|
13001
12982
|
const labelMap = {};
|
package/dist/temmlPostProcess.js
CHANGED
package/package.json
CHANGED
package/src/buildMathML.js
CHANGED
@@ -9,6 +9,7 @@ import ParseError from "./ParseError"
|
|
9
9
|
import symbols, { ligatures } from "./symbols"
|
10
10
|
import { _mathmlGroupBuilders as groupBuilders } from "./defineFunction"
|
11
11
|
import { MathNode } from "./mathMLTree"
|
12
|
+
import { DocumentFragment } from "./tree"
|
12
13
|
import setLineBreaks from "./linebreaking"
|
13
14
|
|
14
15
|
/**
|
@@ -123,7 +124,9 @@ const consolidateNumbers = expression => {
|
|
123
124
|
*/
|
124
125
|
export const makeRow = function(body) {
|
125
126
|
if (body.length === 1) {
|
126
|
-
return body[0]
|
127
|
+
return body[0] instanceof DocumentFragment
|
128
|
+
? body[0]
|
129
|
+
: new mathMLTree.MathNode("mrow", body);
|
127
130
|
} else {
|
128
131
|
return new mathMLTree.MathNode("mrow", body);
|
129
132
|
}
|
@@ -237,7 +240,6 @@ export default function buildMathML(tree, texExpression, style, settings) {
|
|
237
240
|
|
238
241
|
const n1 = expression.length === 0 ? null : expression[0]
|
239
242
|
let wrapper = expression.length === 1 && tag === null && (n1 instanceof MathNode)
|
240
|
-
&& !(n1.type === "mstyle" && n1.attributes.mathcolor)
|
241
243
|
? expression[0]
|
242
244
|
: setLineBreaks(expression, wrap, settings.displayMode)
|
243
245
|
|
package/src/functions/color.js
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
import defineFunction, { ordargument } from "../defineFunction"
|
2
|
-
import
|
2
|
+
import mathMLTree from "../mathMLTree"
|
3
3
|
import { assertNodeType } from "../parseNode"
|
4
4
|
import ParseError from "../ParseError"
|
5
5
|
import * as mml from "../buildMathML"
|
@@ -125,7 +125,7 @@ export const colorFromSpec = (model, spec) => {
|
|
125
125
|
spec.split(",").map(e => {
|
126
126
|
const num = Number(e.trim())
|
127
127
|
if (num > 1) { throw new ParseError("Color rgb input must be < 1.") }
|
128
|
-
color += toHex((num * 255))
|
128
|
+
color += toHex(Number((num * 255).toFixed(0)))
|
129
129
|
})
|
130
130
|
}
|
131
131
|
if (color.charAt(0) !== "#") { color = "#" + color }
|
@@ -152,11 +152,15 @@ export const validateColor = (color, macros, token) => {
|
|
152
152
|
}
|
153
153
|
|
154
154
|
const mathmlBuilder = (group, style) => {
|
155
|
-
|
156
|
-
//
|
157
|
-
|
158
|
-
|
159
|
-
|
155
|
+
// In LaTeX, color is not supposed to change the spacing of any node.
|
156
|
+
// So instead of wrapping the group in an <mstyle>, we apply
|
157
|
+
// the color individually to each node and return a document fragment.
|
158
|
+
let expr = mml.buildExpression(group.body, style.withColor(group.color))
|
159
|
+
expr = expr.map(e => {
|
160
|
+
e.style.color = group.color
|
161
|
+
return e
|
162
|
+
})
|
163
|
+
return mathMLTree.newDocumentFragment(expr)
|
160
164
|
}
|
161
165
|
|
162
166
|
defineFunction({
|
@@ -264,7 +264,7 @@ defineFunction({
|
|
264
264
|
if (group.right === "\u2216" || group.right.indexOf("arrow") > -1) {
|
265
265
|
rightNode.setAttribute("stretchy", "true")
|
266
266
|
}
|
267
|
-
if (group.rightColor) { rightNode.
|
267
|
+
if (group.rightColor) { rightNode.style.color = group.rightColor }
|
268
268
|
inner.push(rightNode)
|
269
269
|
|
270
270
|
return mml.makeRow(inner);
|
package/src/functions/font.js
CHANGED
@@ -29,7 +29,6 @@ const mathmlBuilder = (group, style) => {
|
|
29
29
|
for (let i = 1; i < mathGroup.children.length; i++) {
|
30
30
|
mi.children.push(mathGroup.children[i].children[0])
|
31
31
|
}
|
32
|
-
if (mathGroup.attributes.mathcolor) { mi.attributes.mathcolor = mathGroup.attributes.mathcolor }
|
33
32
|
if (mi.attributes.mathvariant && mi.attributes.mathvariant === "normal") {
|
34
33
|
// Workaround for a Firefox bug that renders spurious space around
|
35
34
|
// a <mi mathvariant="normal">
|
package/src/linebreaking.js
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
import mathMLTree from "./mathMLTree"
|
2
|
+
import { DocumentFragment } from "./tree"
|
2
3
|
|
3
4
|
/*
|
4
5
|
* Neither Firefox nor Chrome support hard line breaks or soft line breaks.
|
@@ -25,125 +26,102 @@ import mathMLTree from "./mathMLTree"
|
|
25
26
|
* much of this module.
|
26
27
|
*/
|
27
28
|
|
28
|
-
export default function setLineBreaks(expression, wrapMode, isDisplayMode
|
29
|
-
if (color === undefined && wrapMode !== "none") {
|
30
|
-
// First, make one pass through the expression and split any color nodes.
|
31
|
-
const upperLimit = expression.length - 1
|
32
|
-
for (let i = upperLimit; i >= 0; i--) {
|
33
|
-
const node = expression[i];
|
34
|
-
if (node.type === "mstyle" && node.attributes.mathcolor) {
|
35
|
-
const color = node.attributes.mathcolor
|
36
|
-
const fragment = setLineBreaks(node.children, wrapMode, isDisplayMode, color)
|
37
|
-
if (!(fragment.type && fragment.type !== "mtable")) {
|
38
|
-
expression.splice(i, 1, ...fragment.children)
|
39
|
-
}
|
40
|
-
}
|
41
|
-
}
|
42
|
-
}
|
43
|
-
|
44
|
-
const tagName = color ? "mstyle" : "mrow"
|
45
|
-
|
29
|
+
export default function setLineBreaks(expression, wrapMode, isDisplayMode) {
|
46
30
|
const mtrs = [];
|
47
31
|
let mrows = [];
|
48
32
|
let block = [];
|
49
33
|
let numTopLevelEquals = 0
|
50
34
|
let canBeBIN = false // The first node cannot be an infix binary operator.
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
// Start a new block. (Insert a soft linebreak.)
|
56
|
-
mrows.push(new mathMLTree.MathNode(tagName, block))
|
57
|
-
}
|
58
|
-
// Insert the mstyle
|
59
|
-
mrows.push(node)
|
60
|
-
block = [];
|
61
|
-
continue
|
35
|
+
let i = 0
|
36
|
+
while (i < expression.length) {
|
37
|
+
while (expression[i] instanceof DocumentFragment) {
|
38
|
+
expression.splice(i, 1, ...expression[i].children) // Expand the fragment.
|
62
39
|
}
|
40
|
+
const node = expression[i];
|
63
41
|
if (node.attributes && node.attributes.linebreak &&
|
64
42
|
node.attributes.linebreak === "newline") {
|
65
43
|
// A hard line break. Create a <mtr> for the current block.
|
66
44
|
if (block.length > 0) {
|
67
|
-
|
68
|
-
if (color) { element.setAttribute("mathcolor", color) }
|
69
|
-
mrows.push(new mathMLTree.MathNode(tagName, block))
|
45
|
+
mrows.push(new mathMLTree.MathNode("mrow", block))
|
70
46
|
}
|
71
47
|
mrows.push(node)
|
72
48
|
block = [];
|
73
49
|
const mtd = new mathMLTree.MathNode("mtd", mrows)
|
50
|
+
mtd.style.textAlign = "left"
|
74
51
|
mtrs.push(new mathMLTree.MathNode("mtr", [mtd]))
|
75
52
|
mrows = [];
|
53
|
+
i += 1
|
76
54
|
continue
|
77
55
|
}
|
78
56
|
block.push(node);
|
79
|
-
if (node.type && node.type === "mo" &&
|
80
|
-
if (
|
57
|
+
if (node.type && node.type === "mo" && node.children.length === 1) {
|
58
|
+
if (wrapMode === "=" && node.children[0].text === "=") {
|
81
59
|
numTopLevelEquals += 1
|
82
60
|
if (numTopLevelEquals > 1) {
|
83
61
|
block.pop()
|
84
62
|
// Start a new block. (Insert a soft linebreak.)
|
85
|
-
const element = new mathMLTree.MathNode(
|
86
|
-
if (color) { element.setAttribute("mathcolor", color) }
|
63
|
+
const element = new mathMLTree.MathNode("mrow", block)
|
87
64
|
mrows.push(element)
|
88
65
|
block = [node];
|
89
66
|
}
|
90
|
-
}
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
)
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
const nd = expression[j];
|
109
|
-
if (
|
110
|
-
nd.type &&
|
111
|
-
nd.type === "mspace" &&
|
112
|
-
!(nd.attributes.linebreak && nd.attributes.linebreak === "newline")
|
113
|
-
) {
|
114
|
-
block.push(nd);
|
115
|
-
i += 1;
|
67
|
+
} else if (wrapMode === "tex") {
|
68
|
+
// This may be a place for a soft line break.
|
69
|
+
if (canBeBIN && !node.attributes.form) {
|
70
|
+
// Check if the following node is a \nobreak text node, e.g. "~""
|
71
|
+
const next = i < expression.length - 1 ? expression[i + 1] : null;
|
72
|
+
let glueIsFreeOfNobreak = true;
|
73
|
+
if (
|
74
|
+
!(
|
75
|
+
next &&
|
76
|
+
next.type === "mtext" &&
|
77
|
+
next.attributes.linebreak &&
|
78
|
+
next.attributes.linebreak === "nobreak"
|
79
|
+
)
|
80
|
+
) {
|
81
|
+
// We may need to start a new block.
|
82
|
+
// First, put any post-operator glue on same line as operator.
|
83
|
+
for (let j = i + 1; j < expression.length; j++) {
|
84
|
+
const nd = expression[j];
|
116
85
|
if (
|
117
|
-
nd.
|
118
|
-
nd.
|
119
|
-
nd.attributes.linebreak === "
|
86
|
+
nd.type &&
|
87
|
+
nd.type === "mspace" &&
|
88
|
+
!(nd.attributes.linebreak && nd.attributes.linebreak === "newline")
|
120
89
|
) {
|
121
|
-
|
90
|
+
block.push(nd);
|
91
|
+
i += 1;
|
92
|
+
if (
|
93
|
+
nd.attributes &&
|
94
|
+
nd.attributes.linebreak &&
|
95
|
+
nd.attributes.linebreak === "nobreak"
|
96
|
+
) {
|
97
|
+
glueIsFreeOfNobreak = false;
|
98
|
+
}
|
99
|
+
} else {
|
100
|
+
break;
|
122
101
|
}
|
123
|
-
} else {
|
124
|
-
break;
|
125
102
|
}
|
126
103
|
}
|
104
|
+
if (glueIsFreeOfNobreak) {
|
105
|
+
// Start a new block. (Insert a soft linebreak.)
|
106
|
+
const element = new mathMLTree.MathNode("mrow", block)
|
107
|
+
mrows.push(element)
|
108
|
+
block = [];
|
109
|
+
}
|
110
|
+
canBeBIN = false
|
127
111
|
}
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
block = [];
|
134
|
-
}
|
135
|
-
canBeBIN = false;
|
112
|
+
const isOpenDelimiter = node.attributes.form && node.attributes.form === "prefix"
|
113
|
+
// Any operator that follows an open delimiter is unary.
|
114
|
+
canBeBIN = !(node.attributes.separator || isOpenDelimiter);
|
115
|
+
} else {
|
116
|
+
canBeBIN = true
|
136
117
|
}
|
137
|
-
const isOpenDelimiter = node.attributes.form && node.attributes.form === "prefix";
|
138
|
-
// Any operator that follows an open delimiter is unary.
|
139
|
-
canBeBIN = !(node.attributes.separator || isOpenDelimiter);
|
140
118
|
} else {
|
141
|
-
canBeBIN = true
|
119
|
+
canBeBIN = true
|
142
120
|
}
|
121
|
+
i += 1
|
143
122
|
}
|
144
123
|
if (block.length > 0) {
|
145
|
-
const element = new mathMLTree.MathNode(
|
146
|
-
if (color) { element.setAttribute("mathcolor", color) }
|
124
|
+
const element = new mathMLTree.MathNode("mrow", block)
|
147
125
|
mrows.push(element)
|
148
126
|
}
|
149
127
|
if (mtrs.length > 0) {
|