<commit_before>module InlineSvg::TransformPipeline::Transformations
  class Title < Transformation
    def transform(doc)
      doc = Nokogiri::XML::Document.parse(doc.to_html)
      node = Nokogiri::XML::Node.new('title', doc)
      node.content = value
      doc.search('svg title').each { |node| node.remove }
      doc.at_css('svg').prepend_child(node)
      doc
    end
  end
end
<commit_msg>Handle documents without SVG root elements<commit_after>module InlineSvg::TransformPipeline::Transformations
  class Title < Transformation
    def transform(doc)
      with_svg(doc) do |svg|
        node = Nokogiri::XML::Node.new("title", doc)
        node.content = value

        svg.search("title").each { |node| node.remove }
        svg.prepend_child(node)
      end
    end
  end
end

{'fraction_non_alphanumeric': 0.116751269035533, 'fraction_numerical': 0.0, 'mean_word_length': 3.3114754098360657, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4821095', 'n_tokens_mistral': 248, 'n_tokens_neox': 244, 'n_words': 51}