openstax_kitchen 12.2.0 → 16.0.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 (83) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +45 -0
  3. data/Gemfile +1 -0
  4. data/Gemfile.lock +4 -4
  5. data/codecov.yaml +4 -0
  6. data/lib/kitchen/directions/bake_all_chapter_solutions_types.rb +30 -0
  7. data/lib/kitchen/directions/bake_all_numbered_exercise_types.rb +26 -0
  8. data/lib/kitchen/directions/bake_annotation_classes/main.rb +2 -2
  9. data/lib/kitchen/directions/bake_annotation_classes/v1.rb +3 -3
  10. data/lib/kitchen/directions/bake_appendix.rb +1 -0
  11. data/lib/kitchen/directions/bake_autotitled_exercise/main.rb +8 -0
  12. data/lib/kitchen/directions/bake_autotitled_exercise/v2.rb +33 -0
  13. data/lib/kitchen/directions/bake_autotitled_exercise/v3.rb +35 -0
  14. data/lib/kitchen/directions/bake_chapter_glossary/v1.rb +3 -1
  15. data/lib/kitchen/directions/bake_chapter_references/v1.rb +1 -1
  16. data/lib/kitchen/directions/bake_chapter_solutions/v1.rb +1 -1
  17. data/lib/kitchen/directions/bake_chapter_summary.rb +1 -1
  18. data/lib/kitchen/directions/bake_example.rb +1 -1
  19. data/lib/kitchen/directions/bake_figure.rb +1 -15
  20. data/lib/kitchen/directions/bake_footnotes/v1.rb +1 -1
  21. data/lib/kitchen/directions/bake_iframes/v1.rb +2 -0
  22. data/lib/kitchen/directions/bake_index/v1.rb +1 -1
  23. data/lib/kitchen/directions/bake_index/v1.xhtml.erb +5 -9
  24. data/lib/kitchen/directions/{bake_injected_exercise.rb → bake_injected_exercise/bake_injected_exercise.rb} +10 -1
  25. data/lib/kitchen/directions/bake_injected_exercise/bake_injected_exercise_question.rb +4 -0
  26. data/lib/kitchen/directions/bake_learning_objectives.rb +13 -0
  27. data/lib/kitchen/directions/bake_lo_link_labels.rb +19 -0
  28. data/lib/kitchen/directions/bake_non_introduction_pages.rb +3 -1
  29. data/lib/kitchen/directions/bake_notes/bake_autotitled_notes.rb +1 -26
  30. data/lib/kitchen/directions/bake_notes/bake_note_exercise.rb +54 -0
  31. data/lib/kitchen/directions/bake_notes/bake_note_injected_question.rb +15 -0
  32. data/lib/kitchen/directions/bake_notes/bake_numbered_notes/main.rb +0 -31
  33. data/lib/kitchen/directions/bake_notes/bake_numbered_notes/v1.rb +2 -2
  34. data/lib/kitchen/directions/bake_notes/bake_numbered_notes/v2.rb +2 -2
  35. data/lib/kitchen/directions/bake_notes/bake_numbered_notes/v3.rb +2 -2
  36. data/lib/kitchen/directions/bake_notes/bake_unclassified_notes.rb +5 -3
  37. data/lib/kitchen/directions/bake_numbered_exercise/main.rb +8 -3
  38. data/lib/kitchen/directions/bake_numbered_exercise/v1.rb +48 -7
  39. data/lib/kitchen/directions/bake_numbered_table/bake_table_body.rb +3 -0
  40. data/lib/kitchen/directions/bake_numbered_table/v2.rb +2 -1
  41. data/lib/kitchen/directions/bake_references/main.rb +6 -9
  42. data/lib/kitchen/directions/bake_references/v1.rb +22 -8
  43. data/lib/kitchen/directions/bake_references/v2.rb +9 -10
  44. data/lib/kitchen/directions/bake_references/v3.rb +32 -0
  45. data/lib/kitchen/directions/bake_screenreader_spans.rb +22 -0
  46. data/lib/kitchen/directions/bake_unnumbered_exercise.rb +16 -0
  47. data/lib/kitchen/directions/bake_unnumbered_figure.rb +26 -0
  48. data/lib/kitchen/directions/book_answer_key_container/eob_answer_key_container.xhtml.erb +9 -0
  49. data/lib/kitchen/directions/book_answer_key_container/v1.rb +6 -2
  50. data/lib/kitchen/directions/{eoc_composite_page_container → composite_page_container}/main.rb +1 -1
  51. data/lib/kitchen/directions/composite_page_container/v1.rb +28 -0
  52. data/lib/kitchen/directions/default_strategy_for_answer_key_solutions.rb +35 -0
  53. data/lib/kitchen/directions/move_custom_section_to_eoc_container/v1.rb +1 -1
  54. data/lib/kitchen/directions/move_solutions_to_answer_key/answer_key_inner_container.rb +29 -0
  55. data/lib/kitchen/element_base.rb +8 -4
  56. data/lib/kitchen/element_enumerator_base.rb +36 -0
  57. data/lib/kitchen/figure_element.rb +12 -4
  58. data/lib/kitchen/injected_exercise_element.rb +41 -0
  59. data/lib/kitchen/injected_exercise_element_enumerator.rb +21 -0
  60. data/lib/kitchen/injected_question_element.rb +7 -0
  61. data/lib/kitchen/patches/i18n.rb +4 -0
  62. data/lib/kitchen/patches/nokogiri.rb +8 -0
  63. data/lib/kitchen/patches/renderable.rb +1 -1
  64. data/lib/kitchen/section_element.rb +27 -0
  65. data/lib/kitchen/section_element_enumerator.rb +20 -0
  66. data/lib/kitchen/selectors/base.rb +6 -0
  67. data/lib/kitchen/selectors/standard_1.rb +2 -0
  68. data/lib/kitchen/templates/composite_page_template.xhtml.erb +10 -0
  69. data/lib/kitchen/version.rb +1 -1
  70. data/lib/locales/en.yml +4 -0
  71. data/lib/locales/es.yml +9 -1
  72. data/lib/locales/pl.yml +3 -0
  73. metadata +24 -14
  74. data/lib/kitchen/directions/book_answer_key_container/eob_answer_key_outer_container.xhtml.erb +0 -9
  75. data/lib/kitchen/directions/eoc_composite_page_container/v1.rb +0 -19
  76. data/lib/kitchen/directions/move_solutions_to_answer_key/main.rb +0 -18
  77. data/lib/kitchen/directions/move_solutions_to_answer_key/strategies/calculus.rb +0 -41
  78. data/lib/kitchen/directions/move_solutions_to_answer_key/strategies/contemporary_math.rb +0 -40
  79. data/lib/kitchen/directions/move_solutions_to_answer_key/strategies/default.rb +0 -27
  80. data/lib/kitchen/directions/move_solutions_to_answer_key/strategies/precalculus.rb +0 -63
  81. data/lib/kitchen/directions/move_solutions_to_answer_key/strategies/uphysics.rb +0 -21
  82. data/lib/kitchen/directions/move_solutions_to_answer_key/v1.rb +0 -47
  83. data/lib/kitchen/templates/eoc_section_template.xhtml.erb +0 -11
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f36305ee23acfe22fc13a9c06ee76f69243f1cd2cba33fe86c28c8c90b5eb36d
4
- data.tar.gz: fd501ef342ff2c7334455cc214139581dadf1619fde7841a29650b4fc10acd79
3
+ metadata.gz: 7796fb964e8a6ff796d9cf84220449681a89e5501e41e0a9a956620faf022d11
4
+ data.tar.gz: 4b2c488ac82a05067c7353f274b9f94888125eb7f66cfa92f30db3c28e7ae29a
5
5
  SHA512:
