openstax_kitchen 9.1.0 → 11.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (93) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +63 -0
  3. data/Gemfile.lock +2 -2
  4. data/lib/kitchen/chapter_element.rb +8 -0
  5. data/lib/kitchen/composite_page_element.rb +8 -0
  6. data/lib/kitchen/directions/bake_annotation_classes/main.rb +12 -0
  7. data/lib/kitchen/directions/bake_annotation_classes/v1.rb +32 -0
  8. data/lib/kitchen/directions/bake_chapter_glossary/main.rb +3 -2
  9. data/lib/kitchen/directions/bake_chapter_glossary/v1.rb +10 -1
  10. data/lib/kitchen/directions/bake_chapter_introductions/bake_chapter_objectives.rb +46 -0
  11. data/lib/kitchen/directions/bake_chapter_introductions/bake_chapter_outline.rb +14 -0
  12. data/lib/kitchen/directions/bake_chapter_introductions/main.rb +43 -0
  13. data/lib/kitchen/directions/bake_chapter_introductions/v1.rb +56 -0
  14. data/lib/kitchen/directions/bake_chapter_introductions/v2.rb +91 -0
  15. data/lib/kitchen/directions/bake_chapter_key_concepts/v1.rb +11 -21
  16. data/lib/kitchen/directions/bake_chapter_references/v1.rb +1 -3
  17. data/lib/kitchen/directions/bake_chapter_solutions/main.rb +7 -2
  18. data/lib/kitchen/directions/bake_chapter_solutions/v1.rb +11 -9
  19. data/lib/kitchen/directions/bake_chapter_summary.rb +1 -2
  20. data/lib/kitchen/directions/bake_custom_sections/main.rb +14 -0
  21. data/lib/kitchen/directions/bake_custom_sections/v1.rb +42 -0
  22. data/lib/kitchen/directions/bake_eoc_section_content/change_subsection_title_tag.rb +13 -0
  23. data/lib/kitchen/directions/bake_equations.rb +2 -3
  24. data/lib/kitchen/directions/bake_example.rb +9 -12
  25. data/lib/kitchen/directions/bake_figure.rb +5 -3
  26. data/lib/kitchen/directions/bake_first_elements.rb +15 -2
  27. data/lib/kitchen/directions/bake_folio.rb +12 -0
  28. data/lib/kitchen/directions/bake_free_response/v1.rb +1 -1
  29. data/lib/kitchen/directions/bake_further_research.rb +1 -3
  30. data/lib/kitchen/directions/bake_handbook/main.rb +11 -0
  31. data/lib/kitchen/directions/bake_handbook/v1.rb +74 -0
  32. data/lib/kitchen/directions/bake_iframes/main.rb +11 -0
  33. data/lib/kitchen/directions/bake_iframes/v1.rb +25 -0
  34. data/lib/kitchen/directions/bake_index/main.rb +2 -2
  35. data/lib/kitchen/directions/bake_index/v1.rb +39 -7
  36. data/lib/kitchen/directions/bake_index/v1.xhtml.erb +3 -3
  37. data/lib/kitchen/directions/bake_injected_exercise.rb +18 -0
  38. data/lib/kitchen/directions/bake_injected_exercise_question.rb +71 -0
  39. data/lib/kitchen/directions/bake_link_placeholders.rb +15 -2
  40. data/lib/kitchen/directions/bake_lists_with_para.rb +17 -0
  41. data/lib/kitchen/directions/bake_notes/bake_autotitled_notes.rb +5 -5
  42. data/lib/kitchen/directions/bake_notes/bake_note_subtitle.rb +6 -2
  43. data/lib/kitchen/directions/bake_notes/bake_numbered_notes/main.rb +13 -3
  44. data/lib/kitchen/directions/bake_notes/bake_numbered_notes/v1.rb +29 -25
  45. data/lib/kitchen/directions/bake_notes/bake_numbered_notes/v2.rb +22 -17
  46. data/lib/kitchen/directions/bake_notes/bake_numbered_notes/v3.rb +27 -22
  47. data/lib/kitchen/directions/bake_numbered_exercise/main.rb +3 -2
  48. data/lib/kitchen/directions/bake_numbered_exercise/v1.rb +6 -5
  49. data/lib/kitchen/directions/bake_numbered_table/bake_table_body.rb +57 -16
  50. data/lib/kitchen/directions/bake_numbered_table/main.rb +4 -4
  51. data/lib/kitchen/directions/bake_numbered_table/v1.rb +4 -4
  52. data/lib/kitchen/directions/bake_numbered_table/v2.rb +4 -4
  53. data/lib/kitchen/directions/bake_toc.rb +8 -1
  54. data/lib/kitchen/directions/bake_unit_page_title/main.rb +11 -0
  55. data/lib/kitchen/directions/bake_unit_page_title/v1.rb +23 -0
  56. data/lib/kitchen/directions/eoc_section_title_link_snippet.rb +32 -21
  57. data/lib/kitchen/directions/move_custom_section_to_eoc_container/main.rb +4 -3
  58. data/lib/kitchen/directions/move_custom_section_to_eoc_container/v1.rb +19 -3
  59. data/lib/kitchen/directions/move_exercises_to_eoc/v1.rb +1 -2
  60. data/lib/kitchen/directions/move_exercises_to_eoc/v2.rb +11 -30
  61. data/lib/kitchen/directions/move_exercises_to_eoc/v3.rb +1 -2
  62. data/lib/kitchen/directions/move_solutions_to_answer_key/move_solutions_from_exercise_section.rb +34 -0
  63. data/lib/kitchen/directions/move_solutions_to_answer_key/move_solutions_from_numbered_note.rb +27 -0
  64. data/lib/kitchen/directions/move_solutions_to_answer_key/solution_area_snippet.rb +12 -0
  65. data/lib/kitchen/directions/move_solutions_to_answer_key/strategies/calculus.rb +1 -1
  66. data/lib/kitchen/directions/move_solutions_to_answer_key/strategies/contemporary_math.rb +40 -0
  67. data/lib/kitchen/directions/move_solutions_to_answer_key/strategies/default.rb +1 -1
  68. data/lib/kitchen/directions/move_solutions_to_answer_key/strategies/precalculus.rb +18 -39
  69. data/lib/kitchen/directions/move_solutions_to_answer_key/strategies/uphysics.rb +6 -48
  70. data/lib/kitchen/directions/move_solutions_to_answer_key/v1.rb +10 -3
  71. data/lib/kitchen/element_base.rb +36 -4
  72. data/lib/kitchen/element_enumerator_base.rb +35 -0
  73. data/lib/kitchen/example_element.rb +9 -3
  74. data/lib/kitchen/exercise_element.rb +8 -0
  75. data/lib/kitchen/figure_element.rb +11 -0
  76. data/lib/kitchen/injected_question_element.rb +77 -0
  77. data/lib/kitchen/injected_question_element_enumerator.rb +21 -0
  78. data/lib/kitchen/note_element.rb +8 -1
  79. data/lib/kitchen/page_element.rb +12 -9
  80. data/lib/kitchen/selectors/base.rb +6 -0
  81. data/lib/kitchen/selectors/standard_1.rb +3 -0
  82. data/lib/kitchen/solution_element_enumerator.rb +21 -0
  83. data/lib/kitchen/table_element.rb +25 -0
  84. data/lib/kitchen/version.rb +1 -1
  85. data/lib/locales/en.yml +10 -4
  86. data/lib/locales/es.yml +8 -4
  87. data/lib/locales/pl.yml +52 -7
  88. metadata +30 -8
  89. data/lib/kitchen/directions/bake_chapter_introductions/chapter_introduction.xhtml.erb +0 -0
  90. data/lib/kitchen/directions/bake_chapter_introductions.rb +0 -65
  91. data/lib/kitchen/directions/bake_notes/bake_note_iframes.rb +0 -27
  92. data/lib/kitchen/directions/bake_theorem/main.rb +0 -11
  93. data/lib/kitchen/directions/bake_theorem/v1.rb +0 -28
