Module: Kitchen::Directions::BakeAppendix

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

Class Method Summary collapse

Class Method Details

.v1(page:, number:) ⇒ Object



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

def self.v1(page:, number:)
  title = page.title
  title.name = 'h1'
  title.replace_children(with:
    <<~HTML
      <span class="os-part-text">#{I18n.t(:appendix)} </span>
      <span class="os-number">#{number}</span>
      <span class="os-divider"> </span>
      <span data-type="" itemprop="" class="os-text">#{title.children}</span>
    HTML
  )

  # Make a section with data-depth of X have a header level of X+1
  page.search('section').each do |section|
    title = section.titles.first
    next unless title.present?

    title.name = "h#{section['data-depth'].to_i + 1}"
    section.name = 'div' if section.has_class?('column-container')
  end
end