Cabal: literate hscolour

Hello, I can't find a way to pass the -lit flag to hscoulour using neither my cabal configuration file nor a command line option to runhaskell Setup.hs haddock. I'd really like to not have my literate comments be colored according to Haskell lexical conventions. Is there a way to do this? Thanks! Sean

On Thu, 2009-08-20 at 09:12 -0400, Sean McLaughlin wrote:
Hello,
I can't find a way to pass the -lit flag to hscoulour using neither my cabal configuration file nor a command line option to runhaskell Setup.hs haddock. I'd really like to not have my literate comments be colored according to Haskell lexical conventions. Is there a way to do this?
So it's fine for us to call hscolour differently for .lhs vs .hs files. The annoying thing here is that to "do the right thing" Cabal would need to distinguish bird-track style literate files (hscolour -lit) from tex style (hscolour -lit-tex). I don't think this is reasonable. The hscolour program is the one doing the lexing so it is in a position to work out which literate style it is using, or indeed if it's using a mixture. So I suggest you file a ticket against hscolour asking for -lit and -lit-tex to be merged. It might be worth asking if hscolour should by default just do the right thing, ie use -lit on .lhs input files. If not then file a separate ticket for Cabal to use -lit on .lhs files. In particular I'm not suggesting any configuration knob in Cabal for this. We should just do the right thing. Seem like a reasonable plan? Duncan

The annoying thing here is that to "do the right thing" Cabal would need to distinguish bird-track style literate files (hscolour -lit) from tex style (hscolour -lit-tex). I don't think this is reasonable.
I've fixed hscolour - from the newly release version 1.14 there is now no difference between the -lit and -lit-tex options. Both will deal with either style of literate input.
It might be worth asking if hscolour should by default just do the right thing, ie use -lit on .lhs input files.
Hscolour-1.14 also makes this fix. If your source file name ends in .lhs or .ly or .lx, it will be automatically processed with -lit. You can override the guess, by using an explicit -nolit (or -lit) to force the particular behaviour you want. Another new change, is that you can now supply multiple filenames as input, and their colourised contents will be concatenated to the output. Regards, Malcolm

Hi Malcolm, Thanks for the quick fix! I installed the newest version. There are a couple of problems for me. The first is that there is no color. My old files processed with hscolour 1.13 had headers like <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" " http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html> <head> <!-- Generated by HsColour, http://www.cs.york.ac.uk/fp/darcs/hscolour/ --> <title>src/Imogen/Infon/Fol/Subst.lhs</title> <link type='text/css' rel='stylesheet' href='hscolour.css' /> </head> <body> The files now don't have this header, and they are not showing up colored. Second, I'm probably being a pain in the ass, but I'd also like to keep my literate comments preformatted. Right now they are mashed all together and are unreadable. Would it be possible to add an option for preformatting, in case you prefer the default to be unformatted? Thanks! Sean On Fri, Aug 21, 2009 at 6:24 AM, Malcolm Wallace < Malcolm.Wallace@cs.york.ac.uk> wrote:
The annoying thing here is that to "do the right thing" Cabal would need
to distinguish bird-track style literate files (hscolour -lit) from tex style (hscolour -lit-tex). I don't think this is reasonable.
I've fixed hscolour - from the newly release version 1.14 there is now no difference between the -lit and -lit-tex options. Both will deal with either style of literate input.
It might be worth asking if hscolour should by
default just do the right thing, ie use -lit on .lhs input files.
Hscolour-1.14 also makes this fix. If your source file name ends in .lhs or .ly or .lx, it will be automatically processed with -lit. You can override the guess, by using an explicit -nolit (or -lit) to force the particular behaviour you want.
Another new change, is that you can now supply multiple filenames as input, and their colourised contents will be concatenated to the output.
Regards, Malcolm
_______________________________________________ Libraries mailing list Libraries@haskell.org http://www.haskell.org/mailman/listinfo/libraries

