From 452a140d0cd808abbdfbb1f91dc35280b1f90794 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Thu, 2 Jan 2014 21:09:39 -0800 Subject: Pretty: Added nestle. API change, minor version bump to 1.12.3. --- src/Text/Pandoc/Pretty.hs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src/Text/Pandoc/Pretty.hs') 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') -- cgit v1.2.3 From 286781f8014cd40ad741e52b254904ffa7dc2855 Mon Sep 17 00:00:00 2001 From: Merijn Verstraaten Date: Thu, 6 Feb 2014 23:10:59 +0100 Subject: Removed RenderState datatype context. Reasoning: - It's not Haskell2010 - It breaks some tools - Doesn't actually do anything - RenderState doesn't even have a Monoid instance --- src/Text/Pandoc/Pretty.hs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/Text/Pandoc/Pretty.hs') diff --git a/src/Text/Pandoc/Pretty.hs b/src/Text/Pandoc/Pretty.hs index 033511832..5331587ce 100644 --- a/src/Text/Pandoc/Pretty.hs +++ b/src/Text/Pandoc/Pretty.hs @@ -81,8 +81,7 @@ import Data.String import Control.Monad.State import Data.Char (isSpace) -data Monoid a => - RenderState a = RenderState{ +data RenderState a = RenderState{ output :: [a] -- ^ In reverse order , prefix :: String , usePrefix :: Bool -- cgit v1.2.3