openstax_kitchen 16.0.0 → 19.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7796fb964e8a6ff796d9cf84220449681a89e5501e41e0a9a956620faf022d11
4
- data.tar.gz: 4b2c488ac82a05067c7353f274b9f94888125eb7f66cfa92f30db3c28e7ae29a
3
+ metadata.gz: 8ad3abbaf8b72b698a5c8d16136f6d6ec9662c82c12291a7c7f87d02eafc0805
4
+ data.tar.gz: 948a85a3659dd95502113d351cbeb5a3cbc0b2c0151806974c69978818f622f2
5
5
  SHA512:
6
- metadata.gz: cc57439823f55ee6cdec35304a2bb4413a28afc5c98ae616effadec60095cfa964a4b9faa0380178f189c55771d1a1f28813268ce001349f29c3d1b44397d4ab
7
- data.tar.gz: d055f27db123b8e7441f45056e1c6f2a576ab56d1faa3bbdbb4af6a904674f1562e4403dd5e914a372fe67c5e969eb385838aab6f9ff9a5cbc8a0f5b20356df7
6
+ metadata.gz: 619c09628f6d62413fd07a7ee4e732cff9f52e78363a2f3414a11f9bbb3f32a008695fb4eaa25f82f0bc8cd81354ebc9e8666973904dd9f5ae2367a6183fde5c
7
+ data.tar.gz: f1b1198cdf3d84544fdd0af0fafa5bb17a0b15a273fb801ea5a4a345a7812da2e0de5311292e5b1e05a4d11715f6564ef817ff07ae5450a23f4397483ba45254
data/CHANGELOG.md CHANGED
@@ -6,12 +6,43 @@ 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)
16
+
17
+ ## [18.0.0] - 2022-01-14
18
+
19
+ * Fix links in `BakeHanbook` outline to point sections (patch)
20
+ * Add unit title prefix with number to `BakeUnitPageTitle` (patch)
21
+ * Add `scope="col"` attribute to `BakeTableBody` and `BakeUnnumberedTables` (major)
22
+
23
+ ## [17.1.0] - 2021-12-17
24
+
25
+ * Add append_to support to `BakeChapterSummary` (minor)
26
+ * Add support for italicized terms in index (minor)
27
+ * Fix problem with namespaces in `BakeLinkPlaceholders` and `BakeIndex` (minor)
28
+ * Create `V3` for `BakeChapterReferences` which sorts references alphabetically (minor)
29
+
30
+ ## [17.0.0] - 2021-12-3
31
+
32
+ * Create method in `Integer` class that generate roman numbers up to 100 (minor)
33
+ * Add more roman numbers to `Integer` class (patch)
34
+ * Create `V2` for `BakeChapterReferences` (minor)
35
+ * Create `BakeExercisePrefixes` direction adding prefixes for exercises in selected sections (minor)
36
+ * Add support for 'text-heavy-top-titled' tables in `BakeTableBody` (minor)
37
+ * Remove `Nokigiri#previous` patch, `ElementBase#previous` now uses `#previous_element` (minor)
38
+ * Modifies `BakeAnnotationClasses` for annotations wrapper to be a `span` intead of a `div` (major)
9
39
 
10
40
  ## [16.0.0] - 2021-11-19
11
41
 
12
42
  * Add reference link separator to `BakeReferences.v1` (patch)
13
43
  * Modify `BakeFootnotes` to be more general (minor)
14
44
  * Add `#preceded_by_text` method to element_base and the nokigiri patch (minor)
45
+ * Remove `Nokigiri#previous` patch, `ElementBase#previous` now uses `#previous_element` (minor)
15
46
  * Broaden caption selection for `BakeNumberedTable#v2` (patch)
16
47
  * Add details of question count to injected exercises in `BakeInjectedExercise` (major)
17
48
  * 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)
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- openstax_kitchen (16.0.0)
4
+ openstax_kitchen (19.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.1)
14
+ activesupport (6.1.4.4)
15
15
  concurrent-ruby (~> 1.0, >= 1.0.2)
16
16
  i18n (>= 1.6, < 2)
17
17
  minitest (>= 5.1)
