Class: ReverseAdoc::Converters::Li

Inherits:
Base
  • Object
show all
Defined in:
lib/reverse_adoc/converters/li.rb

Instance Method Summary collapse

Methods inherited from Base

#escape_keychars, #extract_title, #treat, #treat_children

Instance Method Details

#convert(node, state = {}) ⇒ Object



4
5
6
7
8
9
10
# File 'lib/reverse_adoc/converters/li.rb', line 4

def convert(node, state = {})
  id = node['id']
  anchor = id ? "[[#{id}]]" : ""
  content     = treat_children(node, state)
  prefix      = prefix_for(node, state)
  "#{prefix} #{anchor}#{content.chomp}\n"
end

#prefix_for(node, state) ⇒ Object



12
13
14
15
16
17
18
19
# File 'lib/reverse_adoc/converters/li.rb', line 12

def prefix_for(node, state)
  length = state.fetch(:ol_count, 0)
  if node.parent.name == 'ol'
    "." * [length, 0].max
  else
    "*" * [length, 0].max
  end
end