diff options
author | John MacFarlane <jgm@berkeley.edu> | 2014-07-25 10:53:04 -0700 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2014-07-25 10:53:04 -0700 |
commit | 18f4490482aa4f21a1c4e4a9493fb3a88815dcfa (patch) | |
tree | c58e6b8eac486f6b525f3e0c4a04587f34f4807a /src/Text/Pandoc | |
parent | 9c3f7688ee1c44c5452cb30986f1e37317acb6e2 (diff) | |
download | pandoc-18f4490482aa4f21a1c4e4a9493fb3a88815dcfa.tar.gz |
Fixed runtime error with compactify'DL on certain lists.
Closes #1452. Added test.
Diffstat (limited to 'src/Text/Pandoc')
-rw-r--r-- | src/Text/Pandoc/Shared.hs | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/src/Text/Pandoc/Shared.hs b/src/Text/Pandoc/Shared.hs index bb13836f2..77180bd4b 100644 --- a/src/Text/Pandoc/Shared.hs +++ b/src/Text/Pandoc/Shared.hs @@ -553,20 +553,22 @@ compactify' items = _ -> items _ -> items --- | Like @compactify'@, but akts on items of definition lists. +-- | Like @compactify'@, but acts on items of definition lists. compactify'DL :: [(Inlines, [Blocks])] -> [(Inlines, [Blocks])] compactify'DL items = let defs = concatMap snd items - defBlocks = reverse $ concatMap B.toList defs - in case defBlocks of - (Para x:_) -> if not $ any isPara (drop 1 defBlocks) - then let (t,ds) = last items - lastDef = B.toList $ last ds - ds' = init ds ++ - [B.fromList $ init lastDef ++ [Plain x]] - in init items ++ [(t, ds')] - else items - _ -> items + in case reverse (concatMap B.toList defs) of + (Para x:xs) + | not (any isPara xs) -> + let (t,ds) = last items + lastDef = B.toList $ last ds + ds' = init ds ++ + if null lastDef + then [B.fromList lastDef] + else [B.fromList $ init lastDef ++ [Plain x]] + in init items ++ [(t, ds')] + | otherwise -> items + _ -> items isPara :: Block -> Bool isPara (Para _) = True |