class Asciidoctor::ListItem

Public: Methods for managing items for AsciiDoc olists, ulist, and dlists.

Attributes

marker[RW]

Public: Get/Set the String used to mark this list item

Public Class Methods

new(parent, text = nil) click to toggle source

Public: Initialize an Asciidoctor::ListItem object.

parent - The parent list block for this list item text - the String text (default nil)

Calls superclass method Asciidoctor::AbstractBlock.new
# File lib/asciidoctor/list.rb, line 47
def initialize parent, text = nil
  super parent, :list_item
  @text = text
  @level = parent.level
end

Public Instance Methods

fold_first(continuation_connects_first_block = false, content_adjacent = false) click to toggle source

Public: Fold the first paragraph block into the text

Here are the rules for when a folding occurs:

Given: this list item has at least one block When: the first block is a paragraph that's not connected by a list continuation Or: the first block is an indented paragraph that's adjacent (wrapped line) Or: the first block is an indented paragraph that's not connected by a list continuation Then: then drop the first block and fold it's content (buffer) into the list text

Returns nothing

# File lib/asciidoctor/list.rb, line 72
def fold_first(continuation_connects_first_block = false, content_adjacent = false)
  if (first_block = @blocks[0]) && first_block.is_a?(Block) &&
      ((first_block.context == :paragraph && !continuation_connects_first_block) ||
      ((content_adjacent || !continuation_connects_first_block) && first_block.context == :literal &&
          first_block.option?('listparagraph')))

    block = blocks.shift
    block.lines.unshift @text unless @text.nil_or_empty?
    @text = block.source
  end
  nil
end
text() click to toggle source
# File lib/asciidoctor/list.rb, line 57
def text
  apply_subs @text
end
text?() click to toggle source
# File lib/asciidoctor/list.rb, line 53
def text?
  !@text.nil_or_empty?
end
to_s() click to toggle source
# File lib/asciidoctor/list.rb, line 85
def to_s
  %Q(#<#{self.class}@#{object_id} {list_context: #{parent.context.inspect}, text: #{@text.inspect}, blocks: #{(@blocks || []).size}}>)
end