Sha256: 274ae651da4e7367420c4fc6e58e475b00b8723b83c20a03a1b3f543370a9443

Contents?: true

Size: 955 Bytes

Versions: 16

Compression:

Stored size: 955 Bytes

Contents

begin
  require "rinku"
rescue LoadError => _
  abort "Missing dependency 'rinku' for AutolinkFilter. See README.md for details."
end

module HTML
  class Pipeline
    # HTML Filter for auto_linking urls in HTML.
    #
    # Context options:
    #   :autolink  - boolean whether to autolink urls
    #   :link_attr - HTML attributes for the link that will be generated
    #   :skip_tags - HTML tags inside which autolinking will be skipped.
    #                See Rinku.skip_tags
    #   :flags     - additional Rinku flags. See https://github.com/vmg/rinku
    #
    # This filter does not write additional information to the context.
    class AutolinkFilter < Filter
      def call
        return html if context[:autolink] == false

        skip_tags = context[:skip_tags]
        flags = 0
        flags |= context[:flags] if context[:flags]

        Rinku.auto_link(html, :urls, context[:link_attr], skip_tags, flags)
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
html-pipeline-2.2.2 lib/html/pipeline/autolink_filter.rb
html-pipeline-2.2.1 lib/html/pipeline/autolink_filter.rb
html-pipeline-2.2.0 lib/html/pipeline/autolink_filter.rb
html-pipeline-2.1.0 lib/html/pipeline/autolink_filter.rb
html-pipeline-2.0 lib/html/pipeline/autolink_filter.rb
html-pipeline-1.11.0 lib/html/pipeline/autolink_filter.rb
html-pipeline-1.10.0 lib/html/pipeline/autolink_filter.rb
html-pipeline-1.9.0 lib/html/pipeline/autolink_filter.rb
html-pipeline-1.8.0 lib/html/pipeline/autolink_filter.rb
html-pipeline-1.7.0 lib/html/pipeline/autolink_filter.rb
html-pipeline-1.6.0 lib/html/pipeline/autolink_filter.rb
html-pipeline-1.5.0 lib/html/pipeline/autolink_filter.rb
html-pipeline-1.4.0 lib/html/pipeline/autolink_filter.rb
html-pipeline-1.3.0 lib/html/pipeline/autolink_filter.rb
html-pipeline-1.1.0 lib/html/pipeline/autolink_filter.rb
html-pipeline-1.0.0 lib/html/pipeline/autolink_filter.rb