@@ -69,14 +69,18 @@ compileInfo =
6969#endif
7070 if null languages
7171 then "\n"
72− else "\nCompiled with syntax highlighting support for:\n" ++
73− (unlines $ map unwords $ chunk 5 $ map (\s -> s ++ replicate (15 - length s) ' ') languages)
74−
75−-- | Splits a list into groups of at most n.
76−chunk :: Int -> [a] -> [[a]]
77−chunk size lst =
78− let (next, rest) = splitAt size lst
79− in if null rest then [next] else next : chunk size rest
72+ else "\nCompiled with syntax highlighting support for:\n" ++ wrapWords 78 languages
73+
74+-- | Converts a list of strings into a single string with the items printed as
75+-- comma separated words in lines with a maximum line length.
76+wrapWords :: Int -> [String] -> String
77+wrapWords c = wrap' c c where
78+ wrap' _ _ [] = ""
79+ wrap' cols remaining (x:xs) = if remaining == cols
80+ then x ++ wrap' cols (remaining - length x) xs
81+ else if (length x + 1) > remaining
82+ then ",\n" ++ x ++ wrap' cols (cols - length x) xs
83+ else ", " ++ x ++ wrap' cols (remaining - (length x + 2)) xs
8084
8185-- | Association list of formats and readers.
8286readers :: [(String, ParserState -> String -> Pandoc)]