openstax_kitchen 1.0.0 → 4.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (182) hide show
  1. checksums.yaml +4 -4
  2. data/.devcontainer/devcontainer.json +37 -17
  3. data/.github/config.yml +14 -0
  4. data/.github/workflows/tests.yml +5 -15
  5. data/.gitignore +2 -2
  6. data/.inch.yml +6 -0
  7. data/.rubocop.yml +65 -0
  8. data/CHANGELOG.md +85 -2
  9. data/Gemfile +5 -3
  10. data/Gemfile.lock +66 -18
  11. data/README.md +69 -15
  12. data/Rakefile +5 -3
  13. data/bin/console +4 -3
  14. data/docker/Dockerfile +36 -0
  15. data/docker/Dockerfile.ci +10 -0
  16. data/docker/bash +5 -1
  17. data/docker/build +10 -0
  18. data/docker/ci +15 -0
  19. data/docker/run +9 -0
  20. data/docker/tag_and_push_latest +17 -0
  21. data/lefthook.yml +6 -0
  22. data/lib/kitchen/ancestor.rb +38 -1
  23. data/lib/kitchen/book_document.rb +20 -2
  24. data/lib/kitchen/book_element.rb +40 -5
  25. data/lib/kitchen/book_element_enumerator.rb +4 -0
  26. data/lib/kitchen/book_recipe.rb +15 -1
  27. data/lib/kitchen/chapter_element.rb +43 -6
  28. data/lib/kitchen/chapter_element_enumerator.rb +9 -1
  29. data/lib/kitchen/clipboard.rb +35 -4
  30. data/lib/kitchen/composite_chapter_element.rb +21 -6
  31. data/lib/kitchen/composite_page_element.rb +35 -7
  32. data/lib/kitchen/composite_page_element_enumerator.rb +9 -1
  33. data/lib/kitchen/config.rb +20 -6
  34. data/lib/kitchen/counter.rb +9 -2
  35. data/lib/kitchen/debug/print_recipe_error.rb +53 -35
  36. data/lib/kitchen/directions/.rubocop.yml +22 -0
  37. data/lib/kitchen/directions/bake_appendix.rb +4 -4
  38. data/lib/kitchen/directions/bake_chapter_glossary/main.rb +18 -0
  39. data/lib/kitchen/directions/bake_chapter_glossary/v1.rb +30 -0
  40. data/lib/kitchen/directions/bake_chapter_introductions.rb +7 -7
  41. data/lib/kitchen/directions/bake_chapter_key_concepts/main.rb +16 -0
  42. data/lib/kitchen/directions/bake_chapter_key_concepts/v1.rb +35 -0
  43. data/lib/kitchen/directions/bake_chapter_key_equations.rb +30 -20
  44. data/lib/kitchen/directions/bake_chapter_section_exercises/main.rb +11 -0
  45. data/lib/kitchen/directions/bake_chapter_section_exercises/v1.rb +28 -0
  46. data/lib/kitchen/directions/bake_chapter_summary.rb +45 -36
  47. data/lib/kitchen/directions/bake_chapter_title/main.rb +11 -0
  48. data/lib/kitchen/directions/bake_chapter_title/v1.rb +24 -0
  49. data/lib/kitchen/directions/bake_checkpoint.rb +44 -0
  50. data/lib/kitchen/directions/bake_composite_chapters.rb +14 -0
  51. data/lib/kitchen/directions/bake_composite_pages.rb +2 -2
  52. data/lib/kitchen/directions/bake_equations.rb +37 -0
  53. data/lib/kitchen/directions/bake_example.rb +39 -11
  54. data/lib/kitchen/directions/bake_figure.rb +8 -5
  55. data/lib/kitchen/directions/bake_first_elements.rb +16 -0
  56. data/lib/kitchen/directions/bake_footnotes/main.rb +2 -2
  57. data/lib/kitchen/directions/bake_footnotes/v1.rb +6 -5
  58. data/lib/kitchen/directions/bake_free_response/free_response.xhtml.erb +10 -0
  59. data/lib/kitchen/directions/bake_free_response/main.rb +11 -0
  60. data/lib/kitchen/directions/bake_free_response/v1.rb +29 -0
  61. data/lib/kitchen/directions/bake_further_research.rb +59 -0
  62. data/lib/kitchen/directions/bake_index/main.rb +2 -2
  63. data/lib/kitchen/directions/bake_index/v1.rb +46 -18
  64. data/lib/kitchen/directions/bake_link_placeholders.rb +24 -0
  65. data/lib/kitchen/directions/bake_math_in_paragraph.rb +5 -3
  66. data/lib/kitchen/directions/bake_non_introduction_pages.rb +26 -0
  67. data/lib/kitchen/directions/bake_notes/bake_autotitled_notes.rb +29 -0
  68. data/lib/kitchen/directions/bake_notes/bake_note_subtitle.rb +22 -0
  69. data/lib/kitchen/directions/bake_notes/bake_numbered_notes.rb +51 -0
  70. data/lib/kitchen/directions/bake_notes/bake_unclassified_notes.rb +30 -0
  71. data/lib/kitchen/directions/bake_numbered_exercise/main.rb +15 -0
  72. data/lib/kitchen/directions/bake_numbered_exercise/v1.rb +47 -0
  73. data/lib/kitchen/directions/bake_numbered_table/main.rb +4 -4
  74. data/lib/kitchen/directions/bake_numbered_table/v1.rb +37 -18
  75. data/lib/kitchen/directions/bake_page_abstracts.rb +30 -0
  76. data/lib/kitchen/directions/bake_preface/main.rb +11 -0
  77. data/lib/kitchen/directions/bake_preface/v1.rb +18 -0
  78. data/lib/kitchen/directions/bake_references/main.rb +16 -0
  79. data/lib/kitchen/directions/bake_references/v1.rb +48 -0
  80. data/lib/kitchen/directions/bake_stepwise.rb +8 -12
  81. data/lib/kitchen/directions/bake_suggested_reading.rb +31 -0
  82. data/lib/kitchen/directions/bake_theorem/main.rb +11 -0
  83. data/lib/kitchen/directions/bake_theorem/v1.rb +28 -0
  84. data/lib/kitchen/directions/bake_toc.rb +49 -22
  85. data/lib/kitchen/directions/bake_unit_title/main.rb +11 -0
  86. data/lib/kitchen/directions/bake_unit_title/v1.rb +23 -0
  87. data/lib/kitchen/directions/bake_unnumbered_tables.rb +7 -5
  88. data/lib/kitchen/directions/book_answer_key_container/eob_solutions_container.xhtml.erb +9 -0
  89. data/lib/kitchen/directions/book_answer_key_container/main.rb +11 -0
  90. data/lib/kitchen/directions/book_answer_key_container/v1.rb +13 -0
  91. data/lib/kitchen/directions/chapter_review_container/chapter_review.xhtml.erb +9 -0
  92. data/lib/kitchen/directions/chapter_review_container/main.rb +11 -0
  93. data/lib/kitchen/directions/chapter_review_container/v1.rb +13 -0
  94. data/lib/kitchen/directions/eoc_section_title_link_snippet.rb +20 -0
  95. data/lib/kitchen/directions/move_exercises_to_eoc/main.rb +27 -0
  96. data/lib/kitchen/directions/move_exercises_to_eoc/v1.rb +36 -0
  97. data/lib/kitchen/directions/move_exercises_to_eoc/v2.rb +49 -0
  98. data/lib/kitchen/directions/move_solutions_to_answer_key/main.rb +14 -0
  99. data/lib/kitchen/directions/move_solutions_to_answer_key/strategies/american_government.rb +19 -0
  100. data/lib/kitchen/directions/move_solutions_to_answer_key/strategies/calculus.rb +41 -0
  101. data/lib/kitchen/directions/move_solutions_to_answer_key/strategies/uphysics.rb +63 -0
  102. data/lib/kitchen/directions/move_solutions_to_answer_key/v1.rb +34 -0
  103. data/lib/kitchen/directions/move_title_text_into_span.rb +2 -2
  104. data/lib/kitchen/document.rb +83 -13
  105. data/lib/kitchen/element.rb +20 -3
  106. data/lib/kitchen/element_base.rb +373 -63
  107. data/lib/kitchen/element_enumerator.rb +8 -0
  108. data/lib/kitchen/element_enumerator_base.rb +297 -28
  109. data/lib/kitchen/element_enumerator_factory.rb +64 -53
  110. data/lib/kitchen/element_factory.rb +27 -12
  111. data/lib/kitchen/errors.rb +5 -0
  112. data/lib/kitchen/example_element.rb +21 -6
  113. data/lib/kitchen/example_element_enumerator.rb +9 -1
  114. data/lib/kitchen/exercise_element.rb +42 -0
  115. data/lib/kitchen/exercise_element_enumerator.rb +21 -0
  116. data/lib/kitchen/figure_element.rb +36 -5
  117. data/lib/kitchen/figure_element_enumerator.rb +9 -1
  118. data/lib/kitchen/metadata_element.rb +34 -0
  119. data/lib/kitchen/metadata_element_enumerator.rb +21 -0
  120. data/lib/kitchen/mixins/block_error_if.rb +24 -4
  121. data/lib/kitchen/note_element.rb +48 -20
  122. data/lib/kitchen/note_element_enumerator.rb +9 -1
  123. data/lib/kitchen/oven.rb +66 -15
  124. data/lib/kitchen/page_element.rb +84 -14
  125. data/lib/kitchen/page_element_enumerator.rb +9 -1
  126. data/lib/kitchen/pantry.rb +28 -1
  127. data/lib/kitchen/patches/nokogiri.rb +19 -2
  128. data/lib/kitchen/patches/renderable.rb +9 -3
  129. data/lib/kitchen/patches/string.rb +8 -0
  130. data/lib/kitchen/recipe.rb +69 -32
  131. data/lib/kitchen/reference_element.rb +27 -0
  132. data/lib/kitchen/references_element_enumerator.rb +20 -0
  133. data/lib/kitchen/search_history.rb +43 -4
  134. data/lib/kitchen/search_query.rb +106 -0
  135. data/lib/kitchen/selector.rb +24 -0
  136. data/lib/kitchen/selectors/base.rb +65 -0
  137. data/lib/kitchen/selectors/standard_1.rb +21 -0
  138. data/lib/kitchen/table_element.rb +55 -7
  139. data/lib/kitchen/table_element_enumerator.rb +9 -1
  140. data/lib/kitchen/templates/eob_section_title_template.xhtml.erb +10 -0
  141. data/lib/kitchen/templates/eoc_section_title_template.xhtml.erb +10 -0
  142. data/lib/kitchen/term_element.rb +15 -4
  143. data/lib/kitchen/term_element_enumerator.rb +9 -1
  144. data/lib/kitchen/transliterations.rb +7 -5
  145. data/lib/kitchen/type_casting_element_enumerator.rb +17 -1
  146. data/lib/kitchen/unit_element.rb +45 -0
  147. data/lib/kitchen/unit_element_enumerator.rb +20 -0
  148. data/lib/kitchen/utils.rb +10 -13
  149. data/lib/kitchen/version.rb +5 -1
  150. data/lib/locales/en.yml +18 -7
  151. data/lib/locales/pl.yml +24 -0
  152. data/lib/openstax_kitchen.rb +59 -0
  153. data/openstax_kitchen.gemspec +26 -20
  154. data/tutorials/00/solution1.rb +9 -0
  155. data/tutorials/00/solution2.rb +8 -0
  156. data/tutorials/01/solution1.rb +18 -0
  157. data/tutorials/01/solution2.rb +26 -0
  158. data/tutorials/02/solution1.rb +31 -0
  159. data/tutorials/03/{solution_1.rb → solution1.rb} +6 -4
  160. data/tutorials/03/solution2.rb +18 -0
  161. data/tutorials/04/{solution_1.rb → solution1.rb} +4 -2
  162. data/tutorials/04/{solution_2.rb → solution2.rb} +6 -4
  163. data/tutorials/05/solution1.rb +11 -0
  164. data/tutorials/check_it +16 -15
  165. data/tutorials/setup_my_recipes +7 -6
  166. metadata +148 -27
  167. data/Dockerfile +0 -19
  168. data/bin/normalize +0 -79
  169. data/books/chemistry2e/bake.rb +0 -133
  170. data/docker-compose.yml +0 -12
  171. data/docker/entrypoint +0 -9
  172. data/lib/kitchen.rb +0 -57
  173. data/lib/kitchen/directions/bake_chapter_glossary.rb +0 -34
  174. data/lib/kitchen/directions/bake_exercises.rb +0 -164
  175. data/lib/kitchen/directions/bake_notes.rb +0 -58
  176. data/tutorials/00/solution_1.rb +0 -7
  177. data/tutorials/00/solution_2.rb +0 -6
  178. data/tutorials/01/solution_1.rb +0 -16
  179. data/tutorials/01/solution_2.rb +0 -24
  180. data/tutorials/02/solution_1.rb +0 -29
  181. data/tutorials/03/solution_2.rb +0 -15
  182. data/tutorials/05/solution_1.rb +0 -9
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Kitchen
4
+ module Directions
5
+ # Bake directions for link placeholders
6
+ #
7
+ module BakeLinkPlaceholders
8
+ def self.v1(book:)
9
+ book.search('a').each do |anchor|
10
+ next unless anchor.text == '[link]'
11
+
12
+ id = anchor[:href][1..-1]
13
+ replacement = book.pantry(name: :link_text).get(id)
14
+ if replacement.present?
15
+ anchor.replace_children(with: replacement)
16
+ else
17
+ # TODO: log a warning!
18
+ puts "warning! could not find a replacement for '[link]' on an element with ID '#{id}'"
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
@@ -1,13 +1,15 @@
1
+ # frozen-string-literal: true
2
+
1
3
  module Kitchen
