openstax_kitchen 10.0.0 → 12.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (90) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +61 -0
  3. data/Gemfile.lock +3 -3
  4. data/lib/kitchen/chapter_element.rb +15 -0
  5. data/lib/kitchen/composite_page_element.rb +8 -0
  6. data/lib/kitchen/directions/bake_accessibility_fixes.rb +11 -0
  7. data/lib/kitchen/directions/bake_annotation_classes/main.rb +12 -0
  8. data/lib/kitchen/directions/bake_annotation_classes/v1.rb +32 -0
  9. data/lib/kitchen/directions/bake_autotitled_exercise/main.rb +11 -0
  10. data/lib/kitchen/directions/bake_autotitled_exercise/v1.rb +28 -0
  11. data/lib/kitchen/directions/bake_chapter_introductions/bake_chapter_objectives.rb +48 -0
  12. data/lib/kitchen/directions/bake_chapter_introductions/bake_chapter_outline.rb +14 -0
  13. data/lib/kitchen/directions/bake_chapter_introductions/main.rb +43 -0
  14. data/lib/kitchen/directions/bake_chapter_introductions/v1.rb +16 -0
  15. data/lib/kitchen/directions/bake_chapter_introductions/v2.rb +91 -0
  16. data/lib/kitchen/directions/bake_chapter_key_concepts/v1.rb +0 -1
  17. data/lib/kitchen/directions/bake_chapter_references/v1.rb +3 -3
  18. data/lib/kitchen/directions/bake_chapter_summary.rb +1 -1
  19. data/lib/kitchen/directions/bake_custom_sections/main.rb +14 -0
  20. data/lib/kitchen/directions/bake_custom_sections/v1.rb +42 -0
  21. data/lib/kitchen/directions/bake_eoc_section_content/change_subsection_title_tag.rb +13 -0
  22. data/lib/kitchen/directions/bake_eoc_section_content/remove_section_title.rb +2 -2
  23. data/lib/kitchen/directions/bake_equations.rb +2 -3
  24. data/lib/kitchen/directions/bake_example.rb +8 -7
  25. data/lib/kitchen/directions/bake_figure.rb +5 -3
  26. data/lib/kitchen/directions/bake_first_elements.rb +7 -3
  27. data/lib/kitchen/directions/bake_folio.rb +12 -0
  28. data/lib/kitchen/directions/bake_footnotes/v1.rb +5 -1
  29. data/lib/kitchen/directions/bake_free_response/v1.rb +4 -2
  30. data/lib/kitchen/directions/bake_further_research.rb +1 -2
  31. data/lib/kitchen/directions/bake_iframes/main.rb +11 -0
  32. data/lib/kitchen/directions/bake_iframes/v1.rb +25 -0
  33. data/lib/kitchen/directions/bake_index/main.rb +2 -2
  34. data/lib/kitchen/directions/bake_index/v1.rb +39 -7
  35. data/lib/kitchen/directions/bake_index/v1.xhtml.erb +3 -3
  36. data/lib/kitchen/directions/bake_injected_exercise.rb +18 -0
  37. data/lib/kitchen/directions/bake_injected_exercise_question.rb +71 -0
  38. data/lib/kitchen/directions/{bake_page_abstracts.rb → bake_learning_objectives.rb} +10 -5
  39. data/lib/kitchen/directions/bake_link_placeholders.rb +15 -2
  40. data/lib/kitchen/directions/bake_lists_with_para.rb +3 -3
  41. data/lib/kitchen/directions/bake_notes/bake_autotitled_notes.rb +25 -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 +32 -22
  47. data/lib/kitchen/directions/bake_numbered_exercise/main.rb +3 -2
  48. data/lib/kitchen/directions/bake_numbered_exercise/v1.rb +6 -24
  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 +5 -3
  52. data/lib/kitchen/directions/bake_numbered_table/v2.rb +6 -4
  53. data/lib/kitchen/directions/bake_references/main.rb +3 -2
  54. data/lib/kitchen/directions/bake_references/v1.rb +8 -3
  55. data/lib/kitchen/directions/bake_stepwise.rb +1 -1
  56. data/lib/kitchen/directions/bake_toc.rb +1 -1
  57. data/lib/kitchen/directions/bake_unit_page_title/v1.rb +4 -2
  58. data/lib/kitchen/directions/eoc_section_title_link_snippet.rb +32 -21
  59. data/lib/kitchen/directions/move_custom_section_to_eoc_container/main.rb +1 -3
  60. data/lib/kitchen/directions/move_custom_section_to_eoc_container/v1.rb +2 -2
  61. data/lib/kitchen/directions/move_exercises_to_eoc/v1.rb +1 -2
  62. data/lib/kitchen/directions/move_exercises_to_eoc/v2.rb +0 -1
  63. data/lib/kitchen/directions/move_exercises_to_eoc/v3.rb +1 -2
  64. data/lib/kitchen/directions/move_solutions_to_answer_key/move_solutions_from_exercise_section.rb +34 -0
  65. data/lib/kitchen/directions/move_solutions_to_answer_key/move_solutions_from_numbered_note.rb +27 -0
  66. data/lib/kitchen/directions/move_solutions_to_answer_key/solution_area_snippet.rb +12 -0
  67. data/lib/kitchen/directions/move_solutions_to_answer_key/strategies/calculus.rb +1 -1
  68. data/lib/kitchen/directions/move_solutions_to_answer_key/strategies/contemporary_math.rb +20 -20
  69. data/lib/kitchen/directions/move_solutions_to_answer_key/strategies/default.rb +1 -1
  70. data/lib/kitchen/directions/move_solutions_to_answer_key/strategies/precalculus.rb +18 -39
  71. data/lib/kitchen/directions/move_solutions_to_answer_key/strategies/uphysics.rb +6 -48
  72. data/lib/kitchen/directions/move_solutions_to_answer_key/v1.rb +3 -2
  73. data/lib/kitchen/element_base.rb +36 -4
  74. data/lib/kitchen/element_enumerator_base.rb +35 -0
  75. data/lib/kitchen/exercise_element.rb +42 -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/page_element.rb +12 -1
  79. data/lib/kitchen/selectors/base.rb +6 -0
  80. data/lib/kitchen/selectors/standard_1.rb +3 -0
  81. data/lib/kitchen/solution_element_enumerator.rb +21 -0
  82. data/lib/kitchen/table_element.rb +25 -0
  83. data/lib/kitchen/version.rb +1 -1
  84. data/lib/locales/en.yml +9 -4
  85. data/lib/locales/es.yml +8 -4
  86. data/lib/locales/pl.yml +52 -7
  87. metadata +27 -6
  88. data/lib/kitchen/directions/bake_chapter_introductions/chapter_introduction.xhtml.erb +0 -0
  89. data/lib/kitchen/directions/bake_chapter_introductions.rb +0 -65
  90. data/lib/kitchen/directions/bake_notes/bake_note_iframes.rb +0 -27
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3a071ba6e289c222a7333f401c7d6bd25d6dba9527253b6c6ae123169d9b6425
4
- data.tar.gz: 2debc535f61a289f6668019f1eeb5cd639efaf8d49172d668f8b602e02e91b07
3
+ metadata.gz: ddc1370c1b05b52bdf0df2f0a7cd4624b1725f39aae33f57f9715e091a358f8d
4
+ data.tar.gz: fcd328b3dd9c091f2461e3acd22db036c02c4005bb5c8f31071096ed96461179
5
5
  SHA512:
