# frozen_string_literal: true module SharedMarkers include ActionView::Helpers::TagHelper def process_link(link, text = nil) href = if ALLOWED_HOSTS_IN_MARKDOWN.include?(URI(link).host) || URI(link).relative? link else linkfilter_path(url: link) end options = { href: href } unless URI(link).relative? options = options.merge({ target: "_blank", rel: "nofollow" }) end content_tag(:a, text.nil? ? link : text, options) rescue link end def autolink(link, _link_type) process_link(link) end def link(link, _title, content) process_link(link, content) end end