Render a Haskell script, including the outputs.
For html
rendering, this tool depends on the executable file HsColour
provided by the hscolour package.
$ ghcscriptrender --help
ghcscriptrender
Usage: ghcscriptrender FILE [-s|--singleoutputs] [-n|--nooutputs]
[-t|--type TYPE] [-f|--fragment]
[-p|--package-db package-database]
Convert a Haskell script to html or txt, including the outputs.
Available options:
-h,--help Show this help text
FILE The Haskell script
-s,--singleoutputs In case every output takes only one line
-n,--nooutputs Do not include the outputs
-t,--type TYPE Output type: html (default), txt, or md
-f,--fragment Generate a html block (for --type html)
-p,--package-db package-database
Add the package database
-
-t
: output type:html
,txt
ormd
. -
-f
: for--type html
only; returns a html block, without header and body tags. -
-n
: for--type html
only; don't include the outputs, but only placeholders. -
-s
: use this option in case every output of the script fits on one line, to gain speed. -
-p
: the package database, the same as the option-package-db
ofghc
.
Once you get the txt output, you can convert it to highlighted html by using node.js
with the pygments library, or the Python command line pygmentize.
The -t md
option returns a block such as:
```haskell
> -- define a new type:
> data Point = Point Float Float deriving (Show)
> -- variable of type Point:
> let point = (Point 3 4)
> point
Point 3.0 4.0
> :t point
point :: Point
> -- 'Point' is like a function:
> :t Point
Point :: Float -> Float -> Point
> -- a function acting on 'Point' variables:
> :{
> let squareNorm :: Point -> Float
> squareNorm (Point x y) = x^2+y^2
> :}
> squareNorm point
25.0
```
This markdown block of code is ready to be processed by Pandoc.
This is the output of Pandoc using the option --highlight-style haddock
.