From ba05e1ea02d5227796f12dea2404285300021de6 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Sat, 23 Feb 2019 15:40:06 -0700 Subject: Shared.compactify: Avoid mixed lists. This improves on the original fix to #5285 by preventing other mixed lists (lists with a mix of Plain and Para elements) that were allowed given the original fix. --- src/Text/Pandoc/Shared.hs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/Text/Pandoc/Shared.hs b/src/Text/Pandoc/Shared.hs index a945c9355..db00d5aa4 100644 --- a/src/Text/Pandoc/Shared.hs +++ b/src/Text/Pandoc/Shared.hs @@ -424,13 +424,12 @@ compactify [] = [] compactify items = let (others, final) = (init items, last items) in case reverse (B.toList final) of - (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)] - -- if other Paras, it's a loose list, change - -- all Plain to Para - _ -> map (fmap plainToPara) items - _ -> items + (Para a:xs) + | null [Para x | Para x <- (xs ++ concatMap B.toList others)] + -> others ++ [B.fromList (reverse (Plain a : xs))] + _ | null [Para x | Para x <- concatMap B.toList items] + -> items + _ -> map (fmap plainToPara) items plainToPara :: Block -> Block plainToPara (Plain ils) = Para ils -- cgit v1.2.3