Class: ReverseAdoc::Converters::H
- Inherits:
-
Base
- Object
- Base
- ReverseAdoc::Converters::H
show all
- Defined in:
- lib/reverse_adoc/converters/h.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
11
12
|
# File 'lib/reverse_adoc/converters/h.rb', line 4
def convert(node, state = {})
id = node['id']
anchor = id ? "[[#{id}]]" : ""
internal_anchor = treat_children_anchors(node, state) || ""
anchor.empty? and anchor = internal_anchor
anchor.empty? or anchor += "\n"
prefix = '=' * (node.name[/\d/].to_i + 1)
["\n", anchor, prefix, ' ', treat_children_no_anchors(node, state), "\n"].join
end
|
#treat_children_anchors(node, state) ⇒ Object
20
21
22
23
24
|
# File 'lib/reverse_adoc/converters/h.rb', line 20
def treat_children_anchors(node, state)
node.children.select { |a| a.name == "a" }.inject('') do |memo, child|
memo << treat(child, state)
end
end
|
#treat_children_no_anchors(node, state) ⇒ Object
14
15
16
17
18
|
# File 'lib/reverse_adoc/converters/h.rb', line 14
def treat_children_no_anchors(node, state)
node.children.reject { |a| a.name == "a" }.inject('') do |memo, child|
memo << treat(child, state)
end
end
|