Class: HTML::Pipeline::AutolinkFilter

Inherits:
Filter
  • Object
show all
Defined in:
lib/html/pipeline/autolink_filter.rb

Overview

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.

Instance Attribute Summary

Attributes inherited from Filter

#context, #result

Instance Method Summary collapse

Methods inherited from Filter

#base_url, call, #current_user, #doc, #has_ancestor?, #html, #initialize, #needs, #parse_html, #repository, to_document, to_html, #validate

Constructor Details

This class inherits a constructor from HTML::Pipeline::Filter

Instance Method Details

#callObject


18
19
20
21
22
23
24
25
26
# File 'lib/html/pipeline/autolink_filter.rb', line 18

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