fix bbdown newlines + format & emojify footers

staging
multiple creatures 2019-05-18 16:38:42 -05:00
parent e411b20711
commit 23d2e5f97c
2 changed files with 9 additions and 8 deletions

View File

@ -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)

View File

@ -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