Module: Anchored::Linker

Extended by:
Linker
Included in:
Linker
Defined in:
lib/anchored/linker.rb

Instance Method Summary collapse

Instance Method Details



7
8
9
10
# File 'lib/anchored/linker.rb', line 7

def auto_link(text, options = {}, &block)
  return "" if text.to_s.empty?
  auto_link_urls(text, options, &block)
end

#remove_target_if_local(href, domain, options) ⇒ Object

remove_target_if_local(“same.com/x”, “same.com”, target: “_blank”)

> <a href=“same.com/x”>same.com/x</a>

remove_target_if_local(“same.com/x”, “different.com”, target: “_blank”)

> <a href=“same.com/x” target=“_blank”>same.com/x</a>

modifies options in place



19
20
21
22
# File 'lib/anchored/linker.rb', line 19

def remove_target_if_local(href, domain, options)
  return unless options[:target]
  options.delete(:target) if href.include?("//#{domain}")
end