6
- metadata.gz: e3b939d8a9851db4940213aae3350f720369eb794b8551627d2a44565af36aeda5ad701b62c2c1ec98fb7dcfabafa8bd2e4531642bf40dd777a635c0117560b6
7
- data.tar.gz: 5ec8d3e59faa619a3b23a84ce74514c96b6d360dc1b46d233cd1566b63815a5a7edaa73980f102b4c6656c603c43ea349fcc2eac99149cbafb8fa91d8f0e2fdc
6
+ metadata.gz: cc57439823f55ee6cdec35304a2bb4413a28afc5c98ae616effadec60095cfa964a4b9faa0380178f189c55771d1a1f28813268ce001349f29c3d1b44397d4ab
7
+ data.tar.gz: d055f27db123b8e7441f45056e1c6f2a576ab56d1faa3bbdbb4af6a904674f1562e4403dd5e914a372fe67c5e969eb385838aab6f9ff9a5cbc8a0f5b20356df7
data/CHANGELOG.md CHANGED
@@ -6,6 +6,51 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+
10
+ ## [16.0.0] - 2021-11-19
11
+
12
+ * Add reference link separator to `BakeReferences.v1` (patch)
13
+ * Modify `BakeFootnotes` to be more general (minor)
14
+ * Add `#preceded_by_text` method to element_base and the nokigiri patch (minor)
15
+ * Broaden caption selection for `BakeNumberedTable#v2` (patch)
16
+ * Add details of question count to injected exercises in `BakeInjectedExercise` (major)
17
+ * Add target labels to chapter content module pages option in `BakeNonIntroductionPages`, create a separate directory `BakeLOLinkLabels` to add `.label-text`, `.label-counter` spans wrappers for links with `.lo-reference` class (minor)
18
+ * Add `BakeScreenreaderSpans` direction (minor)
19
+ * Fix `BakeIndex` to group terms by character in polish books and transliterate it for others (minor)
20
+ * Add optional bake `exercies-context` figure_reference if there is one present in singular part exercises to `BakeInjectedExercise`,`BakeInjectedQuestion` to move it down from exercise to question problem container. (major)
21
+ * Create v3 for autotitled exercises with os-hasSolution class
22
+
23
+ ## [15.0.0] - 2021-11-05
24
+
25
+ * Add unstyled tables to `BakeTableBody` (minor)
26
+ * Add to `BakeNumberedExercises` rules for baking exercises in appendecies (minor)
27
+ * Add `BakeUnnumberedExercise` direction (minor)
28
+ * Change whitespace for `BakeIndex` and `BakeExample` (major)
29
+ * Add `BakeAllNumberedExerciseTypes` direction for easier baking of compound sections (minor)
30
+ * Add `solution_stays_put` option for `BakeNumberedExercise` (minor)
31
+ * Add `BakeAllChapterSolutionsTypes` direction to move injected solutions and regular ones to EOC (minor)
32
+ * Refactor: moves all `Answer key strategies` that are book-specific to the
33
+ recipes side and keeps the `Default Strategy`in kitchen (major)
34
+ * Adds missing spanish translations (minor)
35
+
36
+ ## [14.0.0] - 2021-10-22
37
+
38
+ * Fix `BakeAutotitledExercise` V2 to stop breaking for exercises without solutions (patch)
39
+ * Add `BakeAutotitledExercise` V2 (minor)
40
+ * Fix `BakeChapterGlossary::V1` to stop adding an empty wrapper if there is no content (patch)
41
+ * Create `BakeNoteExercise` and `BakeNoteInjectedQuestion` and support exercises in `BakeUnclassifiedNotes` (minor)
42
+ * Add baking section with class `column header` to `BakeAppendix` (patch)
43
+ * Expand `BakeAnnotationClasses` to book from chapter to bake also paragraphs from Preface (major)
44
+ * Create separate direction `BakeUnnumberedFigure`, clean `BakeFigure` to not match unnumbered figures , rename and update `figure_to_bake?` method to `figure_to_number?` to support only numbered figures except subfigures (major)
45
+
46
+ ## [13.0.0] - 2021-10-6
47
+
48
+ * Add `BakeLearningObjectives` v3 (minor)
49
+ * Fix `BakeIframes` to skip already-baked iframes (patch)
50
+ * Add `SectionElement` and `SectionElementEnumerator` classes (minor)
51
+ * Refactor `EocCompositePageContainer` to be used by `EOB` sections as well (major)
52
+ * Refactor `bake_references` `v1, v2 and v3` to use `CompositePageContainer` (major)
53
+
9
54
  ## [12.2.0] - 2021-10-1
