aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Krotov <ilabdsf@gmail.com>2017-11-22 18:49:07 +0300
committerAlexander Krotov <ilabdsf@gmail.com>2017-11-22 18:49:07 +0300
commit75e2a1104cda760a939ca12258c0355844f70a31 (patch)
treee63e5d943ffd61e7f8b65fbb6acc6c1a3e29e304
parent0b63ac2db1924e487aa83c6b2683b16e64a4d566 (diff)
downloadpandoc-75e2a1104cda760a939ca12258c0355844f70a31.tar.gz
Muse reader: allow list items to be empty
-rw-r--r--src/Text/Pandoc/Readers/Muse.hs4
-rw-r--r--test/Tests/Readers/Muse.hs21
2 files changed, 23 insertions, 2 deletions
diff --git a/src/Text/Pandoc/Readers/Muse.hs b/src/Text/Pandoc/Readers/Muse.hs
index c0f8bfa01..11fea5fde 100644
--- a/src/Text/Pandoc/Readers/Muse.hs
+++ b/src/Text/Pandoc/Readers/Muse.hs
@@ -412,7 +412,7 @@ listStart marker = try $ do
st <- stateParserContext <$> getState
getPosition >>= \pos -> guard (st == ListItemState || sourceColumn pos /= 1)
markerLength <- marker
- many1 spaceChar
+ void (many1 spaceChar) <|> eol
return $ preWhitespace + markerLength + 1
listItemContents :: PandocMonad m => Int -> MuseParser m (F Blocks)
@@ -448,7 +448,7 @@ orderedListStart style delim = listStart (snd <$> withHorizDisplacement (ordered
orderedList :: PandocMonad m => MuseParser m (F Blocks)
orderedList = try $ do
- p@(_, style, delim) <- lookAhead (many spaceChar *> anyOrderedListMarker <* spaceChar)
+ p@(_, style, delim) <- lookAhead (many spaceChar *> anyOrderedListMarker <* (eol <|> void spaceChar))
guard $ style `elem` [Decimal, LowerAlpha, UpperAlpha, LowerRoman, UpperRoman]
guard $ delim == Period
items <- sequence <$> many1 (listItem $ orderedListStart style delim)
diff --git a/test/Tests/Readers/Muse.hs b/test/Tests/Readers/Muse.hs
index fe75135f7..65665c1d2 100644
--- a/test/Tests/Readers/Muse.hs
+++ b/test/Tests/Readers/Muse.hs
@@ -566,6 +566,27 @@ tests =
, para "Item2"
, para "Item3"
]
+ , "Bullet list with empty items" =:
+ T.unlines
+ [ " -"
+ , ""
+ , " - Item2"
+ ] =?>
+ bulletList [ mempty
+ , para "Item2"
+ ]
+ , "Ordered list with empty items" =:
+ T.unlines
+ [ " 1."
+ , ""
+ , " 2."
+ , ""
+ , " 3. Item3"
+ ] =?>
+ orderedListWith (1, Decimal, Period) [ mempty
+ , mempty
+ , para "Item3"
+ ]
, testGroup "Nested lists"
[ "Nested list" =:
T.unlines