File tree Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -990,7 +990,7 @@ 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
Original file line number Diff line number Diff line change @@ -344,6 +344,17 @@ class ContentExample {
344
344
]),
345
345
]);
346
346
347
+ // Current servers no longer produce this, but it can be found in ancient
348
+ // messages. For example:
349
+ // https://chat.zulip.org/#narrow/stream/2-general/topic/Error.20in.20dev.20server/near/18765
350
+ static final codeBlockWithEmptyBody = ContentExample (
351
+ 'code block, with an empty body' ,
352
+ '```' ,
353
+ '<div class="codehilite"><pre></pre></div>' , [
354
+ blockUnimplemented (
355
+ '<div class="codehilite"><pre></pre></div>' ),
356
+ ]);
357
+
347
358
static final codeBlockWithHighlightedLines = ContentExample (
348
359
'code block, with syntax highlighting and highlighted lines' ,
349
360
'```\n ::markdown hl_lines="2 4"\n # he\n ## llo\n ### world\n ```' ,
@@ -1149,6 +1160,7 @@ void main() {
1149
1160
testParseExample (ContentExample .codeBlockPlain);
1150
1161
testParseExample (ContentExample .codeBlockHighlightedShort);
1151
1162
testParseExample (ContentExample .codeBlockHighlightedMultiline);
1163
+ testParseExample (ContentExample .codeBlockWithEmptyBody);
1152
1164
testParseExample (ContentExample .codeBlockWithHighlightedLines);
1153
1165
testParseExample (ContentExample .codeBlockWithUnknownSpanType);
1154
1166
testParseExample (ContentExample .codeBlockFollowedByMultipleLineBreaks);
You can’t perform that action at this time.
0 commit comments