-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Streaming HTML parser -- @package list-t-html-parser @version 0.3.0.0 module ListT.HTMLParser -- | A backtracking HTML-tokens stream parser. data Parser m a -- | A possibly detailed parser error. When mzero or empty is -- used, an error value of Nothing is produced. type Error = Maybe ErrorDetails data ErrorDetails -- | A text message ErrorDetails_Message :: Text -> ErrorDetails -- | Unexpected token ErrorDetails_UnexpectedToken :: ErrorDetails -- | End of input ErrorDetails_EOI :: ErrorDetails -- | Run a parser on a stream of HTML tokens, consuming only as many as -- needed. run :: Monad m => Parser m a -> ListT m Token -> m (Either Error a) -- | End of input. eoi :: Monad m => Parser m () -- | Any HTML token. token :: Monad m => Parser m Token -- | An opening tag. openingTag :: Monad m => Parser m OpeningTag -- | A closing tag. closingTag :: Monad m => Parser m ClosingTag -- | A text between tags with HTML-entities decoded. text :: Monad m => Parser m Text -- | Contents of a comment. comment :: Monad m => Parser m Text -- | The auto-repaired textual HTML representation of an HTML-tree node. -- -- Useful for consuming HTML-formatted snippets. -- -- E.g., when the following parser: -- --
-- openingTag *> html ---- -- is run against the following HTML snippet: -- --
-- <ul> -- <li>I'm not your friend, <b>buddy</b>!</li> -- <li>I'm not your buddy, <b>guy</b>!</li> -- <li>He's not your guy, <b>friend</b>!</li> -- <li>I'm not your friend, <b>buddy</b>!</li> -- </ul> ---- -- it'll produce the following text builder value: -- --
-- <li>I'm not your friend, <b>buddy</b>!</li> ---- -- If you want to consume all children of a node, it's recommended to use -- properHTML in combination with many or many1. For -- details consult the docs on properHTML. -- -- This parser is smart and handles and repairs broken HTML: -- --
-- openingTag *> (mconcat <$> many properHTML) ---- -- on the following input: -- --
-- <ul> -- <li>I'm not your friend, <b>buddy</b>!</li> -- <li>I'm not your buddy, <b>guy</b>!</li> -- <li>He's not your guy, <b>friend</b>!</li> -- <li>I'm not your friend, <b>buddy</b>!</li> -- </ul> ---- -- will produce a merged text builder, which consists of the following -- nodes: -- --
-- <li>I'm not your friend, <b>buddy</b>!</li> -- <li>I'm not your buddy, <b>guy</b>!</li> -- <li>He's not your guy, <b>friend</b>!</li> -- <li>I'm not your friend, <b>buddy</b>!</li> ---- -- Notice that unlike with html, it's safe to assume that it will -- not consume the following closing </ul> tag, because it -- does not begin a valid HTML-tree node. -- -- Notice also that despite failing in case of the first broken token, -- this parser handles the broken tokens in other cases the same way as -- html. properHTML :: Monad m => Parser m Builder -- | Apply a parser at least one time. many1 :: Monad m => Parser m a -> Parser m [a] -- | Apply a parser multiple times until another parser is satisfied. -- Returns results of both parsers. manyTill :: Monad m => Parser m a -> Parser m b -> Parser m ([a], b) -- | Skip any tokens until the provided parser is satisfied. skipTill :: Monad m => Parser m a -> Parser m a -- | Greedily consume all the input until the end, while running the -- provided parser. Same as: -- --
-- theParser <* eoi --total :: Monad m => Parser m a -> Parser m a instance Show ErrorDetails instance Eq ErrorDetails instance Monad m => Functor (Parser m) instance Monad m => Applicative (Parser m) instance Monad m => MonadError Error (Parser m) instance Monad m => MonadPlus (Parser m) instance Monad m => Alternative (Parser m) instance Monad m => Monad (Parser m)