aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc
diff options
context:
space:
mode:
authorfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b>2007-08-30 22:49:20 +0000
committerfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b>2007-08-30 22:49:20 +0000
commit33d47ced769a4907954653ba82ad9c632b6b4dd5 (patch)
tree1c28961c48f87888e69665090e58313483158a29 /src/Text/Pandoc
parent1827ab40c35f1233b2f3fdee58bab4ab500c8e40 (diff)
downloadpandoc-33d47ced769a4907954653ba82ad9c632b6b4dd5.tar.gz
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
Diffstat (limited to 'src/Text/Pandoc')
-rw-r--r--src/Text/Pandoc/Shared.hs7
1 files changed, 7 insertions, 0 deletions
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
--