@@ -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--