@@ -13,7 +13,7 @@ CustomRender mathRender({OnMathError? onMathError}) =>
13
13
String texStr = context.tree.element == null
14
14
? ''
15
15
: _parseMathRecursive (context.tree.element! , r'' );
16
- return Container (
16
+ return SizedBox (
17
17
width: context.parser.shrinkWrap
18
18
? null
19
19
: MediaQuery .of (context.buildContext).size.width,
@@ -40,9 +40,9 @@ String _parseMathRecursive(dom.Node node, String parsed) {
40
40
if (node is dom.Element ) {
41
41
List <dom.Element > nodeList = node.nodes.whereType< dom.Element > ().toList ();
42
42
if (node.localName == "math" || node.localName == "mrow" ) {
43
- nodeList. forEach (( element) {
43
+ for ( var element in nodeList ) {
44
44
parsed = _parseMathRecursive (element, parsed);
45
- });
45
+ }
46
46
}
47
47
// note: munder, mover, and munderover do not support placing braces and other
48
48
// markings above/below elements, instead they are treated as super/subscripts for now.
@@ -52,37 +52,35 @@ String _parseMathRecursive(dom.Node node, String parsed) {
52
52
node.localName == "mover" ) &&
53
53
nodeList.length == 2 ) {
54
54
parsed = _parseMathRecursive (nodeList[0 ], parsed);
55
- parsed = _parseMathRecursive (
55
+ parsed = "${ _parseMathRecursive (
56
56
nodeList [1 ],
57
- parsed +
58
- "${node .localName == "msup" || node .localName == "mover" ? "^" : "_" }{" ) +
59
- "}" ;
57
+ "$parsed ${node .localName == "msup" || node .localName == "mover" ? "^" : "_" }{" )}}" ;
60
58
}
61
59
if ((node.localName == "msubsup" || node.localName == "munderover" ) &&
62
60
nodeList.length == 3 ) {
63
61
parsed = _parseMathRecursive (nodeList[0 ], parsed);
64
- parsed = _parseMathRecursive (nodeList[1 ], parsed + " _{" ) + " }" ;
65
- parsed = _parseMathRecursive (nodeList[2 ], parsed + " ^{" ) + " }" ;
62
+ parsed = "${ _parseMathRecursive (nodeList [1 ], "${ parsed } _{" )} }" ;
63
+ parsed = "${ _parseMathRecursive (nodeList [2 ], "$ parsed ^{" )} }" ;
66
64
}
67
65
if (node.localName == "mfrac" && nodeList.length == 2 ) {
68
- parsed = _parseMathRecursive (nodeList[0 ], parsed + r"\frac{" ) + " }" ;
69
- parsed = _parseMathRecursive (nodeList[1 ], parsed + " {" ) + " }" ;
66
+ parsed = "${ _parseMathRecursive (nodeList [0 ], parsed + r"\frac{" )} }" ;
67
+ parsed = "${ _parseMathRecursive (nodeList [1 ], "$ parsed {" )} }" ;
70
68
}
71
69
// note: doesn't support answer & intermediate steps
72
70
if (node.localName == "mlongdiv" && nodeList.length == 4 ) {
73
71
parsed = _parseMathRecursive (nodeList[0 ], parsed);
74
- parsed = _parseMathRecursive (nodeList[2 ], parsed + r"\overline{)" ) + " }" ;
72
+ parsed = "${ _parseMathRecursive (nodeList [2 ], parsed + r"\overline{)" )} }" ;
75
73
}
76
74
if (node.localName == "msqrt" ) {
77
75
parsed = parsed + r"\sqrt{" ;
78
- nodeList. forEach (( element) {
76
+ for ( var element in nodeList ) {
79
77
parsed = _parseMathRecursive (element, parsed);
80
- });
81
- parsed = parsed + " }" ;
78
+ }
79
+ parsed = "$ parsed }" ;
82
80
}
83
81
if (node.localName == "mroot" && nodeList.length == 2 ) {
84
- parsed = _parseMathRecursive (nodeList[1 ], parsed + r"\sqrt[" ) + " ]" ;
85
- parsed = _parseMathRecursive (nodeList[0 ], parsed + " {" ) + " }" ;
82
+ parsed = "${ _parseMathRecursive (nodeList [1 ], parsed + r"\sqrt[" )} ]" ;
83
+ parsed = "${ _parseMathRecursive (nodeList [0 ], "$ parsed {" )} }" ;
86
84
}
87
85
if (node.localName == "mi" ||
88
86
node.localName == "mn" ||
0 commit comments