parsec-tagsoup-0.1: Parsec parsers for Tagsoup tag streams

Text.ParserCombinators.Parsec.Tag

Synopsis

Documentation

type TagParser str st = GenParser (Tag str) stSource

The type of Tag parsers, a synonym for GenParser (Tag str)

satisfy :: (StringLike str, Show str) => (Tag str -> Bool) -> TagParser str st (Tag str)Source

Parse a tag if it satisfies the predicate. As all the tag parsers, it consumes the whitespace immediately after the parsed tag.

lexeme :: (Show str, StringLike str) => TagParser str st a -> TagParser str st aSource

lexeme p first applies parser p and then whitespace, returning the value of p.

lexeme = (<* whitespace)

Every tag parser is defined using lexeme, this way every parse starts at a point without whitespace.

The only point where whitespace should be called explicitly is at the start of the top level parser, in order to skip any leading whitespace.

space :: (Show str, StringLike str) => TagParser str st (Tag str)Source

Parses a text block containing only characters which satisfy isSpace.

whitespace :: (Show str, StringLike str) => TagParser str st ()Source

Parses any whitespace. Whitespace consists of zero or more ocurrences of space.

anyTag :: (Show str, StringLike str) => TagParser str st (Tag str)Source

Parses any tag.

anyTagOpen, anyTagClose :: (Show str, StringLike str) => TagParser str st (Tag str)Source

Parse any opening or closing tag. As all the tag parsers, these consume the whitespace immediately after the parsed tag.

tag :: forall st str rep. (StringLike str, Show str, TagRep rep) => rep -> TagParser str st (Tag str)Source

tag t parses any tag for which (~== t) is true.

tagOpen, tagClose :: (Show str, StringLike str) => str -> TagParser str st (Tag str)Source

Parse the given opening or closing tag As all the tag parsers, these consume the whitespace immediately after the parsed tag.

tagP :: forall rep str st a. (StringLike str, Show str, TagRep rep) => rep -> (Tag str -> TagParser str st a) -> TagParser str st aSource

The main workhorse.

tagP t p parses an opening tag u for which (~== t) is true. Then it runs the continuation parser p. Next it skips all the tags until the closing tag for u. Finally it returns the results of p.

The p parser should never consume the closing tag for u, or tagP will fail.

anyTagP :: (Show str, StringLike str) => (Tag str -> TagParser str st a) -> TagParser str st aSource

Behaves like tagP sans the predicate. Expects that the next tag will be an opening tag or fails otherwise.

tagText :: (Show str, StringLike str) => TagParser str st strSource

Parses a chunk of text. As all the tag parsers, it consumes the whitespace immediately after the parsed tag.

oneOf, noneOf :: (Show str, StringLike str) => [Tag str] -> TagParser str st (Tag str)Source

Versions of these Parsec combinators for tags