Muse reader: count only one space as part of list item marker

This commit is contained in:
Alexander Krotov 2017-11-19 04:26:45 +03:00
parent 163af3fdee
commit 82bcda80c6
2 changed files with 38 additions and 24 deletions

View file

@ -392,8 +392,8 @@ listStart marker = try $ do
st <- stateParserContext <$> getState st <- stateParserContext <$> getState
getPosition >>= \pos -> guard (st == ListItemState || sourceColumn pos /= 1) getPosition >>= \pos -> guard (st == ListItemState || sourceColumn pos /= 1)
markerLength <- marker markerLength <- marker
postWhitespace <- length <$> many1 spaceChar many1 spaceChar
return $ preWhitespace + markerLength + postWhitespace return $ preWhitespace + markerLength + 1
listItemContents :: PandocMonad m => Int -> MuseParser m (F Blocks) listItemContents :: PandocMonad m => Int -> MuseParser m (F Blocks)
listItemContents markerLength = do listItemContents markerLength = do

View file

@ -527,28 +527,42 @@ tests =
orderedListWith (1, Decimal, Period) [ para "Item1" orderedListWith (1, Decimal, Period) [ para "Item1"
, para "Item2" , para "Item2"
] ]
, "Nested list" =: , testGroup "Nested lists"
T.unlines [ "Nested list" =:
[ " - Item1" T.unlines
, " - Item2" [ " - Item1"
, " - Item3" , " - Item2"
, " - Item4" , " - Item3"
, " 1. Nested" , " - Item4"
, " 2. Ordered" , " 1. Nested"
, " 3. List" , " 2. Ordered"
] =?> , " 3. List"
bulletList [ mconcat [ para "Item1" ] =?>
, bulletList [ para "Item2" bulletList [ mconcat [ para "Item1"
, para "Item3" , bulletList [ para "Item2"
] , para "Item3"
] ]
, mconcat [ para "Item4" ]
, orderedListWith (1, Decimal, Period) [ para "Nested" , mconcat [ para "Item4"
, para "Ordered" , orderedListWith (1, Decimal, Period) [ para "Nested"
, para "List" , para "Ordered"
] , para "List"
] ]
] ]
]
, "Incorrectly indented Text::Amuse nested list" =:
T.unlines
[ " - First item"
, " - Not nested item"
] =?>
bulletList [ para "First item", para "Not nested item"]
, "Text::Amuse includes only one space in list marker" =:
T.unlines
[ " - First item"
, " - Nested item"
] =?>
bulletList [ para "First item" <> bulletList [ para "Nested item"]]
]
, "List continuation" =: , "List continuation" =:
T.unlines T.unlines
[ " - a" [ " - a"