@@ -860,8 +860,11 @@ String? _parseMath(dom.Element element, {required bool block}) {
860
860
/// instance has been reset to its starting state, and can be re-used for
861
861
/// parsing other subtrees.
862
862
class _ZulipInlineContentParser {
863
- String ? parseInlineMath (dom.Element element) {
864
- return _parseMath (element, block: false );
863
+ InlineContentNode ? parseInlineMath (dom.Element element) {
864
+ final debugHtmlNode = kDebugMode ? element : null ;
865
+ final texSource = _parseMath (element, block: false );
866
+ if (texSource == null ) return null ;
867
+ return MathInlineNode (texSource: texSource, debugHtmlNode: debugHtmlNode);
865
868
}
866
869
867
870
UserMentionNode ? parseUserMention (dom.Element element) {
@@ -1017,9 +1020,7 @@ class _ZulipInlineContentParser {
1017
1020
}
1018
1021
1019
1022
if (localName == 'span' && className == 'katex' ) {
1020
- final texSource = parseInlineMath (element);
1021
- if (texSource == null ) return unimplemented ();
1022
- return MathInlineNode (texSource: texSource, debugHtmlNode: debugHtmlNode);
1023
+ return parseInlineMath (element) ?? unimplemented ();
1023
1024
}
1024
1025
1025
1026
// TODO more types of node
@@ -1054,8 +1055,11 @@ class _ZulipContentParser {
1054
1055
return inlineParser.parseBlockInline (nodes);
1055
1056
}
1056
1057
1057
- String ? parseMathBlock (dom.Element element) {
1058
- return _parseMath (element, block: true );
1058
+ BlockContentNode parseMathBlock (dom.Element element) {
1059
+ final debugHtmlNode = kDebugMode ? element : null ;
1060
+ final texSource = _parseMath (element, block: true );
1061
+ if (texSource == null ) return UnimplementedBlockContentNode (htmlNode: element);
1062
+ return MathBlockNode (texSource: texSource, debugHtmlNode: debugHtmlNode);
1059
1063
}
1060
1064
1061
1065
BlockContentNode parseListNode (dom.Element element) {
@@ -1477,9 +1481,7 @@ class _ZulipContentParser {
1477
1481
// The case with the `<br>\n` can happen when at the end of a quote;
1478
1482
// it seems like a glitch in the server's Markdown processing,
1479
1483
// so hopefully there just aren't any further such glitches.
1480
- final texSource = parseMathBlock (child);
1481
- if (texSource == null ) return UnimplementedBlockContentNode (htmlNode: node);
1482
- return MathBlockNode (texSource: texSource, debugHtmlNode: debugHtmlNode);
1484
+ return parseMathBlock (child);
1483
1485
}
1484
1486
}
1485
1487
}
0 commit comments