2
4
  module Directions
5
+ # Wraps any math contained in a <p> tag
6
+ # with a <span> with class 'os-math-in-para'
3
7
  module BakeMathInParagraph
4
-
5
8
  def self.v1(book:)
6
- book.search("p m|math").each do |math|
9
+ book.search('p m|math', '//p//math | //p//m').each do |math|
7
10
  math.wrap("<span class='os-math-in-para'>")
8
11
  end
9
12
  end
10
-
11
13
  end
12
14
  end
13
15
  end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Kitchen
4
+ module Directions
5
+ module BakeNonIntroductionPages
6
+ def self.v1(chapter:)
7
+ chapter.non_introduction_pages.each do |page|
8
+ number = "#{chapter.count_in(:book)}.#{page.count_in(:chapter)}"
9
+
10
+ page.search("div[data-type='description']").each(&:trash)
11
+ page.add_class('chapter-content-module')
12
+
13
+ title = page.title
14
+ title.name = 'h2'
15
+ title.replace_children(with:
16
+ <<~HTML
17
+ <span class="os-number">#{number}</span>
18
+ <span class="os-divider"> </span>
19
+ <span data-type="" itemprop="" class="os-text">#{title.text}</span>
20
+ HTML
21
+ )
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Kitchen
4
+ module Directions
5
+ module BakeAutotitledNotes
6
+ def self.v1(book:, classes:)
7
+ book.notes.each do |note|
8
+ next unless (note.classes & classes).any?
9
+
10
+ bake_note(note: note)
11
+ end
12
+ end
13
+
14
+ def self.bake_note(note:)
15
+ note.wrap_children(class: 'os-note-body')
16
+
17
+ BakeNoteSubtitle.v1(note: note)
18
+
19
+ note.prepend(child:
20
+ <<~HTML
21
+ <h3 class="os-title" data-type="title">
22
+ <span class="os-title-label">#{note.autogenerated_title}</span>
23
+ </h3>
24
+ HTML
25
+ )
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Kitchen
4
+ module Directions
5
+ module BakeNoteSubtitle
6
+ def self.v1(note:)
7
+ title = note.title&.cut
8
+
9
+ return unless title
10
+
11
+ # Store label information
12
+ note_label = title.children
13
+ note.pantry(name: :link_text).store note_label, label: note.id
14
+
15
+ title.name = 'h4'
16
+ title.add_class('os-subtitle')
17
+ title.wrap_children('span', class: 'os-subtitle-label')
18
+ note.first!('.os-note-body').prepend(child: title.to_s)
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,51 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Kitchen
4
+ module Directions
5
+ module BakeNumberedNotes
6
+ def self.v1(book:, classes:)
7
+ classes.each do |klass|
8
+ book.chapters.notes("$.#{klass}").each do |note|
9
+ bake_note(note: note)
10
+ note.exercises.each do |exercise|
11
+ bake_note_exercise(note: note, exercise: exercise)
12
+ end
13
+ end
14
+ end
15
+ end
16
+
17
+ def self.bake_note(note:)
18
+ note.wrap_children(class: 'os-note-body')
19
+
20
+ chapter_count = note.ancestor(:chapter).count_in(:book)
21
+ note_count = note.count_in(:chapter)
22
+ note.prepend(child:
23
+ <<~HTML
24
+ <h3 class="os-title">
25
+ <span class="os-title-label">#{note.autogenerated_title}</span>
26
+ <span class="os-number">#{chapter_count}.#{note_count}</span>
27
+ <span class="os-divider"> </span>
28
+ </h3>
29
+ HTML
30
+ )
31
+
32
+ return unless note['use-subtitle']
33
+
34
+ BakeNoteSubtitle.v1(note: note)
35
+ end
36
+
37
+ def self.bake_note_exercise(note:, exercise:)
38
+ exercise.add_class('unnumbered')
39
+ # bake problem
40
+ exercise.problem.wrap_children('div', class: 'os-problem-container')
41
+ exercise.problem.first('strong')&.trash
42
+ exercise.search('[data-type="commentary"]').each(&:trash)
43
+ return unless exercise.solution
44
+
45
+ # bake solution in place
46
+ BakeNumberedExercise.bake_solution_v1(
47
+ exercise: exercise, number: note.first('.os-number').text, divider: ' ')
48
+ end
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Kitchen
4
+ module Directions
5
+ module BakeUnclassifiedNotes
6
+ def self.v1(book:)
7
+ book.notes.each do |note|
8
+ next unless note.classes.empty?
9
+
10
+ bake_note(note: note)
11
+ end
12
+ end
13
+
14
+ def self.bake_note(note:)
15
+ note.wrap_children(class: 'os-note-body')
16
+
17
+ title = note.title&.cut
18
+ return unless title
19
+
20
+ note.prepend(child:
21
+ <<~HTML
22
+ <h3 class="os-title" data-type="title">
23
+ <span class="os-title-label" data-type="" id="#{title[:id]}">#{title.children}</span>
24
+ </h3>
25
+ HTML
26
+ )
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Kitchen
4
+ module Directions
5
+ module BakeNumberedExercise
6
+ def self.v1(exercise:, number:, suppress_solution: false)
7
+ V1.new.bake(exercise: exercise, number: number, suppress_solution: suppress_solution)
8
+ end
9
+
10
+ def self.bake_solution_v1(exercise:, number:, divider: '. ')
11
+ V1.new.bake_solution(exercise: exercise, number: number, divider: divider)
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,47 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Kitchen::Directions::BakeNumberedExercise
4
+ class V1
5
+ def bake(exercise:, number:, suppress_solution: false)
6
+ problem = exercise.problem
7
+ solution = exercise.solution
8
+
9
+ exercise.pantry(name: :link_text).store(
10
+ "#{I18n.t(:exercise_label)} #{exercise.ancestor(:chapter).count_in(:book)}.#{number}",
11
+ label: exercise.id
12
+ )
13
+ problem_number = "<span class='os-number'>#{number}</span>"
14
+
15
+ if solution.present?
16
+ if suppress_solution
17
+ solution.trash
18
+ else
19
+ problem_number = "<a class='os-number' href='##{exercise.id}-solution'>#{number}</a>"
20
+ bake_solution(exercise: exercise, number: number)
21
+ end
22
+ end
23
+
24
+ problem.replace_children(with:
25
+ <<~HTML
26
+ #{problem_number}
27
+ <span class='os-divider'>. </span>
28
+ <div class="os-problem-container">#{problem.children}</div>
29
+ HTML
30
+ )
31
+ end
32
+
33
+ def bake_solution(exercise:, number:, divider: '. ')
34
+ solution = exercise.solution
35
+ solution.id = "#{exercise.id}-solution"
36
+ exercise.add_class('os-hasSolution')
37
+
38
+ solution.replace_children(with:
39
+ <<~HTML
40
+ <a class='os-number' href='##{exercise.id}'>#{number}</a>
41
+ <span class='os-divider'>#{divider}</span>
42
+ <div class="os-solution-container">#{solution.children}</div>
43
+ HTML
44
+ )
45
+ end
46
+ end
47
+ end
@@ -1,11 +1,11 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Kitchen
2
4
  module Directions
