diff options
Diffstat (limited to 'src/Parser/Utils.hs')
-rw-r--r-- | src/Parser/Utils.hs | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/Parser/Utils.hs b/src/Parser/Utils.hs index c03ab03..d72a1ce 100644 --- a/src/Parser/Utils.hs +++ b/src/Parser/Utils.hs @@ -1,5 +1,7 @@ module Parser.Utils - ( getTagsBetween + ( getTagsBefore + , getTagsAfter + , getTagsBetween , getTagAttributes , getTagAttribute , getTagTextAfter @@ -12,11 +14,14 @@ import qualified Data.Text as T import Text.HTML.TagSoup +getTagsBefore :: String -> [Tag Text] -> [Tag Text] +getTagsBefore selector = takeWhile (~/= selector) + +getTagsAfter :: String -> [Tag Text] -> [Tag Text] +getTagsAfter selector = drop 1 . dropWhile (~/= selector) + getTagsBetween :: String -> String -> [Tag Text] -> [Tag Text] -getTagsBetween beginSelector endSelector = - takeWhile (~/= endSelector) - . drop 1 - . dropWhile (~/= beginSelector) +getTagsBetween begin end = getTagsBefore end . getTagsAfter begin getTagAttributes :: String -> Text -> [Tag Text] -> [Text] getTagAttributes selector attribute = |