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