openstax_kitchen 3.1.0 → 5.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (115) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -1
  3. data/CHANGELOG.md +64 -0
  4. data/Gemfile.lock +20 -14
  5. data/README.md +16 -0
  6. data/codecov.yaml +1 -0
  7. data/docker/ci +0 -1
  8. data/lib/kitchen/book_document.rb +1 -1
  9. data/lib/kitchen/book_element.rb +16 -2
  10. data/lib/kitchen/chapter_element.rb +10 -13
  11. data/lib/kitchen/chapter_element_enumerator.rb +1 -1
  12. data/lib/kitchen/composite_chapter_element.rb +7 -11
  13. data/lib/kitchen/composite_chapter_element_enumerator.rb +21 -0
  14. data/lib/kitchen/composite_page_element.rb +15 -10
  15. data/lib/kitchen/composite_page_element_enumerator.rb +1 -1
  16. data/lib/kitchen/config.rb +14 -0
  17. data/lib/kitchen/directions/bake_chapter_glossary/main.rb +18 -0
  18. data/lib/kitchen/directions/bake_chapter_glossary/v1.rb +30 -0
  19. data/lib/kitchen/directions/bake_chapter_introductions.rb +1 -1
  20. data/lib/kitchen/directions/bake_chapter_key_concepts/main.rb +7 -2
  21. data/lib/kitchen/directions/bake_chapter_key_concepts/v1.rb +12 -7
  22. data/lib/kitchen/directions/bake_chapter_key_equations.rb +26 -21
  23. data/lib/kitchen/directions/bake_chapter_references/main.rb +16 -0
  24. data/lib/kitchen/directions/bake_chapter_references/v1.rb +35 -0
  25. data/lib/kitchen/directions/bake_chapter_summary.rb +48 -42
  26. data/lib/kitchen/directions/bake_composite_chapters.rb +1 -1
  27. data/lib/kitchen/directions/bake_composite_pages.rb +1 -1
  28. data/lib/kitchen/directions/bake_equations.rb +14 -4
  29. data/lib/kitchen/directions/bake_example.rb +5 -1
  30. data/lib/kitchen/directions/bake_figure.rb +1 -1
  31. data/lib/kitchen/directions/bake_first_elements.rb +22 -0
  32. data/lib/kitchen/directions/bake_footnotes/v1.rb +2 -1
  33. data/lib/kitchen/directions/bake_free_response/free_response.xhtml.erb +10 -0
  34. data/lib/kitchen/directions/bake_free_response/main.rb +11 -0
  35. data/lib/kitchen/directions/bake_free_response/v1.rb +29 -0
  36. data/lib/kitchen/directions/bake_further_research.rb +59 -0
  37. data/lib/kitchen/directions/bake_index/v1.rb +36 -26
  38. data/lib/kitchen/directions/bake_link_placeholders.rb +1 -1
  39. data/lib/kitchen/directions/bake_notes/bake_note_subtitle.rb +4 -0
  40. data/lib/kitchen/directions/bake_notes/bake_numbered_notes.rb +9 -21
  41. data/lib/kitchen/directions/bake_numbered_exercise/main.rb +6 -2
  42. data/lib/kitchen/directions/bake_numbered_exercise/v1.rb +25 -12
  43. data/lib/kitchen/directions/bake_numbered_table/v1.rb +1 -8
  44. data/lib/kitchen/directions/bake_page_abstracts.rb +1 -1
  45. data/lib/kitchen/directions/bake_references/main.rb +16 -0
  46. data/lib/kitchen/directions/bake_references/v1.rb +48 -0
  47. data/lib/kitchen/directions/bake_suggested_reading.rb +5 -0
  48. data/lib/kitchen/directions/bake_toc.rb +4 -2
  49. data/lib/kitchen/directions/{bake_book_answer_key → book_answer_key_container}/eob_solutions_container.xhtml.erb +0 -0
  50. data/lib/kitchen/directions/{bake_book_answer_key → book_answer_key_container}/main.rb +1 -1
  51. data/lib/kitchen/directions/{bake_book_answer_key → book_answer_key_container}/v1.rb +2 -2
  52. data/lib/kitchen/directions/{bake_chapter_review → chapter_review_container}/chapter_review.xhtml.erb +0 -0
  53. data/lib/kitchen/directions/{bake_chapter_review → chapter_review_container}/main.rb +1 -1
  54. data/lib/kitchen/directions/{bake_chapter_review → chapter_review_container}/v1.rb +2 -2
  55. data/lib/kitchen/directions/eoc_section_title_link_snippet.rb +1 -1
  56. data/lib/kitchen/directions/move_exercises_to_eoc/main.rb +27 -0
  57. data/lib/kitchen/directions/{bake_chapter_review_exercises → move_exercises_to_eoc}/v1.rb +8 -10
  58. data/lib/kitchen/directions/{bake_chapter_review_exercises → move_exercises_to_eoc}/v2.rb +8 -9
  59. data/lib/kitchen/directions/{bake_chapter_answer_key → move_solutions_to_answer_key}/main.rb +1 -1
  60. data/lib/kitchen/directions/move_solutions_to_answer_key/strategies/american_government.rb +19 -0
  61. data/lib/kitchen/directions/{bake_chapter_answer_key → move_solutions_to_answer_key}/strategies/calculus.rb +1 -1
  62. data/lib/kitchen/directions/{bake_chapter_answer_key → move_solutions_to_answer_key}/strategies/uphysics.rb +7 -5
  63. data/lib/kitchen/directions/{bake_chapter_answer_key → move_solutions_to_answer_key}/v1.rb +3 -1
  64. data/lib/kitchen/document.rb +20 -42
  65. data/lib/kitchen/element.rb +9 -3
  66. data/lib/kitchen/element_base.rb +93 -21
  67. data/lib/kitchen/element_enumerator_base.rb +33 -2
  68. data/lib/kitchen/element_enumerator_factory.rb +28 -12
  69. data/lib/kitchen/element_factory.rb +3 -3
  70. data/lib/kitchen/example_element.rb +8 -11
  71. data/lib/kitchen/example_element_enumerator.rb +1 -1
  72. data/lib/kitchen/exercise_element.rb +7 -10
  73. data/lib/kitchen/exercise_element_enumerator.rb +1 -1
  74. data/lib/kitchen/figure_element.rb +8 -11
  75. data/lib/kitchen/figure_element_enumerator.rb +1 -1
  76. data/lib/kitchen/id_tracker.rb +68 -0
  77. data/lib/kitchen/metadata_element.rb +8 -2
  78. data/lib/kitchen/metadata_element_enumerator.rb +1 -1
  79. data/lib/kitchen/note_element.rb +8 -11
  80. data/lib/kitchen/note_element_enumerator.rb +1 -1
  81. data/lib/kitchen/oven.rb +5 -1
  82. data/lib/kitchen/page_element.rb +25 -9
  83. data/lib/kitchen/page_element_enumerator.rb +1 -1
  84. data/lib/kitchen/patches/i18n.rb +34 -0
  85. data/lib/kitchen/patches/nokogiri.rb +55 -0
  86. data/lib/kitchen/patches/nokogiri_profiling.rb +60 -0
  87. data/lib/kitchen/reference_element.rb +27 -0
  88. data/lib/kitchen/references_element_enumerator.rb +20 -0
  89. data/lib/kitchen/search_query.rb +31 -3
  90. data/lib/kitchen/selector.rb +25 -0
  91. data/lib/kitchen/selectors/base.rb +39 -0
  92. data/lib/kitchen/selectors/standard_1.rb +13 -0
  93. data/lib/kitchen/table_element.rb +8 -11
  94. data/lib/kitchen/table_element_enumerator.rb +1 -1
  95. data/lib/kitchen/templates/eob_section_title_template.xhtml.erb +10 -0
  96. data/lib/kitchen/templates/eoc_section_title_template.xhtml.erb +10 -0
  97. data/lib/kitchen/term_element.rb +5 -8
  98. data/lib/kitchen/term_element_enumerator.rb +1 -1
  99. data/lib/kitchen/unit_element.rb +13 -7
  100. data/lib/kitchen/unit_element_enumerator.rb +1 -1
  101. data/lib/kitchen/version.rb +1 -1
  102. data/lib/locales/en.yml +3 -0
  103. data/lib/locales/es.yml +32 -0
  104. data/lib/openstax_kitchen.rb +2 -5
  105. data/openstax_kitchen.gemspec +1 -0
  106. metadata +51 -23
  107. data/lib/kitchen/directions/bake_chapter_glossary.rb +0 -39
  108. data/lib/kitchen/directions/bake_chapter_key_concepts/key_concepts.xhtml.erb +0 -16
  109. data/lib/kitchen/directions/bake_chapter_review_exercises/main.rb +0 -15
  110. data/lib/kitchen/directions/bake_chapter_review_exercises/review_exercises.xhtml.erb +0 -10
  111. data/lib/kitchen/directions/bake_exercises/main.rb +0 -12
  112. data/lib/kitchen/directions/bake_exercises/v1.rb +0 -169
  113. data/lib/kitchen/directions/bake_notes/bake_notes.rb +0 -48
  114. data/lib/kitchen/directions/bake_problem_first_elements.rb +0 -16
  115. data/lib/kitchen/transliterations.rb +0 -21