@@ -36,7 +36,7 @@ GEM
36
36
  yard (~> 0.9.12)
37
37
  method_source (1.0.0)
38
38
  mini_portile2 (2.5.0)
39
- minitest (5.14.4)
39
+ minitest (5.15.0)
40
40
  nokogiri (1.11.1)
41
41
  mini_portile2 (~> 2.5.0)
42
42
  racc (~> 1.4)
@@ -99,7 +99,7 @@ GEM
99
99
  tins (~> 1.0)
100
100
  tins (1.26.0)
101
101
  sync
102
- twitter_cldr (6.8.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.1)
110
+ zeitwerk (2.5.4)
111
111
 
112
112
  PLATFORMS
113
113
  ruby
@@ -20,9 +20,18 @@ module Kitchen::Directions::BakeAnnotationClasses
20
20
  kinesthetic-icon]
21
21
  annotation_icon_classes.each do |annotation_icon_class|
22
22
  book.search("p.#{annotation_icon_class}").each do |annotation_with_icon_class|
23
- annotation_with_icon_class.search('div.os-icons').first.append(child:
23
+ annotation_with_icon_class.search('div.os-icons').first&.name = 'span'
24
+
25
+ icon_title = I18n.t(:"annotation_icons.#{annotation_icon_class}.title")
26
+
27
+ annotation_with_icon_class.search('span.os-icons').first.append(child:
24
28
  <<~HTML
25
- <span class = "#{annotation_icon_class}"></span>
29
+ <span
30
+ class = "#{annotation_icon_class}"
31
+ role="img"
32
+ title="#{icon_title}"
33
+ aria-label="#{icon_title}"
34
+ ></span>
26
35
  HTML
27
36
  )
28
37
  end
@@ -10,6 +10,21 @@ module Kitchen
10
10
  uuid_prefix: uuid_prefix,
11
11
  klass: klass)
12
12
  end
13
+
14
+ def self.v2(chapter:, metadata_source:, uuid_prefix: '.', klass: 'references')
15
+ V2.new.bake(
16
+ chapter: chapter,
17
+ metadata_source: metadata_source,
18
+ uuid_prefix: uuid_prefix,
19
+ klass: klass)
20
+ end
21
+
22
+ def self.v3(chapter:, metadata_source:, uuid_prefix: '.')
23
+ V3.new.bake(
24
+ chapter: chapter,
25
+ metadata_source: metadata_source,
26
+ uuid_prefix: uuid_prefix)
27
+ end
13
28
  end
14
29
  end
15
30
  end
@@ -0,0 +1,53 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Kitchen::Directions::BakeChapterReferences
4
+ class V2
5
+ def bake(chapter:, metadata_source:, uuid_prefix: '.', klass: 'references')
6
+ chapter.pages.each do |page|
7
+ bake_page_cite(page: page)
8
+ bake_page_references(page: page)
9
+ end
10
+
11
+ return if chapter.pages.references.none?
12
+
13
+ content = chapter.pages.references.cut.paste
14
+
15
+ Kitchen::Directions::CompositePageContainer.v1(
16
+ container_key: klass,
17
+ uuid_key: "#{uuid_prefix}#{klass}",
18
+ metadata_source: metadata_source,
19
+ content: content,
20
+ append_to: chapter
21
+ )
22
+ end
23
+
24
+ def bake_page_cite(page:)
25
+ page.search('[data-type="cite"]').each do |link|
26
+ link.id = "#{page.id}-endNote#{link.count_in(:chapter)}"
27
+
28
+ link.prepend(child:
29
+ <<~HTML
30
+ <sup class="os-end-note-number">#{link.count_in(:chapter)}</sup>
31
+ HTML
32
+ )
33
+
34
+ link.search('.delete-me').trash
35
+ end
36
+ end
37
+
38
+ def bake_page_references(page:)
39
+ page.references.each do |reference|
40
+ Kitchen::Directions::RemoveSectionTitle.v1(section: reference)
41
+
42
+ reference.search('a').each do |ref_link|
43
+ ref_link.replace_children(with:
44
+ <<~HTML
45
+ <span>#{ref_link.count_in(:chapter)}.</span>
46
+ HTML
47
+ )
48
+ ref_link.href = "##{page.id}-endNote#{ref_link.count_in(:chapter)}"
49
+ end
50
+ end
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,45 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Kitchen::Directions::BakeChapterReferences
4
+ class V3
5
+ class Reference
6
+ attr_reader :element
7
+
8
+ def initialize(element)
9
+ reference_item = Kitchen::I18nString.new(element.text.downcase)
10
+ @sortable = [reference_item]
11
+ @element = element
12
+ end
13
+
14
+ def <=>(other)
15
+ sortable <=> other.sortable
16
+ end
17
+
18
+ protected
19
+
20
+ attr_reader :sortable
21
+ end
22
+
23
+ def bake(chapter:, metadata_source:, append_to: nil, uuid_prefix: '.')
24
+ @references = []
25
+
26
+ chapter.references.search('p').each do |reference_element|
27
+ @references.push(Reference.new(reference_element.cut))
28
+ end
29
+
30
+ chapter.references.trash
31
+
32
+ content = @references.sort.map { |reference| reference.element.paste }.join
33
+
34
+ return if content.empty?
35
+
36
+ Kitchen::Directions::CompositePageContainer.v1(
37
+ container_key: 'references',
38
+ uuid_key: "#{uuid_prefix}references",
39
+ metadata_source: metadata_source,
40
+ content: content,
41
+ append_to: append_to || chapter
42
+ )
43
+ end
44
+ end
45
+ end
@@ -5,17 +5,18 @@ module Kitchen
5
5
  # Bake directions for eoc summary
