fix bbdown newlines + format & emojify footers
parent
e411b20711
commit
23d2e5f97c
|
@ -210,13 +210,17 @@ class Formatter
|
||||||
html = html.delete("\n")
|
html = html.delete("\n")
|
||||||
end
|
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
|
html.html_safe # rubocop:disable Rails/OutputSafety
|
||||||
end
|
end
|
||||||
|
|
||||||
def format_markdown(html)
|
def format_markdown(html)
|
||||||
html = html.gsub("\r\n", "\n").gsub("\r", "\n")
|
|
||||||
html = reformat(markdown_formatter.render(html))
|
html = reformat(markdown_formatter.render(html))
|
||||||
html.delete("\r").delete("\n")
|
html.delete("\r").delete("\n")
|
||||||
end
|
end
|
||||||
|
@ -226,11 +230,12 @@ class Formatter
|
||||||
html = html.gsub(/<hr>.*<\/hr>/im, '<hr />')
|
html = html.gsub(/<hr>.*<\/hr>/im, '<hr />')
|
||||||
return html unless sanitize
|
return html unless sanitize
|
||||||
html = reformat(html)
|
html = reformat(html)
|
||||||
html.delete("\n")
|
html.delete("\r").delete("\n")
|
||||||
end
|
end
|
||||||
|
|
||||||
def format_bbdown(html)
|
def format_bbdown(html)
|
||||||
html = format_bbcode(html, false)
|
html = format_bbcode(html, false)
|
||||||
|
html = html.gsub(/<br *\/>|<br>/, '')
|
||||||
format_markdown(html)
|
format_markdown(html)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -294,11 +299,6 @@ class Formatter
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def append_footer(html, footer)
|
|
||||||
return html if footer.blank?
|
|
||||||
"#{html.strip}<p class=\"signature\">— #{encode(footer)}</p>"
|
|
||||||
end
|
|
||||||
|
|
||||||
def bbcode_formatter(html)
|
def bbcode_formatter(html)
|
||||||
begin
|
begin
|
||||||
html = html.bbcode_to_html(false, BBCODE_TAGS, :enable, *BBCODE_TAGS.keys)
|
html = html.bbcode_to_html(false, BBCODE_TAGS, :enable, *BBCODE_TAGS.keys)
|
||||||
|
|
|
@ -251,6 +251,7 @@ class Status < ApplicationRecord
|
||||||
|
|
||||||
fields = [spoiler_text, text]
|
fields = [spoiler_text, text]
|
||||||
fields += preloadable_poll.options unless preloadable_poll.nil?
|
fields += preloadable_poll.options unless preloadable_poll.nil?
|
||||||
|
fields << footer unless footer.nil?
|
||||||
|
|
||||||
@emojis = CustomEmoji.from_text(fields.join(' '), account.domain)
|
@emojis = CustomEmoji.from_text(fields.join(' '), account.domain)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue