Package org.asciidoctor.extension
Annotation Type Contexts
This annotation defines what type of blocks a BlockProcessor processes.
Example for a BlockProcessor that transforms all open blocks with the name
yell
to upper case:
@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)
}
}
Applicable for:
BlockMacroProcessor | |
BlockProcessor | ✓ |
BlockProcessor | |
DocInfoProcessor | |
IncludeProcessor | |
InlineMacroProcessor | |
Postprocessor | |
Preprocessor | |
Treeprocessor |
-
Required Element Summary
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
Predefined constant for making a Processor work on unordered lists.static final String
Predefined constant for making a Processor work on unordered lists.static final String
Predefined constant for making a Processor work on example blocks.static final String
This value is used as the config option key when defining the block type a Processor should process.static final String
Predefined constant for making a Processor work on source blocks.static final String
Predefined constant for making a Processor work on literal blocks.static final String
Predefined constant for making a Processor work on ordered lists.static final String
Predefined constant for making a Processor work on open blocks.static final String
Predefined constant for making a Processor work on paragraph blocks.static final String
Predefined constant for making a Processor work on passthrough blocks.static final String
Predefined constant for making a Processor work on quote blocks.static final String
Predefined constant for making a Processor work on sidebar blocks.static final String
Predefined constant for making a Processor work on unordered lists.
-
Field Details
-
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); - See Also:
-
OPEN
Predefined constant for making a Processor work on open blocks.[foo] -- An open block can be an anonymous container, or it can masquerade as any other block. --
- See Also:
-
EXAMPLE
Predefined constant for making a Processor work on example blocks.[foo] ==== This is just a neat example. ====
- See Also:
-
SIDEBAR
Predefined constant for making a Processor work on sidebar blocks.[foo] **** This is just a sidebar. ****
- See Also:
-
LITERAL
Predefined constant for making a Processor work on literal blocks.[foo] .... This is just a literal block. ....
- See Also:
-
LISTING
Predefined constant for making a Processor work on source blocks.[foo] .... This is just a literal block. ....
- See Also:
-
QUOTE
Predefined constant for making a Processor work on quote blocks.[foo] ____ To be or not to be... ____
- See Also:
-
PASS
Predefined constant for making a Processor work on passthrough blocks.[foo] ++++ <h1>Big text</h1> ++++
- See Also:
-
PARAGRAPH
Predefined constant for making a Processor work on paragraph blocks.[foo] Please process this paragraph. And don't process this.
- See Also:
-
OLIST
Predefined constant for making a Processor work on ordered lists.1. First item 2. Second item
- See Also:
-
ULIST
Predefined constant for making a Processor work on unordered lists.. First item . Second item
- See Also:
-
COLIST
Predefined constant for making a Processor work on unordered lists.. First item . Second item
- See Also:
-
DLIST
Predefined constant for making a Processor work on unordered lists.First:: The first item Second:: The second item
- See Also:
-
-
Element Details
-
value
String[] value
-