Class: Redmine::WikiFormatting::CommonMark::FixupAutoLinksFilter
- Inherits:
-
HTML::Pipeline::Filter
- Object
- HTML::Pipeline::Filter
- Redmine::WikiFormatting::CommonMark::FixupAutoLinksFilter
- Defined in:
- lib/redmine/wiki_formatting/common_mark/fixup_auto_links_filter.rb
Overview
fixes:
-
autolinked email addresses that are actually references to users: user:<a href=“[email protected]”>[email protected]</a> @<a href=“[email protected]”>[email protected]</a>
-
autolinked hi res image names that look like email addresses: <a href=“[email protected]”>[email protected]</a>
Constant Summary collapse
- USER_LINK_PREFIX =
/(@|user:)\z/
- HIRES_IMAGE =
/.+@\dx\.(bmp|gif|jpg|jpe|jpeg|png)\z/
Instance Method Summary collapse
Instance Method Details
#call ⇒ Object
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 |