Haddock code block problems
Simon Marlow
simonmar@microsoft.com
Tue, 6 May 2003 11:11:35 +0100
=20
> I'm using the latest Haddock release (0.4) and seem to
> be having a lot of trouble getting line breaks to appear
> in code blocks. I've tried it so many ways that if I
> were to enumerate them all this would be a very long email.
> I can't find any consistency in when it decides to work
> (occasionally) and when it doesn't (usually). Here's
> some examples..
>=20
> This gives no line breaks:
> {-$CStuff
> @
> test f [] =3D 0
> test f (x:xs) =3D 0
> @
> -}
>=20
> Neither does this:
> {-$CStuff
> >test f [] =3D 0
> >test f (x:xs) =3D 0
> -}
This is a result of the fact that Haddock removes the <p>..</p> around
single paragraphs to eliminate extra whitespace around short
documentation comments. In the same vein it turns a single code
paragraph, normally <pre>..</pre>, into <tt>..</tt>, which has the side
effect of removing line breaks. On reflection that seems to be the
wrong thing to do, so I'll change the behaviour for the next release.
> This gives a parse error:-(
> {-$CStuff
> @
> test f [] =3D 0
> test f (x:xs) =3D 0
> @
> >test f [] =3D 0
> >test f (x:xs) =3D 0
> -}
because there's no paragraph break between these paragraphs. A
paragraph break is two consecutive newlines.
> This doesn't, but still no line breaks.
> {-$CStuff
> >test f [] =3D 0
> >test f (x:xs) =3D 0
> @
> test f [] =3D 0
> test f (x:xs) =3D 0
> @
> -}
That's a bug (one that I'm aware of). I'm planning to rewrite Haddock's
lexer using Alex and get rid of this strange behaviour at the same time.
> This gives me line breaks at the end of each birdtracked
> line (only).
> {-$CStuff
> >test f [] =3D 0
> >test f (x:xs) =3D 0
>=20
> @
> test f [] =3D 0
> test f (x:xs) =3D 0
> @
> -}
Urk, that's just a bug. Thanks!
Cheers,
Simon