mkdocs-shadcn

  • Home
  • Get started
  • Pages
  • HTML
Extensions
  • Admonitions
  • Attribute Lists
  • Codehilite
  • Codexec
  • Apache ECharts
  • Fenced code
  • Footnotes
  • Hover Card
  • Iconify
  • pymdownx.arithmatex
  • pymdownx.blocks.caption
  • pymdownx.blocks.details
  • pymdownx.blocks.tab
  • pymdownx.progressbar
  • pymdownx.tabbed
  • Table of Contents
Plugins
  • Autonumber
  • Excalidraw
  • Mike
  • Mkdocstrings
Contributing
  • Contributing
  • Setup
  • Internationalization

Codehilite

Previous Next

Syntax highlighting for code blocks

Reference

The CodeHilite extension adds code/syntax highlighting to standard Python-Markdown code blocks using Pygments.

You must have pygments installed.

pip install Pygments
uv add Pygments
poetry add Pygments

Configuration

# mkdocs.yml

markdown_extensions:
  - codehilite

Syntax

With the colon syntax (don't forget to indent the block).

    :::python
    import numpy as np

or backticks syntax

```python
import numpy as np
```

both give

import numpy as np
Attribute Lists Codexec
Menu
Home Get started Pages HTML
Extensions
Admonitions Attribute Lists Codehilite Codexec Apache ECharts Fenced code Footnotes Hover Card Iconify pymdownx.arithmatex pymdownx.blocks.caption pymdownx.blocks.details pymdownx.blocks.tab pymdownx.progressbar pymdownx.tabbed Table of Contents
Plugins
Autonumber Excalidraw Mike Mkdocstrings
Contributing
Contributing Setup Internationalization

On This Page

Configuration Syntax
Built by Alban Siffer — shadcn theme provided by @asiffer