5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/kitchen/directions/bake_chapter_section_exercises/v1.rb', line 5
def bake(chapter:, options:)
chapter.non_introduction_pages.each do |page|
page.search('section.section-exercises').each do |section|
section.first('h3[data-type="title"]')&.trash if options[:trash_title]
section.wrap(
%(<div class="os-eos os-section-exercises-container"
data-uuid-key=".section-exercises">)
)
next unless options[:create_title]
section_title = I18n.t(
:section_exercises,
number: "#{chapter.count_in(:book)}.#{page.count_in(:chapter)}")
section.prepend(sibling:
<<~HTML
<h3 data-type="document-title">
<span class="os-text">#{section_title}</span>
</h3>
HTML
)
end
end
end
|