<commit_before>module Slim
  # Slim helper functions
  #
  # @api public
  module Helpers
    # Iterate over `Enumerable` object
    # yielding each element to a Slim block
    # and putting the result into `<li>` elements.
    # For example:
    #
    #     = list_of([1,2]) do |i|
    #       = i
    #
    # Produces:
    #
    #     <li>1</li>
    #     <li>2</li>
    #
    # @param enum [Enumerable] The enumerable objects to iterate over
    # @yield [item] A block which contains Slim code that goes within list items
    # @yieldparam item An element of `enum`
    # @api public
    def list_of(enum, &block)
      list = enum.map do |i|
        "<li>#{yield(i)}</li>"
      end.join("\n")
      list.respond_to?(:html_safe) ? list.html_safe : list
    end

    # Returns an escaped copy of `html`.
    # Strings which are declared as html_safe are not escaped.
    #
    # @param html [String] The string to escape
    # @return [String] The escaped string
    # @api public
    def escape_html_safe(html)
      html.html_safe? ? html : escape_html(html)
    end

    if defined?(EscapeUtils)
      # Returns an escaped copy of `html`.
      #
      # @param html [String] The string to escape
      # @return [String] The escaped string
      # @api public
      def escape_html(html)
        EscapeUtils.escape_html(html.to_s)
      end
    elsif RUBY_VERSION > '1.9'
      # Used by escape_html
      # @api private
      ESCAPE_HTML = {
        '&' => '&amp;',
        '"' => '&quot;',
        '<' => '&lt;',
        '>' => '&gt;',
        '/' => '&#47;',
      }.freeze

      # Returns an escaped copy of `html`.
      #
      # @param html [String] The string to escape
      # @return [String] The escaped string
      # @api public
      def escape_html(html)
        html.to_s.gsub(/[&\"<>\/]/, ESCAPE_HTML)
      end
    else
      # Returns an escaped copy of `html`.
      #
      # @param html [String] The string to escape
      # @return [String] The escaped string
      # @api public
      def escape_html(html)
        html.to_s.gsub(/&/n, '&amp;').gsub(/\"/n, '&quot;').gsub(/>/n, '&gt;').gsub(/</n, '&lt;').gsub(/\//, '&#47;')
      end
    end

    module_function :escape_html, :escape_html_safe
  end
end<commit_msg>use extend self instead of module_function<commit_after>module Slim
  # Slim helper functions
  #
  # @api public
  module Helpers
    extend self

    # Iterate over `Enumerable` object
    # yielding each element to a Slim block
    # and putting the result into `<li>` elements.
    # For example:
    #
    #     = list_of([1,2]) do |i|
    #       = i
    #
    # Produces:
    #
    #     <li>1</li>
    #     <li>2</li>
    #
    # @param enum [Enumerable] The enumerable objects to iterate over
    # @yield [item] A block which contains Slim code that goes within list items
    # @yieldparam item An element of `enum`
    # @api public
    def list_of(enum, &block)
      list = enum.map do |i|
        "<li>#{yield(i)}</li>"
      end.join("\n")
      list.respond_to?(:html_safe) ? list.html_safe : list
    end

    # Returns an escaped copy of `html`.
    # Strings which are declared as html_safe are not escaped.
    #
    # @param html [String] The string to escape
    # @return [String] The escaped string
    # @api public
    def escape_html_safe(html)
      html.html_safe? ? html : escape_html(html)
    end

    if defined?(EscapeUtils)
      # Returns an escaped copy of `html`.
      #
      # @param html [String] The string to escape
      # @return [String] The escaped string
      # @api public
      def escape_html(html)
        EscapeUtils.escape_html(html.to_s)
      end
    elsif RUBY_VERSION > '1.9'
      # Used by escape_html
      # @api private
      ESCAPE_HTML = {
        '&' => '&amp;',
        '"' => '&quot;',
        '<' => '&lt;',
        '>' => '&gt;',
        '/' => '&#47;',
      }.freeze

      # Returns an escaped copy of `html`.
      #
      # @param html [String] The string to escape
      # @return [String] The escaped string
      # @api public
      def escape_html(html)
        html.to_s.gsub(/[&\"<>\/]/, ESCAPE_HTML)
      end
    else
      # Returns an escaped copy of `html`.
      #
      # @param html [String] The string to escape
      # @return [String] The escaped string
      # @api public
      def escape_html(html)
        html.to_s.gsub(/&/n, '&amp;').gsub(/\"/n, '&quot;').gsub(/>/n, '&gt;').gsub(/</n, '&lt;').gsub(/\//, '&#47;')
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.14133095926997552, 'fraction_numerical': 0.00445136879590474, 'mean_word_length': 2.067576791808874, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 35, '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': '2598585', 'n_tokens_mistral': 1536, 'n_tokens_neox': 1509, 'n_words': 435}