Class | Asciidoctor::AbstractBlock |
In: |
lib/asciidoctor/abstract_block.rb
|
Parent: | AbstractNode |
blocks | [R] | Public: Get the Array of Asciidoctor::AbstractBlock sub-blocks for this block |
caption | [RW] | Public: Get/Set the caption for this block |
content_model | [RW] | Public: The types of content that this block can accomodate |
level | [RW] | Public: Set the Integer level of this Section or the Section level in which this Block resides |
source_location | [RW] | Public: Gets/Sets the location in the AsciiDoc source where this block begins |
style | [RW] | Public: Get/Set the String style (block type qualifier) for this block. |
subs | [R] | Public: Substitutions to be applied to content in this block |
title | [W] | Public: Set the String block title. |
Public: Append a content block to this block‘s list of blocks.
block - The new child block.
Examples
block = Block.new(parent, :preamble, :content_model => :compound) block << Block.new(block, :paragraph, :source => 'p1') block << Block.new(block, :paragraph, :source => 'p2') block.blocks? # => true block.blocks.size # => 2
Returns The parent Block
Public: Generate a caption and assign it to this block if one is not already assigned.
If the block has a title and a caption prefix is available for this block, then build a caption from this information, assign it a number and store it to the caption attribute on the block.
If an explicit caption has been specified on this block, then do nothing.
key - The prefix of the caption and counter attribute names.
If not provided, the name of the context for this block is used. (default: nil).
Returns nothing
Internal: Assign the next index (0-based) to this section
Assign the next index of this section within the parent Block (in document order)
Returns nothing
Public: Convenience method that returns the interpreted title of the Block with the caption prepended.
Concatenates the value of this Block‘s caption instance variable and the return value of this Block‘s title method. No space is added between the two values. If the Block does not have a caption, the interpreted title is returned.
Returns the String title prefixed with the caption, or just the title if no caption is set
Public: Get the converted result of the child blocks by converting the children appropriate to content model that this block supports.
Public: Update the context of this block.
This method changes the context of this block. It also updates the node name accordingly.
Public: Query for all descendant block nodes in the document tree that match the specified Symbol filter_context and, optionally, the style and/or role specified in the options Hash. If a block is provided, it‘s used as an additional filter. If no filters are specified, all block nodes in the tree are returned.
Examples
doc.find_by context: :section #=> Asciidoctor::Section@14459860 { level: 0, title: "Hello, AsciiDoc!", blocks: 0 } #=> Asciidoctor::Section@14505460 { level: 1, title: "First Section", blocks: 1 } doc.find_by(context: :section) {|section| section.level == 1 } #=> Asciidoctor::Section@14505460 { level: 1, title: "First Section", blocks: 1 } doc.find_by context: :listing, style: 'source' #=> Asciidoctor::Block@13136720 { context: :listing, content_model: :verbatim, style: "source", lines: 1 }
Returns An Array of block nodes that match the given selector or an empty Array if no matches are found
Internal: Reassign the section indexes
Walk the descendents of the current Document or Section and reassign the section 0-based index value to each Section as it appears in document order.
IMPORTANT You must invoke this method on a node after removing child sections or else the internal counters will be off.
Returns nothing
Public: Get the Array of child Section objects
Only applies to Document and Section instances
Examples
doc << (sect1 = Section.new doc, 1, false) sect1.title = 'Section 1' para1 = Block.new sect1, :paragraph, :source => 'Paragraph 1' para2 = Block.new sect1, :paragraph, :source => 'Paragraph 2' sect1 << para1 << para2 sect1 << (sect1_1 = Section.new sect1, 2, false) sect1_1.title = 'Section 1.1' sect1_1 << (Block.new sect1_1, :paragraph, :source => 'Paragraph 3') sect1.blocks? # => true sect1.blocks.size # => 3 sect1.sections.size # => 1
Public: A convenience method that checks whether the specified substitution is enabled for this block.
name - The Symbol substitution name
Returns A Boolean indicating whether the specified substitution is enabled for this block
Public: Get the String title of this Block with title substitions applied
The following substitutions are applied to block and section titles:
:specialcharacters, :quotes, :replacements, :macros, :attributes and :post_replacements
Examples
block.title = "Foo 3^ # {two-colons} Bar(1)" block.title => "Foo 3^ # :: Bar(1)"