@@ -3,29 +3,19 @@
3
3
  module Kitchen::Directions::BakeChapterKeyConcepts
4
4
  class V1
5
5
  def bake(chapter:, metadata_source:, append_to:, uuid_prefix:)
6
- key_concepts_clipboard = Kitchen::Clipboard.new
7
- chapter.non_introduction_pages.each do |page|
8
- key_concepts = page.key_concepts
9
- next if key_concepts.none?
10
-
11
- title = Kitchen::Directions::EocSectionTitleLinkSnippet.v1(page: page)
12
- key_concepts.each do |key_concept|
13
- Kitchen::Directions::RemoveSectionTitle.v1(section: key_concept)
14
- key_concept.prepend(child: title)
15
- key_concept.wrap("<div class='os-section-area'>")
16
- page.search('div.os-section-area').first.cut(to: key_concepts_clipboard)
17
- end
18
- end
19
-
20
- content = "<div class=\"os-key-concepts\"> #{key_concepts_clipboard.paste} </div>"
21
-
22
- Kitchen::Directions::EocCompositePageContainer.v1(
6
+ Kitchen::Directions::MoveCustomSectionToEocContainer.v1(
7
+ chapter: chapter,
8
+ metadata_source: metadata_source,
23
9
  container_key: 'key-concepts',
24
10
  uuid_key: "#{uuid_prefix}key-concepts",
25
- metadata_source: metadata_source,
26
- content: content,
27
- append_to: append_to || chapter
28
- )
11
+ section_selector: 'section.key-concepts',
12
+ append_to: append_to || chapter,
13
+ wrap_section: true, wrap_content: true
14
+ ) do |section|
15
+ Kitchen::Directions::RemoveSectionTitle.v1(section: section)
16
+ title = Kitchen::Directions::EocSectionTitleLinkSnippet.v1(page: section.ancestor(:page))
17
+ section.prepend(child: title)
18
+ end
29
19
  end
