<commit_before>module ApplicationHelper
  def body_class
    %|#{controller.controller_name} #{controller.controller_name}-#{controller.action_name} #{@body_class}|
  end

  class HTMLwithPygments < Redcarpet::Render::HTML
    def block_code(code, language)
      sha = Digest::SHA1.hexdigest(code)
      Rails.cache.fetch ["code", language, sha].join('-') do
        add_line_numbers(Pygments.highlight(code, lexer: language))
      end
    end

    def add_line_numbers(code)
      current_line = 0
      code_arr = code.split("\n")
      # total_lines = code_arr.count
      # code_arr.map! do |line|
      #   current_line += 1
      #   if current_line == 1
      #     line.gsub!('<pre>', "<pre><span class='line-number'>#{current_line}:</span> ")
      #   elsif current_line == total_lines
      #     line
      #   else
      #     "<span class='line-number'>#{current_line}:</span> #{line}"
      #   end
      # end
      line_numbers = []
      (code_arr.length - 1).times do |n|
        current_line += 1
        line_numbers << "<span>#{current_line}: </span>"
      end
      line_numbers_div = <<-HTML.strip_heredoc
        <div class='line-numbers'>
          #{line_numbers.join("<br />")}
        </div>
      HTML

      markdown_div = <<-HTML.strip_heredoc
        <div class='code-block'>
          #{line_numbers_div}
          #{code}
        </div>
      HTML
    end
  end

  def markdown(text)
    renderer = HTMLwithPygments.new(hard_wrap: true, filter_html: false)
    options = {
      autolink: true,
      no_intra_emphasis: true,
      fenced_code_blocks: true,
      lax_spacing: true,
      lax_html_blocks: true,
      strikethrough: true,
      superscript: true
    }
    Redcarpet::Markdown.new(renderer, options).render(text).html_safe
  end
end<commit_msg>Remove commented code<commit_after>module ApplicationHelper
  def body_class
    %|#{controller.controller_name} #{controller.controller_name}-#{controller.action_name} #{@body_class}|
  end

  class HTMLwithPygments < Redcarpet::Render::HTML
    def block_code(code, language)
      sha = Digest::SHA1.hexdigest(code)
      Rails.cache.fetch ["code", language, sha].join('-') do
        add_line_numbers(Pygments.highlight(code, lexer: language))
      end
    end

    def add_line_numbers(code)
      current_line = 0
      code_arr = code.split("\n")
      line_numbers = []
      (code_arr.length - 1).times do |n|
        current_line += 1
        line_numbers << "<span>#{current_line}: </span>"
      end
      line_numbers_div = <<-HTML.strip_heredoc
        <div class='line-numbers'>
          #{line_numbers.join("<br />")}
        </div>
      HTML

      markdown_div = <<-HTML.strip_heredoc
        <div class='code-block'>
          #{line_numbers_div}
          #{code}
        </div>
      HTML
    end
  end

  def markdown(text)
    renderer = HTMLwithPygments.new(hard_wrap: true, filter_html: false)
    options = {
      autolink: true,
      no_intra_emphasis: true,
      fenced_code_blocks: true,
      lax_spacing: true,
      lax_html_blocks: true,
      strikethrough: true,
      superscript: true
    }
    Redcarpet::Markdown.new(renderer, options).render(text).html_safe
  end
end
{'fraction_non_alphanumeric': 0.12862036748676425, 'fraction_numerical': 0.003114294612270321, 'mean_word_length': 2.55703211517165, 'pattern_counts': {'":': 0, '<': 37, '<?xml version=': 0, '>': 23, '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': '5879094', 'n_tokens_mistral': 1089, 'n_tokens_neox': 1056, 'n_words': 196}