6
6
  #
7
7
  module BakeChapterSummary
8
- def self.v1(chapter:, metadata_source:, klass: 'summary', uuid_prefix: '.')
8
+ def self.v1(chapter:, metadata_source:, klass: 'summary', uuid_prefix: '.', append_to: nil)
9
9
  V1.new.bake(
10
10
  chapter: chapter,
11
11
  metadata_source: metadata_source,
12
12
  uuid_prefix: uuid_prefix,
13
- klass: klass
13
+ klass: klass,
14
+ append_to: append_to
14
15
  )
15
16
  end
16
17
 
17
18
  class V1
18
- def bake(chapter:, metadata_source:, uuid_prefix: '.', klass: 'summary')
19
+ def bake(chapter:, metadata_source:, uuid_prefix: '.', klass: 'summary', append_to: nil)
19
20
  summaries = Clipboard.new
20
21
 
21
22
  chapter.pages.each do |page|
@@ -36,7 +37,7 @@ module Kitchen
36
37
  uuid_key: "#{uuid_prefix}#{klass}",
37
38
  metadata_source: metadata_source,
38
39
  content: summaries.paste,
39
- append_to: chapter
40
+ append_to: append_to || chapter
40
41
  )
41
42
  end
42
43
  end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Kitchen
4
+ module Directions
5
+ module BakeExercisePrefixes
6
+ def self.v1(chapter:, sections_prefixed:)
7
+ V1.new.bake(
8
+ chapter: chapter,
9
+ sections_prefixed: sections_prefixed
10
+ )
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Kitchen::Directions::BakeExercisePrefixes
4
+ class V1
5
+ def bake(chapter:, sections_prefixed:)
6
+ sections_prefixed.each do |section_key|
7
+ chapter.composite_pages.each do |composite_page|
8
+ composite_page.search("section.#{section_key}").exercises.each do |exercise|
9
+ problem = exercise.problem
10
+ exercise_prefix =
11
+ "<span class='os-text'>#{I18n.t(:"sections_prefixed.#{section_key}")}</span>"
12
+ problem.prepend(child:
13
+ <<~HTML
14
+ #{exercise_prefix}
15
+ HTML
16
+ )
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
@@ -43,7 +43,7 @@ module Kitchen::Directions::BakeHandbook
43
43
 
44
44
  outline_item_html = <<~HTML
45
45
  <div class="os-handbook-objective">
46
- <a class="os-handbook-objective" href="##{first_section_title[:id]}">
46
+ <a class="os-handbook-objective" href="##{section[:id]}">
47
47
  #{first_section_title.children}
48
48
  </a>
49
49
  </div>
