Class: PotMarkdown::Filters::MentionFilter
- Inherits:
-
HTML::Pipeline::MentionFilter
- Object
- HTML::Pipeline::MentionFilter
- PotMarkdown::Filters::MentionFilter
- Defined in:
- lib/pot_markdown/filters/mention_filter.rb
Constant Summary collapse
- USER_NAME_PATTERN =
/[A-Za-z0-9][A-Za-z0-9\-\_]+/
Instance Method Summary collapse
Instance Method Details
#call ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/pot_markdown/filters/mention_filter.rb', line 9 def call result[:mentioned_usernames] ||= [] doc.xpath('.//text()').each do |node| content = node.text next unless content.include?('@') next if has_ancestor?(node, IGNORE_PARENTS) html = mention_link_filter(content, base_url, info_url, username_pattern) next if html == content node.replace(html) end doc end |
#link_to_mentioned_user(login) ⇒ Object
27 28 29 30 |
# File 'lib/pot_markdown/filters/mention_filter.rb', line 27 def link_to_mentioned_user(login) result[:mentioned_usernames] |= [login] "<a href='#{base_url}#{login}' class='user-mention'>@#{login}</a>" end |
#username_pattern ⇒ Object
23 24 25 |
# File 'lib/pot_markdown/filters/mention_filter.rb', line 23 def username_pattern context[:username_pattern] || USER_NAME_PATTERN end |