@@ -856,29 +856,25 @@ normalizeSpaces list =
856856 else lst
857857 in removeLeading $ removeTrailing $ removeDoubles list
858858
859−-- | Change final list item from @Para@ to @Plain@ if the list should
860−-- be compact.
859+-- | Change final list item from @Para@ to @Plain@ if the list contains
860+-- no other @Para@ blocks.
861861compactify :: [[Block]] -- ^ List of list items (each a list of blocks)
862862 -> [[Block]]
863863compactify [] = []
864864compactify items =
865− let final = last items
866− others = init items
867− in case last final of
868− Para a -> if all endsWithPlain others && not (null final)
869− then others ++ [init final ++ [Plain a]]
870− else items
871− _ -> items
872−
873−endsWithPlain :: [Block] -> Bool
874−endsWithPlain [] = False
875−endsWithPlain blocks =
876− case last blocks of
877− Plain _ -> True
878− (BulletList (x:xs)) -> endsWithPlain $ last (x:xs)
879− (OrderedList _ (x:xs)) -> endsWithPlain $ last (x:xs)
880− (DefinitionList (x:xs)) -> endsWithPlain $ last $ map snd (x:xs)
881− _ -> False
865+ case (init items, last items) of
866+ (_,[]) -> items
867+ (others, final) ->
868+ case last final of
869+ Para a -> case (filter isPara $ concat items) of
870+ -- if this is only Para, change to Plain
871+ [_] -> others ++ [init final ++ [Plain a]]
872+ _ -> items
873+ _ -> items
874+
875+isPara :: Block -> Bool
876+isPara (Para _) = True
877+isPara _ = False
882878
883879-- | Data structure for defining hierarchical Pandoc documents
884880data Element = Blk Block