@asciidoctor/core
    Preparing search index...

    Class BlockProcessor

    BlockProcessors handle delimited blocks and paragraphs with a custom name.

    The process(parent, reader, attributes) method receives:

    • parent {AbstractBlock} — the enclosing block
    • reader {Reader} — positioned at the block content
    • attributes {Object} — parsed block attributes

    It must return a block node (created with this.createBlock(...), etc.) or call this.parseContent(parent, reader) to delegate parsing.

    Use the static config object or the DSL helpers (contexts(), contentModel(), resolveAttributes(), …) to declare the block's behaviour before registering.

    Implementations must extend BlockProcessor and override process.

    class ShoutBlock extends BlockProcessor {
    process(parent, reader, attrs) {
    const block = this.createBlock(parent, 'paragraph', reader.readLines().join('\n').toUpperCase(), attrs)
    return block
    }
    }
    ShoutBlock.config = { name: 'shout', contexts: ['paragraph'], content_model: 'simple' }
    Extensions.register(function () { this.block(ShoutBlock) })
    // AsciiDoc usage: [shout]\nHello world

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    config: any
    name: any

    Accessors

    • get config(): object

      Get the static configuration map for this processor class. Uses hasOwnProperty to avoid inheriting a parent class's config object through the prototype chain when a subclass first accesses config.

      Returns object

    Methods

    • Create a generic block node and link it to the specified parent.

      Parameters

      • parent: Section | Block

        The parent node.

      • context: string

        The block context (e.g. 'paragraph', 'listing').

      • source: string | string[]

        The source content.

      • attrs: object

        A plain object of attributes.

      • Optionalopts: object

        An optional plain object of options.

      Returns Block

      a Block node with all properties properly initialized.

    • Create an image block node and link it to the specified parent.

      Parameters

      • parent: Document | Section | Block

        The parent of this new image block.

      • attrs: object

        A plain object of attributes to control how the image block is built. The target attribute sets the image source; alt sets the alt text.

      • Optionalopts: object

        An optional plain object of options.

      Returns Block

      a Block node with all properties properly initialized.

    • Create an inline node and bind it to the specified parent.

      Parameters

      • parent: Block

        The parent Block of this new inline node.

      • context: string

        The context of the inline node ('quoted', 'anchor', etc.).

      • text: string

        The text of the inline node.

      • Optionalopts: object

        An optional plain object of options:

        • type {string} - The subtype of the inline node context.
        • attributes {object} - Attributes to set on the inline node.

      Returns Inline

      an Inline node with all properties properly initialized.

    • Create a list node and link it to the specified parent.

      Parameters

      • parent: Document | Section | Block

        The parent of this new list.

      • context: string

        The list context ('ulist', 'olist', 'colist', 'dlist').

      • Optionalattrs: object

        A plain object of attributes to set on this list block.

      Returns List

      a List node with all properties properly initialized.

    • Create a list item node and link it to the specified parent.

      Parameters

      • parent: List

        The parent List of this new list item.

      • Optionaltext: string

        The text of the list item.

      Returns ListItem

      a ListItem node with all properties properly initialized.

    • Create a Section node in the same manner as the parser.

      Parameters

      • parent: Document | Section

        The parent Section or Document of this new Section.

      • title: string

        The String title of the new Section.

      • attrs: object

        A plain object of attributes to control how the section is built. Use the style attribute to set the name of a special section (e.g. appendix). Use the id attribute to assign an explicit ID, or set it to false to disable automatic ID generation (when sectids document attribute is set).

      • Optionalopts: object

        An optional plain object of options:

        • level {number} - The Integer level to assign; defaults to parent.level + 1.
        • numbered {boolean} - Flag to force numbering.

      Returns Section

      a Section node with all properties properly initialized.

    • Parse the attrlist String into a plain object of attributes.

      Parameters

      • block: Section | Block

        The current block (used for applying subs).

      • attrlist: string

        The list of attributes as a String.

      • Optionalopts: object

        An optional plain object of options:

        • positional_attributes {string[]} - Array of attribute names to map positional args to.
        • sub_attributes {boolean} - Enables attribute substitution on attrlist.

      Returns Promise<object>

      a plain object of parsed attributes.

    • Parameters

      • _parent: any
      • _reader: any
      • _attributes: any

      Returns void

    • Set a default option value for all instances of this processor class.

      Parameters

      • key: string

        The option key.

      • value: any

        The option value.

      Returns void