30
20
  end
31
21
  end
@@ -3,9 +3,7 @@
3
3
  module Kitchen::Directions::BakeChapterReferences
4
4
  class V1
5
5
  def bake(chapter:, metadata_source:, uuid_prefix: '.', klass: 'references')
6
- bake_page_references(page: chapter.introduction_page)
7
-
8
- chapter.non_introduction_pages.each do |page|
6
+ chapter.pages.each do |page|
9
7
  bake_page_references(page: page)
10
8
  end
11
9
 
@@ -3,8 +3,13 @@
3
3
  module Kitchen
4
4
  module Directions
5
5
  module BakeChapterSolutions
6
- def self.v1(chapter:, metadata_source:, uuid_prefix: '')
7
- V1.new.bake(chapter: chapter, metadata_source: metadata_source, uuid_prefix: uuid_prefix)
6
+ def self.v1(chapter:, metadata_source:, uuid_prefix: '', classes: %w[free-response])
7
+ V1.new.bake(
8
+ chapter: chapter,
9
+ metadata_source: metadata_source,
10
+ uuid_prefix: uuid_prefix,
11
+ classes: classes
12
+ )
8
13
  end
9
14
  end
10
15
  end
@@ -2,20 +2,22 @@
2
2
 
3
3
  module Kitchen::Directions::BakeChapterSolutions
4
4
  class V1
5
- def bake(chapter:, metadata_source:, uuid_prefix: '')
5
+ def bake(chapter:, metadata_source:, uuid_prefix: '', classes: %w[free-response])
6
6
  solutions_clipboard = Kitchen::Clipboard.new
7
7
 
8
- chapter.search('section.free-response').each do |free_response_question|
9
- exercises = free_response_question.exercises
10
- # must run AFTER .free-response notes are baked
8
+ classes.each do |klass|
9
+ chapter.search("section.#{klass}").each do |question|
10
+ exercises = question.exercises
11
+ # must run AFTER the other sections are baked
11
12
 
12
- next if exercises.none?
13
+ next if exercises.none?
13
14
 
14
- exercises.each do |exercise|
15
- solution = exercise.solution
16
- next unless solution.present?
15
+ exercises.each do |exercise|
16
+ solution = exercise.solution
17
+ next unless solution.present?
17
18
 
18
- solution.cut(to: solutions_clipboard)
19
+ solution.cut(to: solutions_clipboard)
20
+ end
19
21
  end
20
22
  end
21
23
 
@@ -18,7 +18,7 @@ module Kitchen
18
18
  def bake(chapter:, metadata_source:, uuid_prefix: '.', klass: 'summary')
