openstax_kitchen 12.0.0 → 12.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: ddc1370c1b05b52bdf0df2f0a7cd4624b1725f39aae33f57f9715e091a358f8d
4
- data.tar.gz: fcd328b3dd9c091f2461e3acd22db036c02c4005bb5c8f31071096ed96461179
3
+ metadata.gz: 28254d4a9107528ff5dbebacc82e5cc3cbf20e71fcc9d8303c2f41fd90d2d4be
4
+ data.tar.gz: 2c71714f62fe45ea772614d5c72f6a95ce59deebc63e1259b182e25d70481400
5
5
  SHA512:
6
- metadata.gz: fd04ee2890144c697d9ab1ff10f97b9593f594eca116856bc6f26edb51f28e6330a0daca42c23e29d7bc08f2d336e764c957dcf93d6f638a22be1572a3ab939c
7
- data.tar.gz: bb270311e092585ef966c4f2ba76d8847d7fbaedaae9c102274363ac5c21bbf411a6af5ebd7689c6b8ffd02d81ea46b586cd2273eab26320f21c559d28019bcb
6
+ metadata.gz: dfaf9123a29ef2bedddb524ed7758b1092c88c6cbc850aeee0d4530633783ab2cbec39b68f3b5fc391219f344f191c4714f779ef8efc57c7f35c47d075eb813e
7
+ data.tar.gz: c686d00ca4305b0f90f23c4ba2cfb3151a5c0384f7979e82fe16d5432a9e79b32705822aeae244601343d3620e053247b848edf78631c59f93a920e312d7951d
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
+ ## [12.1.0] - 2021-09-24
10
+
11
+ * Fix `BakeExample#titles_to_rename` to exclude exercise titles (patch)
12
+ * Modify `BakeFigure` to bake unnumbered figures with caption (minor)
13
+ * Fix `NoteElement#title` to be more specific about finding the title (patch)
14
+ * Adds `data-type="slug"` to `metadata_lement` `children_to_keep` method, updates spec helper `metadata_element` and related spec files(minor)
15
+
9
16
  ## [12.0.0] - 2021-09-21
10
17
 
11
18
  * Fixes `BakeStepwise` to skip nested lists (patch)
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- openstax_kitchen (12.0.0)
4
+ openstax_kitchen (12.1.0)
5
5
  activesupport
6
6
  i18n
7
7
  nokogiri
@@ -4,10 +4,11 @@ module Kitchen
4
4
  module Directions
5
5
  module BakeFigure
6
6
  def self.v1(figure:, number:, cases: false)
7
- return if figure.has_class?('unnumbered') && !figure.has_class?('splash')
7
+ return if figure.has_class?('unnumbered') && !figure.has_class?('splash') && !figure.caption
8
8
 
9
9
  figure.wrap(%(<div class="os-figure#{' has-splash' if figure.has_class?('splash')}">))
10
- if figure.has_class?('unnumbered') && figure.has_class?('splash')
10
+
11
+ if figure.has_class?('unnumbered') && (figure.caption || figure.has_class?('splash'))
11
12
  caption = figure.caption&.cut
12
13
  figure.append(sibling:
13
14
  <<~HTML
@@ -211,6 +211,14 @@ module Kitchen
211
211
  self[:id] = value
212
212
  end
213
213
 
214
+ # Returns the element's data-type
215
+ #
216
+ # @return [String]
217
+ #
218
+ def data_type
219
+ self[:'data-type']
220
+ end
221
+
214
222
  # A way to set values and chain them
215
223
  #
216
224
  # @param property [String, Symbol] the name of the property to set
@@ -33,7 +33,8 @@ module Kitchen
33
33
  title.parent.has_class?('os-caption-container') || \
34
34
  title.parent.has_class?('os-caption') || \
35
35
  title.parent.name == 'caption' || \
36
- title.parent[:'data-type'] == 'note'
36
+ title.parent.data_type == 'note' || \
37
+ title.parent.data_type == 'exercise'
37
38
  end
38
39
  )
39
40
  end
@@ -53,7 +53,7 @@ module Kitchen
53
53
  # @return [Boolean]
54
54
  #
55
55
  def figure_to_bake?
56
- return false if subfigure? || (has_class?('unnumbered') && !has_class?('splash'))
56
+ return false if subfigure? || (has_class?('unnumbered') && !has_class?('splash') && !caption)
57
57
 
58
58
  true
59
59
  end
@@ -27,7 +27,12 @@ module Kitchen
27
27
  # @return [ElementEnumerator]
28
28
  #
29
29
  def children_to_keep
30
- search(%w(span[data-type='revised'] div.authors div.publishers div.print-style div.permissions
30
+ search(%w(span[data-type='revised']
31
+ span[data-type='slug']
32
+ div.authors
33
+ div.publishers
34
+ div.print-style
35
+ div.permissions
31
36
  div[data-type='subject']))
32
37
  end
33
38
  end
@@ -29,16 +29,24 @@ module Kitchen
29
29
  #
30
30
  def title
31
31
  block_error_if(block_given?)
32
- note_body = first('div.os-note-body')
33
- first_child = note_body ? note_body.element_children[0] : element_children[0]
32
+ # An element with data-type="title" is ambiguous; it is only the note's title if:
33
+ # 1. it is the note body's first child
34
+ # 2. it is the first child's first child and the first child is a paragraph
35
+ first_child = first_note_body_child
36
+ first_grandchild = first_child&.element_children&.[](0) if first_child.name == 'p'
34
37
 
35
- if first_child[:'data-type'] == 'title'
38
+ if first_child.data_type == 'title'
36
39
  first_child
37
- elsif first_child&.element_children&.[](0)&.[](:'data-type') == 'title'
38
- first_child.element_children[0]
40
+ elsif first_grandchild&.data_type == 'title'
41
+ first_grandchild
39
42
  end
40
43
  end
41
44
 
45
+ def first_note_body_child
46
+ note_body = first('div.os-note-body')
47
+ note_body ? note_body.element_children[0] : element_children[0]
48
+ end
49
+
42
50
  # Returns true if the note's title is autogenerated
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 = '12.0.0'
6
+ VERSION = '12.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: 12.0.0
4
+ version: 12.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-09-21 00:00:00.000000000 Z
11
+ date: 2021-09-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -461,7 +461,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
461
461
  - !ruby/object:Gem::Version
462
462
  version: '0'
463
463
  requirements: []
464
- rubygems_version: 3.0.3
464
+ rubygems_version: 3.0.3.1
465
465
  signing_key:
466
466
  specification_version: 4
467
467
  summary: OpenStax content baking library