Sha256: e8fdf0b6eccf16f324961e924cf8fab4536ef76ea91131aea0d93d7dee4c0a92

Contents?: true

Size: 694 Bytes

Versions: 30

Compression:

Stored size: 694 Bytes

Contents

# frozen_string_literal: true

module Kitchen::Directions::BakeChapterTitle
  class V1
    def bake(book:)
      book.chapters.each do |chapter|
        fix_up_chapter_title(chapter: chapter)
      end
    end

    def fix_up_chapter_title(chapter:)
      heading = chapter.at('h1[2]')
      heading[:id] = "chapTitle#{chapter.count_in(:book)}"
      heading.replace_children(with:
        <<~HTML
          <span class="os-part-text">#{I18n.t(:chapter)} </span>
          <span class="os-number">#{chapter.count_in(:book)}</span>
          <span class="os-divider"> </span>
          <span data-type="" itemprop="" class="os-text">#{heading.text}</span>
        HTML
      )
    end
  end
end

Version data entries

30 entries across 30 versions & 1 rubygems

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