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