Sha256: 42890e480bf4b43b547b88665ad58e5e145f8b2f82ed43acfeba958262fbbb36

Contents?: true

Size: 860 Bytes

Versions: 23

Compression:

Stored size: 860 Bytes

Contents

# frozen_string_literal: true

module Kitchen::Directions::BakeChapterSectionExercises
  class V1
    def bake(chapter:, trash_title:)
      chapter.pages.each do |page|
        page.search('section.section-exercises').each do |section|
          section.first('h3[data-type="title"]')&.trash if trash_title
          section.wrap(
            %(<div class="os-eos os-section-exercises-container"
              data-uuid-key=".section-exercises">)
          )

          section_title = I18n.t(
            :section_exercises,
            number: "#{chapter.count_in(:book)}.#{section.count_in(:chapter)}")

          section.prepend(sibling:
            <<~HTML
              <h3 data-type="document-title">
                <span class="os-text">#{section_title}</span>
              </h3>
            HTML
          )
        end
      end
    end
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
openstax_kitchen-19.0.0 lib/kitchen/directions/bake_chapter_section_exercises/v1.rb
openstax_kitchen-18.0.0 lib/kitchen/directions/bake_chapter_section_exercises/v1.rb
openstax_kitchen-17.1.0 lib/kitchen/directions/bake_chapter_section_exercises/v1.rb
openstax_kitchen-17.0.0 lib/kitchen/directions/bake_chapter_section_exercises/v1.rb
openstax_kitchen-16.0.0 lib/kitchen/directions/bake_chapter_section_exercises/v1.rb
openstax_kitchen-15.0.0 lib/kitchen/directions/bake_chapter_section_exercises/v1.rb
openstax_kitchen-14.0.0 lib/kitchen/directions/bake_chapter_section_exercises/v1.rb
openstax_kitchen-13.0.0 lib/kitchen/directions/bake_chapter_section_exercises/v1.rb
openstax_kitchen-12.2.0 lib/kitchen/directions/bake_chapter_section_exercises/v1.rb
openstax_kitchen-12.1.0 lib/kitchen/directions/bake_chapter_section_exercises/v1.rb
openstax_kitchen-12.0.0 lib/kitchen/directions/bake_chapter_section_exercises/v1.rb
openstax_kitchen-11.2.0 lib/kitchen/directions/bake_chapter_section_exercises/v1.rb
openstax_kitchen-11.1.0 lib/kitchen/directions/bake_chapter_section_exercises/v1.rb
openstax_kitchen-11.0.0 lib/kitchen/directions/bake_chapter_section_exercises/v1.rb
openstax_kitchen-10.0.0 lib/kitchen/directions/bake_chapter_section_exercises/v1.rb
openstax_kitchen-9.2.0 lib/kitchen/directions/bake_chapter_section_exercises/v1.rb
openstax_kitchen-9.1.0 lib/kitchen/directions/bake_chapter_section_exercises/v1.rb
openstax_kitchen-9.0.0 lib/kitchen/directions/bake_chapter_section_exercises/v1.rb
openstax_kitchen-8.0.1 lib/kitchen/directions/bake_chapter_section_exercises/v1.rb
openstax_kitchen-8.0.0 lib/kitchen/directions/bake_chapter_section_exercises/v1.rb