Skip to content

Commit e99e2cc

Browse files
authored
feat: Support mtable, mtd, mtr for draw matrix. (Sub6Resources#1164)
1 parent db99a2b commit e99e2cc

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

packages/flutter_html_math/lib/flutter_html_math.dart

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@ CustomRenderMatcher mathMatcher() => (context) {
3939
String _parseMathRecursive(dom.Node node, String parsed) {
4040
if (node is dom.Element) {
4141
List<dom.Element> nodeList = node.nodes.whereType<dom.Element>().toList();
42-
if (node.localName == "math" || node.localName == "mrow") {
42+
if (node.localName == "math" ||
43+
node.localName == "mrow" ||
44+
node.localName == "mtr") {
4345
for (var element in nodeList) {
4446
parsed = _parseMathRecursive(element, parsed);
4547
}
@@ -98,6 +100,17 @@ String _parseMathRecursive(dom.Node node, String parsed) {
98100
parsed = parsed + node.text.trim();
99101
}
100102
}
103+
if (node.localName == 'mtable') {
104+
String inner =
105+
nodeList.map((e) => _parseMathRecursive(e, '')).join(' \\\\');
106+
parsed = '$parsed\\begin{matrix}$inner\\end{matrix}';
107+
}
108+
if (node.localName == "mtd") {
109+
for (var element in nodeList) {
110+
parsed = _parseMathRecursive(element, parsed);
111+
}
112+
parsed = '$parsed & ';
113+
}
101114
}
102115
return parsed;
103116
}

0 commit comments

Comments
 (0)