Sha256: 57e5b55735c9181857cb5097b69d11308b92fe87ad8acc686e6d9c129f3d73b7
Contents?: true
Size: 1.01 KB
Versions: 10
Compression:
Stored size: 1.01 KB
Contents
# frozen_string_literal: true module Kitchen::Directions::BakeNumberedNotes class V1 def bake(book:, classes:) classes.each do |klass| book.chapters.notes("$.#{klass}").each do |note| bake_note(note: note) note.exercises.each do |exercise| Kitchen::Directions::BakeNumberedNotes.bake_note_exercise(note: note, exercise: exercise) end end end end def bake_note(note:) note.wrap_children(class: 'os-note-body') chapter_count = note.ancestor(:chapter).count_in(:book) note_count = note.count_in(:chapter) note.prepend(child: <<~HTML <h3 class="os-title"> <span class="os-title-label">#{note.autogenerated_title}</span> <span class="os-number">#{chapter_count}.#{note_count}</span> <span class="os-divider"> </span> </h3> HTML ) return unless note['use-subtitle'] Kitchen::Directions::BakeNoteSubtitle.v1(note: note) end end end
Version data entries
10 entries across 10 versions & 1 rubygems