openstax_kitchen 18.0.0 → 19.0.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: 4343b799c2a49cec3c179ba3af59dae109cdb4fb4839fd7993710d6a1125d322
4
- data.tar.gz: 6ac5fcdb6adda5fbf080b507676156c42dfc301f8060bae4dabe1bf3561fbebf
3
+ metadata.gz: 8ad3abbaf8b72b698a5c8d16136f6d6ec9662c82c12291a7c7f87d02eafc0805
4
+ data.tar.gz: 948a85a3659dd95502113d351cbeb5a3cbc0b2c0151806974c69978818f622f2
5
5
  SHA512:
6
- metadata.gz: 4dad4bfc3619807740965bc6d8f9c4332e13d2031433a5b32576d3fb66d79005ae08bebd9e25398097921ff15e1c835ebefa2b3a35d30185f194442412355f89
7
- data.tar.gz: 6372b3c2860ef570dd6e0ff9011ee08759138843eef48953a2187452581edcccd96df337d1441bad5f03c32482c9058104f2ae20d4e50a905baf279a478fdb87
6
+ metadata.gz: 619c09628f6d62413fd07a7ee4e732cff9f52e78363a2f3414a11f9bbb3f32a008695fb4eaa25f82f0bc8cd81354ebc9e8666973904dd9f5ae2367a6183fde5c
7
+ data.tar.gz: f1b1198cdf3d84544fdd0af0fafa5bb17a0b15a273fb801ea5a4a345a7812da2e0de5311292e5b1e05a4d11715f6564ef817ff07ae5450a23f4397483ba45254
data/CHANGELOG.md CHANGED
@@ -6,6 +6,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [19.0.0] - 2022-1-28
10
+
11
+ * Add features to `BakeScreenreaderSpans` & use translations instead of plaintext (minor)
12
+ * Create `AnswerKeyCleaner` to remove empty chapter containers (minor)
13
+ * Change markup to `span` with `sup` for reference link separator `BakeReferences.v1` plus remove whitespaces and new lines (patch)
14
+ * Changes to `BakeScreenreaderSpans` behavior (major)
15
+ * Changes to `BakeToc` to improve error messaging by including `page.id` (minor)
9
16
 
10
17
  ## [18.0.0] - 2022-01-14
11
18
 
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- openstax_kitchen (18.0.0)
4
+ openstax_kitchen (19.0.0)
5
5
  activesupport
6
6
  i18n
7
7
  nokogiri
@@ -99,7 +99,7 @@ GEM
99
99
  tins (~> 1.0)
100
100
  tins (1.26.0)
101
101
  sync
102
- twitter_cldr (6.11.0)
102
+ twitter_cldr (6.11.1)
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.5.3)
110
+ zeitwerk (2.5.4)
111
111
 
112
112
  PLATFORMS
113
113
  ruby
@@ -8,7 +8,7 @@ module Kitchen::Directions::BakeReferences
8
8
  book.chapters.each do |chapter|
9
9
  chapter.search('[data-type="cite"]').each do |link|
10
10
  link.prepend(child:
11
- <<~HTML
11
+ <<~HTML.chomp
12
12
  <sup class="os-citation-number">#{link.count_in(:chapter)}</sup>
13
13
  HTML
14
14
  )
@@ -21,10 +21,10 @@ module Kitchen::Directions::BakeReferences
21
21
  next unless link_sibling&.raw&.attr('data-type') == 'cite'
22
22
 
23
23
  link.prepend(sibling:
24
- <<~HTML
25
- <span class="os-reference-link-separator">, </span>
24
+ <<~HTML.strip.chomp
25
+ <span class="os-reference-link-separator"><sup>, </sup></span>
26
26
  HTML
27
- )
27
+ )
28
28
  end
29
29
 
30
30
  chapter.references.each do |reference|
@@ -6,17 +6,51 @@ module Kitchen
6
6
  # Add text for accessibility.
7
7
  # Additional screenreader spans can be added below.
8
8
  def self.v1(book:)
9
+ book.search('u[data-effect="underline"]').each do |element|
10
+ add_screenreader_text(
11
+ element: element,
12
+ begin_message: I18n.t(:'screenreader.underline'),
13
+ end_message: "#{I18n.t(:'screenreader.end')} #{I18n.t(:'screenreader.underline')}"
14
+ )
15
+ end
9
16
  book.search('u[data-effect="double-underline"]').each do |element|