@@ -0,0 +1,10 @@
1
+ <div class="os-eoc os-free-response-container" data-type="composite-page" data-uuid-key=".free-response">
2
+ <<%= @title_tag %> data-type="document-title">
3
+ <span class="os-text"><%= I18n.t(:eoc_free_response) %></span>
4
+ </<%= @title_tag %>>
5
+ <div data-type="metadata" style="display: none;">
6
+ <h1 data-type="document-title" itemprop="name"><%= I18n.t(:eoc_free_response) %></h1>
7
+ <%= @metadata_elements.paste %>
8
+ </div>
9
+ <%= @free_response_clipboard.paste %>
10
+ </div>
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Kitchen
4
+ module Directions
5
+ module BakeFreeResponse
6
+ def self.v1(chapter:, metadata_source:, append_to: nil)
7
+ V1.new.bake(chapter: chapter, metadata_source: metadata_source, append_to: append_to)
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Kitchen::Directions::BakeFreeResponse
4
+ class V1
5
+ renderable
6
+
7
+ def bake(chapter:, metadata_source:, append_to:)
8
+ @metadata_elements = metadata_source.children_to_keep.copy
9
+
10
+ @free_response_clipboard = Kitchen::Clipboard.new
11
+ chapter.non_introduction_pages.each do |page|
12
+ free_response_questions = page.free_response
13
+ next if free_response_questions.none?
14
+
15
+ free_response_questions.search('h3').trash
16
+ title = Kitchen::Directions::EocSectionTitleLinkSnippet.v1(page: page)
17
+ free_response_questions.each do |free_response_question|
18
+ free_response_question.prepend(child: title)
19
+ free_response_question.cut(to: @free_response_clipboard)
20
+ end
21
+ end
22
+
23
+ append_to_element = append_to || chapter
24
+ @title_tag = append_to ? 'h3' : 'h2'
25
+
26
+ append_to_element.append(child: render(file: 'free_response.xhtml.erb'))
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,59 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Kitchen
4
+ module Directions
5
+ # Bake directions for further research
6
+ #
7
+ module BakeFurtherResearch
8
+ def self.v1(chapter:, metadata_source:, uuid_prefix: '.')
9
+ V1.new.bake(
10
+ chapter: chapter,
11
+ metadata_source: metadata_source,
12
+ uuid_prefix: uuid_prefix)
13
+ end
14
+
15
+ class V1
16
+ renderable
17
+ def bake(chapter:, metadata_source:, uuid_prefix: '.')
18
+ @metadata = metadata_source.children_to_keep.copy
19
+ @klass = 'further-research'
20
+ @title = I18n.t(:eoc_further_research_title)
21
+ @uuid_prefix = uuid_prefix
22
+
23
+ further_researches = Clipboard.new
24
+
25
+ chapter.non_introduction_pages.each do |page|
26
+ further_research = page.first('.further-research')
27
+ further_research.first("[data-type='title']")&.trash # get rid of old title if exists
28
+ further_research_title = page.title.copy
29
+ further_research_title.name = 'h3'
30
+ further_research_title.replace_children(with: <<~HTML
31
+ <span class="os-number">#{chapter.count_in(:book)}.#{page.count_in(:chapter)}</span>
32
+ <span class="os-divider"> </span>
33
+ <span class="os-text" data-type="" itemprop="">#{further_research_title.children}</span>
34
+ HTML
35
+ )
36
+
37
+ further_research.prepend(child:
38
+ <<~HTML
39
+ <a href="##{page.title.id}">
40
+ #{further_research_title.paste}
41
+ </a>
42
+ HTML
43
+ )
44
+ further_research.cut(to: further_researches)
45
+ end
46
+
47
+ return if further_researches.none?
48
+
49
+ @content = further_researches.paste
50
+
51
+ @in_composite_chapter = false
52
+
53
+ chapter.append(child: render(file:
54
+ '../templates/eoc_section_title_template.xhtml.erb'))
55
+ end
56
+ end
57
+ end
58
+ end
59
+ end
@@ -27,13 +27,6 @@ module Kitchen::Directions::BakeIndex
27
27
  def initialize(term_text:)
