<commit_before>require 'helper'
require 'slim/translator'

class TestSlimTranslator < TestSlim
  def setup
    super
    Slim::Engine.set_default_options :tr => true, :tr_fn => 'TestSlimTranslator.tr'
  end

  def self.tr(s)
    s.upcase
  end

  def self.tr_reverse(s)
    s.reverse.gsub(/(\d+)%/, '%\1')
  end

  def test_no_translation_of_embedded
    source = %q{
markdown:
  #Header
  Hello from #{"Markdown!"}

  #{1+2}

  * one
  * two
}
    assert_html "<h1 id=\"header\">Header</h1>\n<p>Hello from Markdown!</p>\n\n<p>3</p>\n\n<ul>\n  <li>one</li>\n  <li>two</li>\n</ul>\n", source, :tr_mode => :dynamic
    assert_html "<h1 id=\"header\">Header</h1>\n<p>Hello from Markdown!</p>\n\n<p>3</p>\n\n<ul>\n  <li>one</li>\n  <li>two</li>\n</ul>\n", source, :tr_mode => :static<commit_msg>Fix markdown tests regarding latest redcarpet, rdiscount and kramdown<commit_after>require 'helper'
require 'slim/translator'

class TestSlimTranslator < TestSlim
  def setup
    super
    Slim::Engine.set_default_options :tr => true, :tr_fn => 'TestSlimTranslator.tr'
  end

  def self.tr(s)
    s.upcase
  end

  def self.tr_reverse(s)
    s.reverse.gsub(/(\d+)%/, '%\1')
  end

  def test_no_translation_of_embedded
    source = %q{
markdown:
  #Header
  Hello from #{"Markdown!"}

  #{1+2}

  * one
  * two
}
    if !Gem::Specification::find_all_by_name('redcarpet').empty?
      # redcarpet
      assert_html "<h1>Header</h1>\n\n<p>Hello from Markdown!</p>\n\n<p>3</p>\n\n<ul>\n<li>one</li>\n<li>two</li>\n</ul>\n", source, :tr_mode => :dynamic
      assert_html "<h1>Header</h1>\n\n<p>Hello from Markdown!</p>\n\n<p>3</p>\n\n<ul>\n<li>one</li>\n<li>two</li>\n</ul>\n", source, :tr_mode => :static
    elsif !Gem::Specification::find_all_by_name('rdiscount').empty?
      # rdiscount
      assert_html "<h1>Header</h1>\n\n<p>Hello from Markdown!</p>\n\n<p>3</p>\n\n<ul>\n<li>one</li>\n<li>two</li>\n</ul>\n\n", source, :tr_mode => :dynamic
      assert_html "<h1>Header</h1>\n\n<p>Hello from Markdown!</p>\n\n<p>3</p>\n\n<ul>\n<li>one</li>\n<li>two</li>\n</ul>\n\n", source, :tr_mode => :static
    else
      # kramdown
      assert_html "<h1 id=\"header\">Header</h1>\n<p>Hello from Markdown!</p>\n\n<p>3</p>\n\n<ul>\n  <li>one</li>\n  <li>two</li>\n</ul>\n", source, :tr_mode => :dynamic
      assert_html "<h1 id=\"header\">Header</h1>\n<p>Hello from Markdown!</p>\n\n<p>3</p>\n\n<ul>\n  <li>one</li>\n  <li>two</li>\n</ul>\n", source, :tr_mode => :static
    end
{'fraction_non_alphanumeric': 0.22817701989443767, 'fraction_numerical': 0.012180267965895249, 'mean_word_length': 3.6578449905482042, 'pattern_counts': {'":': 0, '<': 101, '<?xml version=': 0, '>': 111, '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': '4368992', 'n_tokens_mistral': 1083, 'n_tokens_neox': 1069, 'n_words': 158}