<commit_before>module Tritium::Engines::Reference::Scope
  module NodeModules 
    module ActionMethods
      def insert_tag(tag_name, contents = "", attributes = {}, &block)
        if contents.is_a? Hash
          attributes = contents
          contents = ""
        end

        new_node = position_node(node, "<#{tag_name} />").first
        (new_node.inner_html = contents) if contents.size > 0
    
        # Merge doesn't work here, so we have to iterate... bullshit!
        attributes.each do |key, value|
          new_node.set_attribute(key.to_s, value.to_s) 
        end

        if block
          Tritium::Engines::Reference::Scope::Node.new(new_node, @root, self).instance_eval(&block)
        end
      end
  
      def insert(html)
        position_node(node, html)
      end
  
      def name(new_name = nil, &block)
        if new_name
          node.name = new_name
        end
        if block<commit_msg>Tritium: Fixing the insert_move issue as detailed by Andrew.<commit_after>module Tritium::Engines::Reference::Scope
  module NodeModules 
    module ActionMethods
      def insert_tag(tag_name, contents = "", attributes = {}, &block)
        if contents.is_a? Hash
          attributes = contents
          contents = ""
        end

        new_node = position_node(node, "<#{tag_name} />").first
        (new_node.inner_html = contents) if contents.size > 0
    
        # Merge doesn't work here, so we have to iterate... bullshit!
        attributes.each do |key, value|
          new_node.set_attribute(key.to_s, value.to_s) 
        end

        if block
          Tritium::Engines::Reference::Scope::Node.new(new_node, @root, self).instance_eval(&block)
        end
      end
  
      def insert(html, &block)
        result = position_node(node, html)
        if block
          Tritium::Engines::Reference::Scope::Node.new(result, @root, self).instance_eval(&block)
        end
      end
  
      def name(new_name = nil, &block)
        if new_name
          node.name = new_name
        end
        if block
{'fraction_non_alphanumeric': 0.10220048899755502, 'fraction_numerical': 0.0009779951100244498, 'mean_word_length': 2.172093023255814, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '7554690', 'n_tokens_mistral': 611, 'n_tokens_neox': 600, 'n_words': 149}