diff options
author | Joris Guyonvarch | 2015-04-18 11:03:56 +0200 |
---|---|---|
committer | Joris Guyonvarch | 2015-04-18 11:03:56 +0200 |
commit | a14b3c3d4447cbeb77e4146fba7e0d31393e625e (patch) | |
tree | a325de340e88df4706925dd166aefa985f085a06 /src/Parser/Utils.hs | |
parent | 3eff27c41a0501d07586b90c8bbb835a3ec86b84 (diff) | |
download | ad-listener-a14b3c3d4447cbeb77e4146fba7e0d31393e625e.tar.gz ad-listener-a14b3c3d4447cbeb77e4146fba7e0d31393e625e.tar.bz2 ad-listener-a14b3c3d4447cbeb77e4146fba7e0d31393e625e.zip |
Parsing images in detail and show URLs in notifications
Diffstat (limited to 'src/Parser/Utils.hs')
-rw-r--r-- | src/Parser/Utils.hs | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/Parser/Utils.hs b/src/Parser/Utils.hs index 16fe3d2..c03ab03 100644 --- a/src/Parser/Utils.hs +++ b/src/Parser/Utils.hs @@ -1,11 +1,12 @@ module Parser.Utils ( getTagsBetween + , getTagAttributes , getTagAttribute , getTagTextAfter ) where import Data.List (find, findIndex) -import Data.Maybe (listToMaybe) +import Data.Maybe (listToMaybe, catMaybes) import Data.Text (Text) import qualified Data.Text as T @@ -17,9 +18,16 @@ getTagsBetween beginSelector endSelector = . drop 1 . dropWhile (~/= beginSelector) +getTagAttributes :: String -> Text -> [Tag Text] -> [Text] +getTagAttributes selector attribute = + catMaybes + . fmap (maybeTagAttribute attribute) + . filter (~== selector) + getTagAttribute :: String -> Text -> [Tag Text] -> Maybe Text -getTagAttribute selector attribute tags = - find (~== selector) tags >>= maybeTagAttribute attribute +getTagAttribute selector attribute = + listToMaybe + . getTagAttributes selector attribute getTagTextAfter :: String -> [Tag Text] -> Maybe Text getTagTextAfter selector tags = |