class Content::Pipeline::Filters::Links

Constants

HttpRegexp

Public Instance Methods

external(val) click to toggle source
# File lib/content/pipeline/filters/links.rb, line 16
def external(val)
  unless !@opts[:host] || val[:href] =~ \
      %r!https?://#{Regexp.escape(@opts[:host])}(?:\Z|/)!
    val[:target] = "_blank"
  end
val
end
https(val) click to toggle source
# File lib/content/pipeline/filters/links.rb, line 24
def https(val)
  val[:href] = val[:href].gsub(
    HttpRegexp, "https://"
  )
val
end
wrapper() click to toggle source
# File lib/content/pipeline/filters/links.rb, line 7
def wrapper
  @str = @str.to_nokogiri_fragment
  @str.xpath(".//a").each do |v|
    external(https(
      v
    ))
  end
end