tagsoup-parsec 0.0.3 → 0.0.5
raw patch · 2 files changed
+41/−14 lines, 2 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Text.HTML.TagSoup.Parsec: eitherCloseTag :: String -> TagParser (Either Tag Tag)
+ Text.HTML.TagSoup.Parsec: eitherOpenTag :: String -> TagParser (Either Tag Tag)
+ Text.HTML.TagSoup.Parsec: eitherP :: (Show tok) => GenParser tok st a -> GenParser tok st (Either tok a)
+ Text.HTML.TagSoup.Parsec: eitherWholeTag :: String -> TagParser (Either Tag WholeTag)
Files
- Text/HTML/TagSoup/Parsec.hs +40/−13
- tagsoup-parsec.cabal +1/−1
Text/HTML/TagSoup/Parsec.hs view
@@ -5,17 +5,21 @@ , tParse , openTag , maybeOpenTag+ , eitherOpenTag , notOpenTag , allOpenTags , wholeTag , maybeWholeTag+ , eitherWholeTag , allWholeTags , closeTag , maybeCloseTag+ , eitherCloseTag , notCloseTag , allCloseTags , maybeP , allP+ , eitherP ) where @@ -117,41 +121,64 @@ -- It will return `Nothing` otherwise. -- It is not case sensitive. maybeOpenTag :: String -> TagParser ( Maybe Tag )-maybeOpenTag soughtName =- maybeP $ openTag soughtName+maybeOpenTag =+ maybeP . openTag -- | maybeCloseTag will return `Just` the tag if it gets a TagClose with he given name, -- It will return `Nothing` otherwise. -- It is not case sensitive. maybeCloseTag :: String -> TagParser ( Maybe Tag )-maybeCloseTag soughtName =- maybeP $ closeTag soughtName+maybeCloseTag =+ maybeP . closeTag -- | maybeWholeTag will return `Just` the tag if it gets a WholeTag with he given name, -- It will return `Nothing` otherwise. -- It is not case sensitive. maybeWholeTag :: String -> TagParser ( Maybe WholeTag )-maybeWholeTag soughtName =- maybeP $ wholeTag soughtName+maybeWholeTag =+ maybeP . wholeTag -- | allOpenTags will return all TagOpen with the given name. -- It is not case sensitive. allOpenTags :: String -> TagParser [ Tag ]-allOpenTags t =- allP $ maybeOpenTag t +allOpenTags =+ allP . maybeOpenTag -- | allCloseTags will return all TagClose with the given name. -- It is not case sensitive. allCloseTags :: String -> TagParser [ Tag ]-allCloseTags t =- allP $ maybeCloseTag t+allCloseTags =+ allP . maybeCloseTag -- | allWholeTags will return all WholeTag with the given name. -- It is not case sensitive. allWholeTags :: String -> TagParser [ WholeTag ]-allWholeTags t =- allP $ maybeWholeTag t- +allWholeTags =+ allP . maybeWholeTag++-- | eitherP takes a parser, and becomes its `Either` equivalent -- returning `Right` if it matches, and `Left` if it doesn't.+eitherP :: Show tok => GenParser tok st a -> GenParser tok st ( Either tok a )+eitherP p = do+ try ( do t <- p+ return $ Right t+ ) <|> ( do t <- anyToken+ return $ Left t+ )+-- | either a Right TagOpen or a Left arbitary tag.+eitherOpenTag :: String -> TagParser ( Either Tag Tag )+eitherOpenTag = + eitherP . openTag++-- | either a Right TagClose or a Left arbitary tag.+eitherCloseTag :: String -> TagParser ( Either Tag Tag )+eitherCloseTag =+ eitherP . closeTag++-- | either a Right WholeTag or a Left arbitary tag.+eitherWholeTag :: String -> TagParser ( Either Tag WholeTag )+eitherWholeTag = + eitherP . wholeTag+ -- | allP takes a parser which returns a `Maybe` value, and returns a list of matching tokens. allP :: GenParser tok st ( Maybe a ) -> GenParser tok st [ a ] allP p = do
tagsoup-parsec.cabal view
@@ -1,5 +1,5 @@ Name: tagsoup-parsec -Version: 0.0.3+Version: 0.0.5 License: BSD3 License-file: LICENSE Author: Johnny Morrice