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
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Kitchen
4
+ # An enumerator for composite page elements
5
+ #
6
+ class CompositeChapterElementEnumerator < ElementEnumeratorBase
7
+
8
+ # Returns a factory for this enumerator
9
+ #
10
+ # @return [ElementEnumeratorFactory]
11
+ #
12
+ def self.factory
13
+ ElementEnumeratorFactory.new(
14
+ default_css_or_xpath: Selector.named(:composite_chapter),
15
+ sub_element_class: CompositeChapterElement,
16
+ enumerator_class: self
17
+ )
18
+ end
19
+
20
+ end
21
+ end
@@ -13,8 +13,14 @@ module Kitchen
13
13
  def initialize(node:, document: nil)
14
14
  super(node: node,
15
15
  document: document,
16
- enumerator_class: CompositePageElementEnumerator,
17
- short_type: :composite_page)
16
+ enumerator_class: CompositePageElementEnumerator)
17
+ end
18
+
19
+ # Returns the short type
20
+ # @return [Symbol]
21
+ #
22
+ def self.short_type
23
+ :composite_page
18
24
  end
19
25
 
20
26
  # Returns the title element (the one in the immediate children, not the one in the metadata)
@@ -26,24 +32,23 @@ module Kitchen
26
32
  # Get the title in the immediate children, not the one in the metadata. Could use
27
33
  # CSS of ":not([data-type='metadata']) > [data-type='document-title'], [data-type='document-title']"
28
34
  # but xpath is shorter
29
- first!("./*[@data-type = 'document-title']")
35
+ first!("./*[@data-type = 'document-title' or @data-type = 'title']")
30
36
  end
31
37
 
32
- # Returns true if this class represents the element for the given node
38
+ # Returns true if this page is a book index
33
39
  #
34
- # @param node [Nokogiri::XML::Node] the underlying node
35
40
  # @return [Boolean]
36
41
  #
37
- def self.is_the_element_class_for?(node)
38
- node['data-type'] == 'composite-page'
42
+ def is_index?
43
+ has_class?('os-index-container')
39
44
  end
40
45
 
41
- # Returns true if this page is a book index
46
+ # Returns true if this page is a book reference
42
47
  #
43
48
  # @return [Boolean]
44
49
  #
45
- def is_index?
46
- has_class?('os-index-container')
50
+ def is_reference?
51
+ has_class?('os-reference-container')
47
52
  end
48
53
 
49
54
  end
@@ -11,7 +11,7 @@ module Kitchen
11
11
  #
12
12
  def self.factory
13
13
  ElementEnumeratorFactory.new(
14
- default_css_or_xpath: "div[data-type='composite-page']",
14
+ default_css_or_xpath: Selector.named(:composite_page),
15
15
  sub_element_class: CompositePageElement,
16
16
  enumerator_class: self
17
17
  )
@@ -11,6 +11,18 @@ module Kitchen
11
11
  #
12
12
  attr_reader :selectors
13
13
 
14
+ # @!attribute [rw] enable_all_namespaces
15
+ #
16
+ # @return [Boolean]
17
+ #
18
+ attr_accessor :enable_all_namespaces
19
+
20
+ # @!attribute [rw] enable_search_cache
21
+ #
22
+ # @return [Boolean]
23
+ #
24
+ attr_accessor :enable_search_cache
25
+
14
26
  # Creates a new config from a file (not implemented)
15
27
  #
16
28
  def self.new_from_file(_file)
@@ -21,6 +33,8 @@ module Kitchen
21
33
  #
22
34
  def initialize(hash: {}, selectors: nil)
23
35
  @selectors = selectors || Kitchen::Selectors::Standard1.new
36
+ @enable_all_namespaces = hash[:enable_all_namespaces] || true
37
+ @enable_search_cache = hash[:enable_search_cache] || false
24
38
  @hash = hash
25
39
  end
26
40
  end
@@ -17,7 +17,9 @@ module Kitchen
17
17
 
18
18
  # Make a section with data-depth of X have a header level of X+1
19
19
  page.search('section').each do |section|
