openstax_kitchen 3.2.0 → 6.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (144) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/changelog.yml +27 -0
  3. data/.github/workflows/rubocop.yml +28 -0
  4. data/.gitignore +1 -1
  5. data/CHANGELOG.md +94 -1
  6. data/Gemfile.lock +26 -18
  7. data/README.md +16 -0
  8. data/codecov.yaml +1 -0
  9. data/docker/ci +0 -1
  10. data/docker/rubocop +22 -0
  11. data/lib/kitchen/book_document.rb +1 -1
  12. data/lib/kitchen/book_element.rb +16 -2
  13. data/lib/kitchen/chapter_element.rb +10 -13
  14. data/lib/kitchen/chapter_element_enumerator.rb +1 -1
  15. data/lib/kitchen/composite_chapter_element.rb +7 -11
  16. data/lib/kitchen/composite_chapter_element_enumerator.rb +21 -0
  17. data/lib/kitchen/composite_page_element.rb +15 -10
  18. data/lib/kitchen/composite_page_element_enumerator.rb +1 -1
  19. data/lib/kitchen/config.rb +14 -0
  20. data/lib/kitchen/directions/bake_appendix.rb +3 -1
  21. data/lib/kitchen/directions/bake_chapter_glossary/main.rb +18 -0
  22. data/lib/kitchen/directions/bake_chapter_glossary/v1.rb +30 -0
  23. data/lib/kitchen/directions/bake_chapter_introductions.rb +23 -16
  24. data/lib/kitchen/directions/bake_chapter_introductions/chapter_introduction.xhtml.erb +0 -0
  25. data/lib/kitchen/directions/bake_chapter_key_concepts/main.rb +7 -2
  26. data/lib/kitchen/directions/bake_chapter_key_concepts/v1.rb +12 -7
  27. data/lib/kitchen/directions/bake_chapter_key_equations.rb +26 -21
  28. data/lib/kitchen/directions/bake_chapter_references/main.rb +16 -0
  29. data/lib/kitchen/directions/bake_chapter_references/v1.rb +35 -0
  30. data/lib/kitchen/directions/bake_chapter_section_exercises/main.rb +2 -2
  31. data/lib/kitchen/directions/bake_chapter_section_exercises/v1.rb +2 -1
  32. data/lib/kitchen/directions/bake_chapter_solutions/main.rb +11 -0
  33. data/lib/kitchen/directions/bake_chapter_solutions/v1.rb +37 -0
  34. data/lib/kitchen/directions/bake_chapter_summary.rb +56 -43
  35. data/lib/kitchen/directions/bake_composite_chapters.rb +1 -1
  36. data/lib/kitchen/directions/bake_composite_pages.rb +1 -1
  37. data/lib/kitchen/directions/bake_equations.rb +2 -2
  38. data/lib/kitchen/directions/bake_example.rb +8 -1
  39. data/lib/kitchen/directions/bake_figure.rb +14 -1
  40. data/lib/kitchen/directions/bake_first_elements.rb +22 -0
  41. data/lib/kitchen/directions/bake_footnotes/main.rb +2 -2
  42. data/lib/kitchen/directions/bake_footnotes/v1.rb +13 -9
  43. data/lib/kitchen/directions/bake_free_response/free_response.xhtml.erb +10 -0
  44. data/lib/kitchen/directions/{bake_chapter_review → bake_free_response}/main.rb +3 -3
  45. data/lib/kitchen/directions/bake_free_response/v1.rb +29 -0
  46. data/lib/kitchen/directions/bake_further_research.rb +61 -0
  47. data/lib/kitchen/directions/bake_index/v1.rb +36 -26
  48. data/lib/kitchen/directions/bake_link_placeholders.rb +1 -1
  49. data/lib/kitchen/directions/bake_notes/bake_note_subtitle.rb +4 -0
  50. data/lib/kitchen/directions/bake_notes/bake_numbered_notes/main.rb +43 -0
  51. data/lib/kitchen/directions/bake_notes/bake_numbered_notes/v1.rb +37 -0
  52. data/lib/kitchen/directions/bake_notes/bake_numbered_notes/v2.rb +25 -0
  53. data/lib/kitchen/directions/bake_notes/bake_numbered_notes/v3.rb +32 -0
  54. data/lib/kitchen/directions/bake_numbered_exercise/main.rb +7 -2
  55. data/lib/kitchen/directions/bake_numbered_exercise/v1.rb +34 -12
  56. data/lib/kitchen/directions/bake_numbered_table/bake_table_body.rb +29 -0
  57. data/lib/kitchen/directions/bake_numbered_table/main.rb +4 -0
  58. data/lib/kitchen/directions/bake_numbered_table/v1.rb +1 -24
  59. data/lib/kitchen/directions/bake_numbered_table/v2.rb +31 -0
  60. data/lib/kitchen/directions/bake_page_abstracts.rb +1 -1
  61. data/lib/kitchen/directions/bake_preface/main.rb +2 -2
  62. data/lib/kitchen/directions/bake_preface/v1.rb +3 -2
  63. data/lib/kitchen/directions/bake_references/main.rb +16 -0
  64. data/lib/kitchen/directions/bake_references/v1.rb +48 -0
  65. data/lib/kitchen/directions/bake_suggested_reading.rb +5 -0
  66. data/lib/kitchen/directions/bake_toc.rb +4 -2
  67. data/lib/kitchen/directions/book_answer_key_container/eob_answer_key_outer_container.xhtml.erb +9 -0
  68. data/lib/kitchen/directions/book_answer_key_container/main.rb +11 -0
  69. data/lib/kitchen/directions/book_answer_key_container/v1.rb +14 -0
  70. data/lib/kitchen/directions/chapter_review_container/chapter_review.xhtml.erb +9 -0
  71. data/lib/kitchen/directions/chapter_review_container/main.rb +11 -0
  72. data/lib/kitchen/directions/chapter_review_container/v1.rb +15 -0
  73. data/lib/kitchen/directions/eoc_section_title_link_snippet.rb +14 -1
  74. data/lib/kitchen/directions/move_exercises_to_eoc/main.rb +37 -0
  75. data/lib/kitchen/directions/{bake_chapter_review_exercises → move_exercises_to_eoc}/v1.rb +8 -10
  76. data/lib/kitchen/directions/{bake_chapter_review_exercises → move_exercises_to_eoc}/v2.rb +8 -9
  77. data/lib/kitchen/directions/move_exercises_to_eoc/v3.rb +49 -0
  78. data/lib/kitchen/directions/{bake_chapter_answer_key → move_solutions_to_answer_key}/main.rb +7 -3
  79. data/lib/kitchen/directions/{bake_chapter_answer_key → move_solutions_to_answer_key}/strategies/calculus.rb +1 -1
  80. data/lib/kitchen/directions/move_solutions_to_answer_key/strategies/default.rb +27 -0
  81. data/lib/kitchen/directions/move_solutions_to_answer_key/strategies/precalculus.rb +84 -0
  82. data/lib/kitchen/directions/{bake_chapter_answer_key → move_solutions_to_answer_key}/strategies/uphysics.rb +7 -5
  83. data/lib/kitchen/directions/{bake_chapter_answer_key → move_solutions_to_answer_key}/v1.rb +12 -6
  84. data/lib/kitchen/document.rb +20 -42
  85. data/lib/kitchen/element.rb +9 -3
  86. data/lib/kitchen/element_base.rb +108 -21
  87. data/lib/kitchen/element_enumerator_base.rb +33 -2
  88. data/lib/kitchen/element_enumerator_factory.rb +28 -12
  89. data/lib/kitchen/element_factory.rb +3 -3
  90. data/lib/kitchen/example_element.rb +8 -11
  91. data/lib/kitchen/example_element_enumerator.rb +1 -1
  92. data/lib/kitchen/exercise_element.rb +7 -10
  93. data/lib/kitchen/exercise_element_enumerator.rb +1 -1
  94. data/lib/kitchen/figure_element.rb +8 -11
  95. data/lib/kitchen/figure_element_enumerator.rb +1 -1
  96. data/lib/kitchen/id_tracker.rb +68 -0
  97. data/lib/kitchen/metadata_element.rb +8 -2
  98. data/lib/kitchen/metadata_element_enumerator.rb +1 -1
  99. data/lib/kitchen/note_element.rb +8 -11
  100. data/lib/kitchen/note_element_enumerator.rb +1 -1
  101. data/lib/kitchen/oven.rb +5 -1
  102. data/lib/kitchen/page_element.rb +27 -12
  103. data/lib/kitchen/page_element_enumerator.rb +1 -1
  104. data/lib/kitchen/patches/i18n.rb +34 -0
  105. data/lib/kitchen/patches/integer.rb +24 -0
  106. data/lib/kitchen/patches/nokogiri.rb +62 -0
  107. data/lib/kitchen/patches/nokogiri_profiling.rb +60 -0
  108. data/lib/kitchen/reference_element.rb +27 -0
  109. data/lib/kitchen/references_element_enumerator.rb +20 -0
  110. data/lib/kitchen/search_query.rb +31 -3
  111. data/lib/kitchen/selector.rb +25 -0
  112. data/lib/kitchen/selectors/base.rb +39 -0
  113. data/lib/kitchen/selectors/standard_1.rb +13 -0
  114. data/lib/kitchen/table_element.rb +8 -11
  115. data/lib/kitchen/table_element_enumerator.rb +1 -1
  116. data/lib/kitchen/templates/eob_section_title_template.xhtml.erb +10 -0
  117. data/lib/kitchen/templates/eoc_section_title_template.xhtml.erb +10 -0
  118. data/lib/kitchen/term_element.rb +5 -8
  119. data/lib/kitchen/term_element_enumerator.rb +1 -1
  120. data/lib/kitchen/unit_element.rb +13 -7
  121. data/lib/kitchen/unit_element_enumerator.rb +1 -1
  122. data/lib/kitchen/version.rb +1 -1
  123. data/lib/locales/en.yml +5 -1
  124. data/lib/locales/es.yml +33 -0
  125. data/lib/locales/pl.yml +3 -2
  126. data/lib/openstax_kitchen.rb +2 -5
  127. data/openstax_kitchen.gemspec +1 -0
  128. metadata +66 -25
  129. data/.github/config.yml +0 -14
  130. data/lib/kitchen/directions/bake_book_answer_key/eob_solutions_container.xhtml.erb +0 -9
  131. data/lib/kitchen/directions/bake_book_answer_key/main.rb +0 -11
  132. data/lib/kitchen/directions/bake_book_answer_key/v1.rb +0 -13
  133. data/lib/kitchen/directions/bake_chapter_glossary.rb +0 -39
  134. data/lib/kitchen/directions/bake_chapter_key_concepts/key_concepts.xhtml.erb +0 -16
  135. data/lib/kitchen/directions/bake_chapter_review/chapter_review.xhtml.erb +0 -9
  136. data/lib/kitchen/directions/bake_chapter_review/v1.rb +0 -13
  137. data/lib/kitchen/directions/bake_chapter_review_exercises/main.rb +0 -15
  138. data/lib/kitchen/directions/bake_chapter_review_exercises/review_exercises.xhtml.erb +0 -10
  139. data/lib/kitchen/directions/bake_exercises/main.rb +0 -12
  140. data/lib/kitchen/directions/bake_exercises/v1.rb +0 -169
  141. data/lib/kitchen/directions/bake_notes/bake_notes.rb +0 -48
  142. data/lib/kitchen/directions/bake_notes/bake_numbered_notes.rb +0 -63
  143. data/lib/kitchen/directions/bake_problem_first_elements.rb +0 -16
  144. data/lib/kitchen/transliterations.rb +0 -21
