Module: Kitchen::Directions::BakeUnnumberedFigure

Defined in:
lib/kitchen/directions/bake_unnumbered_figure.rb

Class Method Summary collapse

Class Method Details

.v1(book:) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/kitchen/directions/bake_unnumbered_figure.rb', line 6

def self.v1(book:)
  book.figures(only: :unnumbered?).each do |figure|
    next unless figure.caption || figure.title

    figure.wrap(%(<div class="os-figure#{' has-splash' if figure.has_class?('splash')}">))
    title = figure.title&.cut
    caption = figure.caption&.cut
    figure.append(sibling:
      <<~HTML
        <div class="os-caption-container">
          #{"<span class=\"os-title\" data-type=\"title\" id=\"#{title.id}\">#{title.children}</span>" if title}
          #{'<span class="os-divider"> </span>' if title && caption}
          #{"<span class=\"os-caption\">#{caption.children}</span>" if caption}
        </div>
      HTML
    )
  end
end