-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Utility functions for working with html-parse -- -- See README.md here @package html-parse-util @version 0.2.3 -- | Utility functions to make working with html-parse as easy as -- working with TagSoup! Most functions are one-to-one replacements for -- their respective TagSoup analogues and work the same way. module Text.HTML.Parser.Util -- | Like toTokenDefault, but with a supplied default value. -- --
--   >>> toToken "text"
--   ContentText "text"
--   
toToken :: Text -> Token -- | Convert Text to Token, with a default in case of a parse -- failure. toTokenDefault :: Token -> Text -> Token -- | Test if a Token is a TagOpen. isTagOpen :: Token -> Bool -- | Test if a Token is a TagClose. isTagClose :: Token -> Bool -- | Test if a Token is a TagSelfClose. isTagSelfClose :: Token -> Bool -- | Test if a Token is a ContentText. isContentText :: Token -> Bool -- | Test if a Token is a ContentChar. isContentChar :: Token -> Bool -- | Test if a Token is a Comment. isComment :: Token -> Bool -- | Test if a Token is a Doctype. isDoctype :: Token -> Bool -- | Returns True if the Token is TagOpen and matches the -- given name. isTagOpenName :: Text -> Token -> Bool -- | Returns True if the Token is TagClose and matches the -- given name. isTagCloseName :: Text -> Token -> Bool -- | Extract the string from within ContentText, crashes if not a -- ContentText. fromContentText :: Token -> Text -- | Extract the string from within ContentText, otherwise return -- Nothing. maybeContentText :: Token -> Maybe Text -- | Extract an attribute; crashes if not a TagOpen. Returns -- Attr "" "" if no attribute present. -- -- Warning: does not distinguish between missing attribute and present -- attribute with values "". fromAttrib :: Attr -> Token -> Attr -- | Extract an attribute; crashes if not a TagOpen. Returns -- Nothing if no attribute present. maybeAttrib :: Attr -> Token -> Maybe Attr -- | Extract all text content from a list of Tokens (similar to Verbatim -- found in HaXml). innerText :: [Token] -> Text -- | Get the first ContentText element from a list of Tokens. -- If no tag could be found, return an empty string. toHeadContentText :: [Token] -> Text -- | Get all Tokens between start and end. between :: Token -> Token -> [Token] -> [Token] -- | Drop an HTML header (i.e. the header tags and everything in between), -- as well as everything before it, from a list of Tokens. dropHeader :: [Attr] -> [Token] -> [Token] -- | Get all ContentText entries from a list of Tokens and -- extract their content. allContentText :: [Token] -> [Text] -- | This function takes a list, and returns all suffixes whose first item -- matches the predicate. -- --
--   >>> sections (== 'c') "abc cba ccb"
--   ["c cba ccb","cba ccb","ccb","cb"]
--   
sections :: (a -> Bool) -> [a] -> [[a]] -- | Like sections, but return the head element. Returns an empty -- list if no head element is present. -- --
--   >>> section (== 'c') "abc cba ccb"
--   "c cba ccb"
--   
section :: (a -> Bool) -> [a] -> [a] -- | This function is similar to sections, but splits the list so no -- element appears in any two partitions. -- --
--   >>> partitions (== 'c') "abc cba ccb"
--   ["c ","cba ","c","cb"]
--   
partitions :: (a -> Bool) -> [a] -> [[a]] -- | Performs an inexact match, the first item should be the thing to -- match. -- --
--   >>> ContentText "test" ~== ContentText ""
--   True
--   
-- --
--   >>> TagOpen "div" [Attr "class" "division ", Attr "id" "dd"] ~== TagOpen "div" [Attr "class" "division "]
--   True
--   
(~==) :: Token -> Token -> Bool infixl 9 ~== -- | Negation of (~==). (~/=) :: Token -> Token -> Bool infixl 9 ~/=