git.iko.soy/typeable/pandoc
on master help sign in
Simplify compactDL.
92ffd37John MacFarlane
src/Text/Pandoc/Shared.hs+11−13
@@ -464,22 +464,20 @@ plainToPara :: Block -> Block
464plainToPara (Plain ils) = Para ils
464plainToPara (Plain ils) = Para ils
465plainToPara x = x
465plainToPara x = x
466
466
467+
467-- | Like @compactify@, but acts on items of definition lists.
468-- | Like @compactify@, but acts on items of definition lists.
468compactifyDL :: [(Inlines, [Blocks])] -> [(Inlines, [Blocks])]
469compactifyDL :: [(Inlines, [Blocks])] -> [(Inlines, [Blocks])]
469compactifyDL items =
470compactifyDL items =
470− let defs = concatMap snd items
471+ case reverse items of
472+ ((t,ds):ys) ->
471− in case reverse (concatMap B.toList defs) of
473+ case reverse (map (reverse . B.toList) ds) of
472− (Para x:xs)
473− | not (any isPara xs) ->
474+ ((Para x:xs) : zs) | not (any isPara xs) ->
474− let (t,ds) = last items
475+ reverse ys ++
475− lastDef = B.toList $ last ds
476+ [(t, reverse (map B.fromList zs) ++
476− ds' = init ds ++
477+ [B.fromList (reverse (Plain x:xs))])]
477− if null lastDef
478− then [B.fromList lastDef]
479− else [B.fromList $ init lastDef ++ [Plain x]]
480− in init items ++ [(t, ds')]
481− | otherwise -> items
478+ _ -> items
482− _ -> items
479+ _ -> items
480+
483
481
484-- | Combine a list of lines by adding hard linebreaks.
482-- | Combine a list of lines by adding hard linebreaks.
485combineLines :: [[Inline]] -> [Inline]
483combineLines :: [[Inline]] -> [Inline]