28
28
  @term_text = term_text
29
29
  @terms = []
30
-
31
- # Sort by transliterated version first to support accent marks,
32
- # then by the raw text to support the same text with different capitalization
33
- @sortable = [
34
- ActiveSupport::Inflector.transliterate(term_text).downcase,
35
- term_text
36
- ]
37
30
  end
38
31
 
39
32
  def add_term(term)
@@ -44,13 +37,13 @@ module Kitchen::Directions::BakeIndex
44
37
  @term_text = @term_text.uncapitalize
45
38
  end
46
39
 
47
- def <=>(other)
48
- sortable <=> other.sortable
40
+ def capitalize_term_text!
41
+ @term_text = @term_text.capitalize
49
42
  end
50
43
 
51
- protected
52
-
53
- attr_reader :sortable
44
+ def <=>(other)
45
+ I18n.sort_strings(term_text, other.term_text)
46
+ end
54
47
  end
55
48
 
56
49
  class IndexSection
@@ -84,6 +77,11 @@ module Kitchen::Directions::BakeIndex
84
77
  different_caps_item = @items_by_term_text[term.text.uncapitalize]
85
78
  different_caps_item&.uncapitalize_term_text!
86
79
 
80
+ unless different_caps_item
81
+ different_caps_item = @items_by_term_text[term.text.capitalize]
82
+ different_caps_item&.capitalize_term_text!
83
+ end
84
+
87
85
  (different_caps_item || IndexItem.new(term_text: term.text)).tap do |item|
