about summary refs log tree commit diff
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/helpers/text_helper.rb13
1 files changed, 10 insertions, 3 deletions
diff --git a/app/helpers/text_helper.rb b/app/helpers/text_helper.rb
index 614158c1b..998473036 100644
--- a/app/helpers/text_helper.rb
+++ b/app/helpers/text_helper.rb
@@ -21,11 +21,18 @@ module TextHelper
     t.gsub!(/[ \t]+\n/, "\n")
     t.gsub!(/\n\n+/, "\n")
 
-    t.unaccent_via_split_map.strip
+    return t.strip.unaccent_via_split_map unless '#'.in?(t)
+
+    tags = Extractor.extract_hashtags(t).uniq
+    t.gsub!(/^(?:#[\w:._·\-]+\s*)+/, '')
+    t.gsub!(/(?:#[\w:._·\-]+\s*)+$/, '')
+
+    t.delete!('#')
+
+    "#{tags.join(' ')}\n#{t.lstrip}".strip.unaccent_via_split_map
   end
 
   def normalize_status(status, cache: true, skip_cache: true)
-    return normalize_text("#{status.spoiler_text}\n#{status.text}") unless status.local?
-    normalize_text("#{status.spoiler_text}\n#{Formatter.instance.format(status, skip_cache: skip_cache, cache: cache)}")
+    normalize_text("#{status.tags.pluck(:name).join(' ')}\n#{status.spoiler_text}\n#{status.local? ? Formatter.instance.format(status, skip_cache: skip_cache, cache: cache) : status.text}")
   end
 end