Improve tight/loose list handling.
Closes #5285. Previously the algorithm allowed list items with a mix of Para and Plain, which is never wanted. compactify in T.P.Shared has been modified so that, if a list's items contain (at the top level) Para elements (aside from perhaps at the very end), ALL Plains are converted to Paras.
This commit is contained in:
parent
5c8e12b64b
commit
47537d26db
2 changed files with 24 additions and 2 deletions
|
@ -416,7 +416,8 @@ capitalize = walk go
|
|||
go x = x
|
||||
|
||||
-- | Change final list item from @Para@ to @Plain@ if the list contains
|
||||
-- no other @Para@ blocks.
|
||||
-- no other @Para@ blocks. Otherwise (if the list items contain @Para@
|
||||
-- blocks besides possibly at the end), turn any @Plain@s into @Para@s (#5285).
|
||||
compactify :: [Blocks] -- ^ List of list items (each a list of blocks)
|
||||
-> [Blocks]
|
||||
compactify [] = []
|
||||
|
@ -426,9 +427,15 @@ compactify items =
|
|||
(Para a:xs) -> case [Para x | Para x <- concatMap B.toList items] of
|
||||
-- if this is only Para, change to Plain
|
||||
[_] -> others ++ [B.fromList (reverse $ Plain a : xs)]
|
||||
_ -> items
|
||||
-- if other Paras, it's a loose list, change
|
||||
-- all Plain to Para
|
||||
_ -> map (fmap plainToPara) items
|
||||
_ -> items
|
||||
|
||||
plainToPara :: Block -> Block
|
||||
plainToPara (Plain ils) = Para ils
|
||||
plainToPara x = x
|
||||
|
||||
-- | Like @compactify@, but acts on items of definition lists.
|
||||
compactifyDL :: [(Inlines, [Blocks])] -> [(Inlines, [Blocks])]
|
||||
compactifyDL items =
|
||||
|
|
15
test/command/5285.md
Normal file
15
test/command/5285.md
Normal file
|
@ -0,0 +1,15 @@
|
|||
```
|
||||
% pandoc -t native
|
||||
- a
|
||||
|
||||
b
|
||||
- a
|
||||
|
||||
- b
|
||||
^D
|
||||
[BulletList
|
||||
[[Para [Str "a"]
|
||||
,Para [Str "b"]]
|
||||
,[Para [Str "a"]]
|
||||
,[Para [Str "b"]]]]
|
||||
```
|
Loading…
Add table
Reference in a new issue