openstax_kitchen 12.1.0 → 12.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 28254d4a9107528ff5dbebacc82e5cc3cbf20e71fcc9d8303c2f41fd90d2d4be
4
- data.tar.gz: 2c71714f62fe45ea772614d5c72f6a95ce59deebc63e1259b182e25d70481400
3
+ metadata.gz: f36305ee23acfe22fc13a9c06ee76f69243f1cd2cba33fe86c28c8c90b5eb36d
4
+ data.tar.gz: fd501ef342ff2c7334455cc214139581dadf1619fde7841a29650b4fc10acd79
5
5
  SHA512:
6
- metadata.gz: dfaf9123a29ef2bedddb524ed7758b1092c88c6cbc850aeee0d4530633783ab2cbec39b68f3b5fc391219f344f191c4714f779ef8efc57c7f35c47d075eb813e
7
- data.tar.gz: c686d00ca4305b0f90f23c4ba2cfb3151a5c0384f7979e82fe16d5432a9e79b32705822aeae244601343d3620e053247b848edf78631c59f93a920e312d7951d
6
+ metadata.gz: e3b939d8a9851db4940213aae3350f720369eb794b8551627d2a44565af36aeda5ad701b62c2c1ec98fb7dcfabafa8bd2e4531642bf40dd777a635c0117560b6
7
+ data.tar.gz: 5ec8d3e59faa619a3b23a84ce74514c96b6d360dc1b46d233cd1566b63815a5a7edaa73980f102b4c6656c603c43ea349fcc2eac99149cbafb8fa91d8f0e2fdc
data/CHANGELOG.md CHANGED
@@ -6,6 +6,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [12.2.0] - 2021-10-1
10
+
11
+ * Add `context_lead_text` to translations (minor)
12
+ * Make `ElementBase#search_with` callable from an `ElementEnumerator` (minor)
13
+ * Support top-titled tables in `BakeUnnumberedTables` (minor)
14
+ * Stop `NoteElement#title` from breaking for empty notes (patch)
15
+ * Add text heavy tables to `BakeTableBody` (minor)
16
+ * Modify `BakeAutotitledNotes` to bake unnumbered exercises with solution (minor)
17
+ * Create `AddInjectedExerciseId` to separate creating ids from `BakeInjectedExerciseQuestion` (minor)
18
+ * Rework `AddInjectedExerciseId` to use loop inside module (minor)
19
+
9
20
  ## [12.1.0] - 2021-09-24
10
21
 
11
22
  * Fix `BakeExample#titles_to_rename` to exclude exercise titles (patch)
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- openstax_kitchen (12.1.0)
4
+ openstax_kitchen (12.2.0)
5
5
  activesupport
6
6
  i18n
7
7
  nokogiri
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Kitchen
4
+ module Directions
5
+ # Ids should be added before exercises are moved to EOC,
6
+ # since they're using part of the ancestor page id.
7
+ #
8
+ # In some books exercises are numbered after moving.
9
+ # That's why this step has to be separated from BakeInjectedExerciseQuestion
10
+ module AddInjectedExerciseId
11
+ def self.v1(book:)
12
+ book.pages.injected_questions.each(&:id)
13
+ end
14
+ end
15
+ end
16
+ end
@@ -37,10 +37,22 @@ module Kitchen
37
37
  note.exercises.each do |exercise|
38
38
  exercise.problem.wrap_children('div', class: 'os-problem-container')
39
39
 
40
- exercise.problem.prepend(child:
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:
41
54
  <<~HTML
42
- <span class="os-title-label">#{I18n.t(:"exercises.exercise")} </span>
43
- <span class="os-number">#{exercise.count_in(:note)}</span>
55
+ <span class="os-title-label">#{I18n.t(:"exercises.solution")}</span>
44
56
  HTML
45
57
  )
46
58
  end
@@ -62,6 +62,9 @@ module Kitchen
62
62
  elsif table.column_header?
63
63
  custom_table = CustomBody.new(table: table, klass: 'column-header')
64
64
  custom_table.modify_body(has_fake_title: false)
65
+ elsif table.text_heavy?
66
+ custom_table = CustomBody.new(table: table, klass: 'text-heavy')
67
+ custom_table.modify_body(has_fake_title: false)
65
68
  end
66
69
  end
67
70
  end
@@ -9,6 +9,7 @@ module Kitchen
9
9
  table.remove_attribute('summary')
10
10
  table.parent.add_class('os-unstyled-container') if table.unstyled?
11
11
  table.parent.add_class('os-column-header-container') if table.column_header?
12
+ table.parent.add_class('os-top-titled-container') if table.top_titled?
12
13
  end
13
14
  end
14
15
  end
@@ -38,7 +38,9 @@ module Kitchen::Directions::MoveSolutionsToAnswerKey
38
38
  </div>
39
39
  HTML
40
40
  )
41
- strategy.bake(chapter: chapter, append_to: append_to.first("[data-uuid-key='#{uuid_key}']"))
41
+ strategy.bake(
42
+ chapter: chapter, append_to: append_to.first("div[data-uuid-key='#{uuid_key}']")
43
+ )
42
44
  end
43
45
  # rubocop:enable Metrics/ParameterLists
44
46
  end
@@ -427,23 +427,6 @@ module Kitchen
427
427
  )
428
428
  end
429
429
 
