Class: Redmine::WikiFormatting::CommonMark::FixupAutoLinksFilter

Inherits:
HTML::Pipeline::Filter
  • Object
show all
Defined in:
lib/redmine/wiki_formatting/common_mark/fixup_auto_links_filter.rb

Overview

fixes:

Constant Summary collapse

/(@|user:)\z/
HIRES_IMAGE =
/.+@\dx\.(bmp|gif|jpg|jpe|jpeg|png)\z/

Instance Method Summary collapse

Instance Method Details

#callObject



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/redmine/wiki_formatting/common_mark/fixup_auto_links_filter.rb', line 33

def call
  doc.search("a").each do |node|
    unless (url = node['href']) && url.starts_with?('mailto:')
      next
    end

    if ((p = node.previous) && p.text? &&
        p.text =~(USER_LINK_PREFIX)) ||
       (node.text =~ HIRES_IMAGE)

      node.replace node.text
    end
  end
  doc
end