diff --git a/lib/index.js b/lib/index.js index f2ce4d4..1de6fda 100644 --- a/lib/index.js +++ b/lib/index.js @@ -772,7 +772,9 @@ function containerFlow(parent, state, info) { function inferDepth(state) { let depth = 0 - for (const x of state.stack) { + for (let i = state.stack.length - 1; i >= 0; i--) { + const x = state.stack[i] + if (x === 'listItem') break if (x === 'mdxJsxFlowElement') { depth++ } diff --git a/test.js b/test.js index 7b66b37..ac4e0d0 100644 --- a/test.js +++ b/test.js @@ -2549,6 +2549,40 @@ test('roundtrip', async function (t) { ) } ) + + await t.test('should roundtrip `nested JSXs and lists`', async function () { + const source = ` + * list item + + + * list item + + + + * list item + + * list item + + + content + + + + content + + + + + + + + content + + + +` + equal(source, source) + }) }) /**