From a7a95efde220deb5ce1a354ab6d00ee4d230d011 Mon Sep 17 00:00:00 2001 From: Claudio Ortolina Date: Sun, 23 Feb 2025 19:12:22 +0000 Subject: [PATCH] Make render bio work on bio summary as well --- lib/music_library_web/live/artist_live/show.ex | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/lib/music_library_web/live/artist_live/show.ex b/lib/music_library_web/live/artist_live/show.ex index 663b73da..a0008a2e 100644 --- a/lib/music_library_web/live/artist_live/show.ex +++ b/lib/music_library_web/live/artist_live/show.ex @@ -61,9 +61,24 @@ defmodule MusicLibraryWeb.ArtistLive.Show do # Bios start with text, then a link to read more on Last.fm, followed by a license text. # We split the bio at the read more link in order to render the license separately. - @last_fm_link_regex ~r/\.\s*/ + @last_fm_link_regex ~r/\.*\s*/ defp render_bio(bio) do case String.split(bio, @last_fm_link_regex, include_captures: true) do + [text, link, ""] -> + reformatted_bio = + Enum.join( + [ + text, + ~s(

#{link}

) + ], + "" + ) + + PhoenixHTMLHelpers.Format.text_to_html(reformatted_bio, + escape: false, + attributes: [class: "mt-2 text-sm/7"] + ) + [text, link, license] -> reformatted_bio = Enum.join(