Muse reader: allow list items to be empty
This commit is contained in:
parent
0b63ac2db1
commit
75e2a1104c
2 changed files with 23 additions and 2 deletions
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue