about summary refs log tree commit diff
path: root/tools/colouriser/colour.hs
blob: 3e6e39ba45f613e6e943612803e6c400260a04da (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
{-# LANGUAGE TemplateHaskell #-}

import Control.Monad (unless)
import Language.Haskell.HsColour.Colourise (defaultColourPrefs)
import Language.Haskell.HsColour.CSS
import Options

defineOptions "MainOptions" $ do
	stringOption "optFile" "file" ""
		"Name of the .hs file. Will be used for the HTML file as well"

colorCode :: String -> IO ()
colorCode input = do
	code <- readFile input
	putStr $ concat [ "<div class=\"code\">"
		     		, hscolour False code
				    , "</div>"
				    ]

main :: IO ()
main = runCommand $ \opts args -> do
	let file = optFile opts
	unless (file == "") $
		colorCode file