Sha256: 93baa28edc42057604adaab3bf3ef6b73c50ebdda47cf52afe1f3b7a04acaf12

Contents?: true

Size: 430 Bytes

Versions: 4

Compression:

Stored size: 430 Bytes

Contents

require 'redcarpet'

class NoParagraphRenderer < ::Redcarpet::Render::XHTML
  def paragraph(text)
    text
  end
end

AutoHtml.add_filter(:image).with({:alt => ''}) do |text, options|
  r = Redcarpet::Markdown.new(NoParagraphRenderer)
  alt = options[:alt]
  options[:proxy] ||= ""
  text.gsub(/(?<!src=")https?:\/\/.+?\.(jpg|jpeg|bmp|gif|png)(\?\S+)?/i) do |match|
    r.render("![#{alt}](#{options[:proxy]}#{match})")
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
auto_html-1.6.4 lib/auto_html/filters/image.rb
auto_html-1.6.3 lib/auto_html/filters/image.rb
auto_html-1.6.2 lib/auto_html/filters/image.rb
auto_html-1.6.1 lib/auto_html/filters/image.rb