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
    • 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);
         
         

      • OPEN

        static final java.lang.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.
         --
         
      • EXAMPLE

        static final java.lang.String EXAMPLE
        Predefined constant for making a Processor work on example blocks.
         [foo]
         ====
         This is just a neat example.
         ====
         
      • SIDEBAR

        static final java.lang.String SIDEBAR
        Predefined constant for making a Processor work on sidebar blocks.
         [foo]
         ****
         This is just a sidebar.
         ****
         
      • LITERAL

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

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

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

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

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

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

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

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

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

      • value

        java.lang.String[] value