git.iko.soy/typeable/pandoc
on master help sign in
Have the '-v' option print syntax highlighting languages separated by commas,
c4c7751fiddlosopher
Main.hs+12−8
@@ -69,14 +69,18 @@ compileInfo =
69#endif
69#endif
70 if null languages
70 if null languages
71 then "\n"
71 then "\n"
72− else "\nCompiled with syntax highlighting support for:\n" ++
72+ else "\nCompiled with syntax highlighting support for:\n" ++ wrapWords 78 languages
73− (unlines $ map unwords $ chunk 5 $ map (\s -> s ++ replicate (15 - length s) ' ') languages)
73+
74−
74+-- | Converts a list of strings into a single string with the items printed as
75−-- | Splits a list into groups of at most n.
75+-- comma separated words in lines with a maximum line length.
76−chunk :: Int -> [a] -> [[a]]
76+wrapWords :: Int -> [String] -> String
77−chunk size lst =
77+wrapWords c = wrap' c c where
78− let (next, rest) = splitAt size lst
78+ wrap' _ _ [] = ""
79− in if null rest then [next] else next : chunk size rest
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
80
84
81-- | Association list of formats and readers.
85-- | Association list of formats and readers.
82readers :: [(String, ParserState -> String -> Pandoc)]
86readers :: [(String, ParserState -> String -> Pandoc)]