convert_a

in jekyll/plugins/markdown_converter.rb [99:121]


      def convert_a(el, indent)
        res = inner(el, indent)
        attr = el.attr.dup
        attr['href'] = '' if attr['href'].nil?
        href = convert_href(attr['href'])

        is_external = href.start_with?('http://', 'https://', 'ftp://', '//')
        attr['data-bypass'] = 'yes' if is_external
        if href.start_with?('mailto:')
          mail_addr = href[7..-1]
          attr['href'] = obfuscate('mailto') << ":" << obfuscate(mail_addr)
          res = obfuscate(res) if res == mail_addr
        end

        href = @options[:baseurl] + href[1, href.length - 1] if href.start_with?('/') and !href.start_with?('//')
        uri = URI(href)
        uri.path = uri.path.chomp(File.extname(uri.path)) + '.html' if !uri.path.nil? and File.extname(uri.path) == '.md' and !is_external
        attr['href'] = uri.to_s
        attr['target'] = '_blank' if is_external

        format_as_span_html(el.type, attr, "<span>#{res}</span>")
      end