git.iko.soy/typeable/pandoc
on master help sign in
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

commit33d47ced769a4907954653ba82ad9c632b6b4dd5 authorfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b> dateThu 30 Aug 2007, 22:49 (19 years ago) parent1827ab4
1 file changed+7
src/Text/Pandoc/Shared.hs+7
src/Text/Pandoc/Shared.hs+7
@@ -43,6 +43,7 @@ module Text.Pandoc.Shared (
4343 stripFirstAndLast,
4444 camelCaseToHyphenated,
4545 toRomanNumeral,
46+ wrapped,
4647 -- * Parsing
4748 (>>~),
4849 anyLine,
@@ -98,6 +99,7 @@ module Text.Pandoc.Shared (
9899
99100import Text.Pandoc.Definition
100101import Text.ParserCombinators.Parsec
102+import Text.PrettyPrint.HughesPJ ( Doc (..), fsep )
101103import Text.Pandoc.CharacterReferences ( characterReference )
102104import Data.Char ( toLower, toUpper, ord, chr, isLower, isUpper )
103105import Data.List ( find, groupBy, isPrefixOf, isSuffixOf )
@@ -207,6 +209,11 @@ toRomanNumeral x =
207209 x | x >= 1 -> "I" ++ toRomanNumeral (x - 1)
208210 0 -> ""
209211
212+-- | Wrap inlines to line length.
213+wrapped :: Monad m => ([Inline] -> m Doc) -> [Inline] -> m Doc
214+wrapped listWriter sect = (mapM listWriter $ splitBy Space sect) >>=
215+ return . fsep
216+
210217--
211218-- Parsing
212219--