Skip to content

Commit

Permalink
Fix: markdown JSX expression inconsistencies (withastro#3152)
Browse files Browse the repository at this point in the history
* fix: remove micromark-extension-mdx-expression to unbreak JSX expressions

* chore: changeset

* deps: update lockfile

* tests: jsx expressions in markdown
  • Loading branch information
bholmesdev authored Apr 19, 2022
1 parent 9ac8d35 commit 317e124
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
11 changes: 11 additions & 0 deletions test/astro-markdown.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,17 @@ describe('Astro Markdown', () => {
expect($('#test').length).to.be.ok;
});

it('Can parse JSX expressions in markdown pages', async () => {
const html = await fixture.readFile('/jsx-expressions/index.html');
const $ = cheerio.load(html);

expect($('h2').html()).to.equal('Blog Post with JSX expressions')
expect($('p').first().html()).to.equal('JSX at the start of the line!')
for (let listItem of ['test-1', 'test-2', 'test-3']) {
expect($(`#${listItem}`).html()).to.equal(`\n${listItem}\n`)
}
})

it('Can load more complex jsxy stuff', async () => {
const html = await fixture.readFile('/complex/index.html');
const $ = cheerio.load(html);
Expand Down
11 changes: 11 additions & 0 deletions test/fixtures/astro-markdown/src/pages/jsx-expressions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
title: Blog Post with JSX expressions
paragraph: JSX at the start of the line!
list: ['test-1', 'test-2', 'test-3']
---

## {frontmatter.title}

{frontmatter.paragraph}

{frontmatter.list.map(item => <p id={item}>{item}</p>)}

0 comments on commit 317e124

Please sign in to comment.