Class: Kitchen::Directions::BakeNumberedNotes::V3
- Defined in:
- lib/kitchen/directions/bake_notes/bake_numbered_notes/v3.rb
Instance Method Summary collapse
-
#bake(book:, classes:, suppress_solution: true) ⇒ Object
for the try it notes, must be called AFTER bake_exercises.
Instance Method Details
#bake(book:, classes:, suppress_solution: true) ⇒ Object
for the try it notes, must be called AFTER bake_exercises
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/kitchen/directions/bake_notes/bake_numbered_notes/v3.rb', line 7 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 until previous_example.nil? || previous_example[:'data-type'] == 'example' previous_example = previous_example.previous end os_number = previous_example&.first('.os-number')&.children&.to_s note.prepend(child: " <h3 class=\"os-title\">\n <span class=\"os-title-label\">\#{note.autogenerated_title}</span>\n <span class=\"os-number\">\#{os_number}</span>\n </h3>\n HTML\n )\n\n note.title&.trash\n note.exercises.each do |exercise|\n BakeNoteExercise.v1(\n note: note, exercise: exercise, divider: '. ', suppress_solution: suppress_solution\n )\n end\n note.injected_questions.each do |question|\n BakeNoteInjectedQuestion.v1(note: note, question: question)\n end\n\n note.search(\"div[data-type='solution']\").each&.trash if suppress_solution\n end\n end\nend\n" |