Even if the library is part of the AsciidoctorJ project, there is a separate java library called: asciidoctorj-diagram
(the java version of asciidoctor-diagram
)
Are you sure that you have asciidoctorj-diagram
on your classpath? Here the maven coordinates:
<dependency>
<groupId>org.asciidoctor</groupId>
<artifactId>asciidoctorj-diagram</artifactId>
<version>1.3.1</version>
</dependency>
You also need to tell Asciidoctor that asciidoctor-diagram
is required. See line <1>
in the following plain java example:
public static void main(String[] args) {
org.asciidoctor.Asciidoctor asciidoctor =
org.asciidoctor.Asciidoctor.Factory.create();
asciidoctor.requireLibrary("asciidoctor-diagram"); // <1>
StringBuilder sb = new StringBuilder();
sb.append("== Diagrams\n");
sb.append("\n");
sb.append("[plantuml,auth-protocol]\n");
sb.append("....\n");
sb.append("Alice -> Bob: Authentication Request\n");
sb.append("Bob --> Alice: Authentication Response\n");
sb.append("\n");
sb.append("Alice -> Bob: Another authentication Request\n");
sb.append("Alice <-- Bob: another authentication Response\n");
sb.append("....\n");
String html = asciidoctor.convert(sb.toString(),
new java.util.HashMap<String, Object>());
System.out.println(html);
}
By the way, there is also a maven example: asciidoctor-diagram-example. But this example requires the asciidoctor-maven-plugin
which is similar to the gradle plugin.