org.asciidoctor.extension.Contexts Maven / Gradle / Ivy
package org.asciidoctor.extension;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* This annotation defines what type of blocks a BlockProcessor processes.
* Example for a BlockProcessor that transforms all open blocks with the name {@code 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
*
*/
@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
public @interface Contexts {
/**
* 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);
*
*
*
*/
String KEY = "contexts";
/**
* 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.
* --
*
*/
String OPEN = ":open";
/**
* Predefined constant for making a Processor work on example blocks.
*
* [foo]
* ====
* This is just a neat example.
* ====
*
*/
String EXAMPLE = ":example";
/**
* Predefined constant for making a Processor work on sidebar blocks.
*
* [foo]
* ****
* This is just a sidebar.
* ****
*
*/
String SIDEBAR = ":sidebar";
/**
* Predefined constant for making a Processor work on literal blocks.
*
* [foo]
* ....
* This is just a literal block.
* ....
*
*/
String LITERAL = ":literal";
/**
* Predefined constant for making a Processor work on source blocks.
*
* [foo]
* ....
* This is just a literal block.
* ....
*
*/
String LISTING = ":listing";
/**
* Predefined constant for making a Processor work on quote blocks.
*
* [foo]
* ____
* To be or not to be...
* ____
*
*/
String QUOTE = ":quote";
/**
* Predefined constant for making a Processor work on passthrough blocks.
*
*
* [foo]
* ++++
* <h1>Big text</h1>
* ++++
*
*/
String PASS = ":pass";
/**
* Predefined constant for making a Processor work on paragraph blocks.
*
*
* [foo]
* Please process this paragraph.
*
* And don't process this.
*
*/
String PARAGRAPH = ":paragraph";
/**
* Predefined constant for making a Processor work on ordered lists.
*
*
* 1. First item
* 2. Second item
*
*/
String OLIST = ":olist";
/**
* Predefined constant for making a Processor work on unordered lists.
*
*
* . First item
* . Second item
*
*/
String ULIST = ":ulist";
/**
* Predefined constant for making a Processor work on unordered lists.
*
*
* . First item
* . Second item
*
*/
String COLIST = ":colist";
/**
* Predefined constant for making a Processor work on unordered lists.
*
*
* First:: The first item
* Second:: The second item
*
*/
String DLIST = ":dlist";
String[] value();
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy