aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Shared.hs
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2019-02-23 15:40:06 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2019-02-25 17:33:54 -0800
commitba05e1ea02d5227796f12dea2404285300021de6 (patch)
tree6ee0d7372dcfcd55c67c52b590b32cb1c12701f0 /src/Text/Pandoc/Shared.hs
parent38c028bd50fc3781e69370864f163f8d33fd481f (diff)
downloadpandoc-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/Shared.hs')
-rw-r--r--src/Text/Pandoc/Shared.hs13
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