Sha256: 13421941dae0b0812bf13ff984a2e38930d4b5b86eed78726b8b70a503c1d6a7

Contents?: true

Size: 662 Bytes

Versions: 3

Compression:

Stored size: 662 Bytes

Contents

# frozen_string_literal: true

module Kitchen
  module Directions
    # Bake directions for link placeholders
    #
    module BakeLinkPlaceholders
      def self.v1(book:)
        book.search('a').each do |anchor|
          next unless anchor.text == '[link]'

          id = anchor[:href][1..-1]
          replacement = book.document.pantry(name: :link_text).get(id)
          if replacement.present?
            anchor.replace_children(with: replacement)
          else
            # TODO: log a warning!
            puts "warning! could not find a replacement for '[link]' on an element with ID '#{id}'"
          end
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
openstax_kitchen-3.2.0 lib/kitchen/directions/bake_link_placeholders.rb
openstax_kitchen-3.1.0 lib/kitchen/directions/bake_link_placeholders.rb
openstax_kitchen-3.0.0 lib/kitchen/directions/bake_link_placeholders.rb