<commit_before># frozen_string_literal: true

class CustomMarkdownRenderer < Redcarpet::Render::HTML
  include ImageHelpers
  include ::Padrino::Helpers::OutputHelpers
  include ::Padrino::Helpers::TagHelpers

  def block_code(code, language)
    path = code.lines.first[/^#\s(\S*)$/, 1]
    code = code.lines[1..-1].join if path
    code = code.gsub('<', '&lt').gsub('>', '&gt')
    template = File.read('source/partials/_code_block.erb')
    ERB.new(template).result(binding)
  end

  def table(header, body)
    header_labels = header.scan(/<th>([\s\S]*?)<\/th>/).flatten
    table_rows = parse_table(body)
    template = File.read('source/partials/_table.erb')
    ERB.new(template).result(binding)
  end

  def header(text, header_level)
    content_tag "h#{header_level}", id: text.parameterize, class: 'offset' do
      text
    end
  end

  def link(link, title, content)
    template = File.read('source/partials/_anchor.erb')<commit_msg>Do not escape markdown haders in custom renderer<commit_after># frozen_string_literal: true

class CustomMarkdownRenderer < Redcarpet::Render::HTML
  include ImageHelpers
  include ::Padrino::Helpers::OutputHelpers
  include ::Padrino::Helpers::TagHelpers

  def block_code(code, language)
    path = code.lines.first[/^#\s(\S*)$/, 1]
    code = code.lines[1..-1].join if path
    code = code.gsub('<', '&lt').gsub('>', '&gt')
    template = File.read('source/partials/_code_block.erb')
    ERB.new(template).result(binding)
  end

  def table(header, body)
    header_labels = header.scan(/<th>([\s\S]*?)<\/th>/).flatten
    table_rows = parse_table(body)
    template = File.read('source/partials/_table.erb')
    ERB.new(template).result(binding)
  end

  def header(text, header_level)
    content_tag "h#{header_level}", id: text.parameterize, class: 'offset' do
      mark_safe(text)
    end
  end

  def link(link, title, content)
    template = File.read('source/partials/_anchor.erb')
{'fraction_non_alphanumeric': 0.16082474226804125, 'fraction_numerical': 0.003092783505154639, 'mean_word_length': 4.134920634920635, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 9, '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': '2750057', 'n_tokens_mistral': 670, 'n_tokens_neox': 671, 'n_words': 126}