Sha256: c103b8a1130670f552bb29b08fa81186ba71e5827235f4ae1775b9d7f52dc3af

Contents?: true

Size: 748 Bytes

Versions: 5

Compression:

Stored size: 748 Bytes

Contents

require 'rinku'

module HTML
  class Pipeline
    # HTML Filter for auto_linking urls in HTML.
    #
    # Context options:
    #   :autolink  - boolean whether to autolink urls
    #   :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, nil, skip_tags, flags)
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
html-pipeline-0.3.1 lib/html/pipeline/autolink_filter.rb
html-pipeline-0.3.0 lib/html/pipeline/autolink_filter.rb
html-pipeline-0.2.1 lib/html/pipeline/autolink_filter.rb
html-pipeline-0.2.0 lib/html/pipeline/autolink_filter.rb
html-pipeline-0.1.0 lib/html/pipeline/autolink_filter.rb