Sha256: b68000e394e53c231613b3c7a045263159e7d9b6c60fe1fe12263aeda6d823dd

Contents?: true

Size: 380 Bytes

Versions: 3

Compression:

Stored size: 380 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]
  text.gsub(/https?:\/\/.+?\.(jpg|jpeg|bmp|gif|png)(\?\S+)?/i) do |match|
    r.render("![#{alt}](#{match})")
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
auto_html-1.6.0 lib/auto_html/filters/image.rb
auto_html-1.5.3 lib/auto_html/filters/image.rb
auto_html-1.5.2 lib/auto_html/filters/image.rb