aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2011-01-29 10:03:31 -0800
committerJohn MacFarlane <jgm@berkeley.edu>2011-01-29 10:03:31 -0800
commit387a2b365ea4b3e7181d60a0636d0f593e7f3b19 (patch)
tree720d4176c50186a1eae0266c33d44977b53b69bc
parent0833daff4af7ce17aa0a77528731f30ec127bc68 (diff)
downloadpandoc-387a2b365ea4b3e7181d60a0636d0f593e7f3b19.tar.gz
Shared: Fixed bug in normalize revealed by tests!
-rw-r--r--src/Text/Pandoc/Shared.hs9
1 files changed, 5 insertions, 4 deletions
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 [] = []