{-# LANGUAGE OverloadedStrings #-}
module Text.Pandoc.Readers.Creole ( readCreole
) where
import Control.Monad
import Control.Monad.Except (throwError)
import qualified Data.Foldable as F
import Data.Maybe (fromMaybe)
import Data.Text (Text)
import qualified Data.Text as T
import qualified Text.Pandoc.Builder as B
import Text.Pandoc.Class.PandocMonad (PandocMonad (..))
import Text.Pandoc.Definition
import Text.Pandoc.Options
import Text.Pandoc.Parsing hiding (enclosed)
readCreole :: (PandocMonad m, ToSources a)
=> ReaderOptions
-> a
-> m Pandoc
readCreole :: forall (m :: * -> *) a.
(PandocMonad m, ToSources a) =>
ReaderOptions -> a -> m Pandoc
readCreole ReaderOptions
opts a
s = do
let sources :: Sources
sources = Int -> Sources -> Sources
ensureFinalNewlines Int
2 (forall a. ToSources a => a -> Sources
toSources a
s)
Either PandocError Pandoc
res <- forall (m :: * -> *) t st a.
(Monad m, ToSources t) =>
ParsecT Sources st m a -> st -> t -> m (Either PandocError a)
readWithM forall (m :: * -> *). PandocMonad m => CRLParser m Pandoc
parseCreole forall a. Default a => a
def{ stateOptions :: ReaderOptions
stateOptions = ReaderOptions
opts } Sources
sources
case Either PandocError Pandoc
res of
Left PandocError
e -> forall e (m :: * -> *) a. MonadError e m => e -> m a
throwError PandocError
e
Right Pandoc
d -> forall (m :: * -> *) a. Monad m => a -> m a
return Pandoc
d
type CRLParser = ParsecT Sources ParserState
(<+>) :: (Monad m, Semigroup a) => m a -> m a -> m a
<+> :: forall (m :: * -> *) a. (Monad m, Semigroup a) => m a -> m a -> m a
(<+>) = forall (m :: * -> *) a1 a2 r.
Monad m =>
(a1 -> a2 -> r) -> m a1 -> m a2 -> m r
liftM2 forall a. Semigroup a => a -> a -> a
(<>)
enclosed :: (Show end, PandocMonad m) => CRLParser m start
-> CRLParser m end
-> CRLParser m a
-> CRLParser m [a]
enclosed :: forall end (m :: * -> *) start a.
(Show end, PandocMonad m) =>
CRLParser m start
-> CRLParser m end -> CRLParser m a -> CRLParser m [a]
enclosed CRLParser m start
start CRLParser m end
end CRLParser m a
parser = forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try forall a b. (a -> b) -> a -> b
$ CRLParser m start
start forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall end s (m :: * -> *) t st a.
(Show end, Stream s m t) =>
ParsecT s st m a -> ParsecT s st m end -> ParsecT s st m [a]
many1Till CRLParser m a
parser CRLParser m end
end
specialChars :: [Char]
specialChars :: [Char]
specialChars = [Char]
"*/~{}\\|[]()<>\"'"
parseCreole :: PandocMonad m => CRLParser m Pandoc
parseCreole :: forall (m :: * -> *). PandocMonad m => CRLParser m Pandoc
parseCreole = do
Blocks
bs <- forall a. Monoid a => [a] -> a
mconcat forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
many forall (m :: * -> *). PandocMonad m => CRLParser m Blocks
block
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s u m ()
spaces
forall s (m :: * -> *) t u.
(Stream s m t, Show t) =>
ParsecT s u m ()
eof
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ Blocks -> Pandoc
B.doc Blocks
bs
block :: PandocMonad m => CRLParser m B.Blocks
block :: forall (m :: * -> *). PandocMonad m => CRLParser m Blocks
block = do
Blocks
res <- forall a. Monoid a => a
mempty forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m ()
skipMany1 forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s st m Char
blankline
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> forall (m :: * -> *). PandocMonad m => CRLParser m Blocks
nowiki
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> forall (m :: * -> *). PandocMonad m => CRLParser m Blocks
header
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> forall (m :: * -> *). PandocMonad m => CRLParser m Blocks
horizontalRule
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> forall (m :: * -> *). PandocMonad m => Int -> CRLParser m Blocks
anyList Int
1
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> forall (m :: * -> *). PandocMonad m => CRLParser m Blocks
table
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> forall (m :: * -> *). PandocMonad m => CRLParser m Blocks
para
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m ()
skipMany forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s st m Char
blankline
forall (m :: * -> *) a. Monad m => a -> m a
return Blocks
res
nowiki :: PandocMonad m => CRLParser m B.Blocks
nowiki :: forall (m :: * -> *). PandocMonad m => CRLParser m Blocks
nowiki = forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try forall a b. (a -> b) -> a -> b
$ forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (Text -> Blocks
B.codeBlock forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Monoid a => [a] -> a
mconcat) (forall {u}. ParsecT Sources u m Char
nowikiStart
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall s (m :: * -> *) t u a end.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m end -> ParsecT s u m [a]
manyTill ParsecT Sources ParserState m Text
content ParsecT Sources ParserState m Char
nowikiEnd)
where
content :: ParsecT Sources ParserState m Text
content = ParsecT Sources ParserState m Text
brackets forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> ParsecT Sources ParserState m Text
line
brackets :: ParsecT Sources ParserState m Text
brackets = forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try forall a b. (a -> b) -> a -> b
$ forall s (m :: * -> *) t a u.
Stream s m t =>
a -> ParsecT s u m a -> ParsecT s u m a
option Text
"" (Char -> Text
T.singleton forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s u m Char
newline)
forall (m :: * -> *) a. (Monad m, Semigroup a) => m a -> m a -> m a
<+> (forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
Char -> ParsecT s u m Char
char Char
' ' forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> (forall s (m :: * -> *) t st.
Stream s m t =>
ParsecT s st m Char -> ParsecT s st m Text
manyChar (forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
Char -> ParsecT s u m Char
char Char
' ') forall (m :: * -> *) a. (Monad m, Semigroup a) => m a -> m a -> m a
<+> forall s (m :: * -> *) u.
(Stream s m Char, UpdateSourcePos s Char) =>
Text -> ParsecT s u m Text
textStr Text
"}}}") forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* ParsecT Sources ParserState m Char
eol)
line :: ParsecT Sources ParserState m Text
line = forall s (m :: * -> *) t a u.
Stream s m t =>
a -> ParsecT s u m a -> ParsecT s u m a
option Text
"" (Char -> Text
T.singleton forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s u m Char
newline) forall (m :: * -> *) a. (Monad m, Semigroup a) => m a -> m a -> m a
<+> forall s (m :: * -> *) t st a.
Stream s m t =>
ParsecT s st m Char -> ParsecT s st m a -> ParsecT s st m Text
manyTillChar forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s u m Char
anyChar ParsecT Sources ParserState m Char
eol
eol :: ParsecT Sources ParserState m Char
eol = forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m a
lookAhead forall a b. (a -> b) -> a -> b
$ forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try forall a b. (a -> b) -> a -> b
$ ParsecT Sources ParserState m Char
nowikiEnd forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s u m Char
newline
nowikiStart :: ParsecT Sources u m Char
nowikiStart = forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m ()
optional forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s u m Char
newline forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
[Char] -> ParsecT s u m [Char]
string [Char]
"{{{" forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m ()
skipMany forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s st m Char
spaceChar forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s u m Char
newline
nowikiEnd :: ParsecT Sources ParserState m Char
nowikiEnd = forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *). PandocMonad m => CRLParser m Inlines
linebreak forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
[Char] -> ParsecT s u m [Char]
string [Char]
"}}}" forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m ()
skipMany forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s st m Char
spaceChar forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s u m Char
newline
header :: PandocMonad m => CRLParser m B.Blocks
= forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try forall a b. (a -> b) -> a -> b
$ do
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s st m ()
skipSpaces
Int
level <-
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall (t :: * -> *) a. Foldable t => t a -> Int
length (forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m [a]
many1 (forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
Char -> ParsecT s u m Char
char Char
'='))
forall (f :: * -> *). Alternative f => Bool -> f ()
guard forall a b. (a -> b) -> a -> b
$ Int
level forall a. Ord a => a -> a -> Bool
<= Int
6
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s st m ()
skipSpaces
Inlines
content <- Text -> Inlines
B.str forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall s (m :: * -> *) t st a.
Stream s m t =>
ParsecT s st m Char -> ParsecT s st m a -> ParsecT s st m Text
manyTillChar (forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
[Char] -> ParsecT s u m Char
noneOf [Char]
"\n") forall {u}. ParsecT Sources u m Char
headerEnd
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ Int -> Inlines -> Blocks
B.header Int
level Inlines
content
where
headerEnd :: ParsecT Sources u m Char
headerEnd = forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try forall a b. (a -> b) -> a -> b
$ forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s st m ()
skipSpaces forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
many (forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
Char -> ParsecT s u m Char
char Char
'=') forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s st m ()
skipSpaces forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s u m Char
newline
unorderedList :: PandocMonad m => Int -> CRLParser m B.Blocks
unorderedList :: forall (m :: * -> *). PandocMonad m => Int -> CRLParser m Blocks
unorderedList = forall (m :: * -> *).
PandocMonad m =>
Char -> ([Blocks] -> Blocks) -> Int -> CRLParser m Blocks
list Char
'*' [Blocks] -> Blocks
B.bulletList
orderedList :: PandocMonad m => Int -> CRLParser m B.Blocks
orderedList :: forall (m :: * -> *). PandocMonad m => Int -> CRLParser m Blocks
orderedList = forall (m :: * -> *).
PandocMonad m =>
Char -> ([Blocks] -> Blocks) -> Int -> CRLParser m Blocks
list Char
'#' [Blocks] -> Blocks
B.orderedList
anyList :: PandocMonad m => Int -> CRLParser m B.Blocks
anyList :: forall (m :: * -> *). PandocMonad m => Int -> CRLParser m Blocks
anyList Int
n = forall (m :: * -> *). PandocMonad m => Int -> CRLParser m Blocks
unorderedList Int
n forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> forall (m :: * -> *). PandocMonad m => Int -> CRLParser m Blocks
orderedList Int
n
anyListItem :: PandocMonad m => Int -> CRLParser m B.Blocks
anyListItem :: forall (m :: * -> *). PandocMonad m => Int -> CRLParser m Blocks
anyListItem Int
n = forall (m :: * -> *).
PandocMonad m =>
Char -> Int -> CRLParser m Blocks
listItem Char
'*' Int
n forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> forall (m :: * -> *).
PandocMonad m =>
Char -> Int -> CRLParser m Blocks
listItem Char
'#' Int
n
list :: PandocMonad m => Char -> ([B.Blocks] -> B.Blocks) -> Int -> CRLParser m B.Blocks
list :: forall (m :: * -> *).
PandocMonad m =>
Char -> ([Blocks] -> Blocks) -> Int -> CRLParser m Blocks
list Char
c [Blocks] -> Blocks
f Int
n =
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap [Blocks] -> Blocks
f (forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m [a]
many1 (ParsecT Sources ParserState m Blocks
itemPlusSublist forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> forall (m :: * -> *).
PandocMonad m =>
Char -> Int -> CRLParser m Blocks
listItem Char
c Int
n))
where itemPlusSublist :: ParsecT Sources ParserState m Blocks
itemPlusSublist = forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *).
PandocMonad m =>
Char -> Int -> CRLParser m Blocks
listItem Char
c Int
n forall (m :: * -> *) a. (Monad m, Semigroup a) => m a -> m a -> m a
<+> forall (m :: * -> *). PandocMonad m => Int -> CRLParser m Blocks
anyList (Int
nforall a. Num a => a -> a -> a
+Int
1)
listItem :: PandocMonad m => Char -> Int -> CRLParser m B.Blocks
listItem :: forall (m :: * -> *).
PandocMonad m =>
Char -> Int -> CRLParser m Blocks
listItem Char
c Int
n =
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (Inlines -> Blocks
B.plain forall b c a. (b -> c) -> (a -> b) -> a -> c
. Inlines -> Inlines
B.trimInlines forall b c a. (b -> c) -> (a -> b) -> a -> c
.forall a. Monoid a => [a] -> a
mconcat) (forall {u}. ParsecT Sources u m ()
listStart forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall end s (m :: * -> *) t st a.
(Show end, Stream s m t) =>
ParsecT s st m a -> ParsecT s st m end -> ParsecT s st m [a]
many1Till forall (m :: * -> *). PandocMonad m => CRLParser m Inlines
inline ParsecT Sources ParserState m ()
itemEnd)
where
listStart :: ParsecT Sources u m ()
listStart = forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try forall a b. (a -> b) -> a -> b
$ forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s st m ()
skipSpaces forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m ()
optional forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s u m Char
newline forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s st m ()
skipSpaces
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall s (m :: * -> *) t u a.
Stream s m t =>
Int -> ParsecT s u m a -> ParsecT s u m [a]
count Int
n (forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
Char -> ParsecT s u m Char
char Char
c)
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m a
lookAhead (forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
[Char] -> ParsecT s u m Char
noneOf [Char
c]) forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s st m ()
skipSpaces
itemEnd :: ParsecT Sources ParserState m ()
itemEnd = forall (m :: * -> *). PandocMonad m => CRLParser m ()
endOfParaElement forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> forall {m :: * -> *} {a}.
(PandocMonad m, Monoid a) =>
Int -> ParsecT Sources ParserState m a
nextItem Int
n
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> if Int
n forall a. Ord a => a -> a -> Bool
< Int
3 then forall {m :: * -> *} {a}.
(PandocMonad m, Monoid a) =>
Int -> ParsecT Sources ParserState m a
nextItem (Int
nforall a. Num a => a -> a -> a
+Int
1)
else forall {m :: * -> *} {a}.
(PandocMonad m, Monoid a) =>
Int -> ParsecT Sources ParserState m a
nextItem (Int
nforall a. Num a => a -> a -> a
+Int
1) forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> forall {m :: * -> *} {a}.
(PandocMonad m, Monoid a) =>
Int -> ParsecT Sources ParserState m a
nextItem (Int
nforall a. Num a => a -> a -> a
-Int
1)
nextItem :: Int -> ParsecT Sources ParserState m a
nextItem Int
x = forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m a
lookAhead forall a b. (a -> b) -> a -> b
$ forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try forall a b. (a -> b) -> a -> b
$ forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s st m Char
blankline forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall (m :: * -> *). PandocMonad m => Int -> CRLParser m Blocks
anyListItem Int
x forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall (m :: * -> *) a. Monad m => a -> m a
return forall a. Monoid a => a
mempty
table :: PandocMonad m => CRLParser m B.Blocks
table :: forall (m :: * -> *). PandocMonad m => CRLParser m Blocks
table = forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try forall a b. (a -> b) -> a -> b
$ do
Maybe [Blocks]
headers <- forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m (Maybe a)
optionMaybe ParsecT Sources ParserState m [Blocks]
headerRow
[[Blocks]]
rows <- forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m [a]
many1 ParsecT Sources ParserState m [Blocks]
row
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ [Blocks] -> [[Blocks]] -> Blocks
B.simpleTable (forall a. a -> Maybe a -> a
fromMaybe [forall a. Monoid a => a
mempty] Maybe [Blocks]
headers) [[Blocks]]
rows
where
headerRow :: ParsecT Sources ParserState m [Blocks]
headerRow = forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try forall a b. (a -> b) -> a -> b
$ forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s st m ()
skipSpaces forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall end s (m :: * -> *) t st a.
(Show end, Stream s m t) =>
ParsecT s st m a -> ParsecT s st m end -> ParsecT s st m [a]
many1Till ParsecT Sources ParserState m Blocks
headerCell forall {u}. ParsecT Sources u m Char
rowEnd
headerCell :: ParsecT Sources ParserState m Blocks
headerCell = Inlines -> Blocks
B.plain forall b c a. (b -> c) -> (a -> b) -> a -> c
. Inlines -> Inlines
B.trimInlines forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Monoid a => [a] -> a
mconcat
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
[Char] -> ParsecT s u m [Char]
string [Char]
"|=" forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall end s (m :: * -> *) t st a.
(Show end, Stream s m t) =>
ParsecT s st m a -> ParsecT s st m end -> ParsecT s st m [a]
many1Till forall (m :: * -> *). PandocMonad m => CRLParser m Inlines
inline forall {u}. ParsecT Sources u m Char
cellEnd)
row :: ParsecT Sources ParserState m [Blocks]
row = forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try forall a b. (a -> b) -> a -> b
$ forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s st m ()
skipSpaces forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall end s (m :: * -> *) t st a.
(Show end, Stream s m t) =>
ParsecT s st m a -> ParsecT s st m end -> ParsecT s st m [a]
many1Till ParsecT Sources ParserState m Blocks
cell forall {u}. ParsecT Sources u m Char
rowEnd
cell :: ParsecT Sources ParserState m Blocks
cell = Inlines -> Blocks
B.plain forall b c a. (b -> c) -> (a -> b) -> a -> c
. Inlines -> Inlines
B.trimInlines forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Monoid a => [a] -> a
mconcat
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
Char -> ParsecT s u m Char
char Char
'|' forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall end s (m :: * -> *) t st a.
(Show end, Stream s m t) =>
ParsecT s st m a -> ParsecT s st m end -> ParsecT s st m [a]
many1Till forall (m :: * -> *). PandocMonad m => CRLParser m Inlines
inline forall {u}. ParsecT Sources u m Char
cellEnd)
rowEnd :: ParsecT Sources u m Char
rowEnd = forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try forall a b. (a -> b) -> a -> b
$ forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m ()
optional (forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
Char -> ParsecT s u m Char
char Char
'|') forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s st m ()
skipSpaces forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s u m Char
newline
cellEnd :: ParsecT Sources u m Char
cellEnd = forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m a
lookAhead forall a b. (a -> b) -> a -> b
$ forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
Char -> ParsecT s u m Char
char Char
'|' forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> forall {u}. ParsecT Sources u m Char
rowEnd
para :: PandocMonad m => CRLParser m B.Blocks
para :: forall (m :: * -> *). PandocMonad m => CRLParser m Blocks
para = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (Inlines -> Blocks
result forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Monoid a => [a] -> a
mconcat) (forall end s (m :: * -> *) t st a.
(Show end, Stream s m t) =>
ParsecT s st m a -> ParsecT s st m end -> ParsecT s st m [a]
many1Till forall (m :: * -> *). PandocMonad m => CRLParser m Inlines
inline forall (m :: * -> *). PandocMonad m => CRLParser m ()
endOfParaElement)
where
result :: Inlines -> Blocks
result Inlines
content = if forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
F.all (forall a. Eq a => a -> a -> Bool
==Inline
Space) Inlines
content
then forall a. Monoid a => a
mempty
else Inlines -> Blocks
B.para forall a b. (a -> b) -> a -> b
$ Inlines -> Inlines
B.trimInlines Inlines
content
endOfParaElement :: PandocMonad m => CRLParser m ()
endOfParaElement :: forall (m :: * -> *). PandocMonad m => CRLParser m ()
endOfParaElement = forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m a
lookAhead forall a b. (a -> b) -> a -> b
$ forall {u}. ParsecT Sources u m ()
endOfInput forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> forall {u}. ParsecT Sources u m ()
endOfPara
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> ParsecT Sources ParserState m ()
startOfList forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> ParsecT Sources ParserState m ()
startOfTable
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> ParsecT Sources ParserState m ()
startOfHeader forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> ParsecT Sources ParserState m ()
hr forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> ParsecT Sources ParserState m ()
startOfNowiki
where
endOfInput :: ParsecT Sources u m ()
endOfInput = forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try forall a b. (a -> b) -> a -> b
$ forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m ()
skipMany forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s st m Char
blankline forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s st m ()
skipSpaces forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall s (m :: * -> *) t u.
(Stream s m t, Show t) =>
ParsecT s u m ()
eof
endOfPara :: ParsecT Sources u m ()
endOfPara = forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try forall a b. (a -> b) -> a -> b
$ forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s st m Char
blankline forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m ()
skipMany1 forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s st m Char
blankline
startOf :: PandocMonad m => CRLParser m a -> CRLParser m ()
startOf :: forall (m :: * -> *) a.
PandocMonad m =>
CRLParser m a -> CRLParser m ()
startOf CRLParser m a
p = forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try forall a b. (a -> b) -> a -> b
$ forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s st m Char
blankline forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> CRLParser m a
p forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall (m :: * -> *) a. Monad m => a -> m a
return forall a. Monoid a => a
mempty
startOfList :: ParsecT Sources ParserState m ()
startOfList = forall (m :: * -> *) a.
PandocMonad m =>
CRLParser m a -> CRLParser m ()
startOf forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *). PandocMonad m => Int -> CRLParser m Blocks
anyListItem Int
1
startOfTable :: ParsecT Sources ParserState m ()
startOfTable = forall (m :: * -> *) a.
PandocMonad m =>
CRLParser m a -> CRLParser m ()
startOf forall (m :: * -> *). PandocMonad m => CRLParser m Blocks
table
startOfHeader :: ParsecT Sources ParserState m ()
startOfHeader = forall (m :: * -> *) a.
PandocMonad m =>
CRLParser m a -> CRLParser m ()
startOf forall (m :: * -> *). PandocMonad m => CRLParser m Blocks
header
startOfNowiki :: ParsecT Sources ParserState m ()
startOfNowiki = forall (m :: * -> *) a.
PandocMonad m =>
CRLParser m a -> CRLParser m ()
startOf forall (m :: * -> *). PandocMonad m => CRLParser m Blocks
nowiki
hr :: ParsecT Sources ParserState m ()
hr = forall (m :: * -> *) a.
PandocMonad m =>
CRLParser m a -> CRLParser m ()
startOf forall (m :: * -> *). PandocMonad m => CRLParser m Blocks
horizontalRule
horizontalRule :: PandocMonad m => CRLParser m B.Blocks
horizontalRule :: forall (m :: * -> *). PandocMonad m => CRLParser m Blocks
horizontalRule = forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try forall a b. (a -> b) -> a -> b
$ forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s st m ()
skipSpaces forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
[Char] -> ParsecT s u m [Char]
string [Char]
"----" forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s st m ()
skipSpaces forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s u m Char
newline
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall (m :: * -> *) a. Monad m => a -> m a
return Blocks
B.horizontalRule
inline :: PandocMonad m => CRLParser m B.Inlines
inline :: forall (m :: * -> *). PandocMonad m => CRLParser m Inlines
inline = forall s (m :: * -> *) t u a.
Stream s m t =>
[ParsecT s u m a] -> ParsecT s u m a
choice [ forall (m :: * -> *). PandocMonad m => CRLParser m Inlines
whitespace
, forall (m :: * -> *). PandocMonad m => CRLParser m Inlines
escapedLink
, forall (m :: * -> *). PandocMonad m => CRLParser m Inlines
escapedChar
, forall (m :: * -> *). PandocMonad m => CRLParser m Inlines
link
, forall (m :: * -> *). PandocMonad m => CRLParser m Inlines
inlineNowiki
, forall (m :: * -> *). PandocMonad m => CRLParser m Inlines
placeholder
, forall (m :: * -> *). PandocMonad m => CRLParser m Inlines
image
, forall (m :: * -> *). PandocMonad m => CRLParser m Inlines
forcedLinebreak
, forall (m :: * -> *). PandocMonad m => CRLParser m Inlines
bold
, forall (m :: * -> *). PandocMonad m => CRLParser m Inlines
finalBold
, forall (m :: * -> *). PandocMonad m => CRLParser m Inlines
italics
, forall (m :: * -> *). PandocMonad m => CRLParser m Inlines
finalItalics
, forall (m :: * -> *). PandocMonad m => CRLParser m Inlines
str
, forall (m :: * -> *). PandocMonad m => CRLParser m Inlines
symbol
] forall s u (m :: * -> *) a.
ParsecT s u m a -> [Char] -> ParsecT s u m a
<?> [Char]
"inline"
escapedChar :: PandocMonad m => CRLParser m B.Inlines
escapedChar :: forall (m :: * -> *). PandocMonad m => CRLParser m Inlines
escapedChar =
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (Text -> Inlines
B.str forall b c a. (b -> c) -> (a -> b) -> a -> c
. Char -> Text
T.singleton) (forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
Char -> ParsecT s u m Char
char Char
'~' forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
[Char] -> ParsecT s u m Char
noneOf [Char]
"\t\n ")
escapedLink :: PandocMonad m => CRLParser m B.Inlines
escapedLink :: forall (m :: * -> *). PandocMonad m => CRLParser m Inlines
escapedLink = forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try forall a b. (a -> b) -> a -> b
$ do
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
Char -> ParsecT s u m Char
char Char
'~'
(Text
orig, Text
_) <- forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s st m (Text, Text)
uri
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ Text -> Inlines
B.str Text
orig
image :: PandocMonad m => CRLParser m B.Inlines
image :: forall (m :: * -> *). PandocMonad m => CRLParser m Inlines
image = forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try forall a b. (a -> b) -> a -> b
$ do
(Text
orig, Text
src) <- forall {u}. ParsecT Sources u m (Text, Text)
wikiImg
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ Text -> Text -> Inlines -> Inlines
B.image Text
src Text
"" (Text -> Inlines
B.str Text
orig)
where
linkSrc :: ParsecT Sources st m Text
linkSrc = forall s (m :: * -> *) t st.
Stream s m t =>
ParsecT s st m Char -> ParsecT s st m Text
manyChar forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
[Char] -> ParsecT s u m Char
noneOf [Char]
"|}\n\r\t"
linkDsc :: ParsecT Sources u m Text
linkDsc = forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
Char -> ParsecT s u m Char
char Char
'|' forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall s (m :: * -> *) t st.
Stream s m t =>
ParsecT s st m Char -> ParsecT s st m Text
manyChar (forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
[Char] -> ParsecT s u m Char
noneOf [Char]
"}\n\r\t")
wikiImg :: ParsecT Sources u m (Text, Text)
wikiImg = forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try forall a b. (a -> b) -> a -> b
$ do
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
[Char] -> ParsecT s u m [Char]
string [Char]
"{{"
Text
src <- forall {st}. ParsecT Sources st m Text
linkSrc
Text
dsc <- forall s (m :: * -> *) t a u.
Stream s m t =>
a -> ParsecT s u m a -> ParsecT s u m a
option Text
"" forall {st}. ParsecT Sources st m Text
linkDsc
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
[Char] -> ParsecT s u m [Char]
string [Char]
"}}"
forall (m :: * -> *) a. Monad m => a -> m a
return (Text
dsc, Text
src)
link :: PandocMonad m => CRLParser m B.Inlines
link :: forall (m :: * -> *). PandocMonad m => CRLParser m Inlines
link = forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try forall a b. (a -> b) -> a -> b
$ do
(Inlines
orig, Text
src) <- forall {u}. ParsecT Sources u m (Inlines, Text)
uriLink forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> ParsecT Sources ParserState m (Inlines, Text)
wikiLink
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ Text -> Text -> Inlines -> Inlines
B.link Text
src Text
"" Inlines
orig
where
linkSrc :: ParsecT Sources st m Text
linkSrc = forall s (m :: * -> *) t st.
Stream s m t =>
ParsecT s st m Char -> ParsecT s st m Text
manyChar forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
[Char] -> ParsecT s u m Char
noneOf [Char]
"|]\n\r\t"
linkDsc :: PandocMonad m => Text -> CRLParser m B.Inlines
linkDsc :: forall (m :: * -> *). PandocMonad m => Text -> CRLParser m Inlines
linkDsc Text
otxt = Text -> Inlines
B.str
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (forall s (m :: * -> *) t a u.
Stream s m t =>
a -> ParsecT s u m a -> ParsecT s u m a
option Text
otxt
(forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
Char -> ParsecT s u m Char
char Char
'|' forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall s (m :: * -> *) t st.
Stream s m t =>
ParsecT s st m Char -> ParsecT s st m Text
manyChar (forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
[Char] -> ParsecT s u m Char
noneOf [Char]
"]\n\r\t")))
linkImg :: ParsecT Sources ParserState m Inlines
linkImg = forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
Char -> ParsecT s u m Char
char Char
'|' forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall (m :: * -> *). PandocMonad m => CRLParser m Inlines
image
wikiLink :: ParsecT Sources ParserState m (Inlines, Text)
wikiLink = forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try forall a b. (a -> b) -> a -> b
$ do
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
[Char] -> ParsecT s u m [Char]
string [Char]
"[["
Text
src <- forall {st}. ParsecT Sources st m Text
linkSrc
Inlines
dsc <- ParsecT Sources ParserState m Inlines
linkImg forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> forall (m :: * -> *). PandocMonad m => Text -> CRLParser m Inlines
linkDsc Text
src
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
[Char] -> ParsecT s u m [Char]
string [Char]
"]]"
forall (m :: * -> *) a. Monad m => a -> m a
return (Inlines
dsc, Text
src)
uriLink :: ParsecT Sources u m (Inlines, Text)
uriLink = forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try forall a b. (a -> b) -> a -> b
$ do
(Text
orig, Text
src) <- forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s st m (Text, Text)
uri
forall (m :: * -> *) a. Monad m => a -> m a
return (Text -> Inlines
B.str Text
orig, Text
src)
inlineNowiki :: PandocMonad m => CRLParser m B.Inlines
inlineNowiki :: forall (m :: * -> *). PandocMonad m => CRLParser m Inlines
inlineNowiki = Text -> Inlines
B.code forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (forall {u}. ParsecT Sources u m [Char]
start forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall s (m :: * -> *) t st a.
Stream s m t =>
ParsecT s st m Char -> ParsecT s st m a -> ParsecT s st m Text
manyTillChar (forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
[Char] -> ParsecT s u m Char
noneOf [Char]
"\n\r") forall {u}. ParsecT Sources u m Char
end)
where
start :: ParsecT Sources u m [Char]
start = forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
[Char] -> ParsecT s u m [Char]
string [Char]
"{{{"
end :: ParsecT Sources u m Char
end = forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
[Char] -> ParsecT s u m [Char]
string [Char]
"}}}" forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m a
lookAhead (forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
[Char] -> ParsecT s u m Char
noneOf [Char]
"}")
placeholder :: PandocMonad m => CRLParser m B.Inlines
placeholder :: forall (m :: * -> *). PandocMonad m => CRLParser m Inlines
placeholder = Text -> Inlines
B.text forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
[Char] -> ParsecT s u m [Char]
string [Char]
"<<<" forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall s (m :: * -> *) t u a end.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m end -> ParsecT s u m [a]
manyTill forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s u m Char
anyChar (forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
[Char] -> ParsecT s u m [Char]
string [Char]
">>>")
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall (m :: * -> *) a. Monad m => a -> m a
return Text
"")
whitespace :: PandocMonad m => CRLParser m B.Inlines
whitespace :: forall (m :: * -> *). PandocMonad m => CRLParser m Inlines
whitespace = ParsecT Sources ParserState m Inlines
lb forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> forall {u}. ParsecT Sources u m Inlines
regsp
where lb :: ParsecT Sources ParserState m Inlines
lb = forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try forall a b. (a -> b) -> a -> b
$ forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m ()
skipMany forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s st m Char
spaceChar forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall (m :: * -> *). PandocMonad m => CRLParser m Inlines
linebreak forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall (m :: * -> *) a. Monad m => a -> m a
return Inlines
B.space
regsp :: ParsecT Sources u m Inlines
regsp = forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try forall a b. (a -> b) -> a -> b
$ forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m ()
skipMany1 forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s st m Char
spaceChar forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall (m :: * -> *) a. Monad m => a -> m a
return Inlines
B.space
linebreak :: PandocMonad m => CRLParser m B.Inlines
linebreak :: forall (m :: * -> *). PandocMonad m => CRLParser m Inlines
linebreak = forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s u m Char
newline forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall s (m :: * -> *) t a u.
(Stream s m t, Show a) =>
ParsecT s u m a -> ParsecT s u m ()
notFollowedBy forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s u m Char
newline forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> (forall {u}. ParsecT Sources u m Inlines
lastNewline forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> ParsecT Sources ParserState m Inlines
innerNewline)
where lastNewline :: ParsecT Sources u m Inlines
lastNewline = forall s (m :: * -> *) t u.
(Stream s m t, Show t) =>
ParsecT s u m ()
eof forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall (m :: * -> *) a. Monad m => a -> m a
return forall a. Monoid a => a
mempty
innerNewline :: ParsecT Sources ParserState m Inlines
innerNewline = forall (m :: * -> *) a. Monad m => a -> m a
return Inlines
B.space
symbol :: PandocMonad m => CRLParser m B.Inlines
symbol :: forall (m :: * -> *). PandocMonad m => CRLParser m Inlines
symbol = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (Text -> Inlines
B.str forall b c a. (b -> c) -> (a -> b) -> a -> c
. Char -> Text
T.singleton) (forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
[Char] -> ParsecT s u m Char
oneOf [Char]
specialChars)
str :: PandocMonad m => CRLParser m B.Inlines
str :: forall (m :: * -> *). PandocMonad m => CRLParser m Inlines
str = let strChar :: ParsecT Sources u m Char
strChar = forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
[Char] -> ParsecT s u m Char
noneOf ([Char]
"\t\n " forall a. [a] -> [a] -> [a]
++ [Char]
specialChars) in
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Text -> Inlines
B.str (forall s (m :: * -> *) t st.
Stream s m t =>
ParsecT s st m Char -> ParsecT s st m Text
many1Char forall {u}. ParsecT Sources u m Char
strChar)
bold :: PandocMonad m => CRLParser m B.Inlines
bold :: forall (m :: * -> *). PandocMonad m => CRLParser m Inlines
bold = Inlines -> Inlines
B.strong forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Monoid a => [a] -> a
mconcat forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
forall end (m :: * -> *) start a.
(Show end, PandocMonad m) =>
CRLParser m start
-> CRLParser m end -> CRLParser m a -> CRLParser m [a]
enclosed (forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
[Char] -> ParsecT s u m [Char]
string [Char]
"**") (forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
[Char] -> ParsecT s u m [Char]
string [Char]
"**") forall (m :: * -> *). PandocMonad m => CRLParser m Inlines
inline
italics :: PandocMonad m => CRLParser m B.Inlines
italics :: forall (m :: * -> *). PandocMonad m => CRLParser m Inlines
italics = Inlines -> Inlines
B.emph forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Monoid a => [a] -> a
mconcat forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
forall end (m :: * -> *) start a.
(Show end, PandocMonad m) =>
CRLParser m start
-> CRLParser m end -> CRLParser m a -> CRLParser m [a]
enclosed (forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
[Char] -> ParsecT s u m [Char]
string [Char]
"//") (forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
[Char] -> ParsecT s u m [Char]
string [Char]
"//") forall (m :: * -> *). PandocMonad m => CRLParser m Inlines
inline
finalBold :: PandocMonad m => CRLParser m B.Inlines
finalBold :: forall (m :: * -> *). PandocMonad m => CRLParser m Inlines
finalBold = Inlines -> Inlines
B.strong forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Monoid a => [a] -> a
mconcat forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
[Char] -> ParsecT s u m [Char]
string [Char]
"**" forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall end s (m :: * -> *) t st a.
(Show end, Stream s m t) =>
ParsecT s st m a -> ParsecT s st m end -> ParsecT s st m [a]
many1Till forall (m :: * -> *). PandocMonad m => CRLParser m Inlines
inline forall (m :: * -> *). PandocMonad m => CRLParser m ()
endOfParaElement)
finalItalics :: PandocMonad m => CRLParser m B.Inlines
finalItalics :: forall (m :: * -> *). PandocMonad m => CRLParser m Inlines
finalItalics = Inlines -> Inlines
B.emph forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Monoid a => [a] -> a
mconcat forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
[Char] -> ParsecT s u m [Char]
string [Char]
"//" forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall end s (m :: * -> *) t st a.
(Show end, Stream s m t) =>
ParsecT s st m a -> ParsecT s st m end -> ParsecT s st m [a]
many1Till forall (m :: * -> *). PandocMonad m => CRLParser m Inlines
inline forall (m :: * -> *). PandocMonad m => CRLParser m ()
endOfParaElement)
forcedLinebreak :: PandocMonad m => CRLParser m B.Inlines
forcedLinebreak :: forall (m :: * -> *). PandocMonad m => CRLParser m Inlines
forcedLinebreak = forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
[Char] -> ParsecT s u m [Char]
string [Char]
"\\\\" forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall (m :: * -> *) a. Monad m => a -> m a
return Inlines
B.linebreak