2012-03-25 19:01:56 +02:00
|
|
|
{-# 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"
|
|
|
|
|
2012-04-12 02:56:33 +02:00
|
|
|
colorCode :: String -> IO ()
|
|
|
|
colorCode input = do
|
2012-03-25 19:01:56 +02:00
|
|
|
code <- readFile input
|
2012-04-12 02:56:33 +02:00
|
|
|
putStr $ concat [ "<div class=\"code\">"
|
|
|
|
, hscolour False code
|
|
|
|
, "</div>"
|
|
|
|
]
|
2012-03-25 19:01:56 +02:00
|
|
|
|
|
|
|
main :: IO ()
|
|
|
|
main = runCommand $ \opts args -> do
|
|
|
|
let file = optFile opts
|
|
|
|
unless (file == "") $
|
2012-04-12 02:56:33 +02:00
|
|
|
colorCode file
|