@@ -345,10 +345,12 @@ class CodeBlockSpanNode extends ContentNode {
345
345
class MathBlockNode extends BlockContentNode {
346
346
const MathBlockNode ({
347
347
super .debugHtmlNode,
348
+ this .debugHasError = false ,
348
349
required this .texSource,
349
350
required this .nodes,
350
351
});
351
352
353
+ final bool debugHasError;
352
354
final String texSource;
353
355
final List <KatexNode >? nodes;
354
356
@@ -366,11 +368,14 @@ class MathBlockNode extends BlockContentNode {
366
368
367
369
class KatexNode extends ContentNode {
368
370
const KatexNode ({
371
+ required this .styles,
369
372
required this .text,
370
373
required this .nodes,
371
374
super .debugHtmlNode,
372
375
}) : assert ((text != null ) ^ (nodes != null ));
373
376
377
+ final KatexSpanStyles styles;
378
+
374
379
/// The text or a single character this KaTeX span contains, generally
375
380
/// observed to be the leaf node in the KaTeX HTML tree.
376
381
/// It will be null if this span has child nodes.
@@ -383,6 +388,7 @@ class KatexNode extends ContentNode {
383
388
@override
384
389
void debugFillProperties (DiagnosticPropertiesBuilder properties) {
385
390
super .debugFillProperties (properties);
391
+ properties.add (KatexSpanStylesProperty ('styles' , styles));
386
392
properties.add (StringProperty ('text' , text));
387
393
}
388
394
@@ -856,10 +862,12 @@ class ImageEmojiNode extends EmojiNode {
856
862
class MathInlineNode extends InlineContentNode {
857
863
const MathInlineNode ({
858
864
super .debugHtmlNode,
865
+ this .debugHasError = false ,
859
866
required this .texSource,
860
867
required this .nodes,
861
868
});
862
869
870
+ final bool debugHasError;
863
871
final String texSource;
864
872
final List <KatexNode >? nodes;
865
873
@@ -898,7 +906,7 @@ class GlobalTimeNode extends InlineContentNode {
898
906
899
907
////////////////////////////////////////////////////////////////
900
908
901
- ({List <KatexNode >? spans, String texSource})? _parseMath (
909
+ ({List <KatexNode >? spans, bool debugHasError, String texSource})? _parseMath (
902
910
dom.Element element, {
903
911
required bool block,
904
912
}) {
@@ -949,13 +957,18 @@ class GlobalTimeNode extends InlineContentNode {
949
957
}
950
958
951
959
List <KatexNode >? spans;
960
+ final parser = KatexParser ();
952
961
try {
953
- spans = KatexParser () .parseKatexHTML (katexHtmlElement);
962
+ spans = parser .parseKatexHTML (katexHtmlElement);
954
963
} on KatexHtmlParseError catch (e, st) {
955
964
assert (debugLog ('$e \n $st ' ));
956
965
}
957
966
958
- return (spans: spans, texSource: texSource);
967
+ return (
968
+ spans: spans,
969
+ debugHasError: parser.debugHasError,
970
+ texSource: texSource,
971
+ );
959
972
} else {
960
973
return null ;
961
974
}
@@ -976,6 +989,7 @@ class _ZulipInlineContentParser {
976
989
return MathInlineNode (
977
990
texSource: parsed.texSource,
978
991
nodes: parsed.spans,
992
+ debugHasError: parsed.debugHasError,
979
993
debugHtmlNode: debugHtmlNode);
980
994
}
981
995
@@ -1683,6 +1697,7 @@ class _ZulipContentParser {
1683
1697
result.add (MathBlockNode (
1684
1698
texSource: parsed.texSource,
1685
1699
nodes: parsed.spans,
1700
+ debugHasError: parsed.debugHasError,
1686
1701
debugHtmlNode: kDebugMode ? firstChild : null ));
1687
1702
} else {
1688
1703
result.add (UnimplementedBlockContentNode (htmlNode: firstChild));
0 commit comments