git.iko.soy/typeable/pandoc
on master help sign in
Added 'wrapped' function to Text.Pandoc.Shared.
33d47cefiddlosopher
src/Text/Pandoc/Shared.hs+7
@@ -43,6 +43,7 @@ module Text.Pandoc.Shared (
43 stripFirstAndLast,
43 stripFirstAndLast,
44 camelCaseToHyphenated,
44 camelCaseToHyphenated,
45 toRomanNumeral,
45 toRomanNumeral,
46+ wrapped,
46 -- * Parsing
47 -- * Parsing
47 (>>~),
48 (>>~),
48 anyLine,
49 anyLine,
@@ -98,6 +99,7 @@ module Text.Pandoc.Shared (
98
99
99import Text.Pandoc.Definition
100import Text.Pandoc.Definition
100import Text.ParserCombinators.Parsec
101import Text.ParserCombinators.Parsec
102+import Text.PrettyPrint.HughesPJ ( Doc (..), fsep )
101import Text.Pandoc.CharacterReferences ( characterReference )
103import Text.Pandoc.CharacterReferences ( characterReference )
102import Data.Char ( toLower, toUpper, ord, chr, isLower, isUpper )
104import Data.Char ( toLower, toUpper, ord, chr, isLower, isUpper )
103import Data.List ( find, groupBy, isPrefixOf, isSuffixOf )
105import Data.List ( find, groupBy, isPrefixOf, isSuffixOf )
@@ -207,6 +209,11 @@ toRomanNumeral x =
207 x | x >= 1 -> "I" ++ toRomanNumeral (x - 1)
209 x | x >= 1 -> "I" ++ toRomanNumeral (x - 1)
208 0 -> ""
210 0 -> ""
209
211
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+
210--
217--
211-- Parsing
218-- Parsing
212--
219--