10
55
 
11
56
  * Add `context_lead_text` to translations (minor)
data/Gemfile CHANGED
@@ -9,3 +9,4 @@ gem 'rake', '~> 12.0'
9
9
  gem 'rspec', '~> 3.0'
10
10
 
11
11
  gem 'codecov', require: false
12
+
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- openstax_kitchen (12.2.0)
4
+ openstax_kitchen (16.0.0)
5
5
  activesupport
6
6
  i18n
7
7
  nokogiri
@@ -27,7 +27,7 @@ GEM
27
27
  concurrent-ruby (1.1.9)
28
28
  diff-lcs (1.3)
29
29
  docile (1.4.0)
30
- i18n (1.8.10)
30
+ i18n (1.8.11)
31
31
  concurrent-ruby (~> 1.0)
32
32
  inch (0.8.0)
33
33
  pry
@@ -99,7 +99,7 @@ GEM
99
99
  tins (~> 1.0)
100
100
  tins (1.26.0)
101
101
  sync
102
- twitter_cldr (6.7.0)
102
+ twitter_cldr (6.8.0)
103
103
  camertron-eprun
104
104
  cldr-plurals-runtime-rb (~> 1.1)
105
105
  tzinfo
@@ -107,7 +107,7 @@ GEM
107
107
  concurrent-ruby (~> 1.0)
