File tree 2 files changed +14
-1
lines changed 2 files changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -694,6 +694,8 @@ class _ZulipContentParser {
694
694
}();
695
695
static final _emojiCodeFromClassNameRegexp = RegExp (r"emoji-([^ ]+)" );
696
696
697
+ static final _redundantLineBreaksRegexp = RegExp (r'^\n+$' );
698
+
697
699
InlineContentNode parseInlineContent (dom.Node node) {
698
700
assert (_debugParserContext == _ParserContext .inline);
699
701
final debugHtmlNode = kDebugMode ? node : null ;
@@ -1107,7 +1109,7 @@ class _ZulipContentParser {
1107
1109
for (final node in nodes) {
1108
1110
// We get a bunch of newline Text nodes between paragraphs.
1109
1111
// A browser seems to ignore these; let's do the same.
1110
- if (node is dom.Text && (node.text == ' \n ' )) continue ;
1112
+ if (node is dom.Text && _redundantLineBreaksRegexp. hasMatch (node.text)) continue ;
1111
1113
1112
1114
final block = parseBlockContent (node);
1113
1115
if (block is ImageNode ) {
Original file line number Diff line number Diff line change @@ -301,6 +301,16 @@ 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
+ '<div class="codehilite">'
308
+ '<pre><span></span><code>code block.\n </code></pre></div>\n\n '
309
+ '<p>some content</p>' , [
310
+ CodeBlockNode ([CodeBlockSpanNode (text: "code block." , type: CodeBlockSpanType .text)]),
311
+ ParagraphNode (links: null , nodes: [TextNode ("some content" )]),
312
+ ]);
313
+
304
314
static final mathInline = ContentExample .inline (
305
315
'inline math' ,
306
316
r"$$ \lambda $$" ,
@@ -843,6 +853,7 @@ void main() {
843
853
testParseExample (ContentExample .codeBlockHighlightedMultiline);
844
854
testParseExample (ContentExample .codeBlockWithHighlightedLines);
845
855
testParseExample (ContentExample .codeBlockWithUnknownSpanType);
856
+ testParseExample (ContentExample .codeBlockFollowedByMultipleLineBreaks);
846
857
847
858
testParseExample (ContentExample .mathBlock);
848
859
testParseExample (ContentExample .mathBlockInQuote);
You can’t perform that action at this time.
0 commit comments