class Asciidoctor::ListItem
Public: Methods for managing items for AsciiDoc olists, ulist, and dlists.
In a description list (dlist), each item is a tuple that consists of a 2-item Array of ListItem terms and a ListItem description (i.e., [[term, term, …], desc]. If a description is not set, then the second entry in the tuple is nil.
Attributes
Public: Get/Set the String used to mark this list item
Public Class Methods
Source
# File lib/asciidoctor/list.rb, line 59 def initialize parent, text = nil super parent, :list_item @text = text @level = parent.level @subs = NORMAL_SUBS.drop 0 end
Public: Initialize an Asciidoctor::ListItem object.
parent - The parent list block for this list item text - the String text (default nil)
Asciidoctor::AbstractBlock::new
Public Instance Methods
Source
# File lib/asciidoctor/list.rb, line 98 def compound? !simple? end
Check whether this list item has compound content (nested blocks aside from a single outline list). Primarily relevant for outline lists.
Return true if the list item contains blocks other than a single outline list. Otherwise, return false.
Source
# File lib/asciidoctor/list.rb, line 105 def fold_first @text = @text.nil_or_empty? ? @blocks.shift.source : %(#{@text}#{LF}#{@blocks.shift.source}) nil end
Internal: Fold the adjacent paragraph block into the list item text
Returns nothing
Source
# File lib/asciidoctor/list.rb, line 90 def simple? @blocks.empty? || (@blocks.size == 1 && List === (blk = @blocks[0]) && blk.outline?) end
Check whether this list item has simple content (no nested blocks aside from a single outline list). Primarily relevant for outline lists.
Return true if the list item contains no blocks or it contains a single outline list. Otherwise, return false.
Source
# File lib/asciidoctor/list.rb, line 78 def text # NOTE @text can be nil if dd node only has block content @text && (apply_subs @text, @subs) end
Source
# File lib/asciidoctor/list.rb, line 68 def text? @text.nil_or_empty? ? false : true end
Public: A convenience method that checks whether the text of this list item is not blank (i.e., not nil or empty string).
Source
# File lib/asciidoctor/list.rb, line 110 def to_s %(#<#{self.class}@#{object_id} {list_context: #{parent.context.inspect}, text: #{@text.inspect}, blocks: #{(@blocks || []).size}}>) end