module Commonmark.Parser
( commonmark
, commonmarkWith
, parseCommonmarkWith
, ParseError
) where
import Commonmark.Blocks
import Commonmark.Inlines
import Commonmark.Tokens
import Commonmark.Types
import Commonmark.Syntax (SyntaxSpec(..), defaultSyntaxSpec)
import Text.Parsec.Error (ParseError)
import Data.Functor.Identity (runIdentity)
import Data.Text (Text)
commonmark :: IsBlock il bl
=> String
-> Text
-> Either ParseError bl
commonmark sourcename =
runIdentity .
parseCommonmarkWith defaultSyntaxSpec .
tokenize sourcename
commonmarkWith :: (Monad m, IsBlock il bl, IsInline il)
=> SyntaxSpec m il bl
-> String
-> Text
-> m (Either ParseError bl)
commonmarkWith syntax sourcename =
parseCommonmarkWith syntax .
tokenize sourcename
parseCommonmarkWith :: (Monad m, IsBlock il bl, IsInline il)
=> SyntaxSpec m il bl
-> [Tok]
-> m (Either ParseError bl)
parseCommonmarkWith syntax =
mkBlockParser (syntaxBlockSpecs syntax)
(syntaxFinalParsers syntax)
(mkInlineParser (syntaxBracketedSpecs syntax)
(syntaxFormattingSpecs syntax)
(syntaxInlineParsers syntax)
(syntaxAttributeParsers syntax))
(syntaxAttributeParsers syntax)