commonmark-0.2.6.1: Pure Haskell commonmark parser.

Safe Haskell | None
Language | Haskell2010

Commonmark.Parser

Contents

- Exported from Text.Parsec.Error

Synopsis

- commonmark :: IsBlock il bl => String -> Text -> Either ParseError bl
- commonmarkWith :: (Monad m, IsBlock il bl, IsInline il) => SyntaxSpec m il bl -> String -> Text -> m (Either ParseError bl)
- parseCommonmarkWith :: (Monad m, IsBlock il bl, IsInline il) => SyntaxSpec m il bl -> [Tok] -> m (Either ParseError bl)
- data ParseError

# Documentation

commonmark Source #

Arguments

:: IsBlock il bl |
=> String | Name or path of input
-> Text | Commonmark text input
-> Either ParseError bl | Result or error

Parse a commonmark document using the core syntax elements. To produce HTML, instantiate `bl` with ``Html` ()` (see `Html`. If you want to add syntax extensions or run the parser in a monadic context, use `commonmarkWith`. If you want to operate on tokenized input, use `parseCommonmarkWith`.

commonmarkWith Source #

Arguments

:: (Monad m, IsBlock il bl, IsInline il) |
=> SyntaxSpec m il bl | Defines syntax
-> String | Name or path of input
-> Text | Commonmark text input
-> m (Either ParseError bl) | Result or error

Like `commonmark`, but allows specifying a custom syntax and a monadic context (since some syntax extensions may only be defined in certain monads, e.g. an extension for include files may require IO).

parseCommonmarkWith Source #

Arguments

:: (Monad m, IsBlock il bl, IsInline il) |
=> SyntaxSpec m il bl | Defines syntax
-> [Tok] | Tokenized commonmark input
-> m (Either ParseError bl) | Result or error

Parse a tokenized commonmark document using specified syntax elements. Use `tokenize` to convert `Text` into [`Tok`].

# Exported from Text.Parsec.Error

data ParseError Source #

The abstract data type `ParseError` represents parse errors. It provides the source position (`SourcePos`) of the error and a list of error messages (`Message`). A `ParseError` can be returned by the function `parse`. `ParseError` is an instance of the `Show` and `Eq` classes.

#### Instances

Instances details

Exception ParseError | Since: parsec-3.1.17.0
Instance details Defined in Text.Parsec.Error Methods toException :: ParseError -> SomeException Source # fromException :: SomeException -> Maybe ParseError Source # displayException :: ParseError -> String Source # backtraceDesired :: ParseError -> Bool Source #
Show ParseError |
Instance details Defined in Text.Parsec.Error Methods showsPrec :: Int -> ParseError -> ShowS Source # show :: ParseError -> String Source # showList :: [ParseError] -> ShowS Source #
Eq ParseError |
Instance details Defined in Text.Parsec.Error Methods (==) :: ParseError -> ParseError -> Bool Source # (/=) :: ParseError -> ParseError -> Bool Source #