git.iko.soy/typeable/pandoc
on master help sign in
Pretty: Added nestle. API change, minor version bump to 1.12.3.
452a140John MacFarlane
pandoc.cabal+1−1
@@ -1,5 +1,5 @@
1Name: pandoc
1Name: pandoc
2−Version: 1.12.2.1
2+Version: 1.12.3
3Cabal-Version: >= 1.10
3Cabal-Version: >= 1.10
4Build-Type: Custom
4Build-Type: Custom
5License: GPL
5License: GPL
src/Text/Pandoc/Pretty.hs+10−1
@@ -60,6 +60,7 @@ module Text.Pandoc.Pretty (
60 , hsep
60 , hsep
61 , vcat
61 , vcat
62 , vsep
62 , vsep
63+ , nestle
63 , chomp
64 , chomp
64 , inside
65 , inside
65 , braces
66 , braces
@@ -72,7 +73,7 @@ module Text.Pandoc.Pretty (
72 )
73 )
73
74
74where
75where
75−import Data.Sequence (Seq, fromList, (<|), singleton, mapWithIndex)
76+import Data.Sequence (Seq, fromList, (<|), singleton, mapWithIndex, viewl, ViewL(..))
76import Data.Foldable (toList)
77import Data.Foldable (toList)
77import Data.List (intercalate)
78import Data.List (intercalate)
78import Data.Monoid
79import Data.Monoid
@@ -186,6 +187,14 @@ vcat = foldr ($$) empty
186vsep :: [Doc] -> Doc
187vsep :: [Doc] -> Doc
187vsep = foldr ($+$) empty
188vsep = foldr ($+$) empty
188
189
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+
189-- | Chomps trailing blank space off of a 'Doc'.
198-- | Chomps trailing blank space off of a 'Doc'.
190chomp :: Doc -> Doc
199chomp :: Doc -> Doc
191chomp d = Doc (fromList dl')
200chomp d = Doc (fromList dl')