Class: ReverseAdoc::Converters::Table
- Inherits:
-
Base
- Object
- Base
- ReverseAdoc::Converters::Table
show all
- Defined in:
- lib/reverse_adoc/converters/table.rb
Instance Method Summary
collapse
Methods inherited from Base
#constrained?, #escape_keychars, #node_has_ancestor?, #textnode_before_end_with?, #treat, #treat_children, #treat_children_coradoc, #treat_coradoc, #unconstrained_after?, #unconstrained_before?
Instance Method Details
#convert(node, state = {}) ⇒ Object
12
13
14
|
# File 'lib/reverse_adoc/converters/table.rb', line 12
def convert(node, state = {})
Coradoc::Generator.gen_adoc(to_coradoc(node, state))
end
|
16
17
18
19
20
21
|
# File 'lib/reverse_adoc/converters/table.rb', line 16
def (node)
title = node.at("./caption")
return "" if title.nil?
treat_children(title, {})
end
|
#frame(node) ⇒ Object
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'lib/reverse_adoc/converters/table.rb', line 23
def frame(node)
case node["frame"]
when "void"
"none"
when "hsides"
"topbot"
when "vsides"
"sides"
when "box", "border"
"all"
end
end
|
#rules(node) ⇒ Object
36
37
38
39
40
41
42
43
44
45
46
47
|
# File 'lib/reverse_adoc/converters/table.rb', line 36
def rules(node)
case node["rules"]
when "all"
"all"
when "rows"
"rows"
when "cols"
"cols"
when "none"
"none"
end
end
|
#style(node) ⇒ Object
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
# File 'lib/reverse_adoc/converters/table.rb', line 49
def style(node)
attrs = Coradoc::Element::AttributeList.new
frame_attr = frame(node)
attrs.add_named("frame", frame_attr) if frame_attr
rules_attr = rules(node)
attrs.add_named("rules", rules_attr) if rules_attr
return "" if attrs.empty?
attrs
end
|
#to_coradoc(node, state = {}) ⇒ Object
4
5
6
7
8
9
10
|
# File 'lib/reverse_adoc/converters/table.rb', line 4
def to_coradoc(node, state = {})
id = node["id"]
title = (node)
attrs = style(node)
content = treat_children_coradoc(node, state)
Coradoc::Element::Table.new(title, content, { id: id, attrs: attrs })
end
|