Skip to content

Commit d1bf2cc

Browse files
Copilotggazzo
andauthored
fix(message-parser): Merge blockquotes separated by empty > lines into a single block (#39062)
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: ggazzo <5263975+ggazzo@users.noreply.github.com>
1 parent 29d2454 commit d1bf2cc

3 files changed

Lines changed: 24 additions & 1 deletion

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@rocket.chat/message-parser': patch
3+
---
4+
5+
Fixed blockquotes with empty lines between paragraphs not rendering as a single blockquote. Lines like `> ` or `>` (empty quote lines) are now treated as part of the surrounding blockquote rather than breaking it into separate quotes.

packages/message-parser/src/grammar.pegjs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,9 @@ Blocks
7676
*/
7777
Blockquote = b:BlockquoteLine+ { return quote(b); }
7878

79-
BlockquoteLine = ">" [ \t]* @Paragraph
79+
BlockquoteLine
80+
= ">" [ \t]* EndOfLine { return paragraph([plain('')]); }
81+
/ ">" [ \t]* @Paragraph
8082

8183
/**
8284
* Block Spoiler

packages/message-parser/tests/blockquotes.test.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,22 @@ As Rocket Cat said:
2626
`.trim(),
2727
[paragraph([plain('As Rocket Cat said:')]), quote([paragraph([plain('meowww')]), paragraph([plain('grr.')])])],
2828
],
29+
[
30+
`
31+
> meowww
32+
>
33+
> grr.
34+
`.trim(),
35+
[quote([paragraph([plain('meowww')]), paragraph([plain('')]), paragraph([plain('grr.')])])],
36+
],
37+
[
38+
`
39+
> meowww
40+
>
41+
> grr.
42+
`.trim(),
43+
[quote([paragraph([plain('meowww')]), paragraph([plain('')]), paragraph([plain('grr.')])])],
44+
],
2945
])('parses %p', (input, output) => {
3046
expect(parse(input)).toMatchObject(output);
3147
});

0 commit comments

Comments
 (0)