Package org.asciidoctor.extension
Annotation Type Contexts
-
@Documented @Retention(RUNTIME) @Target(TYPE) public @interface Contexts
This annotation defines what type of blocks a BlockProcessor processes. Example for a BlockProcessor that transforms all open blocks with the nameyell
to upper case:
Applicable for:@Name("yell") @Contexts(Contexts.OPEN) @ContentModel(ContentModel.SIMPLE) class YellBlockProcessor extends BlockProcessor { public YellBlockProcessor(String blockName) { super(blockName); } public Object process(StructuralNode parent, Reader reader, Map<String, Object> attributes) { List<String> lines = reader.readLines(); List<String> newLines = new ArrayList<>(); for (String line: lines) { newLines.add(line.toUpperCase()); } return createBlock(parent, 'paragraph', newLines) } }
BlockMacroProcessor BlockProcessor ✓ BlockProcessor DocInfoProcessor IncludeProcessor InlineMacroProcessor Postprocessor Preprocessor Treeprocessor
-
-
Field Summary
Fields Modifier and Type Fields Description static java.lang.String
COLIST
Predefined constant for making a Processor work on unordered lists.static java.lang.String
DLIST
Predefined constant for making a Processor work on unordered lists.static java.lang.String
EXAMPLE
Predefined constant for making a Processor work on example blocks.static java.lang.String
KEY
This value is used as the config option key when defining the block type a Processor should process.static java.lang.String
LISTING
Predefined constant for making a Processor work on source blocks.static java.lang.String
LITERAL
Predefined constant for making a Processor work on literal blocks.static java.lang.String
OLIST
Predefined constant for making a Processor work on ordered lists.static java.lang.String
OPEN
Predefined constant for making a Processor work on open blocks.static java.lang.String
PARAGRAPH
Predefined constant for making a Processor work on paragraph blocks.static java.lang.String
PASS
Predefined constant for making a Processor work on passthrough blocks.static java.lang.String
QUOTE
Predefined constant for making a Processor work on quote blocks.static java.lang.String
SIDEBAR
Predefined constant for making a Processor work on sidebar blocks.static java.lang.String
ULIST
Predefined constant for making a Processor work on unordered lists.
-
Required Element Summary
Required Elements Modifier and Type Required Element Description java.lang.String[]
value
-
-
-
Field Detail
-
KEY
static final java.lang.String KEY
This value is used as the config option key when defining the block type a Processor should process. Its value must be a list of String constants:Example to make a BlockProcessor work on listings and examples named foo:
Map<String, Object> config = new HashMap<>(); config.put(Contexts.KEY, Arrays.asList(Contexts.EXAMPLE, Contexts.LISTING)); BlockProcessor blockProcessor = new BlockProcessor("foo", config); asciidoctor.javaExtensionRegistry().block(blockProcessor);
-
-