Skip to content

Commit

Permalink
Fix indent of JSX in block quotes in JSX
Browse files Browse the repository at this point in the history
  • Loading branch information
wooorm committed Mar 13, 2024
1 parent 63b7767 commit a793033
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -775,7 +775,7 @@ function inferDepth(state) {
while (--index > -1) {
const name = state.stack[index]

if (name === 'listItem') break
if (name === 'blockquote' || name === 'listItem') break
if (name === 'mdxJsxFlowElement') depth++
}

Expand Down
39 changes: 38 additions & 1 deletion test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2550,7 +2550,7 @@ test('roundtrip', async function (t) {
}
)

await t.test('should roundtrip `nested JSXs and lists`', async function () {
await t.test('should roundtrip `nested JSX and lists`', async function () {
const source = `<x>
* Alpha
Expand Down Expand Up @@ -2583,6 +2583,43 @@ test('roundtrip', async function (t) {
`
equal(source, source)
})

await t.test(
'should roundtrip `nested JSX and block quotes`',
async function () {
const source = `<x>
> Alpha
>
> <y>
> > Bravo
> >
> > <z>
> > <a>
> > > Charlie
> > >
> > > > Delta
> > > >
> > > > <b>
> > > > Echo
> > > > </b>
> > >
> > > <b>
> > > Foxtrot
> > > </b>
> > </a>
> > </z>
> </y>
<y>
<z>
Golf
</z>
</y>
</x>
`
equal(source, source)
}
)
})

/**
Expand Down

0 comments on commit a793033

Please sign in to comment.