<commit_before>module Merb
    module ChannelsHelper
      def time_to_date(time)
        Date.new time.year, time.month, time.day
      end

      def date_to_time(date)
        Time.parse date.to_s
      end

      def colored_nick(nick)
        @colored_nicks ||= {}

        @colored_nicks[nick] ||= "#%02x%02x%02x" % [rand(256), rand(256), rand(256)]
      end

      def content(content)
        linkify_uris(h(content))
      end

      def linkify_uris(content)
        content.gsub %r{\b(\w+://\S+\w+/?)} do |m| 
          match, entity, _ = *m.partition(/&\w+$/)
          "<a href=\"#{match}\">#{match}</a>#{entity}#{_}"
        end
      end
    end
end<commit_msg>Ruby 1.8.6 compatible linkify.<commit_after>module Merb
    module ChannelsHelper
      def time_to_date(time)
        Date.new time.year, time.month, time.day
      end

      def date_to_time(date)
        Time.parse date.to_s
      end

      def colored_nick(nick)
        @colored_nicks ||= {}

        @colored_nicks[nick] ||= "#%02x%02x%02x" % [rand(256), rand(256), rand(256)]
      end

      def content(content)
        linkify_uris(h(content))
      end

      def linkify_uris(content)
        content.gsub %r{\b(\w+://\S+\w+/?)} do |m| 
          entity = if m2 = /&\w+$/.match(m)
            m[/&\w+$/] = ""
            m2[0]
          else
            ""
          end

          "<a href=\"#{m}\">#{m}</a>#{entity}"
        end
      end
    end
end
{'fraction_non_alphanumeric': 0.16285516285516285, 'fraction_numerical': 0.02494802494802495, 'mean_word_length': 1.803883495145631, 'pattern_counts': {'":': 0, '<': 7, '<?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': '6693889', 'n_tokens_mistral': 547, 'n_tokens_neox': 515, 'n_words': 95}