Class: ReverseAsciidoctor::Converters::Figure

Inherits:
Base
  • Object
show all
Defined in:
lib/reverse_asciidoctor/converters/figure.rb

Instance Method Summary collapse

Methods inherited from Base

#escape_keychars, #treat, #treat_children

Instance Method Details

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



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

def convert(node, state = {})
  id = node['id']
  anchor = id ? "[[#{id}]]\n" : ""
  title = extract_title(node)
  title = ".#{title}\n" unless title.empty?
  "\n\n#{anchor}#{title}====\n" << treat_children(node, state).strip << "\n====\n\n"
end

#extract_title(node) ⇒ Object



12
13
14
15
16
# File 'lib/reverse_asciidoctor/converters/figure.rb', line 12

def extract_title(node)
  title = node.at("./figcaption")
  return "" if title.nil?
  treat_children(title, {})
end