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 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

    Required Elements
    Modifier and Type
    Required Element
    Description
     
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static 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

      static final 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);
       
       

      See Also:
    • OPEN

      static final String 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

      static final String EXAMPLE
      Predefined constant for making a Processor work on example blocks.
       [foo]
       ====
       This is just a neat example.
       ====
       
      See Also:
    • LITERAL

      static final String LITERAL
      Predefined constant for making a Processor work on literal blocks.
       [foo]
       ....
       This is just a literal block.
       ....
       
      See Also:
    • LISTING

      static final String LISTING
      Predefined constant for making a Processor work on source blocks.
       [foo]
       ....
       This is just a literal block.
       ....
       
      See Also:
    • QUOTE

      static final String QUOTE
      Predefined constant for making a Processor work on quote blocks.
       [foo]
       ____
       To be or not to be...
       ____
       
      See Also:
    • PASS

      static final String PASS
      Predefined constant for making a Processor work on passthrough blocks.
       [foo]
       ++++
       <h1>Big text</h1>
       ++++
       
      See Also:
    • PARAGRAPH

      static final String PARAGRAPH
      Predefined constant for making a Processor work on paragraph blocks.
       [foo]
       Please process this paragraph.
      
       And don't process this.
       
      See Also:
    • OLIST

      static final String OLIST
      Predefined constant for making a Processor work on ordered lists.
       1. First item
       2. Second item
       
      See Also:
    • ULIST

      static final String ULIST
      Predefined constant for making a Processor work on unordered lists.
       . First item
       . Second item
       
      See Also:
    • COLIST

      static final String COLIST
      Predefined constant for making a Processor work on unordered lists.
       . First item
       . Second item
       
      See Also:
    • DLIST

      static final String DLIST
      Predefined constant for making a Processor work on unordered lists.
       First:: The first item
       Second:: The second item
       
      See Also:
  • Element Details