Extensions API
One of the major improvements to Asciidoctor recently is the extensions API. AsciidoctorJ brings this extension API to the JVM environment allowing us to write extensions in Java instead of Ruby.
If you are migrating existing extensions to a newer version, please see the guides: |
Writing an extension is as simple as creating a Java class and sub-classing from one of the extension points. However, to explore the full potential it us recommended to:
-
Have a brief understanding of the AsciidoctorJ conversion process and internal representation of the document. In short, extensions allow you to tap into the conversion process to make modifications to enhance the generated content.
-
Write an extension class. This is as simple as creating a sub-class from one of the extension points listed below.
-
Register your class to make AsciidoctorJ converter aware of it. There several options depending on the use case.
Asciidoctor provides eight types of extension points. Each extension point has an abstract class in Java that maps to the extension API in Ruby.
Name | Class | Description |
---|---|---|
|
Intercepts |
|
|
Allows you to modify the asciidoc text before parsing |
|
|
Processes block macros like |
|
|
Processes an arbitrary block based on it’s style such as [prohibited] -- Do not enter -- |
|
|
Modify the AST after parsing. |
|
|
Processes inline macros like |
|
|
Modifies the backend-specific output document. |
|
|
Insert content into the |