@@ -10,7 +10,7 @@ module Kitchen
10
10
  next unless anchor.text == '[link]'
11
11
 
12
12
  id = anchor[:href][1..-1]
13
- replacement = book.document.pantry(name: :link_text).get(id)
13
+ replacement = book.pantry(name: :link_text).get(id)
14
14
  if replacement.present?
15
15
  anchor.replace_children(with: replacement)
16
16
  else
@@ -8,6 +8,10 @@ module Kitchen
8
8
 
9
9
  return unless title
10
10
 
11
+ # Store label information
12
+ note_label = title.children
13
+ note.pantry(name: :link_text).store note_label, label: note.id
14
+
11
15
  title.name = 'h4'
12
16
  title.add_class('os-subtitle')
13
17
  title.wrap_children('span', class: 'os-subtitle-label')
@@ -0,0 +1,43 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Kitchen
4
+ module Directions
5
+ module BakeNumberedNotes
6
+ def self.v1(book:, classes:)
7
+ V1.new.bake(book: book, classes: classes)
8
+ end
9
+
10
+ def self.v2(book:, classes:)
11
+ V2.new.bake(book: book, classes: classes)
12
+ end
13
+
14
+ # V3 bakes notes tied to an example immediately previous ("Try It" notes)
15
+ # Must be called AFTER BakeExercises
16
+ #
17
+ def self.v3(book:, classes:, suppress_solution: true)
18
+ V3.new.bake(book: book, classes: classes, suppress_solution: suppress_solution)
19
+ end
20
+
21
+ # Used by V1, V2, V3
22
+ def self.bake_note_exercise(note:, exercise:, divider: ' ', suppress_solution: false)
23
+ exercise.add_class('unnumbered')
24
+ # bake problem
25
+ exercise.problem.wrap_children('div', class: 'os-problem-container')
26
+ exercise.search('[data-type="commentary"]').each(&:trash)
27
+ return unless exercise.solution
28
+
29
+ # bake solution in place
30
+ if suppress_solution
31
+ exercise.add_class('os-hasSolution')
32
+ exercise.solution.trash
33
+ else
34
+ BakeNumberedExercise.bake_solution_v1(
35
+ exercise: exercise,
36
+ number: note.first('.os-number').text.gsub(/#/, ''),
37
+ divider: divider
38
+ )
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Kitchen::Directions::BakeNumberedNotes
4
+
5
+ class V1
6
+ def bake(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
+ Kitchen::Directions::BakeNumberedNotes.bake_note_exercise(note: note, exercise: exercise)
12
+ end
13
+ end
14
+ end
15
+ end
16
+
17
+ def 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
+ Kitchen::Directions::BakeNoteSubtitle.v1(note: note)
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Kitchen::Directions::BakeNumberedNotes
4
+ class V2
5
+ def bake(book:, classes:)
6
+ classes.each do |klass|
7
+ book.chapters.pages.notes("$.#{klass}").each do |note|
8
+ note.wrap_children(class: 'os-note-body')
9
+ note_count = note.count_in(:page)
10
+ note.prepend(child:
11
+ <<~HTML
12
+ <h3 class="os-title">
13
+ <span class="os-title-label">#{note.autogenerated_title}</span>
14
+ <span class="os-number">##{note_count}</span>
15
+ </h3>
16
+ HTML
17
+ )
18
+ note.exercises.each do |exercise|
19
+ Kitchen::Directions::BakeNumberedNotes.bake_note_exercise(note: note, exercise: exercise, divider: '. ')
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Kitchen::Directions::BakeNumberedNotes
4
+ class V3
5
+ # for the try it notes, must be called AFTER bake_exercises
6
+ def bake(book:, classes:, suppress_solution: true)
7
+ classes.each do |klass|
8
+ book.chapters.notes("$.#{klass}").each do |note|
9
+ note.wrap_children(class: 'os-note-body')
10
+ previous_example = note.previous
11
+ os_number = previous_example&.first('.os-number')&.children&.to_s
12
+
13
+ note.prepend(child:
14
+ <<~HTML
15
+ <h3 class="os-title">
16
+ <span class="os-title-label">#{note.autogenerated_title}</span>
17
+ <span class="os-number">#{os_number}</span>
18
+ </h3>
19
+ HTML
20
+ )
21
+
22
+ note.title&.trash
23
+ note.exercises.each do |exercise|
24
+ Kitchen::Directions::BakeNumberedNotes.bake_note_exercise(
25
+ note: note, exercise: exercise, divider: '. ', suppress_solution: suppress_solution
26
+ )
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -3,8 +3,13 @@
3
3
  module Kitchen
4
4
  module Directions
5
5
  module BakeNumberedExercise
6
- def self.v1(exercise:, number:)
7
- V1.new.bake(exercise: exercise, number: number)
6
+ def self.v1(exercise:, number:, suppress_solution_if: false, note_suppressed_solutions: false)
7
+ V1.new.bake(exercise: exercise, number: number, suppress_solution_if: suppress_solution_if,
8
+ note_suppressed_solutions: note_suppressed_solutions)
9
+ end
10
+
11
+ def self.bake_solution_v1(exercise:, number:, divider: '. ')
12
+ V1.new.bake_solution(exercise: exercise, number: number, divider: divider)
8
13
  end
9
14
  end
10
15
  end
@@ -2,24 +2,32 @@
2
2
 
3
3
  module Kitchen::Directions::BakeNumberedExercise
4
4
  class V1
5
- def bake(exercise:, number:)
5
+ def bake(exercise:, number:, suppress_solution_if: false, note_suppressed_solutions: false)
6
6
  problem = exercise.problem
7
7
  solution = exercise.solution
8
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
+ )
9
13
  problem_number = "<span class='os-number'>#{number}</span>"
10
14
 
11
- if solution.present?
12
- solution.id = "#{exercise.id}-solution"
13
- exercise.add_class('os-hasSolution')
14
- problem_number = "<a class='os-number' href='##{exercise.id}-solution'>#{number}</a>"
15
+ suppress_solution =
16
+ case suppress_solution_if
17
+ when Symbol
18
+ number.send(suppress_solution_if)
19
+ else
20
+ suppress_solution_if
21
+ end
15
22
 
16
- solution.replace_children(with:
17
- <<~HTML
18
- <a class='os-number' href='##{exercise.id}'>#{number}</a>
19
- <span class='os-divider'>. </span>
20
- <div class="os-solution-container">#{solution.children}</div>
21
- HTML
22
- )
23
+ if solution.present?
24
+ if suppress_solution
25
+ solution.trash
26
+ exercise.add_class('os-hasSolution-trashed') if note_suppressed_solutions
27
+ else
28
+ problem_number = "<a class='os-number' href='##{exercise.id}-solution'>#{number}</a>"
29
+ bake_solution(exercise: exercise, number: number)
30
+ end
23
31
  end
24
32
 
25
33
  problem.replace_children(with:
@@ -30,5 +38,19 @@ module Kitchen::Directions::BakeNumberedExercise
30
38
  HTML
31
39
  )
32
40
  end
41
+
42
+ def bake_solution(exercise:, number:, divider: '. ')
43
+ solution = exercise.solution
44
+ solution.id = "#{exercise.id}-solution"
45
+ exercise.add_class('os-hasSolution')
46
+
47
+ solution.replace_children(with:
48
+ <<~HTML
49
+ <a class='os-number' href='##{exercise.id}'>#{number}</a>
50
+ <span class='os-divider'>#{divider}</span>
51
+ <div class="os-solution-container">#{solution.children}</div>
52
+ HTML
53
+ )
54
+ end
33
55
  end
34
56
  end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Kitchen
4
+ module Directions
5
+ # Bake directions for table body
6
+ #
7
+ module BakeTableBody
8
+ def self.v1(table:, number:)
9
+ table.remove_attribute('summary')
10
+ table.wrap(%(<div class="os-table">))
11
+
12
+ table_label = "#{I18n.t(:table_label)} #{number}"
13
+ table.pantry(name: :link_text).store table_label, label: table.id
14
+
15
+ if table.top_titled?
16
+ table.parent.add_class('os-top-titled-container')
17
+ table.prepend(sibling:
18
+ <<~HTML
19
+ <div class="os-table-title">#{table.title}</div>
20
+ HTML
21
+ )
22
+ table.title_row.trash
23
+ end
24
+
25
+ table.parent.add_class('os-column-header-container') if table.column_header?
26
+ end
27
+ end
28
+ end
29
+ end
@@ -6,6 +6,10 @@ module Kitchen
6
6
  def self.v1(table:, number:, always_caption: false)
7
7
  V1.new.bake(table: table, number: number, always_caption: always_caption)
8
8
  end
9
+
10
+ def self.v2(table:, number:)
11
+ V2.new.bake(table: table, number: number)
12
+ end
9
13
  end
10
14
  end
11
15
  end
@@ -4,39 +4,19 @@ module Kitchen::Directions::BakeNumberedTable
4
4
  class V1
5
5
 
6
6
  def bake(table:, number:, always_caption: false)
7
- table.wrap(%(<div class="os-table">))
8
-
9
- table_label = "#{I18n.t(:table_label)} #{number}"
10
- table.document.pantry(name: :link_text).store table_label, label: table.id
11
-
12
- if table.top_titled?
13
- table.parent.add_class('os-top-titled-container')
14
- table.prepend(sibling:
15
- <<~HTML
16
- <div class="os-table-title">#{table.title}</div>
17
- HTML
18
- )
19
- table.title_row.trash
20
- end
21
-
22
- table.parent.add_class('os-column-header-container') if table.column_header?
7
+ Kitchen::Directions::BakeTableBody.v1(table: table, number: number)
23
8
 
24
9
  # TODO: extra spaces added here to match legacy implementation, but probably not meaningful?
25
- new_summary = "#{table_label} "
26
10
  new_caption = ''
27
11
  caption_title = ''
28
12
 
29
13
  if (title = table.first("span[data-type='title']")&.cut)
30
- new_summary += title.text
31
14
  caption_title = <<~HTML
32
15
  \n<span class="os-title" data-type="title">#{title.children}</span>
33
16
  HTML
34
17
  end
35
18
 
36
- new_summary += ' '
37
-
38
19
  if (caption = table.caption&.cut)
39
- new_summary += caption.text
40
20
  new_caption = <<~HTML
41
21
  \n<span class="os-caption">#{caption.children}</span>
42
22
  HTML
@@ -46,8 +26,6 @@ module Kitchen::Directions::BakeNumberedTable
46
26
  HTML
47
27
  end
48
28
 
49
- table[:summary] = new_summary
50
-
51
29
  return if table.unnumbered?
52
30
 
53
31
  table.append(sibling:
@@ -61,6 +39,5 @@ module Kitchen::Directions::BakeNumberedTable
61
39
  HTML
62
40
  )
63
41
  end
64
-
65
42
  end
66
43
  end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Kitchen::Directions::BakeNumberedTable
4
+ # Difference from v1: only in the caption
5
+ # V2 caption titles are nested within an .os-caption span
6
+ class V2
7
+
8
+ def bake(table:, number:)
9
+ Kitchen::Directions::BakeTableBody.v1(table: table, number: number)
10
+
11
+ caption = ''
12
+ if table&.caption&.first("span[data-type='title']")
13
+ caption_el = table.caption
14
+ caption_el.add_class('os-caption')
15
+ caption_el.name = 'span'
16
+ caption = caption_el.cut
17
+ end
18
+
19
+ table.append(sibling:
20
+ <<~HTML
21
+ <div class="os-caption-container">
22
+ <span class="os-title-label">#{I18n.t(:table_label)} </span>
23
+ <span class="os-number">#{number}</span>
24
+ <span class="os-divider"> </span>
25
+ #{caption}
26
+ </div>
27
+ HTML
28
+ )
29
+ end
30
+ end
31
+ end
@@ -19,7 +19,7 @@ module Kitchen
19
19
  li.replace_children(with:
20
20
  <<~HTML
21
21
  <span class="os-abstract-token">#{chapter.count_in(:book)}.#{abstract.count_in(:chapter)}.#{index + 1}</span>
22
- <span class="os-abstract-content">#{li.text}</span>
22
+ <span class="os-abstract-content">#{li.children}</span>
23
23
  HTML
24
24
  )
25
25
  end
@@ -3,8 +3,8 @@
3
3
  module Kitchen
4
4
  module Directions
5
5
  module BakePreface
6
- def self.v1(book:)
7
- V1.new.bake(book: book)
6
+ def self.v1(book:, title_element: 'h1')
7
+ V1.new.bake(book: book, title_element: title_element)
8
8
  end
9
9
  end
10
10
  end
@@ -2,15 +2,16 @@
2
2
 
3
3
  module Kitchen::Directions::BakePreface
4
4
  class V1
5
- def bake(book:)
5
+ def bake(book:, title_element:)
6
6
  book.pages('$.preface').each do |page|
7
+ page.search('div[data-type="description"], div[data-type="abstract"]').each(&:trash)
7
8
  page.titles.each do |title|
8
9
  title.replace_children(with:
9
10
  <<~HTML
10
11
  <span data-type="" itemprop="" class="os-text">#{title.text}</span>
11
12
  HTML
12
13
  )
13
- title.name = 'h1'
14
+ title.name = title_element
14
15
  end
15
16
  end
16
17
  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
@@ -0,0 +1,48 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Kitchen::Directions::BakeReferences
4
+ class V1
5
+ renderable
6
+
7
+ def bake(book:, metadata_source:)
8
+ @metadata = metadata_source.children_to_keep.copy
9
+ @klass = 'reference'
10
+ @uuid_prefix = '.'
11
+ @title = I18n.t(:references)
12
+
13
+ book.chapters.each do |chapter|
14
+ chapter.search('[data-type="cite"]').each do |link|
15
+ link.prepend(child:
16
+ <<~HTML
17
+ <sup class="os-citation-number">#{link.count_in(:chapter)}</sup>
18
+ HTML
19
+ )
20
+ end
21
+
22
+ chapter.references.each do |reference|
23
+ reference.prepend(child:
24
+ <<~HTML.chomp
25
+ <span class="os-reference-number">#{reference.count_in(:chapter)}. </span>
26
+ HTML
27
+ )
28
+ end
29
+
30
+ chapter_references = chapter.pages.references.cut
31
+ chapter_title_no_num = chapter.title.search('.os-text')
32
+
33
+ chapter.append(child:
34
+ <<~HTML
35
+ <div class="os-chapter-area">
36
+ <h2 data-type="document-title">#{chapter_title_no_num}</h2>
37
+ #{chapter_references.paste}
38
+ </div>
39
+ HTML
40
+ )
41
+ end
42
+ chapter_area_references = book.chapters.search('.os-chapter-area').cut
43
+ @content = chapter_area_references.paste
44
+ book.body.append(child: render(file:
45
+ '../../templates/eob_section_title_template.xhtml.erb'))
46
+ end
47
+ end
48
+ end