Skip to main content

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:

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:
Override per block with :line-numbers or :no-line-numbers:

Custom Containers

Custom containers provide callout-style blocks for tips, warnings, and more:
Container implementation is in src/node/markdown/plugins/containers.ts:8-27. The plugin uses markdown-it-container to create custom blocks.

GitHub-Flavored Alerts

VitePress supports GitHub-style alerts that render as callouts:

Code Groups

Group related code blocks with tabs for better organization:

Import Code Snippets

Import code from external files using the <<< syntax:
1

Basic Import

The @ 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-216

Markdown File Inclusion

Include markdown content from other files:
You can also include specific line ranges or regions:

Header Anchors

Headers automatically get anchor links for navigation:

Custom Anchors

This allows linking to #my-anchor instead of the auto-generated slug.

Configuration

Internal links are converted to router links for SPA navigation:
External links automatically get target="_blank" rel="noreferrer":

Tables

GitHub-flavored Markdown tables with alignment support:

Emoji

Emoji shortcuts are supported out of the box:
See the full emoji list.

Table of Contents

Generate a table of contents from headers:
Configure TOC depth:

Math Equations

Enable LaTeX math support with markdown-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:
The markdown renderer is created in src/node/markdown/markdown.ts:243-400. Custom plugins are applied after built-in VitePress plugins.

Vue Components in Markdown

Use Vue components directly in markdown files:

The raw Container

Prevent style conflicts when documenting component libraries:
For style isolation, install PostCSS:
Create docs/postcss.config.mjs: