Sha256: f8b7eb14a23079d349e9d6bf862af5cb9c9275c5d686d71c8e5e3578ca855c4e

Contents?: true

Size: 884 Bytes

Versions: 11

Compression:

Stored size: 884 Bytes

Contents

# -*- coding: utf-8; frozen_string_literal: true -*-
#
#--
# Copyright (C) 2009-2019 Thomas Leitner <t_leitner@gmx.at>
#
# This file is part of kramdown which is licensed under the MIT.
#++
#

module Kramdown
  module Parser
    class Kramdown

      ACHARS = '[[:alnum:]]-_.'
      AUTOLINK_START_STR = "<((mailto|https?|ftps?):.+?|[#{ACHARS}]+?@[#{ACHARS}]+?)>"
      AUTOLINK_START = /#{AUTOLINK_START_STR}/u

      # Parse the autolink at the current location.
      def parse_autolink
        start_line_number = @src.current_line_number
        @src.pos += @src.matched_size
        href = (@src[2].nil? ? "mailto:#{@src[1]}" : @src[1])
        el = Element.new(:a, nil, {'href' => href}, location: start_line_number)
        add_text(@src[1].sub(/^mailto:/, ''), el)
        @tree.children << el
      end
      define_parser(:autolink, AUTOLINK_START, '<')

    end
  end
end

Version data entries

11 entries across 11 versions & 3 rubygems

Version Path
kramdown-2.5.1 lib/kramdown/parser/kramdown/autolink.rb
kramdown-2.5.0 lib/kramdown/parser/kramdown/autolink.rb
getargv-0.3.3-universal-darwin vendor/bundle/ruby/3.3.0/gems/kramdown-2.4.0/lib/kramdown/parser/kramdown/autolink.rb
kramdown-2.4.0 lib/kramdown/parser/kramdown/autolink.rb
kramdown-2.3.2 lib/kramdown/parser/kramdown/autolink.rb
kramdown-2.3.1 lib/kramdown/parser/kramdown/autolink.rb
zine_brewer-1.5.0 vendor/bundle/ruby/2.7.0/gems/kramdown-2.3.0/lib/kramdown/parser/kramdown/autolink.rb
zine_brewer-1.3.0 vendor/bundle/ruby/2.7.0/gems/kramdown-2.3.0/lib/kramdown/parser/kramdown/autolink.rb
kramdown-2.3.0 lib/kramdown/parser/kramdown/autolink.rb
kramdown-2.2.1 lib/kramdown/parser/kramdown/autolink.rb
kramdown-2.2.0 lib/kramdown/parser/kramdown/autolink.rb