Sha256: 7d61f78af04200fd60f488c2f0e8271051e3ad92f10afcfe7d0e6e83804f64df

Contents?: true

Size: 940 Bytes

Versions: 8

Compression:

Stored size: 940 Bytes

Contents

# frozen_string_literal: true

module Kitchen::Directions::BakeReferences
  class V2
    def bake(book:, metadata_source:)
      book.chapters.each do |chapter|

        chapter.references.search('h3').trash

        chapter_references = chapter.pages.references.cut
        chapter_title_no_num = chapter.title.search('.os-text')

        chapter.append(child:
          <<~HTML
            <div class="os-chapter-area">
              <h2 data-type="document-title">#{chapter_title_no_num}</h2>
              #{chapter_references.paste}
            </div>
          HTML
        )
      end

      chapter_area_references = book.chapters.search('.os-chapter-area').cut

      Kitchen::Directions::CompositePageContainer.v1(
        container_key: 'references',
        uuid_key: '.references',
        metadata_source: metadata_source,
        content: chapter_area_references.paste,
        append_to: book.body
      )
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
openstax_kitchen-19.0.0 lib/kitchen/directions/bake_references/v2.rb
openstax_kitchen-18.0.0 lib/kitchen/directions/bake_references/v2.rb
openstax_kitchen-17.1.0 lib/kitchen/directions/bake_references/v2.rb
openstax_kitchen-17.0.0 lib/kitchen/directions/bake_references/v2.rb
openstax_kitchen-16.0.0 lib/kitchen/directions/bake_references/v2.rb
openstax_kitchen-15.0.0 lib/kitchen/directions/bake_references/v2.rb
openstax_kitchen-14.0.0 lib/kitchen/directions/bake_references/v2.rb
openstax_kitchen-13.0.0 lib/kitchen/directions/bake_references/v2.rb