<commit_before>require 'cgi'
require 'rdoc/markup/simple_markup'
require 'rdoc/markup/simple_markup/to_html'

module YARD::Generators::Helpers
  module HtmlHelper
    SimpleMarkup = SM::SimpleMarkup.new
    SimpleMarkupHtml = SM::ToHtml.new
    
    def h(text)
      CGI.escapeHTML(text)
    end
    
    def urlencode(text)
      #CGI.escape(text)
      text
    end

    def htmlify(text)
      resolve_links SimpleMarkup.convert(text, SimpleMarkupHtml)
    end

    def resolve_links(text)
      text.gsub(/\{(\S+)\}/) do 
        "<tt>" + linkify(P(current_object, $1)) + "</tt>" 
      end
    end
    
    def linkify(*args) 
      # The :// character sequence exists in no valid object path but just about every URL scheme.
      if args.first.is_a?(String) && args.first.include?("://")
        link_url(*args)
      else
        link_object(*args)
      end
    end
    
    def link_object(object, title = nil, anchor = nil)
      object = P(current_object, object) if object.is_a?(String)
      return title || object.path unless serializer

      if object.is_a?(YARD::CodeObjects::Proxy)
        log.warn "Cannot resolve link to #{object.path}. Missing file #{url_for(object, false)}."
        return object.path 
      end
      
      title = h(title || object.path)
      link = url_for(object)
      
      case anchor
      when String, Symbol
        link += "#" + urlencode(anchor)
      when YARD::CodeObjects::Base
        link += "#" + urlencode(anchor.name + "-" + anchor.type)
      when YARD::CodeObjects::Proxy
        link += "#" + urlencode(anchor.path)
      end
      
      link.empty? ? title : "<a href='#{link}' title='#{title}'>#{title}</a>"
    end
    <commit_msg>Convert a bunch of the parameters to strings because symbols will often be passed in.<commit_after>require 'cgi'
require 'rdoc/markup/simple_markup'
require 'rdoc/markup/simple_markup/to_html'

module YARD::Generators::Helpers
  module HtmlHelper
    SimpleMarkup = SM::SimpleMarkup.new
    SimpleMarkupHtml = SM::ToHtml.new
    
    def h(text)
      CGI.escapeHTML(text)
    end
    
    def urlencode(text)
      #CGI.escape(text)
      text
    end

    def htmlify(text)
      resolve_links SimpleMarkup.convert(text, SimpleMarkupHtml)
    end

    def resolve_links(text)
      text.gsub(/\{(\S+)\}/) do 
        "<tt>" + linkify(P(current_object, $1)) + "</tt>" 
      end
    end
    
    def linkify(*args) 
      # The :// character sequence exists in no valid object path but just about every URL scheme.
      if args.first.is_a?(String) && args.first.include?("://")
        link_url(*args)
      else
        link_object(*args)
      end
    end
    
    def link_object(object, title = nil, anchor = nil)
      title = title.to_s if title
      object = P(current_object, object) if object.is_a?(String)
      return title || object.path unless serializer

      if object.is_a?(YARD::CodeObjects::Proxy)
        log.warn "Cannot resolve link to #{object.path}. Missing file #{url_for(object, false)}."
        return object.path 
      end
      
      title = h(title || object.path)
      link = url_for(object)
      
      case anchor
      when String, Symbol
        link += "#" + urlencode(anchor)
      when YARD::CodeObjects::Base
        link += "#" + urlencode(anchor.name.to_s + "-" + anchor.type.to_s)
      when YARD::CodeObjects::Proxy
        link += "#" + urlencode(anchor.path)
      end
      
      link.empty? ? title : "<a href='#{link}' title='#{title}'>#{title}</a>"
    end
    
{'fraction_non_alphanumeric': 0.12805224304372514, 'fraction_numerical': 0.0005678591709256105, 'mean_word_length': 2.42704280155642, 'pattern_counts': {'":': 2, '<': 11, '<?xml version=': 0, '>': 11, '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': '4217868', 'n_tokens_mistral': 1130, 'n_tokens_neox': 1125, 'n_words': 266}