Commit 696ba4d3 authored by Jerry Cheung's avatar Jerry Cheung

Merge pull request #42 from fahchen/master

add result[:mentioned_usernames] for MentionFilter
parents 98fc8dd7 eb3bcb2a
......@@ -60,6 +60,8 @@ module HTML
IGNORE_PARENTS = %w(pre code a).to_set
def call
result[:mentioned_usernames] ||= []
doc.search('text()').each do |node|
content = node.to_html
next if !content.include?('@')
......@@ -108,6 +110,7 @@ module HTML
end
def link_to_mentioned_user(login)
result[:mentioned_usernames] |= [login]
url = File.join(base_url, login)
"<a href='#{url}' class='user-mention'>" +
"@#{login}" +
......
......@@ -76,9 +76,7 @@ class HTML::Pipeline::MentionFilterTest < Test::Unit::TestCase
def mentioned_usernames
result = {}
MarkdownPipeline.call(@body, {}, result)
html = result[:output].to_html
users = html.scan(/user-mention">@(.+?)</)
users ? users.flatten.uniq : []
result[:mentioned_usernames]
end
def test_matches_usernames_in_body
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment