about summary refs log tree commit diff
path: root/app/lib/formatter.rb
diff options
context:
space:
mode:
authormultiple creatures <dev@multiple-creature.party>2019-05-18 16:38:42 -0500
committermultiple creatures <dev@multiple-creature.party>2019-05-21 03:16:50 -0500
commit23d2e5f97cbe44980a27685a6b9a80ddf0799245 (patch)
tree6579fcb89e6ee27df57b9a9ab81c4f3c8d1c949c /app/lib/formatter.rb
parente411b20711325219695007496ec8db545b67f209 (diff)
fix bbdown newlines + format & emojify footers
Diffstat (limited to 'app/lib/formatter.rb')
-rw-r--r--app/lib/formatter.rb16
1 files changed, 8 insertions, 8 deletions
diff --git a/app/lib/formatter.rb b/app/lib/formatter.rb
index 9005ec768..ccaf71e7b 100644
--- a/app/lib/formatter.rb
+++ b/app/lib/formatter.rb
@@ -210,13 +210,17 @@ class Formatter
       html = html.delete("\n")
     end
 
-    html = append_footer(html, status.footer)
+    unless status.footer.blank?
+      footer = status.footer
+      footer = encode_and_link_urls(footer)
+      footer = encode_custom_emojis(footer, status.emojis, options[:autoplay]) if options[:custom_emojify]
+      html = "#{html.strip}<p class=\"signature\">— #{footer}</p>"
+    end
 
     html.html_safe # rubocop:disable Rails/OutputSafety
   end
 
   def format_markdown(html)
-    html = html.gsub("\r\n", "\n").gsub("\r", "\n")
     html = reformat(markdown_formatter.render(html))
     html.delete("\r").delete("\n")
   end
@@ -226,11 +230,12 @@ class Formatter
     html = html.gsub(/<hr>.*<\/hr>/im, '<hr />')
     return html unless sanitize
     html = reformat(html)
-    html.delete("\n")
+    html.delete("\r").delete("\n")
   end
 
   def format_bbdown(html)
     html = format_bbcode(html, false)
+    html = html.gsub(/<br *\/>|<br>/, '')
     format_markdown(html)
   end
 
@@ -294,11 +299,6 @@ class Formatter
 
   private
 
-  def append_footer(html, footer)
-    return html if footer.blank?
-    "#{html.strip}<p class=\"signature\">— #{encode(footer)}</p>"
-  end
-
   def bbcode_formatter(html)
     begin
       html = html.bbcode_to_html(false, BBCODE_TAGS, :enable, *BBCODE_TAGS.keys)