{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE ScopedTypeVariables #-}
module Text.Pandoc.Readers.CommonMark (readCommonMark)
where
import Commonmark
import Commonmark.Extensions
import Commonmark.Pandoc
import Data.Text (Text)
import Text.Pandoc.Class.PandocMonad (PandocMonad)
import Text.Pandoc.Definition
import Text.Pandoc.Builder as B
import Text.Pandoc.Options
import Text.Pandoc.Error
import Text.Pandoc.Readers.Metadata (yamlMetaBlock)
import Control.Monad.Except
import Data.Functor.Identity (runIdentity)
import Data.Typeable
import Text.Pandoc.Parsing (runParserT, getInput,
runF, defaultParserState, option, many1, anyChar,
Sources(..), ToSources(..), ParserT, Future,
sourceName)
import qualified Data.Text as T
readCommonMark :: (PandocMonad m, ToSources a)
=> ReaderOptions -> a -> m Pandoc
readCommonMark :: ReaderOptions -> a -> m Pandoc
readCommonMark ReaderOptions
opts a
s
| Extension -> ReaderOptions -> Bool
forall a. HasSyntaxExtensions a => Extension -> a -> Bool
isEnabled Extension
Ext_yaml_metadata_block ReaderOptions
opts = do
let sources :: Sources
sources = a -> Sources
forall a. ToSources a => a -> Sources
toSources a
s
let toks :: [Tok]
toks = ((SourcePos, Text) -> [Tok]) -> [(SourcePos, Text)] -> [Tok]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap (SourcePos, Text) -> [Tok]
sourceToToks (Sources -> [(SourcePos, Text)]
unSources Sources
sources)
Either ParseError (Future ParserState Meta, Sources)
res <- ParsecT Sources ParserState m (Future ParserState Meta, Sources)
-> ParserState
-> SourceName
-> Sources
-> m (Either ParseError (Future ParserState Meta, Sources))
forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> u -> SourceName -> s -> m (Either ParseError a)
runParserT (do Future ParserState Meta
meta <- ParserT Sources ParserState m (Future ParserState MetaValue)
-> ParserT Sources ParserState m (Future ParserState Meta)
forall st (m :: * -> *).
(HasLastStrPosition st, PandocMonad m) =>
ParserT Sources st m (Future st MetaValue)
-> ParserT Sources st m (Future st Meta)
yamlMetaBlock (ReaderOptions
-> ParserT Sources ParserState m (Future ParserState MetaValue)
forall (m :: * -> *) st.
Monad m =>
ReaderOptions -> ParserT Sources st m (Future st MetaValue)
metaValueParser ReaderOptions
opts)
Sources
rest <- ParsecT Sources ParserState m Sources
forall (m :: * -> *) s u. Monad m => ParsecT s u m s
getInput
(Future ParserState Meta, Sources)
-> ParsecT Sources ParserState m (Future ParserState Meta, Sources)
forall (m :: * -> *) a. Monad m => a -> m a
return (Future ParserState Meta
meta, Sources
rest))
ParserState
defaultParserState SourceName
"YAML metadata" (a -> Sources
forall a. ToSources a => a -> Sources
toSources a
s)
case Either ParseError (Future ParserState Meta, Sources)
res of
Left ParseError
_ -> ReaderOptions -> Sources -> [Tok] -> m Pandoc
forall (m :: * -> *).
PandocMonad m =>
ReaderOptions -> Sources -> [Tok] -> m Pandoc
readCommonMarkBody ReaderOptions
opts Sources
sources [Tok]
toks
Right (Future ParserState Meta
meta, Sources
rest) -> do
let body :: [Tok]
body = ((SourcePos, Text) -> [Tok]) -> [(SourcePos, Text)] -> [Tok]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap (SourcePos, Text) -> [Tok]
sourceToToks (Sources -> [(SourcePos, Text)]
unSources Sources
rest)
Pandoc Meta
_ [Block]
bs <- ReaderOptions -> Sources -> [Tok] -> m Pandoc
forall (m :: * -> *).
PandocMonad m =>
ReaderOptions -> Sources -> [Tok] -> m Pandoc
readCommonMarkBody ReaderOptions
opts Sources
sources [Tok]
body
Pandoc -> m Pandoc
forall (m :: * -> *) a. Monad m => a -> m a
return (Pandoc -> m Pandoc) -> Pandoc -> m Pandoc
forall a b. (a -> b) -> a -> b
$ Meta -> [Block] -> Pandoc
Pandoc (Future ParserState Meta -> ParserState -> Meta
forall s a. Future s a -> s -> a
runF Future ParserState Meta
meta ParserState
defaultParserState) [Block]
bs
| Bool
otherwise = do
let sources :: Sources
sources = a -> Sources
forall a. ToSources a => a -> Sources
toSources a
s
let toks :: [Tok]
toks = ((SourcePos, Text) -> [Tok]) -> [(SourcePos, Text)] -> [Tok]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap (SourcePos, Text) -> [Tok]
sourceToToks (Sources -> [(SourcePos, Text)]
unSources Sources
sources)
ReaderOptions -> Sources -> [Tok] -> m Pandoc
forall (m :: * -> *).
PandocMonad m =>
ReaderOptions -> Sources -> [Tok] -> m Pandoc
readCommonMarkBody ReaderOptions
opts Sources
sources [Tok]
toks
sourceToToks :: (SourcePos, Text) -> [Tok]
sourceToToks :: (SourcePos, Text) -> [Tok]
sourceToToks (SourcePos
pos, Text
s) = SourceName -> Text -> [Tok]
tokenize (SourcePos -> SourceName
sourceName SourcePos
pos) Text
s
metaValueParser :: Monad m
=> ReaderOptions -> ParserT Sources st m (Future st MetaValue)
metaValueParser :: ReaderOptions -> ParserT Sources st m (Future st MetaValue)
metaValueParser ReaderOptions
opts = do
Text
inp <- Text -> ParsecT Sources st m Text -> ParsecT Sources st m Text
forall s (m :: * -> *) t a u.
Stream s m t =>
a -> ParsecT s u m a -> ParsecT s u m a
option Text
"" (ParsecT Sources st m Text -> ParsecT Sources st m Text)
-> ParsecT Sources st m Text -> ParsecT Sources st m Text
forall a b. (a -> b) -> a -> b
$ SourceName -> Text
T.pack (SourceName -> Text)
-> ParsecT Sources st m SourceName -> ParsecT Sources st m Text
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT Sources st m Char -> ParsecT Sources st m SourceName
forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m [a]
many1 ParsecT Sources st m Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s u m Char
anyChar
let toks :: [Tok]
toks = ((SourcePos, Text) -> [Tok]) -> [(SourcePos, Text)] -> [Tok]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap (SourcePos, Text) -> [Tok]
sourceToToks (Sources -> [(SourcePos, Text)]
unSources (Text -> Sources
forall a. ToSources a => a -> Sources
toSources Text
inp))
case Identity (Either ParseError (Cm () Blocks))
-> Either ParseError (Cm () Blocks)
forall a. Identity a -> a
runIdentity (SyntaxSpec Identity (Cm () Inlines) (Cm () Blocks)
-> [Tok] -> Identity (Either ParseError (Cm () Blocks))
forall (m :: * -> *) il bl.
(Monad m, IsBlock il bl, IsInline il) =>
SyntaxSpec m il bl -> [Tok] -> m (Either ParseError bl)
parseCommonmarkWith (ReaderOptions -> SyntaxSpec Identity (Cm () Inlines) (Cm () Blocks)
forall (m :: * -> *) a.
(Monad m, Typeable m, Typeable a, Rangeable (Cm a Inlines),
Rangeable (Cm a Blocks)) =>
ReaderOptions -> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
specFor ReaderOptions
opts) [Tok]
toks) of
Left ParseError
_ -> ParserT Sources st m (Future st MetaValue)
forall (m :: * -> *) a. MonadPlus m => m a
mzero
Right (Cm Blocks
bls :: Cm () Blocks) -> Future st MetaValue -> ParserT Sources st m (Future st MetaValue)
forall (m :: * -> *) a. Monad m => a -> m a
return (Future st MetaValue -> ParserT Sources st m (Future st MetaValue))
-> Future st MetaValue
-> ParserT Sources st m (Future st MetaValue)
forall a b. (a -> b) -> a -> b
$ MetaValue -> Future st MetaValue
forall (m :: * -> *) a. Monad m => a -> m a
return (MetaValue -> Future st MetaValue)
-> MetaValue -> Future st MetaValue
forall a b. (a -> b) -> a -> b
$ Blocks -> MetaValue
forall a. ToMetaValue a => a -> MetaValue
B.toMetaValue Blocks
bls
readCommonMarkBody :: PandocMonad m => ReaderOptions -> Sources -> [Tok] -> m Pandoc
readCommonMarkBody :: ReaderOptions -> Sources -> [Tok] -> m Pandoc
readCommonMarkBody ReaderOptions
opts Sources
s [Tok]
toks
| Extension -> ReaderOptions -> Bool
forall a. HasSyntaxExtensions a => Extension -> a -> Bool
isEnabled Extension
Ext_sourcepos ReaderOptions
opts =
case Identity (Either ParseError (Cm SourceRange Blocks))
-> Either ParseError (Cm SourceRange Blocks)
forall a. Identity a -> a
runIdentity (SyntaxSpec
Identity (Cm SourceRange Inlines) (Cm SourceRange Blocks)
-> [Tok] -> Identity (Either ParseError (Cm SourceRange Blocks))
forall (m :: * -> *) il bl.
(Monad m, IsBlock il bl, IsInline il) =>
SyntaxSpec m il bl -> [Tok] -> m (Either ParseError bl)
parseCommonmarkWith (ReaderOptions
-> SyntaxSpec
Identity (Cm SourceRange Inlines) (Cm SourceRange Blocks)
forall (m :: * -> *) a.
(Monad m, Typeable m, Typeable a, Rangeable (Cm a Inlines),
Rangeable (Cm a Blocks)) =>
ReaderOptions -> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
specFor ReaderOptions
opts) [Tok]
toks) of
Left ParseError
err -> PandocError -> m Pandoc
forall e (m :: * -> *) a. MonadError e m => e -> m a
throwError (PandocError -> m Pandoc) -> PandocError -> m Pandoc
forall a b. (a -> b) -> a -> b
$ Sources -> ParseError -> PandocError
PandocParsecError Sources
s ParseError
err
Right (Cm Blocks
bls :: Cm SourceRange Blocks) -> Pandoc -> m Pandoc
forall (m :: * -> *) a. Monad m => a -> m a
return (Pandoc -> m Pandoc) -> Pandoc -> m Pandoc
forall a b. (a -> b) -> a -> b
$ Blocks -> Pandoc
B.doc Blocks
bls
| Bool
otherwise =
case Identity (Either ParseError (Cm () Blocks))
-> Either ParseError (Cm () Blocks)
forall a. Identity a -> a
runIdentity (SyntaxSpec Identity (Cm () Inlines) (Cm () Blocks)
-> [Tok] -> Identity (Either ParseError (Cm () Blocks))
forall (m :: * -> *) il bl.
(Monad m, IsBlock il bl, IsInline il) =>
SyntaxSpec m il bl -> [Tok] -> m (Either ParseError bl)
parseCommonmarkWith (ReaderOptions -> SyntaxSpec Identity (Cm () Inlines) (Cm () Blocks)
forall (m :: * -> *) a.
(Monad m, Typeable m, Typeable a, Rangeable (Cm a Inlines),
Rangeable (Cm a Blocks)) =>
ReaderOptions -> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
specFor ReaderOptions
opts) [Tok]
toks) of
Left ParseError
err -> PandocError -> m Pandoc
forall e (m :: * -> *) a. MonadError e m => e -> m a
throwError (PandocError -> m Pandoc) -> PandocError -> m Pandoc
forall a b. (a -> b) -> a -> b
$ Sources -> ParseError -> PandocError
PandocParsecError Sources
s ParseError
err
Right (Cm Blocks
bls :: Cm () Blocks) -> Pandoc -> m Pandoc
forall (m :: * -> *) a. Monad m => a -> m a
return (Pandoc -> m Pandoc) -> Pandoc -> m Pandoc
forall a b. (a -> b) -> a -> b
$ Blocks -> Pandoc
B.doc Blocks
bls
specFor :: (Monad m, Typeable m, Typeable a,
Rangeable (Cm a Inlines), Rangeable (Cm a Blocks))
=> ReaderOptions -> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
specFor :: ReaderOptions -> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
specFor ReaderOptions
opts = ((SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks))
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks))
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> [SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)]
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr (SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks))
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
forall a b. (a -> b) -> a -> b
($) SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
forall (m :: * -> *) il bl.
(Monad m, IsBlock il bl, IsInline il) =>
SyntaxSpec m il bl
defaultSyntaxSpec [SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)]
exts
where
exts :: [SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)]
exts = [ (SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
forall (m :: * -> *) il bl.
(Monad m, IsBlock il bl, IsInline il) =>
SyntaxSpec m il bl
hardLineBreaksSpec SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
forall a. Semigroup a => a -> a -> a
<>) | Extension -> ReaderOptions -> Bool
forall a. HasSyntaxExtensions a => Extension -> a -> Bool
isEnabled Extension
Ext_hard_line_breaks ReaderOptions
opts ] [SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)]
-> [SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)]
-> [SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)]
forall a. [a] -> [a] -> [a]
++
[ (SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
forall (m :: * -> *) il bl.
(Monad m, IsBlock il bl, IsInline il, HasQuoted il) =>
SyntaxSpec m il bl
smartPunctuationSpec SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
forall a. Semigroup a => a -> a -> a
<>) | Extension -> ReaderOptions -> Bool
forall a. HasSyntaxExtensions a => Extension -> a -> Bool
isEnabled Extension
Ext_smart ReaderOptions
opts ] [SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)]
-> [SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)]
-> [SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)]
forall a. [a] -> [a] -> [a]
++
[ (SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
forall (m :: * -> *) il bl.
(Monad m, IsBlock il bl, IsInline il, HasStrikethrough il) =>
SyntaxSpec m il bl
strikethroughSpec SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
forall a. Semigroup a => a -> a -> a
<>) | Extension -> ReaderOptions -> Bool
forall a. HasSyntaxExtensions a => Extension -> a -> Bool
isEnabled Extension
Ext_strikeout ReaderOptions
opts ] [SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)]
-> [SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)]
-> [SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)]
forall a. [a] -> [a] -> [a]
++
[ (SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
forall (m :: * -> *) il bl.
(Monad m, IsBlock il bl, IsInline il, HasSuperscript il) =>
SyntaxSpec m il bl
superscriptSpec SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
forall a. Semigroup a => a -> a -> a
<>) | Extension -> ReaderOptions -> Bool
forall a. HasSyntaxExtensions a => Extension -> a -> Bool
isEnabled Extension
Ext_superscript ReaderOptions
opts ] [SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)]
-> [SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)]
-> [SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)]
forall a. [a] -> [a] -> [a]
++
[ (SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
forall (m :: * -> *) il bl.
(Monad m, IsBlock il bl, IsInline il, HasSubscript il) =>
SyntaxSpec m il bl
subscriptSpec SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
forall a. Semigroup a => a -> a -> a
<>) | Extension -> ReaderOptions -> Bool
forall a. HasSyntaxExtensions a => Extension -> a -> Bool
isEnabled Extension
Ext_subscript ReaderOptions
opts ] [SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)]
-> [SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)]
-> [SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)]
forall a. [a] -> [a] -> [a]
++
[ (SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
forall (m :: * -> *) il bl.
(Monad m, IsBlock il bl, IsInline il, HasMath il) =>
SyntaxSpec m il bl
mathSpec SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
forall a. Semigroup a => a -> a -> a
<>) | Extension -> ReaderOptions -> Bool
forall a. HasSyntaxExtensions a => Extension -> a -> Bool
isEnabled Extension
Ext_tex_math_dollars ReaderOptions
opts ] [SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)]
-> [SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)]
-> [SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)]
forall a. [a] -> [a] -> [a]
++
[ (SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
forall (m :: * -> *) il bl.
(Monad m, IsBlock il bl, IsInline il) =>
SyntaxSpec m il bl
fancyListSpec SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
forall a. Semigroup a => a -> a -> a
<>) | Extension -> ReaderOptions -> Bool
forall a. HasSyntaxExtensions a => Extension -> a -> Bool
isEnabled Extension
Ext_fancy_lists ReaderOptions
opts ] [SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)]
-> [SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)]
-> [SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)]
forall a. [a] -> [a] -> [a]
++
[ (SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
forall (m :: * -> *) il bl.
(Monad m, IsInline il, IsBlock il bl, HasDiv bl) =>
SyntaxSpec m il bl
fencedDivSpec SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
forall a. Semigroup a => a -> a -> a
<>) | Extension -> ReaderOptions -> Bool
forall a. HasSyntaxExtensions a => Extension -> a -> Bool
isEnabled Extension
Ext_fenced_divs ReaderOptions
opts ] [SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)]
-> [SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)]
-> [SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)]
forall a. [a] -> [a] -> [a]
++
[ (SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
forall (m :: * -> *) il bl.
(Monad m, IsInline il, HasSpan il) =>
SyntaxSpec m il bl
bracketedSpanSpec SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
forall a. Semigroup a => a -> a -> a
<>) | Extension -> ReaderOptions -> Bool
forall a. HasSyntaxExtensions a => Extension -> a -> Bool
isEnabled Extension
Ext_bracketed_spans ReaderOptions
opts ] [SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)]
-> [SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)]
-> [SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)]
forall a. [a] -> [a] -> [a]
++
[ (SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
forall (m :: * -> *) il bl.
(Monad m, IsBlock il bl) =>
SyntaxSpec m il bl
rawAttributeSpec SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
forall a. Semigroup a => a -> a -> a
<>) | Extension -> ReaderOptions -> Bool
forall a. HasSyntaxExtensions a => Extension -> a -> Bool
isEnabled Extension
Ext_raw_attribute ReaderOptions
opts ] [SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)]
-> [SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)]
-> [SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)]
forall a. [a] -> [a] -> [a]
++
[ (SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
forall (m :: * -> *) il bl.
(Monad m, IsInline il) =>
SyntaxSpec m il bl
attributesSpec SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
forall a. Semigroup a => a -> a -> a
<>) | Extension -> ReaderOptions -> Bool
forall a. HasSyntaxExtensions a => Extension -> a -> Bool
isEnabled Extension
Ext_attributes ReaderOptions
opts ] [SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)]
-> [SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)]
-> [SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)]
forall a. [a] -> [a] -> [a]
++
[ (SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
forall a. Semigroup a => a -> a -> a
<> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
forall (m :: * -> *) il bl.
(Monad m, IsBlock il bl, IsInline il, HasPipeTable il bl) =>
SyntaxSpec m il bl
pipeTableSpec) | Extension -> ReaderOptions -> Bool
forall a. HasSyntaxExtensions a => Extension -> a -> Bool
isEnabled Extension
Ext_pipe_tables ReaderOptions
opts ] [SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)]
-> [SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)]
-> [SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)]
forall a. [a] -> [a] -> [a]
++
[ (SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
forall (m :: * -> *) il bl.
(Monad m, IsBlock il bl, IsInline il) =>
SyntaxSpec m il bl
autolinkSpec SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
forall a. Semigroup a => a -> a -> a
<>) | Extension -> ReaderOptions -> Bool
forall a. HasSyntaxExtensions a => Extension -> a -> Bool
isEnabled Extension
Ext_autolink_bare_uris ReaderOptions
opts ] [SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)]
-> [SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)]
-> [SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)]
forall a. [a] -> [a] -> [a]
++
[ (SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
forall (m :: * -> *) il bl.
(Monad m, IsBlock il bl, IsInline il, HasEmoji il) =>
SyntaxSpec m il bl
emojiSpec SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
forall a. Semigroup a => a -> a -> a
<>) | Extension -> ReaderOptions -> Bool
forall a. HasSyntaxExtensions a => Extension -> a -> Bool
isEnabled Extension
Ext_emoji ReaderOptions
opts ] [SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)]
-> [SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)]
-> [SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)]
forall a. [a] -> [a] -> [a]
++
[ (SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
forall (m :: * -> *) il bl.
(Monad m, IsBlock il bl, IsInline il, ToPlainText il) =>
SyntaxSpec m il bl
autoIdentifiersSpec SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
forall a. Semigroup a => a -> a -> a
<>)
| Extension -> ReaderOptions -> Bool
forall a. HasSyntaxExtensions a => Extension -> a -> Bool
isEnabled Extension
Ext_gfm_auto_identifiers ReaderOptions
opts
, Bool -> Bool
not (Extension -> ReaderOptions -> Bool
forall a. HasSyntaxExtensions a => Extension -> a -> Bool
isEnabled Extension
Ext_ascii_identifiers ReaderOptions
opts) ] [SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)]
-> [SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)]
-> [SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)]
forall a. [a] -> [a] -> [a]
++
[ (SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
forall (m :: * -> *) il bl.
(Monad m, IsBlock il bl, IsInline il, ToPlainText il) =>
SyntaxSpec m il bl
autoIdentifiersAsciiSpec SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
forall a. Semigroup a => a -> a -> a
<>)
| Extension -> ReaderOptions -> Bool
forall a. HasSyntaxExtensions a => Extension -> a -> Bool
isEnabled Extension
Ext_gfm_auto_identifiers ReaderOptions
opts
, Extension -> ReaderOptions -> Bool
forall a. HasSyntaxExtensions a => Extension -> a -> Bool
isEnabled Extension
Ext_ascii_identifiers ReaderOptions
opts ] [SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)]
-> [SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)]
-> [SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)]
forall a. [a] -> [a] -> [a]
++
[ (SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
forall (m :: * -> *) il bl.
(Monad m, IsBlock il bl, IsInline il) =>
SyntaxSpec m il bl
implicitHeadingReferencesSpec SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
forall a. Semigroup a => a -> a -> a
<>)
| Extension -> ReaderOptions -> Bool
forall a. HasSyntaxExtensions a => Extension -> a -> Bool
isEnabled Extension
Ext_implicit_header_references ReaderOptions
opts ] [SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)]
-> [SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)]
-> [SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)]
forall a. [a] -> [a] -> [a]
++
[ (SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
forall (m :: * -> *) il bl.
(Monad m, Typeable m, IsBlock il bl, IsInline il, Typeable il,
Typeable bl, HasFootnote il bl) =>
SyntaxSpec m il bl
footnoteSpec SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
forall a. Semigroup a => a -> a -> a
<>) | Extension -> ReaderOptions -> Bool
forall a. HasSyntaxExtensions a => Extension -> a -> Bool
isEnabled Extension
Ext_footnotes ReaderOptions
opts ] [SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)]
-> [SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)]
-> [SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)]
forall a. [a] -> [a] -> [a]
++
[ (SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
forall (m :: * -> *) il bl.
(Monad m, IsBlock il bl, IsInline il, Typeable il, Typeable bl,
HasDefinitionList il bl) =>
SyntaxSpec m il bl
definitionListSpec SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
forall a. Semigroup a => a -> a -> a
<>) | Extension -> ReaderOptions -> Bool
forall a. HasSyntaxExtensions a => Extension -> a -> Bool
isEnabled Extension
Ext_definition_lists ReaderOptions
opts ] [SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)]
-> [SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)]
-> [SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)]
forall a. [a] -> [a] -> [a]
++
[ (SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
forall (m :: * -> *) il bl.
(Monad m, IsBlock il bl, IsInline il, HasTaskList il bl) =>
SyntaxSpec m il bl
taskListSpec SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
forall a. Semigroup a => a -> a -> a
<>) | Extension -> ReaderOptions -> Bool
forall a. HasSyntaxExtensions a => Extension -> a -> Bool
isEnabled Extension
Ext_task_lists ReaderOptions
opts ] [SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)]
-> [SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)]
-> [SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)]
forall a. [a] -> [a] -> [a]
++
[ (SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
forall (m :: * -> *) bl il.
(Monad m, IsInline il, IsBlock il bl) =>
SyntaxSpec m il bl
rebaseRelativePathsSpec SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
-> SyntaxSpec m (Cm a Inlines) (Cm a Blocks)
forall a. Semigroup a => a -> a -> a
<>)
| Extension -> ReaderOptions -> Bool
forall a. HasSyntaxExtensions a => Extension -> a -> Bool
isEnabled Extension
Ext_rebase_relative_paths ReaderOptions
opts ]