Fediverse posts: three spaces between the title and the tags (Pixelfed strips the HTML)

cff00cb · gmorell · 2026-11-19 19:29

7 files +6 -1

Files changed

modified lib/final_track/federation/objects.ex
+4 −1
@@ -136,13 +136,16 @@ defmodule FinalTrack.Federation.Objects do
136 136 # tag-followers). The account's own tag, then (if it asks) the artist's.
137 137 defp hashtag_html(tags) when tags == [], do: ""
138 138
139 + # Three spaces before the tags' paragraph: invisible where the HTML is
140 + # rendered (Mastodon), but where it's stripped to text (Pixelfed) the
141 + # title and the tags would otherwise run together.
139 142 defp hashtag_html(tags) do
140 143 links =
141 144 Enum.map_join(tags, " ", fn tag ->
142 145 ~s(<a href="#{tag_url(tag)}" class="mention hashtag" rel="tag">#<span>#{escape(tag)}</span></a>)
143 146 end)
144 147
145 − "<p>" <> links <> "</p>"
148 + " <p>" <> links <> "</p>"
146 149 end
147 150
148 151 defp hashtag_tags(tags),
modified test/final_track/federation_test.exs
+2 −0
@@ -91,6 +91,8 @@ defmodule FinalTrack.FederationTest do
91 91 assert_received {:delivered, _, %{"object" => note}, _, _, _}
92 92
93 93 assert note["content"] =~ ~s(rel="tag">#<span>scropple</span></a>)
94 + # Three spaces between the title and the tags, for servers that strip the HTML.
95 + assert note["content"] =~ "</p> <p><a"
94 96 assert [%{"type" => "Hashtag", "name" => "#scropple", "href" => href}] = note["tag"]
95 97 assert href =~ "/tags/scropple"
96 98 end

Parents: 950dedf