# frozen_string_literal: true module Kitchen::Directions::BakeCustomSections class V1 def bake(chapter:, custom_sections_properties:) custom_sections_properties.each do |_custom_section_name, property| title_text = I18n.t(:"custom-sections.#{property[:class]}") property_class = property[:class] inject = property[:inject] chapter.search(".#{property_class}").each do |custom_section| case inject when 'title' custom_section_title = custom_section.first('h2') custom_section_title_os_text = custom_section_title.first('.os-text') custom_section_title_sibling = custom_section.first('h2 + div') div_id = custom_section_title_sibling['id'] custom_section_title_sibling.trash custom_section_title.append(sibling: <<~HTML