6
- metadata.gz: 6bfeae3a664c95c17249ab32a8bba863091fb1e23f501273fd57d9752688c29ba9877b5a6404393dc88ae993f16af3f89fa768e3984cf81233908ab238b0350a
7
- data.tar.gz: '086fa06f8f7eb33f3908c15ba0172a02a1738c943ba87b25245f63626cda51e5163edbece95cdce2ce1907d5815aefd179db7fb7e3a4fe2a7165c623c5120ede'
6
+ metadata.gz: fd04ee2890144c697d9ab1ff10f97b9593f594eca116856bc6f26edb51f28e6330a0daca42c23e29d7bc08f2d336e764c957dcf93d6f638a22be1572a3ab939c
7
+ data.tar.gz: bb270311e092585ef966c4f2ba76d8847d7fbaedaae9c102274363ac5c21bbf411a6af5ebd7689c6b8ffd02d81ea46b586cd2273eab26320f21c559d28019bcb
data/CHANGELOG.md CHANGED
@@ -6,6 +6,67 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [12.0.0] - 2021-09-21
10
+
11
+ * Fixes `BakeStepwise` to skip nested lists (patch)
12
+ * Adds an optional selector to `RemoveSectionTitles` (minor)
13
+ * Patches `BakeFreeResponse` to only delete the first h3, not all h3s (patch)
14
+ * Lets `BakeExample` not count titles in lists as commentary titles (minor)
15
+ * Renames `BakePageAbstracts` to `BakeLearningObjectives` and adds optional parameter for titles in `v2` (major)
16
+ * Gets rid of extraneous titles in `BakeAutoTitledNotes` when subtitles are off (minor)
17
+ * Adds `BakeAutotitledExercise` direction and the option to `bake_unclassified_exercises` within `BakeAutotitledNotes`
18
+ * Adds optional numbering for `BakeReferences.v1` (minor)
19
+ * Patches`BakeNumberedNotes.v3` to suppress solutions outside examples when suppress_solutions is true (minor)
20
+
21
+ ## [11.2.0] - 2021-09-10
22
+
23
+ * Adds `BakeAccessibilityFixes` direction for (minor)
24
+ * Remove deprecation warning from `BakeChapterIntroductions.v1` and adapted to be used like `.v2` (minor)
25
+ * Small class fix for `BakeFootnotes.v1` (patch)
26
+ * Fix `BakeNumberedNotes` to find related example better (minor)
27
+ * Small fix for parameter in `bake_note` definition (minor)
28
+ * Small fixes to return when no elements are found and not add an empty wrapper in `BakeChapterReferences` and
29
+ `BakeFreeResponse` (minor)
30
+ * Adding class `os-timeline-table-container` to numbered tables when required (minor)
31
+ * Fix `BakeExample` to catch the multiple solutions to one exercise (patch)
32
+
33
+ ## [11.1.0] - 2021-08-30
34
+
35
+ * Update injected questions to synthesize ids during baking (minor)
36
+ * Fix `BakeListsWithPara` to copy all children from para not just text (minor)
37
+ * Implement labels with cases to `BakeAutotitledNotes` and `BakeNumberedNotes` (minor)
38
+ * Add ids to injected questions (minor)
39
+ * Create `BakeIframes` outer directory to allow bake iframes also from outside notes, remove `BakeNoteIFrames` module from notes directory (minor)
40
+ * Update the contemporary math `Strategy` to target injected solution sections (minor)
41
+ * Update `BakeNumberedNotes` to handle injected questions in notes (minor)
42
+ * Create `InjectedQuestionElement` and `InjectedQuestionElementEnumerator` classes (minor)
43
+ * Create `BakeInjectedExercise` and `BakeInjectedExerciseQuestion` directions (minor)
44
+ * Update `MoveSolutionsFromExerciseSection` and `MoveSolutionsFromNumberedNote` to move injected solutions (minor)
45
+ * Add `SolutionElementEnumerator` to support the above (minor)
46
+ * Remove multipart exercise baking from `BakeNumberedExercise`; this is now done in `InjectedExercise` directions (patch)
47
+ * Modify target labels to use grammatical cases (minor)
48
+ * Modify `BakeIndex` to bake multiple types of indexes (minor)
49
+ * Create `v2` in `BakeChapterIntroductions` that should replace `v1` (minor)
50
+ * Added a DEPRECATION warning in `v1` for `BakeChapterIntroductions` (minor)
51
+ * Added a bit more description to deprecation warning for `BakeChapterIntroductions.v1` (minor)
52
+
53
+ ## [11.0.0] - 2021-08-6
54
+
55
+ * Add `ChangeSubsectionTitleTag` direction for modifying eoc sections (minor)
56
+ * Add `MoveSolutionsFromNumberedNote`, `MoveSolutionsFromExerciseSection`, and `SolutionAreaSnippet` for answer key baking (minor)
57
+ * Refactor the following `Strategies`: contemporary math, precalculus, uphysics (minor)
58
+ * Fix `BakeUnitPageTite` to utilize only pages which are direct children of the unit (patch)
59
+ * Patch `BakeFirstElements` to include first figure elements (patch)
60
+ * Refactor `MoveCustomSectionToEocContainer` to remove `include_intro_page` (major)
61
+ * Update `BakeFirstElement` to optionally add the `has-first-inline-element` class (patch)
62
+ * Patch `BakeExample` crashing if an example has commentary but no title (patch)
63
+ * Refactor `EocSectionTitleLinkSnippet` to only have v1 with optional params (major)
64
+ * Adds `PageElement#count_in_chapter_without_intro_page` (minor)
65
+ * Adds `ChapterElement#has_introduction?` (minor)
66
+ * Adds `BakeFolio` to set spanish translation variables in the html tag for folio-pdf purposes (minor)
67
+ * Create `BakeCustomSections` direction for English Composition (minor)
68
+ * Create `BakeAnnotationClasses` v1 for English Composition (minor)
69
+
9
70
  ## [10.0.0] - 2021-07-30
