Skip to content

Commit

Permalink
fix: consecutive blockquotes blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
frankie567 committed Mar 22, 2024
1 parent 069b486 commit 370a4e5
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/strange-planets-buy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"markdown-to-jsx": patch
---

fix: consecutive blockquotes blocks
33 changes: 33 additions & 0 deletions index.compiler.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,39 @@ describe('misc block level elements', () => {
</blockquote>
`)
})

it('should handle lazy continuation lines of blockquotes', () => {
render(compiler('> Line 1\nLine 2\n>Line 3'))

expect(root.innerHTML).toMatchInlineSnapshot(`
<blockquote>
<p>
Line 1
Line 2
Line 3
</p>
</blockquote>
`)
})

it('should handle consecutive blockquotes', () => {
render(compiler('> Something important, perhaps?\n\n> Something else'))

expect(root.innerHTML).toMatchInlineSnapshot(`
<div>
<blockquote>
<p>
Something important, perhaps?
</p>
</blockquote>
<blockquote>
<p>
Something else
</p>
</blockquote>
</div>
`)
})
})

describe('headings', () => {
Expand Down
2 changes: 1 addition & 1 deletion index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ const ATTR_EXTRACTOR_R =

const AUTOLINK_MAILTO_CHECK_R = /mailto:/i
const BLOCK_END_R = /\n{2,}$/
const BLOCKQUOTE_R = /^( *>[^\n]+(\n[^\n]+)*\n*)+\n{2,}/
const BLOCKQUOTE_R = /^(\s*>[\s\S]*?)(?=\n{2,})/
const BLOCKQUOTE_TRIM_LEFT_MULTILINE_R = /^ *> ?/gm
const BREAK_LINE_R = /^ {2,}\n/
const BREAK_THEMATIC_R = /^(?:( *[-*_])){3,} *(?:\n *)+\n/
Expand Down

0 comments on commit 370a4e5

Please sign in to comment.