Shared: Fixed bug in normalize revealed by tests!

This commit is contained in:
John MacFarlane 2011-01-29 10:03:31 -08:00
parent 0833daff4a
commit 387a2b365e

View file

@ -257,10 +257,10 @@ normalizeSpaces = cleanup . dropWhile isSpaceOrEmpty
-- | Normalize @Pandoc@ document, consolidating doubled 'Space's, -- | Normalize @Pandoc@ document, consolidating doubled 'Space's,
-- combining adjacent 'Str's and 'Emph's, remove 'Null's and -- combining adjacent 'Str's and 'Emph's, remove 'Null's and
-- empty elements, etc. -- empty elements, etc.
normalize :: Data a => a -> a normalize :: (Eq a, Data a) => a -> a
normalize = topDown consolidateInlines . normalize = topDown removeEmptyBlocks .
bottomUp removeEmptyInlines . topDown consolidateInlines .
topDown removeEmptyBlocks bottomUp removeEmptyInlines
removeEmptyBlocks :: [Block] -> [Block] removeEmptyBlocks :: [Block] -> [Block]
removeEmptyBlocks (Null : xs) = removeEmptyBlocks xs removeEmptyBlocks (Null : xs) = removeEmptyBlocks xs
@ -280,6 +280,7 @@ removeEmptyInlines (SmallCaps [] : zs) = removeEmptyInlines zs
removeEmptyInlines (Strikeout [] : zs) = removeEmptyInlines zs removeEmptyInlines (Strikeout [] : zs) = removeEmptyInlines zs
removeEmptyInlines (RawInline _ [] : zs) = removeEmptyInlines zs removeEmptyInlines (RawInline _ [] : zs) = removeEmptyInlines zs
removeEmptyInlines (Code _ [] : zs) = removeEmptyInlines zs removeEmptyInlines (Code _ [] : zs) = removeEmptyInlines zs
removeEmptyInlines (Str "" : zs) = removeEmptyInlines zs
removeEmptyInlines (x : xs) = x : removeEmptyInlines xs removeEmptyInlines (x : xs) = x : removeEmptyInlines xs
removeEmptyInlines [] = [] removeEmptyInlines [] = []