@@ -11,12 +11,14 @@ module Kitchen::Directions::BakeIndex
11
11
  attr_reader :id
12
12
  attr_reader :group_by
13
13
  attr_reader :page_title
14
+ attr_reader :italicized
14
15
 
15
- def initialize(text:, id:, group_by:, page_title:)
16
+ def initialize(text:, id:, group_by:, page_title:, italicized:)
16
17
  @text = text.strip
17
18
  @id = id
18
19
  @group_by = group_by
19
20
  @page_title = page_title
21
+ @italicized = italicized
20
22
  end
21
23
  end
22
24
 
@@ -126,7 +128,8 @@ module Kitchen::Directions::BakeIndex
126
128
  page = term_element.ancestor(:page)
127
129
  term_element.id = "auto_#{page.id}_term#{term_element.count_in(:book)}"
128
130
  page_title = page.title.text
129
- add_term_to_index(term_element, page_title)
131
+ term_italicized = term_element&.first("em[data-effect='italics']")
132
+ add_term_to_index(term_element, page_title, term_italicized)
130
133
  end
131
134
 
132
135
  book.chapters.composite_pages.terms.each do |term_element|
@@ -135,7 +138,8 @@ module Kitchen::Directions::BakeIndex
135
138
  term_element.id = "auto_composite_page_term#{term_element.count_in(:book)}"
136
139
  chapter_number = chapter.count_in(:book)
137
140
  page_title = "#{chapter_number} #{page.title.text.strip}".strip
138
- add_term_to_index(term_element, page_title)
141
+ term_italicized = term_element&.first("em[data-effect='italics']")
142
+ add_term_to_index(term_element, page_title, term_italicized)
139
143
  end
140
144
 
141
145
  types.each do |type|
@@ -150,18 +154,18 @@ module Kitchen::Directions::BakeIndex
150
154
  end
151
155
  end
152
156
 
153
- def add_term_to_index(term_element, page_title)
157
+ def add_term_to_index(term_element, page_title, term_italicized)
154
158
  type =
155
159
  if !term_element.key?('index')
156
160
  'term'
157
- elsif term_element['cxlxt:index'] == 'name'
161
+ elsif term_element['cxlxt:index'] == 'name' || term_element['index'] == 'name'
158
162
  'name'
159
- elsif term_element['cxlxt:index'] == 'foreign'
163
+ elsif term_element['cxlxt:index'] == 'foreign' || term_element['index'] == 'foreign'
160
164
  'foreign'
161
165
  end
162
166
 
163
167
  if term_element.key?('reference')
164
- term_reference = term_element['cmlnle:reference']
168
+ term_reference = term_element['cmlnle:reference'] || term_element['reference']
165
169
  group_by = term_reference[0]
166
170
  content = term_reference
167
171
  else
@@ -175,6 +179,7 @@ module Kitchen::Directions::BakeIndex
175
179
  # Add it to our index object
