Class: Coradoc::CoreModel::ListBlock

Inherits:
Base
  • Object
show all
Defined in:
lib/coradoc/core_model/list_block.rb

Overview

Represents a list block with proper nesting support

Handles all AsciiDoc list types:

  • Unordered lists (*, **, ***)

  • Ordered lists (., .., …)

  • Description lists

  • Labeled lists

Lists can contain nested lists at multiple levels, with each level tracked through marker_level.

Examples:

Creating an unordered list

list = CoreModel::ListBlock.new(
  marker_type: "asterisk",
  marker_level: 1,
  items: [
    ListItem.new(marker: "*", content: "First item"),
    ListItem.new(marker: "*", content: "Second item")
  ]
)

Creating a nested list

nested = CoreModel::ListBlock.new(
  marker_type: "asterisk",
  marker_level: 2,
  items: [ListItem.new(marker: "**", content: "Nested item")]
)
list = CoreModel::ListBlock.new(
  marker_type: "asterisk",
  marker_level: 1,
  items: [
    ListItem.new(
      marker: "*",
      content: "Parent item",
      nested_list: nested
    )
  ]
)

Instance Attribute Summary collapse

Attributes inherited from Base

#element_attributes, #id, #metadata_entries, #title

Method Summary

Methods inherited from Base

#accept, #attr, #metadata, #semantically_equivalent?, #set_attr, #set_metadata

Instance Attribute Details

#itemsArray<ListItem>

Returns collection of list items.

Returns:

  • (Array<ListItem>)

    collection of list items



110
# File 'lib/coradoc/core_model/list_block.rb', line 110

attribute :items, ListItem, collection: true

#marker_levelInteger

Returns nesting level of the list (default: 1).

Returns:

  • (Integer)

    nesting level of the list (default: 1)



102
# File 'lib/coradoc/core_model/list_block.rb', line 102

attribute :marker_level, :integer, default: -> { 1 }

#marker_typeString?

Returns type of list marker (e.g., ‘asterisk’, ‘dash’, ‘numbered’, ‘labeled’).

Returns:

  • (String, nil)

    type of list marker (e.g., ‘asterisk’, ‘dash’, ‘numbered’, ‘labeled’)



98
# File 'lib/coradoc/core_model/list_block.rb', line 98

attribute :marker_type, :string

#startInteger?

Returns starting number for ordered lists.

Returns:

  • (Integer, nil)

    starting number for ordered lists



106
# File 'lib/coradoc/core_model/list_block.rb', line 106

attribute :start, :integer