openstax_kitchen 3.2.0 → 4.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -1
- data/CHANGELOG.md +42 -1
- data/Gemfile.lock +13 -14
- data/docker/ci +0 -1
- data/lib/kitchen/book_element.rb +16 -2
- data/lib/kitchen/chapter_element.rb +8 -11
- data/lib/kitchen/chapter_element_enumerator.rb +1 -1
- data/lib/kitchen/composite_chapter_element.rb +7 -11
- data/lib/kitchen/composite_page_element.rb +15 -10
- data/lib/kitchen/composite_page_element_enumerator.rb +1 -1
- data/lib/kitchen/config.rb +7 -0
- data/lib/kitchen/directions/bake_chapter_glossary/main.rb +18 -0
- data/lib/kitchen/directions/bake_chapter_glossary/v1.rb +30 -0
- data/lib/kitchen/directions/bake_chapter_introductions.rb +1 -1
- data/lib/kitchen/directions/bake_chapter_key_concepts/main.rb +7 -2
- data/lib/kitchen/directions/bake_chapter_key_concepts/v1.rb +12 -7
- data/lib/kitchen/directions/bake_chapter_key_equations.rb +26 -21
- data/lib/kitchen/directions/bake_chapter_summary.rb +48 -42
- data/lib/kitchen/directions/bake_equations.rb +1 -1
- data/lib/kitchen/directions/bake_example.rb +5 -1
- data/lib/kitchen/directions/bake_figure.rb +1 -1
- data/lib/kitchen/directions/{bake_problem_first_elements.rb → bake_first_elements.rb} +2 -2
- data/lib/kitchen/directions/bake_footnotes/v1.rb +2 -1
- data/lib/kitchen/directions/bake_free_response/free_response.xhtml.erb +10 -0
- data/lib/kitchen/directions/bake_free_response/main.rb +11 -0
- data/lib/kitchen/directions/bake_free_response/v1.rb +29 -0
- data/lib/kitchen/directions/bake_further_research.rb +59 -0
- data/lib/kitchen/directions/bake_index/v1.rb +35 -14
- data/lib/kitchen/directions/bake_link_placeholders.rb +1 -1
- data/lib/kitchen/directions/bake_notes/bake_note_subtitle.rb +4 -0
- data/lib/kitchen/directions/bake_notes/bake_numbered_notes.rb +9 -21
- data/lib/kitchen/directions/bake_numbered_exercise/main.rb +6 -2
- data/lib/kitchen/directions/bake_numbered_exercise/v1.rb +25 -12
- data/lib/kitchen/directions/bake_numbered_table/v1.rb +1 -1
- data/lib/kitchen/directions/bake_page_abstracts.rb +1 -1
- data/lib/kitchen/directions/bake_references/main.rb +16 -0
- data/lib/kitchen/directions/bake_references/v1.rb +48 -0
- data/lib/kitchen/directions/bake_suggested_reading.rb +5 -0
- data/lib/kitchen/directions/bake_toc.rb +4 -2
- data/lib/kitchen/directions/{bake_book_answer_key → book_answer_key_container}/eob_solutions_container.xhtml.erb +0 -0
- data/lib/kitchen/directions/{bake_book_answer_key → book_answer_key_container}/main.rb +1 -1
- data/lib/kitchen/directions/{bake_book_answer_key → book_answer_key_container}/v1.rb +1 -1
- data/lib/kitchen/directions/{bake_chapter_review → chapter_review_container}/chapter_review.xhtml.erb +0 -0
- data/lib/kitchen/directions/{bake_chapter_review → chapter_review_container}/main.rb +1 -1
- data/lib/kitchen/directions/{bake_chapter_review → chapter_review_container}/v1.rb +1 -1
- data/lib/kitchen/directions/eoc_section_title_link_snippet.rb +1 -1
- data/lib/kitchen/directions/move_exercises_to_eoc/main.rb +27 -0
- data/lib/kitchen/directions/{bake_chapter_review_exercises → move_exercises_to_eoc}/v1.rb +8 -10
- data/lib/kitchen/directions/{bake_chapter_review_exercises → move_exercises_to_eoc}/v2.rb +8 -9
- data/lib/kitchen/directions/{bake_chapter_answer_key → move_solutions_to_answer_key}/main.rb +1 -1
- data/lib/kitchen/directions/move_solutions_to_answer_key/strategies/american_government.rb +19 -0
- data/lib/kitchen/directions/{bake_chapter_answer_key → move_solutions_to_answer_key}/strategies/calculus.rb +1 -1
- data/lib/kitchen/directions/{bake_chapter_answer_key → move_solutions_to_answer_key}/strategies/uphysics.rb +5 -3
- data/lib/kitchen/directions/{bake_chapter_answer_key → move_solutions_to_answer_key}/v1.rb +3 -1
- data/lib/kitchen/document.rb +11 -0
- data/lib/kitchen/element.rb +9 -3
- data/lib/kitchen/element_base.rb +61 -10
- data/lib/kitchen/element_enumerator_base.rb +9 -1
- data/lib/kitchen/element_enumerator_factory.rb +9 -5
- data/lib/kitchen/element_factory.rb +3 -3
- data/lib/kitchen/example_element.rb +8 -11
- data/lib/kitchen/example_element_enumerator.rb +1 -1
- data/lib/kitchen/exercise_element.rb +5 -8
- data/lib/kitchen/exercise_element_enumerator.rb +1 -1
- data/lib/kitchen/figure_element.rb +8 -11
- data/lib/kitchen/figure_element_enumerator.rb +1 -1
- data/lib/kitchen/metadata_element.rb +8 -2
- data/lib/kitchen/metadata_element_enumerator.rb +1 -1
- data/lib/kitchen/note_element.rb +8 -11
- data/lib/kitchen/note_element_enumerator.rb +1 -1
- data/lib/kitchen/page_element.rb +20 -7
- data/lib/kitchen/page_element_enumerator.rb +1 -1
- data/lib/kitchen/reference_element.rb +27 -0
- data/lib/kitchen/references_element_enumerator.rb +20 -0
- data/lib/kitchen/search_query.rb +25 -3
- data/lib/kitchen/selector.rb +24 -0
- data/lib/kitchen/selectors/base.rb +39 -0
- data/lib/kitchen/selectors/standard_1.rb +13 -0
- data/lib/kitchen/table_element.rb +8 -11
- data/lib/kitchen/table_element_enumerator.rb +1 -1
- data/lib/kitchen/templates/eob_section_title_template.xhtml.erb +10 -0
- data/lib/kitchen/templates/eoc_section_title_template.xhtml.erb +10 -0
- data/lib/kitchen/term_element.rb +5 -8
- data/lib/kitchen/term_element_enumerator.rb +1 -1
- data/lib/kitchen/unit_element.rb +13 -7
- data/lib/kitchen/unit_element_enumerator.rb +1 -1
- data/lib/kitchen/version.rb +1 -1
- data/lib/locales/en.yml +3 -0
- data/lib/openstax_kitchen.rb +1 -0
- metadata +30 -22
- data/lib/kitchen/directions/bake_chapter_glossary.rb +0 -39
- data/lib/kitchen/directions/bake_chapter_key_concepts/key_concepts.xhtml.erb +0 -16
- data/lib/kitchen/directions/bake_chapter_review_exercises/main.rb +0 -15
- data/lib/kitchen/directions/bake_chapter_review_exercises/review_exercises.xhtml.erb +0 -10
- data/lib/kitchen/directions/bake_exercises/main.rb +0 -12
- data/lib/kitchen/directions/bake_exercises/v1.rb +0 -169
- data/lib/kitchen/directions/bake_notes/bake_notes.rb +0 -48
@@ -2,33 +2,38 @@
|
|
2
2
|
|
3
3
|
module Kitchen
|
4
4
|
module Directions
|
5
|
-
# Bake
|
5
|
+
# Bake directons for eoc key equations
|
6
6
|
#
|
7
7
|
module BakeChapterKeyEquations
|
8
|
-
def self.v1(chapter:, metadata_source:, append_to: nil)
|
9
|
-
|
8
|
+
def self.v1(chapter:, metadata_source:, append_to: nil, uuid_prefix: '.')
|
9
|
+
V1.new.bake(
|
10
|
+
chapter: chapter,
|
11
|
+
metadata_source: metadata_source,
|
12
|
+
append_to: append_to,
|
13
|
+
uuid_prefix: uuid_prefix
|
14
|
+
)
|
15
|
+
end
|
10
16
|
|
11
|
-
|
12
|
-
|
17
|
+
class V1
|
18
|
+
renderable
|
19
|
+
def bake(chapter:, metadata_source:, append_to:, uuid_prefix:)
|
20
|
+
@metadata = metadata_source.children_to_keep.copy
|
21
|
+
@klass = 'key-equations'
|
22
|
+
@title = I18n.t(:eoc_key_equations)
|
23
|
+
@uuid_prefix = uuid_prefix
|
13
24
|
|
14
|
-
|
25
|
+
chapter.key_equations.search('h3').trash
|
15
26
|
|
16
|
-
|
27
|
+
return if chapter.key_equations.none?
|
17
28
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
#{metadata_elements.paste}
|
27
|
-
</div>
|
28
|
-
#{key_equations.paste}
|
29
|
-
</div>
|
30
|
-
HTML
|
31
|
-
)
|
29
|
+
@content = chapter.key_equations.cut.paste
|
30
|
+
|
31
|
+
append_to_element = append_to || chapter
|
32
|
+
@in_composite_chapter = append_to_element.is?(:composite_chapter)
|
33
|
+
|
34
|
+
append_to_element.append(child: render(file:
|
35
|
+
'../templates/eoc_section_title_template.xhtml.erb'))
|
36
|
+
end
|
32
37
|
end
|
33
38
|
end
|
34
39
|
end
|
@@ -5,50 +5,56 @@ module Kitchen
|
|
5
5
|
# Bake directions for eoc summary
|
6
6
|
#
|
7
7
|
module BakeChapterSummary
|
8
|
-
def self.v1(chapter:, metadata_source:)
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
8
|
+
def self.v1(chapter:, metadata_source:, klass: 'summary', uuid_prefix: '.')
|
9
|
+
V1.new.bake(
|
10
|
+
chapter: chapter,
|
11
|
+
metadata_source: metadata_source,
|
12
|
+
uuid_prefix: uuid_prefix,
|
13
|
+
klass: klass
|
14
|
+
)
|
15
|
+
end
|
16
|
+
|
17
|
+
class V1
|
18
|
+
renderable
|
19
|
+
def bake(chapter:, metadata_source:, uuid_prefix: '.', klass: 'summary')
|
20
|
+
@metadata = metadata_source.children_to_keep.copy
|
21
|
+
@klass = klass
|
22
|
+
@title = I18n.t(:eoc_summary_title)
|
23
|
+
@uuid_prefix = uuid_prefix
|
24
|
+
|
25
|
+
summaries = Clipboard.new
|
26
|
+
|
27
|
+
# TODO: include specific page types somehow without writing it out
|
28
|
+
chapter.non_introduction_pages.each do |page|
|
29
|
+
summary = page.summary
|
30
|
+
summary.first("[data-type='title']")&.trash # get rid of old title if exists
|
31
|
+
summary_title = page.title.copy
|
32
|
+
summary_title.name = 'h3'
|
33
|
+
summary_title.replace_children(with: <<~HTML
|
34
|
+
<span class="os-number">#{chapter.count_in(:book)}.#{page.count_in(:chapter)}</span>
|
35
|
+
<span class="os-divider"> </span>
|
36
|
+
<span class="os-text" data-type="" itemprop="">#{summary_title.children}</span>
|
31
37
|
HTML
|
32
|
-
|
33
|
-
summary.cut(to: summaries)
|
34
|
-
end
|
38
|
+
)
|
35
39
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
40
|
+
summary.prepend(child:
|
41
|
+
<<~HTML
|
42
|
+
<a href="##{page.title.id}">
|
43
|
+
#{summary_title.paste}
|
44
|
+
</a>
|
45
|
+
HTML
|
46
|
+
)
|
47
|
+
summary.cut(to: summaries)
|
48
|
+
end
|
49
|
+
|
50
|
+
return if summaries.none?
|
51
|
+
|
52
|
+
@content = summaries.paste
|
53
|
+
@in_composite_chapter = false
|
54
|
+
|
55
|
+
chapter.append(child: render(file:
|
56
|
+
'../templates/eoc_section_title_template.xhtml.erb'))
|
57
|
+
end
|
52
58
|
end
|
53
59
|
end
|
54
60
|
end
|
@@ -10,7 +10,7 @@ module Kitchen
|
|
10
10
|
|
11
11
|
# Store label information
|
12
12
|
equation_label = "#{I18n.t(:equation)} #{number}"
|
13
|
-
book.
|
13
|
+
book.pantry(name: :link_text).store equation_label, label: eq.id
|
14
14
|
|
15
15
|
decorated_number =
|
16
16
|
case number_decorator
|
@@ -20,7 +20,11 @@ module Kitchen
|
|
20
20
|
.pantry(name: :link_text)
|
21
21
|
.store("#{I18n.t(:example_label)} #{number}", label: example.id)
|
22
22
|
|
23
|
-
example.titles.each
|
23
|
+
example.titles.each do |title|
|
24
|
+
next if title.parent.has_class?('os-caption-container')
|
25
|
+
|
26
|
+
title.name = 'h4'
|
27
|
+
end
|
24
28
|
|
25
29
|
example.exercises.each do |exercise|
|
26
30
|
if (problem = exercise.problem)
|
@@ -6,7 +6,7 @@ module Kitchen
|
|
6
6
|
def self.v1(figure:, number:)
|
7
7
|
figure.wrap(%(<div class="os-figure#{' has-splash' if figure.has_class?('splash')}">))
|
8
8
|
|
9
|
-
figure.
|
9
|
+
figure.pantry(name: :link_text).store "#{I18n.t(:figure)} #{number}", label: figure.id
|
10
10
|
title = figure.title&.cut
|
11
11
|
|
12
12
|
caption = figure.caption&.cut
|
@@ -2,10 +2,10 @@
|
|
2
2
|
|
3
3
|
module Kitchen
|
4
4
|
module Directions
|
5
|
-
module
|
5
|
+
module BakeFirstElements
|
6
6
|
def self.v1(within:, selectors:)
|
7
7
|
selectors.each do |selector|
|
8
|
-
within.search("
|
8
|
+
within.search("#{selector}:first-child").each do |problem|
|
9
9
|
problem.add_class('first-element')
|
10
10
|
problem.parent.add_class('has-first-element')
|
11
11
|
end
|
@@ -8,7 +8,8 @@ module Kitchen::Directions::BakeFootnotes
|
|
8
8
|
# appendices, etc) or within chapters. Tackle each case separately
|
9
9
|
|
10
10
|
book.body.element_children.only(Kitchen::PageElement,
|
11
|
-
Kitchen::CompositePageElement
|
11
|
+
Kitchen::CompositePageElement,
|
12
|
+
Kitchen::CompositeChapterElement).each do |page|
|
12
13
|
bake_footnotes_within(page)
|
13
14
|
end
|
14
15
|
|
@@ -0,0 +1,10 @@
|
|
1
|
+
<div class="os-eoc os-free-response-container" data-type="composite-page" data-uuid-key=".free-response">
|
2
|
+
<<%= @title_tag %> data-type="document-title">
|
3
|
+
<span class="os-text"><%= I18n.t(:eoc_free_response) %></span>
|
4
|
+
</<%= @title_tag %>>
|
5
|
+
<div data-type="metadata" style="display: none;">
|
6
|
+
<h1 data-type="document-title" itemprop="name"><%= I18n.t(:eoc_free_response) %></h1>
|
7
|
+
<%= @metadata_elements.paste %>
|
8
|
+
</div>
|
9
|
+
<%= @free_response_clipboard.paste %>
|
10
|
+
</div>
|
@@ -0,0 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Kitchen
|
4
|
+
module Directions
|
5
|
+
module BakeFreeResponse
|
6
|
+
def self.v1(chapter:, metadata_source:, append_to: nil)
|
7
|
+
V1.new.bake(chapter: chapter, metadata_source: metadata_source, append_to: append_to)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Kitchen::Directions::BakeFreeResponse
|
4
|
+
class V1
|
5
|
+
renderable
|
6
|
+
|
7
|
+
def bake(chapter:, metadata_source:, append_to:)
|
8
|
+
@metadata_elements = metadata_source.children_to_keep.copy
|
9
|
+
|
10
|
+
@free_response_clipboard = Kitchen::Clipboard.new
|
11
|
+
chapter.non_introduction_pages.each do |page|
|
12
|
+
free_response_questions = page.free_response
|
13
|
+
next if free_response_questions.none?
|
14
|
+
|
15
|
+
free_response_questions.search('h3').trash
|
16
|
+
title = Kitchen::Directions::EocSectionTitleLinkSnippet.v1(page: page)
|
17
|
+
free_response_questions.each do |free_response_question|
|
18
|
+
free_response_question.prepend(child: title)
|
19
|
+
free_response_question.cut(to: @free_response_clipboard)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
append_to_element = append_to || chapter
|
24
|
+
@title_tag = append_to ? 'h3' : 'h2'
|
25
|
+
|
26
|
+
append_to_element.append(child: render(file: 'free_response.xhtml.erb'))
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Kitchen
|
4
|
+
module Directions
|
5
|
+
# Bake directions for further research
|
6
|
+
#
|
7
|
+
module BakeFurtherResearch
|
8
|
+
def self.v1(chapter:, metadata_source:, uuid_prefix: '.')
|
9
|
+
V1.new.bake(
|
10
|
+
chapter: chapter,
|
11
|
+
metadata_source: metadata_source,
|
12
|
+
uuid_prefix: uuid_prefix)
|
13
|
+
end
|
14
|
+
|
15
|
+
class V1
|
16
|
+
renderable
|
17
|
+
def bake(chapter:, metadata_source:, uuid_prefix: '.')
|
18
|
+
@metadata = metadata_source.children_to_keep.copy
|
19
|
+
@klass = 'further-research'
|
20
|
+
@title = I18n.t(:eoc_further_research_title)
|
21
|
+
@uuid_prefix = uuid_prefix
|
22
|
+
|
23
|
+
further_researches = Clipboard.new
|
24
|
+
|
25
|
+
chapter.non_introduction_pages.each do |page|
|
26
|
+
further_research = page.first('.further-research')
|
27
|
+
further_research.first("[data-type='title']")&.trash # get rid of old title if exists
|
28
|
+
further_research_title = page.title.copy
|
29
|
+
further_research_title.name = 'h3'
|
30
|
+
further_research_title.replace_children(with: <<~HTML
|
31
|
+
<span class="os-number">#{chapter.count_in(:book)}.#{page.count_in(:chapter)}</span>
|
32
|
+
<span class="os-divider"> </span>
|
33
|
+
<span class="os-text" data-type="" itemprop="">#{further_research_title.children}</span>
|
34
|
+
HTML
|
35
|
+
)
|
36
|
+
|
37
|
+
further_research.prepend(child:
|
38
|
+
<<~HTML
|
39
|
+
<a href="##{page.title.id}">
|
40
|
+
#{further_research_title.paste}
|
41
|
+
</a>
|
42
|
+
HTML
|
43
|
+
)
|
44
|
+
further_research.cut(to: further_researches)
|
45
|
+
end
|
46
|
+
|
47
|
+
return if further_researches.none?
|
48
|
+
|
49
|
+
@content = further_researches.paste
|
50
|
+
|
51
|
+
@in_composite_chapter = false
|
52
|
+
|
53
|
+
chapter.append(child: render(file:
|
54
|
+
'../templates/eoc_section_title_template.xhtml.erb'))
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -44,6 +44,10 @@ module Kitchen::Directions::BakeIndex
|
|
44
44
|
@term_text = @term_text.uncapitalize
|
45
45
|
end
|
46
46
|
|
47
|
+
def capitalize_term_text!
|
48
|
+
@term_text = @term_text.capitalize
|
49
|
+
end
|
50
|
+
|
47
51
|
def <=>(other)
|
48
52
|
sortable <=> other.sortable
|
49
53
|
end
|
@@ -84,6 +88,11 @@ module Kitchen::Directions::BakeIndex
|
|
84
88
|
different_caps_item = @items_by_term_text[term.text.uncapitalize]
|
85
89
|
different_caps_item&.uncapitalize_term_text!
|
86
90
|
|
91
|
+
unless different_caps_item
|
92
|
+
different_caps_item = @items_by_term_text[term.text.capitalize]
|
93
|
+
different_caps_item&.capitalize_term_text!
|
94
|
+
end
|
95
|
+
|
87
96
|
(different_caps_item || IndexItem.new(term_text: term.text)).tap do |item|
|
88
97
|
@items.add(item)
|
89
98
|
end
|
@@ -119,27 +128,39 @@ module Kitchen::Directions::BakeIndex
|
|
119
128
|
@index = Index.new
|
120
129
|
|
121
130
|
book.pages.terms.each do |term_element|
|
122
|
-
# Markup the term
|
123
131
|
page = term_element.ancestor(:page)
|
124
132
|
term_element.id = "auto_#{page.id}_term#{term_element.count_in(:book)}"
|
133
|
+
page_title = page.title.text
|
134
|
+
add_term_to_index(term_element, page_title)
|
135
|
+
end
|
125
136
|
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
text: term_element.text,
|
134
|
-
id: term_element.id,
|
135
|
-
group_by: group_by,
|
136
|
-
page_title: page.title.text.gsub(/\n/, '')
|
137
|
-
)
|
138
|
-
)
|
137
|
+
book.chapters.composite_pages.terms.each do |term_element|
|
138
|
+
page = term_element.ancestor(:composite_page)
|
139
|
+
chapter = term_element.ancestor(:chapter)
|
140
|
+
term_element.id = "auto_composite_page_term#{term_element.count_in(:book)}"
|
141
|
+
chapter_number = chapter.count_in(:book)
|
142
|
+
page_title = "#{chapter_number} #{page.title.text.strip}".strip
|
143
|
+
add_term_to_index(term_element, page_title)
|
139
144
|
end
|
140
145
|
|
141
146
|
book.first('body').append(child: render(file: 'v1.xhtml.erb'))
|
142
147
|
end
|
143
148
|
|
149
|
+
def add_term_to_index(term_element, page_title)
|
150
|
+
group_by = term_element.text.strip[0]
|
151
|
+
group_by = I18n.t(:eob_index_symbols_group) unless group_by.match?(/\w/)
|
152
|
+
term_element['group-by'] = group_by
|
153
|
+
|
154
|
+
# Add it to our index object
|
155
|
+
@index.add_term(
|
156
|
+
Term.new(
|
157
|
+
text: term_element.text,
|
158
|
+
id: term_element.id,
|
159
|
+
group_by: group_by,
|
160
|
+
page_title: page_title.gsub(/\n/, '')
|
161
|
+
)
|
162
|
+
)
|
163
|
+
end
|
164
|
+
|
144
165
|
end
|
145
166
|
end
|
@@ -10,7 +10,7 @@ module Kitchen
|
|
10
10
|
next unless anchor.text == '[link]'
|
11
11
|
|
12
12
|
id = anchor[:href][1..-1]
|
13
|
-
replacement = book.
|
13
|
+
replacement = book.pantry(name: :link_text).get(id)
|
14
14
|
if replacement.present?
|
15
15
|
anchor.replace_children(with: replacement)
|
16
16
|
else
|
@@ -8,6 +8,10 @@ module Kitchen
|
|
8
8
|
|
9
9
|
return unless title
|
10
10
|
|
11
|
+
# Store label information
|
12
|
+
note_label = title.children
|
13
|
+
note.pantry(name: :link_text).store note_label, label: note.id
|
14
|
+
|
11
15
|
title.name = 'h4'
|
12
16
|
title.add_class('os-subtitle')
|
13
17
|
title.wrap_children('span', class: 'os-subtitle-label')
|
@@ -7,7 +7,9 @@ module Kitchen
|
|
7
7
|
classes.each do |klass|
|
8
8
|
book.chapters.notes("$.#{klass}").each do |note|
|
9
9
|
bake_note(note: note)
|
10
|
-
|
10
|
+
note.exercises.each do |exercise|
|
11
|
+
bake_note_exercise(note: note, exercise: exercise)
|
12
|
+
end
|
11
13
|
end
|
12
14
|
end
|
13
15
|
end
|
@@ -19,11 +21,11 @@ module Kitchen
|
|
19
21
|
note_count = note.count_in(:chapter)
|
20
22
|
note.prepend(child:
|
21
23
|
<<~HTML
|
22
|
-
<
|
24
|
+
<h3 class="os-title">
|
23
25
|
<span class="os-title-label">#{note.autogenerated_title}</span>
|
24
26
|
<span class="os-number">#{chapter_count}.#{note_count}</span>
|
25
27
|
<span class="os-divider"> </span>
|
26
|
-
</
|
28
|
+
</h3>
|
27
29
|
HTML
|
28
30
|
)
|
29
31
|
|
@@ -32,31 +34,17 @@ module Kitchen
|
|
32
34
|
BakeNoteSubtitle.v1(note: note)
|
33
35
|
end
|
34
36
|
|
35
|
-
def self.bake_note_exercise(note:)
|
36
|
-
exercise = note.exercises.first
|
37
|
-
return unless exercise
|
38
|
-
|
37
|
+
def self.bake_note_exercise(note:, exercise:)
|
39
38
|
exercise.add_class('unnumbered')
|
40
39
|
# bake problem
|
41
40
|
exercise.problem.wrap_children('div', class: 'os-problem-container')
|
42
41
|
exercise.problem.first('strong')&.trash
|
43
42
|
exercise.search('[data-type="commentary"]').each(&:trash)
|
44
|
-
|
45
|
-
return unless solution
|
43
|
+
return unless exercise.solution
|
46
44
|
|
47
45
|
# bake solution in place
|
48
|
-
|
49
|
-
|
50
|
-
solution_number = note.first('.os-number').text
|
51
|
-
solution.replace_children(with:
|
52
|
-
<<~HTML
|
53
|
-
<a class="os-number" href="##{exercise[:id]}">#{solution_number}</a>
|
54
|
-
<span class="os-divider"> </span>
|
55
|
-
<div class="os-solution-container">
|
56
|
-
#{solution.children}
|
57
|
-
</div>
|
58
|
-
HTML
|
59
|
-
)
|
46
|
+
BakeNumberedExercise.bake_solution_v1(
|
47
|
+
exercise: exercise, number: note.first('.os-number').text, divider: ' ')
|
60
48
|
end
|
61
49
|
end
|
62
50
|
end
|