176
180
  @indexes[type].add_term(
177
181
  Term.new(
182
+ italicized: term_italicized,
178
183
  text: content,
179
184
  id: term_element.id,
180
185
  group_by: group_by,
@@ -13,7 +13,7 @@
13
13
  <div class="os-index-item">
14
14
  <%- item.terms.each_with_index do |term, ii| -%>
15
15
  <%- if ii == 0 -%>
16
- <span class="os-term" group-by="<%= term.group_by %>"><%= term.text %></span>
16
+ <span class="os-term" group-by="<%= term.group_by %>"><%- if term.italicized -%><em data-effect="italics"><%= term.text %></em><%- else -%><%= term.text %><% end %></span>
17
17
  <%- else -%><span class="os-index-link-separator">, </span><% end %>
18
18
  <a class="os-term-section-link" href="#<%= term.id %>"><span class="os-term-section"><%= term.page_title %></span></a><!--
19
19
  --><%- end %>
@@ -9,7 +9,7 @@ module Kitchen
9
9
  book.search('a').each do |anchor|
10
10
  next unless anchor.text == '[link]'
11
11
 
12
- label_case = anchor['cmlnle:case']
12
+ label_case = anchor['cmlnle:case'] || anchor['case']
13
13
  id = anchor[:href][1..-1]
14
14
 
15
15
  if cases
@@ -40,12 +40,17 @@ module Kitchen
40
40
  table.remove_attribute('summary')
41
41
  table.wrap(%(<div class="os-table">))
42
42
 
43
+ table.search('th').each do |header|
44
+ header[:scope] = 'col'
45
+ end
46
+
43
47
  # Store label information
44
48
  table.target_label(label_text: 'table', custom_content: number, cases: cases)
45
49
 
46
50
  if table.top_titled?
51
+ klass = table.text_heavy? ? 'text-heavy-top-titled' : 'top-titled'
47
52
  custom_table = CustomBody.new(table: table,
48
- klass: 'top-titled',
53
+ klass: klass,
49
54
  fake_title_class: 'os-table-title',
50
55
  fake_title: table.title,
51
56
  to_trash: table.title_row)
@@ -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
@@ -4,17 +4,23 @@ module Kitchen::Directions::BakeUnitPageTitle
4
4
  class V1
5
5
  def bake(book:)
6
6
  book.units.each do |unit|
7
+ @unit_title = I18n.t(:unit)
8
+ @unit_number = unit.count_in(:book)
7
9
  unit.element_children.only(Kitchen::PageElement).each do |page|
8
- compose_unit_page_title(page: page)
10
+ compose_unit_page_title(page: page, unit_title_prefix: @unit_title,
11
+ unit_number: @unit_number)
9
12
  end
10
13
  end
11
14
  end
12
15
 
13
- def compose_unit_page_title(page:)
16
+ def compose_unit_page_title(page:, unit_title_prefix:, unit_number:)
14
17
  title = page.title
15
18
  title.name = 'h2'
16
19
  title.replace_children(with:
17
20
  <<~HTML
21
+ <span class="os-part-text">#{unit_title_prefix} </span>
22
+ <span class="os-number">#{unit_number}</span>
23
+ <span class="os-divider"> </span>
18
24
  <span data-type="" itemprop="" class="os-text">#{title.text}</span>
19
25
  HTML
20
26
  )
@@ -10,6 +10,10 @@ module Kitchen
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
12
  table.parent.add_class('os-top-titled-container') if table.top_titled?
13
+
14
+ table.search('th').each do |header|
15
+ header[:scope] = 'col'
16
+ end
13
17
  end
14
18
  end
15
19
  end
@@ -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
@@ -223,6 +223,22 @@ module Kitchen
223
223
  self[:'data-type']
224
224
  end
225
225
 
226
+ # Returns the element's href
227
+ #
228
+ # @return [String]
229
+ #
230
+ def href
231
+ self[:href]
232
+ end
233
+
234
+ # Sets the element's href
235
+ #
236
+ # @param value [String] the new value for the href
237
+ #
238
+ def href=(value)
239
+ self[:href] = value
240
+ end
241
+
226
242
  # A way to set values and chain them
227
243
  #
228
244
  # @param property [String, Symbol] the name of the property to set
@@ -511,7 +527,7 @@ module Kitchen
511
527
  # nil if there's no previous sibling
512
528
  #
513
529
  def previous
514
- prev = raw.previous
530
+ prev = raw.previous_element
515
531
  return prev if prev.nil?
516
532
 
517
533
  Element.new(
@@ -3,7 +3,22 @@
3
3
  # Monkey patches for +Integer+
4
4
  #
5
5
  class Integer
6
- ROMAN_NUMERALS = %w[0 i ii iii iv v vi vii viii ix x xi xii xiii xiv xv xvi xvii xviii xix xx].freeze
6
+
7
+ @roman_numerals = {
8
+ 100 => 'c',
9
+ 90 => 'xc',
10
+ 50 => 'l',
11
+ 40 => 'xl',
12
+ 10 => 'x',
13
+ 9 => 'ix',
14
+ 5 => 'v',
15
+ 4 => 'iv',
16
+ 1 => 'i'
17
+ }
18
+
19
+ class << self
20
+ attr_accessor :roman_numerals
21
+ end
7
22
 
8
23
  # Formats as different types of integers, including roman numerals.
9
24
  #
@@ -14,11 +29,25 @@ class Integer
14
29
  when :arabic
15
30
  to_s
16
31
  when :roman
17
- raise 'Unknown conversion to Roman numerals' if self >= ROMAN_NUMERALS.size
32
+ raise 'Unknown conversion to Roman numerals' if self > self.class.roman_numerals.keys.first
18
33
 
19
- ROMAN_NUMERALS[self]
34
+ to_roman
20
35
  else
21
36
  raise 'Unknown integer format'
22
37
  end
23
38
  end
39
+
40
+ def to_roman
41
+ return 0 if zero?
42
+
43
+ roman = ''
44
+ integer = self
45
+ self.class.roman_numerals.each do |number, letter|
46
+ until integer < number
47
+ roman += letter
48
+ integer -= number
49
+ end
50
+ end
51
+ roman
52
+ end
24
53
  end
@@ -67,13 +67,6 @@ module Nokogiri
67
67
  self[:class]&.split || []
68
68
  end
69
69
 
70
- def previous
71
- prev = previous_element
72
- return nil if prev.nil?
73
-
74
- prev.text? ? prev.previous : prev
75
- end
76
-
77
70
  def preceded_by_text?
78
71
  prev = previous_sibling
79
72
  while !prev.nil? && prev.blank? do prev = prev.previous_sibling 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 = '16.0.0'
6
+ VERSION = '19.0.0'
7
7
  end
data/lib/locales/en.yml CHANGED
@@ -46,3 +46,25 @@ en:
46
46
  reference: References
47
47
  index:
48
48
  main: Index
49
+ annotation_icons:
50
+ linguistic-icon:
51
+ title: Language lens icon
52
+ culture-icon:
53
+ title: Culture lens icon
54
+ dreaming-icon:
55
+ title: Generating and capturing ideas icon
56
+ visual-icon:
57
+ title: Visual learning style icon
58
+ speech-icon:
59
+ title: Voice to text icon
60
+ auditory-icon:
61
+ title: Auditory learning style icon
62
+ kinesthetic-icon:
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: 16.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: 2021-11-19 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
@@ -265,6 +265,8 @@ files:
265
265
  - lib/kitchen/directions/bake_chapter_key_equations.rb
266
266
  - lib/kitchen/directions/bake_chapter_references/main.rb
267
267
  - lib/kitchen/directions/bake_chapter_references/v1.rb
268
+ - lib/kitchen/directions/bake_chapter_references/v2.rb
269
+ - lib/kitchen/directions/bake_chapter_references/v3.rb
268
270
  - lib/kitchen/directions/bake_chapter_section_exercises/main.rb
269
271
  - lib/kitchen/directions/bake_chapter_section_exercises/v1.rb
270
272
  - lib/kitchen/directions/bake_chapter_solutions/main.rb
@@ -281,6 +283,8 @@ files:
281
283
  - lib/kitchen/directions/bake_eoc_section_content/remove_section_title.rb
282
284
  - lib/kitchen/directions/bake_equations.rb
283
285
  - lib/kitchen/directions/bake_example.rb
286
+ - lib/kitchen/directions/bake_exercise_prefixes/main.rb
287
+ - lib/kitchen/directions/bake_exercise_prefixes/v1.rb
284
288
  - lib/kitchen/directions/bake_figure.rb
285
289
  - lib/kitchen/directions/bake_first_elements.rb
286
290
  - lib/kitchen/directions/bake_folio.rb
@@ -355,6 +359,7 @@ files:
355
359
  - lib/kitchen/directions/move_exercises_to_eoc/v1.rb
356
360
  - lib/kitchen/directions/move_exercises_to_eoc/v2.rb
357
361
  - lib/kitchen/directions/move_exercises_to_eoc/v3.rb
362
+ - lib/kitchen/directions/move_solutions_to_answer_key/answer_key_cleaner.rb
358
363
  - lib/kitchen/directions/move_solutions_to_answer_key/answer_key_inner_container.rb
359
364
  - lib/kitchen/directions/move_solutions_to_answer_key/move_solutions_from_exercise_section.rb
360
365
  - lib/kitchen/directions/move_solutions_to_answer_key/move_solutions_from_numbered_note.rb