<commit_before>description  'Markdown text filter'
dependencies 'engine/filter'
require      'rdiscount'

Filter.create :markdown do |context, content|
  RDiscount.new(content, :filter_html).to_html
end<commit_msg>fix issue #34. add output parameter for images in markdown filter<commit_after>description  'Markdown text filter'
dependencies 'engine/filter'
require      'rdiscount'

Filter.create :markdown do |context, content|
  content = RDiscount.new(content, :filter_html).to_html
  content.gsub!(/(<img[^>+]src=")([^"]+)"/) do |match|
    prefix, path = $1, $2
    if path.begins_with?('http://') || path.begins_with?('https://')
      match
    else
      path = unescape_html(path)
      prefix + escape_html(path + (path.include?('?') ? '&' : '?') + 'output=image') + '"'
    end
  end
  content
end
{'fraction_non_alphanumeric': 0.15822002472187885, 'fraction_numerical': 0.004944375772558714, 'mean_word_length': 4.294117647058823, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 1, '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': '4120689', 'n_tokens_mistral': 277, 'n_tokens_neox': 267, 'n_words': 63}