diff --git a/packages/astro/test/astro-markdown.test.js b/packages/astro/test/astro-markdown.test.js index b001c6a83..1ef8a4b9a 100644 --- a/packages/astro/test/astro-markdown.test.js +++ b/packages/astro/test/astro-markdown.test.js @@ -291,23 +291,27 @@ describe('Astro Markdown', () => { expect(slots.find('> .fragmentSlot > div').text()).to.contain('1:'); expect(slots.find('> .fragmentSlot > div + p').text()).to.contain('2:'); expect(slots.find('> .pSlot > p[title="hello"]').text()).to.contain('3:'); - expect(slots.find('> .defaultSlot').text().replace(/\s+/g, ' ')).to.equal(` + expect(slots.find('> .defaultSlot').text().replace(/\s+/g, ' ')).to.equal( + ` 4: Div in default slot 5: Paragraph in fragment in default slot 6: Regular text in default slot - `.replace(/\s+/g, ' ')); + `.replace(/\s+/g, ' ') + ); const nestedSlots = $('article').eq(1); expect(nestedSlots.find('> .fragmentSlot').html()).to.contain('1:'); expect(nestedSlots.find('> .pSlot > p').text()).to.contain('2:'); - expect(nestedSlots.find('> .defaultSlot > article').text().replace(/\s+/g, ' ')).to.equal(` + expect(nestedSlots.find('> .defaultSlot > article').text().replace(/\s+/g, ' ')).to.equal( + ` 3: nested fragmentSlot 4: nested pSlot 5: nested text in default slot - `.replace(/\s+/g, ' ')); + `.replace(/\s+/g, ' ') + ); expect($('article').eq(3).text().replace(/[^❌]/g, '')).to.equal('❌❌❌'); - + expect($('article').eq(4).text().replace(/[^❌]/g, '')).to.equal('❌❌❌'); }); }); diff --git a/packages/markdown/remark/src/rehype-jsx.ts b/packages/markdown/remark/src/rehype-jsx.ts index 46c200b70..daeb4d56a 100644 --- a/packages/markdown/remark/src/rehype-jsx.ts +++ b/packages/markdown/remark/src/rehype-jsx.ts @@ -7,9 +7,8 @@ export default function rehypeJsx(): any { child.tagName = `${child.tagName}`; }); visit(node, MDX_ELEMENTS, (child: any, index: number | null, parent: any) => { - if (index === null || !Boolean(parent)) - return; - + if (index === null || !Boolean(parent)) return; + const attrs = child.attributes.reduce((acc: any[], entry: any) => { let attr = entry.value; if (attr && typeof attr === 'object') { diff --git a/packages/markdown/remark/test/components.test.js b/packages/markdown/remark/test/components.test.js index 59816b76e..ca0a3fdb4 100644 --- a/packages/markdown/remark/test/components.test.js +++ b/packages/markdown/remark/test/components.test.js @@ -49,9 +49,7 @@ describe('components', () => { it('should normalize children', async () => { const { code } = await renderMarkdown(`Hello world!`, {}); - chai - .expect(code) - .to.equal(`\nHello world!\n`); + chai.expect(code).to.equal(`\nHello world!\n`); }); it('should be able to nest components', async () => { @@ -73,10 +71,6 @@ describe('components', () => { {} ); - chai - .expect(code) - .to.equal( - `\n

Hello world!

\n` - ); + chai.expect(code).to.equal(`\n

Hello world!

\n`); }); });