Repository navigation
Clarify Markdown processors features and plugins - #14297
Conversation
Lunaria Status Overview🌕 This pull request will trigger status changes. Learn moreBy default, every PR changing files present in the Lunaria configuration's You can change this by adding one of the keywords present in the Tracked Files
Warnings reference
|
|
Preview deployment ✅ Deployment complete!
|
delucis
left a comment
There was a problem hiding this comment.
Incredible work here @ArmandPhilippot! The Sätteri/Unified tabs are super helpful and clear.
I’ve read through and left some comments. I think some of the stuff I picked up on was already present, so your changes are already very much #NWTWWHB but felt like a natural moment to improve these too. Feel free to move changes into a follow-up PR if that would be easier.
| ## Markdown processors | ||
|
|
||
| Astro applies [GitHub-Flavored Markdown](https://github.github.com/gfm/) and [SmartyPants](https://daringfireball.net/projects/smartypants/) automatically. This brings some niceties like generating clickable links from text, and formatting for quotations and em-dashes. | ||
| <p><Since v="6.4.0" /></p> | ||
|
|
||
| You can extend Markdown processing with plugins, enable additional parser features, or [switch to a different processor entirely](#switching-to-the-unified-processor). See the full list of [Markdown configuration options](/en/reference/configuration-reference/#markdown-options). | ||
| A Markdown processor parses Markdown syntax and renders it into HTML. It can offer [built-in features](#built-in-features) or accept [plugins](#markdown-processor-plugins) to extend Markdown's capabilities. | ||
|
|
||
| ### Choosing a Markdown processor | ||
| Astro provides two official processors, [Sätteri](https://satteri.bruits.org/) and [Unified](https://unifiedjs.com/). You can configure a processor for your entire project or choose a different processor for Markdown and MDX files. | ||
|
|
||
| The [`markdown.processor` option](/en/reference/configuration-reference/#markdownprocessor) controls which engine renders your `.md` and `.mdx` files. Astro provides two official options: | ||
| Since Astro v7, Sätteri is the default Markdown processor. You can use it to render Markdown and MDX files without any installation or configuration according to your project's needs. |
|
Thanks for the suggestions! This sounds like great calls to me. 🙌🏽 I'm going to apply the simplest changes now, and I'll update the rest tomorrow or Monday. |
Co-authored-by: Chris Swithinbank <[email protected]>
Co-authored-by: Chris Swithinbank <[email protected]>
trueberryless
left a comment
There was a problem hiding this comment.
Really amazing improvements here. Thank you Armand!
I looked over some files, have to jump on the plane now. But overall looks really solid. Just left some first nitpicks 👍
| }; | ||
| ``` | ||
|
|
||
| ### markdown.processor |
There was a problem hiding this comment.
It would be really cool if we could somehow use the Sätteri/Unified tabs here as well. I am not sure if this is possible with our current setup / autogeneration of this file. 🤔
There was a problem hiding this comment.
Yeah, there are a couple of things we could improve on that page (e.g. inline code in headings, add links to the "See also:") but I don't think that is easy to do.
|
|
||
| Astro provides [Markdown configuration options](/en/reference/configuration-reference/#markdown-options) that allow you to control [syntax highlighting](/en/guides/syntax-highlighting/) and the Markdown processor. Additionally, each Markdown processor offers [configurable features](#built-in-features) and allows you to [add plugins](#markdown-processor-plugins) to customize the Markdown rendering. | ||
|
|
||
| <MarkdownProcessorTabs> |
There was a problem hiding this comment.
I really like the new structure and wording in the whole file here. Well done 👏
One little general nitpick: With these tabs, I find it difficult to guide people exactly to the right point for how to configure e.g. Unified specifically, because they have to find the tab switcher themselves. This might not be clear to everyone. I am not sure if it is possible to "pre-select" the right tab with HTML fragments. And in general, I think this might not be that big of a deal -- I might just not be used to it yet 😅
| } | ||
| } | ||
| ``` | ||
| The following example applies [`satteri-imgattr`](https://www.npmjs.com/package/satteri-imgattr) and [`satteri-callouts`](https://www.npmjs.com/package/satteri-callouts) to Markdown files: |
There was a problem hiding this comment.
We could also link to npmx here 👀
(but we can discuss it in a follow-up PR; I would be happy to replace some links if desired).
There was a problem hiding this comment.
We don't use npmx in docs, so this sounds unrelated to this PR (ie. no need to bring inconsistency here). And although I consider npmx a great initiative, I think it would cause confusion among many users, as most of them are used to browsing npmjs and see it as the official npm registry.
Co-authored-by: Felix Schneider <[email protected]>
Co-authored-by: Felix Schneider <[email protected]>
Co-authored-by: Felix Schneider <[email protected]>
delucis
left a comment
There was a problem hiding this comment.
Once again, stellar work @ArmandPhilippot 👏
Thanks for taking such care to consider how to improve these docs across the board.
|
Thanks for the reviews! 💜 I just opened withastro/astro#17661 in the core repo to apply the Config reference changes. (No rush! I have to go, so I'll merge this PR later and this doesn't need to wait for the core PR) |
Description (required)
Updates the Markdown guide to clarify what features are available by default through Markdown processors, when to choose which, and how plugins work.
Motivations:
unified()processor. But we never document what is available in theunified()object, exceptremarkPluginsandrehypePlugins.markdown.gfmandmarkdown.smartypantshave been deprecated, it's not clear this is also the default with Sätteri: nosmartypantsproperty in the configuration object, and the default forsmartPunctuationis different in Sätteri.markdown.remarkRehypeis deprecated and we do not say how to do the same thing with Sätteri (well, with Sätteri only footnotes are relevant, but this was the only example for unified anyway).@astrojs/markdown-satteri(I guess it works with npm, but we need to install it with pnpm if we want to pass plugins or disable features)Details of the changes:
@astrojs/starlight/componentsimports<MarkdownProcessorTabs />component to avoid repeating the sync key and to make it easier to keep it in sync in the recipes.#markdown-plugins,#switching-to-the-unified-processor, and#using-remark-and-rehype-pluginsare gone)processor" to avoid repeats.Note
Finding generic terms for plugins might require some brainstorming (related to my discussion with Ema in #14277 (review)). At the moment, I chose:
This reuses Sätteri names but... I also think they are the most accurate (remark operates on MDAST/rehype operates on HAST). I don't think "Markdown-tree plugins" and "HTML-tree plugins" are better, and this sounds a bit redundant with the "definition". And, because Sätteri is now the default, it might not be a problem to reuse Sätteri vocabulary.
To merge with a Lunaria directive:
References