aboutsummaryrefslogtreecommitdiff
path: root/Main.hs
diff options
context:
space:
mode:
authorfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b>2008-09-30 20:16:03 +0000
committerfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b>2008-09-30 20:16:03 +0000
commitc4c77517e993d453fdc9a05c8c7593ac1ae2199b (patch)
treef070c7f8dd4dc9b86d8aa2eeee9ebfa7f56df7cc /Main.hs
parent3b584566735a5260b68e5c6b050a71f40957385c (diff)
downloadpandoc-c4c77517e993d453fdc9a05c8c7593ac1ae2199b.tar.gz
Have the '-v' option print syntax highlighting languages separated by commas,
and wrapped in lines, instead of in five columns as before. git-svn-id: https://pandoc.googlecode.com/svn/trunk@1459 788f1e2b-df1e-0410-8736-df70ead52e1b
Diffstat (limited to 'Main.hs')
-rw-r--r--Main.hs20
1 files changed, 12 insertions, 8 deletions
diff --git a/Main.hs b/Main.hs
index 7cf4e9970..c5cfa84b4 100644
--- a/Main.hs
+++ b/Main.hs
@@ -69,14 +69,18 @@ compileInfo =
#endif
if null languages
then "\n"
- else "\nCompiled with syntax highlighting support for:\n" ++
- (unlines $ map unwords $ chunk 5 $ map (\s -> s ++ replicate (15 - length s) ' ') languages)
-
--- | Splits a list into groups of at most n.
-chunk :: Int -> [a] -> [[a]]
-chunk size lst =
- let (next, rest) = splitAt size lst
- in if null rest then [next] else next : chunk size rest
+ else "\nCompiled with syntax highlighting support for:\n" ++ wrapWords 78 languages
+
+-- | Converts a list of strings into a single string with the items printed as
+-- comma separated words in lines with a maximum line length.
+wrapWords :: Int -> [String] -> String
+wrapWords c = wrap' c c where
+ wrap' _ _ [] = ""
+ wrap' cols remaining (x:xs) = if remaining == cols
+ then x ++ wrap' cols (remaining - length x) xs
+ else if (length x + 1) > remaining
+ then ",\n" ++ x ++ wrap' cols (cols - length x) xs
+ else ", " ++ x ++ wrap' cols (remaining - (length x + 2)) xs
-- | Association list of formats and readers.
readers :: [(String, ParserState -> String -> Pandoc)]