430
- # Searches for elements handled by a list of enumerator classes. All element that
431
- # matches one of those enumerator classes are iterated over.
432
- #
433
- # @param enumerator_classes [Array<ElementEnumeratorBase>]
434
- # @return [TypeCastingElementEnumerator]
435
- #
436
- def search_with(*enumerator_classes)
437
- block_error_if(block_given?)
438
- raise 'must supply at least one enumerator class' if enumerator_classes.empty?
439
-
440
- factory = enumerator_classes[0].factory
441
- enumerator_classes[1..-1].each do |enumerator_class|
442
- factory = factory.or_with(enumerator_class.factory)
443
- end
444
- factory.build_within(self)
445
- end
446
-
447
430
  # Removes the element from its parent and places it on the specified clipboard
448
431
  #
449
432
  # @param to [Symbol, String, Clipboard, nil] the name of the clipboard (or a Clipboard
@@ -770,7 +753,8 @@ module Kitchen
770
753
  # Returns a pages enumerator
771
754
  def_delegators :as_enumerator, :pages, :chapters, :terms, :figures, :notes, :tables, :examples,
772
755
  :metadatas, :non_introduction_pages, :units, :titles, :exercises, :references,
773
- :composite_pages, :composite_chapters, :solutions, :injected_questions
756
+ :composite_pages, :composite_chapters, :solutions, :injected_questions,
757
+ :search_with
774
758
 
775
759
  # Returns this element as an enumerator (over only one element, itself)
776
760
  #
@@ -327,6 +327,23 @@ module Kitchen
327
327
  chain_to(ElementEnumerator, css_or_xpath: css_or_xpath, only: only, except: except)
328
328
  end
329
329
 
330
+ # Searches for elements handled by a list of enumerator classes. All element that
331
+ # matches one of those enumerator classes are iterated over.
332
+ #
333
+ # @param enumerator_classes [Array<ElementEnumeratorBase>]
334
+ # @return [TypeCastingElementEnumerator]
335
+ #
336
+ def search_with(*enumerator_classes)
337
+ block_error_if(block_given?)
338
+ raise 'must supply at least one enumerator class' if enumerator_classes.empty?
339
+
340
+ factory = enumerator_classes[0].factory
341
+ enumerator_classes[1..-1].each do |enumerator_class|
342
+ factory = factory.or_with(enumerator_class.factory)
343
+ end
344
+ factory.build_within(self)
345
+ end
346
+
330
347
  # Returns an enumerator that iterates through elements within the scope of this enumerator
331
348
  #
332
349
  # @param enumerator_class [ElementEnumeratorBase] the enumerator to use for the iteration
@@ -33,7 +33,9 @@ module Kitchen
33
33
  # 1. it is the note body's first child
34
34
  # 2. it is the first child's first child and the first child is a paragraph
35
35
  first_child = first_note_body_child
36
- first_grandchild = first_child&.element_children&.[](0) if first_child.name == 'p'
36
+ return unless first_child
37
+
38
+ first_grandchild = get_first_grandchild_for_title(first_child)
37
39
 
38
40
  if first_child.data_type == 'title'
39
41
  first_child
@@ -47,6 +49,10 @@ module Kitchen
47
49
  note_body ? note_body.element_children[0] : element_children[0]
48
50
  end
49
51
 
52
+ def get_first_grandchild_for_title(first_child)
53
+ first_child&.element_children&.[](0) if first_child.name == 'p'
54
+ end
55
+
50
56
  # Returns true if the note's title is autogenerated
51
57
  #
52
58
  # @return [Boolean]
@@ -97,6 +97,14 @@ module Kitchen
97
97
  has_class?('column-header')
98
98
  end
99
99
 
100
+ # Returns true if the table is text heavy
101
+ #
102
+ # @return [Boolean]
103
+ #
104
+ def text_heavy?
105
+ has_class?('text-heavy')
106
+ end
107
+
100
108
  # Returns an element for the table caption, if present
101
109
  #
102
110
  # @return [Element, nil]
@@ -3,5 +3,5 @@
3
3
  # A library for modifying the structure of OpenStax book XML.
4
4
  #
5
5
  module Kitchen
6
- VERSION = '12.1.0'
6
+ VERSION = '12.2.0'
7
7
  end
data/lib/locales/en.yml CHANGED
@@ -27,6 +27,7 @@ en:
27
27
  section_exercises: ! 'Section %{number} Exercises'
28
28
  iframe_link_text: Click to view content
29
29
  handbook_outline_title: Outline
30
+ context_lead_text: 'Refer to '
30
31
  eoc:
31
32
  glossary: Key Terms
32
33
  key-equations: Key Equations
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: openstax_kitchen
3
3
  version: !ruby/object:Gem::Version
4
- version: 12.1.0
4
+ version: 12.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - JP Slavinsky
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-09-24 00:00:00.000000000 Z
11
+ date: 2021-10-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -294,7 +294,8 @@ files:
294
294
  - lib/kitchen/directions/bake_index/v1.rb
295
295
  - lib/kitchen/directions/bake_index/v1.xhtml.erb
296
296
  - lib/kitchen/directions/bake_injected_exercise.rb
297
- - lib/kitchen/directions/bake_injected_exercise_question.rb
297
+ - lib/kitchen/directions/bake_injected_exercise/add_injected_exercise_id.rb
298
+ - lib/kitchen/directions/bake_injected_exercise/bake_injected_exercise_question.rb
298
299
  - lib/kitchen/directions/bake_inline_lists.rb
299
300
  - lib/kitchen/directions/bake_learning_objectives.rb
300
301
  - lib/kitchen/directions/bake_link_placeholders.rb