Skip to content

Commit

Permalink
feat: Support mtable, mtd, mtr for draw matrix. (#1164)
Browse files Browse the repository at this point in the history
  • Loading branch information
fukatani authored Oct 20, 2022
1 parent db99a2b commit e99e2cc
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion packages/flutter_html_math/lib/flutter_html_math.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ CustomRenderMatcher mathMatcher() => (context) {
String _parseMathRecursive(dom.Node node, String parsed) {
if (node is dom.Element) {
List<dom.Element> nodeList = node.nodes.whereType<dom.Element>().toList();
if (node.localName == "math" || node.localName == "mrow") {
if (node.localName == "math" ||
node.localName == "mrow" ||
node.localName == "mtr") {
for (var element in nodeList) {
parsed = _parseMathRecursive(element, parsed);
}
Expand Down Expand Up @@ -98,6 +100,17 @@ String _parseMathRecursive(dom.Node node, String parsed) {
parsed = parsed + node.text.trim();
}
}
if (node.localName == 'mtable') {
String inner =
nodeList.map((e) => _parseMathRecursive(e, '')).join(' \\\\');
parsed = '$parsed\\begin{matrix}$inner\\end{matrix}';
}
if (node.localName == "mtd") {
for (var element in nodeList) {
parsed = _parseMathRecursive(element, parsed);
}
parsed = '$parsed & ';
}
}
return parsed;
}
Expand Down

0 comments on commit e99e2cc

Please sign in to comment.