From f074595602e4efdd307780c942d95bb12afbffe6 Mon Sep 17 00:00:00 2001 From: Fire Demon Date: Sun, 16 Aug 2020 19:59:05 -0500 Subject: [Formatting] Split remote content formatting to utility method --- app/lib/formatter.rb | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'app/lib') diff --git a/app/lib/formatter.rb b/app/lib/formatter.rb index dec60a3ea..513b85fc3 100644 --- a/app/lib/formatter.rb +++ b/app/lib/formatter.rb @@ -52,13 +52,7 @@ class Formatter end return '' if raw_content.blank? - - unless status.local? - html = reformat(raw_content) - html = encode_custom_emojis(html, status.emojis, options[:autoplay]) if options[:custom_emojify] - html = format_article_content(summary, html) if options[:article_content] && summary.present? - return html.html_safe # rubocop:disable Rails/OutputSafety - end + return format_remote_content(raw_content, status.emojis, summary: summary, **options) unless status.local? linkable_accounts = status.active_mentions.map(&:account) linkable_accounts << status.account @@ -80,6 +74,13 @@ class Formatter html.html_safe # rubocop:disable Rails/OutputSafety end + def format_remote_content(html, emojis, **options) + html = reformat(html) + html = encode_custom_emojis(html, emojis, options[:autoplay]) if options[:custom_emojify] + html = format_article_content(options[:summary], html) if options[:article_content] && options[:summary].present? + html.html_safe # rubocop:disable Rails/OutputSafety + end + def format_markdown(html) html = markdown_formatter.render(html) html.delete("\r").delete("\n") -- cgit