From 33d47ced769a4907954653ba82ad9c632b6b4dd5 Mon Sep 17 00:00:00 2001 From: fiddlosopher Date: Thu, 30 Aug 2007 22:49:20 +0000 Subject: Added 'wrapped' function to Text.Pandoc.Shared. This helps wrap text into paragraphs, using the prettyprinting library. git-svn-id: https://pandoc.googlecode.com/svn/trunk@965 788f1e2b-df1e-0410-8736-df70ead52e1b --- src/Text/Pandoc/Shared.hs | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/Text') diff --git a/src/Text/Pandoc/Shared.hs b/src/Text/Pandoc/Shared.hs index ac22a6155..c2228ffff 100644 --- a/src/Text/Pandoc/Shared.hs +++ b/src/Text/Pandoc/Shared.hs @@ -43,6 +43,7 @@ module Text.Pandoc.Shared ( stripFirstAndLast, camelCaseToHyphenated, toRomanNumeral, + wrapped, -- * Parsing (>>~), anyLine, @@ -98,6 +99,7 @@ module Text.Pandoc.Shared ( import Text.Pandoc.Definition import Text.ParserCombinators.Parsec +import Text.PrettyPrint.HughesPJ ( Doc (..), fsep ) import Text.Pandoc.CharacterReferences ( characterReference ) import Data.Char ( toLower, toUpper, ord, chr, isLower, isUpper ) import Data.List ( find, groupBy, isPrefixOf, isSuffixOf ) @@ -207,6 +209,11 @@ toRomanNumeral x = x | x >= 1 -> "I" ++ toRomanNumeral (x - 1) 0 -> "" +-- | Wrap inlines to line length. +wrapped :: Monad m => ([Inline] -> m Doc) -> [Inline] -> m Doc +wrapped listWriter sect = (mapM listWriter $ splitBy Space sect) >>= + return . fsep + -- -- Parsing -- -- cgit v1.2.3