diff options
author | Joris Guyonvarch | 2015-04-11 19:20:04 +0200 |
---|---|---|
committer | Joris Guyonvarch | 2015-04-11 19:20:04 +0200 |
commit | 4ddd6d1f6df2bab75d42b6d45b816e92e7173529 (patch) | |
tree | 09ddfd62fe32e210a87eb15eb86ee07ab9f24623 /src/Parser/Detail.hs | |
parent | 88b7f848da3515d67cfb989b98ad5285a037993e (diff) |
Fixing parsing errors, and use Text from now
Diffstat (limited to 'src/Parser/Detail.hs')
-rw-r--r-- | src/Parser/Detail.hs | 13 |
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 } |