Pretty: Fixed chomp so it works inside Prefixed elements.
This commit is contained in:
parent
0c4965847f
commit
68c95f4857
1 changed files with 8 additions and 6 deletions
|
@ -190,12 +190,14 @@ vsep = foldr ($+$) empty
|
||||||
chomp :: Doc -> Doc
|
chomp :: Doc -> Doc
|
||||||
chomp d = Doc (fromList dl')
|
chomp d = Doc (fromList dl')
|
||||||
where dl = toList (unDoc d)
|
where dl = toList (unDoc d)
|
||||||
dl' = reverse $ dropWhile removeable $ reverse dl
|
dl' = reverse $ go $ reverse dl
|
||||||
removeable BreakingSpace = True
|
go [] = []
|
||||||
removeable CarriageReturn = True
|
go (BreakingSpace : xs) = go xs
|
||||||
removeable NewLine = True
|
go (CarriageReturn : xs) = go xs
|
||||||
removeable BlankLine = True
|
go (NewLine : xs) = go xs
|
||||||
removeable _ = False
|
go (BlankLine : xs) = go xs
|
||||||
|
go (Prefixed s d' : xs) = Prefixed s (chomp d') : xs
|
||||||
|
go xs = xs
|
||||||
|
|
||||||
outp :: (IsString a, Monoid a)
|
outp :: (IsString a, Monoid a)
|
||||||
=> Int -> String -> DocState a
|
=> Int -> String -> DocState a
|
||||||
|
|
Loading…
Add table
Reference in a new issue