class Swordfish::Node::List

Public Instance Methods

depth_of_final_node() click to toggle source

Get the zero-indexed depth of the bottommost child list (This is not the deepest node, just the last child)

# File lib/swordfish/nodes/list.rb, line 17
def depth_of_final_node
  depth = 0
  node = self
  while !@children.empty? && node = node.last_list_item.nested_list do
    depth += 1
  end
  depth
end
last_list() click to toggle source

Return the final child list

# File lib/swordfish/nodes/list.rb, line 27
def last_list
  node = self
  while node.children && node.last_list_item.nested_list
    node = node.last_list_item.nested_list
  end
  node
end
last_list_item(opts = {}) click to toggle source

Return the final child list item

# File lib/swordfish/nodes/list.rb, line 36
def last_list_item(opts = {})
  if opts[:recurse]
    node = self
    li = @children.last
    while node.children && node = node.last_list_item.nested_list
      li = node.children.last
    end
    li
  else
    @children.last
  end
end
to_html() click to toggle source
# File lib/swordfish/nodes/list.rb, line 7
def to_html
  if @style.bullet?
    "<ul>#{@children.map(&:to_html).join}</ul>"
  else
    "<ol>#{@children.map(&:to_html).join}</ol>"
  end
end