module Parser.Detail ( parse ) where import Data.Text (Text) import qualified Data.Text as T import Data.Map (Map) import qualified Data.Map as M import Data.Maybe (catMaybes, fromMaybe) import Text.HTML.TagSoup import Model.Detail import Parser.Utils parse :: Text -> Detail parse page = let tags = parseTags page in Detail { description = parseDescription tags , images = map (\url -> T.concat [T.pack "https:", url]) $ getTagAttributes "" (T.pack "content") tags , properties = parseProperties tags } parseDescription :: [Tag Text] -> Maybe Text parseDescription tags = let descriptionTags = getTagsBetween "
" "
" tags in if null descriptionTags then Nothing else let replaceBr = map (\tag -> if tag ~== "