Processing pipeline
Extensions participate in processing in a defined order:Preprocessor
Runs after source lines are normalized but before parsing begins. Can modify or replace source lines. See Preprocessor.
IncludeProcessor
Intercepts
include::target[] directives. The first processor that claims a target handles it.Parser (BlockProcessor / BlockMacroProcessor)
The parser builds the abstract syntax tree (AST). Custom delimited blocks and block macros are handled by registered
BlockProcessor and BlockMacroProcessor instances. See Block processor.TreeProcessor
Runs on the fully-parsed AST. Ideal for analysis, transformation, or adding nodes. See Tree processor.
Conversion + InlineMacroProcessor
Conversion begins; inline markup is processed. Custom inline macros (
name:target[attrs]) are handled by InlineMacroProcessor instances. See Inline macro processor.Postprocessor
Receives the converted output as a String and can modify it before it is written. See Postprocessor.
Registering extensions
You can register extensions globally so they apply to every document, or pass a registry as a per-document option.- Global registration
- Per-document registry
- Extension Group class
Asciidoctor.convert or Asciidoctor.load is called. Remove all global registrations with:Minimal complete example
The following snippet registers one extension of each major type and converts a document:Extension types
Preprocessor
Modify source lines before parsing.
Include processor
Intercept
include::target[] directives to serve content from custom sources.Block processor
Handle custom delimited blocks and paragraphs.
Block macro processor
Handle custom block-level macros of the form
name::target[attrs].Inline macro processor
Handle custom inline macros of the form
name:target[attrs].Tree processor
Traverse and transform the parsed AST.
Postprocessor
Modify the converted output string.