Sha256: 18857837f6e3ad3eb1615a182ebae7d3ca9f78afbc6d18508d3cff69e9932a7a
Contents?: true
Size: 1.04 KB
Versions: 12
Compression:
Stored size: 1.04 KB
Contents
# frozen_string_literal: true module Kitchen module Directions module BakeEquations def self.v1(book:, number_decorator: :none) 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)}" # Store label information equation_label = "#{I18n.t(:equation)} #{number}" book.pantry(name: :link_text).store equation_label, label: eq.id decorated_number = case number_decorator when :none number when :parentheses "(#{number})" else raise "Unsupported number_decorator '#{number_decorator}'" end # Bake the equation eq.append(child: <<~HTML <div class="os-equation-number"> <span class="os-number">#{decorated_number}</span> </div> HTML ) end end end end end
Version data entries
12 entries across 12 versions & 1 rubygems