Sha256: 8c478cf0b0c16ab7fb4201b928bf6555df685b86c0eb72c67772729e8957c619

Contents?: true

Size: 913 Bytes

Versions: 6

Compression:

Stored size: 913 Bytes

Contents

# frozen_string_literal: true

HTML::Pipeline.require_dependency('rinku', 'AutolinkFilter')

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

6 entries across 6 versions & 1 rubygems

Version Path
html-pipeline-2.13.0 lib/html/pipeline/autolink_filter.rb
html-pipeline-2.12.3 lib/html/pipeline/autolink_filter.rb
html-pipeline-2.12.2 lib/html/pipeline/autolink_filter.rb
html-pipeline-2.12.1 lib/html/pipeline/autolink_filter.rb
html-pipeline-2.12.0 lib/html/pipeline/autolink_filter.rb
html-pipeline-2.11.1 lib/html/pipeline/autolink_filter.rb