git.iko.soy/typeable/pandoc
on master help sign in
Pretty: Added nestle. API change, minor version bump to 1.12.3.
commit452a140d0cd808abbdfbb1f91dc35280b1f90794 authorJohn MacFarlane <fiddlosopher@gmail.com> dateThu 2 Jan 2014, 21:09 (13 years ago) parent4e7aadb
2 files changed+11−2
pandoc.cabal+1−1 src/Text/Pandoc/Pretty.hs+10−1
pandoc.cabal+1−1
@@ -1,5 +1,5 @@
11Name: pandoc
2−Version: 1.12.2.1
2+Version: 1.12.3
33Cabal-Version: >= 1.10
44Build-Type: Custom
55License: GPL
src/Text/Pandoc/Pretty.hs+10−1
@@ -60,6 +60,7 @@ module Text.Pandoc.Pretty (
6060 , hsep
6161 , vcat
6262 , vsep
63+ , nestle
6364 , chomp
6465 , inside
6566 , braces
@@ -72,7 +73,7 @@ module Text.Pandoc.Pretty (
7273 )
7374
7475where
75−import Data.Sequence (Seq, fromList, (<|), singleton, mapWithIndex)
76+import Data.Sequence (Seq, fromList, (<|), singleton, mapWithIndex, viewl, ViewL(..))
7677import Data.Foldable (toList)
7778import Data.List (intercalate)
7879import Data.Monoid
@@ -186,6 +187,14 @@ vcat = foldr ($$) empty
186187vsep :: [Doc] -> Doc
187188vsep = foldr ($+$) empty
188189
190+-- | Removes leading blank lines from a 'Doc'.
191+nestle :: Doc -> Doc
192+nestle (Doc d) = Doc $ go d
193+ where go x = case viewl x of
194+ (BlankLine :< rest) -> go rest
195+ (NewLine :< rest) -> go rest
196+ _ -> x
197+
189198-- | Chomps trailing blank space off of a 'Doc'.
190199chomp :: Doc -> Doc
191200chomp d = Doc (fromList dl')