Markdown Extensions
VitePress extends standard Markdown with powerful features powered by markdown-it. These extensions enable rich documentation with minimal effort.Syntax Highlighting
VitePress uses Shiki for syntax highlighting with accurate, beautiful code blocks that support hundreds of languages.1
Specify Language
Add the language identifier after the opening code fence:
2
Configure Theme
Customize syntax highlighting in your config:
3
Add Language Aliases
Create custom language aliases:
Line Highlighting
Highlight specific lines to draw attention to important code:- Single Line
- Multiple Lines
- Inline Comments
Code Annotations
VitePress supports special comments for focused lines, diffs, and error highlighting:These transformers are implemented via Shiki’s transformer API. See
src/node/markdown/plugins/highlight.ts:80-96 for the implementation.Line Numbers
Enable line numbers globally or per code block::line-numbers or :no-line-numbers:
Custom Containers
Custom containers provide callout-style blocks for tips, warnings, and more:- Types
- Custom Titles
GitHub-Flavored Alerts
VitePress supports GitHub-style alerts that render as callouts:Code Groups
Group related code blocks with tabs for better organization:Code Group Example
Code Group Example
Import Code Snippets
Import code from external files using the<<< syntax:
1
Basic Import
@ symbol maps to your source directory.2
With Line Highlighting
3
Region Import
Import only a specific region marked with comments:In your source file:
4
Specify Language
Snippet plugin implementation:
src/node/markdown/plugins/snippet.ts:122-216Markdown File Inclusion
Include markdown content from other files:Header Anchors
Headers automatically get anchor links for navigation:Custom Anchors
#my-anchor instead of the auto-generated slug.
Configuration
Links
Internal Links
Internal links are converted to router links for SPA navigation:External Links
External links automatically gettarget="_blank" rel="noreferrer":
Tables
GitHub-flavored Markdown tables with alignment support:Emoji
Emoji shortcuts are supported out of the box:Table of Contents
Generate a table of contents from headers:Math Equations
Enable LaTeX math support withmarkdown-it-mathjax3:
1
Install Package
2
Enable in Config
3
Use in Markdown
Image Lazy Loading
Enable lazy loading for images:Advanced Configuration
Customize the markdown-it instance with plugins:Vue Components in Markdown
Use Vue components directly in markdown files:The raw Container
Prevent style conflicts when documenting component libraries:
docs/postcss.config.mjs: