tvl-depot/tools/colouriser/colour.hs
2012-04-12 02:56:33 +02:00

24 lines
No EOL
606 B
Haskell

{-# 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