Class: Asciidoctor::ListItem
- Inherits:
-
AbstractBlock
- Object
- AbstractNode
- AbstractBlock
- Asciidoctor::ListItem
- Defined in:
- lib/asciidoctor/list.rb
Overview
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.
Constant Summary
Constants included from Substitutors
Substitutors::CAN, Substitutors::CGI, Substitutors::DEL, Substitutors::ESC_R_SB, Substitutors::HighlightedPassSlotRx, Substitutors::PASS_END, Substitutors::PASS_START, Substitutors::PLUS, Substitutors::PassSlotRx, Substitutors::QuotedTextSniffRx, Substitutors::RS, Substitutors::R_SB, Substitutors::SUB_GROUPS, Substitutors::SUB_HINTS, Substitutors::SUB_OPTIONS, Substitutors::SpecialCharsRx, Substitutors::SpecialCharsTr
Instance Attribute Summary collapse
-
#marker ⇒ Object
Get/Set the String used to mark this list item.
-
#text ⇒ Object
Get the String text of this ListItem with substitutions applied.
Attributes inherited from AbstractBlock
#blocks, #caption, #content_model, #level, #numeral, #source_location, #style, #subs
Attributes inherited from AbstractNode
#attributes, #context, #document, #id, #node_name, #parent
Instance Method Summary collapse
-
#compound? ⇒ Boolean
Check whether this list item has compound content (nested blocks aside from a single outline list).
-
#initialize(parent, text = nil) ⇒ ListItem
constructor
Initialize an Asciidoctor::ListItem object.
-
#simple? ⇒ Boolean
Check whether this list item has simple content (no nested blocks aside from a single outline list).
-
#text? ⇒ Boolean
A convenience method that checks whether the text of this list item is not blank (i.e., not nil or empty string).
- #to_s ⇒ Object
Methods inherited from AbstractBlock
#<<, #alt, #assign_caption, #block?, #blocks?, #captioned_title, #content, #context=, #convert, #file, #find_by, #inline?, #lineno, #list_marker_keyword, #next_adjacent_block, #number, #number=, #remove_sub, #sections, #sections?, #sub?, #title, #title=, #title?, #xreftext
Methods inherited from AbstractNode
#add_role, #attr, #attr?, #block?, #converter, #enabled_options, #generate_data_uri, #generate_data_uri_from_uri, #has_role?, #icon_uri, #image_uri, #inline?, #is_uri?, #media_uri, #normalize_asset_path, #normalize_system_path, #normalize_web_path, #option?, #read_asset, #read_contents, #reftext, #reftext?, #remove_attr, #remove_role, #role, #role=, #role?, #roles, #set_attr, #set_option, #update_attributes
Methods included from Substitutors
#apply_header_subs, #apply_normal_subs, #apply_reftext_subs, #apply_subs, #expand_subs, #extract_passthroughs, #highlight_source, #resolve_block_subs, #resolve_lines_to_highlight, #resolve_pass_subs, #resolve_subs, #restore_passthroughs, #sub_attributes, #sub_callouts, #sub_macros, #sub_post_replacements, #sub_quotes, #sub_replacements, #sub_source, #sub_specialchars
Methods included from Logging
#logger, #message_with_context
Constructor Details
#initialize(parent, text = nil) ⇒ ListItem
Initialize an Asciidoctor::ListItem object.
57 58 59 60 61 62 |
# File 'lib/asciidoctor/list.rb', line 57 def initialize parent, text = nil super parent, :list_item @text = text @level = parent.level @subs = NORMAL_SUBS.drop 0 end |
Instance Attribute Details
#marker ⇒ Object
Get/Set the String used to mark this list item
51 52 53 |
# File 'lib/asciidoctor/list.rb', line 51 def marker @marker end |
#text ⇒ Object
Get the String text of this ListItem with substitutions applied.
By default, normal substitutions are applied to the text. The substitutions can be modified by altering the subs property of this object.
76 77 78 79 |
# File 'lib/asciidoctor/list.rb', line 76 def text # NOTE @text can be nil if dd node only has block content @text && (apply_subs @text, @subs) end |
Instance Method Details
#compound? ⇒ Boolean
Check whether this list item has compound content (nested blocks aside from a single outline list). Primarily relevant for outline lists.
96 97 98 |
# File 'lib/asciidoctor/list.rb', line 96 def compound? !simple? end |
#simple? ⇒ Boolean
Check whether this list item has simple content (no nested blocks aside from a single outline list). Primarily relevant for outline lists.
88 89 90 |
# File 'lib/asciidoctor/list.rb', line 88 def simple? @blocks.empty? || (@blocks.size == 1 && List === (blk = @blocks[0]) && blk.outline?) end |
#text? ⇒ Boolean
A convenience method that checks whether the text of this list item is not blank (i.e., not nil or empty string).
66 67 68 |
# File 'lib/asciidoctor/list.rb', line 66 def text? @text.nil_or_empty? ? false : true end |
#to_s ⇒ Object
108 109 110 |
# File 'lib/asciidoctor/list.rb', line 108 def to_s %(#<#{self.class}@#{object_id} {list_context: #{parent.context.inspect}, text: #{@text.inspect}, blocks: #{(@blocks || []).size}}>) end |