Sha256: 01f4132a80746f4ab10b001a2cd5acf8e7a66de63b0d693df012a8e952a1649b
Contents?: true
Size: 702 Bytes
Versions: 7
Compression:
Stored size: 702 Bytes
Contents
require "uri" module Kramdown module Parser class KramdownWithAutomaticExternalLinks < Kramdown::Parser::Kramdown class << self attr_writer :document_domains def document_domains @document_domains || %w(www.gov.uk) end end def add_link(el, href, title, alt_text = nil) begin host = URI.parse(href).host unless host.nil? || (self.class.document_domains.compact.include?(host)) el.attr['rel'] = 'external' end rescue URI::InvalidURIError, URI::InvalidComponentError # it's safe to ignore these very *specific* exceptions end super end end end end
Version data entries
7 entries across 7 versions & 1 rubygems