Skip to main content

MkDocs plugin to convert Mermaid code blocks to images.

Project description

MkDocs IZSAM Mermaid to images

This plugin processes each page's Markdown content, finds Mermaid code blocks, converts them to images using mermaid.cli, and replaces the code blocks with image references. The image format can be specified in the mkdocs.yml configuration file.

Installation

Install dependencies:

npm install -g @mermaid-js/mermaid-cli

Install the package with pip:

pip install mkdocs-izsam-mermaid-to-images

Enable the plugin in the mkdocs.yml file:

plugins:
  - search
  - mkdocs-izsam-mermaid-to-images:
        output_dir: mermaid_images # Optional, defaults to 'mermaid_images'
        image_format: svg # Optional, defaults to 'svg'
        image_class: mmd  # Optional, defaults to 'mmd'
        mermaid_config:
            theme: default
            fontFamily: "Arial, sans-serif"
            fontSize: 16

See how to use MkDocs Plugins

Change log

[1.0.7] - 2024-09-17

Added support to Mermaid configuration options

Needed to import json module

[1.0.6] - 2024-09-17

Added support to Mermaid configuration options

[1.0.5] - 2024-09-17

Added class for generate img tag

Added a class to the generated tag and made it configurable by the user, default is 'mmd'.

[1.0.4] - 2024-09-17

Changed the way images directory are generated

Images directory now is generated in the same directory as the HTML file where the Mermaid diagrams are declared. This way, the image paths will be relative to the page, avoiding problems with paths.

[1.0.3] - 2024-09-17

Fix on image paths

The plugin was generating the image paths relative to the current page, but it should generate them relative to the root of the site.

[1.0.2] - 2024-09-17

Fix on image paths

Generated image files are not being found at the expected paths.

[1.0.1] - 2024-09-17

Setup bug fix and README changes

Bug fix for setup entry_points section; fix for error in configuration instructions.

[1.0] - 2024-09-17

First release

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mkdocs_izsam_mermaid_to_images-1.0.7.tar.gz (4.0 kB view hashes)

Uploaded Source

Built Distribution

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page