10
71
 
11
72
  * Add support for baking multipart questions to `BakeNumberedExercise` (minor)
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- openstax_kitchen (10.0.0)
4
+ openstax_kitchen (12.0.0)
5
5
  activesupport
6
6
  i18n
7
7
  nokogiri
@@ -11,7 +11,7 @@ PATH
11
11
  GEM
12
12
  remote: https://rubygems.org/
13
13
  specs:
14
- activesupport (6.1.4)
14
+ activesupport (6.1.4.1)
15
15
  concurrent-ruby (~> 1.0, >= 1.0.2)
16
16
  i18n (>= 1.6, < 2)
17
17
  minitest (>= 5.1)
@@ -99,7 +99,7 @@ GEM
99
99
  tins (~> 1.0)
100
100
  tins (1.26.0)
101
101
  sync
102
- twitter_cldr (6.6.0)
102
+ twitter_cldr (6.7.0)
103
103
  camertron-eprun
104
104
  cldr-plurals-runtime-rb (~> 1.1)
105
105
  tzinfo
@@ -44,6 +44,14 @@ module Kitchen
44
44
  pages('$.introduction').first
45
45
  end
46
46
 
47
+ # Returns true if the chapter has an introduction
48
+ #
49
+ # @return [Boolean]
50
+ #
51
+ def has_introduction?
52
+ @has_introduction ||= introduction_page.present?
53
+ end
54
+
47
55
  # Returns an enumerator for the glossaries
