diff --git a/app/logical/d_text.rb b/app/logical/d_text.rb index 81e2d3573..4fb1e4e23 100644 --- a/app/logical/d_text.rb +++ b/app/logical/d_text.rb @@ -83,7 +83,16 @@ class DText url = element["href"] %("#{title}":[#{url}]) if title.present? && url.present? when "img" - element.attributes["title"] || element.attributes["alt"] || "" + alt_text = element.attributes["title"] || element.attributes["alt"] || "" + src = element["src"] + + if element.parent.name == "a" + alt_text + elsif alt_text.present? && src.present? + %("#{alt_text}":[#{src}]\n\n) + else + "" + end when "comment" # ignored else diff --git a/app/logical/sources/strategies/deviant_art.rb b/app/logical/sources/strategies/deviant_art.rb index 69c1d0137..774c4a9c8 100644 --- a/app/logical/sources/strategies/deviant_art.rb +++ b/app/logical/sources/strategies/deviant_art.rb @@ -52,7 +52,7 @@ module Sources element["href"] = uri.to_s end end - end + end.gsub(/\A[[:space:]]+|[[:space:]]+\z/, "") end protected diff --git a/test/unit/sources/deviantart_test.rb b/test/unit/sources/deviantart_test.rb index 9e164d902..d0825e285 100644 --- a/test/unit/sources/deviantart_test.rb +++ b/test/unit/sources/deviantart_test.rb @@ -65,7 +65,7 @@ module Sources * two * three - Heart   + "Heart":[https://e.deviantart.net/emoticons/h/heart.gif] EOS assert_equal(desc, @site.dtext_artist_commentary_desc)