#mdbook #proprocessor #diagram #kroki

app mdbook-kroki-preprocessor

render kroki diagrams from files or code blocks in mdbook

3 releases

0.1.2 Aug 29, 2022
0.1.1 Jun 19, 2022
0.1.0 Apr 22, 2022

#355 in Text processing

Download history 3/week @ 2022-12-06 7/week @ 2022-12-13 2/week @ 2022-12-20 1/week @ 2022-12-27 7/week @ 2023-01-03 35/week @ 2023-01-10 18/week @ 2023-01-17 24/week @ 2023-01-24 12/week @ 2023-01-31 11/week @ 2023-02-07 11/week @ 2023-02-14 9/week @ 2023-02-21 11/week @ 2023-02-28 7/week @ 2023-03-14 32/week @ 2023-03-21

54 downloads per month

Custom license and GPL-3.0 licenses

228 lines


An mdbook preprocessor that lets you embed diagrams from any of Kroki's diagram types into your book.


First install this preprocessor with cargo install mdbook-kroki-preprocessor.

Then add the preprocessor to your book.toml:

authors = ["You"]
language = "en"
multilingual = false
src = "src"
title = "example"



There are two ways to use Kroki in your book. First is a fenced code block:

graph TD
  A[ Anyone ] -->|Can help | B( Go to github.com/yuzutech/kroki )
  B --> C{ How to contribute? }
  C --> D[ Reporting bugs ]
  C --> E[ Sharing ideas ]
  C --> F[ Advocating ]

The code block's language has to be kroki-<diagram type>.

The other method is to use an image tag, for diagrams contents that are too big to put inline in the markdown (such as for excalidraw):

![Excalidraw example](kroki-excalidraw:example.excalidraw)

The title field can be anything, but the source field needs to start with kroki-<diagram type>:. Both relative and absolute paths are supported. Relative paths are relative to the current markdown source file, not the root of the mdbook.

The preprocessor will collect all Kroki diagrams of both types, send requests out in parallel to the appropriate Kroki API endpoint, and replace their SVG contents back into the markdown.

Endpoint Configuration

If you'd like to use a self-managed instance of Kroki, you can configure the preprocessor to use a different endpoint:

endpoint = "http://localhost:8000"

The preprocessor will add a trailing slash if needed. The default is "https://kroki.io/".


This preprocessor only supports HTML rendering.


~864K SLoC