88
86
  @items.add(item)
89
87
  end
@@ -119,27 +117,39 @@ module Kitchen::Directions::BakeIndex
119
117
  @index = Index.new
120
118
 
121
119
  book.pages.terms.each do |term_element|
122
- # Markup the term
123
120
  page = term_element.ancestor(:page)
124
121
  term_element.id = "auto_#{page.id}_term#{term_element.count_in(:book)}"
122
+ page_title = page.title.text
123
+ add_term_to_index(term_element, page_title)
124
+ end
125
125
 
126
- group_by = term_element.text.strip[0]
127
- group_by = I18n.t(:eob_index_symbols_group) unless group_by.match?(/\w/)
128
- term_element['group-by'] = group_by
129
-
130
- # Add it to our index object
131
- @index.add_term(
132
- Term.new(
133
- text: term_element.text,
134
- id: term_element.id,
135
- group_by: group_by,
136
- page_title: page.title.text.gsub(/\n/, '')
137
- )
138
- )
126
+ book.chapters.composite_pages.terms.each do |term_element|
127
+ page = term_element.ancestor(:composite_page)
128
+ chapter = term_element.ancestor(:chapter)
129
+ term_element.id = "auto_composite_page_term#{term_element.count_in(:book)}"
130
+ chapter_number = chapter.count_in(:book)
131
+ page_title = "#{chapter_number} #{page.title.text.strip}".strip
132
+ add_term_to_index(term_element, page_title)
139
133
  end
140
134
 
141
135
  book.first('body').append(child: render(file: 'v1.xhtml.erb'))
142
136
  end
143
137
 
138
+ def add_term_to_index(term_element, page_title)
139
+ group_by = term_element.text.strip[0]
140
+ group_by = I18n.t(:eob_index_symbols_group) unless group_by.match?(/\w/)
141
+ term_element['group-by'] = group_by
142
+
143
+ # Add it to our index object
144
+ @index.add_term(
145
+ Term.new(
146
+ text: term_element.text,
147
+ id: term_element.id,
148
+ group_by: group_by,
149
+ page_title: page_title.gsub(/\n/, '')
150
+ )
151
+ )
152
+ end
153
+
144
154
  end
145
155
  end
@@ -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')
@@ -7,7 +7,9 @@ module Kitchen
7
7
  classes.each do |klass|
8
8
  book.chapters.notes("$.#{klass}").each do |note|
9
9
  bake_note(note: note)
10
- bake_note_exercise(note: note)
10
+ note.exercises.each do |exercise|
11
+ bake_note_exercise(note: note, exercise: exercise)
12
+ end
11
13
  end
