DEV: Replace Rinku native gem with PrettyText (#31557)

We have a native dependency, Rinku, that's used only to make links in one place. We can get rid of this and use PrettyText instead.

This is almost a one-for-one replacement, but PrettyText adds rel="noopener nofollow ugc" to external links, which I suspect is actually what we want. It also wraps the result in a <p> tag, which we strip out for parity with Rinku.
This commit is contained in:
Ted Johansson
2025-03-03 09:19:17 +08:00
committed by GitHub
parent 176ee0bf60
commit 258dfab8d7
4 changed files with 51 additions and 5 deletions

View File

@ -26,7 +26,8 @@ class TwitterApi
end
end
text = link_hashtags_in link_handles_in text
result = Rinku.auto_link(text, :all, 'target="_blank"').to_s
result =
PrettyText.cook(text, features_override: []).delete_prefix("<p>").delete_suffix("</p>")
if tweet[:includes] && media = tweet[:includes][:media]
media.each do |m|