Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Markdown front matter within Markdown code blocks causes a crash #12637

Closed
1 task
jakelazaroff opened this issue Dec 5, 2024 · 2 comments · Fixed by #12646
Closed
1 task

Markdown front matter within Markdown code blocks causes a crash #12637

jakelazaroff opened this issue Dec 5, 2024 · 2 comments · Fixed by #12646
Labels
- P2: has workaround Bug, but has workaround (priority) feat: markdown Related to Markdown (scope)

Comments

@jakelazaroff
Copy link

Astro Info

Astro                    v5.0.2
Node                     v22.9.0
System                   macOS (arm64)
Package Manager          pnpm
Output                   static
Adapter                  none
Integrations             none

If this issue only occurs in one browser, which browser is a problem?

No response

Describe the Bug

Maybe kind of niche, but including Markdown (or Astro) front matter within a Markdown code fence causes Astro to crash.

For example, the following code within a Markdown file will cause a crash:

this should work

```astro
---
but: it
breaks
---
asdf
```

I think it has to do with it interpreting that as invalid YAML — removing the "breaks" line fixes the crash (though the code block is still empty).

This started happening when I upgraded to Astro 5. Last working version I tested with was 4.16.

I know new releases can be fraught but loving Astro 5 — thanks so much for all the hard work!

What's the expected result?

The entire contents of the code block should be reproduced as a code block in the rendered output.

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-wj9jkb?file=src%2Ftest.md

Participation

  • I am willing to submit a pull request for this issue.
@github-actions github-actions bot added the needs triage Issue needs to be triaged label Dec 5, 2024
@ascorbic
Copy link
Contributor

ascorbic commented Dec 5, 2024

Hi.
Interesting bug. There is a workaround: add empty frontmatter to the top of the file:

---
---

# this should work

```astro
---
but: it
breaks
---

asdf
```

@ascorbic ascorbic added feat: markdown Related to Markdown (scope) - P2: has workaround Bug, but has workaround (priority) and removed needs triage Issue needs to be triaged labels Dec 5, 2024
@bluwy
Copy link
Member

bluwy commented Dec 5, 2024

I've updated how we parse the frontmatter in Astro 5, let me see where the issue is.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
- P2: has workaround Bug, but has workaround (priority) feat: markdown Related to Markdown (scope)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants