-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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 and MDX configuration rework #5684
Conversation
🦋 Changeset detectedLatest commit: aae0f82 The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
import { unified } from 'unified'; | ||
import { VFile } from 'vfile'; | ||
|
||
export { rehypeHeadingIds } from './rehype-collect-headings.js'; | ||
export * from './types.js'; | ||
|
||
export const DEFAULT_REMARK_PLUGINS = ['remark-gfm', 'remark-smartypants']; | ||
export const DEFAULT_REHYPE_PLUGINS = []; | ||
export const markdownConfigDefaults: Omit<Required<AstroMarkdownOptions>, 'drafts'> = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move markdownConfigDefaults
to a const
so Remark, Astro Core, and MDX can all share the same fallbacks!
I just put in this RFC discussion, I wonder if this might complement that withastro/roadmap#424 |
@lorenzolewis thanks! That's a thorough set of ideas I think should be explored in future RFCs. Let me know if any changes proposed here would be blocking to your proposals. Otherwise, we'll treat this PR as step 1 on that journey! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I love this new config, @bholmesdev! Much more intuitive! 🥳
Some comments below!
packages/integrations/mdx/README.md
Outdated
|
||
You can set remark-rehype options in your config file: | ||
For example, say you need to disable GitHub-Flavored Markdown and apply an extra remark plugin for MDX files. You can apply these options like so, with `extendMarkdownConfig` enabled by default: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm wondering whether these examples might be better suited to the docs page itself? I don't think these tell me anything new. They visually show what it looks like when both Markdown and MDX have config options set, but I'm not sure that's needed here?
The docs page here will need updating anyway, to correspond to these changes: /#configuring-markdown-and-mdx
Maybe what you have here as examples actually replaces what's there? Since that's where we show what it looks like when both have config settings are applied.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed! I'll put a docs PR on-hold until we get a dev approval here. May be some final API reshuffling.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright, I think we have dev consensus. Moving to a docs PR!
packages/integrations/mdx/README.md
Outdated
- [`recmaPlugins`](#recmaplugins) | ||
|
||
### `extendPlugins` | ||
### Markdown configuration options |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: it feels weird to call these "Markdown configuration options"
I know this is shorthand for mirrors "all the stuff you can configure in Markdown, too!" but it really is MDX configuration options, that happen to (except for one 😅) be the exact same options that are available elsewhere for configuring Markdown.
I might be tempted to still, in fact, call this MDX configuration options. I think that's what it is. And, I think if people are searching for "MDX configuration" then having that in a header is helpful for our Algolia search results.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, the overarching section is already MDX configuration, so I don't think that would make sense. I vote removing the heading if that's a concern 🤷
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update: renamed to "Options inherited from Markdown config" to clarify. If we don't like that heading, I say scrap it. I was just struggling with the table-of-contents feeling awkward without a heading present here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general, I think this direction is great! Won’t dive into the inline docs before we know we’re doing this, but left one comment that might help us think through these changes from the perspective of an (existing) user.
@bholmesdev I put some details on a possible enum value in the flag that could replace the It might allow for more flexibility in the future without a major semver change, but 💯 up to your discretion if that's something you feel is relevant at this stage or not. |
@lorenzolewis thanks! I just left a comment on that enum suggestion. To explain in context: I'm not sure I'm comfortable with blanket terms like |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me! Didn't see anything that stands out odd, and the new defaults looks great.
1944ffb
to
2d5a774
Compare
.changeset/shaggy-keys-turn.md
Outdated
``` | ||
|
||
|
||
Additionally, applying remark and rehype plugins **no longer disables** `githubFlavoredMarkdown`. You will need to opt-out manually by setting `githubFlavoredMarkdown` to `false`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really like this part
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs TSC approval.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved by TSC.
Thanks TypeScript Compiler ❤️ |
Co-authored-by: Sarah Rainsberger <[email protected]>
Co-authored-by: Sarah Rainsberger <[email protected]>
Co-authored-by: Sarah Rainsberger <[email protected]>
1514417
to
aae0f82
Compare
* [ci] release * Wrap astro 2.0 beta logs in `<details>` * Add link to docs upgrade guide * First pass cleaning up 2.0 release notes * mdx changes from Sarah * combine 5584 and 5842 in deno, image, netlify * markdown/remark incl (5684 & 5769) to match mdx * Tweak markdown/remark formatting * Format astro-prism * Format astro-rss * Format create-astro * Format cloudflare * Format lit * Format partytown * Format node * Format preact * Format react * Format solid * Format svelte * Format tailwind * Format vercel * Format vue * Format telemetry * Format webapi * Format scripts * Reinstate h3s for headings Co-authored-by: Ben Holmes <[email protected]> * Reformat mdx * astro & markdown/remark: Combine #5679 & #5684 changelogs Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Chris Swithinbank <[email protected]> Co-authored-by: Sarah Rainsberger <[email protected]> Co-authored-by: Ben Holmes <[email protected]>
* [ci] release * Update changelogs (#5955) * [ci] release * Wrap astro 2.0 beta logs in `<details>` * Add link to docs upgrade guide * First pass cleaning up 2.0 release notes * mdx changes from Sarah * combine 5584 and 5842 in deno, image, netlify * markdown/remark incl (5684 & 5769) to match mdx * Tweak markdown/remark formatting * Format astro-prism * Format astro-rss * Format create-astro * Format cloudflare * Format lit * Format partytown * Format node * Format preact * Format react * Format solid * Format svelte * Format tailwind * Format vercel * Format vue * Format telemetry * Format webapi * Format scripts * Reinstate h3s for headings Co-authored-by: Ben Holmes <[email protected]> * Reformat mdx * astro & markdown/remark: Combine #5679 & #5684 changelogs Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Chris Swithinbank <[email protected]> Co-authored-by: Sarah Rainsberger <[email protected]> Co-authored-by: Ben Holmes <[email protected]> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Matthew Phillips <[email protected]> Co-authored-by: Chris Swithinbank <[email protected]> Co-authored-by: Sarah Rainsberger <[email protected]> Co-authored-by: Ben Holmes <[email protected]>
* [ci] release * Update changelogs (#5955) * [ci] release * Wrap astro 2.0 beta logs in `<details>` * Add link to docs upgrade guide * First pass cleaning up 2.0 release notes * mdx changes from Sarah * combine 5584 and 5842 in deno, image, netlify * markdown/remark incl (5684 & 5769) to match mdx * Tweak markdown/remark formatting * Format astro-prism * Format astro-rss * Format create-astro * Format cloudflare * Format lit * Format partytown * Format node * Format preact * Format react * Format solid * Format svelte * Format tailwind * Format vercel * Format vue * Format telemetry * Format webapi * Format scripts * Reinstate h3s for headings Co-authored-by: Ben Holmes <[email protected]> * Reformat mdx * astro & markdown/remark: Combine #5679 & #5684 changelogs Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Chris Swithinbank <[email protected]> Co-authored-by: Sarah Rainsberger <[email protected]> Co-authored-by: Ben Holmes <[email protected]> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Matthew Phillips <[email protected]> Co-authored-by: Chris Swithinbank <[email protected]> Co-authored-by: Sarah Rainsberger <[email protected]> Co-authored-by: Ben Holmes <[email protected]>
Changes
Refine Markdown and MDX configuration options for ease-of-use. Decisions based on a discord feedback thread.
Markdown
remark-smartypants
from Astro's default Markdown plugins.extendDefaultPlugins
option with a simplifiedgfm
boolean. This is enabled by default, and can be disabled to remove GitHub-Flavored Markdown.remarkPlugins
orrehypePlugins
are configured. If you want to apply custom plugins and remove GFM, manually setgfm: false
in your config.MDX
drafts
) from your MDX integration config. This includessyntaxHighlighting
andshikiConfig
options to further customize the MDX renderer.extendDefaults
to anextendMarkdownConfig
option. MDX options will be deeply merged with your Markdown config by default. By settingextendMarkdownConfig
to false, you can "eject" to set your own syntax highlighting and plugins.Testing
markdown-plugins
andmdx-plugins
test for new config extend optionsDocs