* small colouriser tool to run .hs files through HsColour
This commit is contained in:
parent
7f4761bf7c
commit
74ce7d9bf0
3 changed files with 88 additions and 0 deletions
21
tools/colouriser/colour.hs
Normal file
21
tools/colouriser/colour.hs
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
{-# 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 -> String -> IO ()
|
||||
colorCode input output = do
|
||||
code <- readFile input
|
||||
writeFile output $ hscolour False code
|
||||
|
||||
main :: IO ()
|
||||
main = runCommand $ \opts args -> do
|
||||
let file = optFile opts
|
||||
unless (file == "") $
|
||||
colorCode (file ++ ".hs") (file ++ ".html")
|
||||
Loading…
Add table
Add a link
Reference in a new issue