aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Shared.hs
diff options
context:
space:
mode:
authorJohn MacFarlane <fiddlosopher@gmail.com>2012-07-24 22:12:18 -0700
committerJohn MacFarlane <fiddlosopher@gmail.com>2012-07-24 22:12:18 -0700
commit02ef26ae91f7c1db1e4018c69b33f59c3ce837a2 (patch)
tree919f991c70a12f60d0b8f68dd8c7cddd70e13439 /src/Text/Pandoc/Shared.hs
parentc00f5c4372fabfcb30744aa85b1cc2b9142ea3e7 (diff)
downloadpandoc-02ef26ae91f7c1db1e4018c69b33f59c3ce837a2.tar.gz
Slightly more efficient normalizeSpaces.
Diffstat (limited to 'src/Text/Pandoc/Shared.hs')
-rw-r--r--src/Text/Pandoc/Shared.hs11
1 files changed, 5 insertions, 6 deletions
diff --git a/src/Text/Pandoc/Shared.hs b/src/Text/Pandoc/Shared.hs
index e976b93dc..0825a414d 100644
--- a/src/Text/Pandoc/Shared.hs
+++ b/src/Text/Pandoc/Shared.hs
@@ -272,13 +272,12 @@ orderedListMarkers (start, numstyle, numdelim) =
-- remove empty Str elements.
normalizeSpaces :: [Inline] -> [Inline]
normalizeSpaces = cleanup . dropWhile isSpaceOrEmpty
- where cleanup [] = []
- cleanup (Space:rest) = let rest' = dropWhile isSpaceOrEmpty rest
- in case rest' of
- [] -> []
- _ -> Space : cleanup rest'
+ where cleanup [] = []
+ cleanup (Space:rest) = case dropWhile isSpaceOrEmpty rest of
+ [] -> []
+ (x:xs) -> Space : x : cleanup xs
cleanup ((Str ""):rest) = cleanup rest
- cleanup (x:rest) = x : cleanup rest
+ cleanup (x:rest) = x : cleanup rest
isSpaceOrEmpty :: Inline -> Bool
isSpaceOrEmpty Space = True