@@ -825,9 +825,7 @@ class _ZulipContentParser {
825825 /// and should be read or updated only inside an assertion.
826826 _ParserContext _debugParserContext = _ParserContext .block;
827827
828- String ? parseMath (dom.Element element, {required bool block}) {
829- assert (block == (_debugParserContext == _ParserContext .block));
830-
828+ static String ? _parseMath (dom.Element element, {required bool block}) {
831829 final dom.Element katexElement;
832830 if (! block) {
833831 assert (element.localName == 'span' && element.className == 'katex' );
@@ -873,6 +871,11 @@ class _ZulipContentParser {
873871 return descendant4.text.trim ();
874872 }
875873
874+ String ? parseInlineMath (dom.Element element) {
875+ assert (_debugParserContext == _ParserContext .inline);
876+ return _parseMath (element, block: false );
877+ }
878+
876879 UserMentionNode ? parseUserMention (dom.Element element) {
877880 assert (_debugParserContext == _ParserContext .inline);
878881 assert (element.localName == 'span' );
@@ -1028,7 +1031,7 @@ class _ZulipContentParser {
10281031 }
10291032
10301033 if (localName == 'span' && className == 'katex' ) {
1031- final texSource = parseMath (element, block : false );
1034+ final texSource = parseInlineMath (element);
10321035 if (texSource == null ) return unimplemented ();
10331036 return MathInlineNode (texSource: texSource, debugHtmlNode: debugHtmlNode);
10341037 }
@@ -1058,6 +1061,11 @@ class _ZulipContentParser {
10581061 return (nodes: resultNodes, links: _takeLinkNodes ());
10591062 }
10601063
1064+ String ? parseMathBlock (dom.Element element) {
1065+ assert (_debugParserContext == _ParserContext .block);
1066+ return _parseMath (element, block: true );
1067+ }
1068+
10611069 BlockContentNode parseListNode (dom.Element element) {
10621070 assert (_debugParserContext == _ParserContext .block);
10631071 ListStyle ? listStyle;
@@ -1485,7 +1493,7 @@ class _ZulipContentParser {
14851493 // The case with the `<br>\n` can happen when at the end of a quote;
14861494 // it seems like a glitch in the server's Markdown processing,
14871495 // so hopefully there just aren't any further such glitches.
1488- final texSource = parseMath (child, block : true );
1496+ final texSource = parseMathBlock (child);
14891497 if (texSource == null ) return UnimplementedBlockContentNode (htmlNode: node);
14901498 return MathBlockNode (texSource: texSource, debugHtmlNode: debugHtmlNode);
14911499 }
0 commit comments