module Kitchen::Directions::BakeNonIntroductionPages

Public Class Methods

v1(chapter:) click to toggle source
# File lib/kitchen/directions/bake_non_introduction_pages.rb, line 6
      def self.v1(chapter:)
        chapter.non_introduction_pages.each do |page|
          number = "#{chapter.count_in(:book)}.#{page.count_in(:chapter)}"

          page.search("div[data-type='description']").each(&:trash)
          page.add_class('chapter-content-module')

          title = page.title
          title.name = 'h2'
          title.replace_children(with:
            <<~HTML
              <span class="os-number">#{number}</span>
              <span class="os-divider"> </span>
              <span data-type="" itemprop="" class="os-text">#{title.text}</span>
            HTML
          )
        end
      end