20
- title = section.first!("[data-type='title']")
20
+ title = section.titles.first
21
+ next unless title.present?
22
+
21
23
  title.name = "h#{section['data-depth'].to_i + 1}"
22
24
  end
23
25
  end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Kitchen
4
+ module Directions
5
+ # Bake directons for eoc glossary
6
+ #
7
+ module BakeChapterGlossary
8
+ def self.v1(chapter:, metadata_source:, append_to: nil, uuid_prefix: nil)
9
+ V1.new.bake(
10
+ chapter: chapter,
11
+ metadata_source: metadata_source,
12
+ append_to: append_to,
13
+ uuid_prefix: uuid_prefix
14
+ )
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Kitchen::Directions::BakeChapterGlossary
4
+ class V1
5
+ renderable
6
+
7
+ def bake(chapter:, metadata_source:, append_to: nil, uuid_prefix: '')
8
+ @metadata = metadata_source.children_to_keep.copy
9
+ @klass = 'glossary'
10
+ @title = I18n.t(:eoc_key_terms_title)
11
+ @uuid_prefix = uuid_prefix
12
+
13
+ definitions = chapter.glossaries.search('dl').cut
14
+ return if definitions.none?
15
+ definitions.sort_by! do |definition|
16
+ [definition.first('dt').text.downcase, definition.first('dd').text.downcase]
17
+ end
18
+
19
+ chapter.glossaries.trash
20
+
21
+ @content = definitions.paste
22
+
23
+ append_to_element = append_to || chapter
24
+ @in_composite_chapter = append_to_element.is?(:composite_chapter)
25
+
26
+ append_to_element.append(child: render(file:
27
+ '../../templates/eoc_section_title_template.xhtml.erb'))
28
+ end
29
+ end
30
+ end
@@ -3,21 +3,31 @@
3
3
  module Kitchen
4
4
  module Directions
5
5
  module BakeChapterIntroductions
6
- def self.v1(book:)
6
+ def self.v1(book:, bake_chapter_objectives: true)
7
7
  book.chapters.each do |chapter|
8
- outline_items_html = chapter.pages.map do |page|
9
- next if page.is_introduction?
8
+ chapter_outline_html = ''
10
9
 
11
- <<~HTML
12
- <div class="os-chapter-objective">
13
- <a class="os-chapter-objective" href="##{page.title[:id]}">
14
- <span class="os-number">#{chapter.count_in(:book)}.#{page.count_in(:chapter) - 1}</span>
15
- <span class="os-divider"> </span>
16
- <span data-type="" itemprop="" class="os-text">#{page.title.children[0].text}</span>
17
- </a>
10
+ if bake_chapter_objectives
11
+ outline_items_html = chapter.non_introduction_pages.map do |page|
12
+
13
+ <<~HTML
14
+ <div class="os-chapter-objective">
15
+ <a class="os-chapter-objective" href="##{page.title[:id]}">
16
+ <span class="os-number">#{chapter.count_in(:book)}.#{page.count_in(:chapter)}</span>
17
+ <span class="os-divider"> </span>
18
+ <span data-type="" itemprop="" class="os-text">#{page.title.children[0].text}</span>
19
+ </a>
20
+ </div>
21
+ HTML
22
+ end.join('')
23
+
24
+ chapter_outline_html = <<~HTML
25
+ <div class="os-chapter-outline">
26
+ <h3 class="os-title">#{I18n.t(:chapter_outline)}</h3>
27
+ #{outline_items_html}
18
28
  </div>
19
29
  HTML
20
- end.join('')
30
+ end
21
31
 
22
32
  introduction_page = chapter.introduction_page
23
33
 
@@ -28,15 +38,12 @@ module Kitchen
28
38
  title.name = 'h2'
29
39
  MoveTitleTextIntoSpan.v1(title: title)
30
40
 
31
- intro_content = introduction_page.search("> :not([data-type='metadata']):not(figure)").cut
41
+ intro_content = introduction_page.search("> :not([data-type='metadata']):not(.splash):not(.has-splash)").cut
32
42
 