108
108
  unicode-display_width (1.7.0)
109
109
  yard (0.9.24)
110
- zeitwerk (2.4.2)
110
+ zeitwerk (2.5.1)
111
111
 
112
112
  PLATFORMS
113
113
  ruby
data/codecov.yaml CHANGED
@@ -5,6 +5,10 @@ coverage:
5
5
  precision: 2
6
6
  round: down
7
7
  range: "70...100"
8
+ status:
9
+ project:
10
+ default:
11
+ threshold: 0.01% # codecov/project fails if there is a drop of more than 0.01%
8
12
 
9
13
  parsers:
10
14
  gcov:
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Kitchen
4
+ module Directions
5
+ module BakeAllChapterSolutionsTypes
6
+ def self.v1(chapter:, within:, metadata_source:, uuid_prefix: '')
7
+ solutions_clipboard = Kitchen::Clipboard.new
8
+
9
+ within.search_with(ExerciseElementEnumerator, InjectedQuestionElementEnumerator)\
10
+ .each do |exercise|
11
+
12
+ solution = exercise.solution
13
+ next unless solution.present?
14
+
15
+ solution.cut(to: solutions_clipboard)
16
+ end
17
+
18
+ content = solutions_clipboard.paste
19
+
20
+ Kitchen::Directions::CompositePageContainer.v1(
21
+ container_key: 'solutions',
22
+ uuid_key: "#{uuid_prefix}solutions",
23
+ metadata_source: metadata_source,
24
+ content: content,
25
+ append_to: chapter
26
+ )
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Kitchen
4
+ module Directions
5
+ module BakeAllNumberedExerciseTypes
6
+ def self.v1(within:, exercise_options: {}, question_options: {})
7
+ exercise_counter = 1
8
+ within.search_with(ExerciseElementEnumerator, InjectedQuestionElementEnumerator)\
9
+ .each do |exercise|
10
+ next if exercise.has_class?('unnumbered')
11
+
12
+ if exercise.instance_of?(ExerciseElement)
13
+ exercise_options[:exercise] = exercise
14
+ exercise_options[:number] = exercise_counter
15
+ BakeNumberedExercise.v1(exercise_options)
16
+ else
17
+ question_options[:number] = exercise_counter
18
+ question_options[:question] = exercise
19
+ BakeInjectedExerciseQuestion.v1(question_options)
20
+ end
21
+ exercise_counter += 1
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -3,9 +3,9 @@
3
3
  module Kitchen
4
4
  module Directions
5
5
  module BakeAnnotationClasses
6
- def self.v1(chapter:)
6
+ def self.v1(book:)
7
7
  V1.new.bake(
8
- chapter: chapter)
8
+ book: book)
9
9
  end
10
10
  end
11
11
  end
@@ -2,8 +2,8 @@
2
2
 
3
3
  module Kitchen::Directions::BakeAnnotationClasses
4
4
  class V1
5
- def bake(chapter:)
6
- chapter.search('p.annotation').each do |annotation|
5
+ def bake(book:)
6
+ book.search('p.annotation').each do |annotation|
7
7
  annotation.wrap_children('span', class: 'os-text')
