openstax_kitchen 11.1.0 → 11.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: 4340461612470e8ddff3976af6bf342821a18f1e01c70d5c6d4dcbf08636ac24
4
- data.tar.gz: 293967ff3cf8af70f6d9d5f5d20866c77608af41c279590b3abb39966813f048
3
+ metadata.gz: e366a482a30f5cda88fe3c76731d3f187e727447cfc9ae1c13ff5e8bb99c1daa
4
+ data.tar.gz: 97db8d770c708fda67c566157989b0999fe12859eb515d52da73a86136ab9c29
5
5
  SHA512:
6
- metadata.gz: 70eedaaa535e97066b5b5b0d80e9c8916ffb6de5ecdf063f7a58d2c984253771742832278e53f5ce8bea3f0f3c7cbdd97da058258e5ace42dda0da372243ff2d
7
- data.tar.gz: 72001901b5c82c46bd835521d9a815d178cc6bcea04502fd6b9b10bf36309ed42028b92714fd003e1a0042c60ce9eb4ab505dc627d8dd763f9c6892ff1fee7ea
6
+ metadata.gz: d1b69721238c536696a265d4419f94944746a8a934f24c2e39d8beebe27b18fbd85b1da1599cf6cf326e2d44053b0927db0ab7edae3e24c1a5bfea44839555d9
7
+ data.tar.gz: 2b420da729d4282fc85f7b074c2848f83d7912a5ff75365ba91d6406b245a1442f0c3dd7074cc6744b44ba96cdc8d00a0a872b092f54a3865e0fd21daff3d81d
data/CHANGELOG.md CHANGED
@@ -6,6 +6,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [11.2.0] - 2021-09-10
10
+
11
+ * Adds `BakeAccessibilityFixes` direction for (minor)
12
+ * Remove deprecation warning from `BakeChapterIntroductions.v1` and adapted to be used like `.v2` (minor)
13
+ * Small class fix for `BakeFootnotes.v1` (patch)
14
+ * Fix `BakeNumberedNotes` to find related example better (minor)
15
+ * Small fix for parameter in `bake_note` definition (minor)
16
+ * Small fixes to return when no elements are found and not add an empty wrapper in `BakeChapterReferences` and
17
+ `BakeFreeResponse` (minor)
18
+ * Adding class `os-timeline-table-container` to numbered tables when required (minor)
19
+ * Fix `BakeExample` to catch the multiple solutions to one exercise (patch)
20
+
9
21
  ## [11.1.0] - 2021-08-30
10
22
 
11
23
  * Update injected questions to synthesize ids during baking (minor)
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- openstax_kitchen (11.1.0)
4
+ openstax_kitchen (11.2.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)
@@ -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
@@ -18,6 +18,8 @@ module Kitchen::Directions::BakeChapterIntroductions
18
18
  def bake_as_note(chapter:)
19
19
  chapter_objectives_note = chapter.notes('$.chapter-objectives').first
20
20
 
21
+ return unless chapter_objectives_note.present?
22
+
21
23
  # trash existing title
22
24
  chapter_objectives_note.titles.first&.trash
