aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc
diff options
context:
space:
mode:
authorAlexander Krotov <ilabdsf@gmail.com>2018-02-13 14:13:00 +0300
committerAlexander Krotov <ilabdsf@gmail.com>2018-02-13 14:14:43 +0300
commit5a304360d0c871e95cbc4c61a5d5127ebbe99651 (patch)
tree5c2eaff59e4e50ffe8ffc0453b716e2727067111 /src/Text/Pandoc
parent8aed3652c2cb1811aa5685bbeb7c97b097b2eed4 (diff)
downloadpandoc-5a304360d0c871e95cbc4c61a5d5127ebbe99651.tar.gz
Muse reader: parse next list item before parsing more item contents
Diffstat (limited to 'src/Text/Pandoc')
-rw-r--r--src/Text/Pandoc/Readers/Muse.hs17
1 files changed, 10 insertions, 7 deletions
diff --git a/src/Text/Pandoc/Readers/Muse.hs b/src/Text/Pandoc/Readers/Muse.hs
index c8ebe1883..18d4104ff 100644
--- a/src/Text/Pandoc/Readers/Muse.hs
+++ b/src/Text/Pandoc/Readers/Muse.hs
@@ -305,26 +305,29 @@ parseBlocksTill end =
listItemContentsUntil :: PandocMonad m
=> Int
-> MuseParser m a
+ -> MuseParser m a
-> MuseParser m (F Blocks, a)
-listItemContentsUntil col end =
+listItemContentsUntil col pre end =
try blockStart <|>
try listStart <|>
try paraStart
where
+ parsePre = do e <- pre
+ return (mempty, e)
parseEnd = do e <- end
return (mempty, e)
paraStart = do
- (first, e) <- paraUntil ((Right <$> continuation) <|> (Left <$> end))
+ (first, e) <- paraUntil ((Left <$> pre) <|> (Right <$> continuation) <|> (Left <$> end))
case e of
Left ee -> return (first, ee)
Right (rest, ee) -> return (first B.<> rest, ee)
blockStart = do first <- blockElements
- (rest, e) <- continuation <|> parseEnd
+ (rest, e) <- parsePre <|> continuation <|> parseEnd
return (first B.<> rest, e)
listStart = do
st <- getState
setState $ st{ museInPara = False }
- (first, e) <- anyListUntil ((Right <$> continuation) <|> (Left <$> end))
+ (first, e) <- anyListUntil ((Left <$> pre) <|> (Right <$> continuation) <|> (Left <$> end))
case e of
Left ee -> return (first, ee)
Right (rest, ee) -> return $ (first B.<> rest, ee)
@@ -333,7 +336,7 @@ listItemContentsUntil col end =
indentWith col
st <- getState
setState $ st{ museInPara = museInPara st && isNothing blank }
- listItemContentsUntil col end
+ listItemContentsUntil col pre end
parseBlock :: PandocMonad m => MuseParser m (F Blocks)
parseBlock = do
@@ -554,7 +557,7 @@ bulletListItemsUntil indent end = try $ do
void spaceChar <|> lookAhead eol
st <- getState
setState $ st{ museInPara = False }
- (x, e) <- listItemContentsUntil (indent + 2) ((Right <$> try (optional blankline >> indentWith indent >> bulletListItemsUntil indent end)) <|> (Left <$> end))
+ (x, e) <- listItemContentsUntil (indent + 2) (Right <$> try (optional blankline >> indentWith indent >> bulletListItemsUntil indent end)) (Left <$> end)
case e of
Left ee -> return ([x], ee)
Right (xs, ee) -> return (x:xs, ee)
@@ -610,7 +613,7 @@ orderedListItemsUntil indent style end =
void spaceChar <|> lookAhead eol
st <- getState
setState $ st{ museInPara = False }
- (x, e) <- listItemContentsUntil (sourceColumn pos) ((Right <$> try (optionMaybe blankline >> indentWith indent >> museOrderedListMarker style >> continuation)) <|> (Left <$> end))
+ (x, e) <- listItemContentsUntil (sourceColumn pos) (Right <$> try (optionMaybe blankline >> indentWith indent >> museOrderedListMarker style >> continuation)) (Left <$> end)
case e of
Left ee -> return ([x], ee)
Right (xs, ee) -> return (x:xs, ee)