From 68c95f4857923f260794418a9769d0896a963f63 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Thu, 28 Feb 2013 20:22:08 -0800 Subject: [PATCH] Pretty: Fixed chomp so it works inside Prefixed elements. --- src/Text/Pandoc/Pretty.hs | 14 ++++++++------ 1 file 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