From 8d9db1412144afd4f6771ce4e82ce6b0addd2dfc Mon Sep 17 00:00:00 2001 From: Fosco Marotto Date: Wed, 3 Feb 2021 13:14:22 -0500 Subject: [PATCH] Revert "Remove local checks from formatter" This reverts commit c30f600f0969108a9a6902a5a116a4c6d7441e62. --- app/lib/formatter.rb | 37 ++++++++++++++++++------------------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/app/lib/formatter.rb b/app/lib/formatter.rb index 2f2012c6..db5dc0ad 100644 --- a/app/lib/formatter.rb +++ b/app/lib/formatter.rb @@ -19,11 +19,11 @@ class HTMLRenderer < Redcarpet::Render::HTML def double_emphasis(text) "#{text}" end - + def emphasis(text) "#{text}" end - + def header(text, header_level) "

#{text}

" end @@ -31,15 +31,15 @@ class HTMLRenderer < Redcarpet::Render::HTML def paragraph(text) "

#{text}

" end - + def triple_emphasis(text) "#{text}" end - + def strikethrough(text) "#{text}" end - + def underline(text) "#{text}" end @@ -53,7 +53,7 @@ class HTMLRenderer < Redcarpet::Render::HTML content end end - + def list_item(text, list_type) "
  • #{text}
  • " end @@ -115,11 +115,11 @@ class Formatter 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] - # return html.html_safe # rubocop:disable Rails/OutputSafety - # end + unless status.local? + html = reformat(raw_content) + html = encode_custom_emojis(html, status.emojis, options[:autoplay]) if options[:custom_emojify] + return html.html_safe # rubocop:disable Rails/OutputSafety + end linkable_accounts = status.active_mentions.map(&:account) linkable_accounts << status.account @@ -167,15 +167,14 @@ class Formatter end def plaintext(status) - return status.text - #if status.local? + return status.text if status.local? - #text = status.text.gsub(/(
    |
    |<\/p>)+/) { |match| "#{match}\n" } - #strip_tags(text) + text = status.text.gsub(/(
    |
    |<\/p>)+/) { |match| "#{match}\n" } + strip_tags(text) end def simplified_format(account, **options) - html = linkify(account.note) + html = account.local? ? linkify(account.note) : reformat(account.note) html = encode_custom_emojis(html, account.emojis, options[:autoplay]) if options[:custom_emojify] html.html_safe # rubocop:disable Rails/OutputSafety end @@ -203,7 +202,7 @@ class Formatter end def format_field(account, str, **options) - html = encode_and_link_urls(str, me: true) + html = account.local? ? encode_and_link_urls(str, me: true) : reformat(str) html = encode_custom_emojis(html, account.emojis, options[:autoplay]) if options[:custom_emojify] html.html_safe # rubocop:disable Rails/OutputSafety end @@ -482,8 +481,8 @@ class Formatter end def mention_html(account) - # return "@#{encode(account.acct)}" unless account.local? + return "@#{encode(account.acct)}" unless account.local? "@#{encode(account.acct)}" end -end +end \ No newline at end of file