23
25
  Kitchen::Directions::BakeAutotitledNotes.v1(
@@ -3,54 +3,14 @@
3
3
  module Kitchen::Directions::BakeChapterIntroductions
4
4
  class V1
5
5
  def bake(book:)
6
- # <b>DEPRECATED:</b> Please use <tt>v2</tt> instead.
7
- warn '[DEPRECATION] `BakeChapterIntroductions.v1` is deprecated. Please use `v2` instead.'
8
-
9
- book.chapters.each do |chapter|
10
- introduction_page = chapter.introduction_page
11
-
12
- introduction_page.search("div[data-type='description']").trash
13
- introduction_page.search("div[data-type='abstract']").trash
14
-
15
- title = introduction_page.title.cut
16
- title.name = 'h2'
17
- Kitchen::Directions::MoveTitleTextIntoSpan.v1(title: title)
18
-
19
- intro_content = introduction_page.search(
20
- "> :not([data-type='metadata']):not(.splash):not(.has-splash)"
21
- ).cut
22
-
23
- chapter_objectives_html = chapter.non_introduction_pages.map do |page|
24
- <<~HTML
25
- <div class="os-chapter-objective">
26
- <a class="os-chapter-objective" href="##{page.title[:id]}">
27
- <span class="os-number">#{chapter.count_in(:book)}.#{page.count_in(:chapter)}</span>
28
- <span class="os-divider"> </span>
29
- <span data-type="" itemprop="" class="os-text">#{page.title.children[0].text}</span>
30
- </a>
31
- </div>
32
- HTML
33
- end.join('')
34
-
35
- chapter_outline =
36
- Kitchen::Directions::BakeChapterIntroductions.bake_chapter_outline(
37
- chapter_objectives_html: chapter_objectives_html
38
- )
39
-
40
- introduction_page.append(child:
41
- <<~HTML
42
- <div class="intro-body">
43
- #{chapter_outline}
44
- <div class="intro-text">
45
- #{title.paste}
46
- #{intro_content.paste}
47
- </div>
48
- </div>
49
- HTML
50
- )
51
- end
52
-
53
- Kitchen::Directions::BakeChapterIntroductions.v1_update_selectors(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
+ )
54
14
  end
55
15
  end
56
16
  end
@@ -7,6 +7,8 @@ module Kitchen::Directions::BakeChapterReferences
7
7
  bake_page_references(page: page)
8
8
  end
9
9
 
10
+ return if chapter.pages.references.none?
11
+
10
12
  content = chapter.pages.references.cut.paste
11
13
 
12
14
  Kitchen::Directions::EocCompositePageContainer.v1(
@@ -30,9 +30,9 @@ module Kitchen
30
30
  problem.wrap_children(class: 'os-problem-container')
31
31
  end
32
32
 
33
- if (solution = exercise.solution)
33
+ exercise.solutions.each do |solution|
34
34
  solution_number = if numbered_solutions
35
- "<span class=\"os-number\">#{exercise.count_in(:example)}</span>"
35
+ "<span class=\"os-number\">#{solution.count_in(:example)}</span>"
36
36
  else
37
37
  ''
38
38
  end
@@ -28,7 +28,11 @@ module Kitchen::Directions::BakeFootnotes
28
28
  anchor.replace_children(with: footnote_number)
29
29
  aside_id = anchor[:href][1..-1]
30
30
  aside_id_to_footnote_number[aside_id] = footnote_number
31
- anchor.parent.add_class('has-noteref') if anchor.parent.name == 'p'
31
+ if anchor.parent.name == 'p'
32
+ anchor.parent.add_class('has-noteref')
33
+ elsif anchor.parent.name == 'em' && anchor.parent.parent.name == 'p'
34
+ anchor.parent.parent.add_class('has-noteref')
35
+ end
32
36
  end
33
37
 
34
38
  container.search('aside').each do |aside|
@@ -20,6 +20,8 @@ module Kitchen::Directions::BakeFreeResponse
20
20
  end
21
21
  end
22
22
 
23
+ return if @free_response_clipboard.none?
24
+
23
25
  append_to_element = append_to || chapter
24
26
  @title_tag = append_to ? 'h3' : 'h2'
25
27
 
@@ -11,7 +11,7 @@ module Kitchen
11
11
  end
12
12
  end
13
13
 
14
- def self.bake_note(note:, bake_subtitle:, cases: false)
14
+ def self.bake_note(note:, bake_subtitle:, cases:)
15
15
  Kitchen::Directions::BakeIframes.v1(outer_element: note)
16
16
  note.wrap_children(class: 'os-note-body')
17
17
 
@@ -9,6 +9,9 @@ module Kitchen::Directions
9
9
  book.chapters.pages.notes("$.#{klass}").each do |note|
10
10
  note.wrap_children(class: 'os-note-body')
11
11
  previous_example = note.previous
12
+ until previous_example.nil? || previous_example[:'data-type'] == 'example'
13
+ previous_example = previous_example.previous
14
+ end
12
15
  os_number = previous_example&.first('.os-number')&.children&.to_s
13
16
 
14
17
  note.prepend(child:
@@ -38,6 +38,8 @@ module Kitchen::Directions::BakeNumberedTable
38
38
  </div>
39
39
  HTML
40
40
  )
41
+
42
+ table.parent.add_class('os-timeline-table-container') if table.has_class?('timeline-table')
41
43
  end
42
44
  end
43
45
  end
@@ -26,6 +26,8 @@ module Kitchen::Directions::BakeNumberedTable
26
26
  </div>
27
27
  HTML
28
28
  )
29
+
30
+ table.parent.add_class('os-timeline-table-container') if table.has_class?('timeline-table')
29
31
  end
30
32
  end
31
33
  end
@@ -39,6 +39,14 @@ module Kitchen
39
39
  first("div[data-type='solution']")
40
40
  end
41
41
 
42
+ # Returns the enumerator for solutions
43
+ #
44
+ # @return [ElementEnumerator]
45
+ #
46
+ def solutions
47
+ search("div[data-type='solution']")
48
+ end
49
+
42
50
  # Returns whether the exercise has been baked
43
51
  #
44
52
  # @return [Boolean]
@@ -3,5 +3,5 @@
3
3
  # A library for modifying the structure of OpenStax book XML.
4
4
  #
5
5
  module Kitchen
6
- VERSION = '11.1.0'
6
+ VERSION = '11.2.0'
7
7
  end
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: 11.1.0
4
+ version: 11.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-08-30 00:00:00.000000000 Z
11
+ date: 2021-09-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -243,6 +243,7 @@ files:
243
243
  - lib/kitchen/counter.rb
244
244
  - lib/kitchen/debug/print_recipe_error.rb
245
245
  - lib/kitchen/directions/.rubocop.yml
246
+ - lib/kitchen/directions/bake_accessibility_fixes.rb
246
247
  - lib/kitchen/directions/bake_annotation_classes/main.rb
247
248
  - lib/kitchen/directions/bake_annotation_classes/v1.rb
248
249
  - lib/kitchen/directions/bake_appendix.rb
@@ -458,7 +459,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
458
459
  - !ruby/object:Gem::Version
459
460
  version: '0'
460
461
  requirements: []
461
- rubygems_version: 3.0.3.1
462
+ rubygems_version: 3.0.3
462
463
  signing_key:
463
464
  specification_version: 4
464
465
  summary: OpenStax content baking library