Crates.io | mdbook-plantuml |
lib.rs | mdbook-plantuml |
version | 0.8.0 |
source | src |
created_at | 2019-07-08 09:16:21.32666 |
updated_at | 2022-07-04 20:11:34.296154 |
description | A preprocessor for mdbook which will convert plantuml code blocks into inline SVG diagrams |
homepage | |
repository | https://github.com/sytsereitsma/mdbook-plantuml |
max_upload_size | |
id | 147487 |
size | 200,042 |
mdBook preprocessor to render PlantUML code blocks as images in your book.
First create the preprocessor in your book.toml file:
[book]
authors = ["Dzjengis Khan"]
multilingual = false
src = "src"
title = "mdBook PlantUML preprocessor"
[preprocessor.plantuml]
plantuml-cmd="plantuml.exe"
The above assumes both the mdbook-preprocessor and the plantuml executable are on your path.
Then simply add a PlantUML code block in your book text:
Some text here
```plantuml
@startuml
A --|> B
@enduml
```
Some more text.
The plantuml code block will be replaced an image reference to an SVG image if possible, or png if PlantUML does not support svg for the requested diagram type (i.e. ditaa).
The image is svg, or png by default, depending on the diagram type. If desired it can be changed to another one of PlantUMLs output formats (note that some formats are not supported by all browsers and or PlantUML server implementations).
See https://plantuml.com/command-line (Types of Output File) for available formats. mdbook-plantuml uses the short param name (case sensitive, without the '-')
A diagram in UTF-8 text format (inlined automatically)
```plantuml,format=utxt
@startuml
A --|> B
@enduml
```
Force png format:
```plantuml,format=png
@startuml
A --|> B
@enduml
```
false
by default). When true
images can be clicked and are opened in a new tab/window.false
by default). When true
images are rendered as inline Data URIs (not requiring external files).Examples:
Install without server support:
cargo install mdbook-plantuml --no-default-features
Install with http server support:
cargo install mdbook-plantuml --no-default-features --features plantuml-server
Install with https server support:
cargo install mdbook-plantuml --no-default-features --features plantuml-ssl-server
[book]
authors = ["Chuck Norris"]
multilingual = false
src = "src"
title = "mdBook PlantUML preprocessor"
[preprocessor.plantuml]
plantuml-cmd="plantuml"
use-data-uris=true
Below is an example server configuration.
You can test your server by appending the URL with "/png/SoWkIImgAStDuGh8ISmh2VNrKT3LhR5J24ujAaijud98pKi1IW80". Using the example below this example you'd end up with this URL. When it is working correctly you should see the following image:
[book]
authors = ["Dzjengis Khan"]
multilingual = false
src = "src"
title = "mdBook PlantUML preprocessor"
[preprocessor.plantuml]
plantuml-cmd="http://localhost:8080/plantuml"
mdBook communicates to the preprocessor using stdio. As a result log output from the preprocessor is not printed to the screen. When the preprocessor's markdown error output is insufficient for you it is possible to redirect logging to the file ./output.log by using the command line switch -l. See the config below for an example:
[book]
authors = ["Sytse Reitsma"]
multilingual = false
src = "src"
title = "mdBook E2E test book"
[preprocessor.plantuml]
plantuml-cmd="http://localhost:8080/plantuml"
command = "mdbook-plantuml -l"
puml
code blocks as an alternative to plantuml (native IDE support for various programs, credit @YushiOMOTE)mdbook serve
command.
Because the preprocessor output cannot be written directly to the book output
dir anymore the images need to be created in the src dir unfortunately (mdBook
change). You still end up with one extra rebuild when images are updated, I cannot
prevent this (the gitignore file of mdbook should be able to prevent this,
but it does not).
Issue #17I primarily work on Windows, and rust is not that portable yet apparently.
When you get the following error while installing/building mdbook-plantuml on Linux:
failed to run custom build command for `openssl-sys v0.9.49`
Make sure you have libssl-dev and pkg-config installed:
sudo apt update
sudo apt install libssl-dev pkg-config