My old files processed with hscolour 1.13 had headers like
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd "> <html> <head> <!-- Generated by HsColour, http://www.cs.york.ac.uk/fp/darcs/hscolour/ --> <title>src/Imogen/Infon/Fol/Subst.lhs</title> <link type='text/css' rel='stylesheet' href='hscolour.css' /> </head> <body>
The files now don't have this header, and they are not showing up colored.
Ah, yes, that was one of the consequences of using -lit: it has always implied -partial. However, it is clearly a bug that there was no way to get an HTML / CSS / LaTeX prologue and epilogue in conjunction with the -lit option. Now fixed. The behaviour of -nopartial is now the default for all inputs, even literate files. People who want the old behaviour must now ask for it explicitly, using -lit -partial.
Second, I'm probably being a pain in the ass, but I'd also like to keep my literate comments preformatted. Right now they are mashed all together
I'm not sure what you mean. Could you send an example? (It is possible that it is a DOS/Windows line-ending bug.) I will make a new release 1.15 of HsColour once I have a fix for this second bug. Regards, Malcolm

Hi Malcolm,
Second, I'm probably being a pain in the ass, but I'd also like to keep my
literate comments preformatted. Right now they are mashed all together
I'm not sure what you mean. Could you send an example? (It is possible that it is a DOS/Windows line-ending bug.)
When you put the literate comments directly in html, for instance -- ---------------------------------------------- -- Sequents -- ---------------------------------------------- Here are a lot of comments about the sequent calculus.
data Seq = ...
This is rendered as -- -------------------------------- -- Sequents -- --------------------------------------- Here are a lot ... I'd like the format of the comments to stay the same as in the file. The easiest way I suppose is to wrap <pre> tags around them. That's all I meant. Thanks for your help, Sean

-- ---------------------------------------------- -- Sequents -- ----------------------------------------------
This is rendered as
-- -------------------------------- -- Sequents -- ---------------------------------------
I'd like the format of the comments to stay the same as in the file. The easiest way I suppose is to wrap <pre> tags around them. That's all I meant.
Now I understand. The literate file format is designed for you to use your own markup for the commentary. In particular, many people use real HTML tags (or LaTeX commands etc) for the comments, and I have no wish to impede them. One obvious solution, that would inconvenience no-one else, would be to add the <pre> tags yourself. If you wish your comments to be essentially a plain-text format, but still to render nicely in HTML, then I suggest you look into markdown http://daringfireball.net/projects/markdown/ and in particular its implementation in Haskell called pandoc http://johnmacfarlane.net/pandoc/ Pandoc does syntax highlighting for Haskell (and other languages), using the highlighting-kate package, rather than HsColour. Regards, Malcolm

On Mon, 2009-08-24 at 18:30 +0100, Malcolm Wallace wrote:
I'd like the format of the comments to stay the same as in the file. The easiest way I suppose is to wrap <pre> tags around them. That's all I meant.
Now I understand. The literate file format is designed for you to use your own markup for the commentary. In particular, many people use real HTML tags (or LaTeX commands etc) for the comments, and I have no wish to impede them. One obvious solution, that would inconvenience no-one else, would be to add the <pre> tags yourself.
Malcolm, this is all true but we need some sensible default case, eg for all the source links in the hackage docs in the case where people are not using any specific markup. If there were a "pre" mode then I think this would be the default that Cabal should use (since it currently does not know any more detail about what form the .lhs files are). Duncan

I'd like the format of the comments to stay the same as in the file. The easiest way I suppose is to wrap <pre> tags around them.
we need some sensible default case, eg for all the source links in the hackage docs in the case where people are not using any specific markup. If there were a "pre" mode then I think this would be the default that Cabal should use (since it currently does not know any more detail about what form the .lhs files are).
OK, if there is demand of more than one, then I can add a new option. :-) Regards, Malcolm
participants (3)
-
Duncan Coutts
-
Malcolm Wallace
-
Sean McLaughlin