Sha256: aac79229207dc2c4e5000dbf98aa85f3aaab84c5c42a8d158d89ad1de223ddb9

Contents?: true

Size: 1.03 KB

Versions: 10

Compression:

Stored size: 1.03 KB

Contents

# frozen_string_literal: true

module Kitchen::Directions::BakeNumberedNotes
  class V3
    # for the try it notes, must be called AFTER bake_exercises
    def bake(book:, classes:, suppress_solution: true)
      classes.each do |klass|
        book.chapters.notes("$.#{klass}").each do |note|
          note.wrap_children(class: 'os-note-body')
          previous_example = note.previous
          os_number = previous_example&.first('.os-number')&.children&.to_s

          note.prepend(child:
            <<~HTML
              <h3 class="os-title">
                <span class="os-title-label">#{note.autogenerated_title}</span>
                <span class="os-number">#{os_number}</span>
              </h3>
            HTML
          )

          note.title&.trash
          note.exercises.each do |exercise|
            Kitchen::Directions::BakeNumberedNotes.bake_note_exercise(
              note: note, exercise: exercise, divider: '. ', suppress_solution: suppress_solution
            )
          end
        end
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
openstax_kitchen-11.0.0 lib/kitchen/directions/bake_notes/bake_numbered_notes/v3.rb
openstax_kitchen-10.0.0 lib/kitchen/directions/bake_notes/bake_numbered_notes/v3.rb
openstax_kitchen-9.2.0 lib/kitchen/directions/bake_notes/bake_numbered_notes/v3.rb
openstax_kitchen-9.1.0 lib/kitchen/directions/bake_notes/bake_numbered_notes/v3.rb
openstax_kitchen-9.0.0 lib/kitchen/directions/bake_notes/bake_numbered_notes/v3.rb
openstax_kitchen-8.0.1 lib/kitchen/directions/bake_notes/bake_numbered_notes/v3.rb
openstax_kitchen-8.0.0 lib/kitchen/directions/bake_notes/bake_numbered_notes/v3.rb
openstax_kitchen-7.0.0 lib/kitchen/directions/bake_notes/bake_numbered_notes/v3.rb
openstax_kitchen-6.1.0 lib/kitchen/directions/bake_notes/bake_numbered_notes/v3.rb
openstax_kitchen-6.0.0 lib/kitchen/directions/bake_notes/bake_numbered_notes/v3.rb