File tree 2 files changed +17
-1
lines changed
2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -1124,14 +1124,18 @@ class _ZulipContentParser {
1124
1124
return result;
1125
1125
}
1126
1126
1127
+ static final _redundantLineBreaksRegexp = RegExp (r'^\n+$' );
1128
+
1127
1129
List <BlockContentNode > parseBlockContentList (dom.NodeList nodes) {
1128
1130
assert (_debugParserContext == _ParserContext .block);
1129
1131
final List <BlockContentNode > result = [];
1130
1132
List <ImageNode > imageNodes = [];
1131
1133
for (final node in nodes) {
1132
1134
// We get a bunch of newline Text nodes between paragraphs.
1133
1135
// A browser seems to ignore these; let's do the same.
1134
- if (node is dom.Text && (node.text == '\n ' )) continue ;
1136
+ if (node is dom.Text && _redundantLineBreaksRegexp.hasMatch (node.text)) {
1137
+ continue ;
1138
+ }
1135
1139
1136
1140
final block = parseBlockContent (node);
1137
1141
if (block is ImageNode ) {
Original file line number Diff line number Diff line change @@ -301,6 +301,17 @@ class ContentExample {
301
301
'\n </code></pre></div>' ),
302
302
]);
303
303
304
+ static const codeBlockFollowedByMultipleLineBreaks = ContentExample (
305
+ 'blank text nodes after code blocks' ,
306
+ ' code block.\n\n some content' ,
307
+ // https://chat.zulip.org/#narrow/stream/7-test-here/near/1774823
308
+ '<div class="codehilite">'
309
+ '<pre><span></span><code>code block.\n </code></pre></div>\n\n '
310
+ '<p>some content</p>' , [
311
+ CodeBlockNode ([CodeBlockSpanNode (text: "code block." , type: CodeBlockSpanType .text)]),
312
+ ParagraphNode (links: null , nodes: [TextNode ("some content" )]),
313
+ ]);
314
+
304
315
static final mathInline = ContentExample .inline (
305
316
'inline math' ,
306
317
r"$$ \lambda $$" ,
@@ -865,6 +876,7 @@ void main() {
865
876
testParseExample (ContentExample .codeBlockHighlightedMultiline);
866
877
testParseExample (ContentExample .codeBlockWithHighlightedLines);
867
878
testParseExample (ContentExample .codeBlockWithUnknownSpanType);
879
+ testParseExample (ContentExample .codeBlockFollowedByMultipleLineBreaks);
868
880
869
881
testParseExample (ContentExample .mathBlock);
870
882
testParseExample (ContentExample .mathBlockInQuote);
You can’t perform that action at this time.
0 commit comments