MkDocs PanZoom Plugin
The MkDocs PanZoom Plugin is an active MkDocs plugin, currently at version 0.5.2, designed to add pan and zoom functionality to images and Mermaid/D2 diagrams within your MkDocs generated documentation. It enhances user interaction with visual content by allowing navigation and magnification, and it maintains a steady release cadence with recent updates improving performance and features.
Warnings
- breaking As of version 0.4.0, the plugin requires explicit configuration of `pymdownx.superfences` for Mermaid/D2 diagrams to work, and the `site_url` must be defined in `mkdocs.yml`. Additionally, the `exclude` (pages) configuration option was removed.
- gotcha The `site_url` parameter in `mkdocs.yml` must be defined for the plugin to function correctly, particularly with diagram and image handling.
- gotcha The `exclude_selectors` option in the plugin configuration is intended only to disable the *default* selectors (e.g., '.mermaid', '.d2'). To exclude a *specific item* (image or diagram) from pan/zoom, you must add the CSS class `pz-ignore` to that item in your Markdown.
Install
-
pip install mkdocs-panzoom-plugin
Quickstart
plugins:
- search
- panzoom:
# Enable pan/zoom for images
include_selectors:
- "img"
# Optional: always show the hint (default: false)
always_show_hint: true
# Optional: set initial zoom level (default: 1.0)
initial_zoom_level: 1.2
# Optional: enable fullscreen (still in development)
full_screen: False
# Required for Mermaid/D2 diagrams with panzoom since v0.4.0
markdown_extensions:
- pymdownx.superfences:
custom_fences:
- name: mermaid
class: mermaid
format: !!python/name:pymdownx.superfences.fence_code_format
site_url: https://example.com/your-docs/