Sha256: 16d009b11ebc94dfe30f0625e3296a385c690379caa68ed2f0dd0b7b18f99e45

Contents?: true

Size: 769 Bytes

Versions: 1

Compression:

Stored size: 769 Bytes

Contents

# frozen_string_literal: true

module Kitchen
  module Directions
    module BakeEquations
      def self.v1(book:)
        book.chapters.search('[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.document.pantry(name: :link_text).store equation_label, label: eq.id

          # Bake the equation
          eq.append(child:
            <<~HTML
              <div class="os-equation-number">
                <span class="os-number">#{number}</span>
              </div>
            HTML
          )
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
openstax_kitchen-3.1.0 lib/kitchen/directions/bake_equations.rb