diff options
author | multiple creatures <dev@multiple-creature.party> | 2019-05-18 16:38:42 -0500 |
---|---|---|
committer | multiple creatures <dev@multiple-creature.party> | 2019-05-21 03:16:50 -0500 |
commit | 23d2e5f97cbe44980a27685a6b9a80ddf0799245 (patch) | |
tree | 6579fcb89e6ee27df57b9a9ab81c4f3c8d1c949c /app | |
parent | e411b20711325219695007496ec8db545b67f209 (diff) |
fix bbdown newlines + format & emojify footers
Diffstat (limited to 'app')
-rw-r--r-- | app/lib/formatter.rb | 16 | ||||
-rw-r--r-- | 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}<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) 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 |