19
19
  summaries = Clipboard.new
20
20
 
21
- chapter.non_introduction_pages.each do |page|
21
+ chapter.pages.each do |page|
22
22
  summary = page.summary
23
23
 
24
24
  next if summary.nil?
@@ -26,7 +26,6 @@ module Kitchen
26
26
  summary.first("[data-type='title']")&.trash # get rid of old title if exists
27
27
  title = EocSectionTitleLinkSnippet.v1(page: page)
28
28
  summary.prepend(child: title)
29
- summary.first('h3')[:itemprop] = 'name'
30
29
  summary.cut(to: summaries)
31
30
  end
32
31
 
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Kitchen
4
+ module Directions
5
+ module BakeCustomSections
6
+ def self.v1(chapter:, custom_sections_properties:)
7
+ V1.new.bake(
8
+ chapter: chapter,
9
+ custom_sections_properties: custom_sections_properties
10
+ )
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Kitchen::Directions::BakeCustomSections
4
+ class V1
5
+ def bake(chapter:, custom_sections_properties:)
6
+ custom_sections_properties.each do |_custom_section_name, property|
7
+ title_text = I18n.t(:"custom-sections.#{property[:class]}")
8
+ property_class = property[:class]
9
+ inject = property[:inject]
10
+ chapter.search(".#{property_class}").each do |custom_section|
11
+
12
+ case inject
13
+ when 'title'
14
+ custom_section_title = custom_section.first('h2')
15
+ custom_section_title_os_text = custom_section_title.first('.os-text')
16
+ custom_section_title_sibling = custom_section.first('h2 + div')
17
+ div_id = custom_section_title_sibling['id']
18
+ custom_section_title_sibling.trash
19
+ custom_section_title.append(sibling:
20
+ <<~HTML
21
+ <h3 class="os-subtitle" id="#{div_id}">#{custom_section_title_os_text.text}</h3>
22
+ HTML
23
+ )
24
+ custom_section_title_os_text.replace_children(with: title_text)
25
+ when 'subtitle'
26
+ custom_section_title = custom_section.titles.first
27
+ custom_section_title.name = 'h4'
28
+ custom_section_title.prepend(sibling:
29
+ <<~HTML
30
+ <h3 class="os-title">#{title_text}</h3>
31
+ HTML
32
+ )
33
+ when 'title_prefix'
34
+ custom_section_title = custom_section.titles.first
35
+ custom_section_title.replace_children(with: "#{title_text}: " +
36
+ custom_section_title.text)
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Kitchen
4
+ module Directions
5
+ module ChangeSubsectionTitleTag
6
+ def self.v1(section:)
7
+ section.search('section').each do |subsection|
8
+ subsection.first('h4').name = 'h5'
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
@@ -3,14 +3,13 @@
3
3
  module Kitchen
4
4
  module Directions
5
5
  module BakeEquations
6
- def self.v1(book:, number_decorator: :none)
6
+ def self.v1(book:, number_decorator: :none, cases: false)
7
7
  book.chapters.search('div[data-type="equation"]:not(.unnumbered)').each do |eq|
8
8
  chapter = eq.ancestor(:chapter)
9
9
  number = "#{chapter.count_in(:book)}.#{eq.count_in(:chapter)}"
10
10
 
11
11
  # Store label information
12
- equation_label = "#{I18n.t(:equation)} #{number}"
13
- book.pantry(name: :link_text).store equation_label, label: eq.id
12
+ eq.target_label(label_text: 'equation', custom_content: number, cases: cases)
14
13
 
15
14
  decorated_number =
16
15
  case number_decorator
@@ -3,35 +3,30 @@
3
3
  module Kitchen
4
4
  module Directions
5
5
  module BakeExample
6
- def self.v1(example:, number:, title_tag:, numbered_solutions: false)
6
+ def self.v1(example:, number:, title_tag:, numbered_solutions: false, cases: false)
7
7
  example.wrap_children(class: 'body')
8
8
 
