Module: Prawn::Markup::Processor::Lists

Included in:
Prawn::Markup::Processor
Defined in:
lib/prawn/markup/processor/lists.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.prepended(base) ⇒ Object



6
7
8
# File 'lib/prawn/markup/processor/lists.rb', line 6

def self.prepended(base)
  base.known_elements.push('ol', 'ul', 'li')
end

Instance Method Details

#end_liObject



42
43
44
45
46
# File 'lib/prawn/markup/processor/lists.rb', line 42

def end_li
  return unless inside_container?

  add_cell_text_node(current_list_item)
end

#end_listObject Also known as: end_ol, end_ul



29
30
31
32
# File 'lib/prawn/markup/processor/lists.rb', line 29

def end_list
  list = list_stack.pop
  append_list(list) unless list.items.empty?
end

#start_imgObject



48
49
50
51
52
53
54
# File 'lib/prawn/markup/processor/lists.rb', line 48

def start_img
  if current_list
    add_cell_image(current_list_item)
  else
    super
  end
end

#start_liObject



36
37
38
39
40
# File 'lib/prawn/markup/processor/lists.rb', line 36

def start_li
  return unless inside_container?

  current_list.items << Elements::Item.new
end

#start_list(ordered) ⇒ Object



18
19
20
21
22
23
24
25
26
27
# File 'lib/prawn/markup/processor/lists.rb', line 18

def start_list(ordered)
  if current_list
    add_cell_text_node(current_list_item)
  elsif current_table
    add_cell_text_node(current_cell)
  else
    add_current_text
  end
  @list_stack.push(Elements::List.new(ordered))
end

#start_olObject



10
11
12
# File 'lib/prawn/markup/processor/lists.rb', line 10

def start_ol
  start_list(true)
end

#start_ulObject



14
15
16
# File 'lib/prawn/markup/processor/lists.rb', line 14

def start_ul
  start_list(false)
end