openstax_kitchen 17.0.0 → 17.1.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: 774e5af35ed15ba87d97802b8395412003291024053c9ed11aa66eaa4ba20712
4
- data.tar.gz: eb371d8b10113005b69b5864c19fe8eed43aa5b9b965329cfcfdcc8a9287b842
3
+ metadata.gz: 23c782f23dfd67f38174ddb5f51c28955ae7929854e17a6f9163f41bb644485e
4
+ data.tar.gz: 4fafd85f2c59373ebe321e0ddc1b86f5b61e7453bbfe1ca66b94b9ec59c75a59
5
5
  SHA512:
6
- metadata.gz: c4953a8d928e31cf45116cb4ac8f5eb54ab06db3c5d91af038da6acefc1e643ab19a4a585fdfb3cf19de67f24ac3778e36aa972014a3b5f9397734b1c1498829
7
- data.tar.gz: ad336376346ed97f0f924ef6fde9e41f0b7735fa920245fc58d1c7c679d88be72867af5dd6722c25bd6185fcdaa0b57708650dbb0ba94d6e3fa3da2b2751e19d
6
+ metadata.gz: 9cf25e0c145ec59512e2e53b52b7dc8e0146568153c04482f8832341389716d7f7682982b273ffebafebb9a0f0b579ac72cc8fee2141415f96ca652946c2f8be
7
+ data.tar.gz: 15d806949cb3f91884cd09b3aa13bf9de30f0264e6ad2ab6a059531394e1d5016752ff1c01ab1fd19d4d82e513e4b465412ba685cef8cad646903baa9953a7ca
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
+ ## [17.1.0] - 2021-12-17
10
+
11
+ * Add append_to support to `BakeChapterSummary` (minor)
12
+ * Add support for italicized terms in index (minor)
13
+ * Fix problem with namespaces in `BakeLinkPlaceholders` and `BakeIndex` (minor)
14
+ * Create `V3` for `BakeChapterReferences` which sorts references alphabetically (minor)
15
+
9
16
  ## [17.0.0] - 2021-12-3
10
17
 
11
18
  * Create method in `Integer` class that generate roman numbers up to 100 (minor)
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- openstax_kitchen (17.0.0)
4
+ openstax_kitchen (17.1.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)
@@ -18,6 +18,13 @@ module Kitchen
18
18
  uuid_prefix: uuid_prefix,
19
19
  klass: klass)
20
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
21
28
  end
22
29
  end
23
30
  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
@@ -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
@@ -3,5 +3,5 @@
3
3
  # A library for modifying the structure of OpenStax book XML.
4
4
  #
5
5
  module Kitchen
6
- VERSION = '17.0.0'
6
+ VERSION = '17.1.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: 17.0.0
4
+ version: 17.1.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-12-03 00:00:00.000000000 Z
11
+ date: 2021-12-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -266,6 +266,7 @@ files:
266
266
  - lib/kitchen/directions/bake_chapter_references/main.rb
267
267
  - lib/kitchen/directions/bake_chapter_references/v1.rb
268
268
  - lib/kitchen/directions/bake_chapter_references/v2.rb
269
+ - lib/kitchen/directions/bake_chapter_references/v3.rb
269
270
  - lib/kitchen/directions/bake_chapter_section_exercises/main.rb
270
271
  - lib/kitchen/directions/bake_chapter_section_exercises/v1.rb
271
272
  - lib/kitchen/directions/bake_chapter_solutions/main.rb