Module: Asciidoctor::Html::List

Defined in:
lib/asciidoctor/html/list.rb

Overview

Helper functions for the list conversion

Class Method Summary collapse

Class Method Details

.convert(node, tag_name = :ol) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/asciidoctor/html/list.rb', line 7

def self.convert(node, tag_name = :ol)
  depth = node.attr "list-depth"
  flat = node.attr? "flat-style"
  level = depth + 1
  classes = [
    "list",
    "list-#{node.context}",
    ("level-#{level} pseudocode" if flat),
    node.role
  ].compact
  classes << "list-checklist" if node.option?("checklist")
  classes << "list-unmarked" if node.option?("unmarked")
  classes << "list-roomy" if node.option?("roomy")
  result = [%(<#{tag_name}#{Utils.dyn_id_class_attr_str node, classes.join(" ")}>)]
  node.items.each do |item|
    result << display_list_item(item)
  end
  result << %(</#{tag_name}> <!-- .level-#{level} -->\n)
  Utils.wrap_id_classes_with_title result.join("\n"), node, node.id, "list-wrapper"
end

.display_list_item(item) ⇒ Object



28
29
30
31
32
33
34
35
36
37
# File 'lib/asciidoctor/html/list.rb', line 28

def self.display_list_item(item)
  result = []
  result << %(<li#{Utils.id_class_attr_str item.id,
                                           item.role}><div class="li-mark">#{item.attr "mark"}</div>)
  result << %(<div class="li-content">)
  result << %(<p>#{item.text}</p>) unless item.text.empty?
  result << "\n#{item.content}" if item.blocks?
  result << %(</div></li>#{Utils.id_class_sel_comment item.id, item.role})
  result.join "\n"
end