diff options
author | John MacFarlane <fiddlosopher@gmail.com> | 2014-01-02 21:09:39 -0800 |
---|---|---|
committer | John MacFarlane <fiddlosopher@gmail.com> | 2014-01-02 21:09:39 -0800 |
commit | 452a140d0cd808abbdfbb1f91dc35280b1f90794 (patch) | |
tree | a1d1240688f8595a731d8c8e06f62ca7066dd1c9 /src/Text | |
parent | 4e7aadb903548bb08c9132c93699071e52f61d76 (diff) | |
download | pandoc-452a140d0cd808abbdfbb1f91dc35280b1f90794.tar.gz |
Pretty: Added nestle. API change, minor version bump to 1.12.3.
Diffstat (limited to 'src/Text')
-rw-r--r-- | src/Text/Pandoc/Pretty.hs | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/Text/Pandoc/Pretty.hs b/src/Text/Pandoc/Pretty.hs index faf2a6797..033511832 100644 --- a/src/Text/Pandoc/Pretty.hs +++ b/src/Text/Pandoc/Pretty.hs @@ -60,6 +60,7 @@ module Text.Pandoc.Pretty ( , hsep , vcat , vsep + , nestle , chomp , inside , braces @@ -72,7 +73,7 @@ module Text.Pandoc.Pretty ( ) where -import Data.Sequence (Seq, fromList, (<|), singleton, mapWithIndex) +import Data.Sequence (Seq, fromList, (<|), singleton, mapWithIndex, viewl, ViewL(..)) import Data.Foldable (toList) import Data.List (intercalate) import Data.Monoid @@ -186,6 +187,14 @@ vcat = foldr ($$) empty vsep :: [Doc] -> Doc vsep = foldr ($+$) empty +-- | Removes leading blank lines from a 'Doc'. +nestle :: Doc -> Doc +nestle (Doc d) = Doc $ go d + where go x = case viewl x of + (BlankLine :< rest) -> go rest + (NewLine :< rest) -> go rest + _ -> x + -- | Chomps trailing blank space off of a 'Doc'. chomp :: Doc -> Doc chomp d = Doc (fromList dl') |