Diagrams

You can use the Asciidoctor Kroki extension to render diagrams in your PDF. In this example, we create a file named piracy.adoc with the following content:

piracy.adoc
= Piracy

Piracy is an act of robbery or criminal violence by ship upon another ship,
typically with the goal of stealing rum and other valuable items or properties.

Here's what a pirate looks like!

[nomnoml]
....
[Pirate|eyeCount: Int|raid();pillage()|
  [beard]--[parrot]
  [beard]-:>[foul mouth]
]

[<abstract>Marauder]<:--[Pirate]
[Pirate]- 0..7[mischief]
[jollyness]->[Pirate]
[jollyness]->[rum]
[jollyness]->[singing]
[Pirate]-> *[rum|tastiness: Int|swig()]
[Pirate]->[singing]
[singing]<->[rum]
....

Kroki supports more than a dozen diagram libraries. In the above example, we are using the nomnoml UML diagram library.

You will need to install asciidoctor-kroki using npm i asciidoctor-kroki.

You can use the following command to generate a PDF:

asciidoctor-web-pdf --require asciidoctor-kroki piracy.adoc

Here’s the result: piracy.pdf