6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
# File 'lib/kitchen/directions/bake_equations.rb', line 6
def self.v1(book:, number_decorator: :none, cases: false)
book.chapters.search('div[data-type="equation"]:not(.unnumbered)').each do |eq|
chapter = eq.ancestor(:chapter)
number = "#{chapter.count_in(:book)}.#{eq.count_in(:chapter)}"
eq.target_label(label_text: 'equation', custom_content: number, cases: cases)
decorated_number =
case number_decorator
when :none
number
when :parentheses
"(#{number})"
else
raise "Unsupported number_decorator '#{number_decorator}'"
end
eq.append(child:
<<~HTML
<div class="os-equation-number">
<span class="os-number">#{decorated_number}</span>
</div>
HTML
)
end
end
|