ruby-dita 0.4.3 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/ruby-dita/table.rb +23 -8
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 83ece111fe0ac7b5650bb2a3ca496ee8ac8a27a6
|
4
|
+
data.tar.gz: 4b1b28b1bc0dc917a426bb80ef951a3c390e627b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ce8b7933ddbfd7e051d65ed2de3a94086252c87347770172566cf60def113d6334cd89e78bfe26c4229ca3e59b3e563333d84fa2eb864a246d2c19cd80033b6b
|
7
|
+
data.tar.gz: 4580b04dba50973ee5c13d01f7987427ec59f21dee9cfda345ea9c2b3cca4179013cce874b683c4f64cc2b1df230b4501436e38814f61a28802e05acab11d6fe
|
data/lib/ruby-dita/table.rb
CHANGED
@@ -9,11 +9,11 @@ module Dita
|
|
9
9
|
def row(ary)
|
10
10
|
return ary if ary.all? do |a| a.respond_to?(:name) and a.name == 'row' end
|
11
11
|
Element.new('row') <<
|
12
|
-
ary.collect do |
|
13
|
-
if
|
14
|
-
|
12
|
+
ary.collect do |e|
|
13
|
+
if e.is_a?(Element) and e.name == 'entry'
|
14
|
+
e
|
15
15
|
else
|
16
|
-
|
16
|
+
entry e
|
17
17
|
end
|
18
18
|
end
|
19
19
|
end
|
@@ -25,16 +25,21 @@ module Dita
|
|
25
25
|
t = Element.new('table')
|
26
26
|
headings = []
|
27
27
|
tgroup = Element.new('tgroup')
|
28
|
+
num_cols = column_info.size.to_s
|
28
29
|
case column_info
|
29
30
|
when Array
|
30
31
|
headings = column_info if column_info.first.is_a?(String)
|
31
|
-
|
32
|
+
colspecs = column_info if column_info.first.is_a?(Element) and column_info.first.name == 'colspec'
|
32
33
|
when Hash
|
33
34
|
headings = column_info.keys
|
34
|
-
|
35
|
+
colspecs = column_info.values
|
35
36
|
else
|
36
37
|
# TODO raise error?
|
37
38
|
end
|
39
|
+
if colspecs
|
40
|
+
colspecs.each_with_index do |c, index| c[:colname] = index.to_s end
|
41
|
+
tgroup << colspecs
|
42
|
+
end
|
38
43
|
if headings.any?
|
39
44
|
tgroup << Element.new('thead', [Element.new('row')])
|
40
45
|
headings.each do |h|
|
@@ -42,9 +47,19 @@ module Dita
|
|
42
47
|
end
|
43
48
|
end
|
44
49
|
|
45
|
-
tgroup[:cols] =
|
50
|
+
tgroup[:cols] = num_cols
|
46
51
|
tgroup << Element.new('tbody')
|
47
52
|
tgroup.tbody << rows.collect do |r| row r end
|
48
53
|
t << tgroup
|
49
54
|
end
|
50
|
-
|
55
|
+
|
56
|
+
def colspec(attrs)
|
57
|
+
Element.new('colspec', attrs)
|
58
|
+
end
|
59
|
+
|
60
|
+
# @param content [String, Element] content of
|
61
|
+
def entry(content, attrs={})
|
62
|
+
Element.new('entry', attrs, [content])
|
63
|
+
end
|
64
|
+
end # end of module Table
|
65
|
+
|