3
5
  module BakeNumberedTable
4
-
5
- def self.v1(table:, number:)
6
- V1.new.bake(table: table, number: number)
6
+ def self.v1(table:, number:, always_caption: false)
7
+ V1.new.bake(table: table, number: number, always_caption: always_caption)
7
8
  end
8
-
9
9
  end
10
10
  end
11
11
  end
@@ -1,13 +1,16 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Kitchen::Directions::BakeNumberedTable
2
4
  class V1
3
5
 
4
- def bake(table:, number:)
5
- table.wrap(%Q(<div class="os-table">))
6
+ def bake(table:, number:, always_caption: false)
7
+ table.wrap(%(<div class="os-table">))
6
8
 
7
9
  table_label = "#{I18n.t(:table_label)} #{number}"
8
- table.document.pantry(name: :link_text).store table_label, label: table.id
10
+ table.pantry(name: :link_text).store table_label, label: table.id
9
11
 
10
12
  if table.top_titled?
13
+ table.parent.add_class('os-top-titled-container')
11
14
  table.prepend(sibling:
12
15
  <<~HTML
13
16
  <div class="os-table-title">#{table.title}</div>
@@ -16,31 +19,47 @@ module Kitchen::Directions::BakeNumberedTable
16
19
  table.title_row.trash
17
20
  end
18
21
 
19
- # TODO extra spaces added here to match legacy implementation, but probably not meaningful?
20
- new_summary = table_label + " "
21
- new_caption = ""
22
+ table.parent.add_class('os-column-header-container') if table.column_header?
23
+
24
+ # TODO: extra spaces added here to match legacy implementation, but probably not meaningful?
25
+ new_summary = "#{table_label} "
26
+ new_caption = ''
27
+ caption_title = ''
28
+
29
+ if (title = table.first("span[data-type='title']")&.cut)
30
+ new_summary += title.text
31
+ caption_title = <<~HTML
32
+ \n<span class="os-title" data-type="title">#{title.children}</span>
33
+ HTML
34
+ end
35
+
36
+ new_summary += ' '
22
37
 
23
38
  if (caption = table.caption&.cut)
24
39
  new_summary += caption.text
25
40
  new_caption = <<~HTML
26
41
  \n<span class="os-caption">#{caption.children}</span>
27
42
  HTML
43
+ elsif always_caption
44
+ new_caption = <<~HTML
45
+ \n<span class="os-caption"></span>
46
+ HTML
28
47
  end
29
48
 
30
49
  table[:summary] = new_summary
31
50
 
32
- if !table.unnumbered?
33
- table.append(sibling:
34
- <<~HTML
35
- <div class="os-caption-container">
36
- <span class="os-title-label">#{I18n.t(:table_label)} </span>
37
- <span class="os-number">#{number}</span>
38
- <span class="os-divider"> </span>
39
- <span class="os-divider"> </span>#{new_caption}
40
- </div>
41
- HTML
42
- )
43
- end
51
+ return if table.unnumbered?
52
+
53
+ table.append(sibling:
54
+ <<~HTML
55
+ <div class="os-caption-container">
56
+ <span class="os-title-label">#{I18n.t(:table_label)} </span>
57
+ <span class="os-number">#{number}</span>
58
+ <span class="os-divider"> </span>#{caption_title}
59
+ <span class="os-divider"> </span>#{new_caption}
60
+ </div>
61
+ HTML
62
+ )
44
63
  end
45
64
 
46
65
  end
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Kitchen
4
+ module Directions
5
+ # Adds learning objectives header to abstracts
6
+ module BakePageAbstracts
7
+ def self.v1(chapter:)
8
+ chapter.abstracts.each do |abstract|
9
+ abstract.prepend(child: "<h3 data-type='title'>#{I18n.t(:learning_objectives)}</h3>")
10
+ end
11
+ end
12
+
13
+ def self.v2(chapter:)
14
+ chapter.abstracts.each do |abstract|
15
+ abstract.prepend(child: "<h3 data-type='title'>#{I18n.t(:learning_objectives)}</h3>")
16
+ ul = abstract.first!('ul')
17
+ ul.add_class('os-abstract')
18
+ ul.search('li').each_with_index do |li, index|
19
+ li.replace_children(with:
20
+ <<~HTML
21
+ <span class="os-abstract-token">#{chapter.count_in(:book)}.#{abstract.count_in(:chapter)}.#{index + 1}</span>
22
+ <span class="os-abstract-content">#{li.children}</span>
23
+ HTML
24
+ )
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Kitchen
4
+ module Directions
5
+ module BakePreface
6
+ def self.v1(book:)
7
+ V1.new.bake(book: book)
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Kitchen::Directions::BakePreface
4
+ class V1
5
+ def bake(book:)
6
+ book.pages('$.preface').each do |page|
7
+ page.titles.each do |title|
8
+ title.replace_children(with:
9
+ <<~HTML
10
+ <span data-type="" itemprop="" class="os-text">#{title.text}</span>
11
+ HTML
12
+ )
13
+ title.name = 'h1'
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Kitchen
4
+ module Directions
5
+ # Bake directions for EOB references
6
+ #
7
+ module BakeReferences
8
+ def self.v1(book:, metadata_source:)
9
+ V1.new.bake(
10
+ book: book,
11
+ metadata_source: metadata_source
12
+ )
13
+ end
14
+ end
15
+ end
16
+ end