def self.build_block(block_context, content_type, terminator, parent, reader, attributes, options = {})
if terminator.nil?
if content_type == :verbatim
buffer = reader.grab_lines_until(:break_on_blank_lines => true, :break_on_list_continuation => true)
else
buffer = reader.grab_lines_until(
:break_on_blank_lines => true,
:break_on_list_continuation => true,
:preserve_last_line => true,
:skip_line_comments => true) {|line|
COMPLIANCE[:block_terminates_paragraph] && (is_delimited_block?(line) || line.match(REGEXP[:attr_line]))
}
end
elsif content_type != :complex
buffer = reader.grab_lines_until(:terminator => terminator, :chomp_last_line => true)
elsif terminator == false
buffer = nil
block_reader = reader
else
buffer = nil
block_reader = Reader.new reader.grab_lines_until(:terminator => terminator)
end
if content_type == :verbatim && attributes.has_key?('indent')
reset_block_indent! buffer, attributes['indent'].to_i
end
block = Block.new(parent, block_context, buffer)
if options.fetch(:supports_caption, false)
block.title = attributes.delete('title') if attributes.has_key?('title')
block.assign_caption attributes.delete('caption')
end
if buffer.nil?
while block_reader.has_more_lines?
parsed_block = next_block(block_reader, block)
block.blocks << parsed_block unless parsed_block.nil?
end
end
block
end