9
9
  example.prepend(child:
10
10
  <<~HTML
11
11
  <#{title_tag} class="os-title">
12
- <span class="os-title-label">#{I18n.t(:example_label)} </span>
12
+ <span class="os-title-label">#{I18n.t("example#{'.nominative' if cases}")} </span>
13
13
  <span class="os-number">#{number}</span>
14
14
  <span class="os-divider"> </span>
15
15
  </#{title_tag}>
16
16
  HTML
17
17
  )
18
18
 
19
- example.document
20
- .pantry(name: :link_text)
21
- .store("#{I18n.t(:example_label)} #{number}", label: example.id)
22
-
23
- example.titles.each do |title|
24
- if title.parent.has_class?('os-caption-container') || \
25
- title.parent.has_class?('os-caption')
26
- next
27
- end
19
+ # Store label information
20
+ example.target_label(label_text: 'example', custom_content: number, cases: cases)
28
21
 
22
+ example.titles_to_rename.each do |title|
29
23
  title.name = 'h4'
30
24
  end
31
25
 
32
26
  example.exercises.each do |exercise|
27
+ next if exercise.baked?
28
+
33
29
  if (problem = exercise.problem)
34
- problem.titles.each { |title| title.name = 'h4' }
35
30
  problem.wrap_children(class: 'os-problem-container')
36
31
  end
37
32
 
@@ -58,6 +53,8 @@ module Kitchen
58
53
  next unless commentary.present?
59
54
 
60
55
  commentary_title = commentary.titles.first
56
+ next unless commentary_title.present?
57
+
61
58
  commentary_title.name = 'h4'
62
59
  commentary_title['data-type'] = 'commentary-title'
63
60
  commentary_title.wrap_children('span', class: 'os-title-label')
@@ -3,7 +3,7 @@
3
3
  module Kitchen
4
4
  module Directions
5
5
  module BakeFigure
6
- def self.v1(figure:, number:)
6
+ def self.v1(figure:, number:, cases: false)
7
7
  return if figure.has_class?('unnumbered') && !figure.has_class?('splash')
8
8
 
9
9
  figure.wrap(%(<div class="os-figure#{' has-splash' if figure.has_class?('splash')}">))
@@ -19,14 +19,16 @@ module Kitchen
19
19
  return
20
20
  end
21
21
 
22
- figure.pantry(name: :link_text).store "#{I18n.t(:figure)} #{number}", label: figure.id
22
+ # Store label information
23
+ figure.target_label(label_text: 'figure', custom_content: number, cases: cases)
24
+
23
25
  title = figure.title&.cut
24
26
 
25
27
  caption = figure.caption&.cut
26
28
  figure.append(sibling:
27
29
  <<~HTML
28
30
  <div class="os-caption-container">
29
- <span class="os-title-label">#{I18n.t(:figure)} </span>
31
+ <span class="os-title-label">#{I18n.t("figure#{'.nominative' if cases}")} </span>
30
32
  <span class="os-number">#{number}</span>
31
33
  <span class="os-divider"> </span>
32
34
  #{"<span class=\"os-title\" data-type=\"title\" id=\"#{title.id}\">#{title.children}</span>" if title}
@@ -3,12 +3,15 @@
3
3
  module Kitchen
4
4
  module Directions
5
5
  module BakeFirstElements
6
- def self.v1(within:)
6
+ def self.v1(within:, first_inline_list: false)
7
+ # add has-first-element class
7
8
  selectors = [
8
9
  'div.os-problem-container > div.os-table',
9
10
  'div.os-problem-container > span[data-type="media"]',
11
+ 'div.os-problem-container > div.os-figure',
10
12
  'div.os-solution-container > div.os-table',
11
- 'div.os-solution-container > span[data-type="media"]'
13
+ 'div.os-solution-container > span[data-type="media"]',
14
+ 'div.os-solution-container > div.os-figure'
12
15
  ]
13
16
  selectors.each do |selector|
14
17
  within.search("#{selector}:first-child").each do |problem|
@@ -16,6 +19,16 @@ module Kitchen
16
19
  problem.parent.add_class('has-first-element')
17
20
  end
18
21
  end
22
+
23
+ return unless first_inline_list
24
+
25
+ # add first-inline-element class
26
+ inline_selector = 'div.os-solution-container > ol[type="1"]:first-child,' \
27
+ 'div.os-problem-container > ol[type="1"]:first-child'
28
+ within.search(inline_selector).each do |inline_list|
29
+ inline_list.add_class('first-inline-list-element')
30
+ inline_list.parent.add_class('has-first-inline-list-element')
31
+ end
19
32
  end
20
33
  end
21
34
  end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Kitchen
4
+ module Directions
5
+ module BakeFolio
6
+ def self.v1(book:)
7
+ book['data-pdf-folio-preface-message'] = I18n.t(:"folio.preface")
8
+ book['data-pdf-folio-access-message'] = I18n.t(:"folio.access_for_free")
9
+ end
10
+ end
11
+ end
12
+ end
@@ -8,7 +8,7 @@ module Kitchen::Directions::BakeFreeResponse
8
8
  @metadata_elements = metadata_source.children_to_keep.copy
9
9
 
10
10
  @free_response_clipboard = Kitchen::Clipboard.new
11
- chapter.non_introduction_pages.each do |page|
11
+ chapter.pages.each do |page|
12
12
  free_response_questions = page.free_response
13
13
  next if free_response_questions.none?
14
14
 
@@ -20,13 +20,11 @@ module Kitchen
20
20
  container_key: 'further-research',
21
21
  uuid_key: "#{uuid_prefix}further-research",
22
22
  section_selector: 'section.further-research',
23
- append_to: nil,
24
- include_intro_page: false
23
+ append_to: nil
25
24
  ) do |further_research|
