mirror of
https://github.com/jgm/pandoc.git
synced 2026-09-19 02:22:09 +08:00
Muse reader: parse directives without parseFromString
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user