48
56
  #
49
57
  # @return [ElementEnumerator]
@@ -60,5 +68,12 @@ module Kitchen
60
68
  search('div[data-type="abstract"]')
61
69
  end
62
70
 
71
+ # Returns an enumerator for the learning objectives
72
+ #
73
+ # @return [ElementEnumerator]
74
+ #
75
+ def learning_objectives
76
+ search('section.learning-objectives')
77
+ end
63
78
  end
64
79
  end
@@ -41,6 +41,14 @@ module Kitchen
41
41
  has_class?('os-index-container')
42
42
  end
43
43
 
44
+ # Returns true if this page is a book index of type
45
+ #
46
+ # @return [Boolean]
47
+ #
48
+ def is_index_of_type?
49
+ (self[:class] || '').match?(/os-index-.+-container/)
50
+ end
51
+
44
52
  # In books we can find two types of EOB References.
45
53
  #
46
54
  # One of them has form similar to footnotes. There are citation links in the text that provides
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Kitchen
4
+ module Directions
5
+ module BakeAccessibilityFixes
6
+ def self.v1(section:)
7
+ section.search('ol[data-number-style="lower-alpha"]').each { |ol| ol['type'] = 'a' }
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Kitchen
4
+ module Directions
5
+ module BakeAnnotationClasses
6
+ def self.v1(chapter:)
7
+ V1.new.bake(
8
+ chapter: chapter)
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Kitchen::Directions::BakeAnnotationClasses
4
+ class V1
5
+ def bake(chapter:)
6
+ chapter.search('p.annotation').each do |annotation|
7
+ annotation.wrap_children('span', class: 'os-text')
8
+ annotation.prepend(child:
9
+ <<~HTML
10
+ <div class="os-icons"></div>
11
+ HTML
12
+ )
13
+ end
14
+ annotation_icon_classes = %w[linguistic-icon
15
+ culture-icon
16
+ dreaming-icon
17
+ visual-icon
18
+ speech-icon
19
+ auditory-icon
20
+ kinesthetic-icon]
21
+ annotation_icon_classes.each do |annotation_icon_class|
22
+ chapter.search("p.#{annotation_icon_class}").each do |annotation_with_icon_class|
23
+ annotation_with_icon_class.search('div.os-icons').first.append(child:
24
+ <<~HTML
25
+ <span class = "#{annotation_icon_class}"></span>
26
+ HTML
27
+ )
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Kitchen
4
+ module Directions
5
+ module BakeAutotitledExercise
6
+ def self.v1(exercise:, number: nil)
7
+ V1.new.bake(exercise: exercise, number: number)
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Kitchen::Directions::BakeAutotitledExercise
4
+ class V1
5
+ def bake(exercise:, number:)
6
+ exercise.add_class('unnumbered') unless number
7
+
8
+ # bake problem
9
+ exercise.problem.wrap_children('div', class: 'os-problem-container')
10
+ exercise.problem.prepend(child:
11
+ <<~HTML
12
+ <h4 class="exercise-title" data-type="title">#{exercise.autogenerated_title}</h4>
13
+ HTML
14
+ )
15
+ return unless exercise.solution
16
+
17
+ # bake solution in place
18
+ exercise.solution.wrap_children('div', class: 'os-solution-container')
19
+ exercise.solution.prepend(child:
20
+ <<~HTML
21
+ <h4 class="solution-title" data-type="title">
22
+ <span class="os-text">#{I18n.t(:"exercises.solution")}</span>
23
+ </h4>
24
+ HTML
25
+ )
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,48 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Kitchen::Directions::BakeChapterIntroductions
4
+ class BakeChapterObjectives
5
+ def bake(chapter:, strategy:)
6
+ case strategy
7
+ when :default
8
+ bake_as_note(chapter: chapter)
9
+ when :add_objectives
10
+ add_chapter_objectives(chapter: chapter)
11
+ when :none
12
+ ''
13
+ else
14
+ raise 'No such strategy'
15
+ end
16
+ end
17
+
18
+ def bake_as_note(chapter:)
19
+ chapter_objectives_note = chapter.notes('$.chapter-objectives').first
20
+
21
+ return unless chapter_objectives_note.present?
22
+
23
+ # trash existing title
24
+ chapter_objectives_note.titles.first&.trash
25
+ Kitchen::Directions::BakeAutotitledNotes.v1(
26
+ book: chapter,
27
+ classes: %w[chapter-objectives],
28
+ bake_subtitle: false
29
+ )
30
+
31
+ chapter_objectives_note.cut.paste
32
+ end
33
+
34
+ def add_chapter_objectives(chapter:)
35
+ chapter.non_introduction_pages.map do |page|
36
+ <<~HTML
37
+ <div class="os-chapter-objective">
38
+ <a class="os-chapter-objective" href="##{page.title[:id]}">
39
+ <span class="os-number">#{chapter.count_in(:book)}.#{page.count_in(:chapter)}</span>
40
+ <span class="os-divider"> </span>
41
+ <span data-type="" itemprop="" class="os-text">#{page.title.children[0].text}</span>
42
+ </a>
43
+ </div>
44
+ HTML
45
+ end.join('')
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Kitchen::Directions::BakeChapterIntroductions
4
+ class BakeChapterOutline
5
+ def bake(chapter_objectives_html:)
6
+ <<~HTML
7
+ <div class="os-chapter-outline">
8
+ <h3 class="os-title">#{I18n.t(:chapter_outline)}</h3>
9
+ #{chapter_objectives_html}
10
+ </div>
11
+ HTML
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,43 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Kitchen
4
+ module Directions
5
+ module BakeChapterIntroductions
6
+ def self.v1(book:)
7
+ V1.new.bake(
8
+ book: book
9
+ )
10
+ end
11
+
12
+ def self.v2(
13
+ book:,
14
+ strategy_options: {
15
+ strategy: :default, bake_chapter_outline: false, introduction_order: :v1
16
+ }
17
+ )
18
+ V2.new.bake(
19
+ book: book,
20
+ strategy_options: strategy_options
21
+ )
22
+ end
23
+
24
+ def self.bake_chapter_objectives(chapter:, strategy:)
25
+ BakeChapterObjectives.new.bake(
26
+ chapter: chapter,
27
+ strategy: strategy
28
+ )
29
+ end
30
+
31
+ def self.bake_chapter_outline(chapter_objectives_html:)
32
+ BakeChapterOutline.new.bake(
33
+ chapter_objectives_html: chapter_objectives_html
34
+ )
35
+ end
36
+
37
+ def self.v1_update_selectors(something_with_selectors)
38
+ something_with_selectors.selectors.title_in_introduction_page =
39
+ ".intro-text > [data-type='document-title']"
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Kitchen::Directions::BakeChapterIntroductions
4
+ class V1
5
+ def bake(book:)
6
+ Kitchen::Directions::BakeChapterIntroductions.v2(
7
+ book: book,
8
+ strategy_options: {
9
+ strategy: :add_objectives,
10
+ bake_chapter_outline: true,
11
+ introduction_order: :v1
12
+ }
13
+ )
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,91 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Kitchen::Directions::BakeChapterIntroductions
4
+ class V2
5
+ def bake(book:, strategy_options:)
6
+ book.chapters.each do |chapter|
7
+ introduction_page = chapter.introduction_page
8
+ title = bake_title(introduction_page: introduction_page)
9
+
10
+ chapter_intro_html =
11
+ Kitchen::Directions::BakeChapterIntroductions.bake_chapter_objectives(
12
+ chapter: chapter,
13
+ strategy: strategy_options[:strategy]
14
+ )
15
+
16
+ if strategy_options[:bake_chapter_outline]
17
+ chapter_intro_html =
18
+ Kitchen::Directions::BakeChapterIntroductions.bake_chapter_outline(
19
+ chapter_objectives_html: chapter_intro_html
20
+ )
21
+ end
22
+
23
+ case strategy_options[:introduction_order]
24
+ when :v1
25
+ v1_introduction_order(
26
+ introduction_page: introduction_page,
27
+ chapter_intro_html: chapter_intro_html,
28
+ title: title
29
+ )
30
+ when :v2
31
+ v2_introduction_order(
32
+ introduction_page: introduction_page,
33
+ chapter_intro_html: chapter_intro_html,
34
+ title: title
35
+ )
36
+ end
37
+ end
38
+
39
+ Kitchen::Directions::BakeChapterIntroductions.v1_update_selectors(book)
40
+ end
41
+
42
+ def v1_introduction_order(introduction_page:, chapter_intro_html:, title:)
43
+ intro_content = introduction_page.search(
44
+ "> :not([data-type='metadata']):not(.splash):not(.has-splash)"
45
+ ).cut
46
+
47
+ introduction_page.append(child:
48
+ <<~HTML
49
+ <div class="intro-body">
50
+ #{chapter_intro_html}
51
+ <div class="intro-text">
52
+ #{title.paste}
53
+ #{intro_content.paste}
54
+ </div>
55
+ </div>
56
+ HTML
57
+ )
58
+ end
59
+
60
+ def v2_introduction_order(introduction_page:, chapter_intro_html:, title:)
61
+ if chapter_intro_html.empty?
62
+ chapter_intro_html = introduction_page.notes('$.chapter-objectives').first&.cut&.paste
63
+ end
64
+ extra_content = introduction_page.search(
65
+ '> :not([data-type="metadata"]):not(.splash):not(.has-splash)'
66
+ ).cut
67
+
68
+ introduction_page.append(child:
69
+ <<~HTML
70
+ <div class="intro-body">
71
+ #{chapter_intro_html}
72
+ <div class="intro-text">
73
+ #{title.paste}
74
+ #{extra_content.paste}
75
+ </div>
76
+ </div>
77
+ HTML
78
+ )
79
+ end
80
+
81
+ def bake_title(introduction_page:)
82
+ introduction_page.search(
83
+ 'div[data-type="description"], div[data-type="abstract"]'
84
+ ).each(&:trash)
85
+
86
+ title = introduction_page.title.cut
87
+ title.name = 'h2'
88
+ Kitchen::Directions::MoveTitleTextIntoSpan.v1(title: title)
89
+ end
90
+ end
91
+ end
@@ -10,7 +10,6 @@ module Kitchen::Directions::BakeChapterKeyConcepts
10
10
  uuid_key: "#{uuid_prefix}key-concepts",
