summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlexander Krotov <ilabdsf@gmail.com>2018-02-13 08:55:30 +0300
committerAlexander Krotov <ilabdsf@gmail.com>2018-02-13 14:34:45 +0300
commit42e39fbd2678fb8480b6253232ffe0258d2bae00 (patch)
treea88f4ed8823e5b86b7869222175f7ea02eb8036f /src
parent5a304360d0c871e95cbc4c61a5d5127ebbe99651 (diff)
Muse reader: parse definition lists with multiple descriptions
Diffstat (limited to 'src')
-rw-r--r--src/Text/Pandoc/Readers/Muse.hs39
1 files changed, 25 insertions, 14 deletions
diff --git a/src/Text/Pandoc/Readers/Muse.hs b/src/Text/Pandoc/Readers/Muse.hs
index 18d4104ff..7ac33fe69 100644
--- a/src/Text/Pandoc/Readers/Muse.hs
+++ b/src/Text/Pandoc/Readers/Muse.hs
@@ -631,26 +631,37 @@ orderedListUntil end = try $ do
(items, e) <- orderedListItemsUntil indent style end
return $ (B.orderedListWith p <$> sequence items, e)
+descriptionsUntil :: PandocMonad m
+ => Int
+ -> MuseParser m a
+ -> MuseParser m ([F Blocks], a)
+descriptionsUntil indent end = do
+ void spaceChar <|> lookAhead eol
+ st <- getState
+ setState $ st{ museInPara = False }
+ (x, e) <- listItemContentsUntil indent (Right <$> try (optional blankline >> indentWith indent >> manyTill spaceChar (string "::") >> descriptionsUntil indent end)) (Left <$> end)
+ case e of
+ Right (xs, ee) -> return (x:xs, ee)
+ Left ee -> return ([x], ee)
+
definitionListItemsUntil :: PandocMonad m
=> Int
-> MuseParser m a
-> MuseParser m ([F (Inlines, [Blocks])], a)
definitionListItemsUntil indent end =
continuation
- where continuation = try $ do
- pos <- getPosition
- term <- trimInlinesF . mconcat <$> manyTill (choice inlineList) (string "::")
- void spaceChar <|> lookAhead eol
- st <- getState
- setState $ st{ museInPara = False }
- (x, e) <- listItemContentsUntil (sourceColumn pos) ((Right <$> try (optional blankline >> count indent spaceChar >> continuation)) <|> (Left <$> end))
- let xx = do
- term' <- term
- x' <- x
- (return (term', [x']))::(F (Inlines, [Blocks]))
- case e of
- Left ee -> return $ ([xx], ee)
- Right (xs, ee) -> return $ (xx : xs, ee)
+ where
+ continuation = try $ do
+ pos <- getPosition
+ term <- trimInlinesF . mconcat <$> manyTill (choice inlineList) (string "::")
+ (x, e) <- descriptionsUntil (sourceColumn pos) ((Right <$> try (optional blankline >> indentWith indent >> continuation)) <|> (Left <$> end))
+ let xx = do
+ term' <- term
+ x' <- sequence x
+ return (term', x')
+ case e of
+ Left ee -> return ([xx], ee)
+ Right (xs, ee) -> return (xx:xs, ee)
definitionListUntil :: PandocMonad m
=> MuseParser m a