aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc
diff options
context:
space:
mode:
authorAlexander Krotov <ilabdsf@gmail.com>2018-01-19 16:05:14 +0300
committerAlexander Krotov <ilabdsf@gmail.com>2018-01-20 02:14:27 +0300
commit22b69b557ecd9a86caa8628b9a395bdd86b55035 (patch)
tree84e8895d1e6be61da9cd181fef6b1f2ae9c91214 /src/Text/Pandoc
parent62c395dafa467ea760cdc938993ef61379e07ace (diff)
downloadpandoc-22b69b557ecd9a86caa8628b9a395bdd86b55035.tar.gz
Muse reader: fix parsing of nested definition lists
Diffstat (limited to 'src/Text/Pandoc')
-rw-r--r--src/Text/Pandoc/Readers/Muse.hs21
1 files changed, 10 insertions, 11 deletions
diff --git a/src/Text/Pandoc/Readers/Muse.hs b/src/Text/Pandoc/Readers/Muse.hs
index 074f1e65a..4c6d1278e 100644
--- a/src/Text/Pandoc/Readers/Muse.hs
+++ b/src/Text/Pandoc/Readers/Muse.hs
@@ -467,26 +467,25 @@ orderedList = try $ do
rest <- many $ listItem (col - 1) (void (orderedListMarker style delim))
return $ B.orderedListWith p <$> sequence (first : rest)
-definitionListItem :: PandocMonad m => MuseParser m (F (Inlines, [Blocks]))
-definitionListItem = try $ do
- many spaceChar
+definitionListItem :: PandocMonad m => Int -> MuseParser m (F (Inlines, [Blocks]))
+definitionListItem n = try $ do
+ count n spaceChar
pos <- getPosition
- (guardDisabled Ext_amuse) <|> (guard (sourceColumn pos /= 1)) -- Initial space is required by Amusewiki, but not Emacs Muse
term <- trimInlinesF . mconcat <$> manyTill (choice inlineList) (string "::")
void spaceChar <|> lookAhead eol
contents <- listItemContents' $ sourceColumn pos
- optionMaybe blankline
pure $ do lineContent' <- contents
term' <- term
pure (term', [lineContent'])
-definitionListItems :: PandocMonad m => MuseParser m (F [(Inlines, [Blocks])])
-definitionListItems = sequence <$> many1 definitionListItem
-
definitionList :: PandocMonad m => MuseParser m (F Blocks)
-definitionList = do
- items <- definitionListItems
- return $ B.definitionList <$> items
+definitionList = try $ do
+ many spaceChar
+ pos <- getPosition
+ (guardDisabled Ext_amuse) <|> (guard (sourceColumn pos /= 1)) -- Initial space is required by Amusewiki, but not Emacs Muse
+ first <- definitionListItem 0
+ rest <- many $ try (optionMaybe blankline >> definitionListItem (sourceColumn pos - 1))
+ return $ B.definitionList <$> sequence (first : rest)
--
-- tables