diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Text/Pandoc/Readers/Muse.hs | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/Text/Pandoc/Readers/Muse.hs b/src/Text/Pandoc/Readers/Muse.hs index d985f5cf8..f24ad9274 100644 --- a/src/Text/Pandoc/Readers/Muse.hs +++ b/src/Text/Pandoc/Readers/Muse.hs @@ -130,8 +130,7 @@ instance HasLogMessages MuseState where parseMuse :: PandocMonad m => MuseParser m Pandoc parseMuse = do many directive - blocks <- mconcat <$> many parseBlock - eof + blocks <- parseBlocks st <- getState let doc = runF (do Pandoc _ bs <- B.doc <$> blocks meta <- museMeta st @@ -250,6 +249,19 @@ directive = do -- block parsers -- +parseBlocks :: PandocMonad m + => MuseParser m (F Blocks) +parseBlocks = + try (mempty <$ eof) <|> + try blockStart <|> + try paraStart + where + blockStart = do first <- blockElements + rest <- parseBlocks + return $ first B.<> rest + paraStart = do (first, rest) <- paraUntil ((mempty <$ eof) <|> (blankline >> blockStart)) + return $ first B.<> rest + parseBlock :: PandocMonad m => MuseParser m (F Blocks) parseBlock = do res <- blockElements <|> para |