26
25
  RemoveSectionTitle.v1(section: further_research)
27
26
  title = EocSectionTitleLinkSnippet.v1(page: further_research.ancestor(:page))
28
27
  further_research.prepend(child: title)
29
- further_research.first('h3')[:itemprop] = 'name'
30
28
  end
31
29
  end
32
30
  end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Kitchen
4
+ module Directions
5
+ module BakeHandbook
6
+ def self.v1(book:, title_element: 'h1')
7
+ V1.new.bake(book: book, title_element: title_element)
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,74 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Kitchen::Directions::BakeHandbook
4
+ class V1
5
+ def bake(book:, title_element:)
6
+ book.pages('$.handbook').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 = title_element
14
+ end
15
+
16
+ # Create Outline Title
17
+ outline_html = <<~HTML
18
+ <div class="os-handbook-outline">
19
+ <h3 class="os-title">#{I18n.t(:handbook_outline_title)}</h3>
20
+ </div>
21
+ HTML
22
+ page.title.append(sibling: outline_html)
23
+
24
+ bake_first_section_title_and_objectives(page: page)
25
+ fix_nested_section_headers(page: page)
26
+ end
27
+ end
28
+
29
+ # Bake Handbook First Section Title
30
+ def bake_first_section_title_and_objectives(page:)
31
+ outline_items_html = []
32
+ page.search('> section').each do |section|
33
+ first_section_title = section.titles.first
34
+ first_section_title.replace_children(with:
35
+ <<~HTML
36
+ <span class="os-part-text">H</span>
37
+ <span class="os-number">#{section.count_in(:page)}</span>
38
+ <span class="os-divider">. </span>
39
+ <span class="os-text">#{first_section_title.text}</span>
40
+ HTML
41
+ )
42
+ first_section_title.name = 'h2'
43
+
44
+ outline_item_html = <<~HTML
45
+ <div class="os-handbook-objective">
46
+ <a class="os-handbook-objective" href="##{first_section_title[:id]}">
47
+ #{first_section_title.children}
48
+ </a>
49
+ </div>
50
+ HTML
51
+ outline_items_html.push(outline_item_html)
52
+ end
53
+ page.search('.os-handbook-outline').first.append(child:
54
+ <<~HTML
55
+ #{outline_items_html.join}
56
+ HTML
57
+ )
58
+ end
59
+
60
+ def fix_nested_section_headers(page:)
61
+ page.search('section').each do |section|
62
+ section_data_depth = section[:'data-depth']
63
+ case section_data_depth
64
+ when '2'
65
+ section.titles.first.name = 'h3'
66
+ when '3'
67
+ section.titles.first.name = 'h4'
68
+ when '4'
69
+ section.titles.first.name = 'h5'
70
+ end
71
+ end
72
+ end
73
+ end
74
+ end