Sha256: 77ee5deed0229f713bb1d7dfe3b00e24bf9f744b1c4934c50ac86025a267fe93

Contents?: true

Size: 1.24 KB

Versions: 1

Compression:

Stored size: 1.24 KB

Contents

# frozen_string_literal: true

module Kitchen::Directions
  module 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.pages.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|
              BakeNumberedNotes.bake_note_exercise(
                note: note, exercise: exercise, divider: '. ', suppress_solution: suppress_solution
              )
            end
            note.injected_questions.each do |question|
              BakeNumberedNotes.bake_note_injected_question(note: note, question: question)
            end
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
openstax_kitchen-11.1.0 lib/kitchen/directions/bake_notes/bake_numbered_notes/v3.rb