<commit_before>require 'erubis'
require 'redcarpet'

module GeraBlog
  # My subclass to perform parse with code bloques options
  class CustomRender < Redcarpet::Render::HTML
    def initialize(lang:)
      super(prettify: true, escape_html: true)
      @lang = lang
    end

    def block_code(code, language)
      l = language.nil? ? @lang : language
      %(<pre><code class="language-#{l}">\n#{html_escape(code)}\n</code></pre>)
    end

    def html_escape(string)
      string.gsub(
        %r{['&\"<>\/]},
        '&' => '&amp;',
        '<' => '&lt;',
        '>' => '&gt;',
        '"' => '&quot;',
        "'" => '&#x27;',
        '/' => '&#x2F;'
      )
    end
  end

  # My Render class
  class Markdown
    def initialize(lang:, blog:)
      @template = blog['template']
      @blog = blog
      @render = Redcarpet::Markdown.new(CustomRender.new(lang: lang))
    end

    def to_html(post:)
      parser = Erubis::Eruby.new File.read(@template['post'])
      post[:converted] = @render.render(post[:content])
      puts post[:converted]
      parser.result(blog: @blog, post: post)
    end
  end
end<commit_msg>remove debug<commit_after>require 'erubis'
require 'redcarpet'

module GeraBlog
  # My subclass to perform parse with code bloques options
  class CustomRender < Redcarpet::Render::HTML
    def initialize(lang:)
      super(prettify: true, escape_html: true)
      @lang = lang
    end

    def block_code(code, language)
      l = language.nil? ? @lang : language
      %(<pre><code class="language-#{l}">\n#{html_escape(code)}\n</code></pre>)
    end

    def html_escape(string)
      string.gsub(
        %r{['&\"<>\/]},
        '&' => '&amp;',
        '<' => '&lt;',
        '>' => '&gt;',
        '"' => '&quot;',
        "'" => '&#x27;',
        '/' => '&#x2F;'
      )
    end
  end

  # My Render class
  class Markdown
    def initialize(lang:, blog:)
      @template = blog['template']
      @blog = blog
      @render = Redcarpet::Markdown.new(CustomRender.new(lang: lang))
    end

    def to_html(post:)
      parser = Erubis::Eruby.new File.read(@template['post'])
      post[:converted] = @render.render(post[:content])
      parser.result(blog: @blog, post: post)
    end
  end
end
{'fraction_non_alphanumeric': 0.17842696629213484, 'fraction_numerical': 0.002696629213483146, 'mean_word_length': 2.5903225806451613, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 27, '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': '7520374', 'n_tokens_mistral': 790, 'n_tokens_neox': 768, 'n_words': 160}