| Class | HTML::Pipeline::MentionFilter |
| In: |
lib/html/pipeline/@mention_filter.rb
|
| Parent: | Filter |
HTML filter that replaces @user mentions with links. Mentions within <pre>, <code>, and <a> elements are ignored. Mentions that reference users that do not exist are ignored.
Context options:
:base_url - Used to construct links to user profile pages for each
mention.
:info_url - Used to link to "more info" when someone mentions @mention
or @mentioned.
:username_pattern - Used to provide a custom regular expression to
identify usernames
| MentionPatterns | = | Hash.new do |hash, key| hash[key] = / (?:^|\W) # beginning of string or non-word char @((?>#{key})) # @username (?!\/) # without a trailing slash (?= \.+[ \t\W]| # dots followed by space or non-word character \.+$| # dots at end of line [^0-9a-zA-Z_.]| # non-word character except dot $ # end of line ) /ix | Hash that contains all of the mention patterns used by the pipeline |
Public: Find user @mentions in text. See MentionFilter#mention_link_filter.
MentionFilter.mentioned_logins_in(text) do |match, login, is_mentioned|
"<a href=...>#{login}</a>"
end
text - String text to search.
Yields the String match, the String login name, and a Boolean determining if the match = "@mention[ed]". The yield‘s return replaces the match in the original text.
Returns a String replaced with the return of the block.