@@ -56,6 +56,7 @@ module Text.Pandoc.Shared (
56 stringify,
56 stringify,
57 compactify,
57 compactify,
58 compactify',
58 compactify',
59 Element (..),
60 Element (..),
60 hierarchicalize,
61 hierarchicalize,
61 uniqueIdent,
62 uniqueIdent,
@@ -82,7 +83,7 @@ module Text.Pandoc.Shared (
82import Text.Pandoc.Definition
83import Text.Pandoc.Definition
83import Text.Pandoc.Walk
84import Text.Pandoc.Walk
84import Text.Pandoc.Generic
85import Text.Pandoc.Generic
85−import Text.Pandoc.Builder (Blocks, ToMetaValue(..))
86+import Text.Pandoc.Builder (Inlines, Blocks, ToMetaValue(..))
86import qualified Text.Pandoc.Builder as B
87import qualified Text.Pandoc.Builder as B
87import qualified Text.Pandoc.UTF8 as UTF8
88import qualified Text.Pandoc.UTF8 as UTF8
88import System.Environment (getProgName)
89import System.Environment (getProgName)
@@ -435,6 +436,21 @@ compactify' items =
435 _ -> items
436 _ -> items
436 _ -> items
437 _ -> items
439+-- | Like @compactify'@, but akts on items of definition lists.
440+compactify'DL :: [(Inlines, [Blocks])] -> [(Inlines, [Blocks])]
441+compactify'DL items =
442+ let defs = concatMap snd items
443+ defBlocks = reverse $ concatMap B.toList defs
444+ in case defBlocks of
445+ (Para x:_) -> if not $ any isPara (drop 1 defBlocks)
446+ then let (t,ds) = last items
447+ lastDef = B.toList $ last ds
449+ [B.fromList $ init lastDef ++ [Plain x]]
450+ in init items ++ [(t, ds')]
438isPara :: Block -> Bool
454isPara :: Block -> Bool
439isPara (Para _) = True
455isPara (Para _) = True
440isPara _ = False
456isPara _ = False
@@ -698,5 +714,3 @@ safeRead s = case reads s of
699 | all isSpace x -> return d
715 | all isSpace x -> return d
700 _ -> fail $ "Could not read `" ++ s ++ "'"
716 _ -> fail $ "Could not read `" ++ s ++ "'"