class AutoHtml::Gist

Gist filter

Public Instance Methods

call(text) click to toggle source
# File lib/auto_html/gist.rb, line 8
def call(text)
  regex = %r{https?://gist\.github\.com/(\w+/)?(\d+)}
  text.gsub(regex) do
    gist_id = Regexp.last_match(2)
    tag(:script, type: 'text/javascript', src: gist_url(gist_id)) { '' }
  end
end

Private Instance Methods

gist_url(id) click to toggle source
# File lib/auto_html/gist.rb, line 18
def gist_url(id)
  "https://gist.github.com/#{id}.js"
end