10
- element.add_previous_sibling(
11
- '<span data-screenreader-only="true">double underline</span>'
17
+ add_screenreader_text(
18
+ element: element,
19
+ begin_message: I18n.t(:'screenreader.double-underline'),
20
+ end_message: "#{I18n.t(:'screenreader.end')} #{I18n.t(:'screenreader.double-underline')}"
12
21
  )
13
22
  end
14
- book.search('u[data-effect="underline"]').each do |element|
15
- element.add_previous_sibling(
16
- '<span data-screenreader-only="true">underline</span>'
23
+ book.search('p.public-domain').each do |element|
24
+ add_screenreader_text(
25
+ element: element,
26
+ begin_message: I18n.t(:'screenreader.public-domain'),
27
+ end_message: "#{I18n.t(:'screenreader.end')} #{I18n.t(:'screenreader.public-domain')}"
28
+ )
29
+ end
30
+ book.search('p.student-sample').each do |element|
31
+ add_screenreader_text(
32
+ element: element,
33
+ begin_message: I18n.t(:'screenreader.student-sample'),
34
+ end_message: "#{I18n.t(:'screenreader.end')} #{I18n.t(:'screenreader.student-sample')}"
35
+ )
36
+ end
37
+ book.search('p.annotation-text').each do |element|
38
+ add_screenreader_text(
39
+ element: element,
40
+ begin_message: I18n.t(:'screenreader.annotation-text'),
41
+ end_message: "#{I18n.t(:'screenreader.end')} #{I18n.t(:'screenreader.annotation-text')}"
17
42
  )
18
43
  end
19
44
  end
45
+
46
+ def self.add_screenreader_text(element:, begin_message:, end_message:)
47
+ element.prepend(child:
48
+ "<span data-screenreader-only=\"true\">#{begin_message}</span>"
49
+ )
50
+ element.append(child:
51
+ "<span data-screenreader-only=\"true\">#{end_message}</span>"
52
+ )
53
+ end
20
54
  end
21
55
  end
22
56
  end
@@ -100,7 +100,8 @@ module Kitchen
100
100
  page.has_ancestor?(:composite_chapter)
101
101
  'os-toc-unit-page'
102
102
  else
103
- raise "do not know what TOC class to use for page with classes #{page.classes}"
103
+ raise "could not detect which page type class to apply for page.id `#{page.id}`
104
+ during baking the TOC. The classes on the page are: `#{page.classes}`"
104
105
  end
105
106
  when CompositePageElement
106
107
  if page.is_index? || page.is_index_of_type?
@@ -112,10 +113,12 @@ module Kitchen
112
113
  elsif page.has_ancestor?(:composite_chapter) || page.has_ancestor?(:chapter)
113
114
  'os-toc-chapter-composite-page'
114
115
  else
115
- raise "do not know what TOC class to use for page with classes #{page.classes}"
116
+ raise "could not detect which composite page type class to apply to TOC for page id \
117
+ `#{page.id}` during baking the TOC. The classes on the page are: `#{page.classes}`"
116
118
  end
117
119
  else
118
- raise(ArgumentError, "don't know how to put `#{page.class}` into the TOC")
120
+ raise(ArgumentError, "could not detect any page type class to apply for `#{page.id}` \
121
+ during baking TOC")
119
122
  end
120
123
 
121
124
  title = page.title.copy
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Kitchen::Directions::AnswerKeyCleaner
4
+ def self.v1(book:)
5
+ V1.new.bake(book: book)
6
+ end
7
+
8
+ class V1
9
+ renderable
10
+
11
+ def bake(book:)
12
+ answer_key_chapters = book.search(
13
+ '.os-eob[data-type="composite-chapter"] > [data-type="composite-page"]')
14
+ answer_key_chapters.each do |container|
15
+ container.trash unless container.contains?('[data-type="solution"]')
16
+ end
17
+ end
18
+ end
19
+ end
@@ -3,5 +3,5 @@
3
3
  # A library for modifying the structure of OpenStax book XML.
4
4
  #
5
5
  module Kitchen
6
- VERSION = '18.0.0'
6
+ VERSION = '19.0.0'
7
7
  end
data/lib/locales/en.yml CHANGED
@@ -61,3 +61,10 @@ en:
61
61
  title: Auditory learning style icon
62
62
  kinesthetic-icon:
63
63
  title: Kinesthetic learning style icon
64
+ screenreader:
65
+ end: end
66
+ underline: underline
67
+ double-underline: double underline
68
+ public-domain: public domain text
69
+ student-sample: student sample text
70
+ annotation-text: annotated text
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: 18.0.0
4
+ version: 19.0.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: 2022-01-14 00:00:00.000000000 Z
11
+ date: 2022-01-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -359,6 +359,7 @@ files:
359
359
  - lib/kitchen/directions/move_exercises_to_eoc/v1.rb
360
360
  - lib/kitchen/directions/move_exercises_to_eoc/v2.rb
361
361
  - lib/kitchen/directions/move_exercises_to_eoc/v3.rb
362
+ - lib/kitchen/directions/move_solutions_to_answer_key/answer_key_cleaner.rb
362
363
  - lib/kitchen/directions/move_solutions_to_answer_key/answer_key_inner_container.rb
363
364
  - lib/kitchen/directions/move_solutions_to_answer_key/move_solutions_from_exercise_section.rb
364
365
  - lib/kitchen/directions/move_solutions_to_answer_key/move_solutions_from_numbered_note.rb