33
43
  introduction_page.append(child:
34
44
  <<~HTML
35
45
  <div class="intro-body">
36
- <div class="os-chapter-outline">
37
- <h3 class="os-title">#{I18n.t(:chapter_outline)}</h3>
38
- #{outline_items_html}
39
- </div>
46
+ #{chapter_outline_html}
40
47
  <div class="intro-text">
41
48
  #{title.paste}
42
49
  #{intro_content.paste}
@@ -3,8 +3,13 @@
3
3
  module Kitchen
4
4
  module Directions
5
5
  module BakeChapterKeyConcepts
6
- def self.v1(chapter:, metadata_source:, append_to: nil)
7
- V1.new.bake(chapter: chapter, metadata_source: metadata_source, append_to: append_to)
6
+ def self.v1(chapter:, metadata_source:, append_to: nil, uuid_prefix: '.')
7
+ V1.new.bake(
8
+ chapter: chapter,
9
+ metadata_source: metadata_source,
10
+ append_to: append_to,
11
+ uuid_prefix: uuid_prefix
12
+ )
8
13
  end
9
14
  end
10
15
  end
@@ -3,10 +3,12 @@
3
3
  module Kitchen::Directions::BakeChapterKeyConcepts
4
4
  class V1
5
5
  renderable
6
- def bake(chapter:, metadata_source:, append_to:)
7
- @metadata_elements = metadata_source.children_to_keep.copy
6
+ def bake(chapter:, metadata_source:, append_to:, uuid_prefix:)
7
+ @metadata = metadata_source.children_to_keep.copy
8
+ @klass = 'key-concepts'
9
+ @title = I18n.t(:eoc_key_concepts)
10
+ @uuid_prefix = uuid_prefix
8
11
 
9
- @key_concepts = []
10
12
  key_concepts_clipboard = Kitchen::Clipboard.new
11
13
  chapter.non_introduction_pages.each do |page|
12
14
  key_concepts = page.key_concepts
@@ -16,15 +18,18 @@ module Kitchen::Directions::BakeChapterKeyConcepts
16
18
  title = Kitchen::Directions::EocSectionTitleLinkSnippet.v1(page: page)
17
19
  key_concepts.each do |key_concept|
18
20
  key_concept.prepend(child: title)
19
- key_concept&.cut(to: key_concepts_clipboard)
21
+ key_concept.wrap("<div class='os-section-area'>")
22
+ page.search('div.os-section-area').first.cut(to: key_concepts_clipboard)
20
23
  end
21
- @key_concepts.push(key_concepts_clipboard.paste)
22
- key_concepts_clipboard.clear
23
24
  end
24
25
 
26
+ @content = "<div class=\"os-key-concepts\"> #{key_concepts_clipboard.paste} </div>"
27
+
25
28
  append_to_element = append_to || chapter
29
+ @in_composite_chapter = append_to_element.is?(:composite_chapter)
26
30
 
27
- append_to_element.append(child: render(file: 'key_concepts.xhtml.erb'))
31
+ append_to_element.append(child: render(file:
32
+ '../../templates/eoc_section_title_template.xhtml.erb'))
28
33
  end
29
34
  end
30
35
  end
@@ -2,33 +2,38 @@
2
2
 
3
3
  module Kitchen
4
4
  module Directions
5
- # Bake directions for eoc key equations
5
+ # Bake directons for eoc key equations
6
6
  #
7
7
  module BakeChapterKeyEquations
8
- def self.v1(chapter:, metadata_source:, append_to: nil)
9
- metadata_elements = metadata_source.children_to_keep.copy
8
+ def self.v1(chapter:, metadata_source:, append_to: nil, uuid_prefix: '.')
9
+ V1.new.bake(
10
+ chapter: chapter,
11
+ metadata_source: metadata_source,
12
+ append_to: append_to,
13
+ uuid_prefix: uuid_prefix
14
+ )
15
+ end
10
16
 
11
- chapter.key_equations.search('h3').trash
12
- key_equations = chapter.key_equations.cut
17
+ class V1
18
+ renderable
19
+ def bake(chapter:, metadata_source:, append_to:, uuid_prefix:)
20
+ @metadata = metadata_source.children_to_keep.copy
21
+ @klass = 'key-equations'
22
+ @title = I18n.t(:eoc_key_equations)
23
+ @uuid_prefix = uuid_prefix
13
24
 
14
- return if key_equations.none?
25
+ chapter.key_equations.search('h3').trash
15
26
 
16
- append_to_element = append_to || chapter
27
+ return if chapter.key_equations.none?
17
28
 
18
- append_to_element.append(child:
19
- <<~HTML
20
- <div class="os-eoc os-key-equations-container" data-type="composite-page" data-uuid-key=".key-equations">
21
- <h2 data-type="document-title">
22
- <span class="os-text">#{I18n.t(:eoc_key_equations)}</span>
23
- </h2>
24
- <div data-type="metadata" style="display: none;">
25
- <h1 data-type="document-title" itemprop="name">#{I18n.t(:eoc_key_equations)}</h1>
26
- #{metadata_elements.paste}
27
- </div>
28
- #{key_equations.paste}
29
- </div>
30
- HTML
31
- )
29
+ @content = chapter.key_equations.cut.paste
30
+
31
+ append_to_element = append_to || chapter
32
+ @in_composite_chapter = append_to_element.is?(:composite_chapter)
33
+
34
+ append_to_element.append(child: render(file:
35
+ '../templates/eoc_section_title_template.xhtml.erb'))
36
+ end
32
37
  end
33
38
  end
34
39
  end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Kitchen
4
+ module Directions
5
+ module BakeChapterReferences
6
+ def self.v1(chapter:, metadata_source:, uuid_prefix: '.', klass: 'references')
7
+ V1.new.bake(
8
+ chapter: chapter,
9
+ metadata_source: metadata_source,
10
+ uuid_prefix: uuid_prefix,
11
+ klass: klass
12
+ )
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Kitchen::Directions::BakeChapterReferences
4
+ class V1
5
+ renderable
6
+
7
+ def bake(chapter:, metadata_source:, uuid_prefix: '.', klass: 'references')
8
+ @metadata = metadata_source.children_to_keep.copy
9
+ @klass = klass
10
+ @title = I18n.t(:references)
11
+ @uuid_prefix = uuid_prefix
12
+
13
+ chapter.references.search('h3').trash
14
+
15
+ chapter.non_introduction_pages.each do |page|
16
+ references = page.references
17
+ next if references.none?
18
+
19
+ references.search('h3').trash
20
+ title = Kitchen::Directions::EocSectionTitleLinkSnippet.v1(page: page)
21
+
22
+ references.each do |reference|
23
+ reference.prepend(child: title)
24
+ end
25
+ end
26
+
27
+ @content = chapter.pages.references.cut.paste
28
+
29
+ @in_composite_chapter = false
30
+
31
+ chapter.append(child: render(file:
32
+ '../../templates/eoc_section_title_template.xhtml.erb'))
33
+ end
34
+ end
35
+ end
@@ -3,8 +3,8 @@
3
3
  module Kitchen
4
4
  module Directions
5
5
  module BakeChapterSectionExercises
6
- def self.v1(chapter:)
7
- V1.new.bake(chapter: chapter)
6
+ def self.v1(chapter:, trash_title: false)
7
+ V1.new.bake(chapter: chapter, trash_title: trash_title)
8
8
  end
9
9
  end
10
10
  end
@@ -2,9 +2,10 @@
2
2
 
3
3
  module Kitchen::Directions::BakeChapterSectionExercises
4
4
  class V1
5
- def bake(chapter:)
5
+ def bake(chapter:, trash_title:)
6
6
  chapter.pages.each do |page|
7
7
  page.search('section.section-exercises').each do |section|
8
+ section.first('h3[data-type="title"]')&.trash if trash_title
8
9
  section.wrap(
9
10
  %(<div class="os-eos os-section-exercises-container"
10
11
  data-uuid-key=".section-exercises">)
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Kitchen
4
+ module Directions
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)
8
+ end
9
+ end
10
+ end
11
+ end