aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn MacFarlane <fiddlosopher@gmail.com>2013-02-28 20:22:08 -0800
committerJohn MacFarlane <fiddlosopher@gmail.com>2013-02-28 20:22:08 -0800
commit68c95f4857923f260794418a9769d0896a963f63 (patch)
tree65f5587f20486913310c0934c402af3707259300
parent0c4965847f00b0aa47a89a24d638e4949c247bd9 (diff)
downloadpandoc-68c95f4857923f260794418a9769d0896a963f63.tar.gz
Pretty: Fixed chomp so it works inside Prefixed elements.
-rw-r--r--src/Text/Pandoc/Pretty.hs14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/Text/Pandoc/Pretty.hs b/src/Text/Pandoc/Pretty.hs
index 3b905b1c5..21121a506 100644
--- a/src/Text/Pandoc/Pretty.hs
+++ b/src/Text/Pandoc/Pretty.hs
@@ -190,12 +190,14 @@ vsep = foldr ($+$) empty
chomp :: Doc -> Doc
chomp d = Doc (fromList dl')
where dl = toList (unDoc d)
- dl' = reverse $ dropWhile removeable $ reverse dl
- removeable BreakingSpace = True
- removeable CarriageReturn = True
- removeable NewLine = True
- removeable BlankLine = True
- removeable _ = False
+ dl' = reverse $ go $ reverse dl
+ go [] = []
+ go (BreakingSpace : xs) = go xs
+ go (CarriageReturn : xs) = go xs
+ go (NewLine : xs) = go xs
+ go (BlankLine : xs) = go xs
+ go (Prefixed s d' : xs) = Prefixed s (chomp d') : xs
+ go xs = xs
outp :: (IsString a, Monoid a)
=> Int -> String -> DocState a