openstax_kitchen 11.0.0 → 12.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +52 -0
- data/Gemfile.lock +2 -2
- data/lib/kitchen/chapter_element.rb +7 -0
- data/lib/kitchen/composite_page_element.rb +8 -0
- data/lib/kitchen/directions/bake_accessibility_fixes.rb +11 -0
- data/lib/kitchen/directions/bake_autotitled_exercise/main.rb +11 -0
- data/lib/kitchen/directions/bake_autotitled_exercise/v1.rb +28 -0
- data/lib/kitchen/directions/bake_chapter_introductions/bake_chapter_objectives.rb +48 -0
- data/lib/kitchen/directions/bake_chapter_introductions/bake_chapter_outline.rb +14 -0
- data/lib/kitchen/directions/bake_chapter_introductions/main.rb +43 -0
- data/lib/kitchen/directions/bake_chapter_introductions/v1.rb +16 -0
- data/lib/kitchen/directions/bake_chapter_introductions/v2.rb +91 -0
- data/lib/kitchen/directions/bake_chapter_references/v1.rb +2 -0
- data/lib/kitchen/directions/bake_custom_sections/main.rb +14 -0
- data/lib/kitchen/directions/bake_custom_sections/v1.rb +42 -0
- data/lib/kitchen/directions/bake_eoc_section_content/remove_section_title.rb +2 -2
- data/lib/kitchen/directions/bake_equations.rb +2 -3
- data/lib/kitchen/directions/bake_example.rb +7 -8
- data/lib/kitchen/directions/bake_figure.rb +8 -5
- data/lib/kitchen/directions/bake_footnotes/v1.rb +5 -1
- data/lib/kitchen/directions/bake_free_response/v1.rb +3 -1
- data/lib/kitchen/directions/bake_iframes/main.rb +11 -0
- data/lib/kitchen/directions/bake_iframes/v1.rb +25 -0
- data/lib/kitchen/directions/bake_index/main.rb +2 -2
- data/lib/kitchen/directions/bake_index/v1.rb +39 -7
- data/lib/kitchen/directions/bake_index/v1.xhtml.erb +3 -3
- data/lib/kitchen/directions/bake_injected_exercise.rb +18 -0
- data/lib/kitchen/directions/bake_injected_exercise_question.rb +71 -0
- data/lib/kitchen/directions/{bake_page_abstracts.rb → bake_learning_objectives.rb} +10 -5
- data/lib/kitchen/directions/bake_link_placeholders.rb +15 -2
- data/lib/kitchen/directions/bake_lists_with_para.rb +3 -3
- data/lib/kitchen/directions/bake_notes/bake_autotitled_notes.rb +25 -5
- data/lib/kitchen/directions/bake_notes/bake_note_subtitle.rb +6 -2
- data/lib/kitchen/directions/bake_notes/bake_numbered_notes/main.rb +13 -3
- data/lib/kitchen/directions/bake_notes/bake_numbered_notes/v1.rb +29 -25
- data/lib/kitchen/directions/bake_notes/bake_numbered_notes/v2.rb +22 -17
- data/lib/kitchen/directions/bake_notes/bake_numbered_notes/v3.rb +32 -22
- data/lib/kitchen/directions/bake_numbered_exercise/main.rb +3 -2
- data/lib/kitchen/directions/bake_numbered_exercise/v1.rb +6 -24
- data/lib/kitchen/directions/bake_numbered_table/bake_table_body.rb +3 -3
- data/lib/kitchen/directions/bake_numbered_table/main.rb +4 -4
- data/lib/kitchen/directions/bake_numbered_table/v1.rb +5 -3
- data/lib/kitchen/directions/bake_numbered_table/v2.rb +5 -3
- data/lib/kitchen/directions/bake_references/main.rb +3 -2
- data/lib/kitchen/directions/bake_references/v1.rb +8 -3
- data/lib/kitchen/directions/bake_stepwise.rb +1 -1
- data/lib/kitchen/directions/bake_toc.rb +1 -1
- data/lib/kitchen/directions/move_solutions_to_answer_key/move_solutions_from_exercise_section.rb +1 -7
- data/lib/kitchen/directions/move_solutions_to_answer_key/move_solutions_from_numbered_note.rb +1 -7
- data/lib/kitchen/directions/move_solutions_to_answer_key/strategies/contemporary_math.rb +17 -0
- data/lib/kitchen/element_base.rb +46 -2
- data/lib/kitchen/element_enumerator_base.rb +35 -0
- data/lib/kitchen/example_element.rb +2 -1
- data/lib/kitchen/exercise_element.rb +42 -0
- data/lib/kitchen/figure_element.rb +1 -1
- data/lib/kitchen/injected_question_element.rb +77 -0
- data/lib/kitchen/injected_question_element_enumerator.rb +21 -0
- data/lib/kitchen/metadata_element.rb +6 -1
- data/lib/kitchen/note_element.rb +13 -5
- data/lib/kitchen/selectors/base.rb +6 -0
- data/lib/kitchen/selectors/standard_1.rb +3 -0
- data/lib/kitchen/solution_element_enumerator.rb +21 -0
- data/lib/kitchen/version.rb +1 -1
- data/lib/locales/en.yml +6 -4
- data/lib/locales/es.yml +5 -4
- data/lib/locales/pl.yml +52 -7
- metadata +21 -7
- data/lib/kitchen/directions/bake_chapter_introductions/chapter_introduction.xhtml.erb +0 -0
- data/lib/kitchen/directions/bake_chapter_introductions.rb +0 -65
- data/lib/kitchen/directions/bake_notes/bake_note_iframes.rb +0 -27
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 28254d4a9107528ff5dbebacc82e5cc3cbf20e71fcc9d8303c2f41fd90d2d4be
|
4
|
+
data.tar.gz: 2c71714f62fe45ea772614d5c72f6a95ce59deebc63e1259b182e25d70481400
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dfaf9123a29ef2bedddb524ed7758b1092c88c6cbc850aeee0d4530633783ab2cbec39b68f3b5fc391219f344f191c4714f779ef8efc57c7f35c47d075eb813e
|
7
|
+
data.tar.gz: c686d00ca4305b0f90f23c4ba2cfb3151a5c0384f7979e82fe16d5432a9e79b32705822aeae244601343d3620e053247b848edf78631c59f93a920e312d7951d
|
data/CHANGELOG.md
CHANGED
@@ -6,6 +6,57 @@ 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
|
+
|
16
|
+
## [12.0.0] - 2021-09-21
|
17
|
+
|
18
|
+
* Fixes `BakeStepwise` to skip nested lists (patch)
|
19
|
+
* Adds an optional selector to `RemoveSectionTitles` (minor)
|
20
|
+
* Patches `BakeFreeResponse` to only delete the first h3, not all h3s (patch)
|
21
|
+
* Lets `BakeExample` not count titles in lists as commentary titles (minor)
|
22
|
+
* Renames `BakePageAbstracts` to `BakeLearningObjectives` and adds optional parameter for titles in `v2` (major)
|
23
|
+
* Gets rid of extraneous titles in `BakeAutoTitledNotes` when subtitles are off (minor)
|
24
|
+
* Adds `BakeAutotitledExercise` direction and the option to `bake_unclassified_exercises` within `BakeAutotitledNotes`
|
25
|
+
* Adds optional numbering for `BakeReferences.v1` (minor)
|
26
|
+
* Patches`BakeNumberedNotes.v3` to suppress solutions outside examples when suppress_solutions is true (minor)
|
27
|
+
|
28
|
+
## [11.2.0] - 2021-09-10
|
29
|
+
|
30
|
+
* Adds `BakeAccessibilityFixes` direction for (minor)
|
31
|
+
* Remove deprecation warning from `BakeChapterIntroductions.v1` and adapted to be used like `.v2` (minor)
|
32
|
+
* Small class fix for `BakeFootnotes.v1` (patch)
|
33
|
+
* Fix `BakeNumberedNotes` to find related example better (minor)
|
34
|
+
* Small fix for parameter in `bake_note` definition (minor)
|
35
|
+
* Small fixes to return when no elements are found and not add an empty wrapper in `BakeChapterReferences` and
|
36
|
+
`BakeFreeResponse` (minor)
|
37
|
+
* Adding class `os-timeline-table-container` to numbered tables when required (minor)
|
38
|
+
* Fix `BakeExample` to catch the multiple solutions to one exercise (patch)
|
39
|
+
|
40
|
+
## [11.1.0] - 2021-08-30
|
41
|
+
|
42
|
+
* Update injected questions to synthesize ids during baking (minor)
|
43
|
+
* Fix `BakeListsWithPara` to copy all children from para not just text (minor)
|
44
|
+
* Implement labels with cases to `BakeAutotitledNotes` and `BakeNumberedNotes` (minor)
|
45
|
+
* Add ids to injected questions (minor)
|
46
|
+
* Create `BakeIframes` outer directory to allow bake iframes also from outside notes, remove `BakeNoteIFrames` module from notes directory (minor)
|
47
|
+
* Update the contemporary math `Strategy` to target injected solution sections (minor)
|
48
|
+
* Update `BakeNumberedNotes` to handle injected questions in notes (minor)
|
49
|
+
* Create `InjectedQuestionElement` and `InjectedQuestionElementEnumerator` classes (minor)
|
50
|
+
* Create `BakeInjectedExercise` and `BakeInjectedExerciseQuestion` directions (minor)
|
51
|
+
* Update `MoveSolutionsFromExerciseSection` and `MoveSolutionsFromNumberedNote` to move injected solutions (minor)
|
52
|
+
* Add `SolutionElementEnumerator` to support the above (minor)
|
53
|
+
* Remove multipart exercise baking from `BakeNumberedExercise`; this is now done in `InjectedExercise` directions (patch)
|
54
|
+
* Modify target labels to use grammatical cases (minor)
|
55
|
+
* Modify `BakeIndex` to bake multiple types of indexes (minor)
|
56
|
+
* Create `v2` in `BakeChapterIntroductions` that should replace `v1` (minor)
|
57
|
+
* Added a DEPRECATION warning in `v1` for `BakeChapterIntroductions` (minor)
|
58
|
+
* Added a bit more description to deprecation warning for `BakeChapterIntroductions.v1` (minor)
|
59
|
+
|
9
60
|
## [11.0.0] - 2021-08-6
|
10
61
|
|
11
62
|
* Add `ChangeSubsectionTitleTag` direction for modifying eoc sections (minor)
|
@@ -20,6 +71,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
20
71
|
* Adds `PageElement#count_in_chapter_without_intro_page` (minor)
|
21
72
|
* Adds `ChapterElement#has_introduction?` (minor)
|
22
73
|
* Adds `BakeFolio` to set spanish translation variables in the html tag for folio-pdf purposes (minor)
|
74
|
+
* Create `BakeCustomSections` direction for English Composition (minor)
|
23
75
|
* Create `BakeAnnotationClasses` v1 for English Composition (minor)
|
24
76
|
|
25
77
|
## [10.0.0] - 2021-07-30
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
openstax_kitchen (
|
4
|
+
openstax_kitchen (12.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)
|
14
|
+
activesupport (6.1.4.1)
|
15
15
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
16
16
|
i18n (>= 1.6, < 2)
|
17
17
|
minitest (>= 5.1)
|
@@ -41,6 +41,14 @@ module Kitchen
|
|
41
41
|
has_class?('os-index-container')
|
42
42
|
end
|
43
43
|
|
44
|
+
# Returns true if this page is a book index of type
|
45
|
+
#
|
46
|
+
# @return [Boolean]
|
47
|
+
#
|
48
|
+
def is_index_of_type?
|
49
|
+
(self[:class] || '').match?(/os-index-.+-container/)
|
50
|
+
end
|
51
|
+
|
44
52
|
# In books we can find two types of EOB References.
|
45
53
|
#
|
46
54
|
# One of them has form similar to footnotes. There are citation links in the text that provides
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Kitchen::Directions::BakeAutotitledExercise
|
4
|
+
class V1
|
5
|
+
def bake(exercise:, number:)
|
6
|
+
exercise.add_class('unnumbered') unless number
|
7
|
+
|
8
|
+
# bake problem
|
9
|
+
exercise.problem.wrap_children('div', class: 'os-problem-container')
|
10
|
+
exercise.problem.prepend(child:
|
11
|
+
<<~HTML
|
12
|
+
<h4 class="exercise-title" data-type="title">#{exercise.autogenerated_title}</h4>
|
13
|
+
HTML
|
14
|
+
)
|
15
|
+
return unless exercise.solution
|
16
|
+
|
17
|
+
# bake solution in place
|
18
|
+
exercise.solution.wrap_children('div', class: 'os-solution-container')
|
19
|
+
exercise.solution.prepend(child:
|
20
|
+
<<~HTML
|
21
|
+
<h4 class="solution-title" data-type="title">
|
22
|
+
<span class="os-text">#{I18n.t(:"exercises.solution")}</span>
|
23
|
+
</h4>
|
24
|
+
HTML
|
25
|
+
)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Kitchen::Directions::BakeChapterIntroductions
|
4
|
+
class BakeChapterObjectives
|
5
|
+
def bake(chapter:, strategy:)
|
6
|
+
case strategy
|
7
|
+
when :default
|
8
|
+
bake_as_note(chapter: chapter)
|
9
|
+
when :add_objectives
|
10
|
+
add_chapter_objectives(chapter: chapter)
|
11
|
+
when :none
|
12
|
+
''
|
13
|
+
else
|
14
|
+
raise 'No such strategy'
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def bake_as_note(chapter:)
|
19
|
+
chapter_objectives_note = chapter.notes('$.chapter-objectives').first
|
20
|
+
|
21
|
+
return unless chapter_objectives_note.present?
|
22
|
+
|
23
|
+
# trash existing title
|
24
|
+
chapter_objectives_note.titles.first&.trash
|
25
|
+
Kitchen::Directions::BakeAutotitledNotes.v1(
|
26
|
+
book: chapter,
|
27
|
+
classes: %w[chapter-objectives],
|
28
|
+
bake_subtitle: false
|
29
|
+
)
|
30
|
+
|
31
|
+
chapter_objectives_note.cut.paste
|
32
|
+
end
|
33
|
+
|
34
|
+
def add_chapter_objectives(chapter:)
|
35
|
+
chapter.non_introduction_pages.map do |page|
|
36
|
+
<<~HTML
|
37
|
+
<div class="os-chapter-objective">
|
38
|
+
<a class="os-chapter-objective" href="##{page.title[:id]}">
|
39
|
+
<span class="os-number">#{chapter.count_in(:book)}.#{page.count_in(:chapter)}</span>
|
40
|
+
<span class="os-divider"> </span>
|
41
|
+
<span data-type="" itemprop="" class="os-text">#{page.title.children[0].text}</span>
|
42
|
+
</a>
|
43
|
+
</div>
|
44
|
+
HTML
|
45
|
+
end.join('')
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Kitchen::Directions::BakeChapterIntroductions
|
4
|
+
class BakeChapterOutline
|
5
|
+
def bake(chapter_objectives_html:)
|
6
|
+
<<~HTML
|
7
|
+
<div class="os-chapter-outline">
|
8
|
+
<h3 class="os-title">#{I18n.t(:chapter_outline)}</h3>
|
9
|
+
#{chapter_objectives_html}
|
10
|
+
</div>
|
11
|
+
HTML
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Kitchen
|
4
|
+
module Directions
|
5
|
+
module BakeChapterIntroductions
|
6
|
+
def self.v1(book:)
|
7
|
+
V1.new.bake(
|
8
|
+
book: book
|
9
|
+
)
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.v2(
|
13
|
+
book:,
|
14
|
+
strategy_options: {
|
15
|
+
strategy: :default, bake_chapter_outline: false, introduction_order: :v1
|
16
|
+
}
|
17
|
+
)
|
18
|
+
V2.new.bake(
|
19
|
+
book: book,
|
20
|
+
strategy_options: strategy_options
|
21
|
+
)
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.bake_chapter_objectives(chapter:, strategy:)
|
25
|
+
BakeChapterObjectives.new.bake(
|
26
|
+
chapter: chapter,
|
27
|
+
strategy: strategy
|
28
|
+
)
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.bake_chapter_outline(chapter_objectives_html:)
|
32
|
+
BakeChapterOutline.new.bake(
|
33
|
+
chapter_objectives_html: chapter_objectives_html
|
34
|
+
)
|
35
|
+
end
|
36
|
+
|
37
|
+
def self.v1_update_selectors(something_with_selectors)
|
38
|
+
something_with_selectors.selectors.title_in_introduction_page =
|
39
|
+
".intro-text > [data-type='document-title']"
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Kitchen::Directions::BakeChapterIntroductions
|
4
|
+
class V1
|
5
|
+
def bake(book:)
|
6
|
+
Kitchen::Directions::BakeChapterIntroductions.v2(
|
7
|
+
book: book,
|
8
|
+
strategy_options: {
|
9
|
+
strategy: :add_objectives,
|
10
|
+
bake_chapter_outline: true,
|
11
|
+
introduction_order: :v1
|
12
|
+
}
|
13
|
+
)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,91 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Kitchen::Directions::BakeChapterIntroductions
|
4
|
+
class V2
|
5
|
+
def bake(book:, strategy_options:)
|
6
|
+
book.chapters.each do |chapter|
|
7
|
+
introduction_page = chapter.introduction_page
|
8
|
+
title = bake_title(introduction_page: introduction_page)
|
9
|
+
|
10
|
+
chapter_intro_html =
|
11
|
+
Kitchen::Directions::BakeChapterIntroductions.bake_chapter_objectives(
|
12
|
+
chapter: chapter,
|
13
|
+
strategy: strategy_options[:strategy]
|
14
|
+
)
|
15
|
+
|
16
|
+
if strategy_options[:bake_chapter_outline]
|
17
|
+
chapter_intro_html =
|
18
|
+
Kitchen::Directions::BakeChapterIntroductions.bake_chapter_outline(
|
19
|
+
chapter_objectives_html: chapter_intro_html
|
20
|
+
)
|
21
|
+
end
|
22
|
+
|
23
|
+
case strategy_options[:introduction_order]
|
24
|
+
when :v1
|
25
|
+
v1_introduction_order(
|
26
|
+
introduction_page: introduction_page,
|
27
|
+
chapter_intro_html: chapter_intro_html,
|
28
|
+
title: title
|
29
|
+
)
|
30
|
+
when :v2
|
31
|
+
v2_introduction_order(
|
32
|
+
introduction_page: introduction_page,
|
33
|
+
chapter_intro_html: chapter_intro_html,
|
34
|
+
title: title
|
35
|
+
)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
Kitchen::Directions::BakeChapterIntroductions.v1_update_selectors(book)
|
40
|
+
end
|
41
|
+
|
42
|
+
def v1_introduction_order(introduction_page:, chapter_intro_html:, title:)
|
43
|
+
intro_content = introduction_page.search(
|
44
|
+
"> :not([data-type='metadata']):not(.splash):not(.has-splash)"
|
45
|
+
).cut
|
46
|
+
|
47
|
+
introduction_page.append(child:
|
48
|
+
<<~HTML
|
49
|
+
<div class="intro-body">
|
50
|
+
#{chapter_intro_html}
|
51
|
+
<div class="intro-text">
|
52
|
+
#{title.paste}
|
53
|
+
#{intro_content.paste}
|
54
|
+
</div>
|
55
|
+
</div>
|
56
|
+
HTML
|
57
|
+
)
|
58
|
+
end
|
59
|
+
|
60
|
+
def v2_introduction_order(introduction_page:, chapter_intro_html:, title:)
|
61
|
+
if chapter_intro_html.empty?
|
62
|
+
chapter_intro_html = introduction_page.notes('$.chapter-objectives').first&.cut&.paste
|
63
|
+
end
|
64
|
+
extra_content = introduction_page.search(
|
65
|
+
'> :not([data-type="metadata"]):not(.splash):not(.has-splash)'
|
66
|
+
).cut
|
67
|
+
|
68
|
+
introduction_page.append(child:
|
69
|
+
<<~HTML
|
70
|
+
<div class="intro-body">
|
71
|
+
#{chapter_intro_html}
|
72
|
+
<div class="intro-text">
|
73
|
+
#{title.paste}
|
74
|
+
#{extra_content.paste}
|
75
|
+
</div>
|
76
|
+
</div>
|
77
|
+
HTML
|
78
|
+
)
|
79
|
+
end
|
80
|
+
|
81
|
+
def bake_title(introduction_page:)
|
82
|
+
introduction_page.search(
|
83
|
+
'div[data-type="description"], div[data-type="abstract"]'
|
84
|
+
).each(&:trash)
|
85
|
+
|
86
|
+
title = introduction_page.title.cut
|
87
|
+
title.name = 'h2'
|
88
|
+
Kitchen::Directions::MoveTitleTextIntoSpan.v1(title: title)
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Kitchen
|
4
|
+
module Directions
|
5
|
+
module BakeCustomSections
|
6
|
+
def self.v1(chapter:, custom_sections_properties:)
|
7
|
+
V1.new.bake(
|
8
|
+
chapter: chapter,
|
9
|
+
custom_sections_properties: custom_sections_properties
|
10
|
+
)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Kitchen::Directions::BakeCustomSections
|
4
|
+
class V1
|
5
|
+
def bake(chapter:, custom_sections_properties:)
|
6
|
+
custom_sections_properties.each do |_custom_section_name, property|
|
7
|
+
title_text = I18n.t(:"custom-sections.#{property[:class]}")
|
8
|
+
property_class = property[:class]
|
9
|
+
inject = property[:inject]
|
10
|
+
chapter.search(".#{property_class}").each do |custom_section|
|
11
|
+
|
12
|
+
case inject
|
13
|
+
when 'title'
|
14
|
+
custom_section_title = custom_section.first('h2')
|
15
|
+
custom_section_title_os_text = custom_section_title.first('.os-text')
|
16
|
+
custom_section_title_sibling = custom_section.first('h2 + div')
|
17
|
+
div_id = custom_section_title_sibling['id']
|
18
|
+
custom_section_title_sibling.trash
|
19
|
+
custom_section_title.append(sibling:
|
20
|
+
<<~HTML
|
21
|
+
<h3 class="os-subtitle" id="#{div_id}">#{custom_section_title_os_text.text}</h3>
|
22
|
+
HTML
|
23
|
+
)
|
24
|
+
custom_section_title_os_text.replace_children(with: title_text)
|
25
|
+
when 'subtitle'
|
26
|
+
custom_section_title = custom_section.titles.first
|
27
|
+
custom_section_title.name = 'h4'
|
28
|
+
custom_section_title.prepend(sibling:
|
29
|
+
<<~HTML
|
30
|
+
<h3 class="os-title">#{title_text}</h3>
|
31
|
+
HTML
|
32
|
+
)
|
33
|
+
when 'title_prefix'
|
34
|
+
custom_section_title = custom_section.titles.first
|
35
|
+
custom_section_title.replace_children(with: "#{title_text}: " +
|
36
|
+
custom_section_title.text)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -3,14 +3,13 @@
|
|
3
3
|
module Kitchen
|
4
4
|
module Directions
|
5
5
|
module BakeEquations
|
6
|
-
def self.v1(book:, number_decorator: :none)
|
6
|
+
def self.v1(book:, number_decorator: :none, cases: false)
|
7
7
|
book.chapters.search('div[data-type="equation"]:not(.unnumbered)').each do |eq|
|
8
8
|
chapter = eq.ancestor(:chapter)
|
9
9
|
number = "#{chapter.count_in(:book)}.#{eq.count_in(:chapter)}"
|
10
10
|
|
11
11
|
# Store label information
|
12
|
-
|
13
|
-
book.pantry(name: :link_text).store equation_label, label: eq.id
|
12
|
+
eq.target_label(label_text: 'equation', custom_content: number, cases: cases)
|
14
13
|
|
15
14
|
decorated_number =
|
16
15
|
case number_decorator
|
@@ -3,22 +3,21 @@
|
|
3
3
|
module Kitchen
|
4
4
|
module Directions
|
5
5
|
module BakeExample
|
6
|
-
def self.v1(example:, number:, title_tag:, numbered_solutions: false)
|
6
|
+
def self.v1(example:, number:, title_tag:, numbered_solutions: false, cases: false)
|
7
7
|
example.wrap_children(class: 'body')
|
8
8
|
|
9
9
|
example.prepend(child:
|
10
10
|
<<~HTML
|
11
11
|
<#{title_tag} class="os-title">
|
12
|
-
<span class="os-title-label">#{I18n.t(
|
12
|
+
<span class="os-title-label">#{I18n.t("example#{'.nominative' if cases}")} </span>
|
13
13
|
<span class="os-number">#{number}</span>
|
14
14
|
<span class="os-divider"> </span>
|
15
15
|
</#{title_tag}>
|
16
16
|
HTML
|
17
17
|
)
|
18
18
|
|
19
|
-
|
20
|
-
|
21
|
-
.store("#{I18n.t(:example_label)} #{number}", label: example.id)
|
19
|
+
# Store label information
|
20
|
+
example.target_label(label_text: 'example', custom_content: number, cases: cases)
|
22
21
|
|
23
22
|
example.titles_to_rename.each do |title|
|
24
23
|
title.name = 'h4'
|
@@ -31,9 +30,9 @@ module Kitchen
|
|
31
30
|
problem.wrap_children(class: 'os-problem-container')
|
32
31
|
end
|
33
32
|
|
34
|
-
|
33
|
+
exercise.solutions.each do |solution|
|
35
34
|
solution_number = if numbered_solutions
|
36
|
-
"<span class=\"os-number\">#{
|
35
|
+
"<span class=\"os-number\">#{solution.count_in(:example)}</span>"
|
37
36
|
else
|
38
37
|
''
|
39
38
|
end
|
@@ -54,7 +53,7 @@ module Kitchen
|
|
54
53
|
next unless commentary.present?
|
55
54
|
|
56
55
|
commentary_title = commentary.titles.first
|
57
|
-
next unless commentary_title.present?
|
56
|
+
next unless commentary_title.present? && commentary_title.parent['data-type'] != 'list'
|
58
57
|
|
59
58
|
commentary_title.name = 'h4'
|
60
59
|
commentary_title['data-type'] = 'commentary-title'
|
@@ -3,11 +3,12 @@
|
|
3
3
|
module Kitchen
|
4
4
|
module Directions
|
5
5
|
module BakeFigure
|
6
|
-
def self.v1(figure:, number:)
|
7
|
-
return if figure.has_class?('unnumbered') && !figure.has_class?('splash')
|
6
|
+
def self.v1(figure:, number:, cases: false)
|
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
|
-
|
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
|
@@ -19,14 +20,16 @@ module Kitchen
|
|
19
20
|
return
|
20
21
|
end
|
21
22
|
|
22
|
-
|
23
|
+
# Store label information
|
24
|
+
figure.target_label(label_text: 'figure', custom_content: number, cases: cases)
|
25
|
+
|
23
26
|
title = figure.title&.cut
|
24
27
|
|
25
28
|
caption = figure.caption&.cut
|
26
29
|
figure.append(sibling:
|
27
30
|
<<~HTML
|
28
31
|
<div class="os-caption-container">
|
29
|
-
<span class="os-title-label">#{I18n.t(
|
32
|
+
<span class="os-title-label">#{I18n.t("figure#{'.nominative' if cases}")} </span>
|
30
33
|
<span class="os-number">#{number}</span>
|
31
34
|
<span class="os-divider"> </span>
|
32
35
|
#{"<span class=\"os-title\" data-type=\"title\" id=\"#{title.id}\">#{title.children}</span>" if title}
|
@@ -28,7 +28,11 @@ module Kitchen::Directions::BakeFootnotes
|
|
28
28
|
anchor.replace_children(with: footnote_number)
|
29
29
|
aside_id = anchor[:href][1..-1]
|
30
30
|
aside_id_to_footnote_number[aside_id] = footnote_number
|
31
|
-
|
31
|
+
if anchor.parent.name == 'p'
|
32
|
+
anchor.parent.add_class('has-noteref')
|
33
|
+
elsif anchor.parent.name == 'em' && anchor.parent.parent.name == 'p'
|
34
|
+
anchor.parent.parent.add_class('has-noteref')
|
35
|
+
end
|
32
36
|
end
|
33
37
|
|
34
38
|
container.search('aside').each do |aside|
|
@@ -12,7 +12,7 @@ module Kitchen::Directions::BakeFreeResponse
|
|
12
12
|
free_response_questions = page.free_response
|
13
13
|
next if free_response_questions.none?
|
14
14
|
|
15
|
-
free_response_questions.search('h3')
|
15
|
+
free_response_questions.search('h3')&.first&.trash
|
16
16
|
title = Kitchen::Directions::EocSectionTitleLinkSnippet.v1(page: page)
|
17
17
|
free_response_questions.each do |free_response_question|
|
18
18
|
free_response_question.prepend(child: title)
|
@@ -20,6 +20,8 @@ module Kitchen::Directions::BakeFreeResponse
|
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
|
+
return if @free_response_clipboard.none?
|
24
|
+
|
23
25
|
append_to_element = append_to || chapter
|
24
26
|
@title_tag = append_to ? 'h3' : 'h2'
|
25
27
|
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Kitchen::Directions::BakeIframes
|
4
|
+
class V1
|
5
|
+
def bake(outer_element:)
|
6
|
+
iframes = outer_element.search('iframe')
|
7
|
+
return unless iframes.any?
|
8
|
+
|
9
|
+
iframes.each do |iframe|
|
10
|
+
iframe.wrap('<div class="os-has-iframe" data-type="alternatives">')
|
11
|
+
iframe.add_class('os-is-iframe')
|
12
|
+
link_ref = iframe[:src]
|
13
|
+
next unless link_ref
|
14
|
+
|
15
|
+
iframe = iframe.parent
|
16
|
+
iframe.add_class('os-has-link')
|
17
|
+
iframe.prepend(child:
|
18
|
+
<<~HTML
|
19
|
+
<a class="os-is-link" href="#{link_ref}" target="_window">#{I18n.t(:iframe_link_text)}</a>
|
20
|
+
HTML
|
21
|
+
)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|