diff options
author | fiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b> | 2008-10-25 22:07:45 +0000 |
---|---|---|
committer | fiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b> | 2008-10-25 22:07:45 +0000 |
commit | 0b3d8581a3f1c52c4bd1a1263a4434740e22043a (patch) | |
tree | 4ff9cf99cfa0085f82e5fa17f6530afb67f33451 | |
parent | 66d459a545b0ddfa372a5abd200fb8916677785b (diff) | |
download | pandoc-0b3d8581a3f1c52c4bd1a1263a4434740e22043a.tar.gz |
Changed compactify in Text.Pandoc.Shared - better heuristic.
Final Para is changed to Plain if all other list items *end* with
a Plain block. Addresses Issue #99.
git-svn-id: https://pandoc.googlecode.com/svn/trunk@1470 788f1e2b-df1e-0410-8736-df70ead52e1b
-rw-r--r-- | Text/Pandoc/Shared.hs | 31 |
1 files changed, 15 insertions, 16 deletions
diff --git a/Text/Pandoc/Shared.hs b/Text/Pandoc/Shared.hs index 6485372db..30fd3fc07 100644 --- a/Text/Pandoc/Shared.hs +++ b/Text/Pandoc/Shared.hs @@ -824,22 +824,21 @@ compactify [] = [] compactify items = let final = last items others = init items - in case final of - [Para a] -> if any containsPara others - then items - else others ++ [[Plain a]] - _ -> items - -containsPara :: [Block] -> Bool -containsPara [] = False -containsPara ((Para _):_) = True -containsPara ((BulletList items):rest) = any containsPara items || - containsPara rest -containsPara ((OrderedList _ items):rest) = any containsPara items || - containsPara rest -containsPara ((DefinitionList items):rest) = any containsPara (map snd items) || - containsPara rest -containsPara (_:rest) = containsPara rest + in case last final of + Para a -> if all endsWithPlain others && not (null final) + then others ++ [init final ++ [Plain a]] + else items + _ -> items + +endsWithPlain :: [Block] -> Bool +endsWithPlain [] = False +endsWithPlain blocks = + case last blocks of + Plain _ -> True + (BulletList (x:xs)) -> endsWithPlain $ last (x:xs) + (OrderedList _ (x:xs)) -> endsWithPlain $ last (x:xs) + (DefinitionList (x:xs)) -> endsWithPlain $ last $ map snd (x:xs) + _ -> False -- | Data structure for defining hierarchical Pandoc documents data Element = Blk Block |