diff options
| author | John MacFarlane <jgm@berkeley.edu> | 2019-02-08 23:16:01 -0800 | 
|---|---|---|
| committer | John MacFarlane <jgm@berkeley.edu> | 2019-02-08 23:16:01 -0800 | 
| commit | 47537d26db29b9dd0810d039933497d4db4ed813 (patch) | |
| tree | a0b5cc5d3cf728eb5a40e8ad716bf48165dcec89 /src/Text | |
| parent | 5c8e12b64bc51542a208b11fb15fa1916bba5a42 (diff) | |
| download | pandoc-47537d26db29b9dd0810d039933497d4db4ed813.tar.gz | |
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.
Diffstat (limited to 'src/Text')
| -rw-r--r-- | src/Text/Pandoc/Shared.hs | 11 | 
1 files changed, 9 insertions, 2 deletions
| diff --git a/src/Text/Pandoc/Shared.hs b/src/Text/Pandoc/Shared.hs index b1ae9eeed..a945c9355 100644 --- a/src/Text/Pandoc/Shared.hs +++ b/src/Text/Pandoc/Shared.hs @@ -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 = | 
