Class BaseProcessor

    • Constructor Detail

      • BaseProcessor

        public BaseProcessor()
      • BaseProcessor

        public BaseProcessor​(java.util.Map<java.lang.String,​java.lang.Object> config)
    • Method Detail

      • getConfig

        public java.util.Map<java.lang.String,​java.lang.Object> getConfig()
        Specified by:
        getConfig in interface Processor
      • setConfig

        public final void setConfig​(java.util.Map<java.lang.String,​java.lang.Object> config)
        Specified by:
        setConfig in interface Processor
      • updateConfig

        public final void updateConfig​(java.util.Map<java.lang.String,​java.lang.Object> config)
        Specified by:
        updateConfig in interface Processor
      • unwrap

        public final <T> T unwrap​(java.lang.Class<T> clazz)
        Specified by:
        unwrap in interface Processor
      • createTableColumn

        public Column createTableColumn​(Table parent,
                                        int index,
                                        java.util.Map<java.lang.String,​java.lang.Object> attributes)
        Specified by:
        createTableColumn in interface Processor
      • createTableCell

        public Cell createTableCell​(Column column,
                                    Document innerDocument,
                                    java.util.Map<java.lang.String,​java.lang.Object> attributes)
        Specified by:
        createTableCell in interface Processor
      • createTableCell

        public Cell createTableCell​(Column column,
                                    java.lang.String text,
                                    java.util.Map<java.lang.String,​java.lang.Object> attributes)
        Specified by:
        createTableCell in interface Processor
      • createPhraseNode

        public PhraseNode createPhraseNode​(ContentNode parent,
                                           java.lang.String context,
                                           java.util.List<java.lang.String> text,
                                           java.util.Map<java.lang.String,​java.lang.Object> attributes,
                                           java.util.Map<java.lang.Object,​java.lang.Object> options)
        Specified by:
        createPhraseNode in interface Processor
      • createPhraseNode

        public PhraseNode createPhraseNode​(ContentNode parent,
                                           java.lang.String context,
                                           java.lang.String text,
                                           java.util.Map<java.lang.String,​java.lang.Object> attributes,
                                           java.util.Map<java.lang.String,​java.lang.Object> options)
        Specified by:
        createPhraseNode in interface Processor
      • createBlock

        public Block createBlock​(StructuralNode parent,
                                 java.lang.String context,
                                 java.util.Map<java.lang.Object,​java.lang.Object> options)
        Specified by:
        createBlock in interface Processor
      • createSection

        public Section createSection​(StructuralNode parent,
                                     java.lang.Integer level,
                                     boolean numbered,
                                     java.util.Map<java.lang.Object,​java.lang.Object> options)
        Specified by:
        createSection in interface Processor
      • createDocument

        public Document createDocument​(Document parentDocument)
        Description copied from interface: Processor
        Creates an inner document for the given parent document. Inner documents are used for tables cells with style asciidoc.
        Specified by:
        createDocument in interface Processor
        Parameters:
        parentDocument - The parent document of the new document.
        Returns:
        A new inner document.
      • createList

        public List createList​(StructuralNode parent,
                               java.lang.String context)
        Description copied from interface: Processor
        Creates a new List. This method is experimental and may change in future minor releases until declared to be stable.
        Specified by:
        createList in interface Processor
        Parameters:
        parent - The block to which the parsed content should be added as children.
        context - Either "olist", ulist, colist or dlist
        Returns:
        A List node that can be added to the AST of a document.
      • createList

        public List createList​(StructuralNode parent,
                               java.lang.String context,
                               java.util.Map<java.lang.String,​java.lang.Object> attributes,
                               java.util.Map<java.lang.Object,​java.lang.Object> options)
        Description copied from interface: Processor
        Creates a new List. This method is experimental and may change in future minor releases until declared to be stable.
        Specified by:
        createList in interface Processor
        Parameters:
        parent - The block to which the parsed content should be added as children.
        context - Either "olist", ulist, colist or dlist
        attributes - Additional attributes to be set on the new list node, e.g. Collections.singletonMap("start", "2").
        options - Additional options to be set on the new list node.
        Returns:
        A List node that can be added to the AST of a document.
      • createList

        public List createList​(StructuralNode parent,
                               java.lang.String context,
                               java.util.Map<java.lang.Object,​java.lang.Object> options)
        Description copied from interface: Processor
        Creates a new List. This method is experimental and may change in future minor releases until declared to be stable.
        Specified by:
        createList in interface Processor
        Parameters:
        parent - The block to which the parsed content should be added as children.
        context - Either "olist", ulist, colist or dlist
        options - Additional options to be set on the new list node.
        Returns:
        A List node that can be added to the AST of a document.
      • parseContent

        public void parseContent​(StructuralNode parent,
                                 java.util.List<java.lang.String> lines)
        Description copied from interface: Processor
        Parses the given raw asciidoctor content, parses it and appends it as children to the given parent block.

        The following example will add two paragraphs with the role newcontent to all top level sections of a document:

             
         Asciidoctor asciidoctor = ...
         asciidoctor.javaExtensionRegistry().treeprocessor(new Treeprocessor() {
             DocumentRuby process(DocumentRuby document) {
                 for (AbstractBlock block: document.getBlocks()) {
                     if (block instanceof Section) {
                         parseContent(block, Arrays.asList(new String[]{
                                                     "[newcontent]",
                                                     "This is new content"
                                                     "",
                                                     "[newcontent]",
                                                     "This is also new content"}));
                     }
                 }
             }
         });
             
         
        Specified by:
        parseContent in interface Processor
        Parameters:
        parent - The block to which the parsed content should be added as children.
        lines - Raw asciidoctor content
      • newCursor

        public Cursor newCursor​(java.lang.String file,
                                java.lang.String dir)
        Specified by:
        newCursor in interface Processor
      • newCursor

        public Cursor newCursor​(java.lang.String file,
                                java.lang.String dir,
                                int lineno)
        Specified by:
        newCursor in interface Processor
      • newReader

        public Reader newReader​(java.util.List<java.lang.String> source,
                                Cursor cursor,
                                java.util.Map<java.lang.Object,​java.lang.Object> options)
        Specified by:
        newReader in interface Processor
      • newReader

        public Reader newReader​(java.util.List<java.lang.String> source,
                                java.util.Map<java.lang.Object,​java.lang.Object> options)
        Specified by:
        newReader in interface Processor
      • newReader

        public Reader newReader​(java.util.List<java.lang.String> source)
        Specified by:
        newReader in interface Processor
      • createBlock

        public Block createBlock​(StructuralNode parent,
                                 java.lang.String context,
                                 java.lang.String content,
                                 java.util.Map<java.lang.String,​java.lang.Object> attributes)
        Specified by:
        createBlock in interface Processor
      • createBlock

        public Block createBlock​(StructuralNode parent,
                                 java.lang.String context,
                                 java.lang.String content,
                                 java.util.Map<java.lang.String,​java.lang.Object> attributes,
                                 java.util.Map<java.lang.Object,​java.lang.Object> options)
        Specified by:
        createBlock in interface Processor
      • createBlock

        public Block createBlock​(StructuralNode parent,
                                 java.lang.String context,
                                 java.util.List<java.lang.String> content,
                                 java.util.Map<java.lang.String,​java.lang.Object> attributes)
        Specified by:
        createBlock in interface Processor
      • createBlock

        public Block createBlock​(StructuralNode parent,
                                 java.lang.String context,
                                 java.util.List<java.lang.String> content,
                                 java.util.Map<java.lang.String,​java.lang.Object> attributes,
                                 java.util.Map<java.lang.Object,​java.lang.Object> options)
        Specified by:
        createBlock in interface Processor
      • createSection

        public Section createSection​(StructuralNode parent,
                                     int level,
                                     boolean numbered,
                                     java.util.Map<java.lang.Object,​java.lang.Object> options)
        Specified by:
        createSection in interface Processor
      • createPhraseNode

        public PhraseNode createPhraseNode​(ContentNode parent,
                                           java.lang.String context,
                                           java.util.List<java.lang.String> text,
                                           java.util.Map<java.lang.String,​java.lang.Object> attributes)
        Specified by:
        createPhraseNode in interface Processor
      • createPhraseNode

        public PhraseNode createPhraseNode​(ContentNode parent,
                                           java.lang.String context,
                                           java.lang.String text,
                                           java.util.Map<java.lang.String,​java.lang.Object> attributes)
        Specified by:
        createPhraseNode in interface Processor