From f8581c81133d58a54617eab2c1082c555b172969 Mon Sep 17 00:00:00 2001 From: evazion Date: Tue, 21 Nov 2017 01:59:09 -0600 Subject: [PATCH] Fix #3321: HTML tags not converted in artist commentaries. --- app/logical/sources/strategies/pixiv.rb | 3 ++- test/unit/sources/pixiv_test.rb | 9 ++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/app/logical/sources/strategies/pixiv.rb b/app/logical/sources/strategies/pixiv.rb index 5632a196a..4222f1b6c 100644 --- a/app/logical/sources/strategies/pixiv.rb +++ b/app/logical/sources/strategies/pixiv.rb @@ -132,7 +132,8 @@ module Sources %("user/#{member_id}":[#{profile_url}] "»":[/artists?#{search_params}]) end - text + text = text.gsub(/\r\n|\r|\n/, "
") + DText.from_html(text) end def illust_id_from_url diff --git a/test/unit/sources/pixiv_test.rb b/test/unit/sources/pixiv_test.rb index deb08b4f0..34feca41b 100644 --- a/test/unit/sources/pixiv_test.rb +++ b/test/unit/sources/pixiv_test.rb @@ -135,10 +135,17 @@ module Sources assert_equal("desc", @site.dtext_artist_commentary_desc) end + should "convert html to dtext" do + get_source("https://www.pixiv.net/member_illust.php?mode=medium&illust_id=65985331") + + dtext_desc = "[b]bold[/b]\n[i]italic[/i]\nred" + assert_equal(dtext_desc, @site.dtext_artist_commentary_desc) + end + should "convert illust links and member links to dtext" do get_source("https://www.pixiv.net/member_illust.php?mode=medium&illust_id=63421642") - dtext_desc = %(foo 【pixiv #46337015 "»":[/posts?tags=pixiv:46337015]】bar 【pixiv #14901720 "»":[/posts?tags=pixiv:14901720]】\r\n\r\nbaz【"user/83739":[https://www.pixiv.net/member.php?id=83739] "»":[/artists?search%5Burl_matches%5D=https%3A%2F%2Fwww.pixiv.net%2Fmember.php%3Fid%3D83739]】) + dtext_desc = %(foo 【pixiv #46337015 "»":[/posts?tags=pixiv:46337015]】bar 【pixiv #14901720 "»":[/posts?tags=pixiv:14901720]】\n\nbaz【"user/83739":[https://www.pixiv.net/member.php?id=83739] "»":[/artists?search%5Burl_matches%5D=https%3A%2F%2Fwww.pixiv.net%2Fmember.php%3Fid%3D83739]】) assert_equal(dtext_desc, @site.dtext_artist_commentary_desc) end end