@@ -60,6 +60,7 @@ module Text.Pandoc.Pretty (
@@ -72,7 +73,7 @@ module Text.Pandoc.Pretty (
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
190+-- | Removes leading blank lines from a '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
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')