* small colouriser tool to run .hs files through HsColour

This commit is contained in:
Vincent Ambo 2012-03-25 19:01:56 +02:00
parent 7f4761bf7c
commit 74ce7d9bf0
3 changed files with 88 additions and 0 deletions

3
tools/colouriser/LICENSE Normal file
View file

@ -0,0 +1,3 @@
This program comes with absolutely no warranty and I can't guarantee that it's not going to explode in your face.
In addition to this, I don't care what you do with this.

View file

@ -0,0 +1,64 @@
-- colour.cabal auto-generated by cabal init. For additional options,
-- see
-- http://www.haskell.org/cabal/release/cabal-latest/doc/users-guide/authors.html#pkg-descr.
-- The name of the package.
Name: colour
-- The package version. See the Haskell package versioning policy
-- (http://www.haskell.org/haskellwiki/Package_versioning_policy) for
-- standards guiding when and how versions should be incremented.
Version: 0.1
-- A short (one-line) description of the package.
Synopsis: Shortcut program to use HsColour
-- A longer description of the package.
-- Description:
-- URL for the project homepage or repository.
Homepage: http://tazj.in/
-- The license under which the package is released.
License: OtherLicense
-- The file containing the license text.
License-file: LICENSE
-- The package author(s).
Author: tazjin
-- An email address to which users can send suggestions, bug reports,
-- and patches.
-- Maintainer:
-- A copyright notice.
-- Copyright:
Category: Web
Build-type: Simple
-- Extra files to be distributed with the package, such as examples or
-- a README.
-- Extra-source-files:
-- Constraint on the version of Cabal needed to build this package.
Cabal-version: >=1.2
Executable colour
-- .hs or .lhs file containing the Main module.
Main-is: colour.hs
-- Packages needed in order to build this package.
Build-depends:
base,
options,
hscolour
-- Modules not exported by this package.
-- Other-modules:
-- Extra tools (e.g. alex, hsc2hs, ...) needed to build the source.
-- Build-tools:

View 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")