8
8
  annotation.prepend(child:
9
9
  <<~HTML
@@ -19,7 +19,7 @@ module Kitchen::Directions::BakeAnnotationClasses
19
19
  auditory-icon
20
20
  kinesthetic-icon]
21
21
  annotation_icon_classes.each do |annotation_icon_class|
22
- chapter.search("p.#{annotation_icon_class}").each do |annotation_with_icon_class|
22
+ book.search("p.#{annotation_icon_class}").each do |annotation_with_icon_class|
23
23
  annotation_with_icon_class.search('div.os-icons').first.append(child:
24
24
  <<~HTML
25
25
  <span class = "#{annotation_icon_class}"></span>
@@ -21,6 +21,7 @@ module Kitchen
21
21
  next unless title.present?
22
22
 
23
23
  title.name = "h#{section['data-depth'].to_i + 1}"
24
+ section.name = 'div' if section.has_class?('column-container')
24
25
  end
25
26
  end
26
27
  end
@@ -6,6 +6,14 @@ module Kitchen
6
6
  def self.v1(exercise:, number: nil)
7
7
  V1.new.bake(exercise: exercise, number: number)
8
8
  end
9
+
10
+ def self.v2(exercise:, title:)
11
+ V2.new.bake(exercise: exercise, title: title)
12
+ end
13
+
14
+ def self.v3(exercise:, title:)
15
+ V3.new.bake(exercise: exercise, title: title)
16
+ end
9
17
  end
10
18
  end
11
19
  end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Kitchen::Directions::BakeAutotitledExercise
4
+ # Differences from V1:
5
+ # 1. Title is an <h3><span>, not <h4>, & above the problem instead of within it
6
+ # 2. Title is generated in the recipe and passed to the method
7
+ class V2
8
+ def bake(exercise:, title:)
9
+ exercise.add_class('unnumbered')
10
+ exercise.titles.first&.trash
11
+
12
+ # bake problem
13
+ exercise.prepend(child:
14
+ <<~HTML
15
+ <h3 class="os-title" data-type="title">
16
+ <span class="os-title-label">#{title}</span>
17
+ </h3>
18
+ HTML
19
+ )
20
+ exercise.problem.wrap_children(class: 'os-problem-container')
21
+ return unless exercise.solution
22
+
23
+ exercise.solution.wrap_children(class: 'os-solution-container')
24
+ exercise.solution.prepend(child:
25
+ <<~HTML
26
+ <h4 class="solution-title" data-type="title">
27
+ <span class="os-text">#{I18n.t(:solution)}</span>
28
+ </h4>
29
+ HTML
30
+ )
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Kitchen::Directions::BakeAutotitledExercise
4
+ # Differences from V2:
5
+ # 1. Exercise with solution has class os-hasSolution
6
+ # 2. Solution id is based on exercise id
7
+ class V3
8
+ def bake(exercise:, title:)
9
+ exercise.add_class('unnumbered')
10
+ exercise.titles.first&.trash
11
+
12
+ # bake problem
13
+ exercise.prepend(child:
14
+ <<~HTML
15
+ <h3 class="os-title" data-type="title">
16
+ <span class="os-title-label">#{title}</span>
17
+ </h3>
18
+ HTML
19
+ )
20
+ exercise.problem.wrap_children(class: 'os-problem-container')
21
+ return unless exercise.solution
22
+
23
+ exercise.add_class('os-hasSolution')
24
+ exercise.solution.id = "#{exercise.id}-solution"
25
+ exercise.solution.wrap_children(class: 'os-solution-container')
26
+ exercise.solution.prepend(child:
27
+ <<~HTML
28
+ <h4 class="solution-title" data-type="title">
29
+ <span class="os-text">#{I18n.t(:solution)}</span>
30
+ </h4>
31
+ HTML
32
+ )
33
+ end
34
+ end
35
+ end
@@ -41,7 +41,9 @@ module Kitchen::Directions::BakeChapterGlossary
41
41
 
42
42
  content = @glossary.sort.map { |definition| definition.element.paste }.join
43
43
 
44
- Kitchen::Directions::EocCompositePageContainer.v1(
44
+ return if content.empty?
45
+
46
+ Kitchen::Directions::CompositePageContainer.v1(
45
47
  container_key: 'glossary',
46
48
  uuid_key: "#{uuid_prefix}glossary",
47
49
  metadata_source: metadata_source,
@@ -11,7 +11,7 @@ module Kitchen::Directions::BakeChapterReferences
11
11
 
12
12
  content = chapter.pages.references.cut.paste
13
13
 
14
- Kitchen::Directions::EocCompositePageContainer.v1(
14
+ Kitchen::Directions::CompositePageContainer.v1(
15
15
  container_key: klass,
16
16
  uuid_key: "#{uuid_prefix}#{klass}",
17
17
  metadata_source: metadata_source,
@@ -23,7 +23,7 @@ module Kitchen::Directions::BakeChapterSolutions
23
23
 
24
24
  content = solutions_clipboard.paste
25
25
 
26
- Kitchen::Directions::EocCompositePageContainer.v1(
26
+ Kitchen::Directions::CompositePageContainer.v1(
27
27
  container_key: 'solutions',
28
28
  uuid_key: "#{uuid_prefix}solutions",
29
29
  metadata_source: metadata_source,
@@ -31,7 +31,7 @@ module Kitchen
31
31
 
32
32
  return if summaries.none?
33
33
 
34
- EocCompositePageContainer.v1(
34
+ CompositePageContainer.v1(
35
35
  container_key: klass,
36
36
  uuid_key: "#{uuid_prefix}#{klass}",
37
37
  metadata_source: metadata_source,
@@ -39,7 +39,7 @@ module Kitchen
39
39
  solution.replace_children(with:
40
40
  <<~HTML
41
41
  <h4 data-type="solution-title">
42
- <span class="os-title-label">#{I18n.t(:solution)} </span>
42
+ <span class="os-title-label">#{I18n.t(:solution)}</span>
43
43
  #{solution_number}
44
44
  </h4>
45
45
  <div class="os-solution-container">#{solution.children}</div>
@@ -4,27 +4,13 @@ module Kitchen
4
4
  module Directions
5
5
  module BakeFigure
6
6
  def self.v1(figure:, number:, cases: false)
7
- return if figure.has_class?('unnumbered') && !figure.has_class?('splash') && !figure.caption
8
-
7
+ warn 'warning! exclude unnumbered figures from `BakeFigure` loop' if figure.unnumbered?
9
8
  figure.wrap(%(<div class="os-figure#{' has-splash' if figure.has_class?('splash')}">))
10
9
 
11
- if figure.has_class?('unnumbered') && (figure.caption || figure.has_class?('splash'))
12
- caption = figure.caption&.cut
13
- figure.append(sibling:
14
- <<~HTML
15
- <div class="os-caption-container">
16
- #{"<span class=\"os-caption\">#{caption.children}</span>" if caption}
17
- </div>
18
- HTML
19
- )
20
- return
21
- end
22
-
23
10
  # Store label information
24
11
  figure.target_label(label_text: 'figure', custom_content: number, cases: cases)
25
12
 
26
13
  title = figure.title&.cut
27
-
28
14
  caption = figure.caption&.cut
29
15
  figure.append(sibling:
30
16
  <<~HTML
@@ -30,7 +30,7 @@ module Kitchen::Directions::BakeFootnotes
30
30
  aside_id_to_footnote_number[aside_id] = footnote_number
31
31
  if anchor.parent.name == 'p'
32
32
  anchor.parent.add_class('has-noteref')
33
- elsif anchor.parent.name == 'em' && anchor.parent.parent.name == 'p'
33
+ elsif anchor.parent.name != 'p' && anchor.parent.parent.name == 'p'
34
34
  anchor.parent.parent.add_class('has-noteref')
35
35
  end
36
36
  end
@@ -7,6 +7,8 @@ module Kitchen::Directions::BakeIframes
7
7
  return unless iframes.any?
8
8
 
9
9
  iframes.each do |iframe|
10
+ next if iframe.has_class?('os-is-iframe')
11
+
10
12
  iframe.wrap('<div class="os-has-iframe" data-type="alternatives">')
11
13
  iframe.add_class('os-is-iframe')
12
14
  link_ref = iframe[:src]
@@ -165,7 +165,7 @@ module Kitchen::Directions::BakeIndex
165
165
  group_by = term_reference[0]
166
166
  content = term_reference
167
167
  else
168
- group_by = I18n.transliterate(term_element.text.strip[0])
168
+ group_by = I18n.character_to_group(term_element.text.strip[0])
169
169
  content = term_element.text
170
170
  end
171
171
 
@@ -11,16 +11,12 @@
11
11
  <span class="group-label"><%= section.name %></span>
12
12
  <% section.items.each do |item| %>
13
13
  <div class="os-index-item">
14
- <% item.terms.each_with_index do |term, ii| %>
15
- <% if ii == 0 %>
14
+ <%- item.terms.each_with_index do |term, ii| -%>
15
+ <%- if ii == 0 -%>
16
16
  <span class="os-term" group-by="<%= term.group_by %>"><%= term.text %></span>
17
- <% else %>
18
- <span class="os-index-link-separator">, </span>
19
- <% end %>
20
- <a class="os-term-section-link" href="#<%= term.id %>">
21
- <span class="os-term-section"><%= term.page_title %></span>
22
- </a>
23
- <% end %>
17
+ <%- else -%><span class="os-index-link-separator">, </span><% end %>
18
+ <a class="os-term-section-link" href="#<%= term.id %>"><span class="os-term-section"><%= term.page_title %></span></a><!--
19
+ --><%- end %>
24
20
  </div>
25
21
  <% end %>
26
22
  </div>
@@ -7,12 +7,21 @@ module Kitchen::Directions::BakeInjectedExercise
7
7
 
8
8
  class V1
9
9
  def bake(exercise:)
10
- context = exercise.search('div[data-type="exercise-context"]')&.first
10
+ question_count = exercise.injected_questions.count
11
+ exercise[:'data-question-count'] = question_count
12
+ exercise[:'data-is-multipart'] = question_count > 1 ? 'True' : 'False'
13
+
14
+ context = exercise&.exercise_context
15
+
11
16
  return unless context
12
17
 
13
18
  # link replacement is done by BakeLinkPlaceholders
14
19
  link = context.first('a').cut
15
20
  context.replace_children(with: "#{I18n.t(:context_lead_text)}#{link.paste}")
21
+ return unless question_count == 1
22
+
23
+ question = exercise.exercise_question
24
+ question.prepend(child: context.cut.paste)
16
25
  end
17
26
  end
18
27
  end
@@ -41,11 +41,15 @@ module Kitchen::Directions::BakeInjectedExerciseQuestion
41
41
  end
42
42
  end
43
43
 
44
+ context = question.exercise_context_in_question&.cut&.paste
45
+
44
46
  question.prepend(child:
45
47
  <<~HTML
46
48
  #{problem_number unless only_number_solution}
47
49
  #{"<span class='os-divider'>. </span>" unless only_number_solution}
48
50
  <div class="os-problem-container">
51
+ #{context if context.present?}
52
+ #{"<span class='os-divider'>. </span>" if context.present?}
49
53
  #{question.stimulus&.cut&.paste}
50
54
  #{question.stem.cut.paste}
51
55
  #{question.answers&.cut&.paste}
@@ -30,6 +30,19 @@ module Kitchen
30
30
  end
31
31
  end
32
32
  end
33
+
34
+ # Wraps & moves abstract under the corresponding chapter objective in the intro page
35
+ def self.v3(chapter:)
36
+ abstracts = chapter.abstracts.map do |abstract|
37
+ abstract.wrap('<div class="learning-objective">')
38
+ abstract.parent
39
+ end
40
+
41
+ chapter.introduction_page.search('div.os-chapter-objective') \
42
+ .each_with_index do |objective, index|
43
+ objective.append(child: abstracts[index].cut.paste)
44
+ end
45
+ end
33
46
  end
34
47
  end
35
48
  end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Kitchen
4
+ module Directions
5
+ # Bake directions for LO link labels
6
+ module BakeLOLinkLabels
7
+ def self.v1(book:)
8
+ book.search('a.lo-reference').each do |anchor|
9
+ anchor.wrap_children('span', class: 'label-counter')
10
+ anchor.prepend(child:
11
+ <<~HTML
12
+ <span class="label-text">#{I18n.t(:lo_label_text)}</span>
13
+ HTML
14
+ )
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -3,13 +3,15 @@
3
3
  module Kitchen
4
4
  module Directions
5
5
  module BakeNonIntroductionPages
6
- def self.v1(chapter:)
6
+ def self.v1(chapter:, add_target_label: false)
7
7
  chapter.non_introduction_pages.each do |page|
8
8
  number = "#{chapter.count_in(:book)}.#{page.count_in(:chapter)}"
9
9
 
10
10
  page.search("div[data-type='description']").each(&:trash)
11
11
  page.add_class('chapter-content-module')
12
12
 
13
+ page.target_label(custom_content: number) if add_target_label
14
+
13
15
  title = page.title
14
16
  title.name = 'h2'
15
17
  title.replace_children(with:
@@ -30,32 +30,7 @@ module Kitchen
30
30
  HTML
31
31
  )
32
32
 
33
- bake_unclassified_exercises(note: note) if bake_exercises
34
- end
35
-
36
- def self.bake_unclassified_exercises(note:)
37
- note.exercises.each do |exercise|
38
- exercise.problem.wrap_children('div', class: 'os-problem-container')
39
-
40
- unless exercise.has_class?('unnumbered')
41
- exercise.problem.prepend(child:
42
- <<~HTML
43
- <span class="os-title-label">#{I18n.t(:"exercises.exercise")} </span>
44
- <span class="os-number">#{exercise.count_in(:note)}</span>
45
- HTML
46
- )
47
- end
48
-
49
- next unless exercise.solution
50
-
51
- exercise.solution.wrap_children('div', class: 'os-solution-container')
52
-
53
- exercise.solution.prepend(child:
54
- <<~HTML
55
- <span class="os-title-label">#{I18n.t(:"exercises.solution")}</span>
56
- HTML
57
- )
58
- end
33
+ BakeNoteExercise.v2(note: note) if bake_exercises
59
34
  end
60
35
  end
61
36
  end
@@ -0,0 +1,54 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Kitchen
4
+ module Directions
5
+ module BakeNoteExercise
6
+ def self.v1(note:, exercise:, divider: ' ', suppress_solution: false)
7
+ exercise.add_class('unnumbered')
8
+ number = note.first('.os-number').text.gsub(/#/, '')
9
+
10
+ # bake problem
11
+ exercise.problem.wrap_children('div', class: 'os-problem-container')
12
+ exercise.search('[data-type="commentary"]').each(&:trash)
13
+ return unless exercise.solution
14
+
15
+ # bake solution in place
16
+ if suppress_solution
17
+ exercise.add_class('os-hasSolution')
18
+ exercise.solution.trash
19
+ else
20
+ BakeNumberedExercise.bake_solution_v1(
21
+ exercise: exercise,
22
+ number: number,
23
+ divider: divider
24
+ )
25
+ end
26
+ end
27
+
28
+ def self.v2(note:)
29
+ note.exercises.each do |exercise|
30
+ exercise.problem.wrap_children('div', class: 'os-problem-container')
31
+
32
+ unless exercise.has_class?('unnumbered')
33
+ exercise.problem.prepend(child:
34
+ <<~HTML
35
+ <span class="os-title-label">#{I18n.t(:"exercises.exercise")} </span>
36
+ <span class="os-number">#{exercise.count_in(:note)}</span>
37
+ HTML
38
+ )
39
+ end
40
+
41
+ next unless exercise.solution
42
+
43
+ exercise.solution.wrap_children('div', class: 'os-solution-container')
44
+
45
+ exercise.solution.prepend(child:
46
+ <<~HTML
47
+ <span class="os-title-label">#{I18n.t(:"exercises.solution")}</span>
48
+ HTML
49
+ )
50
+ end
51
+ end
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Kitchen
4
+ module Directions
5
+ module BakeNoteInjectedQuestion
6
+ def self.v1(note:, question:)
7
+ question.add_class('unnumbered')
8
+ number = note.first('.os-number').text.gsub(/#/, '')
9
+ Kitchen::Directions::BakeInjectedExerciseQuestion.v1(
10
+ question: question, number: number, only_number_solution: true
11
+ )
12
+ end
13
+ end
14
+ end
15
+ end