11
11
  section_selector: 'section.key-concepts',
12
12
  append_to: append_to || chapter,
13
- include_intro_page: false,
14
13
  wrap_section: true, wrap_content: true
15
14
  ) do |section|
16
15
  Kitchen::Directions::RemoveSectionTitle.v1(section: section)
@@ -3,12 +3,12 @@
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
 
10
+ return if chapter.pages.references.none?
11
+
12
12
  content = chapter.pages.references.cut.paste
13
13
 
14
14
  Kitchen::Directions::EocCompositePageContainer.v1(
@@ -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?
@@ -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,8 +3,8 @@
3
3
  module Kitchen
4
4
  module Directions
5
5
  module RemoveSectionTitle
6
- def self.v1(section:)
7
- section.first('[data-type="title"]')&.trash
6
+ def self.v1(section:, selector: '')
7
+ section.first("#{selector}[data-type=\"title\"]")&.trash
8
8
  end
9
9
  end
10
10
  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,22 +3,21 @@
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)
19
+ # Store label information
20
+ example.target_label(label_text: 'example', custom_content: number, cases: cases)
22
21
 
23
22
  example.titles_to_rename.each do |title|
24
23
  title.name = 'h4'
@@ -31,9 +30,9 @@ module Kitchen
31
30
  problem.wrap_children(class: 'os-problem-container')
32
31
  end
33
32
 
34
- if (solution = exercise.solution)
33
+ exercise.solutions.each do |solution|
35
34
  solution_number = if numbered_solutions
36
- "<span class=\"os-number\">#{exercise.count_in(:example)}</span>"
35
+ "<span class=\"os-number\">#{solution.count_in(:example)}</span>"
37
36
  else
38
37
  ''
39
38
  end
@@ -54,6 +53,8 @@ module Kitchen
54
53
  next unless commentary.present?
55
54
 
56
55
  commentary_title = commentary.titles.first
56
+ next unless commentary_title.present? && commentary_title.parent['data-type'] != 'list'
57
+
57
58
  commentary_title.name = 'h4'
58
59
  commentary_title['data-type'] = 'commentary-title'
59
60
  commentary_title.wrap_children('span', class: 'os-title-label')