From 4bfab8f04c105f111d8d4e1c3ed7f7b5c75dbd19 Mon Sep 17 00:00:00 2001 From: Alexander Krotov Date: Sun, 28 Jan 2018 06:31:33 +0300 Subject: Muse reader: parse directives without parseFromString --- src/Text/Pandoc/Readers/Muse.hs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'src/Text/Pandoc/Readers') diff --git a/src/Text/Pandoc/Readers/Muse.hs b/src/Text/Pandoc/Readers/Muse.hs index f4aca92d0..995a3ae9e 100644 --- a/src/Text/Pandoc/Readers/Muse.hs +++ b/src/Text/Pandoc/Readers/Muse.hs @@ -157,16 +157,14 @@ parseEmacsDirective = do parseAmuseDirective :: PandocMonad m => MuseParser m (String, F Inlines) parseAmuseDirective = do key <- parseDirectiveKey - space - spaces - first <- manyTill anyChar eol - rest <- manyTill anyLine endOfDirective + many1 spaceChar + value <- trimInlinesF . mconcat <$> many1Till inline endOfDirective many blankline - value <- parseFromString (trimInlinesF . mconcat <$> many inline) $ unlines (first : rest) return (key, value) where - endOfDirective = lookAhead $ endOfInput <|> try (void blankline) <|> try (void parseDirectiveKey) - endOfInput = try $ skipMany blankline >> skipSpaces >> eof + endOfDirective = lookAhead $ try (eof <|> + void (newline >> blankline) <|> + void (newline >> parseDirectiveKey)) directive :: PandocMonad m => MuseParser m () directive = do -- cgit v1.2.3