Muse reader: allow list items to be empty

This commit is contained in:
Alexander Krotov 2017-11-22 18:49:07 +03:00
parent 0b63ac2db1
commit 75e2a1104c
2 changed files with 23 additions and 2 deletions

View file

@ -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)

View file

@ -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