Sha256: 3d7c75d0c55ef3b9ebc0031331687eeac1645f2c096ab2e2dc83fc1e441989ad

Contents?: true

Size: 984 Bytes

Versions: 16

Compression:

Stored size: 984 Bytes

Contents

# frozen_string_literal: true

module Kitchen
  module Directions
    # Adds learning objectives header to abstracts
    module BakePageAbstracts
      def self.v1(chapter:)
        chapter.abstracts.each do |abstract|
          abstract.prepend(child: "<h3 data-type='title'>#{I18n.t(:learning_objectives)}</h3>")
        end
      end

      def self.v2(chapter:)
        chapter.abstracts.each do |abstract|
          abstract.prepend(child: "<h3 data-type='title'>#{I18n.t(:learning_objectives)}</h3>")
          ul = abstract.first!('ul')
          ul.add_class('os-abstract')
          ul.search('li').each_with_index do |li, index|
            li.replace_children(with:
              <<~HTML
                <span class="os-abstract-token">#{chapter.count_in(:book)}.#{abstract.count_in(:chapter)}.#{index + 1}</span>
                <span class="os-abstract-content">#{li.children}</span>
              HTML
            )
          end
        end
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
openstax_kitchen-11.2.0 lib/kitchen/directions/bake_page_abstracts.rb
openstax_kitchen-11.1.0 lib/kitchen/directions/bake_page_abstracts.rb
openstax_kitchen-11.0.0 lib/kitchen/directions/bake_page_abstracts.rb
openstax_kitchen-10.0.0 lib/kitchen/directions/bake_page_abstracts.rb
openstax_kitchen-9.2.0 lib/kitchen/directions/bake_page_abstracts.rb
openstax_kitchen-9.1.0 lib/kitchen/directions/bake_page_abstracts.rb
openstax_kitchen-9.0.0 lib/kitchen/directions/bake_page_abstracts.rb
openstax_kitchen-8.0.1 lib/kitchen/directions/bake_page_abstracts.rb
openstax_kitchen-8.0.0 lib/kitchen/directions/bake_page_abstracts.rb
openstax_kitchen-7.0.0 lib/kitchen/directions/bake_page_abstracts.rb
openstax_kitchen-6.1.0 lib/kitchen/directions/bake_page_abstracts.rb
openstax_kitchen-6.0.0 lib/kitchen/directions/bake_page_abstracts.rb
openstax_kitchen-5.0.0 lib/kitchen/directions/bake_page_abstracts.rb
openstax_kitchen-4.1.1 lib/kitchen/directions/bake_page_abstracts.rb
openstax_kitchen-4.1.0 lib/kitchen/directions/bake_page_abstracts.rb
openstax_kitchen-4.0.0 lib/kitchen/directions/bake_page_abstracts.rb