6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
# File 'lib/kitchen/directions/bake_unnumbered_tables.rb', line 6
def self.v1(book:)
book.tables('$.unnumbered').each do |table|
table.wrap(%(<div class="os-table">))
table.remove_attribute('summary')
table.parent.add_class('os-unstyled-container') if table.unstyled?
table.parent.add_class('os-no-cellborder-container') if table.no_cellborder_table?
table.parent.add_class('os-column-header-container') if table.column_header?
if table.top_titled?
table.parent.add_class('os-top-titled-container')
if table.first('thead') && table.title
table.prepend(sibling:
<<~HTML
<div class="os-table-title">#{table.title}</div>
HTML
)
table.title_row.trash
end
end
table.search('th').each do ||
[:scope] = if [:colspan].nil? || [:colspan] == '1'
'col'
else
'colgroup'
end
end
if (title = table.first("span[data-type='title']")&.cut)
caption_title = <<~HTML
\n<span class="os-title" data-type="title">#{title.children}</span>
HTML
end
if (caption = table.caption&.cut) && !caption&.children&.to_s&.blank?
caption_text = <<~HTML
\n<span class="os-caption">#{caption.children}</span>
HTML
end
next unless caption_text || caption_title
sibling = <<~HTML
<div class="os-caption-container">
#{caption_title}
<span class="os-divider"> </span>#{caption_text}
</div>
HTML
table.append(sibling: sibling)
end
end
|