-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* refactor: add legacy.jsxInMarkdown flag to config * fix: use `set:html` when `markdown.mode` is 'md' * Revert "refactor: add legacy.jsxInMarkdown flag to config" This reverts commit 5572e8d. * fix: move `remarkUnwrap, remarkEscape` to MDX only * fix: only apply scary HTML passthroughs on MDX * fix: move all JSX-specific rehype plugins under `isMDX` * fix: "allowDangerousHtml" for md (required for Shiki) * fix: apply `set:html` for non-layouts too * test: JSX expressions, components, syntax highlighting * chore: changeset * fix: ignore "setup" and "components" in plain MD mode * refactor: create new fixture to avoid weird caching error * fix: dup package name * chore: update lock * fix: apply rehypeCollectHeaders to md
- Loading branch information
1 parent
c2968b0
commit 399d7e2
Showing
11 changed files
with
143 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
'astro': patch | ||
'@astrojs/markdown-remark': patch | ||
--- | ||
|
||
Avoid parsing JSX, components, and Astro islands when using "plain" md mode. This brings `markdown.mode: 'md'` in-line with our docs description. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import { expect } from 'chai'; | ||
import * as cheerio from 'cheerio'; | ||
import { loadFixture } from './test-utils.js'; | ||
|
||
describe('Astro Markdown - plain MD mode', () => { | ||
let fixture; | ||
|
||
before(async () => { | ||
fixture = await loadFixture({ | ||
root: './fixtures/astro-markdown-md-mode/', | ||
}); | ||
await fixture.build(); | ||
}); | ||
|
||
it('Leaves JSX expressions unprocessed', async () => { | ||
const html = await fixture.readFile('/jsx-expressions/index.html'); | ||
const $ = cheerio.load(html); | ||
|
||
expect($('h2').html()).to.equal('{frontmatter.title}'); | ||
}); | ||
|
||
it('Leaves JSX components un-transformed', async () => { | ||
const html = await fixture.readFile('/components/index.html'); | ||
|
||
expect(html).to.include('<counter client:load="" count="{0}">'); | ||
}); | ||
|
||
describe('syntax highlighting', async () => { | ||
it('handles Shiki', async () => { | ||
const html = await fixture.readFile('/code-in-md/index.html'); | ||
const $ = cheerio.load(html); | ||
|
||
expect($('pre.astro-code').length).to.not.equal(0); | ||
}); | ||
|
||
it('handles Prism', async () => { | ||
fixture = await loadFixture({ | ||
root: './fixtures/astro-markdown-md-mode/', | ||
markdown: { | ||
syntaxHighlight: 'prism', | ||
mode: 'md', | ||
}, | ||
}); | ||
await fixture.build(); | ||
|
||
const html = await fixture.readFile('/code-in-md/index.html'); | ||
const $ = cheerio.load(html); | ||
|
||
expect($('pre.language-html').length).to.not.equal(0); | ||
}); | ||
}); | ||
}); |
11 changes: 11 additions & 0 deletions
11
packages/astro/test/fixtures/astro-markdown-md-mode/astro.config.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { defineConfig } from 'astro/config'; | ||
import svelte from "@astrojs/svelte"; | ||
|
||
// https://astro.build/config | ||
export default defineConfig({ | ||
markdown: { | ||
mode: 'md', | ||
}, | ||
integrations: [svelte()], | ||
site: 'https://astro.build/', | ||
}); |
9 changes: 9 additions & 0 deletions
9
packages/astro/test/fixtures/astro-markdown-md-mode/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"name": "@test/astro-markdown-md-mode", | ||
"version": "0.0.0", | ||
"private": true, | ||
"dependencies": { | ||
"@astrojs/svelte": "workspace:*", | ||
"astro": "workspace:*" | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
packages/astro/test/fixtures/astro-markdown-md-mode/src/components/Counter.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<script> | ||
export let count = 0; | ||
</script> | ||
|
||
<button onClick={() => count += 1}>{count}</button> |
7 changes: 7 additions & 0 deletions
7
packages/astro/test/fixtures/astro-markdown-md-mode/src/pages/code-in-md.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Fenced code blocks | ||
|
||
```html | ||
<body> | ||
<div>This should also work without any problems.</div> | ||
</body> | ||
``` |
5 changes: 5 additions & 0 deletions
5
packages/astro/test/fixtures/astro-markdown-md-mode/src/pages/components.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
setup: import Counter from '../components/Counter.svelte' | ||
--- | ||
|
||
<Counter client:load count={0}></Counter> |
13 changes: 13 additions & 0 deletions
13
packages/astro/test/fixtures/astro-markdown-md-mode/src/pages/jsx-expressions.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
--- | ||
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} | ||
|
||
<ul> | ||
{frontmatter.list.map(item => <li id={item}>{item}</li>)} | ||
</ul> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.