Plugin
Asciibook has a plugin mechanism to extend its functions. You can modify asciidoc parsing, add macro processing, or use third-party themes through plugins.
Add the plugin by command line:
or in asciibook.yml
:
Plugin is Ruby Gem or Ruby script. For Ruby gem, use gem name as plugin value. For script file, use file path as plugin value.
Using plugin will actually execute the Ruby code in the plugin, which can extend any function of asciibook, but it may also cause security risks. This includes deleting documents or uploading sensitive information to third-party websites.
Make sure to only use asciibook to process trusted documents, and always build documents in a docker container.
Example 1: Ruby Gem
we can add asciidoctor-diagram
to support diagram.
First, install Ruby gem and Java runtime(require by ditaa) in container:
For difference diagram types need to install different dependencies, check the documentation for details:
https://docs.asciidoctor.org/diagram-extension/latest/#specifying-diagram-generator-paths
Then add config in asciibook.yml
:
Now we can use ditaa in asciidoc:
Build asciibook:
Ditaa source will generate a image.
Example 2: Ruby Script
If Ruby gem needs config, we can add a ruby script as plugin.
For example, asciidoctor-plantuml
is a plugin to use external server as plantuml generator.
First, install ruby gem:
Add this content to file plugins/plantuml.rb
:
Then add this file as plugin in asciibook.yml
:
Now asciibook will generate plantuml by plantuml.com .
Next Step
It should be noted that the dependencies installed in the container will disappear after exiting. To persist dependencies, you need to Build Docker Image.