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
|
# File 'lib/kitchen/directions/bake_numbered_table/v1.rb', line 6
def bake(table:, number:, always_caption: false, cases: false)
Kitchen::Directions::BakeTableBody::V1.new.bake(table: table, number: number, cases: cases)
new_caption = ''
caption_title = ''
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?
new_caption = <<~HTML
\n<span class="os-caption">#{caption.children}</span>
HTML
elsif always_caption
new_caption = <<~HTML
\n<span class="os-caption"></span>
HTML
end
return if table.unnumbered?
table.append(sibling:
<<~HTML
<div class="os-caption-container">
<span class="os-title-label">#{I18n.t("table#{'.nominative' if cases}")} </span>
<span class="os-number">#{number}</span>
<span class="os-divider"> </span>#{caption_title}
<span class="os-divider"> </span>#{new_caption}
</div>
HTML
)
table.parent.add_class('os-timeline-table-container') if table.has_class?('timeline-table')
end
|