aboutsummaryrefslogtreecommitdiff
path: root/src/Parser/Detail.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Parser/Detail.hs')
-rw-r--r--src/Parser/Detail.hs13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/Parser/Detail.hs b/src/Parser/Detail.hs
index ab1b0ca..b787772 100644
--- a/src/Parser/Detail.hs
+++ b/src/Parser/Detail.hs
@@ -2,14 +2,23 @@ module Parser.Detail
( parseDetail
) where
+import qualified Data.Text as T
+
import Text.HTML.TagSoup
import Model.Detail
import Parser.Utils
-parseDetail :: String -> Detail
+parseDetail :: T.Text -> Detail
parseDetail page =
let tags = parseTags page
- description = getTagText "<div class=content>" tags
+ descriptionTags = getTagsBetween "<div itemprop=description>" "</div>" tags
+ description =
+ if null descriptionTags
+ then
+ Nothing
+ else
+ let replaceBr = map (\tag -> if tag ~== "<br>" then TagText (T.pack "\n") else tag)
+ in Just . T.strip . renderTags . replaceBr $ descriptionTags
in Detail { description = description }