openstax_kitchen 6.0.0 → 6.1.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: 544eb8b780fd248111e4dc9738c32b7edfefc101fbf6abd82f25c01bada69708
4
- data.tar.gz: c3f1e2658259f5d9a04dde8aa188793c3c82e8ef6a4f6c1354e2b50d5ed7982d
3
+ metadata.gz: 68b22024e79d8b530195dafc0dba4b939f7c5503023ae1fbc1ee876a038595d9
4
+ data.tar.gz: 4a35e7fdbae28ecadd234c1aff6596ef61ec4aaffd4adf2a29bc401ed54b7576
5
5
  SHA512:
6
- metadata.gz: 1829a8193fd8d53e2eaa4d91bd00417eb439b1dce3e690b865ff7741d3aad8637282a680f7840842180bfd811cbd79d7275b1c75502fdbcb72d39ed81572b905
7
- data.tar.gz: 6cf08743860774a7f7b6fa73d26d4adbc56d7e2849e2178fc020456f113774942d23f7f14f2a5f02393c43cbfa0312b787bbb8a1adbdca4943fd76cb697ff9c0
6
+ metadata.gz: 34d9856998c75fee77bc41b734399ffc3045a93082cba273b636b10411b852ee71f4e9bda86a38108e9293f53136194d3c85cb12ea5c92159d571c64d2b85044
7
+ data.tar.gz: d29fd215321a1ab877c16083b73bb0b872ee67c68a636425e6ef5ded5d8fd9ff7ae77599ec1d9a500e69ad627f175ac7c5fb1194310b8e0979d0cc7160403b55
@@ -2,9 +2,6 @@ name: CHANGELOG.md
2
2
 
3
3
  on:
4
4
  pull_request:
5
- push:
6
- branches:
7
- - main
8
5
 
9
6
  jobs:
10
7
  exists:
data/CHANGELOG.md CHANGED
@@ -6,6 +6,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [6.1.0] - 2021-06-21
10
+
11
+ * Create a `BakeReferences` V2 for unnumbered section references (minor)
12
+ * Don't check for CHANGELOG when merge a PR to main (patch)
13
+ * Added `BakeInlineLists` (minor)
9
14
 
10
15
  ## [6.0.0] - 2021-06-15
11
16
 
@@ -37,6 +42,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
37
42
  and from v2 the lack of additional "os-section-area" and os-#{@klass} wrapper (minor)
38
43
  * Add a condition in BakeNumberedExercise to make it possible to suppress even solutions in the Answer Key (minor)
39
44
  * Fix BakeFurtherResearch baking with main bake script error by breaking the loop if further research sections are not present (minor)
45
+ * Rework v1 of `BakeChapterReferences` to bake references also from introduction pages (major)
40
46
  * Fix for `BakeIndex` for words that start with a number to be grouped as symbols and for first letters with accent marks to be grouped with regular letters in alphabetic order (major)
41
47
 
42
48
  ## [5.0.0] - 2021-06-02
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- openstax_kitchen (6.0.0)
4
+ openstax_kitchen (6.1.0)
5
5
  activesupport
6
6
  i18n
7
7
  nokogiri
@@ -43,13 +43,30 @@ module Kitchen
43
43
  has_class?('os-index-container')
44
44
  end
45
45
 
46
- # Returns true if this page is a book reference
46
+ # In books we can find two types of EOB References.
47
+ #
48
+ # One of them has form similar to footnotes. There are citation links in the text that provides
49
+ # to the reference note at the end of the book.
50
+ #
51
+ # Second one is a section with references on the Introduction page that is moved to the EOB.
52
+ #
53
+ # Difference in classes is important.
54
+
55
+ # Returns true if this page is a book citation reference
47
56
  #
48
57
  # @return [Boolean]
49
58
  #
50
- def is_reference?
59
+ def is_citation_reference?
51
60
  has_class?('os-reference-container')
52
61
  end
53
62
 
63
+ # Returns true if this page is a book section reference
64
+ #
65
+ # @return [Boolean]
66
+ #
67
+ def is_section_reference?
68
+ has_class?('os-references-container')
69
+ end
70
+
54
71
  end
55
72
  end
@@ -8,8 +8,7 @@ module Kitchen
8
8
  chapter: chapter,
9
9
  metadata_source: metadata_source,
10
10
  uuid_prefix: uuid_prefix,
11
- klass: klass
12
- )
11
+ klass: klass)
13
12
  end
14
13
  end
15
14
  end
@@ -12,24 +12,38 @@ module Kitchen::Directions::BakeChapterReferences
12
12
 
13
13
  chapter.references.search('h3').trash
14
14
 
15
- chapter.non_introduction_pages.each do |page|
16
- references = page.references
17
- next if references.none?
18
-
19
- references.search('h3').trash
20
- title = Kitchen::Directions::EocSectionTitleLinkSnippet.v1(page: page)
15
+ bake_page_references(page: chapter.introduction_page)
21
16
 
22
- references.each do |reference|
23
- reference.prepend(child: title)
24
- end
17
+ chapter.non_introduction_pages.each do |page|
18
+ bake_page_references(page: page)
25
19
  end
26
20
 
27
21
  @content = chapter.pages.references.cut.paste
28
-
29
- @in_composite_chapter = false
30
-
31
22
  chapter.append(child: render(file:
32
23
  '../../templates/eoc_section_title_template.xhtml.erb'))
