From 23d2e5f97cbe44980a27685a6b9a80ddf0799245 Mon Sep 17 00:00:00 2001 From: multiple creatures Date: Sat, 18 May 2019 16:38:42 -0500 Subject: fix bbdown newlines + format & emojify footers --- app/lib/formatter.rb | 16 ++++++++-------- app/models/status.rb | 1 + 2 files changed, 9 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}

— #{footer}

" + 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>/im, '
') 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(/
|
/, '') format_markdown(html) end @@ -294,11 +299,6 @@ class Formatter private - def append_footer(html, footer) - return html if footer.blank? - "#{html.strip}

— #{encode(footer)}

" - end - def bbcode_formatter(html) begin html = html.bbcode_to_html(false, BBCODE_TAGS, :enable, *BBCODE_TAGS.keys) diff --git a/app/models/status.rb b/app/models/status.rb index 895ac8fd6..5f25e86f6 100644 --- a/app/models/status.rb +++ b/app/models/status.rb @@ -251,6 +251,7 @@ class Status < ApplicationRecord fields = [spoiler_text, text] fields += preloadable_poll.options unless preloadable_poll.nil? + fields << footer unless footer.nil? @emojis = CustomEmoji.from_text(fields.join(' '), account.domain) end -- cgit