Class Asciidoctor::Block
In: lib/asciidoctor/block.rb
Parent: AbstractBlock

Public: Methods for managing blocks of Asciidoc content in a section.

Examples

  block = Asciidoctor::Block.new(parent, :paragraph, :source => '_This_ is a <test>')
  block.content
  => "<em>This</em> is a &lt;test&gt;"

Methods

content   new   source   to_s  

Constants

DEFAULT_CONTENT_MODEL = { # TODO should probably fill in all known blocks :audio => :empty, :image => :empty, :listing => :verbatim, :literal => :verbatim, :stem => :raw, :open => :compound, :page_break => :empty, :pass => :raw, :thematic_break => :empty, :video => :empty

External Aliases

context -> blockname
  Public: Create alias for context to be consistent w/ AsciiDoc

Attributes

lines  [RW]  Public: Get/Set the original Array content for this block, if applicable

Public Class methods

Public: Initialize an Asciidoctor::Block object.

parent - The parent AbstractBlock with a compound content model to which this Block will be appended. context - The Symbol context name for the type of content (e.g., :paragraph). opts - a Hash of options to customize block initialization: (default: {})

                * :content_model indicates whether blocks can be nested in this Block (:compound), otherwise
                    how the lines should be processed (:simple, :verbatim, :raw, :empty). (default: :simple)
                * :attributes a Hash of attributes (key/value pairs) to assign to this Block. (default: {})
                * :source a String or Array of raw source for this Block. (default: nil)

IMPORTANT: If you don‘t specify the `:subs` option, you must explicitly call the `lock_in_subs` method to resolve and assign the substitutions to this block (which are resolved from the `subs` attribute, if specified, or the default substitutions based on this block‘s context). If you want to use the default subs for a block, pass the option `:subs => :default`. You can override the default subs using the `:default_subs` option.

Public Instance methods

Public: Get the converted result of the child blocks by converting the children appropriate to content model that this block supports.

Examples

  doc = Asciidoctor::Document.new
  block = Asciidoctor::Block.new(doc, :paragraph,
      :source => '_This_ is what happens when you <meet> a stranger in the <alps>!')
  block.content
  => "<em>This</em> is what happens when you &lt;meet&gt; a stranger in the &lt;alps&gt;!"

Public: Returns the preprocessed source of this block

Returns the a String containing the lines joined together or nil if there are no lines

[Validate]