From 387a2b365ea4b3e7181d60a0636d0f593e7f3b19 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Sat, 29 Jan 2011 10:03:31 -0800 Subject: Shared: Fixed bug in normalize revealed by tests! --- src/Text/Pandoc/Shared.hs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/Text/Pandoc') diff --git a/src/Text/Pandoc/Shared.hs b/src/Text/Pandoc/Shared.hs index cf0eb32c3..b1d5de63f 100644 --- a/src/Text/Pandoc/Shared.hs +++ b/src/Text/Pandoc/Shared.hs @@ -257,10 +257,10 @@ normalizeSpaces = cleanup . dropWhile isSpaceOrEmpty -- | Normalize @Pandoc@ document, consolidating doubled 'Space's, -- combining adjacent 'Str's and 'Emph's, remove 'Null's and -- empty elements, etc. -normalize :: Data a => a -> a -normalize = topDown consolidateInlines . - bottomUp removeEmptyInlines . - topDown removeEmptyBlocks +normalize :: (Eq a, Data a) => a -> a +normalize = topDown removeEmptyBlocks . + topDown consolidateInlines . + bottomUp removeEmptyInlines removeEmptyBlocks :: [Block] -> [Block] removeEmptyBlocks (Null : xs) = removeEmptyBlocks xs @@ -280,6 +280,7 @@ removeEmptyInlines (SmallCaps [] : zs) = removeEmptyInlines zs removeEmptyInlines (Strikeout [] : zs) = removeEmptyInlines zs removeEmptyInlines (RawInline _ [] : zs) = removeEmptyInlines zs removeEmptyInlines (Code _ [] : zs) = removeEmptyInlines zs +removeEmptyInlines (Str "" : zs) = removeEmptyInlines zs removeEmptyInlines (x : xs) = x : removeEmptyInlines xs removeEmptyInlines [] = [] -- cgit v1.2.3