diff options
author | John MacFarlane <jgm@berkeley.edu> | 2019-02-23 15:40:06 -0700 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2019-02-25 17:33:54 -0800 |
commit | ba05e1ea02d5227796f12dea2404285300021de6 (patch) | |
tree | 6ee0d7372dcfcd55c67c52b590b32cb1c12701f0 /src/Text/Pandoc | |
parent | 38c028bd50fc3781e69370864f163f8d33fd481f (diff) | |
download | pandoc-ba05e1ea02d5227796f12dea2404285300021de6.tar.gz |
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.
Diffstat (limited to 'src/Text/Pandoc')
-rw-r--r-- | src/Text/Pandoc/Shared.hs | 13 |
1 files changed, 6 insertions, 7 deletions
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 |