Sha256: 86c9c83ee0719b4ba893d06e938c5e129c9fb3007b6e69b6fc94b38d76542bcc

Contents?: true

Size: 1.39 KB

Versions: 16

Compression:

Stored size: 1.39 KB

Contents

# frozen_string_literal: true

module Kitchen::Directions::BakeReferences
  class V1
    renderable

    def bake(book:, metadata_source:)
      @metadata = metadata_source.children_to_keep.copy
      @klass = 'reference'
      @uuid_prefix = '.'
      @title = I18n.t(:references)

      book.chapters.each do |chapter|
        chapter.search('[data-type="cite"]').each do |link|
          link.prepend(child:
            <<~HTML
              <sup class="os-citation-number">#{link.count_in(:chapter)}</sup>
            HTML
          )
        end

        chapter.references.each do |reference|
          reference.prepend(child:
            <<~HTML.chomp
              <span class="os-reference-number">#{reference.count_in(:chapter)}. </span>
            HTML
          )
        end

        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
      @content = chapter_area_references.paste
      book.body.append(child: render(file:
        '../../templates/eob_section_title_template.xhtml.erb'))
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

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