33
24
  end
25
+
26
+ def bake_page_references(page:)
27
+ return if page.nil?
28
+
29
+ references = page.references
30
+ return if references.none?
31
+
32
+ title = if page.is_introduction?
33
+ <<~HTML
34
+ <a href="##{page.title.id}">
35
+ <h3 data-type="document-title" id="#{page.title.copied_id}">
36
+ <span class="os-text" data-type="" itemprop="">#{page.title_text}</span>
37
+ </h3>
38
+ </a>
39
+ HTML
40
+ else
41
+ Kitchen::Directions::EocSectionTitleLinkSnippet.v1(page: page)
42
+ end
43
+
44
+ references.each do |reference|
45
+ reference.prepend(child: title)
46
+ end
47
+ end
34
48
  end
35
49
  end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Kitchen
4
+ module Directions
5
+ # Bakes inline lists with the desired list separator
6
+ # Does not separate the last list item
7
+ #
8
+ module BakeInlineLists
9
+ LIST_SEPARATOR = '; '
10
+ SEPARATOR_CLASS = '-os-inline-list-separator'
11
+
12
+ def self.v1(book:)
13
+ inline_lists = book.search('span[data-display="inline"][data-type="list"]')
14
+ inline_lists.each do |list|
15
+ list.search('span[data-type="item"]')[0..-2].each do |item|
16
+ item.append(child: "<span class=\"#{SEPARATOR_CLASS}\">#{LIST_SEPARATOR}</span>")
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
@@ -11,6 +11,13 @@ module Kitchen
11
11
  metadata_source: metadata_source
12
12
  )
13
13
  end
14
+
15
+ def self.v2(book:, metadata_source:)
16
+ V2.new.bake(
17
+ book: book,
18
+ metadata_source: metadata_source
19
+ )
20
+ end
14
21
  end
15
22
  end
16
23
  end
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Kitchen::Directions::BakeReferences
4
+ class V2
5
+ renderable
6
+
7
+ def bake(book:, metadata_source:)
8
+ @metadata = metadata_source.children_to_keep.copy
9
+ @klass = 'references'
10
+ @uuid_prefix = '.'
11
+ @title = I18n.t(:references)
12
+
13
+ book.chapters.each do |chapter|
14
+
15
+ chapter.references.search('h3').trash
16
+
17
+ chapter_references = chapter.pages.references.cut
18
+ chapter_title_no_num = chapter.title.search('.os-text')
19
+
20
+ chapter.append(child:
21
+ <<~HTML
22
+ <div class="os-chapter-area">
23
+ <h2 data-type="document-title">#{chapter_title_no_num}</h2>
24
+ #{chapter_references.paste}
25
+ </div>
26
+ HTML
27
+ )
28
+ end
29
+ chapter_area_references = book.chapters.search('.os-chapter-area').cut
30
+ @content = chapter_area_references.paste
31
+ book.body.append(child: render(file:
32
+ '../../templates/eob_section_title_template.xhtml.erb'))
33
+ end
34
+ end
35
+ end
@@ -96,8 +96,10 @@ module Kitchen
96
96
  when CompositePageElement
97
97
  if page.is_index?
98
98
  'os-toc-index'
99
- elsif page.is_reference?
99
+ elsif page.is_citation_reference?
100
100
  'os-toc-reference'
101
+ elsif page.is_section_reference?
102
+ 'os-toc-references'
101
103
  elsif page.has_ancestor?(:composite_chapter) || page.has_ancestor?(:chapter)
102
104
  'os-toc-chapter-composite-page'
103
105
  else
@@ -3,5 +3,5 @@
3
3
  # A library for modifying the structure of OpenStax book XML.
4
4
  #
5
5
  module Kitchen
6
- VERSION = '6.0.0'
6
+ VERSION = '6.1.0'
7
7
  end
data/lib/locales/pl.yml CHANGED
@@ -22,4 +22,5 @@ pl:
22
22
  eoc_key_equations: Najważniejsze wzory
23
23
  eob_index_title: Skorowidz rzeczowy
24
24
  eob_index_symbols_group: Symbole
25
+ references: Bibliografia
25
26
 
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: 6.0.0
4
+ version: 6.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-06-15 00:00:00.000000000 Z
11
+ date: 2021-06-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -276,6 +276,7 @@ files:
276
276
  - lib/kitchen/directions/bake_index/main.rb
277
277
  - lib/kitchen/directions/bake_index/v1.rb
278
278
  - lib/kitchen/directions/bake_index/v1.xhtml.erb
279
+ - lib/kitchen/directions/bake_inline_lists.rb
279
280
  - lib/kitchen/directions/bake_link_placeholders.rb
280
281
  - lib/kitchen/directions/bake_math_in_paragraph.rb
281
282
  - lib/kitchen/directions/bake_non_introduction_pages.rb
@@ -297,6 +298,7 @@ files:
297
298
  - lib/kitchen/directions/bake_preface/v1.rb
298
299
  - lib/kitchen/directions/bake_references/main.rb
299
300
  - lib/kitchen/directions/bake_references/v1.rb
301
+ - lib/kitchen/directions/bake_references/v2.rb
300
302
  - lib/kitchen/directions/bake_stepwise.rb
301
303
  - lib/kitchen/directions/bake_suggested_reading.rb
302
304
  - lib/kitchen/directions/bake_theorem/main.rb