Code Blocks in Astro
The Expressive Code plugin makes code fences in Markdown much more powerful and versatile. For example, consider the following code block of my installation experience. The first line is how I installed Expressive Code as an Astro add-in. The remaining lines initially show as collapsed, but you can expand them to see the results of walking through the installation wizard.
Installation was pretty smooth, except for one hiccup. It required an extra bit of manual tweaking, because the mdx()
integration was before the expressiveCode()
integration. Simply swapping those in the configuration file fixed the problem.
Now, if you’re familiar with how regular markdown code fences are rendered in environments such as GitHub, you are probably already seeing a lot of nice features. I won’t detail how to do all of them, but the primary features include:
- Syntax Highlighting
- Editor vs. Terminal Frames
- Text and Line Markers
- Word Wrap
- Collapible Sections (as an extra plugin)
- Line Numbers (also as an extra plugin)
Expressive Code also support various themes (if that’s important to you).
All-in-all, Expressive Code is the code formatter extension I’ve been looking for for well over a decade now.