12
14
  end
13
15
  end
@@ -19,11 +21,11 @@ module Kitchen
19
21
  note_count = note.count_in(:chapter)
20
22
  note.prepend(child:
21
23
  <<~HTML
22
- <div class="os-title">
24
+ <h3 class="os-title">
23
25
  <span class="os-title-label">#{note.autogenerated_title}</span>
24
26
  <span class="os-number">#{chapter_count}.#{note_count}</span>
25
27
  <span class="os-divider"> </span>
26
- </div>
28
+ </h3>
27
29
  HTML
28
30
  )
29
31
 
@@ -32,31 +34,17 @@ module Kitchen
32
34
  BakeNoteSubtitle.v1(note: note)
33
35
  end
34
36
 
35
- def self.bake_note_exercise(note:)
36
- exercise = note.exercises.first
37
- return unless exercise
38
-
37
+ def self.bake_note_exercise(note:, exercise:)
39
38
  exercise.add_class('unnumbered')
40
39
  # bake problem
41
40
  exercise.problem.wrap_children('div', class: 'os-problem-container')
42
41
  exercise.problem.first('strong')&.trash
43
42
  exercise.search('[data-type="commentary"]').each(&:trash)
44
- solution = exercise.solution
45
- return unless solution
43
+ return unless exercise.solution
46
44
 
47
45
  # bake solution in place
48
- exercise.add_class('os-hasSolution')
49
- solution[:id] = "#{exercise[:id]}-solution"
50
- solution_number = note.first('.os-number').text
51
- solution.replace_children(with:
52
- <<~HTML
53
- <a class="os-number" href="##{exercise[:id]}">#{solution_number}</a>
54
- <span class="os-divider"> </span>
55
- <div class="os-solution-container">
56
- #{solution.children}
57
- </div>
58
- HTML
59
- )
46
+ BakeNumberedExercise.bake_solution_v1(
47
+ exercise: exercise, number: note.first('.os-number').text, divider: ' ')
60
48
  end
61
49
  end
62
50
  end
@@ -3,8 +3,12 @@
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: 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)
8
12
  end
9
13
  end
10
14
  end
@@ -2,24 +2,23 @@
2
2
 
3
3
  module Kitchen::Directions::BakeNumberedExercise
4
4
  class V1
5
- def bake(exercise:, number:)
5
+ def bake(exercise:, number:, suppress_solution: 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
15
  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
-
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
- )
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
23
22
  end
24
23
 
25
24
  problem.replace_children(with:
@@ -30,5 +29,19 @@ module Kitchen::Directions::BakeNumberedExercise
30
29
  HTML
31
30
  )
32
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
33
46
  end
34
47
  end
@@ -7,7 +7,7 @@ module Kitchen::Directions::BakeNumberedTable
7
7
  table.wrap(%(<div class="os-table">))
8
8
 
9
9
  table_label = "#{I18n.t(:table_label)} #{number}"
10
- table.document.pantry(name: :link_text).store table_label, label: table.id
10
+ table.pantry(name: :link_text).store table_label, label: table.id
11
11
 
12
12
  if table.top_titled?
13
13
  table.parent.add_class('os-top-titled-container')
@@ -22,21 +22,16 @@ module Kitchen::Directions::BakeNumberedTable
22
22
  table.parent.add_class('os-column-header-container') if table.column_header?
23
23
 
24
24
  # TODO: extra spaces added here to match legacy implementation, but probably not meaningful?
25
- new_summary = "#{table_label} "
26
25
  new_caption = ''
27
26
  caption_title = ''
28
27
 
29
28
  if (title = table.first("span[data-type='title']")&.cut)
30
- new_summary += title.text
31
29
  caption_title = <<~HTML
32
30
  \n<span class="os-title" data-type="title">#{title.children}</span>
33
31
  HTML
34
32
  end
35
33
 
36
- new_summary += ' '
37
-
38
34
  if (caption = table.caption&.cut)
39
- new_summary += caption.text
40
35
  new_caption = <<~HTML
41
36
  \n<span class="os-caption">#{caption.children}</span>
42
37
  HTML
@@ -46,8 +41,6 @@ module Kitchen::Directions::BakeNumberedTable
46
41
  HTML
47
42
  end
48
43
 
49
- table[:summary] = new_summary
50
-
51
44
  return if table.unnumbered?
52
45
 
53
46
  table.append(sibling:
@@ -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
@@ -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