about summary refs log tree commit diff
path: root/app/lib
diff options
context:
space:
mode:
authorR Tucker <github@ryantucker.us>2017-05-09 22:47:25 -0400
committerEugen Rochko <eugen@zeonfederated.com>2017-05-10 04:47:25 +0200
commite2491680e696d2c285a798ec4c66b26d2748df66 (patch)
tree1c5438c06d4917b7c2e49fa64dc5e8bbf696496b /app/lib
parent3a38322a54f0eeb3eba037a4fd61a072bda44311 (diff)
Handle hashtags in spoiler_texts (partial fix for #699) (#2683)
* services: scan spoiler_text for hashtags (#699)

* views: link hashtags from spoiler_texts

This covers linking hashtags from within the spoiler
text on the server-generated pages.

* services: fix string concat going into hashtag RE

Cleaner Ruby syntax, may handle immutable strings better
Diffstat (limited to 'app/lib')
-rw-r--r--app/lib/formatter.rb11
1 files changed, 11 insertions, 0 deletions
diff --git a/app/lib/formatter.rb b/app/lib/formatter.rb
index 0f2989a81..7b5b8bab4 100644
--- a/app/lib/formatter.rb
+++ b/app/lib/formatter.rb
@@ -25,6 +25,17 @@ class Formatter
     sanitize(html, Sanitize::Config::MASTODON_STRICT).html_safe # rubocop:disable Rails/OutputSafety
   end
 
+  def format_spoiler(status)
+    return reformat(status.spoiler_text) unless status.local?
+
+    html = status.spoiler_text
+    html = encode(html)
+    html = html.delete("\n")
+    html = link_hashtags(html)
+
+    html.html_safe # rubocop:disable Rails/OutputSafety
+  end
+
   def plaintext(status)
     return status.text if status.local?
     strip_tags(status.text)