File tree 2 files changed +11
-2
lines changed
2 files changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -990,14 +990,14 @@ class _ZulipContentParser {
990
990
if (child is ! dom.Element ) return null ;
991
991
if (child.localName != 'pre' ) return null ;
992
992
993
- if (child.nodes.length > 2 ) return null ;
993
+ if (child.nodes.length > 2 || child.nodes.isEmpty ) return null ;
994
994
if (child.nodes.length == 2 ) {
995
995
final first = child.nodes[0 ];
996
996
if (first is ! dom.Element
997
997
|| first.localName != 'span'
998
998
|| first.nodes.isNotEmpty) return null ;
999
999
}
1000
- final grandchild = child.nodes[child.nodes.length - 1 ] ;
1000
+ final grandchild = child.nodes.last ;
1001
1001
if (grandchild is ! dom.Element ) return null ;
1002
1002
if (grandchild.localName != 'code' ) return null ;
1003
1003
Original file line number Diff line number Diff line change @@ -344,6 +344,14 @@ class ContentExample {
344
344
]),
345
345
]);
346
346
347
+ static final codeBlockWithEmptyBody = ContentExample (
348
+ 'code block, with an empty body' ,
349
+ '```' ,
350
+ '<div class="codehilite"><pre></pre></div>' , [
351
+ blockUnimplemented (
352
+ '<div class="codehilite"><pre></pre></div>' ),
353
+ ]);
354
+
347
355
static final codeBlockWithHighlightedLines = ContentExample (
348
356
'code block, with syntax highlighting and highlighted lines' ,
349
357
'```\n ::markdown hl_lines="2 4"\n # he\n ## llo\n ### world\n ```' ,
@@ -1149,6 +1157,7 @@ void main() {
1149
1157
testParseExample (ContentExample .codeBlockPlain);
1150
1158
testParseExample (ContentExample .codeBlockHighlightedShort);
1151
1159
testParseExample (ContentExample .codeBlockHighlightedMultiline);
1160
+ testParseExample (ContentExample .codeBlockWithEmptyBody);
1152
1161
testParseExample (ContentExample .codeBlockWithHighlightedLines);
1153
1162
testParseExample (ContentExample .codeBlockWithUnknownSpanType);
1154
1163
testParseExample (ContentExample .codeBlockFollowedByMultipleLineBreaks);
You can’t perform that action at this time.
0 commit comments