class Asciidoctor::Block

> “This is a <test>”
block.content
block = Asciidoctor::Block.new(parent, :paragraph, source: ‘This is a <test>’)
Examples
Public: Methods for managing AsciiDoc content blocks.

def content

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

Examples

children appropriate to content model that this block supports.
Public: Get the converted result of the child blocks by converting the
def content
  case @content_model
  when :compound
    super
  when :simple
    apply_subs((@lines.join LF), @subs)
  when :verbatim, :raw
    # QUESTION could we use strip here instead of popping empty lines?
    # maybe apply_subs can know how to strip whitespace?
    result = apply_subs @lines, @subs
    if result.size < 2
      result[0] || ''
    else
      result.shift while (first = result[0]) && first.rstrip.empty?
      result.pop while (last = result[-1]) && last.rstrip.empty?
      result.join LF
    end
  else
    logger.warn %(unknown content model '#{@content_model}' for block: #{self}) unless @content_model == :empty
    nil
  end
end

def initialize parent, context, opts = {}

QUESTION should we store source_data as lines for blocks that have compound content models?
--
override the default subs using the `:default_subs` option.
default subs for a block, pass the option `subs: :default`. You can
default substitutions based on this block's context). If you want to use the
block (which are resolved from the `subs` attribute, if specified, or the
the `commit_subs` method to resolve and assign the substitutions to this
IMPORTANT: If you don't specify the `:subs` option, you must explicitly call

* :source a String or Array of raw source for this Block. (default: nil)
* :attributes a Hash of attributes (key/value pairs) to assign to this Block. (default: {})
how the lines should be processed (:simple, :verbatim, :raw, :empty). (default: :simple)
* :content_model indicates whether blocks can be nested in this Block (:compound), otherwise
opts - a Hash of options to customize block initialization: (default: {})
context - The Symbol context name for the type of content (e.g., :paragraph).
parent - The parent AbstractBlock with a compound content model to which this Block will be appended.

Public: Initialize an Asciidoctor::Block object.
def initialize parent, context, opts = {}
  super
  @content_model = opts[:content_model] || DEFAULT_CONTENT_MODEL[context]
  if opts.key? :subs
    # FIXME feels funky; we have to be defensive to get commit_subs to honor override
    # FIXME does not resolve substitution groups inside Array (e.g., [:normal])
    if (subs = opts[:subs])
      case subs
      # e.g., subs: :default
      # subs attribute is honored; falls back to opts[:default_subs], then built-in defaults based on context
      when :default
        @default_subs = opts[:default_subs]
      # e.g., subs: [:quotes]
      # subs attribute is not honored
      when ::Array
        @default_subs = subs.drop 0
        @attributes.delete 'subs'
      # e.g., subs: :normal or subs: 'normal'
      # subs attribute is not honored
      else
        @default_subs = nil
        @attributes['subs'] = subs.to_s
      end
      # resolve the subs eagerly only if subs option is specified
      # QUESTION should we skip subsequent calls to commit_subs?
      commit_subs
    # e.g., subs: nil
    else
      # NOTE @subs is initialized as empty array by super constructor
      # prevent subs from being resolved
      @default_subs = []
      @attributes.delete 'subs'
    end
  # defer subs resolution; subs attribute is honored
  else
    # NOTE @subs is initialized as empty array by super constructor
    # QUESTION should we honor :default_subs option (i.e., @default_subs = opts[:default_subs])?
    @default_subs = nil
  end
  if (raw_source = opts[:source]).nil_or_empty?
    @lines = []
  elsif ::String === raw_source
    @lines = Helpers.prepare_source_string raw_source
  else
    @lines = raw_source.drop 0
  end
end

def source

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

Public: Returns the preprocessed source of this block
def source
  @lines.join LF
end

def to_s

def to_s
  content_summary = @content_model == :compound ? %(blocks: #{@blocks.size}) : %(lines: #{@lines.size})
  %(#<#{self.class}@#{object_id} {context: #{@context.inspect}, content_model: #{@content_model.inspect}, style: #{@style.inspect}, #{content_summary}}>)
end