{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE OverloadedStrings #-}
module Text.Pandoc.Readers.Muse (readMuse) where
import Control.Monad
import Control.Monad.Reader
import Control.Monad.Except (throwError)
import Data.Bifunctor
import Data.Default
import Data.List (transpose, uncons)
import qualified Data.Map as M
import qualified Data.Set as Set
import Data.Maybe (fromMaybe, isNothing, maybeToList)
import Data.Text (Text)
import qualified Data.Text as T
import Text.Pandoc.Builder (Blocks, Inlines, underline)
import qualified Text.Pandoc.Builder as B
import Text.Pandoc.Class.PandocMonad (PandocMonad (..))
import Text.Pandoc.Definition
import Text.Pandoc.Error (PandocError (PandocParsecError))
import Text.Pandoc.Logging
import Text.Pandoc.Options
import Text.Pandoc.Parsing
import Text.Pandoc.Shared (trimr, tshow)
readMuse :: (PandocMonad m, ToSources a)
=> ReaderOptions
-> a
-> m Pandoc
readMuse :: ReaderOptions -> a -> m Pandoc
readMuse ReaderOptions
opts a
s = do
let sources :: Sources
sources = a -> Sources
forall a. ToSources a => a -> Sources
toSources a
s
Either ParseError Pandoc
res <- (ReaderT MuseEnv m (Either ParseError Pandoc)
-> MuseEnv -> m (Either ParseError Pandoc))
-> MuseEnv
-> ReaderT MuseEnv m (Either ParseError Pandoc)
-> m (Either ParseError Pandoc)
forall a b c. (a -> b -> c) -> b -> a -> c
flip ReaderT MuseEnv m (Either ParseError Pandoc)
-> MuseEnv -> m (Either ParseError Pandoc)
forall r (m :: * -> *) a. ReaderT r m a -> r -> m a
runReaderT MuseEnv
forall a. Default a => a
def (ReaderT MuseEnv m (Either ParseError Pandoc)
-> m (Either ParseError Pandoc))
-> ReaderT MuseEnv m (Either ParseError Pandoc)
-> m (Either ParseError Pandoc)
forall a b. (a -> b) -> a -> b
$ ParsecT Sources MuseState (ReaderT MuseEnv m) Pandoc
-> MuseState
-> SourceName
-> Sources
-> ReaderT MuseEnv m (Either ParseError Pandoc)
forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> u -> SourceName -> s -> m (Either ParseError a)
runParserT ParsecT Sources MuseState (ReaderT MuseEnv m) Pandoc
forall (m :: * -> *). PandocMonad m => MuseParser m Pandoc
parseMuse MuseState
forall a. Default a => a
def{ museOptions :: ReaderOptions
museOptions = ReaderOptions
opts }
(Sources -> SourceName
initialSourceName Sources
sources) Sources
sources
case Either ParseError Pandoc
res of
Left ParseError
e -> 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
sources ParseError
e
Right Pandoc
d -> Pandoc -> m Pandoc
forall (m :: * -> *) a. Monad m => a -> m a
return Pandoc
d
type F = Future MuseState
data MuseState = MuseState { MuseState -> F Meta
museMeta :: F Meta
, MuseState -> ReaderOptions
museOptions :: ReaderOptions
, MuseState -> Set Text
museIdentifierList :: Set.Set Text
, MuseState -> Maybe SourcePos
museLastSpacePos :: Maybe SourcePos
, MuseState -> Maybe SourcePos
museLastStrPos :: Maybe SourcePos
, MuseState -> [LogMessage]
museLogMessages :: [LogMessage]
, MuseState -> Map Text (SourcePos, F Blocks)
museNotes :: M.Map Text (SourcePos, F Blocks)
}
instance Default MuseState where
def :: MuseState
def = MuseState :: F Meta
-> ReaderOptions
-> Set Text
-> Maybe SourcePos
-> Maybe SourcePos
-> [LogMessage]
-> Map Text (SourcePos, F Blocks)
-> MuseState
MuseState { museMeta :: F Meta
museMeta = Meta -> F Meta
forall (m :: * -> *) a. Monad m => a -> m a
return Meta
nullMeta
, museOptions :: ReaderOptions
museOptions = ReaderOptions
forall a. Default a => a
def
, museIdentifierList :: Set Text
museIdentifierList = Set Text
forall a. Set a
Set.empty
, museLastStrPos :: Maybe SourcePos
museLastStrPos = Maybe SourcePos
forall a. Maybe a
Nothing
, museLastSpacePos :: Maybe SourcePos
museLastSpacePos = Maybe SourcePos
forall a. Maybe a
Nothing
, museLogMessages :: [LogMessage]
museLogMessages = []
, museNotes :: Map Text (SourcePos, F Blocks)
museNotes = Map Text (SourcePos, F Blocks)
forall k a. Map k a
M.empty
}
data MuseEnv =
MuseEnv { MuseEnv -> Bool
museInLink :: Bool
, MuseEnv -> Bool
museInPara :: Bool
}
instance Default MuseEnv where
def :: MuseEnv
def = MuseEnv :: Bool -> Bool -> MuseEnv
MuseEnv { museInLink :: Bool
museInLink = Bool
False
, museInPara :: Bool
museInPara = Bool
False
}
type MuseParser m = ParserT Sources MuseState (ReaderT MuseEnv m)
instance HasReaderOptions MuseState where
extractReaderOptions :: MuseState -> ReaderOptions
extractReaderOptions = MuseState -> ReaderOptions
museOptions
instance HasIdentifierList MuseState where
extractIdentifierList :: MuseState -> Set Text
extractIdentifierList = MuseState -> Set Text
museIdentifierList
updateIdentifierList :: (Set Text -> Set Text) -> MuseState -> MuseState
updateIdentifierList Set Text -> Set Text
f MuseState
st = MuseState
st{ museIdentifierList :: Set Text
museIdentifierList = Set Text -> Set Text
f (Set Text -> Set Text) -> Set Text -> Set Text
forall a b. (a -> b) -> a -> b
$ MuseState -> Set Text
museIdentifierList MuseState
st }
instance HasLastStrPosition MuseState where
setLastStrPos :: Maybe SourcePos -> MuseState -> MuseState
setLastStrPos Maybe SourcePos
pos MuseState
st = MuseState
st{ museLastStrPos :: Maybe SourcePos
museLastStrPos = Maybe SourcePos
pos }
getLastStrPos :: MuseState -> Maybe SourcePos
getLastStrPos MuseState
st = MuseState -> Maybe SourcePos
museLastStrPos MuseState
st
instance HasLogMessages MuseState where
addLogMessage :: LogMessage -> MuseState -> MuseState
addLogMessage LogMessage
m MuseState
s = MuseState
s{ museLogMessages :: [LogMessage]
museLogMessages = LogMessage
m LogMessage -> [LogMessage] -> [LogMessage]
forall a. a -> [a] -> [a]
: MuseState -> [LogMessage]
museLogMessages MuseState
s }
getLogMessages :: MuseState -> [LogMessage]
getLogMessages = [LogMessage] -> [LogMessage]
forall a. [a] -> [a]
reverse ([LogMessage] -> [LogMessage])
-> (MuseState -> [LogMessage]) -> MuseState -> [LogMessage]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. MuseState -> [LogMessage]
museLogMessages
updateLastSpacePos :: Monad m => MuseParser m ()
updateLastSpacePos :: MuseParser m ()
updateLastSpacePos = ParsecT Sources MuseState (ReaderT MuseEnv m) SourcePos
forall (m :: * -> *) s u. Monad m => ParsecT s u m SourcePos
getPosition ParsecT Sources MuseState (ReaderT MuseEnv m) SourcePos
-> (SourcePos -> MuseParser m ()) -> MuseParser m ()
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \SourcePos
pos ->
(MuseState -> MuseState) -> MuseParser m ()
forall (m :: * -> *) u s. Monad m => (u -> u) -> ParsecT s u m ()
updateState ((MuseState -> MuseState) -> MuseParser m ())
-> (MuseState -> MuseState) -> MuseParser m ()
forall a b. (a -> b) -> a -> b
$ \MuseState
s -> MuseState
s { museLastSpacePos :: Maybe SourcePos
museLastSpacePos = SourcePos -> Maybe SourcePos
forall a. a -> Maybe a
Just SourcePos
pos }
parseMuse :: PandocMonad m => MuseParser m Pandoc
parseMuse :: MuseParser m Pandoc
parseMuse = do
ParsecT Sources MuseState (ReaderT MuseEnv m) ()
-> ParsecT Sources MuseState (ReaderT MuseEnv m) [()]
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
many ParsecT Sources MuseState (ReaderT MuseEnv m) ()
forall (m :: * -> *). PandocMonad m => MuseParser m ()
directive
[F Blocks]
blocks <- (:) (F Blocks -> [F Blocks] -> [F Blocks])
-> ParsecT Sources MuseState (ReaderT MuseEnv m) (F Blocks)
-> ParsecT
Sources MuseState (ReaderT MuseEnv m) ([F Blocks] -> [F Blocks])
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT Sources MuseState (ReaderT MuseEnv m) (F Blocks)
forall (m :: * -> *). PandocMonad m => MuseParser m (F Blocks)
parseBlocks ParsecT
Sources MuseState (ReaderT MuseEnv m) ([F Blocks] -> [F Blocks])
-> ParsecT Sources MuseState (ReaderT MuseEnv m) [F Blocks]
-> ParsecT Sources MuseState (ReaderT MuseEnv m) [F Blocks]
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ParsecT Sources MuseState (ReaderT MuseEnv m) (F Blocks)
-> ParsecT Sources MuseState (ReaderT MuseEnv m) [F Blocks]
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
many ParsecT Sources MuseState (ReaderT MuseEnv m) (F Blocks)
forall (m :: * -> *). PandocMonad m => MuseParser m (F Blocks)
parseSection
ParsecT Sources MuseState (ReaderT MuseEnv m) ()
forall s (m :: * -> *) t u.
(Stream s m t, Show t) =>
ParsecT s u m ()
eof
MuseState
st <- ParsecT Sources MuseState (ReaderT MuseEnv m) MuseState
forall (m :: * -> *) s u. Monad m => ParsecT s u m u
getState
Future MuseState Pandoc -> MuseState -> Pandoc
forall s a. Future s a -> s -> a
runF (Meta -> [Block] -> Pandoc
Pandoc (Meta -> [Block] -> Pandoc)
-> F Meta -> Future MuseState ([Block] -> Pandoc)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> MuseState -> F Meta
museMeta MuseState
st Future MuseState ([Block] -> Pandoc)
-> Future MuseState [Block] -> Future MuseState Pandoc
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (Blocks -> [Block]) -> F Blocks -> Future MuseState [Block]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Blocks -> [Block]
forall a. Many a -> [a]
B.toList ([F Blocks] -> F Blocks
forall a. Monoid a => [a] -> a
mconcat [F Blocks]
blocks)) MuseState
st Pandoc
-> ParsecT Sources MuseState (ReaderT MuseEnv m) ()
-> MuseParser m Pandoc
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ ParsecT Sources MuseState (ReaderT MuseEnv m) ()
forall (m :: * -> *) st s.
(PandocMonad m, HasLogMessages st) =>
ParserT s st m ()
reportLogMessages
lchop :: Text -> Text
lchop :: Text -> Text
lchop Text
s = case Text -> Maybe (Char, Text)
T.uncons Text
s of
Just (Char
'\n', Text
xs) -> Text
xs
Maybe (Char, Text)
_ -> Text
s
rchop :: Text -> Text
rchop :: Text -> Text
rchop Text
s = case Text -> Maybe (Text, Char)
T.unsnoc Text
s of
Just (Text
xs, Char
'\n') -> Text
xs
Maybe (Text, Char)
_ -> Text
s
unindent :: Text -> Text
unindent :: Text -> Text
unindent = Text -> Text
rchop (Text -> Text) -> (Text -> Text) -> Text -> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> [Text] -> Text
T.intercalate Text
"\n" ([Text] -> Text) -> (Text -> [Text]) -> Text -> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Text] -> [Text]
dropSpacePrefix ([Text] -> [Text]) -> (Text -> [Text]) -> Text -> [Text]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Text -> [Text]
T.splitOn Text
"\n" (Text -> [Text]) -> (Text -> Text) -> Text -> [Text]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Text
lchop
dropSpacePrefix :: [Text] -> [Text]
dropSpacePrefix :: [Text] -> [Text]
dropSpacePrefix [Text]
lns = Int -> Text -> Text
T.drop Int
maxIndent (Text -> Text) -> [Text] -> [Text]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [Text]
lns
where isSpaceChar :: Char -> Bool
isSpaceChar Char
c = Char
c Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== Char
' ' Bool -> Bool -> Bool
|| Char
c Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== Char
'\t'
maxIndent :: Int
maxIndent = [Text] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length ([Text] -> Int) -> [Text] -> Int
forall a b. (a -> b) -> a -> b
$ (Text -> Bool) -> [Text] -> [Text]
forall a. (a -> Bool) -> [a] -> [a]
takeWhile (Char -> Bool
isSpaceChar (Char -> Bool) -> (Text -> Char) -> Text -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Char
T.head) ([Text] -> [Text]) -> [Text] -> [Text]
forall a b. (a -> b) -> a -> b
$ (Text -> Bool) -> [Text] -> [Text]
forall a. (a -> Bool) -> [a] -> [a]
takeWhile Text -> Bool
same ([Text] -> [Text]) -> [Text] -> [Text]
forall a b. (a -> b) -> a -> b
$ [Text] -> [Text]
T.transpose [Text]
lns
same :: Text -> Bool
same Text
t = case Text -> Maybe (Char, Text)
T.uncons Text
t of
Just (Char
c, Text
cs) -> (Char -> Bool) -> Text -> Bool
T.all (Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== Char
c) Text
cs
Maybe (Char, Text)
Nothing -> Bool
True
atStart :: PandocMonad m => MuseParser m ()
atStart :: MuseParser m ()
atStart = do
SourcePos
pos <- ParsecT Sources MuseState (ReaderT MuseEnv m) SourcePos
forall (m :: * -> *) s u. Monad m => ParsecT s u m SourcePos
getPosition
MuseState
st <- ParsecT Sources MuseState (ReaderT MuseEnv m) MuseState
forall (m :: * -> *) s u. Monad m => ParsecT s u m u
getState
Bool -> MuseParser m ()
forall (f :: * -> *). Alternative f => Bool -> f ()
guard (Bool -> MuseParser m ()) -> Bool -> MuseParser m ()
forall a b. (a -> b) -> a -> b
$ MuseState -> Maybe SourcePos
museLastStrPos MuseState
st Maybe SourcePos -> Maybe SourcePos -> Bool
forall a. Eq a => a -> a -> Bool
/= SourcePos -> Maybe SourcePos
forall a. a -> Maybe a
Just SourcePos
pos
noSpaceBefore :: PandocMonad m => MuseParser m ()
noSpaceBefore :: MuseParser m ()
noSpaceBefore = do
SourcePos
pos <- ParsecT Sources MuseState (ReaderT MuseEnv m) SourcePos
forall (m :: * -> *) s u. Monad m => ParsecT s u m SourcePos
getPosition
MuseState
st <- ParsecT Sources MuseState (ReaderT MuseEnv m) MuseState
forall (m :: * -> *) s u. Monad m => ParsecT s u m u
getState
Bool -> MuseParser m ()
forall (f :: * -> *). Alternative f => Bool -> f ()
guard (Bool -> MuseParser m ()) -> Bool -> MuseParser m ()
forall a b. (a -> b) -> a -> b
$ MuseState -> Maybe SourcePos
museLastSpacePos MuseState
st Maybe SourcePos -> Maybe SourcePos -> Bool
forall a. Eq a => a -> a -> Bool
/= SourcePos -> Maybe SourcePos
forall a. a -> Maybe a
Just SourcePos
pos
firstColumn :: PandocMonad m => MuseParser m ()
firstColumn :: MuseParser m ()
firstColumn = ParsecT Sources MuseState (ReaderT MuseEnv m) SourcePos
forall (m :: * -> *) s u. Monad m => ParsecT s u m SourcePos
getPosition ParsecT Sources MuseState (ReaderT MuseEnv m) SourcePos
-> (SourcePos -> MuseParser m ()) -> MuseParser m ()
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \SourcePos
pos -> Bool -> MuseParser m ()
forall (f :: * -> *). Alternative f => Bool -> f ()
guard (SourcePos -> Int
sourceColumn SourcePos
pos Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
1)
eol :: (Stream s m Char, UpdateSourcePos s Char) => ParserT s st m ()
eol :: ParserT s st m ()
eol = ParsecT s st m Char -> ParserT s st m ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void ParsecT s st m Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s u m Char
newline ParserT s st m () -> ParserT s st m () -> ParserT s st m ()
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> ParserT s st m ()
forall s (m :: * -> *) t u.
(Stream s m t, Show t) =>
ParsecT s u m ()
eof
getIndent :: PandocMonad m
=> MuseParser m Int
getIndent :: MuseParser m Int
getIndent = Int -> Int -> Int
forall a. Num a => a -> a -> a
subtract Int
1 (Int -> Int) -> (SourcePos -> Int) -> SourcePos -> Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. SourcePos -> Int
sourceColumn (SourcePos -> Int)
-> ParsecT Sources MuseState (ReaderT MuseEnv m) SourceName
-> ParsecT Sources MuseState (ReaderT MuseEnv m) (SourcePos -> Int)
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ ParsecT Sources MuseState (ReaderT MuseEnv m) Char
-> ParsecT Sources MuseState (ReaderT MuseEnv m) SourceName
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
many ParsecT Sources MuseState (ReaderT MuseEnv m) Char
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParserT s st m Char
spaceChar ParsecT Sources MuseState (ReaderT MuseEnv m) (SourcePos -> Int)
-> ParsecT Sources MuseState (ReaderT MuseEnv m) SourcePos
-> MuseParser m Int
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ParsecT Sources MuseState (ReaderT MuseEnv m) SourcePos
forall (m :: * -> *) s u. Monad m => ParsecT s u m SourcePos
getPosition
openTag :: PandocMonad m => Text -> MuseParser m [(Text, Text)]
openTag :: Text -> MuseParser m [(Text, Text)]
openTag Text
tag = MuseParser m [(Text, Text)] -> MuseParser m [(Text, Text)]
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (MuseParser m [(Text, Text)] -> MuseParser m [(Text, Text)])
-> MuseParser m [(Text, Text)] -> MuseParser m [(Text, Text)]
forall a b. (a -> b) -> a -> b
$
Char -> ParsecT Sources MuseState (ReaderT MuseEnv m) Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
Char -> ParsecT s u m Char
char Char
'<' ParsecT Sources MuseState (ReaderT MuseEnv m) Char
-> ParsecT Sources MuseState (ReaderT MuseEnv m) Text
-> ParsecT Sources MuseState (ReaderT MuseEnv m) Text
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Text -> ParsecT Sources MuseState (ReaderT MuseEnv m) Text
forall s (m :: * -> *) u.
(Stream s m Char, UpdateSourcePos s Char) =>
Text -> ParsecT s u m Text
textStr Text
tag ParsecT Sources MuseState (ReaderT MuseEnv m) Text
-> MuseParser m [(Text, Text)] -> MuseParser m [(Text, Text)]
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> ParsecT Sources MuseState (ReaderT MuseEnv m) (Text, Text)
-> ParsecT Sources MuseState (ReaderT MuseEnv m) Char
-> MuseParser m [(Text, Text)]
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 MuseState (ReaderT MuseEnv m) (Text, Text)
forall u. ParsecT Sources u (ReaderT MuseEnv m) (Text, Text)
attr (Char -> ParsecT Sources MuseState (ReaderT MuseEnv m) Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
Char -> ParsecT s u m Char
char Char
'>')
where
attr :: ParsecT Sources u (ReaderT MuseEnv m) (Text, Text)
attr = ParsecT Sources u (ReaderT MuseEnv m) (Text, Text)
-> ParsecT Sources u (ReaderT MuseEnv m) (Text, Text)
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT Sources u (ReaderT MuseEnv m) (Text, Text)
-> ParsecT Sources u (ReaderT MuseEnv m) (Text, Text))
-> ParsecT Sources u (ReaderT MuseEnv m) (Text, Text)
-> ParsecT Sources u (ReaderT MuseEnv m) (Text, Text)
forall a b. (a -> b) -> a -> b
$ (,)
(Text -> Text -> (Text, Text))
-> ParsecT Sources u (ReaderT MuseEnv m) SourceName
-> ParsecT
Sources u (ReaderT MuseEnv m) (Text -> Text -> (Text, Text))
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ ParsecT Sources u (ReaderT MuseEnv m) Char
-> ParsecT Sources u (ReaderT MuseEnv 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 u (ReaderT MuseEnv m) Char
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParserT s st m Char
spaceChar
ParsecT
Sources u (ReaderT MuseEnv m) (Text -> Text -> (Text, Text))
-> ParsecT Sources u (ReaderT MuseEnv m) Text
-> ParsecT Sources u (ReaderT MuseEnv m) (Text -> (Text, Text))
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ParsecT Sources u (ReaderT MuseEnv m) Char
-> ParsecT Sources u (ReaderT MuseEnv m) Text
forall s (m :: * -> *) t st.
Stream s m t =>
ParserT s st m Char -> ParserT s st m Text
many1Char (SourceName -> ParsecT Sources u (ReaderT MuseEnv m) Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
SourceName -> ParsecT s u m Char
noneOf SourceName
"=\n")
ParsecT Sources u (ReaderT MuseEnv m) (Text -> (Text, Text))
-> ParsecT Sources u (ReaderT MuseEnv m) SourceName
-> ParsecT Sources u (ReaderT MuseEnv m) (Text -> (Text, Text))
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* SourceName -> ParsecT Sources u (ReaderT MuseEnv m) SourceName
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
SourceName -> ParsecT s u m SourceName
string SourceName
"=\""
ParsecT Sources u (ReaderT MuseEnv m) (Text -> (Text, Text))
-> ParsecT Sources u (ReaderT MuseEnv m) Text
-> ParsecT Sources u (ReaderT MuseEnv m) (Text, Text)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ParsecT Sources u (ReaderT MuseEnv m) Char
-> ParsecT Sources u (ReaderT MuseEnv m) Char
-> ParsecT Sources u (ReaderT MuseEnv m) Text
forall s (m :: * -> *) t st a.
Stream s m t =>
ParserT s st m Char -> ParserT s st m a -> ParserT s st m Text
manyTillChar (SourceName -> ParsecT Sources u (ReaderT MuseEnv m) Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
SourceName -> ParsecT s u m Char
noneOf SourceName
"\"") (Char -> ParsecT Sources u (ReaderT MuseEnv m) Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
Char -> ParsecT s u m Char
char Char
'"')
closeTag :: PandocMonad m => Text -> MuseParser m ()
closeTag :: Text -> MuseParser m ()
closeTag Text
tag = MuseParser m () -> MuseParser m ()
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (MuseParser m () -> MuseParser m ())
-> MuseParser m () -> MuseParser m ()
forall a b. (a -> b) -> a -> b
$ SourceName
-> ParsecT Sources MuseState (ReaderT MuseEnv m) SourceName
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
SourceName -> ParsecT s u m SourceName
string SourceName
"</" ParsecT Sources MuseState (ReaderT MuseEnv m) SourceName
-> ParsecT Sources MuseState (ReaderT MuseEnv m) Text
-> ParsecT Sources MuseState (ReaderT MuseEnv m) Text
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Text -> ParsecT Sources MuseState (ReaderT MuseEnv m) Text
forall s (m :: * -> *) u.
(Stream s m Char, UpdateSourcePos s Char) =>
Text -> ParsecT s u m Text
textStr Text
tag ParsecT Sources MuseState (ReaderT MuseEnv m) Text
-> MuseParser m () -> MuseParser m ()
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> ParsecT Sources MuseState (ReaderT MuseEnv m) Char
-> MuseParser m ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (Char -> ParsecT Sources MuseState (ReaderT MuseEnv m) Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
Char -> ParsecT s u m Char
char Char
'>')
htmlAttrToPandoc :: [(Text, Text)] -> Attr
htmlAttrToPandoc :: [(Text, Text)] -> Attr
htmlAttrToPandoc [(Text, Text)]
attrs = (Text
ident, [Text]
classes, [(Text, Text)]
keyvals)
where
ident :: Text
ident = Text -> Maybe Text -> Text
forall a. a -> Maybe a -> a
fromMaybe Text
"" (Maybe Text -> Text) -> Maybe Text -> Text
forall a b. (a -> b) -> a -> b
$ Text -> [(Text, Text)] -> Maybe Text
forall a b. Eq a => a -> [(a, b)] -> Maybe b
lookup Text
"id" [(Text, Text)]
attrs
classes :: [Text]
classes = [Text] -> (Text -> [Text]) -> Maybe Text -> [Text]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] Text -> [Text]
T.words (Maybe Text -> [Text]) -> Maybe Text -> [Text]
forall a b. (a -> b) -> a -> b
$ Text -> [(Text, Text)] -> Maybe Text
forall a b. Eq a => a -> [(a, b)] -> Maybe b
lookup Text
"class" [(Text, Text)]
attrs
keyvals :: [(Text, Text)]
keyvals = [(Text
k,Text
v) | (Text
k,Text
v) <- [(Text, Text)]
attrs, Text
k Text -> Text -> Bool
forall a. Eq a => a -> a -> Bool
/= Text
"id", Text
k Text -> Text -> Bool
forall a. Eq a => a -> a -> Bool
/= Text
"class"]
parseHtmlContent :: PandocMonad m
=> Text
-> MuseParser m (Attr, F Blocks)
parseHtmlContent :: Text -> MuseParser m (Attr, F Blocks)
parseHtmlContent Text
tag = MuseParser m (Attr, F Blocks) -> MuseParser m (Attr, F Blocks)
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (MuseParser m (Attr, F Blocks) -> MuseParser m (Attr, F Blocks))
-> MuseParser m (Attr, F Blocks) -> MuseParser m (Attr, F Blocks)
forall a b. (a -> b) -> a -> b
$ MuseParser m Int
forall (m :: * -> *). PandocMonad m => MuseParser m Int
getIndent MuseParser m Int
-> (Int -> MuseParser m (Attr, F Blocks))
-> MuseParser m (Attr, F Blocks)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Int
indent -> (,)
(Attr -> F Blocks -> (Attr, F Blocks))
-> ParsecT Sources MuseState (ReaderT MuseEnv m) Attr
-> ParsecT
Sources
MuseState
(ReaderT MuseEnv m)
(F Blocks -> (Attr, F Blocks))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ([(Text, Text)] -> Attr)
-> ParsecT Sources MuseState (ReaderT MuseEnv m) [(Text, Text)]
-> ParsecT Sources MuseState (ReaderT MuseEnv m) Attr
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap [(Text, Text)] -> Attr
htmlAttrToPandoc (Text
-> ParsecT Sources MuseState (ReaderT MuseEnv m) [(Text, Text)]
forall (m :: * -> *).
PandocMonad m =>
Text -> MuseParser m [(Text, Text)]
openTag Text
tag)
ParsecT
Sources
MuseState
(ReaderT MuseEnv m)
(F Blocks -> (Attr, F Blocks))
-> ParsecT Sources MuseState (ReaderT MuseEnv m) SourceName
-> ParsecT
Sources
MuseState
(ReaderT MuseEnv m)
(F Blocks -> (Attr, F Blocks))
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* ParsecT Sources MuseState (ReaderT MuseEnv m) Char
-> ParsecT Sources MuseState (ReaderT MuseEnv m) ()
-> ParsecT Sources MuseState (ReaderT MuseEnv m) SourceName
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 MuseState (ReaderT MuseEnv m) Char
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParserT s st m Char
spaceChar ParsecT Sources MuseState (ReaderT MuseEnv m) ()
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParserT s st m ()
eol
ParsecT
Sources
MuseState
(ReaderT MuseEnv m)
(F Blocks -> (Attr, F Blocks))
-> ParsecT Sources MuseState (ReaderT MuseEnv m) (F Blocks)
-> MuseParser m (Attr, F Blocks)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ParsecT Sources MuseState (ReaderT MuseEnv m) (F Blocks)
-> ParsecT Sources MuseState (ReaderT MuseEnv m) (F Blocks)
forall (m :: * -> *) a. MonadReader MuseEnv m => m a -> m a
allowPara (ParsecT Sources MuseState (ReaderT MuseEnv m) ()
-> ParsecT Sources MuseState (ReaderT MuseEnv m) (F Blocks)
forall (m :: * -> *) a.
PandocMonad m =>
MuseParser m a -> MuseParser m (F Blocks)
parseBlocksTill (ParsecT Sources MuseState (ReaderT MuseEnv m) ()
-> ParsecT Sources MuseState (ReaderT MuseEnv m) ()
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT Sources MuseState (ReaderT MuseEnv m) ()
-> ParsecT Sources MuseState (ReaderT MuseEnv m) ())
-> ParsecT Sources MuseState (ReaderT MuseEnv m) ()
-> ParsecT Sources MuseState (ReaderT MuseEnv m) ()
forall a b. (a -> b) -> a -> b
$ Int -> ParserT Sources MuseState (ReaderT MuseEnv m) Text
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char, HasReaderOptions st) =>
Int -> ParserT s st m Text
indentWith Int
indent ParserT Sources MuseState (ReaderT MuseEnv m) Text
-> ParsecT Sources MuseState (ReaderT MuseEnv m) ()
-> ParsecT Sources MuseState (ReaderT MuseEnv m) ()
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Text -> ParsecT Sources MuseState (ReaderT MuseEnv m) ()
forall (m :: * -> *). PandocMonad m => Text -> MuseParser m ()
closeTag Text
tag))
MuseParser m (Attr, F Blocks)
-> ParsecT Sources MuseState (ReaderT MuseEnv m) SourceName
-> MuseParser m (Attr, F Blocks)
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* ParsecT Sources MuseState (ReaderT MuseEnv m) Char
-> ParsecT Sources MuseState (ReaderT MuseEnv m) ()
-> ParsecT Sources MuseState (ReaderT MuseEnv m) SourceName
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 MuseState (ReaderT MuseEnv m) Char
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParserT s st m Char
spaceChar ParsecT Sources MuseState (ReaderT MuseEnv m) ()
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParserT s st m ()
eol
parseDirectiveKey :: PandocMonad m => MuseParser m Text
parseDirectiveKey :: MuseParser m Text
parseDirectiveKey = Char -> ParsecT Sources MuseState (ReaderT MuseEnv m) Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
Char -> ParsecT s u m Char
char Char
'#' ParsecT Sources MuseState (ReaderT MuseEnv m) Char
-> MuseParser m Text -> MuseParser m Text
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> ParsecT Sources MuseState (ReaderT MuseEnv m) Char
-> MuseParser m Text
forall s (m :: * -> *) t st.
Stream s m t =>
ParserT s st m Char -> ParserT s st m Text
manyChar (ParsecT Sources MuseState (ReaderT MuseEnv m) Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s u m Char
letter ParsecT Sources MuseState (ReaderT MuseEnv m) Char
-> ParsecT Sources MuseState (ReaderT MuseEnv m) Char
-> ParsecT Sources MuseState (ReaderT MuseEnv m) Char
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> Char -> ParsecT Sources MuseState (ReaderT MuseEnv m) Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
Char -> ParsecT s u m Char
char Char
'-')
parseEmacsDirective :: PandocMonad m => MuseParser m (Text, F Inlines)
parseEmacsDirective :: MuseParser m (Text, F Inlines)
parseEmacsDirective = (,)
(Text -> F Inlines -> (Text, F Inlines))
-> ParsecT Sources MuseState (ReaderT MuseEnv m) Text
-> ParsecT
Sources
MuseState
(ReaderT MuseEnv m)
(F Inlines -> (Text, F Inlines))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT Sources MuseState (ReaderT MuseEnv m) Text
forall (m :: * -> *). PandocMonad m => MuseParser m Text
parseDirectiveKey
ParsecT
Sources
MuseState
(ReaderT MuseEnv m)
(F Inlines -> (Text, F Inlines))
-> ParsecT Sources MuseState (ReaderT MuseEnv m) Char
-> ParsecT
Sources
MuseState
(ReaderT MuseEnv m)
(F Inlines -> (Text, F Inlines))
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* ParsecT Sources MuseState (ReaderT MuseEnv m) Char
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParserT s st m Char
spaceChar
ParsecT
Sources
MuseState
(ReaderT MuseEnv m)
(F Inlines -> (Text, F Inlines))
-> ParsecT Sources MuseState (ReaderT MuseEnv m) (F Inlines)
-> MuseParser m (Text, F Inlines)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (F Inlines -> F Inlines
forall s. Future s Inlines -> Future s Inlines
trimInlinesF (F Inlines -> F Inlines)
-> ([F Inlines] -> F Inlines) -> [F Inlines] -> F Inlines
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [F Inlines] -> F Inlines
forall a. Monoid a => [a] -> a
mconcat ([F Inlines] -> F Inlines)
-> ParsecT Sources MuseState (ReaderT MuseEnv m) [F Inlines]
-> ParsecT Sources MuseState (ReaderT MuseEnv m) (F Inlines)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT Sources MuseState (ReaderT MuseEnv m) (F Inlines)
-> ParsecT Sources MuseState (ReaderT MuseEnv m) ()
-> ParsecT Sources MuseState (ReaderT MuseEnv m) [F Inlines]
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 MuseState (ReaderT MuseEnv m) (F Inlines)
forall (m :: * -> *). PandocMonad m => MuseParser m (F Inlines)
inline' ParsecT Sources MuseState (ReaderT MuseEnv m) ()
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParserT s st m ()
eol)
parseAmuseDirective :: PandocMonad m => MuseParser m (Text, F Inlines)
parseAmuseDirective :: MuseParser m (Text, F Inlines)
parseAmuseDirective = (,)
(Text -> F Inlines -> (Text, F Inlines))
-> ParsecT Sources MuseState (ReaderT MuseEnv m) Text
-> ParsecT
Sources
MuseState
(ReaderT MuseEnv m)
(F Inlines -> (Text, F Inlines))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT Sources MuseState (ReaderT MuseEnv m) Text
forall (m :: * -> *). PandocMonad m => MuseParser m Text
parseDirectiveKey
ParsecT
Sources
MuseState
(ReaderT MuseEnv m)
(F Inlines -> (Text, F Inlines))
-> ParsecT Sources MuseState (ReaderT MuseEnv m) SourceName
-> ParsecT
Sources
MuseState
(ReaderT MuseEnv m)
(F Inlines -> (Text, F Inlines))
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* ParsecT Sources MuseState (ReaderT MuseEnv m) Char
-> ParsecT Sources MuseState (ReaderT MuseEnv 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 MuseState (ReaderT MuseEnv m) Char
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParserT s st m Char
spaceChar
ParsecT
Sources
MuseState
(ReaderT MuseEnv m)
(F Inlines -> (Text, F Inlines))
-> ParsecT Sources MuseState (ReaderT MuseEnv m) (F Inlines)
-> MuseParser m (Text, F Inlines)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (F Inlines -> F Inlines
forall s. Future s Inlines -> Future s Inlines
trimInlinesF (F Inlines -> F Inlines)
-> ([F Inlines] -> F Inlines) -> [F Inlines] -> F Inlines
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [F Inlines] -> F Inlines
forall a. Monoid a => [a] -> a
mconcat ([F Inlines] -> F Inlines)
-> ParsecT Sources MuseState (ReaderT MuseEnv m) [F Inlines]
-> ParsecT Sources MuseState (ReaderT MuseEnv m) (F Inlines)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT Sources MuseState (ReaderT MuseEnv m) (F Inlines)
-> ParserT Sources MuseState (ReaderT MuseEnv m) ()
-> ParsecT Sources MuseState (ReaderT MuseEnv m) [F Inlines]
forall end s (m :: * -> *) t st a.
(Show end, Stream s m t) =>
ParserT s st m a -> ParserT s st m end -> ParserT s st m [a]
many1Till ParsecT Sources MuseState (ReaderT MuseEnv m) (F Inlines)
forall (m :: * -> *). PandocMonad m => MuseParser m (F Inlines)
inline ParserT Sources MuseState (ReaderT MuseEnv m) ()
endOfDirective)
MuseParser m (Text, F Inlines)
-> ParsecT Sources MuseState (ReaderT MuseEnv m) SourceName
-> MuseParser m (Text, F Inlines)
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* ParsecT Sources MuseState (ReaderT MuseEnv m) Char
-> ParsecT Sources MuseState (ReaderT MuseEnv m) SourceName
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
many ParsecT Sources MuseState (ReaderT MuseEnv m) Char
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParserT s st m Char
blankline
where
endOfDirective :: ParserT Sources MuseState (ReaderT MuseEnv m) ()
endOfDirective = ParserT Sources MuseState (ReaderT MuseEnv m) ()
-> ParserT Sources MuseState (ReaderT MuseEnv m) ()
forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m a
lookAhead (ParserT Sources MuseState (ReaderT MuseEnv m) ()
-> ParserT Sources MuseState (ReaderT MuseEnv m) ())
-> ParserT Sources MuseState (ReaderT MuseEnv m) ()
-> ParserT Sources MuseState (ReaderT MuseEnv m) ()
forall a b. (a -> b) -> a -> b
$ ParserT Sources MuseState (ReaderT MuseEnv m) ()
forall s (m :: * -> *) t u.
(Stream s m t, Show t) =>
ParsecT s u m ()
eof ParserT Sources MuseState (ReaderT MuseEnv m) ()
-> ParserT Sources MuseState (ReaderT MuseEnv m) ()
-> ParserT Sources MuseState (ReaderT MuseEnv m) ()
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> ParserT Sources MuseState (ReaderT MuseEnv m) ()
-> ParserT Sources MuseState (ReaderT MuseEnv m) ()
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT Sources MuseState (ReaderT MuseEnv m) Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s u m Char
newline ParsecT Sources MuseState (ReaderT MuseEnv m) Char
-> ParserT Sources MuseState (ReaderT MuseEnv m) ()
-> ParserT Sources MuseState (ReaderT MuseEnv m) ()
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> (ParsecT Sources MuseState (ReaderT MuseEnv m) Char
-> ParserT Sources MuseState (ReaderT MuseEnv m) ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void ParsecT Sources MuseState (ReaderT MuseEnv m) Char
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParserT s st m Char
blankline ParserT Sources MuseState (ReaderT MuseEnv m) ()
-> ParserT Sources MuseState (ReaderT MuseEnv m) ()
-> ParserT Sources MuseState (ReaderT MuseEnv m) ()
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> ParsecT Sources MuseState (ReaderT MuseEnv m) Text
-> ParserT Sources MuseState (ReaderT MuseEnv m) ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void ParsecT Sources MuseState (ReaderT MuseEnv m) Text
forall (m :: * -> *). PandocMonad m => MuseParser m Text
parseDirectiveKey))
directive :: PandocMonad m => MuseParser m ()
directive :: MuseParser m ()
directive = do
Extensions
ext <- (ReaderOptions -> Extensions)
-> ParserT Sources MuseState (ReaderT MuseEnv m) Extensions
forall st s (m :: * -> *) t b.
(HasReaderOptions st, Stream s m t) =>
(ReaderOptions -> b) -> ParserT s st m b
getOption ReaderOptions -> Extensions
readerExtensions
(Text
key, F Inlines
value) <- if Extension -> Extensions -> Bool
extensionEnabled Extension
Ext_amuse Extensions
ext then MuseParser m (Text, F Inlines)
forall (m :: * -> *).
PandocMonad m =>
MuseParser m (Text, F Inlines)
parseAmuseDirective else MuseParser m (Text, F Inlines)
forall (m :: * -> *).
PandocMonad m =>
MuseParser m (Text, F Inlines)
parseEmacsDirective
(MuseState -> MuseState) -> MuseParser m ()
forall (m :: * -> *) u s. Monad m => (u -> u) -> ParsecT s u m ()
updateState ((MuseState -> MuseState) -> MuseParser m ())
-> (MuseState -> MuseState) -> MuseParser m ()
forall a b. (a -> b) -> a -> b
$ \MuseState
st -> MuseState
st { museMeta :: F Meta
museMeta = Text -> Inlines -> Meta -> Meta
forall a b. (HasMeta a, ToMetaValue b) => Text -> b -> a -> a
B.setMeta (Text -> Text
forall p. (Eq p, IsString p) => p -> p
translateKey Text
key) (Inlines -> Meta -> Meta)
-> F Inlines -> Future MuseState (Meta -> Meta)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> F Inlines
value Future MuseState (Meta -> Meta) -> F Meta -> F Meta
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> MuseState -> F Meta
museMeta MuseState
st }
where translateKey :: p -> p
translateKey p
"cover" = p
"cover-image"
translateKey p
x = p
x
allowPara :: MonadReader MuseEnv m => m a -> m a
allowPara :: m a -> m a
allowPara m a
p = (MuseEnv -> MuseEnv) -> m a -> m a
forall r (m :: * -> *) a. MonadReader r m => (r -> r) -> m a -> m a
local (\MuseEnv
s -> MuseEnv
s { museInPara :: Bool
museInPara = Bool
False }) m a
p
parseBlocks :: PandocMonad m
=> MuseParser m (F Blocks)
parseBlocks :: MuseParser m (F Blocks)
parseBlocks =
MuseParser m (F Blocks) -> MuseParser m (F Blocks)
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (MuseParser m (F Blocks)
forall u. ParsecT Sources u (ReaderT MuseEnv m) (F Blocks)
parseEnd MuseParser m (F Blocks)
-> MuseParser m (F Blocks) -> MuseParser m (F Blocks)
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|>
MuseParser m (F Blocks)
nextSection MuseParser m (F Blocks)
-> MuseParser m (F Blocks) -> MuseParser m (F Blocks)
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|>
MuseParser m (F Blocks)
listStart MuseParser m (F Blocks)
-> MuseParser m (F Blocks) -> MuseParser m (F Blocks)
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|>
MuseParser m (F Blocks)
blockStart MuseParser m (F Blocks)
-> MuseParser m (F Blocks) -> MuseParser m (F Blocks)
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|>
MuseParser m (F Blocks)
paraStart)
where
nextSection :: MuseParser m (F Blocks)
nextSection = F Blocks
forall a. Monoid a => a
mempty F Blocks
-> ParsecT Sources MuseState (ReaderT MuseEnv m) (Text, Int)
-> MuseParser m (F Blocks)
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ ParsecT Sources MuseState (ReaderT MuseEnv m) (Text, Int)
-> ParsecT Sources MuseState (ReaderT MuseEnv m) (Text, Int)
forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m a
lookAhead ParsecT Sources MuseState (ReaderT MuseEnv m) (Text, Int)
forall (m :: * -> *). PandocMonad m => MuseParser m (Text, Int)
headingStart
parseEnd :: ParsecT Sources u (ReaderT MuseEnv m) (F Blocks)
parseEnd = F Blocks
forall a. Monoid a => a
mempty F Blocks
-> ParsecT Sources u (ReaderT MuseEnv m) ()
-> ParsecT Sources u (ReaderT MuseEnv m) (F Blocks)
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ ParsecT Sources u (ReaderT MuseEnv m) ()
forall s (m :: * -> *) t u.
(Stream s m t, Show t) =>
ParsecT s u m ()
eof
blockStart :: MuseParser m (F Blocks)
blockStart = F Blocks -> F Blocks -> F Blocks
forall a. Semigroup a => a -> a -> a
(B.<>) (F Blocks -> F Blocks -> F Blocks)
-> MuseParser m (F Blocks)
-> ParsecT
Sources MuseState (ReaderT MuseEnv m) (F Blocks -> F Blocks)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (MuseParser m (F Blocks)
forall (m :: * -> *). PandocMonad m => MuseParser m (F Blocks)
blockElements MuseParser m (F Blocks)
-> MuseParser m (F Blocks) -> MuseParser m (F Blocks)
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> MuseParser m (F Blocks)
forall (m :: * -> *). PandocMonad m => MuseParser m (F Blocks)
emacsNoteBlock)
ParsecT
Sources MuseState (ReaderT MuseEnv m) (F Blocks -> F Blocks)
-> MuseParser m (F Blocks) -> MuseParser m (F Blocks)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> MuseParser m (F Blocks) -> MuseParser m (F Blocks)
forall (m :: * -> *) a. MonadReader MuseEnv m => m a -> m a
allowPara MuseParser m (F Blocks)
forall (m :: * -> *). PandocMonad m => MuseParser m (F Blocks)
parseBlocks
listStart :: MuseParser m (F Blocks)
listStart =
(F Blocks -> F Blocks -> F Blocks)
-> (F Blocks, F Blocks) -> F Blocks
forall a b c. (a -> b -> c) -> (a, b) -> c
uncurry F Blocks -> F Blocks -> F Blocks
forall a. Semigroup a => a -> a -> a
(B.<>) ((F Blocks, F Blocks) -> F Blocks)
-> ParsecT
Sources MuseState (ReaderT MuseEnv m) (F Blocks, F Blocks)
-> MuseParser m (F Blocks)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT Sources MuseState (ReaderT MuseEnv m) (F Blocks, F Blocks)
-> ParsecT
Sources MuseState (ReaderT MuseEnv m) (F Blocks, F Blocks)
forall (m :: * -> *) a. MonadReader MuseEnv m => m a -> m a
allowPara (MuseParser m (F Blocks)
-> ParsecT
Sources MuseState (ReaderT MuseEnv m) (F Blocks, F Blocks)
forall (m :: * -> *) a.
PandocMonad m =>
MuseParser m a -> MuseParser m (F Blocks, a)
anyListUntil MuseParser m (F Blocks)
forall (m :: * -> *). PandocMonad m => MuseParser m (F Blocks)
parseBlocks ParsecT Sources MuseState (ReaderT MuseEnv m) (F Blocks, F Blocks)
-> ParsecT
Sources MuseState (ReaderT MuseEnv m) (F Blocks, F Blocks)
-> ParsecT
Sources MuseState (ReaderT MuseEnv m) (F Blocks, F Blocks)
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> MuseParser m (F Blocks)
-> ParsecT
Sources MuseState (ReaderT MuseEnv m) (F Blocks, F Blocks)
forall (m :: * -> *) a.
PandocMonad m =>
MuseParser m a -> MuseParser m (F Blocks, a)
amuseNoteBlockUntil MuseParser m (F Blocks)
forall (m :: * -> *). PandocMonad m => MuseParser m (F Blocks)
parseBlocks)
paraStart :: MuseParser m (F Blocks)
paraStart = do
Int
indent <- SourceName -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length (SourceName -> Int)
-> ParsecT Sources MuseState (ReaderT MuseEnv m) SourceName
-> ParsecT Sources MuseState (ReaderT MuseEnv m) Int
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT Sources MuseState (ReaderT MuseEnv m) Char
-> ParsecT Sources MuseState (ReaderT MuseEnv m) SourceName
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
many ParsecT Sources MuseState (ReaderT MuseEnv m) Char
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParserT s st m Char
spaceChar
(F Blocks -> F Blocks -> F Blocks)
-> (F Blocks, F Blocks) -> F Blocks
forall a b c. (a -> b -> c) -> (a, b) -> c
uncurry F Blocks -> F Blocks -> F Blocks
forall a. Semigroup a => a -> a -> a
(B.<>) ((F Blocks, F Blocks) -> F Blocks)
-> ((F Blocks, F Blocks) -> (F Blocks, F Blocks))
-> (F Blocks, F Blocks)
-> F Blocks
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (F Blocks -> F Blocks)
-> (F Blocks, F Blocks) -> (F Blocks, F Blocks)
forall (p :: * -> * -> *) a b c.
Bifunctor p =>
(a -> b) -> p a c -> p b c
first (Int -> F Blocks -> F Blocks
forall a (f :: * -> *).
(Ord a, Num a, Functor f) =>
a -> f Blocks -> f Blocks
p Int
indent) ((F Blocks, F Blocks) -> F Blocks)
-> ParsecT
Sources MuseState (ReaderT MuseEnv m) (F Blocks, F Blocks)
-> MuseParser m (F Blocks)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> MuseParser m (F Blocks)
-> ParsecT
Sources MuseState (ReaderT MuseEnv m) (F Blocks, F Blocks)
forall (m :: * -> *) a.
PandocMonad m =>
MuseParser m a -> MuseParser m (F Blocks, a)
paraUntil MuseParser m (F Blocks)
forall (m :: * -> *). PandocMonad m => MuseParser m (F Blocks)
parseBlocks
where p :: a -> f Blocks -> f Blocks
p a
indent = if a
indent a -> a -> Bool
forall a. Ord a => a -> a -> Bool
>= a
2 Bool -> Bool -> Bool
&& a
indent a -> a -> Bool
forall a. Ord a => a -> a -> Bool
< a
6 then (Blocks -> Blocks) -> f Blocks -> f Blocks
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Blocks -> Blocks
B.blockQuote else f Blocks -> f Blocks
forall a. a -> a
id
parseSection :: PandocMonad m
=> MuseParser m (F Blocks)
parseSection :: MuseParser m (F Blocks)
parseSection =
(F Blocks -> F Blocks -> F Blocks
forall a. Semigroup a => a -> a -> a
(B.<>) (F Blocks -> F Blocks -> F Blocks)
-> MuseParser m (F Blocks)
-> ParsecT
Sources MuseState (ReaderT MuseEnv m) (F Blocks -> F Blocks)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> MuseParser m (F Blocks)
forall (m :: * -> *). PandocMonad m => MuseParser m (F Blocks)
emacsHeading ParsecT
Sources MuseState (ReaderT MuseEnv m) (F Blocks -> F Blocks)
-> MuseParser m (F Blocks) -> MuseParser m (F Blocks)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> MuseParser m (F Blocks)
forall (m :: * -> *). PandocMonad m => MuseParser m (F Blocks)
parseBlocks) MuseParser m (F Blocks)
-> MuseParser m (F Blocks) -> MuseParser m (F Blocks)
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|>
((F Blocks -> F Blocks -> F Blocks)
-> (F Blocks, F Blocks) -> F Blocks
forall a b c. (a -> b -> c) -> (a, b) -> c
uncurry F Blocks -> F Blocks -> F Blocks
forall a. Semigroup a => a -> a -> a
(B.<>) ((F Blocks, F Blocks) -> F Blocks)
-> ParsecT
Sources MuseState (ReaderT MuseEnv m) (F Blocks, F Blocks)
-> MuseParser m (F Blocks)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> MuseParser m (F Blocks)
-> ParsecT
Sources MuseState (ReaderT MuseEnv m) (F Blocks, F Blocks)
forall (m :: * -> *) a.
PandocMonad m =>
MuseParser m a -> MuseParser m (F Blocks, a)
amuseHeadingUntil MuseParser m (F Blocks)
forall (m :: * -> *). PandocMonad m => MuseParser m (F Blocks)
parseBlocks)
parseBlocksTill :: PandocMonad m
=> MuseParser m a
-> MuseParser m (F Blocks)
parseBlocksTill :: MuseParser m a -> MuseParser m (F Blocks)
parseBlocksTill MuseParser m a
end = MuseParser m (F Blocks)
continuation
where
parseEnd :: MuseParser m (F Blocks)
parseEnd = F Blocks
forall a. Monoid a => a
mempty F Blocks -> MuseParser m a -> MuseParser m (F Blocks)
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ MuseParser m a
end
blockStart :: MuseParser m (F Blocks)
blockStart = F Blocks -> F Blocks -> F Blocks
forall a. Semigroup a => a -> a -> a
(B.<>) (F Blocks -> F Blocks -> F Blocks)
-> MuseParser m (F Blocks)
-> ParsecT
Sources MuseState (ReaderT MuseEnv m) (F Blocks -> F Blocks)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> MuseParser m (F Blocks)
forall (m :: * -> *). PandocMonad m => MuseParser m (F Blocks)
blockElements ParsecT
Sources MuseState (ReaderT MuseEnv m) (F Blocks -> F Blocks)
-> MuseParser m (F Blocks) -> MuseParser m (F Blocks)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> MuseParser m (F Blocks) -> MuseParser m (F Blocks)
forall (m :: * -> *) a. MonadReader MuseEnv m => m a -> m a
allowPara MuseParser m (F Blocks)
continuation
listStart :: MuseParser m (F Blocks)
listStart = (F Blocks -> F Blocks -> F Blocks)
-> (F Blocks, F Blocks) -> F Blocks
forall a b c. (a -> b -> c) -> (a, b) -> c
uncurry F Blocks -> F Blocks -> F Blocks
forall a. Semigroup a => a -> a -> a
(B.<>) ((F Blocks, F Blocks) -> F Blocks)
-> ParsecT
Sources MuseState (ReaderT MuseEnv m) (F Blocks, F Blocks)
-> MuseParser m (F Blocks)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT Sources MuseState (ReaderT MuseEnv m) (F Blocks, F Blocks)
-> ParsecT
Sources MuseState (ReaderT MuseEnv m) (F Blocks, F Blocks)
forall (m :: * -> *) a. MonadReader MuseEnv m => m a -> m a
allowPara (MuseParser m (F Blocks)
-> ParsecT
Sources MuseState (ReaderT MuseEnv m) (F Blocks, F Blocks)
forall (m :: * -> *) a.
PandocMonad m =>
MuseParser m a -> MuseParser m (F Blocks, a)
anyListUntil (MuseParser m (F Blocks)
parseEnd MuseParser m (F Blocks)
-> MuseParser m (F Blocks) -> MuseParser m (F Blocks)
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> MuseParser m (F Blocks)
continuation))
paraStart :: MuseParser m (F Blocks)
paraStart = (F Blocks -> F Blocks -> F Blocks)
-> (F Blocks, F Blocks) -> F Blocks
forall a b c. (a -> b -> c) -> (a, b) -> c
uncurry F Blocks -> F Blocks -> F Blocks
forall a. Semigroup a => a -> a -> a
(B.<>) ((F Blocks, F Blocks) -> F Blocks)
-> ParsecT
Sources MuseState (ReaderT MuseEnv m) (F Blocks, F Blocks)
-> MuseParser m (F Blocks)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> MuseParser m (F Blocks)
-> ParsecT
Sources MuseState (ReaderT MuseEnv m) (F Blocks, F Blocks)
forall (m :: * -> *) a.
PandocMonad m =>
MuseParser m a -> MuseParser m (F Blocks, a)
paraUntil (MuseParser m (F Blocks)
parseEnd MuseParser m (F Blocks)
-> MuseParser m (F Blocks) -> MuseParser m (F Blocks)
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> MuseParser m (F Blocks)
continuation)
continuation :: MuseParser m (F Blocks)
continuation = MuseParser m (F Blocks) -> MuseParser m (F Blocks)
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (MuseParser m (F Blocks) -> MuseParser m (F Blocks))
-> MuseParser m (F Blocks) -> MuseParser m (F Blocks)
forall a b. (a -> b) -> a -> b
$ MuseParser m (F Blocks)
parseEnd MuseParser m (F Blocks)
-> MuseParser m (F Blocks) -> MuseParser m (F Blocks)
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> MuseParser m (F Blocks)
listStart MuseParser m (F Blocks)
-> MuseParser m (F Blocks) -> MuseParser m (F Blocks)
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> MuseParser m (F Blocks)
blockStart MuseParser m (F Blocks)
-> MuseParser m (F Blocks) -> MuseParser m (F Blocks)
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> MuseParser m (F Blocks)
paraStart
listItemContentsUntil :: PandocMonad m
=> Int
-> MuseParser m a
-> MuseParser m a
-> MuseParser m (F Blocks, a)
listItemContentsUntil :: Int
-> MuseParser m a -> MuseParser m a -> MuseParser m (F Blocks, a)
listItemContentsUntil Int
col MuseParser m a
pre MuseParser m a
end = MuseParser m (F Blocks, a)
p
where
p :: MuseParser m (F Blocks, a)
p = MuseParser m (F Blocks, a) -> MuseParser m (F Blocks, a)
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try MuseParser m (F Blocks, a)
listStart MuseParser m (F Blocks, a)
-> MuseParser m (F Blocks, a) -> MuseParser m (F Blocks, a)
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> MuseParser m (F Blocks, a) -> MuseParser m (F Blocks, a)
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try MuseParser m (F Blocks, a)
blockStart MuseParser m (F Blocks, a)
-> MuseParser m (F Blocks, a) -> MuseParser m (F Blocks, a)
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> MuseParser m (F Blocks, a) -> MuseParser m (F Blocks, a)
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try MuseParser m (F Blocks, a)
paraStart
parsePre :: MuseParser m (F Blocks, a)
parsePre = (F Blocks
forall a. Monoid a => a
mempty,) (a -> (F Blocks, a))
-> MuseParser m a -> MuseParser m (F Blocks, a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> MuseParser m a
pre
parseEnd :: MuseParser m (F Blocks, a)
parseEnd = (F Blocks
forall a. Monoid a => a
mempty,) (a -> (F Blocks, a))
-> MuseParser m a -> MuseParser m (F Blocks, a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> MuseParser m a
end
paraStart :: MuseParser m (F Blocks, a)
paraStart = do
(F Blocks
f, (F Blocks
r, a
e)) <- MuseParser m (F Blocks, a)
-> MuseParser m (F Blocks, (F Blocks, a))
forall (m :: * -> *) a.
PandocMonad m =>
MuseParser m a -> MuseParser m (F Blocks, a)
paraUntil (MuseParser m (F Blocks, a)
parsePre MuseParser m (F Blocks, a)
-> MuseParser m (F Blocks, a) -> MuseParser m (F Blocks, a)
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> MuseParser m (F Blocks, a)
continuation MuseParser m (F Blocks, a)
-> MuseParser m (F Blocks, a) -> MuseParser m (F Blocks, a)
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> MuseParser m (F Blocks, a)
parseEnd)
(F Blocks, a) -> MuseParser m (F Blocks, a)
forall (m :: * -> *) a. Monad m => a -> m a
return (F Blocks
f F Blocks -> F Blocks -> F Blocks
forall a. Semigroup a => a -> a -> a
B.<> F Blocks
r, a
e)
blockStart :: MuseParser m (F Blocks, a)
blockStart = (F Blocks -> F Blocks) -> (F Blocks, a) -> (F Blocks, a)
forall (p :: * -> * -> *) a b c.
Bifunctor p =>
(a -> b) -> p a c -> p b c
first ((F Blocks -> F Blocks) -> (F Blocks, a) -> (F Blocks, a))
-> ParsecT
Sources MuseState (ReaderT MuseEnv m) (F Blocks -> F Blocks)
-> ParsecT
Sources
MuseState
(ReaderT MuseEnv m)
((F Blocks, a) -> (F Blocks, a))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (F Blocks -> F Blocks -> F Blocks
forall a. Semigroup a => a -> a -> a
(B.<>) (F Blocks -> F Blocks -> F Blocks)
-> ParsecT Sources MuseState (ReaderT MuseEnv m) (F Blocks)
-> ParsecT
Sources MuseState (ReaderT MuseEnv m) (F Blocks -> F Blocks)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT Sources MuseState (ReaderT MuseEnv m) (F Blocks)
forall (m :: * -> *). PandocMonad m => MuseParser m (F Blocks)
blockElements)
ParsecT
Sources
MuseState
(ReaderT MuseEnv m)
((F Blocks, a) -> (F Blocks, a))
-> MuseParser m (F Blocks, a) -> MuseParser m (F Blocks, a)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> MuseParser m (F Blocks, a) -> MuseParser m (F Blocks, a)
forall (m :: * -> *) a. MonadReader MuseEnv m => m a -> m a
allowPara (MuseParser m (F Blocks, a)
parsePre MuseParser m (F Blocks, a)
-> MuseParser m (F Blocks, a) -> MuseParser m (F Blocks, a)
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> MuseParser m (F Blocks, a)
continuation MuseParser m (F Blocks, a)
-> MuseParser m (F Blocks, a) -> MuseParser m (F Blocks, a)
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> MuseParser m (F Blocks, a)
parseEnd)
listStart :: MuseParser m (F Blocks, a)
listStart = do
(F Blocks
f, (F Blocks
r, a
e)) <- MuseParser m (F Blocks, (F Blocks, a))
-> MuseParser m (F Blocks, (F Blocks, a))
forall (m :: * -> *) a. MonadReader MuseEnv m => m a -> m a
allowPara (MuseParser m (F Blocks, (F Blocks, a))
-> MuseParser m (F Blocks, (F Blocks, a)))
-> MuseParser m (F Blocks, (F Blocks, a))
-> MuseParser m (F Blocks, (F Blocks, a))
forall a b. (a -> b) -> a -> b
$ MuseParser m (F Blocks, a)
-> MuseParser m (F Blocks, (F Blocks, a))
forall (m :: * -> *) a.
PandocMonad m =>
MuseParser m a -> MuseParser m (F Blocks, a)
anyListUntil (MuseParser m (F Blocks, a)
parsePre MuseParser m (F Blocks, a)
-> MuseParser m (F Blocks, a) -> MuseParser m (F Blocks, a)
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> MuseParser m (F Blocks, a)
continuation MuseParser m (F Blocks, a)
-> MuseParser m (F Blocks, a) -> MuseParser m (F Blocks, a)
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> MuseParser m (F Blocks, a)
parseEnd)
(F Blocks, a) -> MuseParser m (F Blocks, a)
forall (m :: * -> *) a. Monad m => a -> m a
return (F Blocks
f F Blocks -> F Blocks -> F Blocks
forall a. Semigroup a => a -> a -> a
B.<> F Blocks
r, a
e)
continuation :: MuseParser m (F Blocks, a)
continuation = MuseParser m (F Blocks, a) -> MuseParser m (F Blocks, a)
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (MuseParser m (F Blocks, a) -> MuseParser m (F Blocks, a))
-> MuseParser m (F Blocks, a) -> MuseParser m (F Blocks, a)
forall a b. (a -> b) -> a -> b
$ do Maybe Char
blank <- ParsecT Sources MuseState (ReaderT MuseEnv m) Char
-> ParsecT Sources MuseState (ReaderT MuseEnv m) (Maybe Char)
forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m (Maybe a)
optionMaybe ParsecT Sources MuseState (ReaderT MuseEnv m) Char
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParserT s st m Char
blankline
ParsecT Sources MuseState (ReaderT MuseEnv m) Char
-> ParsecT Sources MuseState (ReaderT MuseEnv m) ()
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m ()
skipMany ParsecT Sources MuseState (ReaderT MuseEnv m) Char
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParserT s st m Char
blankline
Int -> ParserT Sources MuseState (ReaderT MuseEnv m) Text
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char, HasReaderOptions st) =>
Int -> ParserT s st m Text
indentWith Int
col
(MuseEnv -> MuseEnv)
-> MuseParser m (F Blocks, a) -> MuseParser m (F Blocks, a)
forall r (m :: * -> *) a. MonadReader r m => (r -> r) -> m a -> m a
local (\MuseEnv
s -> MuseEnv
s { museInPara :: Bool
museInPara = MuseEnv -> Bool
museInPara MuseEnv
s Bool -> Bool -> Bool
&& Maybe Char -> Bool
forall a. Maybe a -> Bool
isNothing Maybe Char
blank }) MuseParser m (F Blocks, a)
p
parseBlock :: PandocMonad m => MuseParser m (F Blocks)
parseBlock :: MuseParser m (F Blocks)
parseBlock = do
F Blocks
res <- MuseParser m (F Blocks)
forall (m :: * -> *). PandocMonad m => MuseParser m (F Blocks)
blockElements MuseParser m (F Blocks)
-> MuseParser m (F Blocks) -> MuseParser m (F Blocks)
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> MuseParser m (F Blocks)
para
Text -> ParsecT Sources MuseState (ReaderT MuseEnv m) ()
forall (m :: * -> *). PandocMonad m => Text -> m ()
trace (Int -> Text -> Text
T.take Int
60 (Text -> Text) -> Text -> Text
forall a b. (a -> b) -> a -> b
$ [Block] -> Text
forall a. Show a => a -> Text
tshow ([Block] -> Text) -> [Block] -> Text
forall a b. (a -> b) -> a -> b
$ Blocks -> [Block]
forall a. Many a -> [a]
B.toList (Blocks -> [Block]) -> Blocks -> [Block]
forall a b. (a -> b) -> a -> b
$ F Blocks -> MuseState -> Blocks
forall s a. Future s a -> s -> a
runF F Blocks
res MuseState
forall a. Default a => a
def)
F Blocks -> MuseParser m (F Blocks)
forall (m :: * -> *) a. Monad m => a -> m a
return F Blocks
res
where para :: MuseParser m (F Blocks)
para = (F Blocks, ()) -> F Blocks
forall a b. (a, b) -> a
fst ((F Blocks, ()) -> F Blocks)
-> ParsecT Sources MuseState (ReaderT MuseEnv m) (F Blocks, ())
-> MuseParser m (F Blocks)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT Sources MuseState (ReaderT MuseEnv m) ()
-> ParsecT Sources MuseState (ReaderT MuseEnv m) (F Blocks, ())
forall (m :: * -> *) a.
PandocMonad m =>
MuseParser m a -> MuseParser m (F Blocks, a)
paraUntil (ParsecT Sources MuseState (ReaderT MuseEnv m) ()
-> ParsecT Sources MuseState (ReaderT MuseEnv m) ()
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT Sources MuseState (ReaderT MuseEnv m) ()
forall s (m :: * -> *) t u.
(Stream s m t, Show t) =>
ParsecT s u m ()
eof ParsecT Sources MuseState (ReaderT MuseEnv m) ()
-> ParsecT Sources MuseState (ReaderT MuseEnv m) ()
-> ParsecT Sources MuseState (ReaderT MuseEnv m) ()
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> MuseParser m (F Blocks)
-> ParsecT Sources MuseState (ReaderT MuseEnv m) ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (MuseParser m (F Blocks) -> MuseParser m (F Blocks)
forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m a
lookAhead MuseParser m (F Blocks)
forall (m :: * -> *). PandocMonad m => MuseParser m (F Blocks)
blockElements)))
blockElements :: PandocMonad m => MuseParser m (F Blocks)
blockElements :: MuseParser m (F Blocks)
blockElements = (F Blocks
forall a. Monoid a => a
mempty F Blocks
-> ParsecT Sources MuseState (ReaderT MuseEnv m) Char
-> MuseParser m (F Blocks)
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ ParsecT Sources MuseState (ReaderT MuseEnv m) Char
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParserT s st m Char
blankline)
MuseParser m (F Blocks)
-> MuseParser m (F Blocks) -> MuseParser m (F Blocks)
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> MuseParser m (F Blocks)
forall (m :: * -> *). PandocMonad m => MuseParser m (F Blocks)
comment
MuseParser m (F Blocks)
-> MuseParser m (F Blocks) -> MuseParser m (F Blocks)
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> MuseParser m (F Blocks)
forall (m :: * -> *). PandocMonad m => MuseParser m (F Blocks)
separator
MuseParser m (F Blocks)
-> MuseParser m (F Blocks) -> MuseParser m (F Blocks)
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> MuseParser m (F Blocks)
forall (m :: * -> *). PandocMonad m => MuseParser m (F Blocks)
pagebreak
MuseParser m (F Blocks)
-> MuseParser m (F Blocks) -> MuseParser m (F Blocks)
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> MuseParser m (F Blocks)
forall (m :: * -> *). PandocMonad m => MuseParser m (F Blocks)
example
MuseParser m (F Blocks)
-> MuseParser m (F Blocks) -> MuseParser m (F Blocks)
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> MuseParser m (F Blocks)
forall (m :: * -> *). PandocMonad m => MuseParser m (F Blocks)
exampleTag
MuseParser m (F Blocks)
-> MuseParser m (F Blocks) -> MuseParser m (F Blocks)
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> MuseParser m (F Blocks)
forall (m :: * -> *). PandocMonad m => MuseParser m (F Blocks)
literalTag
MuseParser m (F Blocks)
-> MuseParser m (F Blocks) -> MuseParser m (F Blocks)
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> MuseParser m (F Blocks)
forall (m :: * -> *). PandocMonad m => MuseParser m (F Blocks)
centerTag
MuseParser m (F Blocks)
-> MuseParser m (F Blocks) -> MuseParser m (F Blocks)
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> MuseParser m (F Blocks)
forall (m :: * -> *). PandocMonad m => MuseParser m (F Blocks)
rightTag
MuseParser m (F Blocks)
-> MuseParser m (F Blocks) -> MuseParser m (F Blocks)
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> MuseParser m (F Blocks)
forall (m :: * -> *). PandocMonad m => MuseParser m (F Blocks)
quoteTag
MuseParser m (F Blocks)
-> MuseParser m (F Blocks) -> MuseParser m (F Blocks)
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> MuseParser m (F Blocks)
forall (m :: * -> *). PandocMonad m => MuseParser m (F Blocks)
divTag
MuseParser m (F Blocks)
-> MuseParser m (F Blocks) -> MuseParser m (F Blocks)
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> MuseParser m (F Blocks)
forall (m :: * -> *). PandocMonad m => MuseParser m (F Blocks)
biblioTag
MuseParser m (F Blocks)
-> MuseParser m (F Blocks) -> MuseParser m (F Blocks)
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> MuseParser m (F Blocks)
forall (m :: * -> *). PandocMonad m => MuseParser m (F Blocks)
playTag
MuseParser m (F Blocks)
-> MuseParser m (F Blocks) -> MuseParser m (F Blocks)
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> MuseParser m (F Blocks)
forall (m :: * -> *). PandocMonad m => MuseParser m (F Blocks)
verseTag
MuseParser m (F Blocks)
-> MuseParser m (F Blocks) -> MuseParser m (F Blocks)
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> MuseParser m (F Blocks)
forall (m :: * -> *). PandocMonad m => MuseParser m (F Blocks)
lineBlock
MuseParser m (F Blocks)
-> MuseParser m (F Blocks) -> MuseParser m (F Blocks)
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> MuseParser m (F Blocks)
forall (m :: * -> *). PandocMonad m => MuseParser m (F Blocks)
museGridTable
MuseParser m (F Blocks)
-> MuseParser m (F Blocks) -> MuseParser m (F Blocks)
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> MuseParser m (F Blocks)
forall (m :: * -> *). PandocMonad m => MuseParser m (F Blocks)
table
MuseParser m (F Blocks)
-> MuseParser m (F Blocks) -> MuseParser m (F Blocks)
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> MuseParser m (F Blocks)
forall (m :: * -> *). PandocMonad m => MuseParser m (F Blocks)
commentTag
comment :: PandocMonad m => MuseParser m (F Blocks)
= MuseParser m (F Blocks) -> MuseParser m (F Blocks)
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (MuseParser m (F Blocks) -> MuseParser m (F Blocks))
-> MuseParser m (F Blocks) -> MuseParser m (F Blocks)
forall a b. (a -> b) -> a -> b
$ F Blocks
forall a. Monoid a => a
mempty
F Blocks
-> ParsecT Sources MuseState (ReaderT MuseEnv m) ()
-> MuseParser m (F Blocks)
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ ParsecT Sources MuseState (ReaderT MuseEnv m) ()
forall (m :: * -> *). PandocMonad m => MuseParser m ()
firstColumn
MuseParser m (F Blocks)
-> ParsecT Sources MuseState (ReaderT MuseEnv m) Char
-> MuseParser m (F Blocks)
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* Char -> ParsecT Sources MuseState (ReaderT MuseEnv m) Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
Char -> ParsecT s u m Char
char Char
';'
MuseParser m (F Blocks)
-> ParsecT Sources MuseState (ReaderT MuseEnv m) ()
-> MuseParser m (F Blocks)
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* ParsecT Sources MuseState (ReaderT MuseEnv m) SourceName
-> ParsecT Sources MuseState (ReaderT MuseEnv m) ()
forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m ()
optional (ParsecT Sources MuseState (ReaderT MuseEnv m) Char
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParserT s st m Char
spaceChar ParsecT Sources MuseState (ReaderT MuseEnv m) Char
-> ParsecT Sources MuseState (ReaderT MuseEnv m) SourceName
-> ParsecT Sources MuseState (ReaderT MuseEnv m) SourceName
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> ParsecT Sources MuseState (ReaderT MuseEnv m) Char
-> ParsecT Sources MuseState (ReaderT MuseEnv m) SourceName
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
many (SourceName -> ParsecT Sources MuseState (ReaderT MuseEnv m) Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
SourceName -> ParsecT s u m Char
noneOf SourceName
"\n"))
MuseParser m (F Blocks)
-> ParsecT Sources MuseState (ReaderT MuseEnv m) ()
-> MuseParser m (F Blocks)
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* ParsecT Sources MuseState (ReaderT MuseEnv m) ()
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParserT s st m ()
eol
separator :: PandocMonad m => MuseParser m (F Blocks)
separator :: MuseParser m (F Blocks)
separator = MuseParser m (F Blocks) -> MuseParser m (F Blocks)
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (MuseParser m (F Blocks) -> MuseParser m (F Blocks))
-> MuseParser m (F Blocks) -> MuseParser m (F Blocks)
forall a b. (a -> b) -> a -> b
$ Blocks -> F Blocks
forall (f :: * -> *) a. Applicative f => a -> f a
pure Blocks
B.horizontalRule
F Blocks
-> ParsecT Sources MuseState (ReaderT MuseEnv m) SourceName
-> MuseParser m (F Blocks)
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ SourceName
-> ParsecT Sources MuseState (ReaderT MuseEnv m) SourceName
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
SourceName -> ParsecT s u m SourceName
string SourceName
"----"
MuseParser m (F Blocks)
-> ParsecT Sources MuseState (ReaderT MuseEnv m) SourceName
-> MuseParser m (F Blocks)
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* ParsecT Sources MuseState (ReaderT MuseEnv m) Char
-> ParsecT Sources MuseState (ReaderT MuseEnv m) SourceName
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
many (Char -> ParsecT Sources MuseState (ReaderT MuseEnv m) Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
Char -> ParsecT s u m Char
char Char
'-')
MuseParser m (F Blocks)
-> ParsecT Sources MuseState (ReaderT MuseEnv m) SourceName
-> MuseParser m (F Blocks)
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* ParsecT Sources MuseState (ReaderT MuseEnv m) Char
-> ParsecT Sources MuseState (ReaderT MuseEnv m) SourceName
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
many ParsecT Sources MuseState (ReaderT MuseEnv m) Char
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParserT s st m Char
spaceChar
MuseParser m (F Blocks)
-> ParsecT Sources MuseState (ReaderT MuseEnv m) ()
-> MuseParser m (F Blocks)
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* ParsecT Sources MuseState (ReaderT MuseEnv m) ()
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParserT s st m ()
eol
pagebreak :: PandocMonad m => MuseParser m (F Blocks)
pagebreak :: MuseParser m (F Blocks)
pagebreak = MuseParser m (F Blocks) -> MuseParser m (F Blocks)
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (MuseParser m (F Blocks) -> MuseParser m (F Blocks))
-> MuseParser m (F Blocks) -> MuseParser m (F Blocks)
forall a b. (a -> b) -> a -> b
$ Blocks -> F Blocks
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Attr -> Blocks -> Blocks
B.divWith (Text
"", [], [(Text
"style", Text
"page-break-before: always;")]) Blocks
forall a. Monoid a => a
mempty)
F Blocks
-> ParsecT Sources MuseState (ReaderT MuseEnv m) SourceName
-> MuseParser m (F Blocks)
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ Int
-> ParsecT Sources MuseState (ReaderT MuseEnv m) Char
-> ParsecT Sources MuseState (ReaderT MuseEnv m) SourceName
forall s (m :: * -> *) t u a.
Stream s m t =>
Int -> ParsecT s u m a -> ParsecT s u m [a]
count Int
6 ParsecT Sources MuseState (ReaderT MuseEnv m) Char
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParserT s st m Char
spaceChar
MuseParser m (F Blocks)
-> ParsecT Sources MuseState (ReaderT MuseEnv m) SourceName
-> MuseParser m (F Blocks)
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* ParsecT Sources MuseState (ReaderT MuseEnv m) Char
-> ParsecT Sources MuseState (ReaderT MuseEnv m) SourceName
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
many ParsecT Sources MuseState (ReaderT MuseEnv m) Char
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParserT s st m Char
spaceChar
MuseParser m (F Blocks)
-> ParsecT Sources MuseState (ReaderT MuseEnv m) SourceName
-> MuseParser m (F Blocks)
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* SourceName
-> ParsecT Sources MuseState (ReaderT MuseEnv m) SourceName
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
SourceName -> ParsecT s u m SourceName
string SourceName
"* * * * *"
MuseParser m (F Blocks)
-> ParsecT Sources MuseState (ReaderT MuseEnv m) SourceName
-> MuseParser m (F Blocks)
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* ParsecT Sources MuseState (ReaderT MuseEnv m) Char
-> ParsecT Sources MuseState (ReaderT MuseEnv m) ()
-> ParsecT Sources MuseState (ReaderT MuseEnv m) SourceName
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 MuseState (ReaderT MuseEnv m) Char
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParserT s st m Char
spaceChar ParsecT Sources MuseState (ReaderT MuseEnv m) ()
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParserT s st m ()
eol
headingStart :: PandocMonad m => MuseParser m (Text, Int)
headingStart :: MuseParser m (Text, Int)
headingStart = MuseParser m (Text, Int) -> MuseParser m (Text, Int)
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (MuseParser m (Text, Int) -> MuseParser m (Text, Int))
-> MuseParser m (Text, Int) -> MuseParser m (Text, Int)
forall a b. (a -> b) -> a -> b
$ (,)
(Text -> Int -> (Text, Int))
-> ParsecT Sources MuseState (ReaderT MuseEnv m) Text
-> ParsecT
Sources MuseState (ReaderT MuseEnv m) (Int -> (Text, Int))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Text
-> ParsecT Sources MuseState (ReaderT MuseEnv m) Text
-> ParsecT Sources MuseState (ReaderT MuseEnv 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 MuseState (ReaderT MuseEnv m) Text
-> ParsecT Sources MuseState (ReaderT MuseEnv m) Text
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT Sources MuseState (ReaderT MuseEnv m) Text
forall (m :: * -> *). PandocMonad m => MuseParser m Text
parseAnchor ParsecT Sources MuseState (ReaderT MuseEnv m) Text
-> ParsecT Sources MuseState (ReaderT MuseEnv m) SourceName
-> ParsecT Sources MuseState (ReaderT MuseEnv m) Text
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* ParsecT Sources MuseState (ReaderT MuseEnv m) Char
-> ParsecT Sources MuseState (ReaderT MuseEnv m) ()
-> ParsecT Sources MuseState (ReaderT MuseEnv m) SourceName
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 MuseState (ReaderT MuseEnv m) Char
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParserT s st m Char
spaceChar ParsecT Sources MuseState (ReaderT MuseEnv m) ()
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParserT s st m ()
eol))
ParsecT Sources MuseState (ReaderT MuseEnv m) (Int -> (Text, Int))
-> ParsecT Sources MuseState (ReaderT MuseEnv m) ()
-> ParsecT
Sources MuseState (ReaderT MuseEnv m) (Int -> (Text, Int))
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* ParsecT Sources MuseState (ReaderT MuseEnv m) ()
forall (m :: * -> *). PandocMonad m => MuseParser m ()
firstColumn
ParsecT Sources MuseState (ReaderT MuseEnv m) (Int -> (Text, Int))
-> ParsecT Sources MuseState (ReaderT MuseEnv m) Int
-> MuseParser m (Text, Int)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (SourceName -> Int)
-> ParsecT Sources MuseState (ReaderT MuseEnv m) SourceName
-> ParsecT Sources MuseState (ReaderT MuseEnv m) Int
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap SourceName -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length (ParsecT Sources MuseState (ReaderT MuseEnv m) Char
-> ParsecT Sources MuseState (ReaderT MuseEnv 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 MuseState (ReaderT MuseEnv m) Char
-> ParsecT Sources MuseState (ReaderT MuseEnv m) SourceName)
-> ParsecT Sources MuseState (ReaderT MuseEnv m) Char
-> ParsecT Sources MuseState (ReaderT MuseEnv m) SourceName
forall a b. (a -> b) -> a -> b
$ Char -> ParsecT Sources MuseState (ReaderT MuseEnv m) Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
Char -> ParsecT s u m Char
char Char
'*')
MuseParser m (Text, Int)
-> ParsecT Sources MuseState (ReaderT MuseEnv m) Char
-> MuseParser m (Text, Int)
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* ParsecT Sources MuseState (ReaderT MuseEnv m) Char
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParserT s st m Char
spaceChar
emacsHeading :: PandocMonad m => MuseParser m (F Blocks)
emacsHeading :: MuseParser m (F Blocks)
emacsHeading = MuseParser m (F Blocks) -> MuseParser m (F Blocks)
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (MuseParser m (F Blocks) -> MuseParser m (F Blocks))
-> MuseParser m (F Blocks) -> MuseParser m (F Blocks)
forall a b. (a -> b) -> a -> b
$ do
Extension -> ParserT Sources MuseState (ReaderT MuseEnv m) ()
forall s (m :: * -> *) a st.
(Stream s m a, HasReaderOptions st) =>
Extension -> ParserT s st m ()
guardDisabled Extension
Ext_amuse
(Text
anchorId, Int
level) <- MuseParser m (Text, Int)
forall (m :: * -> *). PandocMonad m => MuseParser m (Text, Int)
headingStart
F Inlines
content <- F Inlines -> F Inlines
forall s. Future s Inlines -> Future s Inlines
trimInlinesF (F Inlines -> F Inlines)
-> ([F Inlines] -> F Inlines) -> [F Inlines] -> F Inlines
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [F Inlines] -> F Inlines
forall a. Monoid a => [a] -> a
mconcat ([F Inlines] -> F Inlines)
-> ParsecT Sources MuseState (ReaderT MuseEnv m) [F Inlines]
-> ParsecT Sources MuseState (ReaderT MuseEnv m) (F Inlines)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT Sources MuseState (ReaderT MuseEnv m) (F Inlines)
-> ParserT Sources MuseState (ReaderT MuseEnv m) ()
-> ParsecT Sources MuseState (ReaderT MuseEnv m) [F Inlines]
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 MuseState (ReaderT MuseEnv m) (F Inlines)
forall (m :: * -> *). PandocMonad m => MuseParser m (F Inlines)
inline ParserT Sources MuseState (ReaderT MuseEnv m) ()
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParserT s st m ()
eol
Attr
attr <- Attr
-> Inlines -> ParserT Sources MuseState (ReaderT MuseEnv m) Attr
forall s (m :: * -> *) a st.
(Stream s m a, HasReaderOptions st, HasLogMessages st,
HasIdentifierList st) =>
Attr -> Inlines -> ParserT s st m Attr
registerHeader (Text
anchorId, [], []) (F Inlines -> MuseState -> Inlines
forall s a. Future s a -> s -> a
runF F Inlines
content MuseState
forall a. Default a => a
def)
F Blocks -> MuseParser m (F Blocks)
forall (m :: * -> *) a. Monad m => a -> m a
return (F Blocks -> MuseParser m (F Blocks))
-> F Blocks -> MuseParser m (F Blocks)
forall a b. (a -> b) -> a -> b
$ Attr -> Int -> Inlines -> Blocks
B.headerWith Attr
attr Int
level (Inlines -> Blocks) -> F Inlines -> F Blocks
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> F Inlines
content
amuseHeadingUntil :: PandocMonad m
=> MuseParser m a
-> MuseParser m (F Blocks, a)
amuseHeadingUntil :: MuseParser m a -> MuseParser m (F Blocks, a)
amuseHeadingUntil MuseParser m a
end = MuseParser m (F Blocks, a) -> MuseParser m (F Blocks, a)
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (MuseParser m (F Blocks, a) -> MuseParser m (F Blocks, a))
-> MuseParser m (F Blocks, a) -> MuseParser m (F Blocks, a)
forall a b. (a -> b) -> a -> b
$ do
Extension -> ParserT Sources MuseState (ReaderT MuseEnv m) ()
forall s (m :: * -> *) a st.
(Stream s m a, HasReaderOptions st) =>
Extension -> ParserT s st m ()
guardEnabled Extension
Ext_amuse
(Text
anchorId, Int
level) <- MuseParser m (Text, Int)
forall (m :: * -> *). PandocMonad m => MuseParser m (Text, Int)
headingStart
(F Inlines
content, a
e) <- MuseParser m a -> MuseParser m (F Inlines, a)
forall (m :: * -> *) a.
PandocMonad m =>
MuseParser m a -> MuseParser m (F Inlines, a)
paraContentsUntil MuseParser m a
end
Attr
attr <- Attr
-> Inlines -> ParserT Sources MuseState (ReaderT MuseEnv m) Attr
forall s (m :: * -> *) a st.
(Stream s m a, HasReaderOptions st, HasLogMessages st,
HasIdentifierList st) =>
Attr -> Inlines -> ParserT s st m Attr
registerHeader (Text
anchorId, [], []) (F Inlines -> MuseState -> Inlines
forall s a. Future s a -> s -> a
runF F Inlines
content MuseState
forall a. Default a => a
def)
(F Blocks, a) -> MuseParser m (F Blocks, a)
forall (m :: * -> *) a. Monad m => a -> m a
return (Attr -> Int -> Inlines -> Blocks
B.headerWith Attr
attr Int
level (Inlines -> Blocks) -> F Inlines -> F Blocks
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> F Inlines
content, a
e)
example :: PandocMonad m => MuseParser m (F Blocks)
example :: MuseParser m (F Blocks)
example = MuseParser m (F Blocks) -> MuseParser m (F Blocks)
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (MuseParser m (F Blocks) -> MuseParser m (F Blocks))
-> MuseParser m (F Blocks) -> MuseParser m (F Blocks)
forall a b. (a -> b) -> a -> b
$ Blocks -> F Blocks
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Blocks -> F Blocks) -> (Text -> Blocks) -> Text -> F Blocks
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Blocks
B.codeBlock
(Text -> F Blocks)
-> ParsecT Sources MuseState (ReaderT MuseEnv m) SourceName
-> ParsecT Sources MuseState (ReaderT MuseEnv m) (Text -> F Blocks)
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ SourceName
-> ParsecT Sources MuseState (ReaderT MuseEnv m) SourceName
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
SourceName -> ParsecT s u m SourceName
string SourceName
"{{{"
ParsecT Sources MuseState (ReaderT MuseEnv m) (Text -> F Blocks)
-> ParsecT Sources MuseState (ReaderT MuseEnv m) SourceName
-> ParsecT Sources MuseState (ReaderT MuseEnv m) (Text -> F Blocks)
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* ParsecT Sources MuseState (ReaderT MuseEnv m) Char
-> ParsecT Sources MuseState (ReaderT MuseEnv m) SourceName
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
many ParsecT Sources MuseState (ReaderT MuseEnv m) Char
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParserT s st m Char
spaceChar
ParsecT Sources MuseState (ReaderT MuseEnv m) (Text -> F Blocks)
-> ParsecT Sources MuseState (ReaderT MuseEnv m) Text
-> MuseParser m (F Blocks)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (Text -> Text
unindent (Text -> Text)
-> ParsecT Sources MuseState (ReaderT MuseEnv m) Text
-> ParsecT Sources MuseState (ReaderT MuseEnv m) Text
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT Sources MuseState (ReaderT MuseEnv m) Char
-> ParsecT Sources MuseState (ReaderT MuseEnv m) SourceName
-> ParsecT Sources MuseState (ReaderT MuseEnv m) Text
forall s (m :: * -> *) t st a.
Stream s m t =>
ParserT s st m Char -> ParserT s st m a -> ParserT s st m Text
manyTillChar ParsecT Sources MuseState (ReaderT MuseEnv m) Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s u m Char
anyChar (SourceName
-> ParsecT Sources MuseState (ReaderT MuseEnv m) SourceName
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
SourceName -> ParsecT s u m SourceName
string SourceName
"}}}"))
exampleTag :: PandocMonad m => MuseParser m (F Blocks)
exampleTag :: MuseParser m (F Blocks)
exampleTag = MuseParser m (F Blocks) -> MuseParser m (F Blocks)
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (MuseParser m (F Blocks) -> MuseParser m (F Blocks))
-> MuseParser m (F Blocks) -> MuseParser m (F Blocks)
forall a b. (a -> b) -> a -> b
$ (Blocks -> F Blocks)
-> ParsecT Sources MuseState (ReaderT MuseEnv m) Blocks
-> MuseParser m (F Blocks)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Blocks -> F Blocks
forall (f :: * -> *) a. Applicative f => a -> f a
pure (ParsecT Sources MuseState (ReaderT MuseEnv m) Blocks
-> MuseParser m (F Blocks))
-> ParsecT Sources MuseState (ReaderT MuseEnv m) Blocks
-> MuseParser m (F Blocks)
forall a b. (a -> b) -> a -> b
$ Attr -> Text -> Blocks
B.codeBlockWith
(Attr -> Text -> Blocks)
-> ParsecT Sources MuseState (ReaderT MuseEnv m) SourceName
-> ParsecT
Sources MuseState (ReaderT MuseEnv m) (Attr -> Text -> Blocks)
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ ParsecT Sources MuseState (ReaderT MuseEnv m) Char
-> ParsecT Sources MuseState (ReaderT MuseEnv m) SourceName
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
many ParsecT Sources MuseState (ReaderT MuseEnv m) Char
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParserT s st m Char
spaceChar
ParsecT
Sources MuseState (ReaderT MuseEnv m) (Attr -> Text -> Blocks)
-> ParsecT Sources MuseState (ReaderT MuseEnv m) Attr
-> ParsecT Sources MuseState (ReaderT MuseEnv m) (Text -> Blocks)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ([(Text, Text)] -> Attr
htmlAttrToPandoc ([(Text, Text)] -> Attr)
-> ParsecT Sources MuseState (ReaderT MuseEnv m) [(Text, Text)]
-> ParsecT Sources MuseState (ReaderT MuseEnv m) Attr
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Text
-> ParsecT Sources MuseState (ReaderT MuseEnv m) [(Text, Text)]
forall (m :: * -> *).
PandocMonad m =>
Text -> MuseParser m [(Text, Text)]
openTag Text
"example")
ParsecT Sources MuseState (ReaderT MuseEnv m) (Text -> Blocks)
-> ParsecT Sources MuseState (ReaderT MuseEnv m) Text
-> ParsecT Sources MuseState (ReaderT MuseEnv m) Blocks
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (Text -> Text
unindent (Text -> Text)
-> ParsecT Sources MuseState (ReaderT MuseEnv m) Text
-> ParsecT Sources MuseState (ReaderT MuseEnv m) Text
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT Sources MuseState (ReaderT MuseEnv m) Char
-> ParserT Sources MuseState (ReaderT MuseEnv m) ()
-> ParsecT Sources MuseState (ReaderT MuseEnv m) Text
forall s (m :: * -> *) t st a.
Stream s m t =>
ParserT s st m Char -> ParserT s st m a -> ParserT s st m Text
manyTillChar ParsecT Sources MuseState (ReaderT MuseEnv m) Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s u m Char
anyChar (Text -> ParserT Sources MuseState (ReaderT MuseEnv m) ()
forall (m :: * -> *). PandocMonad m => Text -> MuseParser m ()
closeTag Text
"example"))
ParsecT Sources MuseState (ReaderT MuseEnv m) Blocks
-> ParsecT Sources MuseState (ReaderT MuseEnv m) SourceName
-> ParsecT Sources MuseState (ReaderT MuseEnv m) Blocks
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* ParsecT Sources MuseState (ReaderT MuseEnv m) Char
-> ParserT Sources MuseState (ReaderT MuseEnv m) ()
-> ParsecT Sources MuseState (ReaderT MuseEnv m) SourceName
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 MuseState (ReaderT MuseEnv m) Char
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParserT s st m Char
spaceChar ParserT Sources MuseState (ReaderT MuseEnv m) ()
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParserT s st m ()
eol
literalTag :: PandocMonad m => MuseParser m (F Blocks)
literalTag :: MuseParser m (F Blocks)
literalTag = MuseParser m (F Blocks) -> MuseParser m (F Blocks)
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (MuseParser m (F Blocks) -> MuseParser m (F Blocks))
-> MuseParser m (F Blocks) -> MuseParser m (F Blocks)
forall a b. (a -> b) -> a -> b
$ (Blocks -> F Blocks)
-> ParsecT Sources MuseState (ReaderT MuseEnv m) Blocks
-> MuseParser m (F Blocks)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Blocks -> F Blocks
forall (f :: * -> *) a. Applicative f => a -> f a
pure (ParsecT Sources MuseState (ReaderT MuseEnv m) Blocks
-> MuseParser m (F Blocks))
-> ParsecT Sources MuseState (ReaderT MuseEnv m) Blocks
-> MuseParser m (F Blocks)
forall a b. (a -> b) -> a -> b
$ Text -> Text -> Blocks
B.rawBlock
(Text -> Text -> Blocks)
-> ParsecT Sources MuseState (ReaderT MuseEnv m) SourceName
-> ParsecT
Sources MuseState (ReaderT MuseEnv m) (Text -> Text -> Blocks)
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ ParsecT Sources MuseState (ReaderT MuseEnv m) Char
-> ParsecT Sources MuseState (ReaderT MuseEnv m) SourceName
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
many ParsecT Sources MuseState (ReaderT MuseEnv m) Char
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParserT s st m Char
spaceChar
ParsecT
Sources MuseState (ReaderT MuseEnv m) (Text -> Text -> Blocks)
-> ParsecT Sources MuseState (ReaderT MuseEnv m) Text
-> ParsecT Sources MuseState (ReaderT MuseEnv m) (Text -> Blocks)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (Text -> Maybe Text -> Text
forall a. a -> Maybe a -> a
fromMaybe Text
"html" (Maybe Text -> Text)
-> ([(Text, Text)] -> Maybe Text) -> [(Text, Text)] -> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> [(Text, Text)] -> Maybe Text
forall a b. Eq a => a -> [(a, b)] -> Maybe b
lookup Text
"style" ([(Text, Text)] -> Text)
-> ParsecT Sources MuseState (ReaderT MuseEnv m) [(Text, Text)]
-> ParsecT Sources MuseState (ReaderT MuseEnv m) Text
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Text
-> ParsecT Sources MuseState (ReaderT MuseEnv m) [(Text, Text)]
forall (m :: * -> *).
PandocMonad m =>
Text -> MuseParser m [(Text, Text)]
openTag Text
"literal")
ParsecT Sources MuseState (ReaderT MuseEnv m) (Text -> Blocks)
-> ParsecT Sources MuseState (ReaderT MuseEnv m) SourceName
-> ParsecT Sources MuseState (ReaderT MuseEnv m) (Text -> Blocks)
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* ParsecT Sources MuseState (ReaderT MuseEnv m) Char
-> ParsecT Sources MuseState (ReaderT MuseEnv m) ()
-> ParsecT Sources MuseState (ReaderT MuseEnv m) SourceName
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 MuseState (ReaderT MuseEnv m) Char
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParserT s st m Char
spaceChar ParsecT Sources MuseState (ReaderT MuseEnv m) ()
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParserT s st m ()
eol
ParsecT Sources MuseState (ReaderT MuseEnv m) (Text -> Blocks)
-> ParsecT Sources MuseState (ReaderT MuseEnv m) Text
-> ParsecT Sources MuseState (ReaderT MuseEnv m) Blocks
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (Text -> Text
unindent (Text -> Text)
-> ParsecT Sources MuseState (ReaderT MuseEnv m) Text
-> ParsecT Sources MuseState (ReaderT MuseEnv m) Text
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT Sources MuseState (ReaderT MuseEnv m) Char
-> ParsecT Sources MuseState (ReaderT MuseEnv m) ()
-> ParsecT Sources MuseState (ReaderT MuseEnv m) Text
forall s (m :: * -> *) t st a.
Stream s m t =>
ParserT s st m Char -> ParserT s st m a -> ParserT s st m Text
manyTillChar ParsecT Sources MuseState (ReaderT MuseEnv m) Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s u m Char
anyChar (Text -> ParsecT Sources MuseState (ReaderT MuseEnv m) ()
forall (m :: * -> *). PandocMonad m => Text -> MuseParser m ()
closeTag Text
"literal"))
ParsecT Sources MuseState (ReaderT MuseEnv m) Blocks
-> ParsecT Sources MuseState (ReaderT MuseEnv m) SourceName
-> ParsecT Sources MuseState (ReaderT MuseEnv m) Blocks
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* ParsecT Sources MuseState (ReaderT MuseEnv m) Char
-> ParsecT Sources MuseState (ReaderT MuseEnv m) ()
-> ParsecT Sources MuseState (ReaderT MuseEnv m) SourceName
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 MuseState (ReaderT MuseEnv m) Char
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParserT s st m Char
spaceChar ParsecT Sources MuseState (ReaderT MuseEnv m) ()
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParserT s st m ()
eol
centerTag :: PandocMonad m => MuseParser m (F Blocks)
centerTag :: MuseParser m (F Blocks)
centerTag = (Attr, F Blocks) -> F Blocks
forall a b. (a, b) -> b
snd ((Attr, F Blocks) -> F Blocks)
-> ParsecT Sources MuseState (ReaderT MuseEnv m) (Attr, F Blocks)
-> MuseParser m (F Blocks)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Text
-> ParsecT Sources MuseState (ReaderT MuseEnv m) (Attr, F Blocks)
forall (m :: * -> *).
PandocMonad m =>
Text -> MuseParser m (Attr, F Blocks)
parseHtmlContent Text
"center"
rightTag :: PandocMonad m => MuseParser m (F Blocks)
rightTag :: MuseParser m (F Blocks)
rightTag = (Attr, F Blocks) -> F Blocks
forall a b. (a, b) -> b
snd ((Attr, F Blocks) -> F Blocks)
-> ParsecT Sources MuseState (ReaderT MuseEnv m) (Attr, F Blocks)
-> MuseParser m (F Blocks)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Text
-> ParsecT Sources MuseState (ReaderT MuseEnv m) (Attr, F Blocks)
forall (m :: * -> *).
PandocMonad m =>
Text -> MuseParser m (Attr, F Blocks)
parseHtmlContent Text
"right"
quoteTag :: PandocMonad m => MuseParser m (F Blocks)
quoteTag :: MuseParser m (F Blocks)
quoteTag = (Blocks -> Blocks) -> F Blocks -> F Blocks
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Blocks -> Blocks
B.blockQuote (F Blocks -> F Blocks)
-> ((Attr, F Blocks) -> F Blocks) -> (Attr, F Blocks) -> F Blocks
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Attr, F Blocks) -> F Blocks
forall a b. (a, b) -> b
snd ((Attr, F Blocks) -> F Blocks)
-> ParsecT Sources MuseState (ReaderT MuseEnv m) (Attr, F Blocks)
-> MuseParser m (F Blocks)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Text
-> ParsecT Sources MuseState (ReaderT MuseEnv m) (Attr, F Blocks)
forall (m :: * -> *).
PandocMonad m =>
Text -> MuseParser m (Attr, F Blocks)
parseHtmlContent Text
"quote"
divTag :: PandocMonad m => MuseParser m (F Blocks)
divTag :: MuseParser m (F Blocks)
divTag = do
(Attr
attrs, F Blocks
content) <- Text -> MuseParser m (Attr, F Blocks)
forall (m :: * -> *).
PandocMonad m =>
Text -> MuseParser m (Attr, F Blocks)
parseHtmlContent Text
"div"
F Blocks -> MuseParser m (F Blocks)
forall (m :: * -> *) a. Monad m => a -> m a
return (F Blocks -> MuseParser m (F Blocks))
-> F Blocks -> MuseParser m (F Blocks)
forall a b. (a -> b) -> a -> b
$ Attr -> Blocks -> Blocks
B.divWith Attr
attrs (Blocks -> Blocks) -> F Blocks -> F Blocks
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> F Blocks
content
biblioTag :: PandocMonad m => MuseParser m (F Blocks)
biblioTag :: MuseParser m (F Blocks)
biblioTag = (Blocks -> Blocks) -> F Blocks -> F Blocks
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (Attr -> Blocks -> Blocks
B.divWith (Text
"", [Text
"biblio"], [])) (F Blocks -> F Blocks)
-> ((Attr, F Blocks) -> F Blocks) -> (Attr, F Blocks) -> F Blocks
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Attr, F Blocks) -> F Blocks
forall a b. (a, b) -> b
snd
((Attr, F Blocks) -> F Blocks)
-> ParsecT Sources MuseState (ReaderT MuseEnv m) ()
-> ParsecT
Sources
MuseState
(ReaderT MuseEnv m)
((Attr, F Blocks) -> F Blocks)
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ Extension -> ParsecT Sources MuseState (ReaderT MuseEnv m) ()
forall s (m :: * -> *) a st.
(Stream s m a, HasReaderOptions st) =>
Extension -> ParserT s st m ()
guardEnabled Extension
Ext_amuse
ParsecT
Sources
MuseState
(ReaderT MuseEnv m)
((Attr, F Blocks) -> F Blocks)
-> ParsecT Sources MuseState (ReaderT MuseEnv m) (Attr, F Blocks)
-> MuseParser m (F Blocks)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text
-> ParsecT Sources MuseState (ReaderT MuseEnv m) (Attr, F Blocks)
forall (m :: * -> *).
PandocMonad m =>
Text -> MuseParser m (Attr, F Blocks)
parseHtmlContent Text
"biblio"
playTag :: PandocMonad m => MuseParser m (F Blocks)
playTag :: MuseParser m (F Blocks)
playTag = do
Extension -> ParserT Sources MuseState (ReaderT MuseEnv m) ()
forall s (m :: * -> *) a st.
(Stream s m a, HasReaderOptions st) =>
Extension -> ParserT s st m ()
guardEnabled Extension
Ext_amuse
(Blocks -> Blocks) -> F Blocks -> F Blocks
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (Attr -> Blocks -> Blocks
B.divWith (Text
"", [Text
"play"], [])) (F Blocks -> F Blocks)
-> ((Attr, F Blocks) -> F Blocks) -> (Attr, F Blocks) -> F Blocks
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Attr, F Blocks) -> F Blocks
forall a b. (a, b) -> b
snd ((Attr, F Blocks) -> F Blocks)
-> ParsecT Sources MuseState (ReaderT MuseEnv m) (Attr, F Blocks)
-> MuseParser m (F Blocks)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Text
-> ParsecT Sources MuseState (ReaderT MuseEnv m) (Attr, F Blocks)
forall (m :: * -> *).
PandocMonad m =>
Text -> MuseParser m (Attr, F Blocks)
parseHtmlContent Text
"play"
verseLine :: PandocMonad m => MuseParser m (F Inlines)
verseLine :: MuseParser m (F Inlines)
verseLine = F Inlines -> F Inlines -> F Inlines
forall a. Semigroup a => a -> a -> a
(<>)
(F Inlines -> F Inlines -> F Inlines)
-> MuseParser m (F Inlines)
-> ParsecT
Sources MuseState (ReaderT MuseEnv m) (F Inlines -> F Inlines)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Inlines -> F Inlines)
-> ParsecT Sources MuseState (ReaderT MuseEnv m) Inlines
-> MuseParser m (F Inlines)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Inlines -> F Inlines
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Inlines
-> ParsecT Sources MuseState (ReaderT MuseEnv m) Inlines
-> ParsecT Sources MuseState (ReaderT MuseEnv m) Inlines
forall s (m :: * -> *) t a u.
Stream s m t =>
a -> ParsecT s u m a -> ParsecT s u m a
option Inlines
forall a. Monoid a => a
mempty (Text -> Inlines
B.str (Text -> Inlines)
-> ParsecT Sources MuseState (ReaderT MuseEnv m) Text
-> ParsecT Sources MuseState (ReaderT MuseEnv m) Inlines
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParserT Sources MuseState (ReaderT MuseEnv m) Char
-> ParsecT Sources MuseState (ReaderT MuseEnv m) Text
forall s (m :: * -> *) t st.
Stream s m t =>
ParserT s st m Char -> ParserT s st m Text
many1Char (Char
'\160' Char
-> ParserT Sources MuseState (ReaderT MuseEnv m) Char
-> ParserT Sources MuseState (ReaderT MuseEnv m) Char
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ Char -> ParserT Sources MuseState (ReaderT MuseEnv m) Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
Char -> ParsecT s u m Char
char Char
' ')))
ParsecT
Sources MuseState (ReaderT MuseEnv m) (F Inlines -> F Inlines)
-> MuseParser m (F Inlines) -> MuseParser m (F Inlines)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ([F Inlines] -> F Inlines)
-> ParsecT Sources MuseState (ReaderT MuseEnv m) [F Inlines]
-> MuseParser m (F Inlines)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (F Inlines -> F Inlines
forall s. Future s Inlines -> Future s Inlines
trimInlinesF (F Inlines -> F Inlines)
-> ([F Inlines] -> F Inlines) -> [F Inlines] -> F Inlines
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [F Inlines] -> F Inlines
forall a. Monoid a => [a] -> a
mconcat) (MuseParser m (F Inlines)
-> ParsecT Sources MuseState (ReaderT MuseEnv m) ()
-> ParsecT Sources MuseState (ReaderT MuseEnv m) [F Inlines]
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 MuseParser m (F Inlines)
forall (m :: * -> *). PandocMonad m => MuseParser m (F Inlines)
inline' ParsecT Sources MuseState (ReaderT MuseEnv m) ()
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParserT s st m ()
eol)
verseTag :: PandocMonad m => MuseParser m (F Blocks)
verseTag :: MuseParser m (F Blocks)
verseTag = MuseParser m (F Blocks) -> MuseParser m (F Blocks)
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (MuseParser m (F Blocks) -> MuseParser m (F Blocks))
-> MuseParser m (F Blocks) -> MuseParser m (F Blocks)
forall a b. (a -> b) -> a -> b
$ MuseParser m Int
forall (m :: * -> *). PandocMonad m => MuseParser m Int
getIndent MuseParser m Int
-> (Int -> MuseParser m (F Blocks)) -> MuseParser m (F Blocks)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Int
indent -> ([Inlines] -> Blocks) -> Future MuseState [Inlines] -> F Blocks
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap [Inlines] -> Blocks
B.lineBlock (Future MuseState [Inlines] -> F Blocks)
-> ([F Inlines] -> Future MuseState [Inlines])
-> [F Inlines]
-> F Blocks
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [F Inlines] -> Future MuseState [Inlines]
forall (t :: * -> *) (m :: * -> *) a.
(Traversable t, Monad m) =>
t (m a) -> m (t a)
sequence
([F Inlines] -> F Blocks)
-> ParsecT Sources MuseState (ReaderT MuseEnv m) [(Text, Text)]
-> ParsecT
Sources MuseState (ReaderT MuseEnv m) ([F Inlines] -> F Blocks)
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ Text
-> ParsecT Sources MuseState (ReaderT MuseEnv m) [(Text, Text)]
forall (m :: * -> *).
PandocMonad m =>
Text -> MuseParser m [(Text, Text)]
openTag Text
"verse"
ParsecT
Sources MuseState (ReaderT MuseEnv m) ([F Inlines] -> F Blocks)
-> ParsecT Sources MuseState (ReaderT MuseEnv m) SourceName
-> ParsecT
Sources MuseState (ReaderT MuseEnv m) ([F Inlines] -> F Blocks)
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* ParsecT Sources MuseState (ReaderT MuseEnv m) Char
-> ParsecT Sources MuseState (ReaderT MuseEnv m) ()
-> ParsecT Sources MuseState (ReaderT MuseEnv m) SourceName
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 MuseState (ReaderT MuseEnv m) Char
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParserT s st m Char
spaceChar ParsecT Sources MuseState (ReaderT MuseEnv m) ()
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParserT s st m ()
eol
ParsecT
Sources MuseState (ReaderT MuseEnv m) ([F Inlines] -> F Blocks)
-> ParsecT Sources MuseState (ReaderT MuseEnv m) [F Inlines]
-> MuseParser m (F Blocks)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ParsecT Sources MuseState (ReaderT MuseEnv m) (F Inlines)
-> ParsecT Sources MuseState (ReaderT MuseEnv m) ()
-> ParsecT Sources MuseState (ReaderT MuseEnv m) [F Inlines]
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 (Int -> ParserT Sources MuseState (ReaderT MuseEnv m) Text
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char, HasReaderOptions st) =>
Int -> ParserT s st m Text
indentWith Int
indent ParserT Sources MuseState (ReaderT MuseEnv m) Text
-> ParsecT Sources MuseState (ReaderT MuseEnv m) (F Inlines)
-> ParsecT Sources MuseState (ReaderT MuseEnv m) (F Inlines)
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> ParsecT Sources MuseState (ReaderT MuseEnv m) (F Inlines)
forall (m :: * -> *). PandocMonad m => MuseParser m (F Inlines)
verseLine) (ParsecT Sources MuseState (ReaderT MuseEnv m) ()
-> ParsecT Sources MuseState (ReaderT MuseEnv m) ()
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT Sources MuseState (ReaderT MuseEnv m) ()
-> ParsecT Sources MuseState (ReaderT MuseEnv m) ())
-> ParsecT Sources MuseState (ReaderT MuseEnv m) ()
-> ParsecT Sources MuseState (ReaderT MuseEnv m) ()
forall a b. (a -> b) -> a -> b
$ Int -> ParserT Sources MuseState (ReaderT MuseEnv m) Text
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char, HasReaderOptions st) =>
Int -> ParserT s st m Text
indentWith Int
indent ParserT Sources MuseState (ReaderT MuseEnv m) Text
-> ParsecT Sources MuseState (ReaderT MuseEnv m) ()
-> ParsecT Sources MuseState (ReaderT MuseEnv m) ()
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Text -> ParsecT Sources MuseState (ReaderT MuseEnv m) ()
forall (m :: * -> *). PandocMonad m => Text -> MuseParser m ()
closeTag Text
"verse")
MuseParser m (F Blocks)
-> ParsecT Sources MuseState (ReaderT MuseEnv m) SourceName
-> MuseParser m (F Blocks)
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* ParsecT Sources MuseState (ReaderT MuseEnv m) Char
-> ParsecT Sources MuseState (ReaderT MuseEnv m) ()
-> ParsecT Sources MuseState (ReaderT MuseEnv m) SourceName
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 MuseState (ReaderT MuseEnv m) Char
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParserT s st m Char
spaceChar ParsecT Sources MuseState (ReaderT MuseEnv m) ()
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParserT s st m ()
eol
commentTag :: PandocMonad m => MuseParser m (F Blocks)
= MuseParser m (F Blocks) -> MuseParser m (F Blocks)
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (MuseParser m (F Blocks) -> MuseParser m (F Blocks))
-> MuseParser m (F Blocks) -> MuseParser m (F Blocks)
forall a b. (a -> b) -> a -> b
$ F Blocks
forall a. Monoid a => a
mempty
F Blocks
-> ParsecT Sources MuseState (ReaderT MuseEnv m) SourceName
-> MuseParser m (F Blocks)
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ ParsecT Sources MuseState (ReaderT MuseEnv m) Char
-> ParsecT Sources MuseState (ReaderT MuseEnv m) SourceName
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
many ParsecT Sources MuseState (ReaderT MuseEnv m) Char
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParserT s st m Char
spaceChar
MuseParser m (F Blocks)
-> ParsecT Sources MuseState (ReaderT MuseEnv m) [(Text, Text)]
-> MuseParser m (F Blocks)
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* Text
-> ParsecT Sources MuseState (ReaderT MuseEnv m) [(Text, Text)]
forall (m :: * -> *).
PandocMonad m =>
Text -> MuseParser m [(Text, Text)]
openTag Text
"comment"
MuseParser m (F Blocks)
-> ParsecT Sources MuseState (ReaderT MuseEnv m) SourceName
-> MuseParser m (F Blocks)
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* ParsecT Sources MuseState (ReaderT MuseEnv m) Char
-> ParsecT Sources MuseState (ReaderT MuseEnv m) ()
-> ParsecT Sources MuseState (ReaderT MuseEnv m) SourceName
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 MuseState (ReaderT MuseEnv m) Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s u m Char
anyChar (Text -> ParsecT Sources MuseState (ReaderT MuseEnv m) ()
forall (m :: * -> *). PandocMonad m => Text -> MuseParser m ()
closeTag Text
"comment")
MuseParser m (F Blocks)
-> ParsecT Sources MuseState (ReaderT MuseEnv m) SourceName
-> MuseParser m (F Blocks)
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* ParsecT Sources MuseState (ReaderT MuseEnv m) Char
-> ParsecT Sources MuseState (ReaderT MuseEnv m) ()
-> ParsecT Sources MuseState (ReaderT MuseEnv m) SourceName
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 MuseState (ReaderT MuseEnv m) Char
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParserT s st m Char
spaceChar ParsecT Sources MuseState (ReaderT MuseEnv m) ()
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParserT s st m ()
eol
paraContentsUntil :: PandocMonad m
=> MuseParser m a
-> MuseParser m (F Inlines, a)
paraContentsUntil :: MuseParser m a -> MuseParser m (F Inlines, a)
paraContentsUntil MuseParser m a
end = ([F Inlines] -> F Inlines) -> ([F Inlines], a) -> (F Inlines, a)
forall (p :: * -> * -> *) a b c.
Bifunctor p =>
(a -> b) -> p a c -> p b c
first (F Inlines -> F Inlines
forall s. Future s Inlines -> Future s Inlines
trimInlinesF (F Inlines -> F Inlines)
-> ([F Inlines] -> F Inlines) -> [F Inlines] -> F Inlines
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [F Inlines] -> F Inlines
forall a. Monoid a => [a] -> a
mconcat)
(([F Inlines], a) -> (F Inlines, a))
-> ParsecT Sources MuseState (ReaderT MuseEnv m) ([F Inlines], a)
-> MuseParser m (F Inlines, a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParserT Sources MuseState (ReaderT MuseEnv m) (F Inlines)
-> MuseParser m a
-> ParsecT Sources MuseState (ReaderT MuseEnv m) ([F Inlines], a)
forall s u (m :: * -> *) a b.
ParserT s u m a -> ParserT s u m b -> ParserT s u m ([a], b)
manyUntil ParserT Sources MuseState (ReaderT MuseEnv m) (F Inlines)
forall (m :: * -> *). PandocMonad m => MuseParser m (F Inlines)
inline (MuseParser m a -> MuseParser m a
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT Sources MuseState (ReaderT MuseEnv m) Char
-> ParsecT Sources MuseState (ReaderT MuseEnv m) ()
-> ParsecT Sources MuseState (ReaderT MuseEnv m) SourceName
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 MuseState (ReaderT MuseEnv m) Char
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParserT s st m Char
spaceChar ParsecT Sources MuseState (ReaderT MuseEnv m) ()
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParserT s st m ()
eol ParsecT Sources MuseState (ReaderT MuseEnv m) SourceName
-> MuseParser m a -> MuseParser m a
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> (MuseEnv -> MuseEnv) -> MuseParser m a -> MuseParser m a
forall r (m :: * -> *) a. MonadReader r m => (r -> r) -> m a -> m a
local (\MuseEnv
s -> MuseEnv
s { museInPara :: Bool
museInPara = Bool
True}) MuseParser m a
end))
paraUntil :: PandocMonad m
=> MuseParser m a
-> MuseParser m (F Blocks, a)
paraUntil :: MuseParser m a -> MuseParser m (F Blocks, a)
paraUntil MuseParser m a
end = do
Bool
inPara <- (MuseEnv -> Bool)
-> ParsecT Sources MuseState (ReaderT MuseEnv m) Bool
forall r (m :: * -> *) a. MonadReader r m => (r -> a) -> m a
asks MuseEnv -> Bool
museInPara
Bool -> ParsecT Sources MuseState (ReaderT MuseEnv m) ()
forall (f :: * -> *). Alternative f => Bool -> f ()
guard (Bool -> ParsecT Sources MuseState (ReaderT MuseEnv m) ())
-> Bool -> ParsecT Sources MuseState (ReaderT MuseEnv m) ()
forall a b. (a -> b) -> a -> b
$ Bool -> Bool
not Bool
inPara
(F Inlines -> F Blocks) -> (F Inlines, a) -> (F Blocks, a)
forall (p :: * -> * -> *) a b c.
Bifunctor p =>
(a -> b) -> p a c -> p b c
first ((Inlines -> Blocks) -> F Inlines -> F Blocks
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Inlines -> Blocks
B.para) ((F Inlines, a) -> (F Blocks, a))
-> ParsecT Sources MuseState (ReaderT MuseEnv m) (F Inlines, a)
-> MuseParser m (F Blocks, a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> MuseParser m a
-> ParsecT Sources MuseState (ReaderT MuseEnv m) (F Inlines, a)
forall (m :: * -> *) a.
PandocMonad m =>
MuseParser m a -> MuseParser m (F Inlines, a)
paraContentsUntil MuseParser m a
end
noteMarker' :: PandocMonad m
=> Char
-> Char
-> MuseParser m Text
noteMarker' :: Char -> Char -> MuseParser m Text
noteMarker' Char
l Char
r = MuseParser m Text -> MuseParser m Text
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (MuseParser m Text -> MuseParser m Text)
-> MuseParser m Text -> MuseParser m Text
forall a b. (a -> b) -> a -> b
$ (\Char
x SourceName
y -> SourceName -> Text
T.pack (SourceName -> Text) -> SourceName -> Text
forall a b. (a -> b) -> a -> b
$ Char
lChar -> SourceName -> SourceName
forall a. a -> [a] -> [a]
:Char
xChar -> SourceName -> SourceName
forall a. a -> [a] -> [a]
:SourceName
y SourceName -> SourceName -> SourceName
forall a. [a] -> [a] -> [a]
++ [Char
r])
(Char -> SourceName -> Text)
-> ParsecT Sources MuseState (ReaderT MuseEnv m) Char
-> ParsecT
Sources MuseState (ReaderT MuseEnv m) (Char -> SourceName -> Text)
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ Char -> ParsecT Sources MuseState (ReaderT MuseEnv m) Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
Char -> ParsecT s u m Char
char Char
l
ParsecT
Sources MuseState (ReaderT MuseEnv m) (Char -> SourceName -> Text)
-> ParsecT Sources MuseState (ReaderT MuseEnv m) Char
-> ParsecT
Sources MuseState (ReaderT MuseEnv m) (SourceName -> Text)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> SourceName -> ParsecT Sources MuseState (ReaderT MuseEnv m) Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
SourceName -> ParsecT s u m Char
oneOf SourceName
"123456789"
ParsecT Sources MuseState (ReaderT MuseEnv m) (SourceName -> Text)
-> ParsecT Sources MuseState (ReaderT MuseEnv m) SourceName
-> MuseParser m Text
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ParsecT Sources MuseState (ReaderT MuseEnv m) Char
-> ParsecT Sources MuseState (ReaderT MuseEnv m) Char
-> ParsecT Sources MuseState (ReaderT MuseEnv m) SourceName
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 MuseState (ReaderT MuseEnv m) Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s u m Char
digit (Char -> ParsecT Sources MuseState (ReaderT MuseEnv m) Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
Char -> ParsecT s u m Char
char Char
r)
noteMarker :: PandocMonad m => MuseParser m Text
noteMarker :: MuseParser m Text
noteMarker = Char -> Char -> MuseParser m Text
forall (m :: * -> *).
PandocMonad m =>
Char -> Char -> MuseParser m Text
noteMarker' Char
'[' Char
']' MuseParser m Text -> MuseParser m Text -> MuseParser m Text
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> Char -> Char -> MuseParser m Text
forall (m :: * -> *).
PandocMonad m =>
Char -> Char -> MuseParser m Text
noteMarker' Char
'{' Char
'}'
addNote :: PandocMonad m
=> Text
-> SourcePos
-> F Blocks
-> MuseParser m ()
addNote :: Text -> SourcePos -> F Blocks -> MuseParser m ()
addNote Text
ref SourcePos
pos F Blocks
content = do
Map Text (SourcePos, F Blocks)
oldnotes <- MuseState -> Map Text (SourcePos, F Blocks)
museNotes (MuseState -> Map Text (SourcePos, F Blocks))
-> ParsecT Sources MuseState (ReaderT MuseEnv m) MuseState
-> ParsecT
Sources
MuseState
(ReaderT MuseEnv m)
(Map Text (SourcePos, F Blocks))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT Sources MuseState (ReaderT MuseEnv m) MuseState
forall (m :: * -> *) s u. Monad m => ParsecT s u m u
getState
Bool -> MuseParser m () -> MuseParser m ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (Text -> Map Text (SourcePos, F Blocks) -> Bool
forall k a. Ord k => k -> Map k a -> Bool
M.member Text
ref Map Text (SourcePos, F Blocks)
oldnotes)
(LogMessage -> MuseParser m ()
forall s (m :: * -> *) a st.
(Stream s m a, HasLogMessages st) =>
LogMessage -> ParserT s st m ()
logMessage (LogMessage -> MuseParser m ()) -> LogMessage -> MuseParser m ()
forall a b. (a -> b) -> a -> b
$ Text -> SourcePos -> LogMessage
DuplicateNoteReference Text
ref SourcePos
pos)
(MuseState -> MuseState) -> MuseParser m ()
forall (m :: * -> *) u s. Monad m => (u -> u) -> ParsecT s u m ()
updateState ((MuseState -> MuseState) -> MuseParser m ())
-> (MuseState -> MuseState) -> MuseParser m ()
forall a b. (a -> b) -> a -> b
$ \MuseState
s -> MuseState
s{ museNotes :: Map Text (SourcePos, F Blocks)
museNotes = Text
-> (SourcePos, F Blocks)
-> Map Text (SourcePos, F Blocks)
-> Map Text (SourcePos, F Blocks)
forall k a. Ord k => k -> a -> Map k a -> Map k a
M.insert Text
ref (SourcePos
pos, F Blocks
content) Map Text (SourcePos, F Blocks)
oldnotes }
amuseNoteBlockUntil :: PandocMonad m
=> MuseParser m a
-> MuseParser m (F Blocks, a)
amuseNoteBlockUntil :: MuseParser m a -> MuseParser m (F Blocks, a)
amuseNoteBlockUntil MuseParser m a
end = MuseParser m (F Blocks, a) -> MuseParser m (F Blocks, a)
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (MuseParser m (F Blocks, a) -> MuseParser m (F Blocks, a))
-> MuseParser m (F Blocks, a) -> MuseParser m (F Blocks, a)
forall a b. (a -> b) -> a -> b
$ do
Extension -> ParserT Sources MuseState (ReaderT MuseEnv m) ()
forall s (m :: * -> *) a st.
(Stream s m a, HasReaderOptions st) =>
Extension -> ParserT s st m ()
guardEnabled Extension
Ext_amuse
Text
ref <- MuseParser m Text
forall (m :: * -> *). PandocMonad m => MuseParser m Text
noteMarker
SourcePos
pos <- ParsecT Sources MuseState (ReaderT MuseEnv m) SourcePos
forall (m :: * -> *) s u. Monad m => ParsecT s u m SourcePos
getPosition
ParsecT Sources MuseState (ReaderT MuseEnv m) Char
-> ParserT Sources MuseState (ReaderT MuseEnv m) ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void ParsecT Sources MuseState (ReaderT MuseEnv m) Char
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParserT s st m Char
spaceChar ParserT Sources MuseState (ReaderT MuseEnv m) ()
-> ParserT Sources MuseState (ReaderT MuseEnv m) ()
-> ParserT Sources MuseState (ReaderT MuseEnv m) ()
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> ParserT Sources MuseState (ReaderT MuseEnv m) ()
-> ParserT Sources MuseState (ReaderT MuseEnv m) ()
forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m a
lookAhead ParserT Sources MuseState (ReaderT MuseEnv m) ()
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParserT s st m ()
eol
(F Blocks
content, a
e) <- MuseParser m (F Blocks, a) -> MuseParser m (F Blocks, a)
forall (m :: * -> *) a. MonadReader MuseEnv m => m a -> m a
allowPara (MuseParser m (F Blocks, a) -> MuseParser m (F Blocks, a))
-> MuseParser m (F Blocks, a) -> MuseParser m (F Blocks, a)
forall a b. (a -> b) -> a -> b
$ Int
-> MuseParser m a -> MuseParser m a -> MuseParser m (F Blocks, a)
forall (m :: * -> *) a.
PandocMonad m =>
Int
-> MuseParser m a -> MuseParser m a -> MuseParser m (F Blocks, a)
listItemContentsUntil (SourcePos -> Int
sourceColumn SourcePos
pos) (SourceName -> MuseParser m a
forall (m :: * -> *) a. MonadFail m => SourceName -> m a
Prelude.fail SourceName
"x") MuseParser m a
end
Text
-> SourcePos
-> F Blocks
-> ParserT Sources MuseState (ReaderT MuseEnv m) ()
forall (m :: * -> *).
PandocMonad m =>
Text -> SourcePos -> F Blocks -> MuseParser m ()
addNote Text
ref SourcePos
pos F Blocks
content
(F Blocks, a) -> MuseParser m (F Blocks, a)
forall (m :: * -> *) a. Monad m => a -> m a
return (F Blocks
forall a. Monoid a => a
mempty, a
e)
emacsNoteBlock :: PandocMonad m => MuseParser m (F Blocks)
emacsNoteBlock :: MuseParser m (F Blocks)
emacsNoteBlock = MuseParser m (F Blocks) -> MuseParser m (F Blocks)
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (MuseParser m (F Blocks) -> MuseParser m (F Blocks))
-> MuseParser m (F Blocks) -> MuseParser m (F Blocks)
forall a b. (a -> b) -> a -> b
$ do
Extension -> ParserT Sources MuseState (ReaderT MuseEnv m) ()
forall s (m :: * -> *) a st.
(Stream s m a, HasReaderOptions st) =>
Extension -> ParserT s st m ()
guardDisabled Extension
Ext_amuse
Text
ref <- MuseParser m Text
forall (m :: * -> *). PandocMonad m => MuseParser m Text
noteMarker
SourcePos
pos <- ParsecT Sources MuseState (ReaderT MuseEnv m) SourcePos
forall (m :: * -> *) s u. Monad m => ParsecT s u m SourcePos
getPosition
F Blocks
content <- ([F Blocks] -> F Blocks)
-> ParsecT Sources MuseState (ReaderT MuseEnv m) [F Blocks]
-> MuseParser m (F Blocks)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap [F Blocks] -> F Blocks
forall a. Monoid a => [a] -> a
mconcat ParsecT Sources MuseState (ReaderT MuseEnv m) [F Blocks]
blocksTillNote
Text
-> SourcePos
-> F Blocks
-> ParserT Sources MuseState (ReaderT MuseEnv m) ()
forall (m :: * -> *).
PandocMonad m =>
Text -> SourcePos -> F Blocks -> MuseParser m ()
addNote Text
ref SourcePos
pos F Blocks
content
F Blocks -> MuseParser m (F Blocks)
forall (m :: * -> *) a. Monad m => a -> m a
return F Blocks
forall a. Monoid a => a
mempty
where
blocksTillNote :: ParsecT Sources MuseState (ReaderT MuseEnv m) [F Blocks]
blocksTillNote =
MuseParser m (F Blocks)
-> ParserT Sources MuseState (ReaderT MuseEnv m) ()
-> ParsecT Sources MuseState (ReaderT MuseEnv m) [F Blocks]
forall end s (m :: * -> *) t st a.
(Show end, Stream s m t) =>
ParserT s st m a -> ParserT s st m end -> ParserT s st m [a]
many1Till MuseParser m (F Blocks)
forall (m :: * -> *). PandocMonad m => MuseParser m (F Blocks)
parseBlock (ParserT Sources MuseState (ReaderT MuseEnv m) ()
forall s (m :: * -> *) t u.
(Stream s m t, Show t) =>
ParsecT s u m ()
eof ParserT Sources MuseState (ReaderT MuseEnv m) ()
-> ParserT Sources MuseState (ReaderT MuseEnv m) ()
-> ParserT Sources MuseState (ReaderT MuseEnv m) ()
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> () ()
-> MuseParser m Text
-> ParserT Sources MuseState (ReaderT MuseEnv m) ()
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ MuseParser m Text -> MuseParser m Text
forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m a
lookAhead MuseParser m Text
forall (m :: * -> *). PandocMonad m => MuseParser m Text
noteMarker)
lineBlock :: PandocMonad m => MuseParser m (F Blocks)
lineBlock :: MuseParser m (F Blocks)
lineBlock = MuseParser m (F Blocks) -> MuseParser m (F Blocks)
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (MuseParser m (F Blocks) -> MuseParser m (F Blocks))
-> MuseParser m (F Blocks) -> MuseParser m (F Blocks)
forall a b. (a -> b) -> a -> b
$ MuseParser m Int
forall (m :: * -> *). PandocMonad m => MuseParser m Int
getIndent MuseParser m Int
-> (Int -> MuseParser m (F Blocks)) -> MuseParser m (F Blocks)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Int
indent -> ([Inlines] -> Blocks) -> Future MuseState [Inlines] -> F Blocks
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap [Inlines] -> Blocks
B.lineBlock (Future MuseState [Inlines] -> F Blocks)
-> ([F Inlines] -> Future MuseState [Inlines])
-> [F Inlines]
-> F Blocks
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [F Inlines] -> Future MuseState [Inlines]
forall (t :: * -> *) (m :: * -> *) a.
(Traversable t, Monad m) =>
t (m a) -> m (t a)
sequence
([F Inlines] -> F Blocks)
-> ParsecT Sources MuseState (ReaderT MuseEnv m) [F Inlines]
-> MuseParser m (F Blocks)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (ParsecT Sources MuseState (ReaderT MuseEnv m) (F Inlines)
forall u. ParsecT Sources u (ReaderT MuseEnv m) (F Inlines)
blankVerseLine ParsecT Sources MuseState (ReaderT MuseEnv m) (F Inlines)
-> ParsecT Sources MuseState (ReaderT MuseEnv m) (F Inlines)
-> ParsecT Sources MuseState (ReaderT MuseEnv m) (F Inlines)
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> ParsecT Sources MuseState (ReaderT MuseEnv m) (F Inlines)
nonblankVerseLine) ParsecT Sources MuseState (ReaderT MuseEnv m) (F Inlines)
-> ParsecT Sources MuseState (ReaderT MuseEnv m) Text
-> ParsecT Sources MuseState (ReaderT MuseEnv m) [F Inlines]
forall s u (m :: * -> *) a sep.
ParsecT s u m a -> ParsecT s u m sep -> ParsecT s u m [a]
`sepBy1'` ParsecT Sources MuseState (ReaderT MuseEnv m) Text
-> ParsecT Sources MuseState (ReaderT MuseEnv m) Text
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (Int -> ParsecT Sources MuseState (ReaderT MuseEnv m) Text
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char, HasReaderOptions st) =>
Int -> ParserT s st m Text
indentWith Int
indent)
where
blankVerseLine :: ParsecT Sources u (ReaderT MuseEnv m) (F Inlines)
blankVerseLine = ParsecT Sources u (ReaderT MuseEnv m) (F Inlines)
-> ParsecT Sources u (ReaderT MuseEnv m) (F Inlines)
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT Sources u (ReaderT MuseEnv m) (F Inlines)
-> ParsecT Sources u (ReaderT MuseEnv m) (F Inlines))
-> ParsecT Sources u (ReaderT MuseEnv m) (F Inlines)
-> ParsecT Sources u (ReaderT MuseEnv m) (F Inlines)
forall a b. (a -> b) -> a -> b
$ F Inlines
forall a. Monoid a => a
mempty F Inlines
-> ParsecT Sources u (ReaderT MuseEnv m) Char
-> ParsecT Sources u (ReaderT MuseEnv m) (F Inlines)
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ Char -> ParsecT Sources u (ReaderT MuseEnv m) Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
Char -> ParsecT s u m Char
char Char
'>' ParsecT Sources u (ReaderT MuseEnv m) (F Inlines)
-> ParsecT Sources u (ReaderT MuseEnv m) Char
-> ParsecT Sources u (ReaderT MuseEnv m) (F Inlines)
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* ParsecT Sources u (ReaderT MuseEnv m) Char
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParserT s st m Char
blankline
nonblankVerseLine :: ParsecT Sources MuseState (ReaderT MuseEnv m) (F Inlines)
nonblankVerseLine = ParsecT Sources MuseState (ReaderT MuseEnv m) SourceName
-> ParsecT Sources MuseState (ReaderT MuseEnv m) SourceName
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (SourceName
-> ParsecT Sources MuseState (ReaderT MuseEnv m) SourceName
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
SourceName -> ParsecT s u m SourceName
string SourceName
"> ") ParsecT Sources MuseState (ReaderT MuseEnv m) SourceName
-> ParsecT Sources MuseState (ReaderT MuseEnv m) (F Inlines)
-> ParsecT Sources MuseState (ReaderT MuseEnv m) (F Inlines)
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> ParsecT Sources MuseState (ReaderT MuseEnv m) (F Inlines)
forall (m :: * -> *). PandocMonad m => MuseParser m (F Inlines)
verseLine
bulletListItemsUntil :: PandocMonad m
=> Int
-> MuseParser m a
-> MuseParser m ([F Blocks], a)
bulletListItemsUntil :: Int -> MuseParser m a -> MuseParser m ([F Blocks], a)
bulletListItemsUntil Int
indent MuseParser m a
end = MuseParser m ([F Blocks], a) -> MuseParser m ([F Blocks], a)
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (MuseParser m ([F Blocks], a) -> MuseParser m ([F Blocks], a))
-> MuseParser m ([F Blocks], a) -> MuseParser m ([F Blocks], a)
forall a b. (a -> b) -> a -> b
$ do
Char -> ParsecT Sources MuseState (ReaderT MuseEnv m) Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
Char -> ParsecT s u m Char
char Char
'-'
ParsecT Sources MuseState (ReaderT MuseEnv m) Char
-> ParsecT Sources MuseState (ReaderT MuseEnv m) ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void ParsecT Sources MuseState (ReaderT MuseEnv m) Char
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParserT s st m Char
spaceChar ParsecT Sources MuseState (ReaderT MuseEnv m) ()
-> ParsecT Sources MuseState (ReaderT MuseEnv m) ()
-> ParsecT Sources MuseState (ReaderT MuseEnv m) ()
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> ParsecT Sources MuseState (ReaderT MuseEnv m) ()
-> ParsecT Sources MuseState (ReaderT MuseEnv m) ()
forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m a
lookAhead ParsecT Sources MuseState (ReaderT MuseEnv m) ()
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParserT s st m ()
eol
(F Blocks
x, ([F Blocks]
xs, a
e)) <- ParsecT
Sources MuseState (ReaderT MuseEnv m) (F Blocks, ([F Blocks], a))
-> ParsecT
Sources MuseState (ReaderT MuseEnv m) (F Blocks, ([F Blocks], a))
forall (m :: * -> *) a. MonadReader MuseEnv m => m a -> m a
allowPara (ParsecT
Sources MuseState (ReaderT MuseEnv m) (F Blocks, ([F Blocks], a))
-> ParsecT
Sources MuseState (ReaderT MuseEnv m) (F Blocks, ([F Blocks], a)))
-> ParsecT
Sources MuseState (ReaderT MuseEnv m) (F Blocks, ([F Blocks], a))
-> ParsecT
Sources MuseState (ReaderT MuseEnv m) (F Blocks, ([F Blocks], a))
forall a b. (a -> b) -> a -> b
$ Int
-> MuseParser m ([F Blocks], a)
-> MuseParser m ([F Blocks], a)
-> ParsecT
Sources MuseState (ReaderT MuseEnv m) (F Blocks, ([F Blocks], a))
forall (m :: * -> *) a.
PandocMonad m =>
Int
-> MuseParser m a -> MuseParser m a -> MuseParser m (F Blocks, a)
listItemContentsUntil (Int
indent Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
2) (MuseParser m ([F Blocks], a) -> MuseParser m ([F Blocks], a)
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT Sources MuseState (ReaderT MuseEnv m) Char
-> ParsecT Sources MuseState (ReaderT MuseEnv m) ()
forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m ()
optional ParsecT Sources MuseState (ReaderT MuseEnv m) Char
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParserT s st m Char
blankline ParsecT Sources MuseState (ReaderT MuseEnv m) ()
-> ParsecT Sources MuseState (ReaderT MuseEnv m) Text
-> ParsecT Sources MuseState (ReaderT MuseEnv m) Text
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Int -> ParsecT Sources MuseState (ReaderT MuseEnv m) Text
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char, HasReaderOptions st) =>
Int -> ParserT s st m Text
indentWith Int
indent ParsecT Sources MuseState (ReaderT MuseEnv m) Text
-> MuseParser m ([F Blocks], a) -> MuseParser m ([F Blocks], a)
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Int -> MuseParser m a -> MuseParser m ([F Blocks], a)
forall (m :: * -> *) a.
PandocMonad m =>
Int -> MuseParser m a -> MuseParser m ([F Blocks], a)
bulletListItemsUntil Int
indent MuseParser m a
end)) (([],) (a -> ([F Blocks], a))
-> MuseParser m a -> MuseParser m ([F Blocks], a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> MuseParser m a
end)
([F Blocks], a) -> MuseParser m ([F Blocks], a)
forall (m :: * -> *) a. Monad m => a -> m a
return (F Blocks
xF Blocks -> [F Blocks] -> [F Blocks]
forall a. a -> [a] -> [a]
:[F Blocks]
xs, a
e)
bulletListUntil :: PandocMonad m
=> MuseParser m a
-> MuseParser m (F Blocks, a)
bulletListUntil :: MuseParser m a -> MuseParser m (F Blocks, a)
bulletListUntil MuseParser m a
end = MuseParser m (F Blocks, a) -> MuseParser m (F Blocks, a)
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (MuseParser m (F Blocks, a) -> MuseParser m (F Blocks, a))
-> MuseParser m (F Blocks, a) -> MuseParser m (F Blocks, a)
forall a b. (a -> b) -> a -> b
$ do
Int
indent <- MuseParser m Int
forall (m :: * -> *). PandocMonad m => MuseParser m Int
getIndent
Bool -> ParsecT Sources MuseState (ReaderT MuseEnv m) ()
forall (f :: * -> *). Alternative f => Bool -> f ()
guard (Bool -> ParsecT Sources MuseState (ReaderT MuseEnv m) ())
-> Bool -> ParsecT Sources MuseState (ReaderT MuseEnv m) ()
forall a b. (a -> b) -> a -> b
$ Int
indent Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
/= Int
0
([F Blocks] -> F Blocks) -> ([F Blocks], a) -> (F Blocks, a)
forall (p :: * -> * -> *) a b c.
Bifunctor p =>
(a -> b) -> p a c -> p b c
first (([Blocks] -> Blocks) -> Future MuseState [Blocks] -> F Blocks
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap [Blocks] -> Blocks
B.bulletList (Future MuseState [Blocks] -> F Blocks)
-> ([F Blocks] -> Future MuseState [Blocks])
-> [F Blocks]
-> F Blocks
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [F Blocks] -> Future MuseState [Blocks]
forall (t :: * -> *) (m :: * -> *) a.
(Traversable t, Monad m) =>
t (m a) -> m (t a)
sequence) (([F Blocks], a) -> (F Blocks, a))
-> ParsecT Sources MuseState (ReaderT MuseEnv m) ([F Blocks], a)
-> MuseParser m (F Blocks, a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Int
-> MuseParser m a
-> ParsecT Sources MuseState (ReaderT MuseEnv m) ([F Blocks], a)
forall (m :: * -> *) a.
PandocMonad m =>
Int -> MuseParser m a -> MuseParser m ([F Blocks], a)
bulletListItemsUntil Int
indent MuseParser m a
end
museOrderedListMarker :: PandocMonad m
=> ListNumberStyle
-> MuseParser m Int
museOrderedListMarker :: ListNumberStyle -> MuseParser m Int
museOrderedListMarker ListNumberStyle
style =
(ListNumberStyle, Int) -> Int
forall a b. (a, b) -> b
snd ((ListNumberStyle, Int) -> Int)
-> ParsecT
Sources MuseState (ReaderT MuseEnv m) (ListNumberStyle, Int)
-> MuseParser m Int
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT
Sources MuseState (ReaderT MuseEnv m) (ListNumberStyle, Int)
forall st.
ParserT Sources st (ReaderT MuseEnv m) (ListNumberStyle, Int)
p MuseParser m Int
-> ParsecT Sources MuseState (ReaderT MuseEnv m) Char
-> MuseParser m Int
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* Char -> ParsecT Sources MuseState (ReaderT MuseEnv m) Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
Char -> ParsecT s u m Char
char Char
'.'
where p :: ParserT Sources st (ReaderT MuseEnv m) (ListNumberStyle, Int)
p = case ListNumberStyle
style of
ListNumberStyle
Decimal -> ParserT Sources st (ReaderT MuseEnv m) (ListNumberStyle, Int)
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParserT s st m (ListNumberStyle, Int)
decimal
ListNumberStyle
UpperRoman -> ParserT Sources st (ReaderT MuseEnv m) (ListNumberStyle, Int)
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParserT s st m (ListNumberStyle, Int)
upperRoman
ListNumberStyle
LowerRoman -> ParserT Sources st (ReaderT MuseEnv m) (ListNumberStyle, Int)
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParserT s st m (ListNumberStyle, Int)
lowerRoman
ListNumberStyle
UpperAlpha -> ParserT Sources st (ReaderT MuseEnv m) (ListNumberStyle, Int)
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParserT s st m (ListNumberStyle, Int)
upperAlpha
ListNumberStyle
LowerAlpha -> ParserT Sources st (ReaderT MuseEnv m) (ListNumberStyle, Int)
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParserT s st m (ListNumberStyle, Int)
lowerAlpha
ListNumberStyle
_ -> SourceName
-> ParserT Sources st (ReaderT MuseEnv m) (ListNumberStyle, Int)
forall (m :: * -> *) a. MonadFail m => SourceName -> m a
Prelude.fail SourceName
"Unhandled case"
orderedListItemsUntil :: PandocMonad m
=> Int
-> ListNumberStyle
-> MuseParser m a
-> MuseParser m ([F Blocks], a)
orderedListItemsUntil :: Int
-> ListNumberStyle
-> MuseParser m a
-> MuseParser m ([F Blocks], a)
orderedListItemsUntil Int
indent ListNumberStyle
style MuseParser m a
end =
MuseParser m ([F Blocks], a)
continuation
where
continuation :: MuseParser m ([F Blocks], a)
continuation = MuseParser m ([F Blocks], a) -> MuseParser m ([F Blocks], a)
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (MuseParser m ([F Blocks], a) -> MuseParser m ([F Blocks], a))
-> MuseParser m ([F Blocks], a) -> MuseParser m ([F Blocks], a)
forall a b. (a -> b) -> a -> b
$ do
SourcePos
pos <- ParsecT Sources MuseState (ReaderT MuseEnv m) SourcePos
forall (m :: * -> *) s u. Monad m => ParsecT s u m SourcePos
getPosition
ParsecT Sources MuseState (ReaderT MuseEnv m) Char
-> ParsecT Sources MuseState (ReaderT MuseEnv m) ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void ParsecT Sources MuseState (ReaderT MuseEnv m) Char
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParserT s st m Char
spaceChar ParsecT Sources MuseState (ReaderT MuseEnv m) ()
-> ParsecT Sources MuseState (ReaderT MuseEnv m) ()
-> ParsecT Sources MuseState (ReaderT MuseEnv m) ()
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> ParsecT Sources MuseState (ReaderT MuseEnv m) ()
-> ParsecT Sources MuseState (ReaderT MuseEnv m) ()
forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m a
lookAhead ParsecT Sources MuseState (ReaderT MuseEnv m) ()
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParserT s st m ()
eol
(F Blocks
x, ([F Blocks]
xs, a
e)) <- ParsecT
Sources MuseState (ReaderT MuseEnv m) (F Blocks, ([F Blocks], a))
-> ParsecT
Sources MuseState (ReaderT MuseEnv m) (F Blocks, ([F Blocks], a))
forall (m :: * -> *) a. MonadReader MuseEnv m => m a -> m a
allowPara (ParsecT
Sources MuseState (ReaderT MuseEnv m) (F Blocks, ([F Blocks], a))
-> ParsecT
Sources MuseState (ReaderT MuseEnv m) (F Blocks, ([F Blocks], a)))
-> ParsecT
Sources MuseState (ReaderT MuseEnv m) (F Blocks, ([F Blocks], a))
-> ParsecT
Sources MuseState (ReaderT MuseEnv m) (F Blocks, ([F Blocks], a))
forall a b. (a -> b) -> a -> b
$ Int
-> MuseParser m ([F Blocks], a)
-> MuseParser m ([F Blocks], a)
-> ParsecT
Sources MuseState (ReaderT MuseEnv m) (F Blocks, ([F Blocks], a))
forall (m :: * -> *) a.
PandocMonad m =>
Int
-> MuseParser m a -> MuseParser m a -> MuseParser m (F Blocks, a)
listItemContentsUntil (SourcePos -> Int
sourceColumn SourcePos
pos) (MuseParser m ([F Blocks], a) -> MuseParser m ([F Blocks], a)
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT Sources MuseState (ReaderT MuseEnv m) Char
-> ParsecT Sources MuseState (ReaderT MuseEnv m) ()
forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m ()
optional ParsecT Sources MuseState (ReaderT MuseEnv m) Char
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParserT s st m Char
blankline ParsecT Sources MuseState (ReaderT MuseEnv m) ()
-> ParsecT Sources MuseState (ReaderT MuseEnv m) Text
-> ParsecT Sources MuseState (ReaderT MuseEnv m) Text
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Int -> ParsecT Sources MuseState (ReaderT MuseEnv m) Text
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char, HasReaderOptions st) =>
Int -> ParserT s st m Text
indentWith Int
indent ParsecT Sources MuseState (ReaderT MuseEnv m) Text
-> ParsecT Sources MuseState (ReaderT MuseEnv m) Int
-> ParsecT Sources MuseState (ReaderT MuseEnv m) Int
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> ListNumberStyle
-> ParsecT Sources MuseState (ReaderT MuseEnv m) Int
forall (m :: * -> *).
PandocMonad m =>
ListNumberStyle -> MuseParser m Int
museOrderedListMarker ListNumberStyle
style ParsecT Sources MuseState (ReaderT MuseEnv m) Int
-> MuseParser m ([F Blocks], a) -> MuseParser m ([F Blocks], a)
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> MuseParser m ([F Blocks], a)
continuation)) (([],) (a -> ([F Blocks], a))
-> MuseParser m a -> MuseParser m ([F Blocks], a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> MuseParser m a
end)
([F Blocks], a) -> MuseParser m ([F Blocks], a)
forall (m :: * -> *) a. Monad m => a -> m a
return (F Blocks
xF Blocks -> [F Blocks] -> [F Blocks]
forall a. a -> [a] -> [a]
:[F Blocks]
xs, a
e)
orderedListUntil :: PandocMonad m
=> MuseParser m a
-> MuseParser m (F Blocks, a)
orderedListUntil :: MuseParser m a -> MuseParser m (F Blocks, a)
orderedListUntil MuseParser m a
end = MuseParser m (F Blocks, a) -> MuseParser m (F Blocks, a)
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (MuseParser m (F Blocks, a) -> MuseParser m (F Blocks, a))
-> MuseParser m (F Blocks, a) -> MuseParser m (F Blocks, a)
forall a b. (a -> b) -> a -> b
$ do
Int
indent <- MuseParser m Int
forall (m :: * -> *). PandocMonad m => MuseParser m Int
getIndent
Bool -> ParsecT Sources MuseState (ReaderT MuseEnv m) ()
forall (f :: * -> *). Alternative f => Bool -> f ()
guard (Bool -> ParsecT Sources MuseState (ReaderT MuseEnv m) ())
-> Bool -> ParsecT Sources MuseState (ReaderT MuseEnv m) ()
forall a b. (a -> b) -> a -> b
$ Int
indent Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
/= Int
0
(ListNumberStyle
style, Int
start) <- ParserT
Sources MuseState (ReaderT MuseEnv m) (ListNumberStyle, Int)
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParserT s st m (ListNumberStyle, Int)
decimal ParserT
Sources MuseState (ReaderT MuseEnv m) (ListNumberStyle, Int)
-> ParserT
Sources MuseState (ReaderT MuseEnv m) (ListNumberStyle, Int)
-> ParserT
Sources MuseState (ReaderT MuseEnv m) (ListNumberStyle, Int)
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> ParserT
Sources MuseState (ReaderT MuseEnv m) (ListNumberStyle, Int)
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParserT s st m (ListNumberStyle, Int)
lowerRoman ParserT
Sources MuseState (ReaderT MuseEnv m) (ListNumberStyle, Int)
-> ParserT
Sources MuseState (ReaderT MuseEnv m) (ListNumberStyle, Int)
-> ParserT
Sources MuseState (ReaderT MuseEnv m) (ListNumberStyle, Int)
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> ParserT
Sources MuseState (ReaderT MuseEnv m) (ListNumberStyle, Int)
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParserT s st m (ListNumberStyle, Int)
upperRoman ParserT
Sources MuseState (ReaderT MuseEnv m) (ListNumberStyle, Int)
-> ParserT
Sources MuseState (ReaderT MuseEnv m) (ListNumberStyle, Int)
-> ParserT
Sources MuseState (ReaderT MuseEnv m) (ListNumberStyle, Int)
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> ParserT
Sources MuseState (ReaderT MuseEnv m) (ListNumberStyle, Int)
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParserT s st m (ListNumberStyle, Int)
lowerAlpha ParserT
Sources MuseState (ReaderT MuseEnv m) (ListNumberStyle, Int)
-> ParserT
Sources MuseState (ReaderT MuseEnv m) (ListNumberStyle, Int)
-> ParserT
Sources MuseState (ReaderT MuseEnv m) (ListNumberStyle, Int)
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> ParserT
Sources MuseState (ReaderT MuseEnv m) (ListNumberStyle, Int)
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParserT s st m (ListNumberStyle, Int)
upperAlpha
Char -> ParsecT Sources MuseState (ReaderT MuseEnv m) Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
Char -> ParsecT s u m Char
char Char
'.'
([F Blocks] -> F Blocks) -> ([F Blocks], a) -> (F Blocks, a)
forall (p :: * -> * -> *) a b c.
Bifunctor p =>
(a -> b) -> p a c -> p b c
first (([Blocks] -> Blocks) -> Future MuseState [Blocks] -> F Blocks
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (ListAttributes -> [Blocks] -> Blocks
B.orderedListWith (Int
start, ListNumberStyle
style, ListNumberDelim
Period)) (Future MuseState [Blocks] -> F Blocks)
-> ([F Blocks] -> Future MuseState [Blocks])
-> [F Blocks]
-> F Blocks
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [F Blocks] -> Future MuseState [Blocks]
forall (t :: * -> *) (m :: * -> *) a.
(Traversable t, Monad m) =>
t (m a) -> m (t a)
sequence)
(([F Blocks], a) -> (F Blocks, a))
-> ParsecT Sources MuseState (ReaderT MuseEnv m) ([F Blocks], a)
-> MuseParser m (F Blocks, a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Int
-> ListNumberStyle
-> MuseParser m a
-> ParsecT Sources MuseState (ReaderT MuseEnv m) ([F Blocks], a)
forall (m :: * -> *) a.
PandocMonad m =>
Int
-> ListNumberStyle
-> MuseParser m a
-> MuseParser m ([F Blocks], a)
orderedListItemsUntil Int
indent ListNumberStyle
style MuseParser m a
end
descriptionsUntil :: PandocMonad m
=> Int
-> MuseParser m a
-> MuseParser m ([F Blocks], a)
descriptionsUntil :: Int -> MuseParser m a -> MuseParser m ([F Blocks], a)
descriptionsUntil Int
indent MuseParser m a
end = do
ParsecT Sources MuseState (ReaderT MuseEnv m) Char
-> ParsecT Sources MuseState (ReaderT MuseEnv m) ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void ParsecT Sources MuseState (ReaderT MuseEnv m) Char
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParserT s st m Char
spaceChar ParsecT Sources MuseState (ReaderT MuseEnv m) ()
-> ParsecT Sources MuseState (ReaderT MuseEnv m) ()
-> ParsecT Sources MuseState (ReaderT MuseEnv m) ()
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> ParsecT Sources MuseState (ReaderT MuseEnv m) ()
-> ParsecT Sources MuseState (ReaderT MuseEnv m) ()
forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m a
lookAhead ParsecT Sources MuseState (ReaderT MuseEnv m) ()
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParserT s st m ()
eol
(F Blocks
x, ([F Blocks]
xs, a
e)) <- ParsecT
Sources MuseState (ReaderT MuseEnv m) (F Blocks, ([F Blocks], a))
-> ParsecT
Sources MuseState (ReaderT MuseEnv m) (F Blocks, ([F Blocks], a))
forall (m :: * -> *) a. MonadReader MuseEnv m => m a -> m a
allowPara (ParsecT
Sources MuseState (ReaderT MuseEnv m) (F Blocks, ([F Blocks], a))
-> ParsecT
Sources MuseState (ReaderT MuseEnv m) (F Blocks, ([F Blocks], a)))
-> ParsecT
Sources MuseState (ReaderT MuseEnv m) (F Blocks, ([F Blocks], a))
-> ParsecT
Sources MuseState (ReaderT MuseEnv m) (F Blocks, ([F Blocks], a))
forall a b. (a -> b) -> a -> b
$ Int
-> MuseParser m ([F Blocks], a)
-> MuseParser m ([F Blocks], a)
-> ParsecT
Sources MuseState (ReaderT MuseEnv m) (F Blocks, ([F Blocks], a))
forall (m :: * -> *) a.
PandocMonad m =>
Int
-> MuseParser m a -> MuseParser m a -> MuseParser m (F Blocks, a)
listItemContentsUntil Int
indent (MuseParser m ([F Blocks], a) -> MuseParser m ([F Blocks], a)
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT Sources MuseState (ReaderT MuseEnv m) Char
-> ParsecT Sources MuseState (ReaderT MuseEnv m) ()
forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m ()
optional ParsecT Sources MuseState (ReaderT MuseEnv m) Char
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParserT s st m Char
blankline ParsecT Sources MuseState (ReaderT MuseEnv m) ()
-> ParsecT Sources MuseState (ReaderT MuseEnv m) Text
-> ParsecT Sources MuseState (ReaderT MuseEnv m) Text
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Int -> ParsecT Sources MuseState (ReaderT MuseEnv m) Text
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char, HasReaderOptions st) =>
Int -> ParserT s st m Text
indentWith Int
indent ParsecT Sources MuseState (ReaderT MuseEnv m) Text
-> ParsecT Sources MuseState (ReaderT MuseEnv m) SourceName
-> ParsecT Sources MuseState (ReaderT MuseEnv m) SourceName
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> ParsecT Sources MuseState (ReaderT MuseEnv m) Char
-> ParsecT Sources MuseState (ReaderT MuseEnv m) SourceName
-> ParsecT Sources MuseState (ReaderT MuseEnv m) SourceName
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 MuseState (ReaderT MuseEnv m) Char
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParserT s st m Char
spaceChar (SourceName
-> ParsecT Sources MuseState (ReaderT MuseEnv m) SourceName
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
SourceName -> ParsecT s u m SourceName
string SourceName
"::") ParsecT Sources MuseState (ReaderT MuseEnv m) SourceName
-> MuseParser m ([F Blocks], a) -> MuseParser m ([F Blocks], a)
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Int -> MuseParser m a -> MuseParser m ([F Blocks], a)
forall (m :: * -> *) a.
PandocMonad m =>
Int -> MuseParser m a -> MuseParser m ([F Blocks], a)
descriptionsUntil Int
indent MuseParser m a
end)) (([],) (a -> ([F Blocks], a))
-> MuseParser m a -> MuseParser m ([F Blocks], a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> MuseParser m a
end)
([F Blocks], a) -> MuseParser m ([F Blocks], a)
forall (m :: * -> *) a. Monad m => a -> m a
return (F Blocks
xF Blocks -> [F Blocks] -> [F Blocks]
forall a. a -> [a] -> [a]
:[F Blocks]
xs, a
e)
definitionListItemsUntil :: PandocMonad m
=> Int
-> MuseParser m a
-> MuseParser m ([F (Inlines, [Blocks])], a)
definitionListItemsUntil :: Int -> MuseParser m a -> MuseParser m ([F (Inlines, [Blocks])], a)
definitionListItemsUntil Int
indent MuseParser m a
end =
MuseParser m ([F (Inlines, [Blocks])], a)
continuation
where
continuation :: MuseParser m ([F (Inlines, [Blocks])], a)
continuation = MuseParser m ([F (Inlines, [Blocks])], a)
-> MuseParser m ([F (Inlines, [Blocks])], a)
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (MuseParser m ([F (Inlines, [Blocks])], a)
-> MuseParser m ([F (Inlines, [Blocks])], a))
-> MuseParser m ([F (Inlines, [Blocks])], a)
-> MuseParser m ([F (Inlines, [Blocks])], a)
forall a b. (a -> b) -> a -> b
$ do
SourcePos
pos <- ParsecT Sources MuseState (ReaderT MuseEnv m) SourcePos
forall (m :: * -> *) s u. Monad m => ParsecT s u m SourcePos
getPosition
F Inlines
term <- F Inlines -> F Inlines
forall s. Future s Inlines -> Future s Inlines
trimInlinesF (F Inlines -> F Inlines)
-> ([F Inlines] -> F Inlines) -> [F Inlines] -> F Inlines
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [F Inlines] -> F Inlines
forall a. Monoid a => [a] -> a
mconcat ([F Inlines] -> F Inlines)
-> ParsecT Sources MuseState (ReaderT MuseEnv m) [F Inlines]
-> ParsecT Sources MuseState (ReaderT MuseEnv m) (F Inlines)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT Sources MuseState (ReaderT MuseEnv m) (F Inlines)
-> ParsecT Sources MuseState (ReaderT MuseEnv m) SourceName
-> ParsecT Sources MuseState (ReaderT MuseEnv m) [F Inlines]
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 MuseState (ReaderT MuseEnv m) (F Inlines)
forall (m :: * -> *). PandocMonad m => MuseParser m (F Inlines)
inline' (ParsecT Sources MuseState (ReaderT MuseEnv m) SourceName
-> ParsecT Sources MuseState (ReaderT MuseEnv m) SourceName
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT Sources MuseState (ReaderT MuseEnv m) SourceName
-> ParsecT Sources MuseState (ReaderT MuseEnv m) SourceName)
-> ParsecT Sources MuseState (ReaderT MuseEnv m) SourceName
-> ParsecT Sources MuseState (ReaderT MuseEnv m) SourceName
forall a b. (a -> b) -> a -> b
$ SourceName
-> ParsecT Sources MuseState (ReaderT MuseEnv m) SourceName
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
SourceName -> ParsecT s u m SourceName
string SourceName
"::")
([F Blocks]
x, ([F (Inlines, [Blocks])]
xs, a
e)) <- Int
-> MuseParser m ([F (Inlines, [Blocks])], a)
-> MuseParser m ([F Blocks], ([F (Inlines, [Blocks])], a))
forall (m :: * -> *) a.
PandocMonad m =>
Int -> MuseParser m a -> MuseParser m ([F Blocks], a)
descriptionsUntil (SourcePos -> Int
sourceColumn SourcePos
pos) (MuseParser m ([F (Inlines, [Blocks])], a)
-> MuseParser m ([F (Inlines, [Blocks])], a)
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT Sources MuseState (ReaderT MuseEnv m) Char
-> ParsecT Sources MuseState (ReaderT MuseEnv m) ()
forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m ()
optional ParsecT Sources MuseState (ReaderT MuseEnv m) Char
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParserT s st m Char
blankline ParsecT Sources MuseState (ReaderT MuseEnv m) ()
-> ParsecT Sources MuseState (ReaderT MuseEnv m) Text
-> ParsecT Sources MuseState (ReaderT MuseEnv m) Text
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Int -> ParsecT Sources MuseState (ReaderT MuseEnv m) Text
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char, HasReaderOptions st) =>
Int -> ParserT s st m Text
indentWith Int
indent ParsecT Sources MuseState (ReaderT MuseEnv m) Text
-> MuseParser m ([F (Inlines, [Blocks])], a)
-> MuseParser m ([F (Inlines, [Blocks])], a)
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> MuseParser m ([F (Inlines, [Blocks])], a)
continuation) MuseParser m ([F (Inlines, [Blocks])], a)
-> MuseParser m ([F (Inlines, [Blocks])], a)
-> MuseParser m ([F (Inlines, [Blocks])], a)
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> (([],) (a -> ([F (Inlines, [Blocks])], a))
-> MuseParser m a -> MuseParser m ([F (Inlines, [Blocks])], a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> MuseParser m a
end))
let xx :: F (Inlines, [Blocks])
xx = (,) (Inlines -> [Blocks] -> (Inlines, [Blocks]))
-> F Inlines -> Future MuseState ([Blocks] -> (Inlines, [Blocks]))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> F Inlines
term Future MuseState ([Blocks] -> (Inlines, [Blocks]))
-> Future MuseState [Blocks] -> F (Inlines, [Blocks])
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> [F Blocks] -> Future MuseState [Blocks]
forall (t :: * -> *) (m :: * -> *) a.
(Traversable t, Monad m) =>
t (m a) -> m (t a)
sequence [F Blocks]
x
([F (Inlines, [Blocks])], a)
-> MuseParser m ([F (Inlines, [Blocks])], a)
forall (m :: * -> *) a. Monad m => a -> m a
return (F (Inlines, [Blocks])
xxF (Inlines, [Blocks])
-> [F (Inlines, [Blocks])] -> [F (Inlines, [Blocks])]
forall a. a -> [a] -> [a]
:[F (Inlines, [Blocks])]
xs, a
e)
definitionListUntil :: PandocMonad m
=> MuseParser m a
-> MuseParser m (F Blocks, a)
definitionListUntil :: MuseParser m a -> MuseParser m (F Blocks, a)
definitionListUntil MuseParser m a
end = MuseParser m (F Blocks, a) -> MuseParser m (F Blocks, a)
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (MuseParser m (F Blocks, a) -> MuseParser m (F Blocks, a))
-> MuseParser m (F Blocks, a) -> MuseParser m (F Blocks, a)
forall a b. (a -> b) -> a -> b
$ do
Int
indent <- MuseParser m Int
forall (m :: * -> *). PandocMonad m => MuseParser m Int
getIndent
Extension -> ParserT Sources MuseState (ReaderT MuseEnv m) ()
forall s (m :: * -> *) a st.
(Stream s m a, HasReaderOptions st) =>
Extension -> ParserT s st m ()
guardDisabled Extension
Ext_amuse ParserT Sources MuseState (ReaderT MuseEnv m) ()
-> ParserT Sources MuseState (ReaderT MuseEnv m) ()
-> ParserT Sources MuseState (ReaderT MuseEnv m) ()
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> Bool -> ParserT Sources MuseState (ReaderT MuseEnv m) ()
forall (f :: * -> *). Alternative f => Bool -> f ()
guard (Int
indent Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
/= Int
0)
([F (Inlines, [Blocks])] -> F Blocks)
-> ([F (Inlines, [Blocks])], a) -> (F Blocks, a)
forall (p :: * -> * -> *) a b c.
Bifunctor p =>
(a -> b) -> p a c -> p b c
first (([(Inlines, [Blocks])] -> Blocks)
-> Future MuseState [(Inlines, [Blocks])] -> F Blocks
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap [(Inlines, [Blocks])] -> Blocks
B.definitionList (Future MuseState [(Inlines, [Blocks])] -> F Blocks)
-> ([F (Inlines, [Blocks])]
-> Future MuseState [(Inlines, [Blocks])])
-> [F (Inlines, [Blocks])]
-> F Blocks
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [F (Inlines, [Blocks])] -> Future MuseState [(Inlines, [Blocks])]
forall (t :: * -> *) (m :: * -> *) a.
(Traversable t, Monad m) =>
t (m a) -> m (t a)
sequence) (([F (Inlines, [Blocks])], a) -> (F Blocks, a))
-> ParsecT
Sources MuseState (ReaderT MuseEnv m) ([F (Inlines, [Blocks])], a)
-> MuseParser m (F Blocks, a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Int
-> MuseParser m a
-> ParsecT
Sources MuseState (ReaderT MuseEnv m) ([F (Inlines, [Blocks])], a)
forall (m :: * -> *) a.
PandocMonad m =>
Int -> MuseParser m a -> MuseParser m ([F (Inlines, [Blocks])], a)
definitionListItemsUntil Int
indent MuseParser m a
end
anyListUntil :: PandocMonad m
=> MuseParser m a
-> MuseParser m (F Blocks, a)
anyListUntil :: MuseParser m a -> MuseParser m (F Blocks, a)
anyListUntil MuseParser m a
end =
MuseParser m a -> MuseParser m (F Blocks, a)
forall (m :: * -> *) a.
PandocMonad m =>
MuseParser m a -> MuseParser m (F Blocks, a)
bulletListUntil MuseParser m a
end MuseParser m (F Blocks, a)
-> MuseParser m (F Blocks, a) -> MuseParser m (F Blocks, a)
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> MuseParser m a -> MuseParser m (F Blocks, a)
forall (m :: * -> *) a.
PandocMonad m =>
MuseParser m a -> MuseParser m (F Blocks, a)
orderedListUntil MuseParser m a
end MuseParser m (F Blocks, a)
-> MuseParser m (F Blocks, a) -> MuseParser m (F Blocks, a)
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> MuseParser m a -> MuseParser m (F Blocks, a)
forall (m :: * -> *) a.
PandocMonad m =>
MuseParser m a -> MuseParser m (F Blocks, a)
definitionListUntil MuseParser m a
end
data MuseTable = MuseTable
{ MuseTable -> Inlines
museTableCaption :: Inlines
, :: [[Blocks]]
, MuseTable -> [[Blocks]]
museTableRows :: [[Blocks]]
, :: [[Blocks]]
}
data MuseTableElement = [Blocks]
| MuseBodyRow [Blocks]
| [Blocks]
| MuseCaption Inlines
museToPandocTable :: MuseTable -> Blocks
museToPandocTable :: MuseTable -> Blocks
museToPandocTable (MuseTable Inlines
caption [[Blocks]]
headers [[Blocks]]
body [[Blocks]]
footers) =
Caption
-> [ColSpec] -> TableHead -> [TableBody] -> TableFoot -> Blocks
B.table (Blocks -> Caption
B.simpleCaption (Blocks -> Caption) -> Blocks -> Caption
forall a b. (a -> b) -> a -> b
$ Inlines -> Blocks
B.plain Inlines
caption)
[ColSpec]
attrs
(Attr -> [Row] -> TableHead
TableHead Attr
nullAttr ([Row] -> TableHead) -> [Row] -> TableHead
forall a b. (a -> b) -> a -> b
$ [Blocks] -> [Row]
toHeaderRow [Blocks]
headRow)
[Attr -> RowHeadColumns -> [Row] -> [Row] -> TableBody
TableBody Attr
nullAttr RowHeadColumns
0 [] ([Row] -> TableBody) -> [Row] -> TableBody
forall a b. (a -> b) -> a -> b
$ ([Blocks] -> Row) -> [[Blocks]] -> [Row]
forall a b. (a -> b) -> [a] -> [b]
map [Blocks] -> Row
toRow ([[Blocks]] -> [Row]) -> [[Blocks]] -> [Row]
forall a b. (a -> b) -> a -> b
$ [[Blocks]]
rows [[Blocks]] -> [[Blocks]] -> [[Blocks]]
forall a. [a] -> [a] -> [a]
++ [[Blocks]]
body [[Blocks]] -> [[Blocks]] -> [[Blocks]]
forall a. [a] -> [a] -> [a]
++ [[Blocks]]
footers]
(Attr -> [Row] -> TableFoot
TableFoot Attr
nullAttr [])
where attrs :: [ColSpec]
attrs = (Alignment
AlignDefault, ColWidth
ColWidthDefault) ColSpec -> [[Blocks]] -> [ColSpec]
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ [[Blocks]] -> [[Blocks]]
forall a. [[a]] -> [[a]]
transpose ([[Blocks]]
headers [[Blocks]] -> [[Blocks]] -> [[Blocks]]
forall a. [a] -> [a] -> [a]
++ [[Blocks]]
body [[Blocks]] -> [[Blocks]] -> [[Blocks]]
forall a. [a] -> [a] -> [a]
++ [[Blocks]]
footers)
([Blocks]
headRow, [[Blocks]]
rows) = ([Blocks], [[Blocks]])
-> Maybe ([Blocks], [[Blocks]]) -> ([Blocks], [[Blocks]])
forall a. a -> Maybe a -> a
fromMaybe ([], []) (Maybe ([Blocks], [[Blocks]]) -> ([Blocks], [[Blocks]]))
-> Maybe ([Blocks], [[Blocks]]) -> ([Blocks], [[Blocks]])
forall a b. (a -> b) -> a -> b
$ [[Blocks]] -> Maybe ([Blocks], [[Blocks]])
forall a. [a] -> Maybe (a, [a])
uncons [[Blocks]]
headers
toRow :: [Blocks] -> Row
toRow = Attr -> [Cell] -> Row
Row Attr
nullAttr ([Cell] -> Row) -> ([Blocks] -> [Cell]) -> [Blocks] -> Row
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Blocks -> Cell) -> [Blocks] -> [Cell]
forall a b. (a -> b) -> [a] -> [b]
map Blocks -> Cell
B.simpleCell
toHeaderRow :: [Blocks] -> [Row]
toHeaderRow [Blocks]
l = [[Blocks] -> Row
toRow [Blocks]
l | Bool -> Bool
not ([Blocks] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [Blocks]
l)]
museAppendElement :: MuseTableElement
-> MuseTable
-> MuseTable
museAppendElement :: MuseTableElement -> MuseTable -> MuseTable
museAppendElement MuseTableElement
element MuseTable
tbl =
case MuseTableElement
element of
MuseHeaderRow [Blocks]
row -> MuseTable
tbl{ museTableHeaders :: [[Blocks]]
museTableHeaders = [Blocks]
row [Blocks] -> [[Blocks]] -> [[Blocks]]
forall a. a -> [a] -> [a]
: MuseTable -> [[Blocks]]
museTableHeaders MuseTable
tbl }
MuseBodyRow [Blocks]
row -> MuseTable
tbl{ museTableRows :: [[Blocks]]
museTableRows = [Blocks]
row [Blocks] -> [[Blocks]] -> [[Blocks]]
forall a. a -> [a] -> [a]
: MuseTable -> [[Blocks]]
museTableRows MuseTable
tbl }
MuseFooterRow [Blocks]
row -> MuseTable
tbl{ museTableFooters :: [[Blocks]]
museTableFooters = [Blocks]
row [Blocks] -> [[Blocks]] -> [[Blocks]]
forall a. a -> [a] -> [a]
: MuseTable -> [[Blocks]]
museTableFooters MuseTable
tbl }
MuseCaption Inlines
inlines -> MuseTable
tbl{ museTableCaption :: Inlines
museTableCaption = Inlines
inlines }
tableElements :: PandocMonad m => MuseParser m (F [MuseTableElement])
tableElements :: MuseParser m (F [MuseTableElement])
tableElements = [Future MuseState MuseTableElement] -> F [MuseTableElement]
forall (t :: * -> *) (m :: * -> *) a.
(Traversable t, Monad m) =>
t (m a) -> m (t a)
sequence ([Future MuseState MuseTableElement] -> F [MuseTableElement])
-> ParsecT
Sources
MuseState
(ReaderT MuseEnv m)
[Future MuseState MuseTableElement]
-> MuseParser m (F [MuseTableElement])
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT
Sources
MuseState
(ReaderT MuseEnv m)
(Future MuseState MuseTableElement)
-> ParsecT
Sources
MuseState
(ReaderT MuseEnv m)
[Future MuseState MuseTableElement]
forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m [a]
many1 ParsecT
Sources
MuseState
(ReaderT MuseEnv m)
(Future MuseState MuseTableElement)
forall (m :: * -> *).
PandocMonad m =>
MuseParser m (Future MuseState MuseTableElement)
tableParseElement
elementsToTable :: [MuseTableElement] -> MuseTable
elementsToTable :: [MuseTableElement] -> MuseTable
elementsToTable = (MuseTableElement -> MuseTable -> MuseTable)
-> MuseTable -> [MuseTableElement] -> MuseTable
forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr MuseTableElement -> MuseTable -> MuseTable
museAppendElement MuseTable
emptyTable
where emptyTable :: MuseTable
emptyTable = Inlines -> [[Blocks]] -> [[Blocks]] -> [[Blocks]] -> MuseTable
MuseTable Inlines
forall a. Monoid a => a
mempty [[Blocks]]
forall a. Monoid a => a
mempty [[Blocks]]
forall a. Monoid a => a
mempty [[Blocks]]
forall a. Monoid a => a
mempty
museGridPart :: PandocMonad m => MuseParser m Int
museGridPart :: MuseParser m Int
museGridPart = MuseParser m Int -> MuseParser m Int
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (MuseParser m Int -> MuseParser m Int)
-> MuseParser m Int -> MuseParser m Int
forall a b. (a -> b) -> a -> b
$ SourceName -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length (SourceName -> Int)
-> ParsecT Sources MuseState (ReaderT MuseEnv m) SourceName
-> MuseParser m Int
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT Sources MuseState (ReaderT MuseEnv m) Char
-> ParsecT Sources MuseState (ReaderT MuseEnv m) SourceName
forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m [a]
many1 (Char -> ParsecT Sources MuseState (ReaderT MuseEnv m) Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
Char -> ParsecT s u m Char
char Char
'-') MuseParser m Int
-> ParsecT Sources MuseState (ReaderT MuseEnv m) Char
-> MuseParser m Int
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* Char -> ParsecT Sources MuseState (ReaderT MuseEnv m) Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
Char -> ParsecT s u m Char
char Char
'+'
museGridTableHeader :: PandocMonad m => MuseParser m [Int]
= MuseParser m [Int] -> MuseParser m [Int]
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (MuseParser m [Int] -> MuseParser m [Int])
-> MuseParser m [Int] -> MuseParser m [Int]
forall a b. (a -> b) -> a -> b
$ Char -> ParsecT Sources MuseState (ReaderT MuseEnv m) Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
Char -> ParsecT s u m Char
char Char
'+' ParsecT Sources MuseState (ReaderT MuseEnv m) Char
-> MuseParser m [Int] -> MuseParser m [Int]
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> ParsecT Sources MuseState (ReaderT MuseEnv m) Int
-> MuseParser m [Int]
forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m [a]
many1 ParsecT Sources MuseState (ReaderT MuseEnv m) Int
forall (m :: * -> *). PandocMonad m => MuseParser m Int
museGridPart MuseParser m [Int]
-> ParsecT Sources MuseState (ReaderT MuseEnv m) SourceName
-> MuseParser m [Int]
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* ParsecT Sources MuseState (ReaderT MuseEnv m) Char
-> ParsecT Sources MuseState (ReaderT MuseEnv m) ()
-> ParsecT Sources MuseState (ReaderT MuseEnv m) SourceName
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 MuseState (ReaderT MuseEnv m) Char
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParserT s st m Char
spaceChar ParsecT Sources MuseState (ReaderT MuseEnv m) ()
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParserT s st m ()
eol
museGridTableRow :: PandocMonad m
=> Int
-> [Int]
-> MuseParser m (F [Blocks])
museGridTableRow :: Int -> [Int] -> MuseParser m (Future MuseState [Blocks])
museGridTableRow Int
indent [Int]
indices = MuseParser m (Future MuseState [Blocks])
-> MuseParser m (Future MuseState [Blocks])
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (MuseParser m (Future MuseState [Blocks])
-> MuseParser m (Future MuseState [Blocks]))
-> MuseParser m (Future MuseState [Blocks])
-> MuseParser m (Future MuseState [Blocks])
forall a b. (a -> b) -> a -> b
$ do
[[Text]]
lns <- ParsecT Sources MuseState (ReaderT MuseEnv m) [Text]
-> ParsecT Sources MuseState (ReaderT MuseEnv m) [[Text]]
forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m [a]
many1 (ParsecT Sources MuseState (ReaderT MuseEnv m) [Text]
-> ParsecT Sources MuseState (ReaderT MuseEnv m) [[Text]])
-> ParsecT Sources MuseState (ReaderT MuseEnv m) [Text]
-> ParsecT Sources MuseState (ReaderT MuseEnv m) [[Text]]
forall a b. (a -> b) -> a -> b
$ ParsecT Sources MuseState (ReaderT MuseEnv m) [Text]
-> ParsecT Sources MuseState (ReaderT MuseEnv m) [Text]
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (Int -> ParserT Sources MuseState (ReaderT MuseEnv m) Text
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char, HasReaderOptions st) =>
Int -> ParserT s st m Text
indentWith Int
indent ParserT Sources MuseState (ReaderT MuseEnv m) Text
-> ParsecT Sources MuseState (ReaderT MuseEnv m) [Text]
-> ParsecT Sources MuseState (ReaderT MuseEnv m) [Text]
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> [Int] -> ParsecT Sources MuseState (ReaderT MuseEnv m) [Text]
forall (m :: * -> *). PandocMonad m => [Int] -> MuseParser m [Text]
museGridTableRawLine [Int]
indices)
let cols :: [Text]
cols = ([Text] -> Text) -> [[Text]] -> [Text]
forall a b. (a -> b) -> [a] -> [b]
map ([Text] -> Text
T.unlines ([Text] -> Text) -> ([Text] -> [Text]) -> [Text] -> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Text -> Text) -> [Text] -> [Text]
forall a b. (a -> b) -> [a] -> [b]
map Text -> Text
trimr) ([[Text]] -> [Text]) -> [[Text]] -> [Text]
forall a b. (a -> b) -> a -> b
$ [[Text]] -> [[Text]]
forall a. [[a]] -> [[a]]
transpose [[Text]]
lns
Int -> ParserT Sources MuseState (ReaderT MuseEnv m) Text
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char, HasReaderOptions st) =>
Int -> ParserT s st m Text
indentWith Int
indent ParserT Sources MuseState (ReaderT MuseEnv m) Text
-> ParsecT Sources MuseState (ReaderT MuseEnv m) [Int]
-> ParsecT Sources MuseState (ReaderT MuseEnv m) [Int]
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> ParsecT Sources MuseState (ReaderT MuseEnv m) [Int]
forall (m :: * -> *). PandocMonad m => MuseParser m [Int]
museGridTableHeader
[F Blocks] -> Future MuseState [Blocks]
forall (t :: * -> *) (m :: * -> *) a.
(Traversable t, Monad m) =>
t (m a) -> m (t a)
sequence ([F Blocks] -> Future MuseState [Blocks])
-> ParsecT Sources MuseState (ReaderT MuseEnv m) [F Blocks]
-> MuseParser m (Future MuseState [Blocks])
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Text -> ParsecT Sources MuseState (ReaderT MuseEnv m) (F Blocks))
-> [Text]
-> ParsecT Sources MuseState (ReaderT MuseEnv m) [F Blocks]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM (ParsecT Sources MuseState (ReaderT MuseEnv m) (F Blocks)
-> Text -> ParsecT Sources MuseState (ReaderT MuseEnv m) (F Blocks)
forall (m :: * -> *) u a.
(Monad m, HasLastStrPosition u) =>
ParserT Sources u m a -> Text -> ParserT Sources u m a
parseFromString' ParsecT Sources MuseState (ReaderT MuseEnv m) (F Blocks)
forall (m :: * -> *). PandocMonad m => MuseParser m (F Blocks)
parseBlocks) [Text]
cols
museGridTableRawLine :: PandocMonad m
=> [Int]
-> MuseParser m [Text]
museGridTableRawLine :: [Int] -> MuseParser m [Text]
museGridTableRawLine [Int]
indices =
Char -> ParsecT Sources MuseState (ReaderT MuseEnv m) Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
Char -> ParsecT s u m Char
char Char
'|' ParsecT Sources MuseState (ReaderT MuseEnv m) Char
-> MuseParser m [Text] -> MuseParser m [Text]
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> [Int]
-> (Int -> ParsecT Sources MuseState (ReaderT MuseEnv m) Text)
-> MuseParser m [Text]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
t a -> (a -> m b) -> m (t b)
forM [Int]
indices (\Int
n -> Int
-> ParsecT Sources MuseState (ReaderT MuseEnv m) Char
-> ParsecT Sources MuseState (ReaderT MuseEnv m) Text
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char, Monad m) =>
Int -> ParsecT s st m Char -> ParsecT s st m Text
countChar Int
n ParsecT Sources MuseState (ReaderT MuseEnv m) Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s u m Char
anyChar ParsecT Sources MuseState (ReaderT MuseEnv m) Text
-> ParsecT Sources MuseState (ReaderT MuseEnv m) Char
-> ParsecT Sources MuseState (ReaderT MuseEnv m) Text
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* Char -> ParsecT Sources MuseState (ReaderT MuseEnv m) Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
Char -> ParsecT s u m Char
char Char
'|') MuseParser m [Text]
-> ParsecT Sources MuseState (ReaderT MuseEnv m) SourceName
-> MuseParser m [Text]
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* ParsecT Sources MuseState (ReaderT MuseEnv m) Char
-> ParsecT Sources MuseState (ReaderT MuseEnv m) ()
-> ParsecT Sources MuseState (ReaderT MuseEnv m) SourceName
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 MuseState (ReaderT MuseEnv m) Char
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParserT s st m Char
spaceChar ParsecT Sources MuseState (ReaderT MuseEnv m) ()
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParserT s st m ()
eol
museGridTable :: PandocMonad m => MuseParser m (F Blocks)
museGridTable :: MuseParser m (F Blocks)
museGridTable = MuseParser m (F Blocks) -> MuseParser m (F Blocks)
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (MuseParser m (F Blocks) -> MuseParser m (F Blocks))
-> MuseParser m (F Blocks) -> MuseParser m (F Blocks)
forall a b. (a -> b) -> a -> b
$ do
Int
indent <- MuseParser m Int
forall (m :: * -> *). PandocMonad m => MuseParser m Int
getIndent
[Int]
indices <- MuseParser m [Int]
forall (m :: * -> *). PandocMonad m => MuseParser m [Int]
museGridTableHeader
([[Blocks]] -> Blocks) -> Future MuseState [[Blocks]] -> F Blocks
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap [[Blocks]] -> Blocks
rowsToTable (Future MuseState [[Blocks]] -> F Blocks)
-> ([Future MuseState [Blocks]] -> Future MuseState [[Blocks]])
-> [Future MuseState [Blocks]]
-> F Blocks
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Future MuseState [Blocks]] -> Future MuseState [[Blocks]]
forall (t :: * -> *) (m :: * -> *) a.
(Traversable t, Monad m) =>
t (m a) -> m (t a)
sequence ([Future MuseState [Blocks]] -> F Blocks)
-> ParsecT
Sources MuseState (ReaderT MuseEnv m) [Future MuseState [Blocks]]
-> MuseParser m (F Blocks)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT
Sources MuseState (ReaderT MuseEnv m) (Future MuseState [Blocks])
-> ParsecT
Sources MuseState (ReaderT MuseEnv m) [Future MuseState [Blocks]]
forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m [a]
many1 (Int
-> [Int]
-> ParsecT
Sources MuseState (ReaderT MuseEnv m) (Future MuseState [Blocks])
forall (m :: * -> *).
PandocMonad m =>
Int -> [Int] -> MuseParser m (Future MuseState [Blocks])
museGridTableRow Int
indent [Int]
indices)
where rowsToTable :: [[Blocks]] -> Blocks
rowsToTable [[Blocks]]
rows = Caption
-> [ColSpec] -> TableHead -> [TableBody] -> TableFoot -> Blocks
B.table Caption
B.emptyCaption
[ColSpec]
attrs
(Attr -> [Row] -> TableHead
TableHead Attr
nullAttr [])
[Attr -> RowHeadColumns -> [Row] -> [Row] -> TableBody
TableBody Attr
nullAttr RowHeadColumns
0 [] ([Row] -> TableBody) -> [Row] -> TableBody
forall a b. (a -> b) -> a -> b
$ ([Blocks] -> Row) -> [[Blocks]] -> [Row]
forall a b. (a -> b) -> [a] -> [b]
map [Blocks] -> Row
toRow [[Blocks]]
rows]
(Attr -> [Row] -> TableFoot
TableFoot Attr
nullAttr [])
where attrs :: [ColSpec]
attrs = (Alignment
AlignDefault, ColWidth
ColWidthDefault) ColSpec -> [[Blocks]] -> [ColSpec]
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ [[Blocks]] -> [[Blocks]]
forall a. [[a]] -> [[a]]
transpose [[Blocks]]
rows
toRow :: [Blocks] -> Row
toRow = Attr -> [Cell] -> Row
Row Attr
nullAttr ([Cell] -> Row) -> ([Blocks] -> [Cell]) -> [Blocks] -> Row
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Blocks -> Cell) -> [Blocks] -> [Cell]
forall a b. (a -> b) -> [a] -> [b]
map Blocks -> Cell
B.simpleCell
table :: PandocMonad m => MuseParser m (F Blocks)
table :: MuseParser m (F Blocks)
table = MuseParser m (F Blocks) -> MuseParser m (F Blocks)
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (MuseParser m (F Blocks) -> MuseParser m (F Blocks))
-> MuseParser m (F Blocks) -> MuseParser m (F Blocks)
forall a b. (a -> b) -> a -> b
$ ([MuseTableElement] -> Blocks) -> F [MuseTableElement] -> F Blocks
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (MuseTable -> Blocks
museToPandocTable (MuseTable -> Blocks)
-> ([MuseTableElement] -> MuseTable)
-> [MuseTableElement]
-> Blocks
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [MuseTableElement] -> MuseTable
elementsToTable) (F [MuseTableElement] -> F Blocks)
-> ParsecT
Sources MuseState (ReaderT MuseEnv m) (F [MuseTableElement])
-> MuseParser m (F Blocks)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT
Sources MuseState (ReaderT MuseEnv m) (F [MuseTableElement])
forall (m :: * -> *).
PandocMonad m =>
MuseParser m (F [MuseTableElement])
tableElements
tableParseElement :: PandocMonad m => MuseParser m (F MuseTableElement)
tableParseElement :: MuseParser m (Future MuseState MuseTableElement)
tableParseElement = MuseParser m (Future MuseState MuseTableElement)
forall (m :: * -> *).
PandocMonad m =>
MuseParser m (Future MuseState MuseTableElement)
tableParseHeader
MuseParser m (Future MuseState MuseTableElement)
-> MuseParser m (Future MuseState MuseTableElement)
-> MuseParser m (Future MuseState MuseTableElement)
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> MuseParser m (Future MuseState MuseTableElement)
forall (m :: * -> *).
PandocMonad m =>
MuseParser m (Future MuseState MuseTableElement)
tableParseBody
MuseParser m (Future MuseState MuseTableElement)
-> MuseParser m (Future MuseState MuseTableElement)
-> MuseParser m (Future MuseState MuseTableElement)
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> MuseParser m (Future MuseState MuseTableElement)
forall (m :: * -> *).
PandocMonad m =>
MuseParser m (Future MuseState MuseTableElement)
tableParseFooter
MuseParser m (Future MuseState MuseTableElement)
-> MuseParser m (Future MuseState MuseTableElement)
-> MuseParser m (Future MuseState MuseTableElement)
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> MuseParser m (Future MuseState MuseTableElement)
forall (m :: * -> *).
PandocMonad m =>
MuseParser m (Future MuseState MuseTableElement)
tableParseCaption
tableParseRow :: PandocMonad m
=> Int
-> MuseParser m (F [Blocks])
tableParseRow :: Int -> MuseParser m (Future MuseState [Blocks])
tableParseRow Int
n = MuseParser m (Future MuseState [Blocks])
-> MuseParser m (Future MuseState [Blocks])
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (MuseParser m (Future MuseState [Blocks])
-> MuseParser m (Future MuseState [Blocks]))
-> MuseParser m (Future MuseState [Blocks])
-> MuseParser m (Future MuseState [Blocks])
forall a b. (a -> b) -> a -> b
$ [F Blocks] -> Future MuseState [Blocks]
forall (t :: * -> *) (m :: * -> *) a.
(Traversable t, Monad m) =>
t (m a) -> m (t a)
sequence ([F Blocks] -> Future MuseState [Blocks])
-> ParsecT Sources MuseState (ReaderT MuseEnv m) [F Blocks]
-> MuseParser m (Future MuseState [Blocks])
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT Sources MuseState (ReaderT MuseEnv m) [F Blocks]
tableCells
where tableCells :: ParsecT Sources MuseState (ReaderT MuseEnv m) [F Blocks]
tableCells = (:) (F Blocks -> [F Blocks] -> [F Blocks])
-> ParsecT Sources MuseState (ReaderT MuseEnv m) (F Blocks)
-> ParsecT
Sources MuseState (ReaderT MuseEnv m) ([F Blocks] -> [F Blocks])
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT Sources MuseState (ReaderT MuseEnv m) ()
-> ParsecT Sources MuseState (ReaderT MuseEnv m) (F Blocks)
forall (m :: * -> *) a.
PandocMonad m =>
MuseParser m a -> MuseParser m (F Blocks)
tableCell ParsecT Sources MuseState (ReaderT MuseEnv m) ()
forall u. ParsecT Sources u (ReaderT MuseEnv m) ()
sep ParsecT
Sources MuseState (ReaderT MuseEnv m) ([F Blocks] -> [F Blocks])
-> ParsecT Sources MuseState (ReaderT MuseEnv m) [F Blocks]
-> ParsecT Sources MuseState (ReaderT MuseEnv m) [F Blocks]
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (ParsecT Sources MuseState (ReaderT MuseEnv m) [F Blocks]
tableCells ParsecT Sources MuseState (ReaderT MuseEnv m) [F Blocks]
-> ParsecT Sources MuseState (ReaderT MuseEnv m) [F Blocks]
-> ParsecT Sources MuseState (ReaderT MuseEnv m) [F Blocks]
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> (F Blocks -> [F Blocks])
-> ParsecT Sources MuseState (ReaderT MuseEnv m) (F Blocks)
-> ParsecT Sources MuseState (ReaderT MuseEnv m) [F Blocks]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap F Blocks -> [F Blocks]
forall (f :: * -> *) a. Applicative f => a -> f a
pure (ParsecT Sources MuseState (ReaderT MuseEnv m) ()
-> ParsecT Sources MuseState (ReaderT MuseEnv m) (F Blocks)
forall (m :: * -> *) a.
PandocMonad m =>
MuseParser m a -> MuseParser m (F Blocks)
tableCell ParsecT Sources MuseState (ReaderT MuseEnv m) ()
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParserT s st m ()
eol))
tableCell :: ParsecT Sources MuseState (ReaderT MuseEnv m) end
-> ParsecT Sources MuseState (ReaderT MuseEnv m) (F Blocks)
tableCell ParsecT Sources MuseState (ReaderT MuseEnv m) end
p = ParsecT Sources MuseState (ReaderT MuseEnv m) (F Blocks)
-> ParsecT Sources MuseState (ReaderT MuseEnv m) (F Blocks)
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT Sources MuseState (ReaderT MuseEnv m) (F Blocks)
-> ParsecT Sources MuseState (ReaderT MuseEnv m) (F Blocks))
-> ParsecT Sources MuseState (ReaderT MuseEnv m) (F Blocks)
-> ParsecT Sources MuseState (ReaderT MuseEnv m) (F Blocks)
forall a b. (a -> b) -> a -> b
$ (Inlines -> Blocks) -> F Inlines -> F Blocks
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Inlines -> Blocks
B.plain (F Inlines -> F Blocks)
-> ([F Inlines] -> F Inlines) -> [F Inlines] -> F Blocks
forall b c a. (b -> c) -> (a -> b) -> a -> c
. F Inlines -> F Inlines
forall s. Future s Inlines -> Future s Inlines
trimInlinesF (F Inlines -> F Inlines)
-> ([F Inlines] -> F Inlines) -> [F Inlines] -> F Inlines
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [F Inlines] -> F Inlines
forall a. Monoid a => [a] -> a
mconcat ([F Inlines] -> F Blocks)
-> ParsecT Sources MuseState (ReaderT MuseEnv m) [F Inlines]
-> ParsecT Sources MuseState (ReaderT MuseEnv m) (F Blocks)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT Sources MuseState (ReaderT MuseEnv m) (F Inlines)
-> ParsecT Sources MuseState (ReaderT MuseEnv m) end
-> ParsecT Sources MuseState (ReaderT MuseEnv m) [F Inlines]
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 MuseState (ReaderT MuseEnv m) (F Inlines)
forall (m :: * -> *). PandocMonad m => MuseParser m (F Inlines)
inline' ParsecT Sources MuseState (ReaderT MuseEnv m) end
p
sep :: ParsecT Sources u (ReaderT MuseEnv m) ()
sep = ParsecT Sources u (ReaderT MuseEnv m) ()
-> ParsecT Sources u (ReaderT MuseEnv m) ()
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT Sources u (ReaderT MuseEnv m) ()
-> ParsecT Sources u (ReaderT MuseEnv m) ())
-> ParsecT Sources u (ReaderT MuseEnv m) ()
-> ParsecT Sources u (ReaderT MuseEnv m) ()
forall a b. (a -> b) -> a -> b
$ ParsecT Sources u (ReaderT MuseEnv m) Char
-> ParsecT Sources u (ReaderT MuseEnv 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 u (ReaderT MuseEnv m) Char
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParserT s st m Char
spaceChar ParsecT Sources u (ReaderT MuseEnv m) SourceName
-> ParsecT Sources u (ReaderT MuseEnv m) SourceName
-> ParsecT Sources u (ReaderT MuseEnv m) SourceName
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Int
-> ParsecT Sources u (ReaderT MuseEnv m) Char
-> ParsecT Sources u (ReaderT MuseEnv m) SourceName
forall s (m :: * -> *) t u a.
Stream s m t =>
Int -> ParsecT s u m a -> ParsecT s u m [a]
count Int
n (Char -> ParsecT Sources u (ReaderT MuseEnv m) Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
Char -> ParsecT s u m Char
char Char
'|') ParsecT Sources u (ReaderT MuseEnv m) SourceName
-> ParsecT Sources u (ReaderT MuseEnv m) ()
-> ParsecT Sources u (ReaderT MuseEnv m) ()
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> ParsecT Sources u (ReaderT MuseEnv m) ()
-> ParsecT Sources u (ReaderT MuseEnv m) ()
forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m a
lookAhead (ParsecT Sources u (ReaderT MuseEnv m) SourceName
-> ParsecT Sources u (ReaderT MuseEnv m) ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (ParsecT Sources u (ReaderT MuseEnv m) Char
-> ParsecT Sources u (ReaderT MuseEnv 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 u (ReaderT MuseEnv m) Char
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParserT s st m Char
spaceChar) ParsecT Sources u (ReaderT MuseEnv m) ()
-> ParsecT Sources u (ReaderT MuseEnv m) ()
-> ParsecT Sources u (ReaderT MuseEnv m) ()
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> ParsecT Sources u (ReaderT MuseEnv m) ()
-> ParsecT Sources u (ReaderT MuseEnv m) ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void ParsecT Sources u (ReaderT MuseEnv m) ()
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParserT s st m ()
eol)
tableParseHeader :: PandocMonad m => MuseParser m (F MuseTableElement)
= ([Blocks] -> MuseTableElement)
-> Future MuseState [Blocks] -> Future MuseState MuseTableElement
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap [Blocks] -> MuseTableElement
MuseHeaderRow (Future MuseState [Blocks] -> Future MuseState MuseTableElement)
-> ParsecT
Sources MuseState (ReaderT MuseEnv m) (Future MuseState [Blocks])
-> MuseParser m (Future MuseState MuseTableElement)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Int
-> ParsecT
Sources MuseState (ReaderT MuseEnv m) (Future MuseState [Blocks])
forall (m :: * -> *).
PandocMonad m =>
Int -> MuseParser m (Future MuseState [Blocks])
tableParseRow Int
2
tableParseBody :: PandocMonad m => MuseParser m (F MuseTableElement)
tableParseBody :: MuseParser m (Future MuseState MuseTableElement)
tableParseBody = ([Blocks] -> MuseTableElement)
-> Future MuseState [Blocks] -> Future MuseState MuseTableElement
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap [Blocks] -> MuseTableElement
MuseBodyRow (Future MuseState [Blocks] -> Future MuseState MuseTableElement)
-> ParsecT
Sources MuseState (ReaderT MuseEnv m) (Future MuseState [Blocks])
-> MuseParser m (Future MuseState MuseTableElement)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Int
-> ParsecT
Sources MuseState (ReaderT MuseEnv m) (Future MuseState [Blocks])
forall (m :: * -> *).
PandocMonad m =>
Int -> MuseParser m (Future MuseState [Blocks])
tableParseRow Int
1
tableParseFooter :: PandocMonad m => MuseParser m (F MuseTableElement)
= ([Blocks] -> MuseTableElement)
-> Future MuseState [Blocks] -> Future MuseState MuseTableElement
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap [Blocks] -> MuseTableElement
MuseFooterRow (Future MuseState [Blocks] -> Future MuseState MuseTableElement)
-> ParsecT
Sources MuseState (ReaderT MuseEnv m) (Future MuseState [Blocks])
-> MuseParser m (Future MuseState MuseTableElement)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Int
-> ParsecT
Sources MuseState (ReaderT MuseEnv m) (Future MuseState [Blocks])
forall (m :: * -> *).
PandocMonad m =>
Int -> MuseParser m (Future MuseState [Blocks])
tableParseRow Int
3
tableParseCaption :: PandocMonad m => MuseParser m (F MuseTableElement)
tableParseCaption :: MuseParser m (Future MuseState MuseTableElement)
tableParseCaption = MuseParser m (Future MuseState MuseTableElement)
-> MuseParser m (Future MuseState MuseTableElement)
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (MuseParser m (Future MuseState MuseTableElement)
-> MuseParser m (Future MuseState MuseTableElement))
-> MuseParser m (Future MuseState MuseTableElement)
-> MuseParser m (Future MuseState MuseTableElement)
forall a b. (a -> b) -> a -> b
$ (Inlines -> MuseTableElement)
-> F Inlines -> Future MuseState MuseTableElement
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Inlines -> MuseTableElement
MuseCaption (F Inlines -> Future MuseState MuseTableElement)
-> ([F Inlines] -> F Inlines)
-> [F Inlines]
-> Future MuseState MuseTableElement
forall b c a. (b -> c) -> (a -> b) -> a -> c
. F Inlines -> F Inlines
forall s. Future s Inlines -> Future s Inlines
trimInlinesF (F Inlines -> F Inlines)
-> ([F Inlines] -> F Inlines) -> [F Inlines] -> F Inlines
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [F Inlines] -> F Inlines
forall a. Monoid a => [a] -> a
mconcat
([F Inlines] -> Future MuseState MuseTableElement)
-> ParsecT Sources MuseState (ReaderT MuseEnv m) SourceName
-> ParsecT
Sources
MuseState
(ReaderT MuseEnv m)
([F Inlines] -> Future MuseState MuseTableElement)
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ ParsecT Sources MuseState (ReaderT MuseEnv m) Char
-> ParsecT Sources MuseState (ReaderT MuseEnv m) SourceName
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
many ParsecT Sources MuseState (ReaderT MuseEnv m) Char
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParserT s st m Char
spaceChar
ParsecT
Sources
MuseState
(ReaderT MuseEnv m)
([F Inlines] -> Future MuseState MuseTableElement)
-> ParsecT Sources MuseState (ReaderT MuseEnv m) SourceName
-> ParsecT
Sources
MuseState
(ReaderT MuseEnv m)
([F Inlines] -> Future MuseState MuseTableElement)
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* SourceName
-> ParsecT Sources MuseState (ReaderT MuseEnv m) SourceName
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
SourceName -> ParsecT s u m SourceName
string SourceName
"|+"
ParsecT
Sources
MuseState
(ReaderT MuseEnv m)
([F Inlines] -> Future MuseState MuseTableElement)
-> ParsecT Sources MuseState (ReaderT MuseEnv m) [F Inlines]
-> MuseParser m (Future MuseState MuseTableElement)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ParserT Sources MuseState (ReaderT MuseEnv m) (F Inlines)
-> ParserT Sources MuseState (ReaderT MuseEnv m) ()
-> ParsecT Sources MuseState (ReaderT MuseEnv m) [F Inlines]
forall end s (m :: * -> *) t st a.
(Show end, Stream s m t) =>
ParserT s st m a -> ParserT s st m end -> ParserT s st m [a]
many1Till ParserT Sources MuseState (ReaderT MuseEnv m) (F Inlines)
forall (m :: * -> *). PandocMonad m => MuseParser m (F Inlines)
inline (ParserT Sources MuseState (ReaderT MuseEnv m) ()
-> ParserT Sources MuseState (ReaderT MuseEnv m) ()
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParserT Sources MuseState (ReaderT MuseEnv m) ()
-> ParserT Sources MuseState (ReaderT MuseEnv m) ())
-> ParserT Sources MuseState (ReaderT MuseEnv m) ()
-> ParserT Sources MuseState (ReaderT MuseEnv m) ()
forall a b. (a -> b) -> a -> b
$ SourceName
-> ParsecT Sources MuseState (ReaderT MuseEnv m) SourceName
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
SourceName -> ParsecT s u m SourceName
string SourceName
"+|" ParsecT Sources MuseState (ReaderT MuseEnv m) SourceName
-> ParserT Sources MuseState (ReaderT MuseEnv m) ()
-> ParserT Sources MuseState (ReaderT MuseEnv m) ()
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> ParserT Sources MuseState (ReaderT MuseEnv m) ()
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParserT s st m ()
eol)
inline' :: PandocMonad m => MuseParser m (F Inlines)
inline' :: MuseParser m (F Inlines)
inline' = MuseParser m (F Inlines)
forall (m :: * -> *). PandocMonad m => MuseParser m (F Inlines)
whitespace
MuseParser m (F Inlines)
-> MuseParser m (F Inlines) -> MuseParser m (F Inlines)
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> MuseParser m (F Inlines)
forall (m :: * -> *). PandocMonad m => MuseParser m (F Inlines)
br
MuseParser m (F Inlines)
-> MuseParser m (F Inlines) -> MuseParser m (F Inlines)
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> MuseParser m (F Inlines)
forall (m :: * -> *). PandocMonad m => MuseParser m (F Inlines)
anchor
MuseParser m (F Inlines)
-> MuseParser m (F Inlines) -> MuseParser m (F Inlines)
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> MuseParser m (F Inlines)
forall (m :: * -> *). PandocMonad m => MuseParser m (F Inlines)
footnote
MuseParser m (F Inlines)
-> MuseParser m (F Inlines) -> MuseParser m (F Inlines)
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> MuseParser m (F Inlines)
forall (m :: * -> *). PandocMonad m => MuseParser m (F Inlines)
strongEmph
MuseParser m (F Inlines)
-> MuseParser m (F Inlines) -> MuseParser m (F Inlines)
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> MuseParser m (F Inlines)
forall (m :: * -> *). PandocMonad m => MuseParser m (F Inlines)
strong
MuseParser m (F Inlines)
-> MuseParser m (F Inlines) -> MuseParser m (F Inlines)
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> MuseParser m (F Inlines)
forall (m :: * -> *). PandocMonad m => MuseParser m (F Inlines)
strongTag
MuseParser m (F Inlines)
-> MuseParser m (F Inlines) -> MuseParser m (F Inlines)
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> MuseParser m (F Inlines)
forall (m :: * -> *). PandocMonad m => MuseParser m (F Inlines)
emph
MuseParser m (F Inlines)
-> MuseParser m (F Inlines) -> MuseParser m (F Inlines)
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> MuseParser m (F Inlines)
forall (m :: * -> *). PandocMonad m => MuseParser m (F Inlines)
emphTag
MuseParser m (F Inlines)
-> MuseParser m (F Inlines) -> MuseParser m (F Inlines)
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> MuseParser m (F Inlines)
forall (m :: * -> *). PandocMonad m => MuseParser m (F Inlines)
underlined
MuseParser m (F Inlines)
-> MuseParser m (F Inlines) -> MuseParser m (F Inlines)
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> MuseParser m (F Inlines)
forall (m :: * -> *). PandocMonad m => MuseParser m (F Inlines)
superscriptTag
MuseParser m (F Inlines)
-> MuseParser m (F Inlines) -> MuseParser m (F Inlines)
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> MuseParser m (F Inlines)
forall (m :: * -> *). PandocMonad m => MuseParser m (F Inlines)
subscriptTag
MuseParser m (F Inlines)
-> MuseParser m (F Inlines) -> MuseParser m (F Inlines)
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> MuseParser m (F Inlines)
forall (m :: * -> *). PandocMonad m => MuseParser m (F Inlines)
strikeoutTag
MuseParser m (F Inlines)
-> MuseParser m (F Inlines) -> MuseParser m (F Inlines)
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> MuseParser m (F Inlines)
forall (m :: * -> *). PandocMonad m => MuseParser m (F Inlines)
verbatimTag
MuseParser m (F Inlines)
-> MuseParser m (F Inlines) -> MuseParser m (F Inlines)
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> MuseParser m (F Inlines)
forall (m :: * -> *). PandocMonad m => MuseParser m (F Inlines)
classTag
MuseParser m (F Inlines)
-> MuseParser m (F Inlines) -> MuseParser m (F Inlines)
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> MuseParser m (F Inlines)
forall (m :: * -> *). PandocMonad m => MuseParser m (F Inlines)
inlineRtl
MuseParser m (F Inlines)
-> MuseParser m (F Inlines) -> MuseParser m (F Inlines)
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> MuseParser m (F Inlines)
forall (m :: * -> *). PandocMonad m => MuseParser m (F Inlines)
inlineLtr
MuseParser m (F Inlines)
-> MuseParser m (F Inlines) -> MuseParser m (F Inlines)
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> MuseParser m (F Inlines)
forall (m :: * -> *). PandocMonad m => MuseParser m (F Inlines)
nbsp
MuseParser m (F Inlines)
-> MuseParser m (F Inlines) -> MuseParser m (F Inlines)
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> MuseParser m (F Inlines)
forall (m :: * -> *). PandocMonad m => MuseParser m (F Inlines)
linkOrImage
MuseParser m (F Inlines)
-> MuseParser m (F Inlines) -> MuseParser m (F Inlines)
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> MuseParser m (F Inlines)
forall (m :: * -> *). PandocMonad m => MuseParser m (F Inlines)
code
MuseParser m (F Inlines)
-> MuseParser m (F Inlines) -> MuseParser m (F Inlines)
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> MuseParser m (F Inlines)
forall (m :: * -> *). PandocMonad m => MuseParser m (F Inlines)
codeTag
MuseParser m (F Inlines)
-> MuseParser m (F Inlines) -> MuseParser m (F Inlines)
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> MuseParser m (F Inlines)
forall (m :: * -> *). PandocMonad m => MuseParser m (F Inlines)
mathTag
MuseParser m (F Inlines)
-> MuseParser m (F Inlines) -> MuseParser m (F Inlines)
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> MuseParser m (F Inlines)
forall (m :: * -> *). PandocMonad m => MuseParser m (F Inlines)
inlineLiteralTag
MuseParser m (F Inlines)
-> MuseParser m (F Inlines) -> MuseParser m (F Inlines)
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> MuseParser m (F Inlines)
forall (m :: * -> *). PandocMonad m => MuseParser m (F Inlines)
str
MuseParser m (F Inlines)
-> MuseParser m (F Inlines) -> MuseParser m (F Inlines)
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> MuseParser m (F Inlines)
forall (m :: * -> *). PandocMonad m => MuseParser m (F Inlines)
asterisks
MuseParser m (F Inlines)
-> MuseParser m (F Inlines) -> MuseParser m (F Inlines)
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> MuseParser m (F Inlines)
forall (m :: * -> *). PandocMonad m => MuseParser m (F Inlines)
symbol
MuseParser m (F Inlines) -> SourceName -> MuseParser m (F Inlines)
forall s u (m :: * -> *) a.
ParsecT s u m a -> SourceName -> ParsecT s u m a
<?> SourceName
"inline"
inline :: PandocMonad m => MuseParser m (F Inlines)
inline :: MuseParser m (F Inlines)
inline = MuseParser m (F Inlines)
forall (m :: * -> *). PandocMonad m => MuseParser m (F Inlines)
endline MuseParser m (F Inlines)
-> MuseParser m (F Inlines) -> MuseParser m (F Inlines)
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> MuseParser m (F Inlines)
forall (m :: * -> *). PandocMonad m => MuseParser m (F Inlines)
inline'
endline :: PandocMonad m => MuseParser m (F Inlines)
endline :: MuseParser m (F Inlines)
endline = MuseParser m (F Inlines) -> MuseParser m (F Inlines)
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (MuseParser m (F Inlines) -> MuseParser m (F Inlines))
-> MuseParser m (F Inlines) -> MuseParser m (F Inlines)
forall a b. (a -> b) -> a -> b
$ Inlines -> F Inlines
forall (f :: * -> *) a. Applicative f => a -> f a
pure Inlines
B.softbreak F Inlines
-> ParsecT Sources MuseState (ReaderT MuseEnv m) Char
-> MuseParser m (F Inlines)
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ ParsecT Sources MuseState (ReaderT MuseEnv m) Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s u m Char
newline MuseParser m (F Inlines)
-> ParsecT Sources MuseState (ReaderT MuseEnv m) ()
-> MuseParser m (F Inlines)
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* ParsecT Sources MuseState (ReaderT MuseEnv m) Char
-> ParsecT Sources MuseState (ReaderT MuseEnv m) ()
forall s (m :: * -> *) t a u.
(Stream s m t, Show a) =>
ParsecT s u m a -> ParsecT s u m ()
notFollowedBy ParsecT Sources MuseState (ReaderT MuseEnv m) Char
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParserT s st m Char
blankline MuseParser m (F Inlines)
-> ParsecT Sources MuseState (ReaderT MuseEnv m) ()
-> MuseParser m (F Inlines)
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* ParsecT Sources MuseState (ReaderT MuseEnv m) ()
forall (m :: * -> *). Monad m => MuseParser m ()
updateLastSpacePos
parseAnchor :: PandocMonad m => MuseParser m Text
parseAnchor :: MuseParser m Text
parseAnchor = MuseParser m Text -> MuseParser m Text
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (MuseParser m Text -> MuseParser m Text)
-> MuseParser m Text -> MuseParser m Text
forall a b. (a -> b) -> a -> b
$ Char -> Text -> Text
T.cons
(Char -> Text -> Text)
-> ParsecT Sources MuseState (ReaderT MuseEnv m) ()
-> ParsecT
Sources MuseState (ReaderT MuseEnv m) (Char -> Text -> Text)
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ ParsecT Sources MuseState (ReaderT MuseEnv m) ()
forall (m :: * -> *). PandocMonad m => MuseParser m ()
firstColumn
ParsecT
Sources MuseState (ReaderT MuseEnv m) (Char -> Text -> Text)
-> ParsecT Sources MuseState (ReaderT MuseEnv m) Char
-> ParsecT
Sources MuseState (ReaderT MuseEnv m) (Char -> Text -> Text)
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* Char -> ParsecT Sources MuseState (ReaderT MuseEnv m) Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
Char -> ParsecT s u m Char
char Char
'#'
ParsecT
Sources MuseState (ReaderT MuseEnv m) (Char -> Text -> Text)
-> ParsecT Sources MuseState (ReaderT MuseEnv m) Char
-> ParsecT Sources MuseState (ReaderT MuseEnv m) (Text -> Text)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ParsecT Sources MuseState (ReaderT MuseEnv m) Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s u m Char
letter
ParsecT Sources MuseState (ReaderT MuseEnv m) (Text -> Text)
-> MuseParser m Text -> MuseParser m Text
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ParsecT Sources MuseState (ReaderT MuseEnv m) Char
-> MuseParser m Text
forall s (m :: * -> *) t st.
Stream s m t =>
ParserT s st m Char -> ParserT s st m Text
manyChar (ParsecT Sources MuseState (ReaderT MuseEnv m) Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s u m Char
letter ParsecT Sources MuseState (ReaderT MuseEnv m) Char
-> ParsecT Sources MuseState (ReaderT MuseEnv m) Char
-> ParsecT Sources MuseState (ReaderT MuseEnv m) Char
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> ParsecT Sources MuseState (ReaderT MuseEnv m) Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s u m Char
digit ParsecT Sources MuseState (ReaderT MuseEnv m) Char
-> ParsecT Sources MuseState (ReaderT MuseEnv m) Char
-> ParsecT Sources MuseState (ReaderT MuseEnv m) Char
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> Char -> ParsecT Sources MuseState (ReaderT MuseEnv m) Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
Char -> ParsecT s u m Char
char Char
'-')
anchor :: PandocMonad m => MuseParser m (F Inlines)
anchor :: MuseParser m (F Inlines)
anchor = MuseParser m (F Inlines) -> MuseParser m (F Inlines)
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (MuseParser m (F Inlines) -> MuseParser m (F Inlines))
-> MuseParser m (F Inlines) -> MuseParser m (F Inlines)
forall a b. (a -> b) -> a -> b
$ do
Text
anchorId <- MuseParser m Text
forall (m :: * -> *). PandocMonad m => MuseParser m Text
parseAnchor
ParsecT Sources MuseState (ReaderT MuseEnv m) Char
-> ParsecT Sources MuseState (ReaderT MuseEnv m) ()
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m ()
skipMany ParsecT Sources MuseState (ReaderT MuseEnv m) Char
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParserT s st m Char
spaceChar ParsecT Sources MuseState (ReaderT MuseEnv m) ()
-> ParsecT Sources MuseState (ReaderT MuseEnv m) ()
-> ParsecT Sources MuseState (ReaderT MuseEnv m) ()
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> ParsecT Sources MuseState (ReaderT MuseEnv m) Char
-> ParsecT Sources MuseState (ReaderT MuseEnv m) ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void ParsecT Sources MuseState (ReaderT MuseEnv m) Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s u m Char
newline
F Inlines -> MuseParser m (F Inlines)
forall (m :: * -> *) a. Monad m => a -> m a
return (F Inlines -> MuseParser m (F Inlines))
-> F Inlines -> MuseParser m (F Inlines)
forall a b. (a -> b) -> a -> b
$ Inlines -> F Inlines
forall (m :: * -> *) a. Monad m => a -> m a
return (Inlines -> F Inlines) -> Inlines -> F Inlines
forall a b. (a -> b) -> a -> b
$ Attr -> Inlines -> Inlines
B.spanWith (Text
anchorId, [], []) Inlines
forall a. Monoid a => a
mempty
footnote :: PandocMonad m => MuseParser m (F Inlines)
= MuseParser m (F Inlines) -> MuseParser m (F Inlines)
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (MuseParser m (F Inlines) -> MuseParser m (F Inlines))
-> MuseParser m (F Inlines) -> MuseParser m (F Inlines)
forall a b. (a -> b) -> a -> b
$ do
Bool
inLink <- (MuseEnv -> Bool)
-> ParsecT Sources MuseState (ReaderT MuseEnv m) Bool
forall r (m :: * -> *) a. MonadReader r m => (r -> a) -> m a
asks MuseEnv -> Bool
museInLink
Bool -> ParsecT Sources MuseState (ReaderT MuseEnv m) ()
forall (f :: * -> *). Alternative f => Bool -> f ()
guard (Bool -> ParsecT Sources MuseState (ReaderT MuseEnv m) ())
-> Bool -> ParsecT Sources MuseState (ReaderT MuseEnv m) ()
forall a b. (a -> b) -> a -> b
$ Bool -> Bool
not Bool
inLink
Text
ref <- MuseParser m Text
forall (m :: * -> *). PandocMonad m => MuseParser m Text
noteMarker
F Inlines -> MuseParser m (F Inlines)
forall (m :: * -> *) a. Monad m => a -> m a
return (F Inlines -> MuseParser m (F Inlines))
-> F Inlines -> MuseParser m (F Inlines)
forall a b. (a -> b) -> a -> b
$ do
Map Text (SourcePos, F Blocks)
notes <- (MuseState -> Map Text (SourcePos, F Blocks))
-> Future MuseState (Map Text (SourcePos, F Blocks))
forall s a. (s -> a) -> Future s a
asksF MuseState -> Map Text (SourcePos, F Blocks)
museNotes
case Text
-> Map Text (SourcePos, F Blocks) -> Maybe (SourcePos, F Blocks)
forall k a. Ord k => k -> Map k a -> Maybe a
M.lookup Text
ref Map Text (SourcePos, F Blocks)
notes of
Maybe (SourcePos, F Blocks)
Nothing -> Inlines -> F Inlines
forall (m :: * -> *) a. Monad m => a -> m a
return (Inlines -> F Inlines) -> Inlines -> F Inlines
forall a b. (a -> b) -> a -> b
$ Text -> Inlines
B.str Text
ref
Just (SourcePos
_pos, F Blocks
contents) -> do
MuseState
st <- Future MuseState MuseState
forall s. Future s s
askF
let contents' :: Blocks
contents' = F Blocks -> MuseState -> Blocks
forall s a. Future s a -> s -> a
runF F Blocks
contents MuseState
st { museNotes :: Map Text (SourcePos, F Blocks)
museNotes = Text
-> Map Text (SourcePos, F Blocks) -> Map Text (SourcePos, F Blocks)
forall k a. Ord k => k -> Map k a -> Map k a
M.delete Text
ref (MuseState -> Map Text (SourcePos, F Blocks)
museNotes MuseState
st) }
Inlines -> F Inlines
forall (m :: * -> *) a. Monad m => a -> m a
return (Inlines -> F Inlines) -> Inlines -> F Inlines
forall a b. (a -> b) -> a -> b
$ Blocks -> Inlines
B.note Blocks
contents'
whitespace :: PandocMonad m => MuseParser m (F Inlines)
whitespace :: MuseParser m (F Inlines)
whitespace = MuseParser m (F Inlines) -> MuseParser m (F Inlines)
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (MuseParser m (F Inlines) -> MuseParser m (F Inlines))
-> MuseParser m (F Inlines) -> MuseParser m (F Inlines)
forall a b. (a -> b) -> a -> b
$ Inlines -> F Inlines
forall (f :: * -> *) a. Applicative f => a -> f a
pure Inlines
B.space F Inlines
-> ParsecT Sources MuseState (ReaderT MuseEnv m) ()
-> MuseParser m (F Inlines)
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ ParsecT Sources MuseState (ReaderT MuseEnv m) Char
-> ParsecT Sources MuseState (ReaderT MuseEnv m) ()
forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m ()
skipMany1 ParsecT Sources MuseState (ReaderT MuseEnv m) Char
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParserT s st m Char
spaceChar MuseParser m (F Inlines)
-> ParsecT Sources MuseState (ReaderT MuseEnv m) ()
-> MuseParser m (F Inlines)
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* ParsecT Sources MuseState (ReaderT MuseEnv m) ()
forall (m :: * -> *). Monad m => MuseParser m ()
updateLastSpacePos
br :: PandocMonad m => MuseParser m (F Inlines)
br :: MuseParser m (F Inlines)
br = MuseParser m (F Inlines) -> MuseParser m (F Inlines)
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (MuseParser m (F Inlines) -> MuseParser m (F Inlines))
-> MuseParser m (F Inlines) -> MuseParser m (F Inlines)
forall a b. (a -> b) -> a -> b
$ Inlines -> F Inlines
forall (f :: * -> *) a. Applicative f => a -> f a
pure Inlines
B.linebreak F Inlines
-> ParsecT Sources MuseState (ReaderT MuseEnv m) SourceName
-> MuseParser m (F Inlines)
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ SourceName
-> ParsecT Sources MuseState (ReaderT MuseEnv m) SourceName
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
SourceName -> ParsecT s u m SourceName
string SourceName
"<br>"
emphasisBetween :: (PandocMonad m, Show a)
=> MuseParser m a
-> MuseParser m (F Inlines)
emphasisBetween :: MuseParser m a -> MuseParser m (F Inlines)
emphasisBetween MuseParser m a
p = MuseParser m (F Inlines) -> MuseParser m (F Inlines)
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (MuseParser m (F Inlines) -> MuseParser m (F Inlines))
-> MuseParser m (F Inlines) -> MuseParser m (F Inlines)
forall a b. (a -> b) -> a -> b
$ F Inlines -> F Inlines
forall s. Future s Inlines -> Future s Inlines
trimInlinesF (F Inlines -> F Inlines)
-> ([F Inlines] -> F Inlines) -> [F Inlines] -> F Inlines
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [F Inlines] -> F Inlines
forall a. Monoid a => [a] -> a
mconcat
([F Inlines] -> F Inlines)
-> ParsecT Sources MuseState (ReaderT MuseEnv m) ()
-> ParsecT
Sources MuseState (ReaderT MuseEnv m) ([F Inlines] -> F Inlines)
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ ParsecT Sources MuseState (ReaderT MuseEnv m) ()
forall (m :: * -> *). PandocMonad m => MuseParser m ()
atStart
ParsecT
Sources MuseState (ReaderT MuseEnv m) ([F Inlines] -> F Inlines)
-> MuseParser m a
-> ParsecT
Sources MuseState (ReaderT MuseEnv m) ([F Inlines] -> F Inlines)
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* MuseParser m a
p
ParsecT
Sources MuseState (ReaderT MuseEnv m) ([F Inlines] -> F Inlines)
-> ParsecT Sources MuseState (ReaderT MuseEnv m) ()
-> ParsecT
Sources MuseState (ReaderT MuseEnv m) ([F Inlines] -> F Inlines)
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* ParsecT Sources MuseState (ReaderT MuseEnv m) Char
-> ParsecT Sources MuseState (ReaderT MuseEnv m) ()
forall s (m :: * -> *) t a u.
(Stream s m t, Show a) =>
ParsecT s u m a -> ParsecT s u m ()
notFollowedBy ParsecT Sources MuseState (ReaderT MuseEnv m) Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s u m Char
space
ParsecT
Sources MuseState (ReaderT MuseEnv m) ([F Inlines] -> F Inlines)
-> ParsecT Sources MuseState (ReaderT MuseEnv m) [F Inlines]
-> MuseParser m (F Inlines)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> MuseParser m (F Inlines)
-> MuseParser m a
-> ParsecT Sources MuseState (ReaderT MuseEnv m) [F Inlines]
forall end s (m :: * -> *) t st a.
(Show end, Stream s m t) =>
ParserT s st m a -> ParserT s st m end -> ParserT s st m [a]
many1Till MuseParser m (F Inlines)
forall (m :: * -> *). PandocMonad m => MuseParser m (F Inlines)
inline (MuseParser m a -> MuseParser m a
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (MuseParser m a -> MuseParser m a)
-> MuseParser m a -> MuseParser m a
forall a b. (a -> b) -> a -> b
$ ParsecT Sources MuseState (ReaderT MuseEnv m) ()
forall (m :: * -> *). PandocMonad m => MuseParser m ()
noSpaceBefore ParsecT Sources MuseState (ReaderT MuseEnv m) ()
-> MuseParser m a -> MuseParser m a
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> MuseParser m a
p MuseParser m a
-> ParsecT Sources MuseState (ReaderT MuseEnv m) ()
-> MuseParser m a
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* ParsecT Sources MuseState (ReaderT MuseEnv m) Char
-> ParsecT Sources MuseState (ReaderT MuseEnv m) ()
forall s (m :: * -> *) t a u.
(Stream s m t, Show a) =>
ParsecT s u m a -> ParsecT s u m ()
notFollowedBy ParsecT Sources MuseState (ReaderT MuseEnv m) Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s u m Char
alphaNum)
inlineTag :: PandocMonad m
=> Text
-> MuseParser m (F Inlines)
inlineTag :: Text -> MuseParser m (F Inlines)
inlineTag Text
tag = MuseParser m (F Inlines) -> MuseParser m (F Inlines)
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (MuseParser m (F Inlines) -> MuseParser m (F Inlines))
-> MuseParser m (F Inlines) -> MuseParser m (F Inlines)
forall a b. (a -> b) -> a -> b
$ [F Inlines] -> F Inlines
forall a. Monoid a => [a] -> a
mconcat
([F Inlines] -> F Inlines)
-> ParsecT Sources MuseState (ReaderT MuseEnv m) [(Text, Text)]
-> ParsecT
Sources MuseState (ReaderT MuseEnv m) ([F Inlines] -> F Inlines)
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ Text
-> ParsecT Sources MuseState (ReaderT MuseEnv m) [(Text, Text)]
forall (m :: * -> *).
PandocMonad m =>
Text -> MuseParser m [(Text, Text)]
openTag Text
tag
ParsecT
Sources MuseState (ReaderT MuseEnv m) ([F Inlines] -> F Inlines)
-> ParsecT Sources MuseState (ReaderT MuseEnv m) [F Inlines]
-> MuseParser m (F Inlines)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> MuseParser m (F Inlines)
-> ParsecT Sources MuseState (ReaderT MuseEnv m) ()
-> ParsecT Sources MuseState (ReaderT MuseEnv m) [F Inlines]
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 MuseParser m (F Inlines)
forall (m :: * -> *). PandocMonad m => MuseParser m (F Inlines)
inline (Text -> ParsecT Sources MuseState (ReaderT MuseEnv m) ()
forall (m :: * -> *). PandocMonad m => Text -> MuseParser m ()
closeTag Text
tag)
strongEmph :: PandocMonad m => MuseParser m (F Inlines)
strongEmph :: MuseParser m (F Inlines)
strongEmph = (Inlines -> Inlines) -> F Inlines -> F Inlines
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (Inlines -> Inlines
B.strong (Inlines -> Inlines) -> (Inlines -> Inlines) -> Inlines -> Inlines
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Inlines -> Inlines
B.emph) (F Inlines -> F Inlines)
-> MuseParser m (F Inlines) -> MuseParser m (F Inlines)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> MuseParser m SourceName -> MuseParser m (F Inlines)
forall (m :: * -> *) a.
(PandocMonad m, Show a) =>
MuseParser m a -> MuseParser m (F Inlines)
emphasisBetween (SourceName -> MuseParser m SourceName
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
SourceName -> ParsecT s u m SourceName
string SourceName
"***" MuseParser m SourceName
-> ParsecT Sources MuseState (ReaderT MuseEnv m) ()
-> MuseParser m SourceName
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* ParsecT Sources MuseState (ReaderT MuseEnv m) Char
-> ParsecT Sources MuseState (ReaderT MuseEnv m) ()
forall s (m :: * -> *) t a u.
(Stream s m t, Show a) =>
ParsecT s u m a -> ParsecT s u m ()
notFollowedBy (Char -> ParsecT Sources MuseState (ReaderT MuseEnv m) Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
Char -> ParsecT s u m Char
char Char
'*'))
strong :: PandocMonad m => MuseParser m (F Inlines)
strong :: MuseParser m (F Inlines)
strong = (Inlines -> Inlines) -> F Inlines -> F Inlines
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Inlines -> Inlines
B.strong (F Inlines -> F Inlines)
-> MuseParser m (F Inlines) -> MuseParser m (F Inlines)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> MuseParser m SourceName -> MuseParser m (F Inlines)
forall (m :: * -> *) a.
(PandocMonad m, Show a) =>
MuseParser m a -> MuseParser m (F Inlines)
emphasisBetween (SourceName -> MuseParser m SourceName
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
SourceName -> ParsecT s u m SourceName
string SourceName
"**" MuseParser m SourceName
-> ParsecT Sources MuseState (ReaderT MuseEnv m) ()
-> MuseParser m SourceName
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* ParsecT Sources MuseState (ReaderT MuseEnv m) Char
-> ParsecT Sources MuseState (ReaderT MuseEnv m) ()
forall s (m :: * -> *) t a u.
(Stream s m t, Show a) =>
ParsecT s u m a -> ParsecT s u m ()
notFollowedBy (Char -> ParsecT Sources MuseState (ReaderT MuseEnv m) Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
Char -> ParsecT s u m Char
char Char
'*'))
emph :: PandocMonad m => MuseParser m (F Inlines)
emph :: MuseParser m (F Inlines)
emph = (Inlines -> Inlines) -> F Inlines -> F Inlines
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Inlines -> Inlines
B.emph (F Inlines -> F Inlines)
-> MuseParser m (F Inlines) -> MuseParser m (F Inlines)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> MuseParser m Char -> MuseParser m (F Inlines)
forall (m :: * -> *) a.
(PandocMonad m, Show a) =>
MuseParser m a -> MuseParser m (F Inlines)
emphasisBetween (Char -> MuseParser m Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
Char -> ParsecT s u m Char
char Char
'*' MuseParser m Char
-> ParsecT Sources MuseState (ReaderT MuseEnv m) ()
-> MuseParser m Char
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* MuseParser m Char
-> ParsecT Sources MuseState (ReaderT MuseEnv m) ()
forall s (m :: * -> *) t a u.
(Stream s m t, Show a) =>
ParsecT s u m a -> ParsecT s u m ()
notFollowedBy (Char -> MuseParser m Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
Char -> ParsecT s u m Char
char Char
'*'))
underlined :: PandocMonad m => MuseParser m (F Inlines)
underlined :: MuseParser m (F Inlines)
underlined = (Inlines -> Inlines) -> F Inlines -> F Inlines
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Inlines -> Inlines
underline
(F Inlines -> F Inlines)
-> ParsecT Sources MuseState (ReaderT MuseEnv m) ()
-> ParsecT
Sources MuseState (ReaderT MuseEnv m) (F Inlines -> F Inlines)
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ Extension -> ParsecT Sources MuseState (ReaderT MuseEnv m) ()
forall s (m :: * -> *) a st.
(Stream s m a, HasReaderOptions st) =>
Extension -> ParserT s st m ()
guardDisabled Extension
Ext_amuse
ParsecT
Sources MuseState (ReaderT MuseEnv m) (F Inlines -> F Inlines)
-> MuseParser m (F Inlines) -> MuseParser m (F Inlines)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> MuseParser m Char -> MuseParser m (F Inlines)
forall (m :: * -> *) a.
(PandocMonad m, Show a) =>
MuseParser m a -> MuseParser m (F Inlines)
emphasisBetween (Char -> MuseParser m Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
Char -> ParsecT s u m Char
char Char
'_')
strongTag :: PandocMonad m => MuseParser m (F Inlines)
strongTag :: MuseParser m (F Inlines)
strongTag = (Inlines -> Inlines) -> F Inlines -> F Inlines
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Inlines -> Inlines
B.strong (F Inlines -> F Inlines)
-> MuseParser m (F Inlines) -> MuseParser m (F Inlines)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Text -> MuseParser m (F Inlines)
forall (m :: * -> *).
PandocMonad m =>
Text -> MuseParser m (F Inlines)
inlineTag Text
"strong"
emphTag :: PandocMonad m => MuseParser m (F Inlines)
emphTag :: MuseParser m (F Inlines)
emphTag = (Inlines -> Inlines) -> F Inlines -> F Inlines
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Inlines -> Inlines
B.emph (F Inlines -> F Inlines)
-> MuseParser m (F Inlines) -> MuseParser m (F Inlines)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Text -> MuseParser m (F Inlines)
forall (m :: * -> *).
PandocMonad m =>
Text -> MuseParser m (F Inlines)
inlineTag Text
"em"
superscriptTag :: PandocMonad m => MuseParser m (F Inlines)
superscriptTag :: MuseParser m (F Inlines)
superscriptTag = (Inlines -> Inlines) -> F Inlines -> F Inlines
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Inlines -> Inlines
B.superscript (F Inlines -> F Inlines)
-> MuseParser m (F Inlines) -> MuseParser m (F Inlines)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Text -> MuseParser m (F Inlines)
forall (m :: * -> *).
PandocMonad m =>
Text -> MuseParser m (F Inlines)
inlineTag Text
"sup"
subscriptTag :: PandocMonad m => MuseParser m (F Inlines)
subscriptTag :: MuseParser m (F Inlines)
subscriptTag = (Inlines -> Inlines) -> F Inlines -> F Inlines
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Inlines -> Inlines
B.subscript (F Inlines -> F Inlines)
-> MuseParser m (F Inlines) -> MuseParser m (F Inlines)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Text -> MuseParser m (F Inlines)
forall (m :: * -> *).
PandocMonad m =>
Text -> MuseParser m (F Inlines)
inlineTag Text
"sub"
strikeoutTag :: PandocMonad m => MuseParser m (F Inlines)
strikeoutTag :: MuseParser m (F Inlines)
strikeoutTag = (Inlines -> Inlines) -> F Inlines -> F Inlines
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Inlines -> Inlines
B.strikeout (F Inlines -> F Inlines)
-> MuseParser m (F Inlines) -> MuseParser m (F Inlines)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Text -> MuseParser m (F Inlines)
forall (m :: * -> *).
PandocMonad m =>
Text -> MuseParser m (F Inlines)
inlineTag Text
"del"
verbatimTag :: PandocMonad m => MuseParser m (F Inlines)
verbatimTag :: MuseParser m (F Inlines)
verbatimTag = Inlines -> F Inlines
forall (m :: * -> *) a. Monad m => a -> m a
return (Inlines -> F Inlines) -> (Text -> Inlines) -> Text -> F Inlines
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Inlines
B.text
(Text -> F Inlines)
-> ParsecT Sources MuseState (ReaderT MuseEnv m) [(Text, Text)]
-> ParsecT
Sources MuseState (ReaderT MuseEnv m) (Text -> F Inlines)
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ Text
-> ParsecT Sources MuseState (ReaderT MuseEnv m) [(Text, Text)]
forall (m :: * -> *).
PandocMonad m =>
Text -> MuseParser m [(Text, Text)]
openTag Text
"verbatim"
ParsecT Sources MuseState (ReaderT MuseEnv m) (Text -> F Inlines)
-> ParsecT Sources MuseState (ReaderT MuseEnv m) Text
-> MuseParser m (F Inlines)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ParserT Sources MuseState (ReaderT MuseEnv m) Char
-> ParserT Sources MuseState (ReaderT MuseEnv m) ()
-> ParsecT Sources MuseState (ReaderT MuseEnv m) Text
forall s (m :: * -> *) t st a.
Stream s m t =>
ParserT s st m Char -> ParserT s st m a -> ParserT s st m Text
manyTillChar ParserT Sources MuseState (ReaderT MuseEnv m) Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s u m Char
anyChar (Text -> ParserT Sources MuseState (ReaderT MuseEnv m) ()
forall (m :: * -> *). PandocMonad m => Text -> MuseParser m ()
closeTag Text
"verbatim")
classTag :: PandocMonad m => MuseParser m (F Inlines)
classTag :: MuseParser m (F Inlines)
classTag = do
[Text]
classes <- [Text] -> (Text -> [Text]) -> Maybe Text -> [Text]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] Text -> [Text]
T.words (Maybe Text -> [Text])
-> ([(Text, Text)] -> Maybe Text) -> [(Text, Text)] -> [Text]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> [(Text, Text)] -> Maybe Text
forall a b. Eq a => a -> [(a, b)] -> Maybe b
lookup Text
"name" ([(Text, Text)] -> [Text])
-> ParsecT Sources MuseState (ReaderT MuseEnv m) [(Text, Text)]
-> ParsecT Sources MuseState (ReaderT MuseEnv m) [Text]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Text
-> ParsecT Sources MuseState (ReaderT MuseEnv m) [(Text, Text)]
forall (m :: * -> *).
PandocMonad m =>
Text -> MuseParser m [(Text, Text)]
openTag Text
"class"
(Inlines -> Inlines) -> F Inlines -> F Inlines
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (Attr -> Inlines -> Inlines
B.spanWith (Text
"", [Text]
classes, [])) (F Inlines -> F Inlines)
-> ([F Inlines] -> F Inlines) -> [F Inlines] -> F Inlines
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [F Inlines] -> F Inlines
forall a. Monoid a => [a] -> a
mconcat ([F Inlines] -> F Inlines)
-> ParsecT Sources MuseState (ReaderT MuseEnv m) [F Inlines]
-> MuseParser m (F Inlines)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> MuseParser m (F Inlines)
-> ParsecT Sources MuseState (ReaderT MuseEnv m) ()
-> ParsecT Sources MuseState (ReaderT MuseEnv m) [F Inlines]
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 MuseParser m (F Inlines)
forall (m :: * -> *). PandocMonad m => MuseParser m (F Inlines)
inline (Text -> ParsecT Sources MuseState (ReaderT MuseEnv m) ()
forall (m :: * -> *). PandocMonad m => Text -> MuseParser m ()
closeTag Text
"class")
inlineRtl :: PandocMonad m => MuseParser m (F Inlines)
inlineRtl :: MuseParser m (F Inlines)
inlineRtl = MuseParser m (F Inlines) -> MuseParser m (F Inlines)
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (MuseParser m (F Inlines) -> MuseParser m (F Inlines))
-> MuseParser m (F Inlines) -> MuseParser m (F Inlines)
forall a b. (a -> b) -> a -> b
$
(Inlines -> Inlines) -> F Inlines -> F Inlines
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (Attr -> Inlines -> Inlines
B.spanWith (Text
"", [], [(Text
"dir", Text
"rtl")])) (F Inlines -> F Inlines)
-> ([F Inlines] -> F Inlines) -> [F Inlines] -> F Inlines
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [F Inlines] -> F Inlines
forall a. Monoid a => [a] -> a
mconcat ([F Inlines] -> F Inlines)
-> ParsecT Sources MuseState (ReaderT MuseEnv m) SourceName
-> ParsecT
Sources MuseState (ReaderT MuseEnv m) ([F Inlines] -> F Inlines)
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ SourceName
-> ParsecT Sources MuseState (ReaderT MuseEnv m) SourceName
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
SourceName -> ParsecT s u m SourceName
string SourceName
"<<<" ParsecT
Sources MuseState (ReaderT MuseEnv m) ([F Inlines] -> F Inlines)
-> ParsecT Sources MuseState (ReaderT MuseEnv m) [F Inlines]
-> MuseParser m (F Inlines)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> MuseParser m (F Inlines)
-> ParsecT Sources MuseState (ReaderT MuseEnv m) SourceName
-> ParsecT Sources MuseState (ReaderT MuseEnv m) [F Inlines]
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 MuseParser m (F Inlines)
forall (m :: * -> *). PandocMonad m => MuseParser m (F Inlines)
inline (SourceName
-> ParsecT Sources MuseState (ReaderT MuseEnv m) SourceName
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
SourceName -> ParsecT s u m SourceName
string SourceName
">>>")
inlineLtr :: PandocMonad m => MuseParser m (F Inlines)
inlineLtr :: MuseParser m (F Inlines)
inlineLtr = MuseParser m (F Inlines) -> MuseParser m (F Inlines)
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (MuseParser m (F Inlines) -> MuseParser m (F Inlines))
-> MuseParser m (F Inlines) -> MuseParser m (F Inlines)
forall a b. (a -> b) -> a -> b
$
(Inlines -> Inlines) -> F Inlines -> F Inlines
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (Attr -> Inlines -> Inlines
B.spanWith (Text
"", [], [(Text
"dir", Text
"ltr")])) (F Inlines -> F Inlines)
-> ([F Inlines] -> F Inlines) -> [F Inlines] -> F Inlines
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [F Inlines] -> F Inlines
forall a. Monoid a => [a] -> a
mconcat ([F Inlines] -> F Inlines)
-> ParsecT Sources MuseState (ReaderT MuseEnv m) SourceName
-> ParsecT
Sources MuseState (ReaderT MuseEnv m) ([F Inlines] -> F Inlines)
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ SourceName
-> ParsecT Sources MuseState (ReaderT MuseEnv m) SourceName
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
SourceName -> ParsecT s u m SourceName
string SourceName
">>>" ParsecT
Sources MuseState (ReaderT MuseEnv m) ([F Inlines] -> F Inlines)
-> ParsecT Sources MuseState (ReaderT MuseEnv m) [F Inlines]
-> MuseParser m (F Inlines)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> MuseParser m (F Inlines)
-> ParsecT Sources MuseState (ReaderT MuseEnv m) SourceName
-> ParsecT Sources MuseState (ReaderT MuseEnv m) [F Inlines]
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 MuseParser m (F Inlines)
forall (m :: * -> *). PandocMonad m => MuseParser m (F Inlines)
inline (SourceName
-> ParsecT Sources MuseState (ReaderT MuseEnv m) SourceName
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
SourceName -> ParsecT s u m SourceName
string SourceName
"<<<")
nbsp :: PandocMonad m => MuseParser m (F Inlines)
nbsp :: MuseParser m (F Inlines)
nbsp = MuseParser m (F Inlines) -> MuseParser m (F Inlines)
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (MuseParser m (F Inlines) -> MuseParser m (F Inlines))
-> MuseParser m (F Inlines) -> MuseParser m (F Inlines)
forall a b. (a -> b) -> a -> b
$ Inlines -> F Inlines
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Text -> Inlines
B.str Text
"\160") F Inlines
-> ParsecT Sources MuseState (ReaderT MuseEnv m) SourceName
-> MuseParser m (F Inlines)
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ SourceName
-> ParsecT Sources MuseState (ReaderT MuseEnv m) SourceName
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
SourceName -> ParsecT s u m SourceName
string SourceName
"~~"
code :: PandocMonad m => MuseParser m (F Inlines)
code :: MuseParser m (F Inlines)
code = MuseParser m (F Inlines) -> MuseParser m (F Inlines)
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (MuseParser m (F Inlines) -> MuseParser m (F Inlines))
-> MuseParser m (F Inlines) -> MuseParser m (F Inlines)
forall a b. (a -> b) -> a -> b
$ (Inlines -> F Inlines)
-> ParsecT Sources MuseState (ReaderT MuseEnv m) Inlines
-> MuseParser m (F Inlines)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Inlines -> F Inlines
forall (f :: * -> *) a. Applicative f => a -> f a
pure (ParsecT Sources MuseState (ReaderT MuseEnv m) Inlines
-> MuseParser m (F Inlines))
-> ParsecT Sources MuseState (ReaderT MuseEnv m) Inlines
-> MuseParser m (F Inlines)
forall a b. (a -> b) -> a -> b
$ Text -> Inlines
B.code (Text -> Inlines)
-> ((Text, Text) -> Text) -> (Text, Text) -> Inlines
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Text -> Text -> Text) -> (Text, Text) -> Text
forall a b c. (a -> b -> c) -> (a, b) -> c
uncurry Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
(<>)
((Text, Text) -> Inlines)
-> ParsecT Sources MuseState (ReaderT MuseEnv m) ()
-> ParsecT
Sources MuseState (ReaderT MuseEnv m) ((Text, Text) -> Inlines)
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ ParsecT Sources MuseState (ReaderT MuseEnv m) ()
forall (m :: * -> *). PandocMonad m => MuseParser m ()
atStart
ParsecT
Sources MuseState (ReaderT MuseEnv m) ((Text, Text) -> Inlines)
-> ParsecT Sources MuseState (ReaderT MuseEnv m) Char
-> ParsecT
Sources MuseState (ReaderT MuseEnv m) ((Text, Text) -> Inlines)
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* Char -> ParsecT Sources MuseState (ReaderT MuseEnv m) Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
Char -> ParsecT s u m Char
char Char
'='
ParsecT
Sources MuseState (ReaderT MuseEnv m) ((Text, Text) -> Inlines)
-> ParsecT Sources MuseState (ReaderT MuseEnv m) ()
-> ParsecT
Sources MuseState (ReaderT MuseEnv m) ((Text, Text) -> Inlines)
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* ParsecT Sources MuseState (ReaderT MuseEnv m) Char
-> ParsecT Sources MuseState (ReaderT MuseEnv m) ()
forall s (m :: * -> *) t a u.
(Stream s m t, Show a) =>
ParsecT s u m a -> ParsecT s u m ()
notFollowedBy (ParsecT Sources MuseState (ReaderT MuseEnv m) Char
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParserT s st m Char
spaceChar ParsecT Sources MuseState (ReaderT MuseEnv m) Char
-> ParsecT Sources MuseState (ReaderT MuseEnv m) Char
-> ParsecT Sources MuseState (ReaderT MuseEnv m) Char
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> ParsecT Sources MuseState (ReaderT MuseEnv m) Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s u m Char
newline)
ParsecT
Sources MuseState (ReaderT MuseEnv m) ((Text, Text) -> Inlines)
-> ParsecT Sources MuseState (ReaderT MuseEnv m) (Text, Text)
-> ParsecT Sources MuseState (ReaderT MuseEnv m) Inlines
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ParsecT Sources MuseState (ReaderT MuseEnv m) Char
-> ParserT Sources MuseState (ReaderT MuseEnv m) Text
-> ParsecT Sources MuseState (ReaderT MuseEnv m) (Text, Text)
forall s u (m :: * -> *) b.
ParserT s u m Char -> ParserT s u m b -> ParserT s u m (Text, b)
manyUntilChar (SourceName -> ParsecT Sources MuseState (ReaderT MuseEnv m) Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
SourceName -> ParsecT s u m Char
noneOf SourceName
"\n\r" ParsecT Sources MuseState (ReaderT MuseEnv m) Char
-> ParsecT Sources MuseState (ReaderT MuseEnv m) Char
-> ParsecT Sources MuseState (ReaderT MuseEnv m) Char
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> (ParsecT Sources MuseState (ReaderT MuseEnv m) Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s u m Char
newline ParsecT Sources MuseState (ReaderT MuseEnv m) Char
-> ParsecT Sources MuseState (ReaderT MuseEnv m) ()
-> ParsecT Sources MuseState (ReaderT MuseEnv m) Char
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* ParsecT Sources MuseState (ReaderT MuseEnv m) Char
-> ParsecT Sources MuseState (ReaderT MuseEnv m) ()
forall s (m :: * -> *) t a u.
(Stream s m t, Show a) =>
ParsecT s u m a -> ParsecT s u m ()
notFollowedBy ParsecT Sources MuseState (ReaderT MuseEnv m) Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s u m Char
newline)) (ParserT Sources MuseState (ReaderT MuseEnv m) Text
-> ParserT Sources MuseState (ReaderT MuseEnv m) Text
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParserT Sources MuseState (ReaderT MuseEnv m) Text
-> ParserT Sources MuseState (ReaderT MuseEnv m) Text)
-> ParserT Sources MuseState (ReaderT MuseEnv m) Text
-> ParserT Sources MuseState (ReaderT MuseEnv m) Text
forall a b. (a -> b) -> a -> b
$ (Char -> Text)
-> ParsecT Sources MuseState (ReaderT MuseEnv m) Char
-> ParserT Sources MuseState (ReaderT MuseEnv m) Text
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Char -> Text
T.singleton (ParsecT Sources MuseState (ReaderT MuseEnv m) Char
-> ParserT Sources MuseState (ReaderT MuseEnv m) Text)
-> ParsecT Sources MuseState (ReaderT MuseEnv m) Char
-> ParserT Sources MuseState (ReaderT MuseEnv m) Text
forall a b. (a -> b) -> a -> b
$ SourceName -> ParsecT Sources MuseState (ReaderT MuseEnv m) Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
SourceName -> ParsecT s u m Char
noneOf SourceName
" \t\n\r=" ParsecT Sources MuseState (ReaderT MuseEnv m) Char
-> ParsecT Sources MuseState (ReaderT MuseEnv m) Char
-> ParsecT Sources MuseState (ReaderT MuseEnv m) Char
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* Char -> ParsecT Sources MuseState (ReaderT MuseEnv m) Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
Char -> ParsecT s u m Char
char Char
'=')
ParsecT Sources MuseState (ReaderT MuseEnv m) Inlines
-> ParsecT Sources MuseState (ReaderT MuseEnv m) ()
-> ParsecT Sources MuseState (ReaderT MuseEnv m) Inlines
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* ParsecT Sources MuseState (ReaderT MuseEnv m) Char
-> ParsecT Sources MuseState (ReaderT MuseEnv m) ()
forall s (m :: * -> *) t a u.
(Stream s m t, Show a) =>
ParsecT s u m a -> ParsecT s u m ()
notFollowedBy ParsecT Sources MuseState (ReaderT MuseEnv m) Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s u m Char
alphaNum
codeTag :: PandocMonad m => MuseParser m (F Inlines)
codeTag :: MuseParser m (F Inlines)
codeTag = (Inlines -> F Inlines)
-> ParsecT Sources MuseState (ReaderT MuseEnv m) Inlines
-> MuseParser m (F Inlines)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Inlines -> F Inlines
forall (f :: * -> *) a. Applicative f => a -> f a
pure (ParsecT Sources MuseState (ReaderT MuseEnv m) Inlines
-> MuseParser m (F Inlines))
-> ParsecT Sources MuseState (ReaderT MuseEnv m) Inlines
-> MuseParser m (F Inlines)
forall a b. (a -> b) -> a -> b
$ Attr -> Text -> Inlines
B.codeWith
(Attr -> Text -> Inlines)
-> ParsecT Sources MuseState (ReaderT MuseEnv m) Attr
-> ParsecT Sources MuseState (ReaderT MuseEnv m) (Text -> Inlines)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ([(Text, Text)] -> Attr
htmlAttrToPandoc ([(Text, Text)] -> Attr)
-> ParsecT Sources MuseState (ReaderT MuseEnv m) [(Text, Text)]
-> ParsecT Sources MuseState (ReaderT MuseEnv m) Attr
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Text
-> ParsecT Sources MuseState (ReaderT MuseEnv m) [(Text, Text)]
forall (m :: * -> *).
PandocMonad m =>
Text -> MuseParser m [(Text, Text)]
openTag Text
"code")
ParsecT Sources MuseState (ReaderT MuseEnv m) (Text -> Inlines)
-> ParsecT Sources MuseState (ReaderT MuseEnv m) Text
-> ParsecT Sources MuseState (ReaderT MuseEnv m) Inlines
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ParserT Sources MuseState (ReaderT MuseEnv m) Char
-> ParserT Sources MuseState (ReaderT MuseEnv m) ()
-> ParsecT Sources MuseState (ReaderT MuseEnv m) Text
forall s (m :: * -> *) t st a.
Stream s m t =>
ParserT s st m Char -> ParserT s st m a -> ParserT s st m Text
manyTillChar ParserT Sources MuseState (ReaderT MuseEnv m) Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s u m Char
anyChar (Text -> ParserT Sources MuseState (ReaderT MuseEnv m) ()
forall (m :: * -> *). PandocMonad m => Text -> MuseParser m ()
closeTag Text
"code")
mathTag :: PandocMonad m => MuseParser m (F Inlines)
mathTag :: MuseParser m (F Inlines)
mathTag = Inlines -> F Inlines
forall (m :: * -> *) a. Monad m => a -> m a
return (Inlines -> F Inlines) -> (Text -> Inlines) -> Text -> F Inlines
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Inlines
B.math
(Text -> F Inlines)
-> ParsecT Sources MuseState (ReaderT MuseEnv m) [(Text, Text)]
-> ParsecT
Sources MuseState (ReaderT MuseEnv m) (Text -> F Inlines)
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ Text
-> ParsecT Sources MuseState (ReaderT MuseEnv m) [(Text, Text)]
forall (m :: * -> *).
PandocMonad m =>
Text -> MuseParser m [(Text, Text)]
openTag Text
"math"
ParsecT Sources MuseState (ReaderT MuseEnv m) (Text -> F Inlines)
-> ParsecT Sources MuseState (ReaderT MuseEnv m) Text
-> MuseParser m (F Inlines)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ParserT Sources MuseState (ReaderT MuseEnv m) Char
-> ParserT Sources MuseState (ReaderT MuseEnv m) ()
-> ParsecT Sources MuseState (ReaderT MuseEnv m) Text
forall s (m :: * -> *) t st a.
Stream s m t =>
ParserT s st m Char -> ParserT s st m a -> ParserT s st m Text
manyTillChar ParserT Sources MuseState (ReaderT MuseEnv m) Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s u m Char
anyChar (Text -> ParserT Sources MuseState (ReaderT MuseEnv m) ()
forall (m :: * -> *). PandocMonad m => Text -> MuseParser m ()
closeTag Text
"math")
inlineLiteralTag :: PandocMonad m => MuseParser m (F Inlines)
inlineLiteralTag :: MuseParser m (F Inlines)
inlineLiteralTag = MuseParser m (F Inlines) -> MuseParser m (F Inlines)
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (MuseParser m (F Inlines) -> MuseParser m (F Inlines))
-> MuseParser m (F Inlines) -> MuseParser m (F Inlines)
forall a b. (a -> b) -> a -> b
$ (Inlines -> F Inlines)
-> ParsecT Sources MuseState (ReaderT MuseEnv m) Inlines
-> MuseParser m (F Inlines)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Inlines -> F Inlines
forall (f :: * -> *) a. Applicative f => a -> f a
pure (ParsecT Sources MuseState (ReaderT MuseEnv m) Inlines
-> MuseParser m (F Inlines))
-> ParsecT Sources MuseState (ReaderT MuseEnv m) Inlines
-> MuseParser m (F Inlines)
forall a b. (a -> b) -> a -> b
$ Text -> Text -> Inlines
B.rawInline
(Text -> Text -> Inlines)
-> ParsecT Sources MuseState (ReaderT MuseEnv m) Text
-> ParsecT Sources MuseState (ReaderT MuseEnv m) (Text -> Inlines)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Text -> Maybe Text -> Text
forall a. a -> Maybe a -> a
fromMaybe Text
"html" (Maybe Text -> Text)
-> ([(Text, Text)] -> Maybe Text) -> [(Text, Text)] -> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> [(Text, Text)] -> Maybe Text
forall a b. Eq a => a -> [(a, b)] -> Maybe b
lookup Text
"style" ([(Text, Text)] -> Text)
-> ParsecT Sources MuseState (ReaderT MuseEnv m) [(Text, Text)]
-> ParsecT Sources MuseState (ReaderT MuseEnv m) Text
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Text
-> ParsecT Sources MuseState (ReaderT MuseEnv m) [(Text, Text)]
forall (m :: * -> *).
PandocMonad m =>
Text -> MuseParser m [(Text, Text)]
openTag Text
"literal")
ParsecT Sources MuseState (ReaderT MuseEnv m) (Text -> Inlines)
-> ParsecT Sources MuseState (ReaderT MuseEnv m) Text
-> ParsecT Sources MuseState (ReaderT MuseEnv m) Inlines
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ParserT Sources MuseState (ReaderT MuseEnv m) Char
-> ParserT Sources MuseState (ReaderT MuseEnv m) ()
-> ParsecT Sources MuseState (ReaderT MuseEnv m) Text
forall s (m :: * -> *) t st a.
Stream s m t =>
ParserT s st m Char -> ParserT s st m a -> ParserT s st m Text
manyTillChar ParserT Sources MuseState (ReaderT MuseEnv m) Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s u m Char
anyChar (Text -> ParserT Sources MuseState (ReaderT MuseEnv m) ()
forall (m :: * -> *). PandocMonad m => Text -> MuseParser m ()
closeTag Text
"literal")
str :: PandocMonad m => MuseParser m (F Inlines)
str :: MuseParser m (F Inlines)
str = Inlines -> F Inlines
forall (m :: * -> *) a. Monad m => a -> m a
return (Inlines -> F Inlines) -> (Text -> Inlines) -> Text -> F Inlines
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Inlines
B.str (Text -> F Inlines)
-> ParsecT Sources MuseState (ReaderT MuseEnv m) Text
-> MuseParser m (F Inlines)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParserT Sources MuseState (ReaderT MuseEnv m) Char
-> ParsecT Sources MuseState (ReaderT MuseEnv m) Text
forall s (m :: * -> *) t st.
Stream s m t =>
ParserT s st m Char -> ParserT s st m Text
many1Char ParserT Sources MuseState (ReaderT MuseEnv m) Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s u m Char
alphaNum MuseParser m (F Inlines)
-> ParsecT Sources MuseState (ReaderT MuseEnv m) ()
-> MuseParser m (F Inlines)
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* ParsecT Sources MuseState (ReaderT MuseEnv m) ()
forall s (m :: * -> *) a st.
(Stream s m a, HasLastStrPosition st) =>
ParserT s st m ()
updateLastStrPos
asterisks :: PandocMonad m => MuseParser m (F Inlines)
asterisks :: MuseParser m (F Inlines)
asterisks = Inlines -> F Inlines
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Inlines -> F Inlines) -> (Text -> Inlines) -> Text -> F Inlines
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Inlines
B.str (Text -> F Inlines)
-> ParsecT Sources MuseState (ReaderT MuseEnv m) Text
-> MuseParser m (F Inlines)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParserT Sources MuseState (ReaderT MuseEnv m) Char
-> ParsecT Sources MuseState (ReaderT MuseEnv m) Text
forall s (m :: * -> *) t st.
Stream s m t =>
ParserT s st m Char -> ParserT s st m Text
many1Char (Char -> ParserT Sources MuseState (ReaderT MuseEnv m) Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
Char -> ParsecT s u m Char
char Char
'*')
symbol :: PandocMonad m => MuseParser m (F Inlines)
symbol :: MuseParser m (F Inlines)
symbol = Inlines -> F Inlines
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Inlines -> F Inlines) -> (Char -> Inlines) -> Char -> F Inlines
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Inlines
B.str (Text -> Inlines) -> (Char -> Text) -> Char -> Inlines
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Char -> Text
T.singleton (Char -> F Inlines)
-> ParsecT Sources MuseState (ReaderT MuseEnv m) Char
-> MuseParser m (F Inlines)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT Sources MuseState (ReaderT MuseEnv m) Char
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParserT s st m Char
nonspaceChar
linkOrImage :: PandocMonad m => MuseParser m (F Inlines)
linkOrImage :: MuseParser m (F Inlines)
linkOrImage = MuseParser m (F Inlines) -> MuseParser m (F Inlines)
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (MuseParser m (F Inlines) -> MuseParser m (F Inlines))
-> MuseParser m (F Inlines) -> MuseParser m (F Inlines)
forall a b. (a -> b) -> a -> b
$ Text -> MuseParser m (F Inlines)
forall (m :: * -> *).
PandocMonad m =>
Text -> MuseParser m (F Inlines)
link Text
"URL:" MuseParser m (F Inlines)
-> MuseParser m (F Inlines) -> MuseParser m (F Inlines)
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> MuseParser m (F Inlines)
forall (m :: * -> *). PandocMonad m => MuseParser m (F Inlines)
image MuseParser m (F Inlines)
-> MuseParser m (F Inlines) -> MuseParser m (F Inlines)
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> Text -> MuseParser m (F Inlines)
forall (m :: * -> *).
PandocMonad m =>
Text -> MuseParser m (F Inlines)
link Text
""
linkContent :: PandocMonad m => MuseParser m (F Inlines)
linkContent :: MuseParser m (F Inlines)
linkContent = F Inlines -> F Inlines
forall s. Future s Inlines -> Future s Inlines
trimInlinesF (F Inlines -> F Inlines)
-> ([F Inlines] -> F Inlines) -> [F Inlines] -> F Inlines
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [F Inlines] -> F Inlines
forall a. Monoid a => [a] -> a
mconcat
([F Inlines] -> F Inlines)
-> ParsecT Sources MuseState (ReaderT MuseEnv m) Char
-> ParsecT
Sources MuseState (ReaderT MuseEnv m) ([F Inlines] -> F Inlines)
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ Char -> ParsecT Sources MuseState (ReaderT MuseEnv m) Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
Char -> ParsecT s u m Char
char Char
'['
ParsecT
Sources MuseState (ReaderT MuseEnv m) ([F Inlines] -> F Inlines)
-> ParsecT Sources MuseState (ReaderT MuseEnv m) [F Inlines]
-> MuseParser m (F Inlines)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> MuseParser m (F Inlines)
-> ParsecT Sources MuseState (ReaderT MuseEnv m) Char
-> ParsecT Sources MuseState (ReaderT MuseEnv m) [F Inlines]
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 MuseParser m (F Inlines)
forall (m :: * -> *). PandocMonad m => MuseParser m (F Inlines)
inline (Char -> ParsecT Sources MuseState (ReaderT MuseEnv m) Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
Char -> ParsecT s u m Char
char Char
']')
link :: PandocMonad m => Text -> MuseParser m (F Inlines)
link :: Text -> MuseParser m (F Inlines)
link Text
prefix = MuseParser m (F Inlines) -> MuseParser m (F Inlines)
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (MuseParser m (F Inlines) -> MuseParser m (F Inlines))
-> MuseParser m (F Inlines) -> MuseParser m (F Inlines)
forall a b. (a -> b) -> a -> b
$ do
Bool
inLink <- (MuseEnv -> Bool)
-> ParsecT Sources MuseState (ReaderT MuseEnv m) Bool
forall r (m :: * -> *) a. MonadReader r m => (r -> a) -> m a
asks MuseEnv -> Bool
museInLink
Bool -> ParsecT Sources MuseState (ReaderT MuseEnv m) ()
forall (f :: * -> *). Alternative f => Bool -> f ()
guard (Bool -> ParsecT Sources MuseState (ReaderT MuseEnv m) ())
-> Bool -> ParsecT Sources MuseState (ReaderT MuseEnv m) ()
forall a b. (a -> b) -> a -> b
$ Bool -> Bool
not Bool
inLink
Text -> ParsecT Sources MuseState (ReaderT MuseEnv m) Text
forall s (m :: * -> *) u.
(Stream s m Char, UpdateSourcePos s Char) =>
Text -> ParsecT s u m Text
textStr (Text -> ParsecT Sources MuseState (ReaderT MuseEnv m) Text)
-> Text -> ParsecT Sources MuseState (ReaderT MuseEnv m) Text
forall a b. (a -> b) -> a -> b
$ Text
"[[" Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
prefix
Text
url <- ParserT Sources MuseState (ReaderT MuseEnv m) Char
-> ParserT Sources MuseState (ReaderT MuseEnv m) Char
-> ParsecT Sources MuseState (ReaderT MuseEnv m) Text
forall s (m :: * -> *) t st a.
Stream s m t =>
ParserT s st m Char -> ParserT s st m a -> ParserT s st m Text
manyTillChar ParserT Sources MuseState (ReaderT MuseEnv m) Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s u m Char
anyChar (ParserT Sources MuseState (ReaderT MuseEnv m) Char
-> ParsecT Sources MuseState (ReaderT MuseEnv m) Text)
-> ParserT Sources MuseState (ReaderT MuseEnv m) Char
-> ParsecT Sources MuseState (ReaderT MuseEnv m) Text
forall a b. (a -> b) -> a -> b
$ Char -> ParserT Sources MuseState (ReaderT MuseEnv m) Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
Char -> ParsecT s u m Char
char Char
']'
F Inlines
content <- F Inlines -> MuseParser m (F Inlines) -> MuseParser m (F Inlines)
forall s (m :: * -> *) t a u.
Stream s m t =>
a -> ParsecT s u m a -> ParsecT s u m a
option (Inlines -> F Inlines
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Inlines -> F Inlines) -> Inlines -> F Inlines
forall a b. (a -> b) -> a -> b
$ Text -> Inlines
B.str Text
url) ((MuseEnv -> MuseEnv)
-> MuseParser m (F Inlines) -> MuseParser m (F Inlines)
forall r (m :: * -> *) a. MonadReader r m => (r -> r) -> m a -> m a
local (\MuseEnv
s -> MuseEnv
s { museInLink :: Bool
museInLink = Bool
True }) MuseParser m (F Inlines)
forall (m :: * -> *). PandocMonad m => MuseParser m (F Inlines)
linkContent)
Char -> ParserT Sources MuseState (ReaderT MuseEnv m) Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
Char -> ParsecT s u m Char
char Char
']'
F Inlines -> MuseParser m (F Inlines)
forall (m :: * -> *) a. Monad m => a -> m a
return (F Inlines -> MuseParser m (F Inlines))
-> F Inlines -> MuseParser m (F Inlines)
forall a b. (a -> b) -> a -> b
$ Text -> Text -> Inlines -> Inlines
B.link Text
url Text
"" (Inlines -> Inlines) -> F Inlines -> F Inlines
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> F Inlines
content
image :: PandocMonad m => MuseParser m (F Inlines)
image :: MuseParser m (F Inlines)
image = MuseParser m (F Inlines) -> MuseParser m (F Inlines)
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (MuseParser m (F Inlines) -> MuseParser m (F Inlines))
-> MuseParser m (F Inlines) -> MuseParser m (F Inlines)
forall a b. (a -> b) -> a -> b
$ do
SourceName
-> ParsecT Sources MuseState (ReaderT MuseEnv m) SourceName
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
SourceName -> ParsecT s u m SourceName
string SourceName
"[["
(Text
url, (Text
ext, Maybe Text
width, Maybe Char
align)) <- ParserT Sources MuseState (ReaderT MuseEnv m) Char
-> ParserT
Sources
MuseState
(ReaderT MuseEnv m)
(Text, Maybe Text, Maybe Char)
-> ParserT
Sources
MuseState
(ReaderT MuseEnv m)
(Text, (Text, Maybe Text, Maybe Char))
forall s u (m :: * -> *) b.
ParserT s u m Char -> ParserT s u m b -> ParserT s u m (Text, b)
manyUntilChar (SourceName -> ParserT Sources MuseState (ReaderT MuseEnv m) Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
SourceName -> ParsecT s u m Char
noneOf SourceName
"]") (ParserT
Sources
MuseState
(ReaderT MuseEnv m)
(Text, Maybe Text, Maybe Char)
forall u.
ParsecT
Sources u (ReaderT MuseEnv m) (Text, Maybe Text, Maybe Char)
imageExtensionAndOptions ParserT
Sources
MuseState
(ReaderT MuseEnv m)
(Text, Maybe Text, Maybe Char)
-> ParserT Sources MuseState (ReaderT MuseEnv m) Char
-> ParserT
Sources
MuseState
(ReaderT MuseEnv m)
(Text, Maybe Text, Maybe Char)
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* Char -> ParserT Sources MuseState (ReaderT MuseEnv m) Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
Char -> ParsecT s u m Char
char Char
']')
F Inlines
content <- F Inlines -> MuseParser m (F Inlines) -> MuseParser m (F Inlines)
forall s (m :: * -> *) t a u.
Stream s m t =>
a -> ParsecT s u m a -> ParsecT s u m a
option F Inlines
forall a. Monoid a => a
mempty MuseParser m (F Inlines)
forall (m :: * -> *). PandocMonad m => MuseParser m (F Inlines)
linkContent
Char -> ParserT Sources MuseState (ReaderT MuseEnv m) Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
Char -> ParsecT s u m Char
char Char
']'
let widthAttr :: [(Text, Text)]
widthAttr = case Maybe Char
align of
Just Char
'f' -> [(Text
"width", Text -> Maybe Text -> Text
forall a. a -> Maybe a -> a
fromMaybe Text
"100" Maybe Text
width Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"%"), (Text
"height", Text
"75%")]
Maybe Char
_ -> Maybe (Text, Text) -> [(Text, Text)]
forall a. Maybe a -> [a]
maybeToList ((Text
"width",) (Text -> (Text, Text)) -> (Text -> Text) -> Text -> (Text, Text)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"%") (Text -> (Text, Text)) -> Maybe Text -> Maybe (Text, Text)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe Text
width)
let alignClass :: [Text]
alignClass = case Maybe Char
align of
Just Char
'r' -> [Text
"align-right"]
Just Char
'l' -> [Text
"align-left"]
Just Char
'f' -> []
Maybe Char
_ -> []
F Inlines -> MuseParser m (F Inlines)
forall (m :: * -> *) a. Monad m => a -> m a
return (F Inlines -> MuseParser m (F Inlines))
-> F Inlines -> MuseParser m (F Inlines)
forall a b. (a -> b) -> a -> b
$ Attr -> Text -> Text -> Inlines -> Inlines
B.imageWith (Text
"", [Text]
alignClass, [(Text, Text)]
widthAttr) (Text
url Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
ext) Text
forall a. Monoid a => a
mempty (Inlines -> Inlines) -> F Inlines -> F Inlines
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> F Inlines
content
where
imageExtensions :: [Text]
imageExtensions = [Text
".eps", Text
".gif", Text
".jpg", Text
".jpeg", Text
".pbm", Text
".png", Text
".tiff", Text
".xbm", Text
".xpm"]
imageExtension :: ParsecT Sources u (ReaderT MuseEnv m) Text
imageExtension = [ParsecT Sources u (ReaderT MuseEnv m) Text]
-> ParsecT Sources u (ReaderT MuseEnv m) Text
forall s (m :: * -> *) t u a.
Stream s m t =>
[ParsecT s u m a] -> ParsecT s u m a
choice (ParsecT Sources u (ReaderT MuseEnv m) Text
-> ParsecT Sources u (ReaderT MuseEnv m) Text
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT Sources u (ReaderT MuseEnv m) Text
-> ParsecT Sources u (ReaderT MuseEnv m) Text)
-> (Text -> ParsecT Sources u (ReaderT MuseEnv m) Text)
-> Text
-> ParsecT Sources u (ReaderT MuseEnv m) Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> ParsecT Sources u (ReaderT MuseEnv m) Text
forall s (m :: * -> *) u.
(Stream s m Char, UpdateSourcePos s Char) =>
Text -> ParsecT s u m Text
textStr (Text -> ParsecT Sources u (ReaderT MuseEnv m) Text)
-> [Text] -> [ParsecT Sources u (ReaderT MuseEnv m) Text]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [Text]
imageExtensions)
imageExtensionAndOptions :: ParsecT
Sources u (ReaderT MuseEnv m) (Text, Maybe Text, Maybe Char)
imageExtensionAndOptions = do
Text
ext <- ParsecT Sources u (ReaderT MuseEnv m) Text
forall u. ParsecT Sources u (ReaderT MuseEnv m) Text
imageExtension
(Maybe Text
width, Maybe Char
align) <- (Maybe Text, Maybe Char)
-> ParsecT Sources u (ReaderT MuseEnv m) (Maybe Text, Maybe Char)
-> ParsecT Sources u (ReaderT MuseEnv m) (Maybe Text, Maybe Char)
forall s (m :: * -> *) t a u.
Stream s m t =>
a -> ParsecT s u m a -> ParsecT s u m a
option (Maybe Text
forall a. Maybe a
Nothing, Maybe Char
forall a. Maybe a
Nothing) ParsecT Sources u (ReaderT MuseEnv m) (Maybe Text, Maybe Char)
forall u.
ParsecT Sources u (ReaderT MuseEnv m) (Maybe Text, Maybe Char)
imageAttrs
(Text, Maybe Text, Maybe Char)
-> ParsecT
Sources u (ReaderT MuseEnv m) (Text, Maybe Text, Maybe Char)
forall (m :: * -> *) a. Monad m => a -> m a
return (Text
ext, Maybe Text
width, Maybe Char
align)
imageAttrs :: ParsecT Sources u (ReaderT MuseEnv m) (Maybe Text, Maybe Char)
imageAttrs = (,)
(Maybe Text -> Maybe Char -> (Maybe Text, Maybe Char))
-> ParsecT Sources u (ReaderT MuseEnv m) SourceName
-> ParsecT
Sources
u
(ReaderT MuseEnv m)
(Maybe Text -> Maybe Char -> (Maybe Text, Maybe Char))
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ ParsecT Sources u (ReaderT MuseEnv m) Char
-> ParsecT Sources u (ReaderT MuseEnv 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 u (ReaderT MuseEnv m) Char
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParserT s st m Char
spaceChar
ParsecT
Sources
u
(ReaderT MuseEnv m)
(Maybe Text -> Maybe Char -> (Maybe Text, Maybe Char))
-> ParsecT Sources u (ReaderT MuseEnv m) (Maybe Text)
-> ParsecT
Sources
u
(ReaderT MuseEnv m)
(Maybe Char -> (Maybe Text, Maybe Char))
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ParsecT Sources u (ReaderT MuseEnv m) Text
-> ParsecT Sources u (ReaderT MuseEnv m) (Maybe Text)
forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m (Maybe a)
optionMaybe (ParsecT Sources u (ReaderT MuseEnv m) Char
-> ParsecT Sources u (ReaderT MuseEnv m) Text
forall s (m :: * -> *) t st.
Stream s m t =>
ParserT s st m Char -> ParserT s st m Text
many1Char ParsecT Sources u (ReaderT MuseEnv m) Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s u m Char
digit)
ParsecT
Sources
u
(ReaderT MuseEnv m)
(Maybe Char -> (Maybe Text, Maybe Char))
-> ParsecT Sources u (ReaderT MuseEnv m) SourceName
-> ParsecT
Sources
u
(ReaderT MuseEnv m)
(Maybe Char -> (Maybe Text, Maybe Char))
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* ParsecT Sources u (ReaderT MuseEnv m) Char
-> ParsecT Sources u (ReaderT MuseEnv m) SourceName
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
many ParsecT Sources u (ReaderT MuseEnv m) Char
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParserT s st m Char
spaceChar
ParsecT
Sources
u
(ReaderT MuseEnv m)
(Maybe Char -> (Maybe Text, Maybe Char))
-> ParsecT Sources u (ReaderT MuseEnv m) (Maybe Char)
-> ParsecT Sources u (ReaderT MuseEnv m) (Maybe Text, Maybe Char)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ParsecT Sources u (ReaderT MuseEnv m) Char
-> ParsecT Sources u (ReaderT MuseEnv m) (Maybe Char)
forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m (Maybe a)
optionMaybe (SourceName -> ParsecT Sources u (ReaderT MuseEnv m) Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
SourceName -> ParsecT s u m Char
oneOf SourceName
"rlf")