about summary refs log tree commit diff
path: root/app/lib/formatter.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/lib/formatter.rb')
-rw-r--r--app/lib/formatter.rb12
1 files changed, 12 insertions, 0 deletions
diff --git a/app/lib/formatter.rb b/app/lib/formatter.rb
index 60bc3733e..d8d5424fd 100644
--- a/app/lib/formatter.rb
+++ b/app/lib/formatter.rb
@@ -14,6 +14,7 @@ class Formatter
     html = simple_format(html, sanitize: false)
     html = link_urls(html)
     html = link_mentions(html, status.mentions)
+    html = link_hashtags(html)
 
     html.html_safe
   end
@@ -43,6 +44,17 @@ class Formatter
     end
   end
 
+  def link_hashtags(html)
+    html.gsub(Tag::HASHTAG_RE) do |match|
+      hashtag_html(match)
+    end
+  end
+
+  def hashtag_html(match)
+    prefix, affix = match.split('#')
+    "#{prefix}<a href=\"#\" class=\"mention hashtag\">#<span>#{affix}</span></a>"
+  end
+
   def mention_html(match, account)
     "#{match.split('@').first}<a href=\"#{TagManager.instance.url_for(account)}\" class=\"mention\">@<span>#{account.username}</span></a>"
   end