| Copyright | © 2016 Kwang Yul Seo |
|---|---|
| License | BSD |
| Maintainer | Kwang Yul Seo <kwangyul.seo@gmail.com> |
| Stability | experimental |
| Portability | portable |
| Safe Haskell | None |
| Language | Haskell2010 |
Text.Megaparsec.TagSoup
Contents
Description
Make Tags an instance of Stream with 'Tag str' token type.
- type TagParser str = Parsec Dec [Tag str]
- space :: (StringLike str, MonadParsec e s m, Token s ~ Tag str) => m (Tag str)
- whitespace :: (StringLike str, MonadParsec e s m, Token s ~ Tag str) => m ()
- lexeme :: (StringLike str, MonadParsec e s m, Token s ~ Tag str) => m (Tag str) -> m (Tag str)
- satisfy :: (StringLike str, MonadParsec e s m, Token s ~ Tag str) => (Tag str -> Bool) -> m (Tag str)
- anyTag :: (StringLike str, MonadParsec e s m, Token s ~ Tag str) => m (Tag str)
- anyTagOpen :: (StringLike str, MonadParsec e s m, Token s ~ Tag str) => m (Tag str)
- anyTagClose :: (StringLike str, MonadParsec e s m, Token s ~ Tag str) => m (Tag str)
- tagText :: (StringLike str, MonadParsec e s m, Token s ~ Tag str) => m (Tag str)
- tagOpen :: (StringLike str, MonadParsec e s m, Token s ~ Tag str) => str -> m (Tag str)
- tagClose :: (StringLike str, MonadParsec e s m, Token s ~ Tag str) => str -> m (Tag str)
Documentation
type TagParser str = Parsec Dec [Tag str] Source #
Different modules corresponding to various types of streams (String,
Text, ByteString) define it differently, so user can use “abstract”
Parser type and easily change it by importing different “type
modules”. This one is for TagSoup tags.
space :: (StringLike str, MonadParsec e s m, Token s ~ Tag str) => m (Tag str) Source #
Parses a text block containing only characters which satisfy isSpace.
whitespace :: (StringLike str, MonadParsec e s m, Token s ~ Tag str) => m () Source #
Parses any whitespace. Whitespace consists of zero or more ocurrences of space.
lexeme :: (StringLike str, MonadParsec e s m, Token s ~ Tag str) => m (Tag str) -> m (Tag str) Source #
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.
satisfy :: (StringLike str, MonadParsec e s m, Token s ~ Tag str) => (Tag str -> Bool) -> m (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.
anyTag :: (StringLike str, MonadParsec e s m, Token s ~ Tag str) => m (Tag str) Source #
Parses any tag. As all the tag parsers, it consumes the whitespace immediately after the parsed tag.
anyTagOpen :: (StringLike str, MonadParsec e s m, Token s ~ Tag str) => m (Tag str) Source #
Parse any opening tag. As all the tag parsers, it consumes the whitespace immediately after the parsed tag.
anyTagClose :: (StringLike str, MonadParsec e s m, Token s ~ Tag str) => m (Tag str) Source #
Parse any closing tag. As all the tag parsers, it consumes the whitespace immediately after the parsed tag.
tagText :: (StringLike str, MonadParsec e s m, Token s ~ Tag str) => m (Tag str) Source #
Parses a chunk of text. As all the tag parsers, it consumes the whitespace immediately after the parsed tag.
tagOpen :: (StringLike str, MonadParsec e s m, Token s ~ Tag str) => str -> m (Tag str) Source #
Parse the given opening tag. As all the tag parsers, these consume the whitespace immediately after the parsed tag.
tagClose :: (StringLike str, MonadParsec e s m, Token s ~ Tag str) => str -> m (Tag str) Source #
Parse the given closing tag. As all the tag parsers, these consume the whitespace immediately after the parsed tag.